[FFmpeg-devel] [PATCH 3/6] swscale/output: add Y216LE output support

James Almer jamrial at gmail.com
Tue Oct 22 15:48:44 EEST 2024


Signed-off-by: James Almer <jamrial at gmail.com>
---
 libswscale/output.c                      | 44 ++++++++++++++++++++++++
 libswscale/utils.c                       |  2 +-
 tests/ref/fate/filter-pixdesc-y216le     |  1 +
 tests/ref/fate/filter-pixfmts-copy       |  1 +
 tests/ref/fate/filter-pixfmts-field      |  1 +
 tests/ref/fate/filter-pixfmts-fieldorder |  1 +
 tests/ref/fate/filter-pixfmts-il         |  1 +
 tests/ref/fate/filter-pixfmts-null       |  1 +
 tests/ref/fate/filter-pixfmts-scale      |  1 +
 tests/ref/fate/filter-pixfmts-vflip      |  1 +
 10 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/filter-pixdesc-y216le

diff --git a/libswscale/output.c b/libswscale/output.c
index c95ccdfc36..b4e66606c6 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -2983,6 +2983,47 @@ AYUVPACKEDWRAPPER(uyva, AV_PIX_FMT_UYVA)
 yuv2y2xx_wrapper(10)
 yuv2y2xx_wrapper(12)
 
+static void
+yuv2y216le_X_c(SwsContext *c, const int16_t *lumFilter,
+               const int16_t **_lumSrc, int lumFilterSize,
+               const int16_t *chrFilter,
+               const int16_t **_chrUSrc,
+               const int16_t **_chrVSrc, int chrFilterSize,
+               const int16_t **_alpSrc,
+               uint8_t *dest, int dstW, int y)
+{
+    const int32_t **lumSrc  = (const int32_t **)_lumSrc;
+    const int32_t **chrUSrc = (const int32_t **)_chrUSrc;
+    const int32_t **chrVSrc = (const int32_t **)_chrVSrc;
+    int shift = 15;
+
+    for (int i = 0; i < ((dstW + 1) >> 1); i++) {
+        int Y1 = 1 << (shift - 1), Y2 = 1 << (shift - 1);
+        int U  = 1 << (shift - 1), V  = 1 << (shift - 1);
+
+        /* See yuv2planeX_16_c_template for details. */
+        Y1 -= 0x40000000;
+        U  -= 0x40000000;
+        Y2 -= 0x40000000;
+        V  -= 0x40000000;
+
+        for (int j = 0; j < lumFilterSize; j++) {
+            Y1 += lumSrc[j][i * 2]     * (unsigned)lumFilter[j];
+            Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
+        }
+
+        for (int j = 0; j < chrFilterSize; j++) {
+            U += chrUSrc[j][i] * (unsigned)chrFilter[j];
+            V += chrVSrc[j][i] * (unsigned)chrFilter[j];
+        }
+
+        AV_WL16(dest + 8 * i + 0, 0x8000 + av_clip_int16(Y1 >> shift));
+        AV_WL16(dest + 8 * i + 2, 0x8000 + av_clip_int16(U  >> shift));
+        AV_WL16(dest + 8 * i + 4, 0x8000 + av_clip_int16(Y2 >> shift));
+        AV_WL16(dest + 8 * i + 6, 0x8000 + av_clip_int16(V  >> shift));
+    }
+}
+
 static void
 yuv2vyu444_1_c(SwsContext *c, const int16_t *buf0,
                const int16_t *ubuf[2], const int16_t *vbuf[2],
@@ -3656,5 +3697,8 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
     case AV_PIX_FMT_Y212LE:
         *yuv2packedX = yuv2y212le_X_c;
         break;
+    case AV_PIX_FMT_Y216LE:
+        *yuv2packedX = yuv2y216le_X_c;
+        break;
     }
 }
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 25ed05afee..dc0cdb52d4 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -248,7 +248,7 @@ static const FormatEntry format_entries[] = {
     [AV_PIX_FMT_NV42]        = { 1, 1 },
     [AV_PIX_FMT_Y210LE]      = { 1, 1 },
     [AV_PIX_FMT_Y212LE]      = { 1, 1 },
-    [AV_PIX_FMT_Y216LE]      = { 1, 0 },
+    [AV_PIX_FMT_Y216LE]      = { 1, 1 },
     [AV_PIX_FMT_X2RGB10LE]   = { 1, 1 },
     [AV_PIX_FMT_X2BGR10LE]   = { 1, 1 },
     [AV_PIX_FMT_P210BE]      = { 1, 1 },
diff --git a/tests/ref/fate/filter-pixdesc-y216le b/tests/ref/fate/filter-pixdesc-y216le
new file mode 100644
index 0000000000..dd80ad0ad4
--- /dev/null
+++ b/tests/ref/fate/filter-pixdesc-y216le
@@ -0,0 +1 @@
+pixdesc-y216le      ff17fa6e341a5cfe0d549faa25c24257
diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy
index bda10f2519..335eac9ad3 100644
--- a/tests/ref/fate/filter-pixfmts-copy
+++ b/tests/ref/fate/filter-pixfmts-copy
@@ -113,6 +113,7 @@ xyz12be             a1ef56bf746d71f59669c28e48fc8450
 xyz12le             831ff03c1ba4ef19374686f16a064d8c
 y210le              0736b017e0814daf38d3350c42796f7a
 y212le              825768be8fe92708ae80be84855066ed
+y216le              610cc638e695eb64f3004cc5f24c5a7b
 ya16be              37c07787e544f900c87b853253bfc8dd
 ya16le              e8cab8fad88cba6d285b224d8bf0d4df
 ya8                 dbb99fbcdc204aaa1a7397ff561f1a67
diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field
index b64af6d39f..0ecfa34e64 100644
--- a/tests/ref/fate/filter-pixfmts-field
+++ b/tests/ref/fate/filter-pixfmts-field
@@ -113,6 +113,7 @@ xyz12be             d2fa69ec91d3ed862f2dac3f8e7a3437
 xyz12le             02bccd5e0b6824779a1f848b0ea3e3b5
 y210le              025beb25f047a762e3788dbea4b60864
 y212le              ac2a47c45187dd54d0f55293cbffd954
+y216le              332801737b0f779bdf14ff535fd925fd
 ya16be              40403b5277364777e0671da4d38e01ac
 ya16le              54f3295f5326a13d456ac53e973ba398
 ya8                 28cea4f98ed452bd3da9c752e5e3399c
diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder
index f99baf036f..4e7a8c5f43 100644
--- a/tests/ref/fate/filter-pixfmts-fieldorder
+++ b/tests/ref/fate/filter-pixfmts-fieldorder
@@ -102,6 +102,7 @@ xyz12be             15f5cda71de5fef9cec5e75e3833b6bc
 xyz12le             7be6c8781f38c21a6b8f602f62ca31e6
 y210le              ee45acfb1386288af98af5313162ff3e
 y212le              2f08fb195b948056c844acb1eee8d649
+y216le              4176a190d167f0f6d7dbca7ff65d3f48
 ya16be              0f13e0f52586d172aaa07710fa3e8f31
 ya16le              d481d93ea1a1a04d759d9994958983de
 ya8                 055ac5ab5ff8533dd319edc17a398af1
diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il
index cc7e535c01..4d2affa190 100644
--- a/tests/ref/fate/filter-pixfmts-il
+++ b/tests/ref/fate/filter-pixfmts-il
@@ -112,6 +112,7 @@ xyz12be             7c7d54c55f136cbbc50b18029f3be0b3
 xyz12le             090ba6b1170baf2b1358b43b971d33b0
 y210le              306ec4238b49dbc8625a97b678ea1c5f
 y212le              d5a2b4677ddb4a3bc3e5cd5cbb20f426
+y216le              ef6d5ebd8bf99809fb8ac658cf7acbf8
 ya16be              7bc720918bc0132e9717acbde89874e0
 ya16le              61203295a8d39601b841de90f2c9797b
 ya8                 a38d6e288f582f1a04310232ed764afc
diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null
index bda10f2519..335eac9ad3 100644
--- a/tests/ref/fate/filter-pixfmts-null
+++ b/tests/ref/fate/filter-pixfmts-null
@@ -113,6 +113,7 @@ xyz12be             a1ef56bf746d71f59669c28e48fc8450
 xyz12le             831ff03c1ba4ef19374686f16a064d8c
 y210le              0736b017e0814daf38d3350c42796f7a
 y212le              825768be8fe92708ae80be84855066ed
+y216le              610cc638e695eb64f3004cc5f24c5a7b
 ya16be              37c07787e544f900c87b853253bfc8dd
 ya16le              e8cab8fad88cba6d285b224d8bf0d4df
 ya8                 dbb99fbcdc204aaa1a7397ff561f1a67
diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale
index f24f8bd58f..8a99cf3fac 100644
--- a/tests/ref/fate/filter-pixfmts-scale
+++ b/tests/ref/fate/filter-pixfmts-scale
@@ -113,6 +113,7 @@ xyz12be             c7ba8345998c0141ddc079cdd29b1a40
 xyz12le             95f5d3a0de834cc495c9032a14987cde
 y210le              1c2708a520477f955d1fedf6ca7a41bd
 y212le              39a3c0c843041ad4501b3107dd91ef17
+y216le              21ead8be695827822e627df20ab49b1f
 ya16be              20d4842899d61068f5fb6af478bf26a6
 ya16le              6a05895adce85143ae1c1b3470cb4070
 ya8                 0a9db5bb4b009de9197eede5e9d19e16
diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip
index fcdc07d4f2..ed8f6980e8 100644
--- a/tests/ref/fate/filter-pixfmts-vflip
+++ b/tests/ref/fate/filter-pixfmts-vflip
@@ -113,6 +113,7 @@ xyz12be             23fa9fb36d49dce61e284d41b83e0e6b
 xyz12le             ef73e6d1f932a9a355df1eedd628394f
 y210le              9544c81f8e1fc95e9fa4009dbecfea25
 y212le              c801725ae31e3b8f5be269359d49f191
+y216le              0ca0f60d7fd78ec32f417d6209f18a5b
 ya16be              55b1dbbe4d56ed0d22461685ce85520d
 ya16le              d5bf02471823a16dc523a46cace0101a
 ya8                 4299c6ca3b470a7d8a420e26eb485b1d
-- 
2.47.0



More information about the ffmpeg-devel mailing list