[FFmpeg-devel] [PATCH] swsscale/swscale_unscaled: add GBRAP16

Paul B Mahol onemda at gmail.com
Thu Oct 10 20:24:23 CEST 2013


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libswscale/swscale_unscaled.c | 43 ++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 38 insertions(+), 5 deletions(-)

diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 8fb2157..fb8c7a5 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -401,7 +401,7 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
 
         switch(swap) {
         case 3:
-            if (alpha) {
+            if (alpha && !src[3]) {
                 for (x = 0; x < width; x++) {
                     component = av_bswap16(src[0][x]);
                     *dest++ = av_bswap16(component << scale_high | component >> scale_low);
@@ -411,6 +411,17 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
                     *dest++ = av_bswap16(component << scale_high | component >> scale_low);
                     *dest++ = 0xffff;
                 }
+            } else if (alpha && src[3]) {
+                for (x = 0; x < width; x++) {
+                    component = av_bswap16(src[0][x]);
+                    *dest++ = av_bswap16(component << scale_high | component >> scale_low);
+                    component = av_bswap16(src[1][x]);
+                    *dest++ = av_bswap16(component << scale_high | component >> scale_low);
+                    component = av_bswap16(src[2][x]);
+                    *dest++ = av_bswap16(component << scale_high | component >> scale_low);
+                    component = av_bswap16(src[3][x]);
+                    *dest++ = av_bswap16(component << scale_high | component >> scale_low);
+                }
             } else {
                 for (x = 0; x < width; x++) {
                     component = av_bswap16(src[0][x]);
@@ -423,13 +434,20 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
             }
             break;
         case 2:
-            if (alpha) {
+            if (alpha && !src[3]) {
                 for (x = 0; x < width; x++) {
                     *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
                     *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
                     *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
                     *dest++ = 0xffff;
                 }
+            } else if (alpha && src[3]) {
+                for (x = 0; x < width; x++) {
+                    *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
+                    *dest++ = av_bswap16(src[1][x] << scale_high | src[1][x] >> scale_low);
+                    *dest++ = av_bswap16(src[2][x] << scale_high | src[2][x] >> scale_low);
+                    *dest++ = av_bswap16(src[3][x] << scale_high | src[3][x] >> scale_low);
+                }
             } else {
                 for (x = 0; x < width; x++) {
                     *dest++ = av_bswap16(src[0][x] << scale_high | src[0][x] >> scale_low);
@@ -439,13 +457,20 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
             }
             break;
         case 1:
-            if (alpha) {
+            if (alpha && !src[3]) {
                 for (x = 0; x < width; x++) {
                     *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
                     *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
                     *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
                     *dest++ = 0xffff;
                 }
+            } else if (alpha && src[3]) {
+                for (x = 0; x < width; x++) {
+                    *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
+                    *dest++ = av_bswap16(src[1][x]) << scale_high | av_bswap16(src[1][x]) >> scale_low;
+                    *dest++ = av_bswap16(src[2][x]) << scale_high | av_bswap16(src[2][x]) >> scale_low;
+                    *dest++ = av_bswap16(src[3][x]) << scale_high | av_bswap16(src[3][x]) >> scale_low;
+                }
             } else {
                 for (x = 0; x < width; x++) {
                     *dest++ = av_bswap16(src[0][x]) << scale_high | av_bswap16(src[0][x]) >> scale_low;
@@ -455,13 +480,20 @@ static void gbr16ptopacked16(const uint16_t *src[], int srcStride[],
             }
             break;
         default:
-            if (alpha) {
+            if (alpha && !src[3]) {
                 for (x = 0; x < width; x++) {
                     *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
                     *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
                     *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
                     *dest++ = 0xffff;
                 }
+            } else if (alpha && src[3]) {
+                for (x = 0; x < width; x++) {
+                    *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
+                    *dest++ = src[1][x] << scale_high | src[1][x] >> scale_low;
+                    *dest++ = src[2][x] << scale_high | src[2][x] >> scale_low;
+                    *dest++ = src[3][x] << scale_high | src[3][x] >> scale_low;
+                }
             } else {
                 for (x = 0; x < width; x++) {
                     *dest++ = src[0][x] << scale_high | src[0][x] >> scale_low;
@@ -1225,7 +1257,8 @@ void ff_get_unscaled_swscale(SwsContext *c)
          srcFormat == AV_PIX_FMT_GBRP16LE || srcFormat == AV_PIX_FMT_GBRP16BE ||
          srcFormat == AV_PIX_FMT_GBRP10LE || srcFormat == AV_PIX_FMT_GBRP10BE ||
          srcFormat == AV_PIX_FMT_GBRP12LE || srcFormat == AV_PIX_FMT_GBRP12BE ||
-         srcFormat == AV_PIX_FMT_GBRP14LE || srcFormat == AV_PIX_FMT_GBRP14BE) &&
+         srcFormat == AV_PIX_FMT_GBRP14LE || srcFormat == AV_PIX_FMT_GBRP14BE ||
+         srcFormat == AV_PIX_FMT_GBRAP16LE || srcFormat == AV_PIX_FMT_GBRAP16BE) &&
         (dstFormat == AV_PIX_FMT_RGB48LE  || dstFormat == AV_PIX_FMT_RGB48BE  ||
          dstFormat == AV_PIX_FMT_BGR48LE  || dstFormat == AV_PIX_FMT_BGR48BE  ||
          dstFormat == AV_PIX_FMT_RGBA64LE || dstFormat == AV_PIX_FMT_RGBA64BE ||
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list