[FFmpeg-devel] [PATCH v1 3/9] swscale: Add swscale input support for P012

Fei Wang fei.w.wang at intel.com
Fri Jun 19 04:52:42 EEST 2020


Signed-off-by: Fei Wang <fei.w.wang at intel.com>
---
 libswscale/input.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++
 libswscale/utils.c |  1 +
 2 files changed, 53 insertions(+)

diff --git a/libswscale/input.c b/libswscale/input.c
index 0bd1aa7bc9..b0a7d21e60 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -739,6 +739,46 @@ static void p010BEToUV_c(uint8_t *dstU, uint8_t *dstV,
     }
 }
 
+static void p012LEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1,
+                        const uint8_t *unused2, int width, uint32_t *unused)
+{
+    int i;
+    for (i = 0; i < width; i++) {
+        AV_WN16(dst + i * 2, AV_RL16(src + i * 2) >> 4);
+    }
+}
+
+static void p012BEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1,
+                        const uint8_t *unused2, int width, uint32_t *unused)
+{
+    int i;
+    for (i = 0; i < width; i++) {
+        AV_WN16(dst + i * 2, AV_RB16(src + i * 2) >> 4);
+    }
+}
+
+static void p012LEToUV_c(uint8_t *dstU, uint8_t *dstV,
+                       const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
+                       int width, uint32_t *unused)
+{
+    int i;
+    for (i = 0; i < width; i++) {
+        AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0) >> 4);
+        AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2) >> 4);
+    }
+}
+
+static void p012BEToUV_c(uint8_t *dstU, uint8_t *dstV,
+                       const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
+                       int width, uint32_t *unused)
+{
+    int i;
+    for (i = 0; i < width; i++) {
+        AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0) >> 4);
+        AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2) >> 4);
+    }
+}
+
 static void p016LEToUV_c(uint8_t *dstU, uint8_t *dstV,
                        const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
                        int width, uint32_t *unused)
@@ -1249,6 +1289,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_P010BE:
         c->chrToYV12 = p010BEToUV_c;
         break;
+    case AV_PIX_FMT_P012LE:
+        c->chrToYV12 = p012LEToUV_c;
+        break;
+    case AV_PIX_FMT_P012BE:
+        c->chrToYV12 = p012BEToUV_c;
+        break;
     case AV_PIX_FMT_P016LE:
         c->chrToYV12 = p016LEToUV_c;
         break;
@@ -1692,6 +1738,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
     case AV_PIX_FMT_P010BE:
         c->lumToYV12 = p010BEToY_c;
         break;
+    case AV_PIX_FMT_P012LE:
+        c->lumToYV12 = p012LEToY_c;
+        break;
+    case AV_PIX_FMT_P012BE:
+        c->lumToYV12 = p012BEToY_c;
+        break;
     case AV_PIX_FMT_GRAYF32LE:
 #if HAVE_BIGENDIAN
         c->lumToYV12 = grayf32ToY16_bswap_c;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index dcd1dbaa76..dd2e3f6a75 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -272,6 +272,7 @@ static const FormatEntry format_entries[] = {
     [AV_PIX_FMT_NV42]        = { 1, 1 },
     [AV_PIX_FMT_Y210LE]      = { 1, 0 },
     [AV_PIX_FMT_X2RGB10LE]   = { 1, 1 },
+    [AV_PIX_FMT_P012LE]      = { 1, 0 },
 };
 
 int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
-- 
2.17.1



More information about the ffmpeg-devel mailing list