From 19748132613d1d13f5b6786051910e7375bb3df6 Mon Sep 17 00:00:00 2001 From: James Almer Date: Fri, 5 Aug 2022 13:44:16 -0300 Subject: [PATCH] swscale/output: add VUYA output support Signed-off-by: James Almer --- libswscale/output.c | 57 ++++++++++++++++++++++++ libswscale/utils.c | 2 +- tests/ref/fate/filter-pixdesc-vuya | 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-pad | 1 + tests/ref/fate/filter-pixfmts-scale | 1 + tests/ref/fate/filter-pixfmts-transpose | 1 + tests/ref/fate/filter-pixfmts-vflip | 1 + 14 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 tests/ref/fate/filter-pixdesc-vuya diff --git a/libswscale/output.c b/libswscale/output.c index 773f3ce059..1b8f35bb4b 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -2584,6 +2584,60 @@ yuv2ayuv64le_X_c(SwsContext *c, const int16_t *lumFilter, } } +static void +yuv2vuya_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 hasAlpha = !!alpSrc; + int i; + + for (i = 0; i < dstW; i++) { + int j; + int Y = 1 << 18, U = 1 << 18; + int V = 1 << 18, A = 255; + + for (j = 0; j < lumFilterSize; j++) + Y += lumSrc[j][i] * lumFilter[j]; + + for (j = 0; j < lumFilterSize; j++) + U += chrUSrc[j][i] * chrFilter[j]; + + for (j = 0; j < lumFilterSize; j++) + V += chrVSrc[j][i] * chrFilter[j]; + + Y >>= 19; + U >>= 19; + V >>= 19; + + if (Y & 0x100) + Y = av_clip_uint8(Y); + if (U & 0x100) + U = av_clip_uint8(U); + if (V & 0x100) + V = av_clip_uint8(V); + + if (hasAlpha) { + A = 1 << 18; + + for (j = 0; j < lumFilterSize; j++) + A += alpSrc[j][i] * lumFilter[j]; + + A >>= 19; + + if (A & 0x100) + A = av_clip_uint8(A); + } + + dest[4 * i ] = V; + dest[4 * i + 1] = U; + dest[4 * i + 2] = Y; + dest[4 * i + 3] = A; + } +} + av_cold void ff_sws_init_output_funcs(SwsContext *c, yuv2planar1_fn *yuv2plane1, yuv2planarX_fn *yuv2planeX, @@ -3086,5 +3140,8 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, case AV_PIX_FMT_AYUV64LE: *yuv2packedX = yuv2ayuv64le_X_c; break; + case AV_PIX_FMT_VUYA: + *yuv2packedX = yuv2vuya_X_c; + break; } } diff --git a/libswscale/utils.c b/libswscale/utils.c index bc3d1c955c..34503e57f4 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -258,7 +258,7 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_P416BE] = { 1, 1 }, [AV_PIX_FMT_P416LE] = { 1, 1 }, [AV_PIX_FMT_NV16] = { 1, 1 }, - [AV_PIX_FMT_VUYA] = { 1, 0 }, + [AV_PIX_FMT_VUYA] = { 1, 1 }, }; int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos, diff --git a/tests/ref/fate/filter-pixdesc-vuya b/tests/ref/fate/filter-pixdesc-vuya new file mode 100644 index 0000000000..3285c08c32 --- /dev/null +++ b/tests/ref/fate/filter-pixdesc-vuya @@ -0,0 +1 @@ +pixdesc-vuya 6d7d537c388b9d53c3493cd2e0ef4e5c diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy index 3cd0002e4e..ecdbc24f9e 100644 --- a/tests/ref/fate/filter-pixfmts-copy +++ b/tests/ref/fate/filter-pixfmts-copy @@ -89,6 +89,7 @@ rgba b6e1b441c365e03b5ffdf9b7b68d9a0c rgba64be ae2ae04b5efedca3505f47c4dd6ea6ea rgba64le b91e1d77f799eb92241a2d2d28437b15 uyvy422 3bcf3c80047592f2211fae3260b1b65d +vuya b6dfd3268ed8eb82b5d534c6d0a20188 x2bgr10le 550c0d190cf695afa4eaacb644db6b75 x2rgb10le c1e3ac21be04a16bb157b22784524520 xyz12be a1ef56bf746d71f59669c28e48fc8450 diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop index 1a0f0c79ed..6f18d98a51 100644 --- a/tests/ref/fate/filter-pixfmts-crop +++ b/tests/ref/fate/filter-pixfmts-crop @@ -86,6 +86,7 @@ rgb8 9b364a8f112ad9459fec47a51cc03b30 rgba 9488ac85abceaf99a9309eac5a87697e rgba64be 89910046972ab3c68e2a348302cc8ca9 rgba64le fea8ebfc869b52adf353778f29eac7a7 +vuya dcc42e77d663a3a8920826f4ae1f034e x2bgr10le 84de725b85662c362862820dc4a309aa x2rgb10le f4265aca7a67dbfa9354370098ca6f33 xyz12be cb4571f9aaa7b59f999ef327276104b7 diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field index 27a74eaef3..00331ef139 100644 --- a/tests/ref/fate/filter-pixfmts-field +++ b/tests/ref/fate/filter-pixfmts-field @@ -89,6 +89,7 @@ rgba ee616262ca6d67b7ecfba4b36c602ce3 rgba64be 23c8c0edaabe3eaec89ce69633fb0048 rgba64le dfdba4de4a7cac9abf08852666c341d3 uyvy422 1c49e44ab3f060e85fc4a3a9464f045e +vuya 1bb73f6d6f01281ecb5a51c630a132a4 x2bgr10le dbe21538d7cb1744914f6bd46ec09b55 x2rgb10le a18bc4ae5274e0a8cca9137ecd50c677 xyz12be d2fa69ec91d3ed862f2dac3f8e7a3437 diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder index ab080d1a37..8994ce46a4 100644 --- a/tests/ref/fate/filter-pixfmts-fieldorder +++ b/tests/ref/fate/filter-pixfmts-fieldorder @@ -80,6 +80,7 @@ rgba 1fdf872a087a32cd35b80cc7be399578 rgba64be 5598f44514d122b9a57c5c92c20bbc61 rgba64le b34e6e30621ae579519a2d91a96a0acf uyvy422 75de70e31c435dde878002d3f22b238a +vuya 27c98a542197d55a05e671428ff2832a x2bgr10le 86474d84f26c5c51d6f75bf7e1de8da8 x2rgb10le cdf6a9e8a8d081aa768c6ae2e6221676 xyz12be 15f5cda71de5fef9cec5e75e3833b6bc diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip index 8c7a9d83c9..19d9965db6 100644 --- a/tests/ref/fate/filter-pixfmts-hflip +++ b/tests/ref/fate/filter-pixfmts-hflip @@ -86,6 +86,7 @@ rgb8 68a3a575badadd9e4f90226209f11699 rgba 51961c723ea6707e0a410cd3f21f15d3 rgba64be c910444019f4cfbf4d995227af55da8d rgba64le 0c810d8b3a6bca10321788e1cb145340 +vuya 07daf4cfeb79d15428572d22cfdbf472 x2bgr10le 827cc659f29378e00c5a7d2c0ada8f9a x2rgb10le d4a8189b65395a88d0a38a7053f3359f xyz12be 25f90259ff8a226befdaec3dfe82996e diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il index 15dbe868a6..f55fdebaf6 100644 --- a/tests/ref/fate/filter-pixfmts-il +++ b/tests/ref/fate/filter-pixfmts-il @@ -88,6 +88,7 @@ rgba 625d8f4bd39c4bdbf61eb5e4713aecc9 rgba64be db70d33aa6c06f3e0a1c77bd11284261 rgba64le a8a2daae04374a27219bc1c890204007 uyvy422 d6ee3ca43356d08c392382b24b22cda5 +vuya 8c6b0bca3348d0a3cb7dff0717a24b59 x2bgr10le 135acaff8318cf9861bb0f7849a9e5e9 x2rgb10le 517fb186f523dc7cdc5c5c6967cfbe94 xyz12be 7c7d54c55f136cbbc50b18029f3be0b3 diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null index 3cd0002e4e..ecdbc24f9e 100644 --- a/tests/ref/fate/filter-pixfmts-null +++ b/tests/ref/fate/filter-pixfmts-null @@ -89,6 +89,7 @@ rgba b6e1b441c365e03b5ffdf9b7b68d9a0c rgba64be ae2ae04b5efedca3505f47c4dd6ea6ea rgba64le b91e1d77f799eb92241a2d2d28437b15 uyvy422 3bcf3c80047592f2211fae3260b1b65d +vuya b6dfd3268ed8eb82b5d534c6d0a20188 x2bgr10le 550c0d190cf695afa4eaacb644db6b75 x2rgb10le c1e3ac21be04a16bb157b22784524520 xyz12be a1ef56bf746d71f59669c28e48fc8450 diff --git a/tests/ref/fate/filter-pixfmts-pad b/tests/ref/fate/filter-pixfmts-pad index 16949e9672..90c7de0c2e 100644 --- a/tests/ref/fate/filter-pixfmts-pad +++ b/tests/ref/fate/filter-pixfmts-pad @@ -35,6 +35,7 @@ p416le fa4e023d0bf4b03b0ffef3d4d35abf7e rgb0 0984eb985dabbe757ed6beb53db84eff rgb24 17f9e2e0c609009acaf2175c42d4a2a5 rgba b157c90191463d34fb3ce77b36c96386 +vuya 9a4d215c59c3a5c8e364ff882764b40e xyz12le 23dadbbba70b2925ce75fb8ba8080ba3 ya16le 8dbfcb586abf626da7d1aca887a581b9 ya8 495daaca2dcb4f7aeba7652768b41ced diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale index 95a3f071b8..cdf42f575c 100644 --- a/tests/ref/fate/filter-pixfmts-scale +++ b/tests/ref/fate/filter-pixfmts-scale @@ -89,6 +89,7 @@ rgba 85bb5d03cea1c6e8002ced3373904336 rgba64be ee73e57923af984b31cc7795d13929da rgba64le 783d2779adfafe3548bdb671ec0de69e uyvy422 aeb4ba4f9f003ae21f6d18089198244f +vuya ab4c9c4a6b6946945eeb23e15d0341b0 x2bgr10le d57b9a99033cc7b65ddd111578f2d385 x2rgb10le d56bdb23fa6a8e12a0b4394987f89935 xyz12be c7ba8345998c0141ddc079cdd29b1a40 diff --git a/tests/ref/fate/filter-pixfmts-transpose b/tests/ref/fate/filter-pixfmts-transpose index 922666cf95..4116718e3f 100644 --- a/tests/ref/fate/filter-pixfmts-transpose +++ b/tests/ref/fate/filter-pixfmts-transpose @@ -80,6 +80,7 @@ rgb8 c90feb30c3c9391ef5f470209d7b7a15 rgba 4d76a9542143752a4ac30f82f88f68f1 rgba64be a60041217f4c0cd796d19d3940a12a41 rgba64le ad47197774858858ae7b0c177dffa459 +vuya 7ca9ebf75e2f5b6526b0b40a86368999 x2bgr10le 4aa774b6d8f6d446a64f1f288e5c97eb x2rgb10le 09cb1d98fe17ad8a6d9d3bec97ddc845 xyz12be 68e5cba640f6e4ef72dff950e88b5342 diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip index 7af28d3a8f..ce60cdc523 100644 --- a/tests/ref/fate/filter-pixfmts-vflip +++ b/tests/ref/fate/filter-pixfmts-vflip @@ -89,6 +89,7 @@ rgba c1a5908572737f2ae1e5d8218af65f4b rgba64be 17e6273323b5779b5f3f775f150c1011 rgba64le 48f45b10503b7dd140329c3dd0d54c98 uyvy422 3a237e8376264e0cfa78f8a3fdadec8a +vuya 4086a782b3bba1f6200d6e40c903e3c1 x2bgr10le 795b66a5fc83cd2cf300aae51c230f80 x2rgb10le 262c502230cf3724f8e2cf4737f18a42 xyz12be 810644e008deb231850d779aaa27cc7e