[FFmpeg-devel] [PATCH 08/20] swscale/output: add AYUV output support
Michael Niedermayer
michael at niedermayer.cc
Wed Oct 9 01:34:35 EEST 2024
On Mon, Oct 07, 2024 at 09:29:43AM -0300, James Almer wrote:
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
> libswscale/output.c | 56 ++++++++++++++++++++++++
> libswscale/utils.c | 2 +-
> tests/ref/fate/filter-pixdesc-ayuv | 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-ayuv
>
> diff --git a/libswscale/output.c b/libswscale/output.c
> index e5d555f76f..4d6b9d553b 100644
> --- a/libswscale/output.c
> +++ b/libswscale/output.c
> @@ -2825,6 +2825,59 @@ yuv2vuyX_X_c(SwsContext *c, const int16_t *lumFilter,
> }
> }
>
> +static void
> +yuv2ayuv_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 ] = A;
> + dest[4 * i + 1] = Y;
> + dest[4 * i + 2] = U;
> + dest[4 * i + 3] = V;
> + }
> +}
please dont repeat a nearly identical function for each case
see output_pixel(s)
> +
> #define output_pixel(pos, val, bits) \
> AV_WL16(pos, av_clip_uintp2(val >> shift, bits) << output_shift);
>
> @@ -3377,6 +3430,9 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c,
> case AV_PIX_FMT_AYUV64LE:
> *yuv2packedX = yuv2ayuv64le_X_c;
> break;
> + case AV_PIX_FMT_AYUV:
> + *yuv2packedX = yuv2ayuv_X_c;
> + break;
if this covers all needed/used cases, ok
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241009/832d9b06/attachment.sig>
More information about the ffmpeg-devel
mailing list