[FFmpeg-devel] [PATCH] libswscale: GBRAP input & output and GBRAP16 input support

Paul B Mahol onemda at gmail.com
Mon May 6 17:39:57 CEST 2013


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libswscale/input.c   | 9 ++++++++-
 libswscale/output.c  | 9 ++++++++-
 libswscale/swscale.c | 2 +-
 libswscale/utils.c   | 6 +++---
 4 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/libswscale/input.c b/libswscale/input.c
index 5259603..608edd5 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -923,6 +923,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_GBRP14LE:
         c->readChrPlanar = planar_rgb14le_to_uv;
         break;
+    case AV_PIX_FMT_GBRAP16LE:
     case AV_PIX_FMT_GBRP16LE:
         c->readChrPlanar = planar_rgb16le_to_uv;
         break;
@@ -938,9 +939,11 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_GBRP14BE:
         c->readChrPlanar = planar_rgb14be_to_uv;
         break;
+    case AV_PIX_FMT_GBRAP16BE:
     case AV_PIX_FMT_GBRP16BE:
         c->readChrPlanar = planar_rgb16be_to_uv;
         break;
+    case AV_PIX_FMT_GBRAP:
     case AV_PIX_FMT_GBRP:
         c->readChrPlanar = planar_rgb_to_uv;
         break;
@@ -1043,7 +1046,8 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
         case AV_PIX_FMT_BGR555BE:
             c->chrToYV12 = bgr15beToUV_half_c;
             break;
-        case AV_PIX_FMT_GBR24P  :
+        case AV_PIX_FMT_GBRAP:
+        case AV_PIX_FMT_GBRP:
             c->chrToYV12 = gbr24pToUV_half_c;
             break;
         case AV_PIX_FMT_BGR444LE:
@@ -1172,6 +1176,7 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_GBRP14LE:
         c->readLumPlanar = planar_rgb14le_to_y;
         break;
+    case AV_PIX_FMT_GBRAP16LE:
     case AV_PIX_FMT_GBRP16LE:
         c->readLumPlanar = planar_rgb16le_to_y;
         break;
@@ -1187,9 +1192,11 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_GBRP14BE:
         c->readLumPlanar = planar_rgb14be_to_y;
         break;
+    case AV_PIX_FMT_GBRAP16BE:
     case AV_PIX_FMT_GBRP16BE:
         c->readLumPlanar = planar_rgb16be_to_y;
         break;
+    case AV_PIX_FMT_GBRAP:
     case AV_PIX_FMT_GBRP:
         c->readLumPlanar = planar_rgb_to_y;
         break;
diff --git a/libswscale/output.c b/libswscale/output.c
index da760d2..9669b45 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -1495,7 +1495,7 @@ yuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter,
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->dstFormat);
     int i;
-    int hasAlpha = 0;
+    int hasAlpha = (desc->flags & PIX_FMT_ALPHA) && alpSrc;
     uint16_t **dest16 = (uint16_t**)dest;
     int SH = 22 + 7 - desc->comp[0].depth_minus1;
 
@@ -1547,10 +1547,14 @@ yuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter,
             dest16[0][i] = G >> SH;
             dest16[1][i] = B >> SH;
             dest16[2][i] = R >> SH;
+            if (hasAlpha)
+                dest16[3][i] = A;
         } else {
             dest[0][i] = G >> 22;
             dest[1][i] = B >> 22;
             dest[2][i] = R >> 22;
+            if (hasAlpha)
+                dest[3][i] = A;
         }
     }
     if (SH != 22 && (!isBE(c->dstFormat)) != (!HAVE_BIGENDIAN)) {
@@ -1558,6 +1562,8 @@ yuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter,
             dest16[0][i] = av_bswap16(dest16[0][i]);
             dest16[1][i] = av_bswap16(dest16[1][i]);
             dest16[2][i] = av_bswap16(dest16[2][i]);
+            if (hasAlpha)
+                dest16[3][i] = av_bswap16(dest16[3][i]);
         }
     }
 }
@@ -1722,6 +1728,7 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
         case AV_PIX_FMT_GBRP14LE:
         case AV_PIX_FMT_GBRP16BE:
         case AV_PIX_FMT_GBRP16LE:
+        case AV_PIX_FMT_GBRAP:
             *yuv2anyX = yuv2gbrp_full_X_c;
             break;
         }
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index c34c56c..74aba82 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -668,7 +668,7 @@ static int swScale(SwsContext *c, const uint8_t *src[],
                          lumSrcPtr, vLumFilterSize,
                          vChrFilter + dstY * vChrFilterSize,
                          chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
-                         alpSrcPtr, dest, dstW, dstY);
+                         alpPixBuf ? alpSrcPtr : NULL, dest, dstW, dstY);
             }
         }
     }
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 1ce9576..562b225 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -198,9 +198,9 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
     [AV_PIX_FMT_GBRP16BE]    = { 1, 0 },
     [AV_PIX_FMT_XYZ12BE]     = { 1, 0 },
     [AV_PIX_FMT_XYZ12LE]     = { 1, 0 },
-    [AV_PIX_FMT_GBRAP]       = { 0, 0 },
-    [AV_PIX_FMT_GBRAP16LE]   = { 0, 0 },
-    [AV_PIX_FMT_GBRAP16BE]   = { 0, 0 },
+    [AV_PIX_FMT_GBRAP]       = { 1, 1 },
+    [AV_PIX_FMT_GBRAP16LE]   = { 1, 0 },
+    [AV_PIX_FMT_GBRAP16BE]   = { 1, 0 },
 };
 
 int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list