diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index b9c8adb21f..1c34619249 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -82,6 +82,7 @@ SWSCALEOBJS += sw_gbrp.o \ sw_range_convert.o \ sw_rgb.o \ sw_scale.o \ + sw_xyz2rgb.o \ sw_yuv2rgb.o \ sw_yuv2yuv.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index a899967937..7edc8e4e6e 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -330,6 +330,7 @@ static const struct { { "sw_range_convert", checkasm_check_sw_range_convert }, { "sw_rgb", checkasm_check_sw_rgb }, { "sw_scale", checkasm_check_sw_scale }, + { "sw_xyz2rgb", checkasm_check_sw_xyz2rgb }, { "sw_yuv2rgb", checkasm_check_sw_yuv2rgb }, { "sw_yuv2yuv", checkasm_check_sw_yuv2yuv }, { "sw_ops", checkasm_check_sw_ops }, diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index ec075c4763..9f4fb8b283 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -139,6 +139,7 @@ void checkasm_check_sw_gbrp(void); void checkasm_check_sw_range_convert(void); void checkasm_check_sw_rgb(void); void checkasm_check_sw_scale(void); +void checkasm_check_sw_xyz2rgb(void); void checkasm_check_sw_yuv2rgb(void); void checkasm_check_sw_yuv2yuv(void); void checkasm_check_sw_ops(void); diff --git a/tests/checkasm/sw_xyz2rgb.c b/tests/checkasm/sw_xyz2rgb.c new file mode 100644 index 0000000000..afffb6c8da --- /dev/null +++ b/tests/checkasm/sw_xyz2rgb.c @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2025 Arpad Panyik + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include "libavutil/intreadwrite.h" +#include "libavutil/mem_internal.h" +#include "libavutil/pixdesc.h" +#include "libavutil/pixfmt.h" + +#include "libswscale/swscale.h" +#include "libswscale/swscale_internal.h" + +#include "checkasm.h" + +#define NUM_LINES 4 +#define MAX_LINE_SIZE 1920 + +#define randomize_buffers(buf, size) \ + do { \ + for (int j = 0; j < size; j += 2) \ + AV_WN32(buf + j, rnd()); \ + } while (0) + +static void check_xyz12Torgb48le(void) +{ + static const int input_sizes[] = {1, 2, 3, 4, 5, 6, 7, 8, 16, 17, 21, 31, + 32, 64, 128, 256, 512, 1024, + MAX_LINE_SIZE}; + + const int src_stride = 3 * sizeof(uint16_t) * MAX_LINE_SIZE; + const int dst_stride = src_stride; + + const int src_pix_fmt = AV_PIX_FMT_XYZ12LE; + const int dst_pix_fmt = AV_PIX_FMT_RGB48LE; + + const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(src_pix_fmt); + const AVPixFmtDescriptor *dst_desc = av_pix_fmt_desc_get(dst_pix_fmt); + + LOCAL_ALIGNED_8(uint16_t, src, [3 * MAX_LINE_SIZE * NUM_LINES]); + LOCAL_ALIGNED_8(uint16_t, dst_ref, [3 * MAX_LINE_SIZE * NUM_LINES]); + LOCAL_ALIGNED_8(uint16_t, dst_new, [3 * MAX_LINE_SIZE * NUM_LINES]); + + declare_func(void, const SwsContext *, uint8_t *, int, const uint8_t *, + int, int, int); + + SwsInternal c; + memset(&c, 0, sizeof(c)); + c.opts.src_format = src_pix_fmt; + ff_sws_init_xyzdsp(&c); + ff_sws_fill_xyztables(&c); + + randomize_buffers(src, 3 * MAX_LINE_SIZE * NUM_LINES); + + for (int height = 1; height <= NUM_LINES; height++) { + for (int isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++) { + int width = input_sizes[isi]; + + if (check_func(c.xyz12Torgb48, "%s_%s_%dx%d", src_desc->name, + dst_desc->name, width, height)) { + memset(dst_ref, 0xFE, + 3 * sizeof(uint16_t) * MAX_LINE_SIZE * NUM_LINES); + memset(dst_new, 0xFE, + 3 * sizeof(uint16_t) * MAX_LINE_SIZE * NUM_LINES); + + call_ref((const SwsContext*)&c, (uint8_t *)dst_ref, dst_stride, + (const uint8_t *)src, src_stride, width, height); + call_new((const SwsContext*)&c, (uint8_t *)dst_new, dst_stride, + (const uint8_t *)src, src_stride, width, height); + + checkasm_check(uint16_t, dst_ref, dst_stride, dst_new, + dst_stride, width, height, "dst_rgb"); + + if (!(width & 3) && height == NUM_LINES) { + bench_new((const SwsContext*)&c, (uint8_t *)dst_new, + dst_stride, (const uint8_t *)src, src_stride, + width, height); + } + } + } + } +} + +#undef NUM_LINES +#undef MAX_LINE_SIZE + +void checkasm_check_sw_xyz2rgb(void) +{ + check_xyz12Torgb48le(); + report("xyz12Torgb48le"); +} diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak index 48edd17bf2..f26e534591 100644 --- a/tests/fate/checkasm.mak +++ b/tests/fate/checkasm.mak @@ -55,6 +55,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp \ fate-checkasm-sw_range_convert \ fate-checkasm-sw_rgb \ fate-checkasm-sw_scale \ + fate-checkasm-sw_xyz2rgb \ fate-checkasm-sw_yuv2rgb \ fate-checkasm-sw_yuv2yuv \ fate-checkasm-takdsp \