PR #25877 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25877 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25877.patch
>From 787043af6e2519cd90d35507cd1ba6d1ba8ed7fc Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Sun, 8 Nov 2026 11:26:19 -0300 Subject: [PATCH] swscale/output: add yuv2packed1 implementation for YAF32 Signed-off-by: James Almer <[email protected]> --- libswscale/output.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/libswscale/output.c b/libswscale/output.c index b6ad322da00..55cba1ea5f1 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -217,7 +217,8 @@ yuv2nv12cX_16_c_template(int big_endian, const uint8_t *chrDither, } static av_always_inline void -yuv2plane1_float_c_template(const int32_t *src, float *dest, int dstW) +yuv2plane1_float_c_template(const int32_t *src, float *dest, int dstW, + ptrdiff_t stride) { static const int big_endian = HAVE_BIGENDIAN; static const int shift = 3; @@ -228,12 +229,13 @@ yuv2plane1_float_c_template(const int32_t *src, float *dest, int dstW) for (i = 0; i < dstW; ++i){ val = src[i] + (1 << (shift - 1)); output_pixel(&val_uint, val, 0, uint); - dest[i] = float_mult * (float)val_uint; + dest[i * stride] = float_mult * (float)val_uint; } } static av_always_inline void -yuv2plane1_float_bswap_c_template(const int32_t *src, uint32_t *dest, int dstW) +yuv2plane1_float_bswap_c_template(const int32_t *src, uint32_t *dest, int dstW, + ptrdiff_t stride) { static const int big_endian = HAVE_BIGENDIAN; static const int shift = 3; @@ -244,7 +246,7 @@ yuv2plane1_float_bswap_c_template(const int32_t *src, uint32_t *dest, int dstW) for (i = 0; i < dstW; ++i){ val = src[i] + (1 << (shift - 1)); output_pixel(&val_uint, val, 0, uint); - dest[i] = av_bswap32(av_float2int(float_mult * (float)val_uint)); + dest[i * stride] = av_bswap32(av_float2int(float_mult * (float)val_uint)); } } @@ -292,7 +294,7 @@ yuv2planeX_float_bswap_c_template(const int16_t *filter, int filterSize, const i static void yuv2plane1_float ## BE_LE ## _c(const int16_t *src, uint8_t *dest, int dstW, \ const uint8_t *dither, int offset) \ { \ - template((const int32_t *)src, (dest_type *)dest, dstW); \ + template((const int32_t *)src, (dest_type *)dest, dstW, 1); \ } #define yuv2planeX_float(template, dest_type, BE_LE) \ @@ -303,6 +305,28 @@ static void yuv2planeX_float ## BE_LE ## _c(const int16_t *filter, int filterSiz template(filter, filterSize, (const int32_t **)src, (dest_type *)dest, dstW, 1); \ } +#define yuv2yaf32_1(template, dest_type, BE_LE, is_be) \ +static void yuv2yaf32 ## BE_LE ## _1_c(SwsInternal *c, const int16_t *lumSrc, \ + const int16_t *chrUSrc[2], \ + const int16_t *chrVSrc[2], \ + const int16_t *alpSrc, uint8_t *dest, \ + int dstW, int uvalpha, int y) \ +{ \ + dest_type *dst = (dest_type *) dest; \ + template((const int32_t *)lumSrc, dst, dstW, 2); \ + if (alpSrc) { \ + template((const int32_t *)alpSrc, dst + 1, dstW, 2); \ + } else { \ + for (int i = 0; i < dstW; i++) { \ + if (is_be) { \ + AV_WB32(&dst[2 * i + 1], av_float2int(1.0f)); \ + } else { \ + AV_WL32(&dst[2 * i + 1], av_float2int(1.0f)); \ + } \ + } \ + } \ +} + #define yuv2yaf32_X(template, dest_type, BE_LE, is_be) \ static void yuv2yaf32 ## BE_LE ## _X_c(SwsInternal *c, const int16_t *lumFilter, \ const int16_t **lumSrc, int lumFilterSize, \ @@ -332,6 +356,8 @@ yuv2plane1_float(yuv2plane1_float_c_template, float, BE) yuv2plane1_float(yuv2plane1_float_bswap_c_template, uint32_t, LE) yuv2planeX_float(yuv2planeX_float_c_template, float, BE) yuv2planeX_float(yuv2planeX_float_bswap_c_template, uint32_t, LE) +yuv2yaf32_1(yuv2plane1_float_c_template, float, be, 1) +yuv2yaf32_1(yuv2plane1_float_bswap_c_template, uint32_t, le, 0) yuv2yaf32_X(yuv2planeX_float_c_template, float, be, 1) yuv2yaf32_X(yuv2planeX_float_bswap_c_template, uint32_t, le, 0) #else @@ -339,6 +365,8 @@ yuv2plane1_float(yuv2plane1_float_c_template, float, LE) yuv2plane1_float(yuv2plane1_float_bswap_c_template, uint32_t, BE) yuv2planeX_float(yuv2planeX_float_c_template, float, LE) yuv2planeX_float(yuv2planeX_float_bswap_c_template, uint32_t, BE) +yuv2yaf32_1(yuv2plane1_float_c_template, float, le, 0) +yuv2yaf32_1(yuv2plane1_float_bswap_c_template, uint32_t, be, 1) yuv2yaf32_X(yuv2planeX_float_c_template, float, le, 0) yuv2yaf32_X(yuv2planeX_float_bswap_c_template, uint32_t, be, 1) #endif @@ -3865,9 +3893,11 @@ av_cold void ff_sws_init_output_funcs(SwsInternal *c, *yuv2packedX = yuv2ya16be_X_c; break; case AV_PIX_FMT_YAF32LE: + *yuv2packed1 = yuv2yaf32le_1_c; *yuv2packedX = yuv2yaf32le_X_c; break; case AV_PIX_FMT_YAF32BE: + *yuv2packed1 = yuv2yaf32be_1_c; *yuv2packedX = yuv2yaf32be_X_c; break; case AV_PIX_FMT_V30XLE: -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
