aboutsummaryrefslogtreecommitdiffstats
path: root/libswscale/output.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2022-08-05 13:44:16 -0300
committerJames Almer <jamrial@gmail.com>2022-08-07 09:33:16 -0300
commit19748132613d1d13f5b6786051910e7375bb3df6 (patch)
tree0f0bb1a87207727e02ddab285579c286f98b5c14 /libswscale/output.c
parent23758380d0d0704754d0942779f283e1cf7641ae (diff)
downloadffmpeg-19748132613d1d13f5b6786051910e7375bb3df6.tar.gz
swscale/output: add VUYA output support
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libswscale/output.c')
-rw-r--r--libswscale/output.c57
1 files changed, 57 insertions, 0 deletions
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;
}
}