[FFmpeg-devel] [PATCH 09/20] swscale/output: add UYVA output support
James Almer
jamrial at gmail.com
Mon Oct 7 15:29:44 EEST 2024
Signed-off-by: James Almer <jamrial at gmail.com>
---
libswscale/output.c | 56 ++++++++++++++++++++++++
libswscale/utils.c | 2 +-
tests/ref/fate/filter-pixdesc-uyva | 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, 69 insertions(+), 1 deletion(-)
create mode 100644 tests/ref/fate/filter-pixdesc-uyva
diff --git a/libswscale/output.c b/libswscale/output.c
index 4d6b9d553b..a11bedde95 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -2878,6 +2878,59 @@ yuv2ayuv_X_c(SwsContext *c, const int16_t *lumFilter,
}
}
+static void
+yuv2uyva_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 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 < chrFilterSize; j++)
+ U += chrUSrc[j][i] * chrFilter[j];
+
+ for (j = 0; j < chrFilterSize; 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 (alpSrc) {
+ 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 ] = U;
+ dest[4 * i + 1] = Y;
+ dest[4 * i + 2] = V;
+ dest[4 * i + 3] = A;
+ }
+}
+
#define output_pixel(pos, val, bits) \
AV_WL16(pos, av_clip_uintp2(val >> shift, bits) << output_shift);
@@ -3439,6 +3492,9 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
*yuv2packed2 = yuv2vuyX_2_c;
*yuv2packedX = yuv2vuyX_X_c;
break;
+ case AV_PIX_FMT_UYVA:
+ *yuv2packedX = yuv2uyva_X_c;
+ break;
case AV_PIX_FMT_XV30LE:
*yuv2packedX = yuv2xv30le_X_c;
break;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index a5be311393..a37e8c1869 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -269,7 +269,7 @@ static const FormatEntry format_entries[] = {
[AV_PIX_FMT_XV30LE] = { 1, 1 },
[AV_PIX_FMT_XV36LE] = { 1, 1 },
[AV_PIX_FMT_AYUV] = { 1, 1 },
- [AV_PIX_FMT_UYVA] = { 1, 0 },
+ [AV_PIX_FMT_UYVA] = { 1, 1 },
[AV_PIX_FMT_VYU444] = { 1, 0 },
};
diff --git a/tests/ref/fate/filter-pixdesc-uyva b/tests/ref/fate/filter-pixdesc-uyva
new file mode 100644
index 0000000000..49fd1bc6b1
--- /dev/null
+++ b/tests/ref/fate/filter-pixdesc-uyva
@@ -0,0 +1 @@
+pixdesc-uyva 7cec5f820722500f491c3495113e726e
diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy
index dc165b5ec5..de9b35e35a 100644
--- a/tests/ref/fate/filter-pixfmts-copy
+++ b/tests/ref/fate/filter-pixfmts-copy
@@ -97,6 +97,7 @@ rgb8 7ac6008c84d622c2fc50581706e17576
rgba b6e1b441c365e03b5ffdf9b7b68d9a0c
rgba64be ae2ae04b5efedca3505f47c4dd6ea6ea
rgba64le b91e1d77f799eb92241a2d2d28437b15
+uyva affad7282152bcce415bdf228df00ae4
uyvy422 3bcf3c80047592f2211fae3260b1b65d
vuya 3d5e934651cae1ce334001cb1829ad22
vuyx 0af13a42f9d0932c5a9bb6a8a5d1c5ee
diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop
index 07ded708bc..666d99f932 100644
--- a/tests/ref/fate/filter-pixfmts-crop
+++ b/tests/ref/fate/filter-pixfmts-crop
@@ -95,6 +95,7 @@ rgb8 9b364a8f112ad9459fec47a51cc03b30
rgba 9488ac85abceaf99a9309eac5a87697e
rgba64be 89910046972ab3c68e2a348302cc8ca9
rgba64le fea8ebfc869b52adf353778f29eac7a7
+uyva caa03b07812dbb6c48b5fb34edf73962
vuya 76578a705ff3a37559653c1289bd03dd
vuyx 615241c5406eb556fca0ad8606c23a02
x2bgr10le 84de725b85662c362862820dc4a309aa
diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field
index 9e1e06bd80..672ee5d2ec 100644
--- a/tests/ref/fate/filter-pixfmts-field
+++ b/tests/ref/fate/filter-pixfmts-field
@@ -97,6 +97,7 @@ rgb8 62c3b9e2a171de3d894a8eeb271c85e8
rgba ee616262ca6d67b7ecfba4b36c602ce3
rgba64be 23c8c0edaabe3eaec89ce69633fb0048
rgba64le dfdba4de4a7cac9abf08852666c341d3
+uyva c1c2953840061e3778842051b078a41e
uyvy422 1c49e44ab3f060e85fc4a3a9464f045e
vuya f72bcf29d75cd143d0c565f7cc49119a
vuyx 3d02eeab336d0a8106f6fdd91be61073
diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder
index 8f1febf4ad..4b9ba2a88d 100644
--- a/tests/ref/fate/filter-pixfmts-fieldorder
+++ b/tests/ref/fate/filter-pixfmts-fieldorder
@@ -86,6 +86,7 @@ rgb8 6deae05ccac5c50bd0d9c9fe8e124557
rgba 1fdf872a087a32cd35b80cc7be399578
rgba64be 5598f44514d122b9a57c5c92c20bbc61
rgba64le b34e6e30621ae579519a2d91a96a0acf
+uyva fa5df2c0474b2a41dbe2210372b15fcc
uyvy422 75de70e31c435dde878002d3f22b238a
vuya a3891d4168ff208948fd0b3ba0910495
vuyx 9e4480c5fcb7c091ec3e517420764ef3
diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip
index a49abba15b..4742e3957e 100644
--- a/tests/ref/fate/filter-pixfmts-hflip
+++ b/tests/ref/fate/filter-pixfmts-hflip
@@ -95,6 +95,7 @@ rgb8 68a3a575badadd9e4f90226209f11699
rgba 51961c723ea6707e0a410cd3f21f15d3
rgba64be c910444019f4cfbf4d995227af55da8d
rgba64le 0c810d8b3a6bca10321788e1cb145340
+uyva 9266fd7374abf86f7035e356574586f0
vuya 7e530261e7ac4eae4fd616fd7572d0b8
vuyx f1d087284fb1556d76e6def5f94bf273
x2bgr10le 827cc659f29378e00c5a7d2c0ada8f9a
diff --git a/tests/ref/fate/filter-pixfmts-il b/tests/ref/fate/filter-pixfmts-il
index 1ac9cf3bd2..f43377e3dc 100644
--- a/tests/ref/fate/filter-pixfmts-il
+++ b/tests/ref/fate/filter-pixfmts-il
@@ -96,6 +96,7 @@ rgb8 93f9fa5ecf522abe13ed34f21831fdfe
rgba 625d8f4bd39c4bdbf61eb5e4713aecc9
rgba64be db70d33aa6c06f3e0a1c77bd11284261
rgba64le a8a2daae04374a27219bc1c890204007
+uyva f16f848f8283bcd59da6a4d85bc5b0a0
uyvy422 d6ee3ca43356d08c392382b24b22cda5
vuya b9deab5ba249dd608b709c09255a4932
vuyx 4251d94ee49e6a3cc1c10c09cd331308
diff --git a/tests/ref/fate/filter-pixfmts-null b/tests/ref/fate/filter-pixfmts-null
index dc165b5ec5..de9b35e35a 100644
--- a/tests/ref/fate/filter-pixfmts-null
+++ b/tests/ref/fate/filter-pixfmts-null
@@ -97,6 +97,7 @@ rgb8 7ac6008c84d622c2fc50581706e17576
rgba b6e1b441c365e03b5ffdf9b7b68d9a0c
rgba64be ae2ae04b5efedca3505f47c4dd6ea6ea
rgba64le b91e1d77f799eb92241a2d2d28437b15
+uyva affad7282152bcce415bdf228df00ae4
uyvy422 3bcf3c80047592f2211fae3260b1b65d
vuya 3d5e934651cae1ce334001cb1829ad22
vuyx 0af13a42f9d0932c5a9bb6a8a5d1c5ee
diff --git a/tests/ref/fate/filter-pixfmts-pad b/tests/ref/fate/filter-pixfmts-pad
index 5d8111b623..bab4344e01 100644
--- a/tests/ref/fate/filter-pixfmts-pad
+++ b/tests/ref/fate/filter-pixfmts-pad
@@ -42,6 +42,7 @@ rgb0 0984eb985dabbe757ed6beb53db84eff
rgb24 17f9e2e0c609009acaf2175c42d4a2a5
rgb48le ed08db9b1aa50d69b8c3d73db93e390e
rgba b157c90191463d34fb3ce77b36c96386
+uyva be076f4efae6b51032c5fc676a31f2cc
vuya 44368c0a758ee68e24ce976e3b1b8535
vuyx ff637b205b78ee581e393124d0f44f5d
ya16le dfc900a8130a7c5e64201557cbaef50a
diff --git a/tests/ref/fate/filter-pixfmts-scale b/tests/ref/fate/filter-pixfmts-scale
index 41a6fe76e7..66307bc1d3 100644
--- a/tests/ref/fate/filter-pixfmts-scale
+++ b/tests/ref/fate/filter-pixfmts-scale
@@ -97,6 +97,7 @@ rgb8 bcdc033b4ef0979d060dbc8893d4db58
rgba 85bb5d03cea1c6e8002ced3373904336
rgba64be ee73e57923af984b31cc7795d13929da
rgba64le 783d2779adfafe3548bdb671ec0de69e
+uyva ee83c7ba25cfc997de70a4e5b3eb398f
uyvy422 aeb4ba4f9f003ae21f6d18089198244f
vuya ffa817e283bf6a0b6fba21b07523ccaa
vuyx a6ff68f46c6b4b7595ec91b2a497df8e
diff --git a/tests/ref/fate/filter-pixfmts-transpose b/tests/ref/fate/filter-pixfmts-transpose
index bcda0e6460..e5e8a3b7bc 100644
--- a/tests/ref/fate/filter-pixfmts-transpose
+++ b/tests/ref/fate/filter-pixfmts-transpose
@@ -87,6 +87,7 @@ rgb8 c90feb30c3c9391ef5f470209d7b7a15
rgba 4d76a9542143752a4ac30f82f88f68f1
rgba64be a60041217f4c0cd796d19d3940a12a41
rgba64le ad47197774858858ae7b0c177dffa459
+uyva 1500c3f52e32b2080be180d2e8196a7b
vuya 9ece18a345beb17cd19e09e443eca4bf
vuyx 46b5b821d7ee6ddedb3ddafd1e5b007c
x2bgr10le 4aa774b6d8f6d446a64f1f288e5c97eb
diff --git a/tests/ref/fate/filter-pixfmts-vflip b/tests/ref/fate/filter-pixfmts-vflip
index bb8ad46704..53ef4732cc 100644
--- a/tests/ref/fate/filter-pixfmts-vflip
+++ b/tests/ref/fate/filter-pixfmts-vflip
@@ -97,6 +97,7 @@ rgb8 7df049b6094f8a5e084d74462f6d6cde
rgba c1a5908572737f2ae1e5d8218af65f4b
rgba64be 17e6273323b5779b5f3f775f150c1011
rgba64le 48f45b10503b7dd140329c3dd0d54c98
+uyva 0d2d0d286d841ea5b35cc06626dcafe4
uyvy422 3a237e8376264e0cfa78f8a3fdadec8a
vuya fb849f76e56181e005c31fce75d7038c
vuyx ed7de87da324b39090a8961dfd56ca5a
--
2.46.2
More information about the ffmpeg-devel
mailing list