tests/checkasm: Add huffyuvencdsp test

Only covers sub_hfyu_median_pred_int16 for now.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2026-02-25 21:38:30 +01:00
parent 2268ba89f0
commit fd44e277c8
5 changed files with 95 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ AVCODECOBJS-$(CONFIG_H264DSP) += h264dsp.o
AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o
AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o
AVCODECOBJS-$(CONFIG_HPELDSP) += hpeldsp.o
AVCODECOBJS-$(CONFIG_HUFFYUVENCDSP) += huffyuvencdsp.o
AVCODECOBJS-$(CONFIG_IDCTDSP) += idctdsp.o
AVCODECOBJS-$(CONFIG_LLAUDDSP) += llauddsp.o
AVCODECOBJS-$(CONFIG_LLVIDDSP) += llviddsp.o

View File

@@ -198,6 +198,9 @@ static const struct {
#if CONFIG_HUFFYUV_DECODER
{ "huffyuvdsp", checkasm_check_huffyuvdsp },
#endif
#if CONFIG_HUFFYUVENCDSP
{ "huffyuvencdsp", checkasm_check_huffyuvencdsp },
#endif
#if CONFIG_IDCTDSP
{ "idctdsp", checkasm_check_idctdsp },
#endif

View File

@@ -116,6 +116,7 @@ void checkasm_check_hevc_pel(void);
void checkasm_check_hevc_sao(void);
void checkasm_check_hpeldsp(void);
void checkasm_check_huffyuvdsp(void);
void checkasm_check_huffyuvencdsp(void);
void checkasm_check_idctdsp(void);
void checkasm_check_idet(void);
void checkasm_check_jpeg2000dsp(void);

View File

@@ -0,0 +1,89 @@
/*
* 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 <stddef.h>
#include <stdint.h>
#include <string.h>
#include "checkasm.h"
#include "libavcodec/huffyuvencdsp.h"
#include "libavutil/cpu.h"
#include "libavutil/macros.h"
#include "libavutil/mem_internal.h"
enum {
MAX_WIDTH = 4096, ///< maximum test width, must be a power of two smaller than the maximum alignment
};
#define randomize_buffers(buf, size, mask) \
do { \
for (size_t j = 0; j < size; ++j) \
buf[j] = rnd() & mask; \
} while (0)
static void check_sub_hfyu_median_pred_int16(const char *aligned, unsigned width)
{
static const int bpps[] = { 9, 16, };
HuffYUVEncDSPContext c;
declare_func_emms(AV_CPU_FLAG_MMXEXT, void, uint16_t *dst, const uint16_t *src1,
const uint16_t *src2, unsigned mask, int w, int *left, int *left_top);
for (size_t i = 0; i < FF_ARRAY_ELEMS(bpps); ++i) {
const int bpp = bpps[i];
ff_huffyuvencdsp_init(&c, bpp);
if (check_func(c.sub_hfyu_median_pred_int16, "sub_hfyu_median_pred_int16_%dbpp%s", bpp, aligned)) {
DECLARE_ALIGNED(32, uint16_t, dst0)[MAX_WIDTH];
DECLARE_ALIGNED(32, uint16_t, dst1)[MAX_WIDTH];
uint16_t src1[MAX_WIDTH];
uint16_t src2[MAX_WIDTH];
const unsigned mask = (1 << bpp) - 1;
int l1 = rnd() & mask, lt1 = rnd() & mask, l2 = l1, lt2 = lt1;
randomize_buffers(src1, width, mask);
randomize_buffers(src2, width, mask);
call_ref(dst0, src1, src2, mask, width, &l1, &lt1);
call_new(dst1, src1, src2, mask, width, &l2, &lt2);
if (l1 != l2 || lt1 != lt2 || memcmp(dst0, dst1, width * sizeof(dst0[0])))
fail();
bench_new(dst1, src1, src2, mask, width, &l2, &lt2);
}
}
}
void checkasm_check_huffyuvencdsp(void)
{
static unsigned width = 0;
if (!width) {
width = rnd() % MAX_WIDTH;
width = width ? width : 1;
}
const size_t align = av_cpu_max_align();
check_sub_hfyu_median_pred_int16("_aligned", FFALIGN(width, align / sizeof(uint16_t)));
report("sub_hfyu_median_pred_int16_aligned");
check_sub_hfyu_median_pred_int16("", width);
report("sub_hfyu_median_pred_int16");
}

View File

@@ -33,6 +33,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp \
fate-checkasm-hevc_sao \
fate-checkasm-hpeldsp \
fate-checkasm-huffyuvdsp \
fate-checkasm-huffyuvencdsp \
fate-checkasm-idctdsp \
fate-checkasm-jpeg2000dsp \
fate-checkasm-llauddsp \