tests/checkasm: Add huffyuvencdsp test
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Wed, 25 Feb 2026 20:38:30 +0000 (21:38 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Sun, 1 Mar 2026 10:56:57 +0000 (11:56 +0100)
Only covers sub_hfyu_median_pred_int16 for now.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
tests/checkasm/Makefile
tests/checkasm/checkasm.c
tests/checkasm/checkasm.h
tests/checkasm/huffyuvencdsp.c [new file with mode: 0644]
tests/fate/checkasm.mak

index 48de4d22a005837f65243cdc0fe894f94295be79..491bde2a7a146dac61056c4ffe804733ae7b5067 100644 (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
index bdaaa8695ddc61aa0b1ac95e4f5bb6fec818ce62..38bd1edce759439ba3a4775409390c7a22d65680 100644 (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
index 9495c9e19a104352e8e968406bb7738ebd4f4dbe..568b40530c33e08446bcbecaa19cfb2d86bc1a99 100644 (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);
diff --git a/tests/checkasm/huffyuvencdsp.c b/tests/checkasm/huffyuvencdsp.c
new file mode 100644 (file)
index 0000000..049a7d1
--- /dev/null
@@ -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");
+}
index 16c6f1f775fb5a0f096b1a2d60cd4ab28f71e1dc..b05dc61f675c863d37dfd3b38a8ccd4059b426af 100644 (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                                  \