[FFmpeg-devel] [PATCH 3/3] swscale: ayuv16le output support

Paul B Mahol onemda at gmail.com
Fri Jul 3 18:16:33 CEST 2015


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libswscale/output.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 libswscale/utils.c  |  2 +-
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/libswscale/output.c b/libswscale/output.c
index 09e3369..042b36f 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -2008,6 +2008,51 @@ yuv2ya8_X_c(SwsContext *c, const int16_t *lumFilter,
     }
 }
 
+static void
+yuv2ayuv16le_X_c(SwsContext *c, const int16_t *lumFilter,
+                 const int32_t **lumSrc, int lumFilterSize,
+                 const int16_t *chrFilter, const int32_t **chrUSrc,
+                 const int32_t **chrVSrc, int chrFilterSize,
+                 const int32_t **alpSrc, uint8_t *dest, int dstW, int y)
+{
+    int hasAlpha = !!alpSrc;
+    int i;
+
+    for (i = 0; i < dstW; i++) {
+        int Y = 1 << 14, U = 1 << 14;
+        int V = 1 << 14, A = 1 << 14;
+        int j;
+
+        Y -= 0x40000000;
+        U -= 0x40000000;
+        V -= 0x40000000;
+        A -= 0x40000000;
+
+        for (j = 0; j < lumFilterSize; j++)
+            Y += lumSrc[j][i] * (unsigned)lumFilter[j];
+
+        for (j = 0; j < chrFilterSize; j++)
+            U += chrUSrc[j][i] * (unsigned)chrFilter[j];
+
+        for (j = 0; j < chrFilterSize; j++)
+            V += chrVSrc[j][i] * (unsigned)chrFilter[j];
+
+        if (hasAlpha)
+            for (j = 0; j < lumFilterSize; j++)
+                A += alpSrc[j][i] * (unsigned)lumFilter[j];
+
+        Y = 0x8000 + av_clip_int16(Y >> 15);
+        U = 0x8000 + av_clip_int16(U >> 15);
+        V = 0x8000 + av_clip_int16(V >> 15);
+        A = 0x8000 + av_clip_int16(A >> 15);
+
+        AV_WL16(dest + 8 * i, hasAlpha ? A : 65535);
+        AV_WL16(dest + 8 * i + 2, Y);
+        AV_WL16(dest + 8 * i + 4, U);
+        AV_WL16(dest + 8 * i + 6, V);
+    }
+}
+
 av_cold void ff_sws_init_output_funcs(SwsContext *c,
                                       yuv2planar1_fn *yuv2plane1,
                                       yuv2planarX_fn *yuv2planeX,
@@ -2457,5 +2502,8 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
         *yuv2packed2 = yuv2ya8_2_c;
         *yuv2packedX = yuv2ya8_X_c;
         break;
+    case AV_PIX_FMT_AYUV16LE:
+        *yuv2packedX = yuv2ayuv16le_X_c;
+        break;
     }
 }
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 3561f7b..e4e9197 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -224,7 +224,7 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
     [AV_PIX_FMT_BAYER_GRBG16LE] = { 1, 0 },
     [AV_PIX_FMT_BAYER_GRBG16BE] = { 1, 0 },
     [AV_PIX_FMT_XYZ12BE]     = { 1, 1, 1 },
-    [AV_PIX_FMT_AYUV16LE]    = { 1, 0},
+    [AV_PIX_FMT_AYUV16LE]    = { 1, 1},
 };
 
 int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list