[FFmpeg-devel,2/2] swscale: Add swscale input support for Y210

Submitted by Linjie Fu on Sept. 6, 2019, 9:30 a.m.

Details

Message ID 1567762232-12518-1-git-send-email-linjie.fu@intel.com
State New
Headers show

Commit Message

Linjie Fu Sept. 6, 2019, 9:30 a.m.
Make it possible to convert Y210 to other pixel format.

Also add query support in fate.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
 libswscale/input.c               | 47 ++++++++++++++++++++++++++++++++++++++++
 libswscale/utils.c               |  2 ++
 tests/ref/fate/sws-pixdesc-query |  7 ++++++
 3 files changed, 56 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libswscale/input.c b/libswscale/input.c
index 064f8da..e05ee2c 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -552,6 +552,41 @@  static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, con
     av_assert1(src1 == src2);
 }
 
+static void y210le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
+                        const uint8_t *unused1, int width, uint32_t *unused2)
+{
+    int i;
+    for (i = 0; i < width; i++) {
+        AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 2) >> 6);
+        AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6) >> 6);
+    }
+}
+
+static void y210be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src,
+                        const uint8_t *unused1, int width, uint32_t *unused2)
+{
+    int i;
+    for (i = 0; i < width; i++) {
+        AV_WN16(dstU + i * 2, AV_RB16(src + i * 8 + 2) >> 6);
+        AV_WN16(dstV + i * 2, AV_RB16(src + i * 8 + 6) >> 6);
+    }
+}
+
+static void y210le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0,
+                       const uint8_t *unused1, int width, uint32_t *unused2)
+{
+    int i;
+    for (i = 0; i < width; i++)
+        AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> 6);
+}
+static void y210be_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0,
+                       const uint8_t *unused1, int width, uint32_t *unused2)
+{
+    int i;
+    for (i = 0; i < width; i++)
+        AV_WN16(dst + i * 2 ,AV_RB16(src + i * 4) >> 6);
+}
+
 static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width,
                        uint32_t *unused)
 {
@@ -1154,6 +1189,12 @@  av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_P016BE:
         c->chrToYV12 = p016BEToUV_c;
         break;
+    case AV_PIX_FMT_Y210LE:
+        c->chrToYV12 = y210le_UV_c;
+        break;
+    case AV_PIX_FMT_Y210BE:
+        c->chrToYV12 = y210be_UV_c;
+        break;
     }
     if (c->chrSrcHSubSample) {
         switch (srcFormat) {
@@ -1586,6 +1627,12 @@  av_cold void ff_sws_init_input_funcs(SwsContext *c)
         c->lumToYV12 = grayf32ToY16_bswap_c;
 #endif
         break;
+    case AV_PIX_FMT_Y210LE:
+        c->lumToYV12 = y210le_Y_c;
+        break;
+    case AV_PIX_FMT_Y210BE:
+        c->chrToYV12 = y210be_Y_c;
+        break;
     }
     if (c->needAlpha) {
         if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 1b1f779..2f81fd3 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -266,6 +266,8 @@  static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
     [AV_PIX_FMT_YUVA444P12LE] = { 1, 1 },
     [AV_PIX_FMT_NV24]        = { 1, 1 },
     [AV_PIX_FMT_NV42]        = { 1, 1 },
+    [AV_PIX_FMT_Y210BE]      = { 1, 0 },
+    [AV_PIX_FMT_Y210LE]      = { 1, 0 },
 };
 
 int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query
index e234922..bc9a0d8 100644
--- a/tests/ref/fate/sws-pixdesc-query
+++ b/tests/ref/fate/sws-pixdesc-query
@@ -59,6 +59,8 @@  isNBPS:
   p010le
   xyz12be
   xyz12le
+  y210be
+  y210le
   yuv420p10be
   yuv420p10le
   yuv420p12be
@@ -140,6 +142,7 @@  isBE:
   rgb565be
   rgba64be
   xyz12be
+  y210be
   ya16be
   yuv420p10be
   yuv420p12be
@@ -188,6 +191,8 @@  isYUV:
   uyyvyy411
   xyz12be
   xyz12le
+  y210be
+  y210le
   ya16be
   ya16le
   ya8
@@ -686,6 +691,8 @@  Packed:
   uyyvyy411
   xyz12be
   xyz12le
+  y210be
+  y210le
   ya16be
   ya16le
   ya8