From da92f615b66d1d707b87bce337fc83418a9d5cd0 Mon Sep 17 00:00:00 2001 From: James Almer Date: Wed, 23 Oct 2024 13:19:13 -0300 Subject: [PATCH] swscale/output: add XV48 output support Signed-off-by: James Almer Signed-off-by: Paul B Mahol --- libswscale/output.c | 37 +++++++++++++++--------- libswscale/utils.c | 4 +-- libswscale/version.h | 2 +- tests/ref/fate/filter-pixdesc-xv48be | 1 + tests/ref/fate/filter-pixdesc-xv48le | 1 + tests/ref/fate/filter-pixfmts-copy | 2 ++ tests/ref/fate/filter-pixfmts-crop | 2 ++ tests/ref/fate/filter-pixfmts-field | 2 ++ tests/ref/fate/filter-pixfmts-fieldorder | 2 ++ tests/ref/fate/filter-pixfmts-hflip | 2 ++ tests/ref/fate/filter-pixfmts-il | 2 ++ tests/ref/fate/filter-pixfmts-null | 2 ++ tests/ref/fate/filter-pixfmts-scale | 2 ++ tests/ref/fate/filter-pixfmts-transpose | 2 ++ tests/ref/fate/filter-pixfmts-vflip | 2 ++ 15 files changed, 49 insertions(+), 16 deletions(-) create mode 100644 tests/ref/fate/filter-pixdesc-xv48be create mode 100644 tests/ref/fate/filter-pixdesc-xv48le diff --git a/libswscale/output.c b/libswscale/output.c index 0df14e99d6..b37568a10a 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -2577,7 +2577,8 @@ yuv2ayuv64_X_c(SwsInternal *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) + const int16_t **_alpSrc, uint8_t *dest, int dstW, int y, + int A_offset, int Y_offset, int U_offset, int V_offset, int is_be) { const int32_t **lumSrc = (const int32_t **) _lumSrc, **chrUSrc = (const int32_t **) _chrUSrc, @@ -2612,20 +2613,19 @@ yuv2ayuv64_X_c(SwsInternal *c, const int16_t *lumFilter, 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); + if (hasAlpha) + A = 0x8000 + av_clip_int16(A >> 15); - output_pixels(dest + 8 * i, hasAlpha ? A : 65535); - output_pixels(dest + 8 * i + 2, Y); - output_pixels(dest + 8 * i + 4, U); - output_pixels(dest + 8 * i + 6, V); + output_pixels(dest + 8 * i + A_offset, hasAlpha ? A : 65535); + output_pixels(dest + 8 * i + Y_offset, Y); + output_pixels(dest + 8 * i + U_offset, U); + output_pixels(dest + 8 * i + V_offset, V); } } -#undef output_pixels - -#define YUV2AYUV64(BE_LE, is_be) \ +#define YUV2AYUV64(pixfmt, BE_LE, A, Y, U, V, is_be) \ static void \ -yuv2ayuv64 ## BE_LE ##_X_c(SwsInternal *c, const int16_t *lumFilter, \ +yuv2 ## pixfmt ## BE_LE ##_X_c(SwsInternal *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, \ @@ -2633,11 +2633,16 @@ yuv2ayuv64 ## BE_LE ##_X_c(SwsInternal *c, const int16_t *lumFilter, \ { \ yuv2ayuv64_X_c(c, lumFilter, lumSrc, lumFilterSize, \ chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ - alpSrc, dest, dstW, y, is_be); \ + alpSrc, dest, dstW, y, A, Y, U, V, is_be); \ } -YUV2AYUV64(le, 0) -YUV2AYUV64(be, 1) +YUV2AYUV64(ayuv64, le, 0, 2, 4, 6, 0) +YUV2AYUV64(ayuv64, be, 0, 2, 4, 6, 1) + +YUV2AYUV64(xv48, le, 6, 2, 0, 4, 0) +YUV2AYUV64(xv48, be, 6, 2, 0, 4, 1) + +#undef output_pixels static av_always_inline void yuv2v30_X_c_template(SwsInternal *c, const int16_t *lumFilter, @@ -3692,6 +3697,12 @@ av_cold void ff_sws_init_output_funcs(SwsInternal *c, case AV_PIX_FMT_XV36BE: *yuv2packedX = yuv2xv36be_X_c; break; + case AV_PIX_FMT_XV48LE: + *yuv2packedX = yuv2xv48le_X_c; + break; + case AV_PIX_FMT_XV48BE: + *yuv2packedX = yuv2xv48be_X_c; + break; case AV_PIX_FMT_Y210LE: *yuv2packedX = yuv2y210le_X_c; break; diff --git a/libswscale/utils.c b/libswscale/utils.c index db1b010730..87e87269b3 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -277,8 +277,8 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_XV30LE] = { 1, 1 }, [AV_PIX_FMT_XV36LE] = { 1, 1 }, [AV_PIX_FMT_XV36BE] = { 1, 1 }, - [AV_PIX_FMT_XV48LE] = { 1, 0 }, - [AV_PIX_FMT_XV48BE] = { 1, 0 }, + [AV_PIX_FMT_XV48LE] = { 1, 1 }, + [AV_PIX_FMT_XV48BE] = { 1, 1 }, [AV_PIX_FMT_AYUV] = { 1, 1 }, [AV_PIX_FMT_UYVA] = { 1, 1 }, [AV_PIX_FMT_VYU444] = { 1, 1 }, diff --git a/libswscale/version.h b/libswscale/version.h index 109bb5cfd9..41c4181e22 100644 --- a/libswscale/version.h +++ b/libswscale/version.h @@ -29,7 +29,7 @@ #include "version_major.h" #define LIBSWSCALE_VERSION_MINOR 9 -#define LIBSWSCALE_VERSION_MICRO 100 +#define LIBSWSCALE_VERSION_MICRO 101 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ LIBSWSCALE_VERSION_MINOR, \ diff --git a/tests/ref/fate/filter-pixdesc-xv48be b/tests/ref/fate/filter-pixdesc-xv48be new file mode 100644 index 0000000000..9bbbfce6b4 --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-xv48be @@ -0,0 +1 @@ +pixdesc-xv48be 9d848c07ad49d025b9d1421b906ee191 diff --git a/tests/ref/fate/filter-pixdesc-xv48le b/tests/ref/fate/filter-pixdesc-xv48le new file mode 100644 index 0000000000..4b69a41ab2 --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-xv48le @@ -0,0 +1 @@ +pixdesc-xv48le 35c1874574e1cf438ea3e97ef2a5a85e diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy index bd44c34fe0..0ac7ba1d6e 100644 --- a/tests/ref/fate/filter-pixfmts-copy +++ b/tests/ref/fate/filter-pixfmts-copy @@ -109,6 +109,8 @@ x2rgb10le c1e3ac21be04a16bb157b22784524520 xv30le 7dfdd664a9792bb06a19a63353828da0 xv36be 9f556ee59a672fd8725f0bb36ce3e4b0 xv36le e08dcbde02f1c28a3554f372ad1278e2 +xv48be ce34993b4b4411bba1d852b9b86aa39e +xv48le 30b5271d569d1ad6aba916fa5cdf82bd xyz12be a1ef56bf746d71f59669c28e48fc8450 xyz12le 831ff03c1ba4ef19374686f16a064d8c y210le 04e9487b6cce38e7531437e946cdd586 diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop index 25879c4acd..dcb992226c 100644 --- a/tests/ref/fate/filter-pixfmts-crop +++ b/tests/ref/fate/filter-pixfmts-crop @@ -106,6 +106,8 @@ x2rgb10le f4265aca7a67dbfa9354370098ca6f33 xv30le 7e2350aea136c6fb76dae54e9d3fe1f8 xv36be 23b6f253fcb375e4145cfcb562268c5f xv36le 778286003497f92b84d0bd8258d6b85d +xv48be c90889b2cf54cc78bd58e8c47d4eb791 +xv48le 60d81aa388fd40e5bf8aa3323bc4e60f xyz12be cb4571f9aaa7b59f999ef327276104b7 xyz12le cd6aae8d26b18bdb4b9d068586276d91 ya16be a3d18014454942a96f15a49947c0c55d diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field index d35eec2a2f..aac4e0adfa 100644 --- a/tests/ref/fate/filter-pixfmts-field +++ b/tests/ref/fate/filter-pixfmts-field @@ -109,6 +109,8 @@ x2rgb10le a18bc4ae5274e0a8cca9137ecd50c677 xv30le a8e8bfb66178ad5cbef5c82cedc1d3da xv36be bcc7bda2d0a5d43db4464af6a4cb5d65 xv36le ba99f258370f2a56993e8760e6b30194 +xv48be 2abcd986a34789ba4310be3969020d0d +xv48le 90591fca801a6d0ee3fb19bf3c8587f8 xyz12be d2fa69ec91d3ed862f2dac3f8e7a3437 xyz12le 02bccd5e0b6824779a1f848b0ea3e3b5 y210le 4c2fba1dc40322584977d15dd07c9146 diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder index a19f58e73d..f5dddd0a37 100644 --- a/tests/ref/fate/filter-pixfmts-fieldorder +++ b/tests/ref/fate/filter-pixfmts-fieldorder @@ -98,6 +98,8 @@ x2rgb10le cdf6a9e8a8d081aa768c6ae2e6221676 xv30le 8d1921d4a210d8107c20a805cb9a8117 xv36be 962386c88268f4382004c3a7a82c5eb8 xv36le bcceffc985aaa8414c4b8072aa0889bd +xv48be 4d6e4004b03767f12df8bb4e76c98ddf +xv48le f1b19076ff69cb8d587454615015297a xyz12be 15f5cda71de5fef9cec5e75e3833b6bc xyz12le 7be6c8781f38c21a6b8f602f62ca31e6 y210le 22b1a02a39c4b325726bf8793bf1e8f2 diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip index f9e6b564bb..a4630144e3 100644 --- a/tests/ref/fate/filter-pixfmts-hflip +++ b/tests/ref/fate/filter-pixfmts-hflip @@ -106,6 +106,8 @@ x2rgb10le d4a8189b65395a88d0a38a7053f3359f xv30le 7370eadd13a2fc79186443713a639332 xv36be 98f578df965eed369f46cb135e2d1345 xv36le e478b4b54698beb3ce1b9a2dd691d544 +xv48be e030a2c7b1b600cfacb691b6e90c2e3d +xv48le d2fd726fcd96a696ea67cb6281c45b6b xyz12be 25f90259ff8a226befdaec3dfe82996e xyz12le 926c0791d59aaff61b2778e8ada3316d ya16be d5b342355bdd9e3197e01b13b7c6301e diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il index 67a44ef361..981fe287fd 100644 --- a/tests/ref/fate/filter-pixfmts-il +++ b/tests/ref/fate/filter-pixfmts-il @@ -108,6 +108,8 @@ x2rgb10le 517fb186f523dc7cdc5c5c6967cfbe94 xv30le ccd81ba2ba845917d5d1c9fa2a6e2fc6 xv36be 3bbb949278ea55cc947ee03bd9c27c2d xv36le 102c0e817d375ddd6b2cfbb4262dec95 +xv48be 4d7376651fb7b3e84d00abad6c785aad +xv48le 7280a114df023964bdba651a9c2ca752 xyz12be 7c7d54c55f136cbbc50b18029f3be0b3 xyz12le 090ba6b1170baf2b1358b43b971d33b0 y210le d4cf9b53cd7ff22f087743d483e88480 diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null index bd44c34fe0..0ac7ba1d6e 100644 --- a/tests/ref/fate/filter-pixfmts-null +++ b/tests/ref/fate/filter-pixfmts-null @@ -109,6 +109,8 @@ x2rgb10le c1e3ac21be04a16bb157b22784524520 xv30le 7dfdd664a9792bb06a19a63353828da0 xv36be 9f556ee59a672fd8725f0bb36ce3e4b0 xv36le e08dcbde02f1c28a3554f372ad1278e2 +xv48be ce34993b4b4411bba1d852b9b86aa39e +xv48le 30b5271d569d1ad6aba916fa5cdf82bd xyz12be a1ef56bf746d71f59669c28e48fc8450 xyz12le 831ff03c1ba4ef19374686f16a064d8c y210le 04e9487b6cce38e7531437e946cdd586 diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale index 0cb96c0e1c..689ed6ba9a 100644 --- a/tests/ref/fate/filter-pixfmts-scale +++ b/tests/ref/fate/filter-pixfmts-scale @@ -109,6 +109,8 @@ x2rgb10le d56bdb23fa6a8e12a0b4394987f89935 xv30le a2a351cbf936651b558abfc70a925057 xv36be 4d084adca0228d7750d1e2e877e0d79b xv36le de9c74e94dc19c828e1572aa283d8aca +xv48be 9e58d1a045df100b0dec116e13be5b4e +xv48le c739efbfc98e9944911ffb7861b176b7 xyz12be c7ba8345998c0141ddc079cdd29b1a40 xyz12le 95f5d3a0de834cc495c9032a14987cde y210le 7c2aef142d88ab343ec01acd45f38466 diff --git a/tests/ref/fate/filter-pixfmts-transpose b/tests/ref/fate/filter-pixfmts-transpose index 3faceb5f5d..16fdba1140 100644 --- a/tests/ref/fate/filter-pixfmts-transpose +++ b/tests/ref/fate/filter-pixfmts-transpose @@ -98,6 +98,8 @@ x2rgb10le 09cb1d98fe17ad8a6d9d3bec97ddc845 xv30le ebe26bf75c64406dea8b8a160c978fd9 xv36be 2261a0e3db5ee607d37f68d19704ae15 xv36le 9202133de91bf64c76ca27d5cd0c816a +xv48be 14373b7fe123225689e76fe2ce43fb93 +xv48le ad174a65871cacf64275f7f7cef8467d xyz12be 68e5cba640f6e4ef72dff950e88b5342 xyz12le 8b6b6a6db4d7561e80db88ccaecce7a9 ya16be 3e161cb5f225922a80fefdc9cc02a4f9 diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip index e9ffa48cae..032f3b58bb 100644 --- a/tests/ref/fate/filter-pixfmts-vflip +++ b/tests/ref/fate/filter-pixfmts-vflip @@ -109,6 +109,8 @@ x2rgb10le 262c502230cf3724f8e2cf4737f18a42 xv30le f61ddeb49ba8fb7c92294ad621cbf896 xv36be c0272372d3e1a59adb3931ee433a5d5b xv36le ffe6ab75ebc09134c3451f8f6ef0d501 +xv48be bdfc3217ae456b370dbdcf4d52606a3f +xv48le 5e603d6635ddeba02f3201c70437cb9d xyz12be 23fa9fb36d49dce61e284d41b83e0e6b xyz12le ef73e6d1f932a9a355df1eedd628394f y210le f8847bedd3ae6e1c0cf84a823f275e31