From 17a31a220d43fc375fcc61177c4b18735668e9ce Mon Sep 17 00:00:00 2001 From: James Almer Date: Tue, 15 Oct 2024 14:34:11 -0300 Subject: [PATCH] swscale/output: add X36VBE output support Signed-off-by: James Almer Signed-off-by: Paul B Mahol --- libswscale/output.c | 46 +++++++++++++++++++----- libswscale/utils.c | 2 +- tests/ref/fate/filter-pixdesc-xv36be | 1 + tests/ref/fate/filter-pixfmts-copy | 1 + tests/ref/fate/filter-pixfmts-crop | 1 + tests/ref/fate/filter-pixfmts-field | 1 + tests/ref/fate/filter-pixfmts-fieldorder | 1 + tests/ref/fate/filter-pixfmts-hflip | 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-transpose | 1 + tests/ref/fate/filter-pixfmts-vflip | 1 + 13 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 tests/ref/fate/filter-pixdesc-xv36be diff --git a/libswscale/output.c b/libswscale/output.c index 3b954e28a2..c46ac51099 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -2661,12 +2661,19 @@ static void yuv2 ## name ## _X_c(SwsContext *c, const int16_t *lumFilter, \ V30LE_WRAPPER(xv30le, 0) V30LE_WRAPPER(v30xle, 2) +#define output_pixels(pos, val, shift, bits, output_shift) \ + if (is_be) { \ + AV_WB16(pos, av_clip_uintp2(val >> shift, bits) << output_shift); \ + } else { \ + AV_WL16(pos, av_clip_uintp2(val >> shift, bits) << output_shift); \ + } + static void -yuv2xv36le_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) +yuv2xv36_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, int is_be) { int i; for (i = 0; i < dstW; i++) { @@ -2681,13 +2688,31 @@ yuv2xv36le_X_c(SwsContext *c, const int16_t *lumFilter, V += chrVSrc[j][i] * chrFilter[j]; } - AV_WL16(dest + 8 * i + 2, av_clip_uintp2(Y >> 15, 12) << 4); - AV_WL16(dest + 8 * i + 0, av_clip_uintp2(U >> 15, 12) << 4); - AV_WL16(dest + 8 * i + 4, av_clip_uintp2(V >> 15, 12) << 4); - AV_WL16(dest + 8 * i + 6, A << 4); + output_pixels(dest + 8 * i + 2, Y, 15, 12, 4) + output_pixels(dest + 8 * i + 0, U, 15, 12, 4) + output_pixels(dest + 8 * i + 4, V, 15, 12, 4) + AV_WN16(dest + 8 * i + 6, A << 4); } } +#undef output_pixels + +#define YUV2XV36(BE_LE, is_be) \ +static void \ +yuv2xv36 ## BE_LE ##_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) \ +{ \ + yuv2xv36_X_c(c, lumFilter, lumSrc, lumFilterSize, \ + chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ + alpSrc, dest, dstW, y, is_be); \ +} + +YUV2XV36(le, 0) +YUV2XV36(be, 1) + #define output_pixels(pos, A, Y, U, V) \ if (target == AV_PIX_FMT_AYUV) { \ dest[pos + 0] = A; \ @@ -3594,6 +3619,9 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, case AV_PIX_FMT_XV36LE: *yuv2packedX = yuv2xv36le_X_c; break; + case AV_PIX_FMT_XV36BE: + *yuv2packedX = yuv2xv36be_X_c; + break; case AV_PIX_FMT_Y210LE: *yuv2packedX = yuv2y210le_X_c; break; diff --git a/libswscale/utils.c b/libswscale/utils.c index f4e2cc3e55..b0705014dd 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -272,7 +272,7 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_RGBF32LE] = { 1, 0 }, [AV_PIX_FMT_XV30LE] = { 1, 1 }, [AV_PIX_FMT_XV36LE] = { 1, 1 }, - [AV_PIX_FMT_XV36BE] = { 1, 0 }, + [AV_PIX_FMT_XV36BE] = { 1, 1 }, [AV_PIX_FMT_AYUV] = { 1, 1 }, [AV_PIX_FMT_UYVA] = { 1, 1 }, [AV_PIX_FMT_VYU444] = { 1, 1 }, diff --git a/tests/ref/fate/filter-pixdesc-xv36be b/tests/ref/fate/filter-pixdesc-xv36be new file mode 100644 index 0000000000..76929c3ea7 --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-xv36be @@ -0,0 +1 @@ +pixdesc-xv36be 94d17b770b2a519e30952bdeb4e46391 diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy index 8bff815408..7e1259d182 100644 --- a/tests/ref/fate/filter-pixfmts-copy +++ b/tests/ref/fate/filter-pixfmts-copy @@ -106,6 +106,7 @@ vyu444 93912234400a4373b1a6b5c4e4b1a4ef x2bgr10le 550c0d190cf695afa4eaacb644db6b75 x2rgb10le c1e3ac21be04a16bb157b22784524520 xv30le 718bf036d13f9f1ea8804c2658dd53fa +xv36be 502f8a04f496740c0ebf82bce35e6a9d xv36le e08dcbde02f1c28a3554f372ad1278e2 xyz12be a1ef56bf746d71f59669c28e48fc8450 xyz12le 831ff03c1ba4ef19374686f16a064d8c diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop index c4ca776ade..77cf1cf482 100644 --- a/tests/ref/fate/filter-pixfmts-crop +++ b/tests/ref/fate/filter-pixfmts-crop @@ -103,6 +103,7 @@ vyu444 5d976b25782ff69e4b3b18453fa1447b x2bgr10le 84de725b85662c362862820dc4a309aa x2rgb10le f4265aca7a67dbfa9354370098ca6f33 xv30le efebde9ca614024cd7ed95c7c02e9281 +xv36be 888aa586193b6e96dd6b9350503dad99 xv36le 778286003497f92b84d0bd8258d6b85d xyz12be cb4571f9aaa7b59f999ef327276104b7 xyz12le cd6aae8d26b18bdb4b9d068586276d91 diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field index 67ebe64c4f..0b62b37f4d 100644 --- a/tests/ref/fate/filter-pixfmts-field +++ b/tests/ref/fate/filter-pixfmts-field @@ -106,6 +106,7 @@ vyu444 b139fb4ddaef12a7542a68277211efa7 x2bgr10le dbe21538d7cb1744914f6bd46ec09b55 x2rgb10le a18bc4ae5274e0a8cca9137ecd50c677 xv30le 298f6f14c5bfc18587cd1c3225287a39 +xv36be f6b7e1b437aaf1c9d1c69b095779fd4e xv36le ba99f258370f2a56993e8760e6b30194 xyz12be d2fa69ec91d3ed862f2dac3f8e7a3437 xyz12le 02bccd5e0b6824779a1f848b0ea3e3b5 diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder index 91106cbf39..497b3299b5 100644 --- a/tests/ref/fate/filter-pixfmts-fieldorder +++ b/tests/ref/fate/filter-pixfmts-fieldorder @@ -95,6 +95,7 @@ vyu444 3ddab207d561a3ee5efae09e504207f2 x2bgr10le 86474d84f26c5c51d6f75bf7e1de8da8 x2rgb10le cdf6a9e8a8d081aa768c6ae2e6221676 xv30le bfd6693b5e995f65b130d963a972c34e +xv36be e99aece2ae4edc6da58067810452afb6 xv36le bcceffc985aaa8414c4b8072aa0889bd xyz12be 15f5cda71de5fef9cec5e75e3833b6bc xyz12le 7be6c8781f38c21a6b8f602f62ca31e6 diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip index 18b9fe76fe..a27d241d60 100644 --- a/tests/ref/fate/filter-pixfmts-hflip +++ b/tests/ref/fate/filter-pixfmts-hflip @@ -103,6 +103,7 @@ vyu444 7b72337f92a7223fd115265e2f769276 x2bgr10le 827cc659f29378e00c5a7d2c0ada8f9a x2rgb10le d4a8189b65395a88d0a38a7053f3359f xv30le 79c6fe0c957d4fdc7bd6d056b13d7ceb +xv36be 2abe7272fffa70d1bf836b6235508091 xv36le e478b4b54698beb3ce1b9a2dd691d544 xyz12be 25f90259ff8a226befdaec3dfe82996e xyz12le 926c0791d59aaff61b2778e8ada3316d diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il index 02f7021f45..c58560d521 100644 --- a/tests/ref/fate/filter-pixfmts-il +++ b/tests/ref/fate/filter-pixfmts-il @@ -105,6 +105,7 @@ vyu444 50e9e24a38afc81541a536d06aab5ebe x2bgr10le 135acaff8318cf9861bb0f7849a9e5e9 x2rgb10le 517fb186f523dc7cdc5c5c6967cfbe94 xv30le b18e762bfc505cdd51bac3401c019613 +xv36be 014de4ca53607cf7c676161063b3a2ac xv36le 102c0e817d375ddd6b2cfbb4262dec95 xyz12be 7c7d54c55f136cbbc50b18029f3be0b3 xyz12le 090ba6b1170baf2b1358b43b971d33b0 diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null index 8bff815408..7e1259d182 100644 --- a/tests/ref/fate/filter-pixfmts-null +++ b/tests/ref/fate/filter-pixfmts-null @@ -106,6 +106,7 @@ vyu444 93912234400a4373b1a6b5c4e4b1a4ef x2bgr10le 550c0d190cf695afa4eaacb644db6b75 x2rgb10le c1e3ac21be04a16bb157b22784524520 xv30le 718bf036d13f9f1ea8804c2658dd53fa +xv36be 502f8a04f496740c0ebf82bce35e6a9d xv36le e08dcbde02f1c28a3554f372ad1278e2 xyz12be a1ef56bf746d71f59669c28e48fc8450 xyz12le 831ff03c1ba4ef19374686f16a064d8c diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale index d2fbf442c9..6ec7e7901e 100644 --- a/tests/ref/fate/filter-pixfmts-scale +++ b/tests/ref/fate/filter-pixfmts-scale @@ -106,6 +106,7 @@ vyu444 d663334119da56e36aca1e8e4eb29a39 x2bgr10le d57b9a99033cc7b65ddd111578f2d385 x2rgb10le d56bdb23fa6a8e12a0b4394987f89935 xv30le aaee6b4eff276709715fa83073ae87a4 +xv36be 59388bd217c05744e702c00a68f0a297 xv36le de9c74e94dc19c828e1572aa283d8aca xyz12be c7ba8345998c0141ddc079cdd29b1a40 xyz12le 95f5d3a0de834cc495c9032a14987cde diff --git a/tests/ref/fate/filter-pixfmts-transpose b/tests/ref/fate/filter-pixfmts-transpose index 6867c20eff..c240bb4d5e 100644 --- a/tests/ref/fate/filter-pixfmts-transpose +++ b/tests/ref/fate/filter-pixfmts-transpose @@ -95,6 +95,7 @@ vyu444 e70a294738165223928fddc9970b8381 x2bgr10le 4aa774b6d8f6d446a64f1f288e5c97eb x2rgb10le 09cb1d98fe17ad8a6d9d3bec97ddc845 xv30le da27f069e340e756a9bb29f628ed06d1 +xv36be 1b4166ba6cdcfc935763651105121002 xv36le 9202133de91bf64c76ca27d5cd0c816a xyz12be 68e5cba640f6e4ef72dff950e88b5342 xyz12le 8b6b6a6db4d7561e80db88ccaecce7a9 diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip index 945a776a24..b401da4a25 100644 --- a/tests/ref/fate/filter-pixfmts-vflip +++ b/tests/ref/fate/filter-pixfmts-vflip @@ -106,6 +106,7 @@ vyu444 815de7c57dc8afafb3de908a4a280582 x2bgr10le 795b66a5fc83cd2cf300aae51c230f80 x2rgb10le 262c502230cf3724f8e2cf4737f18a42 xv30le 2cb6ce5f744b33d53cd39a2ea2ab00f3 +xv36be 079c30b035dae1a0a9d54753334aad30 xv36le ffe6ab75ebc09134c3451f8f6ef0d501 xyz12be 23fa9fb36d49dce61e284d41b83e0e6b xyz12le ef73e6d1f932a9a355df1eedd628394f