PR #24550 opened by ww8191201-coder
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24550
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24550.patch
swscale/riscv: fix uyvy/yuyv to yuv422p on odd widths
==================================================
The RVV packed-to-planar YUV422 loop writes all luma samples, but only
`width / 2` chroma samples. With an odd width, the final U and V samples
remain untouched instead of matching the C implementations, which use
`AV_CEIL_RSHIFT(width, 1)`.
Write the remaining U/V samples in a scalar row tail for both UYVY and
YUYV. The vector loop and row stride adjustments remain unchanged; the
extra stores do not advance the chroma pointers.
This fixes the existing `uyvytoyuv422_rvv_i32` and
`yuyvtoyuv422_rvv_i32` checkasm failures. The change is confined to
`libswscale/riscv/rgb2rgb_rvv.S`.
Tested on a Spacemit X100, VLEN=256, with GCC 15.2.0:
- Native `sw_rgb` checkasm: all 83 tests passed for 1,000 consecutive seeds.
- QEMU, VLEN 128/256/512/1024: both affected functions passed 100 consecutive
seeds at each VLEN, with all-ones agnostic tails enabled.
- The configured FATE subset passed all 277 targets after the fix. The
unpatched baseline passed 276/277, failing only `checkasm-sw_rgb`.
Signed-off-by: Hongyan Wang <[email protected]>
Co-authored-by: YuanSheng <[email protected]>
Co-authored-by: Fei Zhang <[email protected]>
>From 81c06654e81896c5c1aec635304880aa89d5c673 Mon Sep 17 00:00:00 2001
From: Hongyan Wang <[email protected]>
Date: Thu, 17 Sep 2026 15:47:14 +0800
Subject: [PATCH] Subject: [PATCH] swscale/riscv: fix uyvy/yuyv to yuv422p on
odd widths
The vector loop writes all luma samples, but only width / 2 chroma
samples. For odd widths, the last U and V samples are left untouched,
unlike the C implementations which use AV_CEIL_RSHIFT(width, 1).
Write the remaining U/V samples in a scalar tail for both packed
formats. Keep the existing vector loop and row stride adjustments.
Fixes the uyvytoyuv422_rvv_i32 and yuyvtoyuv422_rvv_i32 failures in
checkasm-sw_rgb.
Signed-off-by: Hongyan Wang <[email protected]>
Co-authored-by: YuanSheng <[email protected]>
Co-authored-by: Fei Zhang <[email protected]>
---
libswscale/riscv/rgb2rgb_rvv.S | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/libswscale/riscv/rgb2rgb_rvv.S b/libswscale/riscv/rgb2rgb_rvv.S
index a1a927b00f..b945d16bf1 100644
--- a/libswscale/riscv/rgb2rgb_rvv.S
+++ b/libswscale/riscv/rgb2rgb_rvv.S
@@ -132,7 +132,7 @@ func ff_deinterleave_bytes_rvv, zve32x, zba
ret
endfunc
-.macro yuy2_to_i422p luma, chroma
+.macro yuy2_to_i422p luma, chroma, chroma_offset
lpad 0
srai t4, a4, 1 // pixel width -> chroma width
lw t6, (sp)
@@ -163,6 +163,14 @@ endfunc
add a0, t0, a0
bnez t4, 2b
+ andi t0, a4, 1
+ beqz t0, 3f
+ // Odd widths need one final U/V sample.
+ lbu t0, \chroma_offset - 2(a3)
+ lbu t1, \chroma_offset(a3)
+ sb t0, (a1)
+ sb t1, (a2)
+3:
add a3, a3, t6
add a0, a0, a6
add a1, a1, a7
@@ -173,9 +181,9 @@ endfunc
.endm
func ff_uyvytoyuv422_rvv, zve32x, b
- yuy2_to_i422p v20, v16
+ yuy2_to_i422p v20, v16, 0
endfunc
func ff_yuyvtoyuv422_rvv, zve32x, b
- yuy2_to_i422p v16, v20
+ yuy2_to_i422p v16, v20, 1
endfunc
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]