Hi

On Mon, Mar 16, 2026 at 03:27:19AM -0700, Hankang Li via ffmpeg-devel wrote:
> Fixes: #22331
> 
> Signed-off-by: Hankang Li <[email protected]>
> ---
>  libswscale/input.c  | 18 +++++++++---------
>  libswscale/output.c | 10 +++++-----
>  2 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/libswscale/input.c b/libswscale/input.c
> index eb4eb3101e..175ed705f2 100644
> --- a/libswscale/input.c
> +++ b/libswscale/input.c
[...]

> @@ -1310,8 +1310,8 @@ static av_always_inline void 
> planar_rgbf32_to_uv(uint8_t *_dstU, uint8_t *_dstV,
>          int b = lrintf(av_clipf(65535.0f * rdpx(src[1] + i), 0.0f, 
> 65535.0f));
>          int r = lrintf(av_clipf(65535.0f * rdpx(src[2] + i), 0.0f, 
> 65535.0f));
>  
> -        dstU[i] = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> 
> RGB2YUV_SHIFT;
> -        dstV[i] = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> 
> RGB2YUV_SHIFT;
> +        dstU[i] = (int)((unsigned)ru*r + (unsigned)gu*g + (unsigned)bu*b + 
> (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
> +        dstV[i] = (int)((unsigned)rv*r + (unsigned)gv*g + (unsigned)bv*b + 
> (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
>      }
>  }
>  
> @@ -1328,7 +1328,7 @@ static av_always_inline void planar_rgbf32_to_y(uint8_t 
> *_dst, const uint8_t *_s
>          int b = lrintf(av_clipf(65535.0f * rdpx(src[1] + i), 0.0f, 
> 65535.0f));
>          int r = lrintf(av_clipf(65535.0f * rdpx(src[2] + i), 0.0f, 
> 65535.0f));
>  
> -        dst[i] = (ry*r + gy*g + by*b + (0x2001 << (RGB2YUV_SHIFT - 1))) >> 
> RGB2YUV_SHIFT;
> +        dst[i] = (int)((unsigned)ry*r + (unsigned)gy*g + (unsigned)by*b + 
> (0x2001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
>      }
>  }

These look odd
there is cliping code and you have integer overflows _after_ it


>  
> diff --git a/libswscale/output.c b/libswscale/output.c
> index 1494b06bf5..2977657b2e 100644
> --- a/libswscale/output.c
> +++ b/libswscale/output.c
> @@ -1232,9 +1232,9 @@ yuv2rgba64_2_c_template(SwsInternal *c, const int32_t 
> *buf[2],
>          Y1 += (1 << 13) - (1 << 29);
>          Y2 += (1 << 13) - (1 << 29);
>  
> -        R = V * c->yuv2rgb_v2r_coeff;
> -        G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
> -        B =                            U * c->yuv2rgb_u2b_coeff;
> +        R = (SUINT)V * c->yuv2rgb_v2r_coeff;
> +        G = (SUINT)V * c->yuv2rgb_v2g_coeff + (SUINT)U * 
> c->yuv2rgb_u2g_coeff;
> +        B =                            (SUINT)U * c->yuv2rgb_u2b_coeff;

please maintain vertical alignment


thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf

Attachment: signature.asc
Description: PGP signature

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to