[FFmpeg-devel] [PATCH] swscale: fix chroma width rounding

lance.lmwang at gmail.com lance.lmwang at gmail.com
Thu Jun 3 05:15:31 EEST 2021


On Wed, Jun 02, 2021 at 11:02:44PM +0800, lance.lmwang at gmail.com wrote:
> From: Limin Wang <lance.lmwang at gmail.com>
> 
> fixes vertical line at the right side of video for rgb24toyv12 conversion.
> Please reproduce it with below command:
> ./ffplay -f lavfi -i "testsrc=size=529x656,ocv=filter_name=smooth,format=yuv420p"

Please reproduce it with below command:
./ffplay -f lavfi -i "testsrc=size=529x656,format=bgr24,format=yuv420p"

> 
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
>  libswscale/rgb2rgb_template.c     | 2 +-
>  libswscale/x86/rgb2rgb_template.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libswscale/rgb2rgb_template.c b/libswscale/rgb2rgb_template.c
> index 42c6980..e716ba5 100644
> --- a/libswscale/rgb2rgb_template.c
> +++ b/libswscale/rgb2rgb_template.c
> @@ -654,7 +654,7 @@ void ff_rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
>      int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
>      int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
>      int y;
> -    const int chromWidth = width >> 1;
> +    const int chromWidth = AV_CEIL_RSHIFT(width, 1);
>  
>      for (y = 0; y < height; y += 2) {
>          int i;
> diff --git a/libswscale/x86/rgb2rgb_template.c b/libswscale/x86/rgb2rgb_template.c
> index ae2469e..704b0fa 100644
> --- a/libswscale/x86/rgb2rgb_template.c
> +++ b/libswscale/x86/rgb2rgb_template.c
> @@ -1578,7 +1578,7 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
>  #define BGR2U_IDX "16*4+16*33"
>  #define BGR2V_IDX "16*4+16*34"
>      int y;
> -    const x86_reg chromWidth= width>>1;
> +    const x86_reg chromWidth = AV_CEIL_RSHIFT(width, 1);
>  
>      if (height > 2) {
>          ff_rgb24toyv12_c(src, ydst, udst, vdst, width, 2, lumStride, chromStride, srcStride, rgb2yuv);
> -- 
> 1.8.3.1
> 

-- 
Thanks,
Limin Wang


More information about the ffmpeg-devel mailing list