tests/checkasm/sw_yuv2rgb: cover nv12 and nv21

The previous chroma stride formula (width >> log2_chroma_w) is correct
for planar yuv but wrong for semi-planar nv12/nv21, where the UV plane
is interleaved at width bytes per row (width/2 UV pairs of 2 bytes
each). Use av_image_get_linesize() so the test feeds a valid stride to
libswscale regardless of input format; for the existing planar suites
the value is unchanged.

With the stride fixed, add nv12 and nv21 to check_yuv2rgb() so the
upcoming NEON 16bpp paths get bench coverage. ff_get_unscaled_swscale
does not wire a C yuv2rgb fast path for these inputs, so the suites
report bench-only (no correctness reference); they still run clobber
detection and cycle counts.

Signed-off-by: DROOdotFOO <drew@axol.io>
This commit is contained in:
DROOdotFOO 2026-05-19 13:31:50 +02:00 committed by Martin Storsjö
parent 61a0b8fb41
commit 34501921fd

View file

@ -19,6 +19,7 @@
#include <string.h>
#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem_internal.h"
#include "libavutil/pixdesc.h"
@ -144,10 +145,14 @@ static void check_yuv2rgb(int src_pix_fmt)
int width = input_sizes[isi];
int srcSliceY = 0;
int srcSliceH = NUM_LINES;
/* Use av_image_get_linesize so that semi-planar formats (NV12,
* NV21) get the correct interleaved-UV stride (= width bytes),
* not (width >> log2_chroma_w) which would only count UV pairs. */
int chroma_linesize = av_image_get_linesize(src_pix_fmt, width, 1);
int srcStride[4] = {
width + SRC_STRIDE_PAD,
(width >> src_desc->log2_chroma_w) + SRC_STRIDE_PAD,
(width >> src_desc->log2_chroma_w) + SRC_STRIDE_PAD,
chroma_linesize + SRC_STRIDE_PAD,
chroma_linesize + SRC_STRIDE_PAD,
width + SRC_STRIDE_PAD,
};
int dstStride[4] = {
@ -239,4 +244,8 @@ void checkasm_check_sw_yuv2rgb(void)
report("yuv422p");
check_yuv2rgb(AV_PIX_FMT_YUVA420P);
report("yuva420p");
check_yuv2rgb(AV_PIX_FMT_NV12);
report("nv12");
check_yuv2rgb(AV_PIX_FMT_NV21);
report("nv21");
}