PR #23940 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23940
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23940.patch

Also fix a segfault in av_tx when using --repeat (in a different way to #23796).


From 0d6b643a67db6679c6204255a9bd4a8dccf4f1ed Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Tue, 28 Jul 2026 11:36:30 +0200
Subject: [PATCH 1/9] Squashed 'tests/checkasm/ext/' changes from
 e13b0bb3ff..e46c473f73

e46c473f73 Re-order conditional (mostly cosmetic)
16738f028d Seed PRNG before running CheckasmTest.init()
9292f9cf6d Bikeshed summary line a bit more, especially for interrupted runs
0f03612ec9 Suppress non-failure output after first iteration
bfdb230dd9 checkasm: Print statusline to track current test/bench progress
c8996a284b checkasm: Move test iteration variable to global state
46e136ee0e utils: Add self-repainting statusline buffer
800053edca Route all log messages through checkasm_fprintf()
f6791fee59 utils: Redefine checkasm_fprintf() as checkasm_vfprintf()
629a211feb Add optional CheckasmTest.init() and uninit()
354f3d3e8d riscv/callcheck: Avoid out-of-range li immediate under LLVM on rv32
6e1b4cd6ca riscv/cpu: Include <asm/unistd.h> for __NR_riscv_hwprobe
8130043b32 Fix CPU detection for AVX512F
9760810b49 Support YMM copy tests on processors with only AVX
dc8c320313 Support XMM copy tests on processors with only SSE

git-subtree-dir: tests/checkasm/ext
git-subtree-split: e46c473f73e747301d44d2e7f8117e23f9a06f64
---
 include/checkasm/checkasm.h |  18 +++-
 src/checkasm.c              | 174 +++++++++++++++++++++++-------------
 src/internal.h              |  21 ++++-
 src/riscv/callcheck.S       |   2 +-
 src/riscv/cpu.c             |   1 +
 src/utils.c                 |  51 +++++++++--
 src/x86/cpu.c               |   2 +-
 tests/selftest.c            |   4 +-
 tests/tests.h               |   4 +-
 tests/x86/tests.c           |  37 ++++----
 tests/x86/tests_asm.asm     |  10 +--
 11 files changed, 221 insertions(+), 103 deletions(-)

diff --git a/include/checkasm/checkasm.h b/include/checkasm/checkasm.h
index fc40fab4cd..a86f41c72a 100644
--- a/include/checkasm/checkasm.h
+++ b/include/checkasm/checkasm.h
@@ -117,6 +117,20 @@ typedef struct CheckasmCpuInfo {
 typedef struct CheckasmTest {
     const char *name;   /**< Name of the test (used for filtering and 
reporting) */
     void (*func)(void); /**< Test function to invoke */
+
+    /**
+     * @brief Optional initialization function
+     *
+     * These functions, if set, are invoked before testing any CPU flags
+     * and after testing all CPU flags, respectively.
+     *
+     * @note If CheckasmConfig.repeat > 1, they will be called for every
+     * iteration.
+     *
+     * @warning These are called even when running checkasm_list_functions().
+     */
+    void (*init)(void);
+    void (*uninit)(void);
 } CheckasmTest;
 
 /**
@@ -362,7 +376,9 @@ CHECKASM_API void checkasm_list_tests(const CheckasmConfig 
*config);
  * @note This requires executing all tests to gather information about the
  *       available functions. During this process, checkasm_check_func() always
  *       returns 0 to skip the actual testing. However, any side effects from
- *       test functions will still occur, unless properly guarded.
+ *       test functions will still occur, unless properly guarded. In
+ *       particular, CheckasmTest.init() and CheckasmTest.uninit() will still
+ *       be executed.
  */
 CHECKASM_API void checkasm_list_functions(const CheckasmConfig *config);
 
diff --git a/src/checkasm.c b/src/checkasm.c
index e10cfa23eb..2ebebaec3d 100644
--- a/src/checkasm.c
+++ b/src/checkasm.c
@@ -108,6 +108,7 @@ static struct {
     /* Miscellaneous global state (cosmetic) */
     int max_function_name_length;
     int max_report_name_length;
+    unsigned test_iter;
 
     /* Timing code measurements (aggregated over multiple trials) */
     CheckasmMeasurement nop_cycles;
@@ -523,6 +524,12 @@ static int wildstrcmp(const char *str, const char *pattern)
 }
 
 static void handle_interrupt(void);
+static void update_statusline(void);
+
+static int test_enabled(const CheckasmTest *test)
+{
+    return !cfg.test_pattern || !wildstrcmp(test->name, cfg.test_pattern);
+}
 
 /* Perform tests and benchmarks for the specified
  * cpu flag if supported by the host */
@@ -550,9 +557,10 @@ static void check_cpu_flag(const CheckasmCpuInfo *cpu)
         cfg.set_cpu_flags(current.cpu_flags);
 
     for (const CheckasmTest *test = cfg.tests; test->func; test++) {
-        if (cfg.test_pattern && wildstrcmp(test->name, cfg.test_pattern))
+        if (!test_enabled(test))
             continue;
         current.test_name = test->name;
+        update_statusline();
 
         if (checkasm_save_context(checkasm_context)) {
             const char *signal = checkasm_get_last_signal_desc();
@@ -592,8 +600,7 @@ static void check_cpu_flag(const CheckasmCpuInfo *cpu)
 static void print_cpu_name(void)
 {
     if (!current.cpu_name_printed) {
-        checkasm_fprintf(stderr, COLOR_YELLOW, "%s:\n",
-                         current.cpu ? current.cpu->name : "C");
+        LOG_COLOR(COLOR_YELLOW, "%s:\n", current.cpu ? current.cpu->name : 
"C");
         current.cpu_name_printed = 1;
     }
 }
@@ -652,15 +659,15 @@ static int set_cpu_affinity(const unsigned affinity)
 #else
     (void) affinity;
     (void) affinity_err;
-    fprintf(stderr, "checkasm: --affinity is not supported on your system\n");
+    LOG("checkasm: --affinity is not supported on your system\n");
     return 1;
 #endif
 
     if (affinity_err) {
-        fprintf(stderr, "checkasm: invalid cpu affinity (%u)\n", affinity);
+        LOG("checkasm: invalid cpu affinity (%u)\n", affinity);
         return 1;
     } else {
-        fprintf(stderr, "checkasm: running on cpu %u\n", affinity);
+        LOG("checkasm: running on cpu %u\n", affinity);
         return 0;
     }
 }
@@ -697,6 +704,25 @@ static void print_functions(const CheckasmFunc *const f)
     }
 }
 
+static void run_all_tests(void)
+{
+    for (const CheckasmTest *test = cfg.tests; test->func; test++) {
+        if (test->init && test_enabled(test)) {
+            checkasm_srand(cfg.seed);
+            test->init();
+        }
+    }
+
+    check_cpu_flag(NULL);
+    for (const CheckasmCpuInfo *info = cfg.cpu_flags; info->flag; info++)
+        check_cpu_flag(info);
+
+    for (const CheckasmTest *test = cfg.tests; test->func; test++) {
+        if (test->uninit && test_enabled(test))
+            test->uninit();
+    }
+}
+
 void checkasm_list_functions(const CheckasmConfig *config)
 {
     memset(&state, 0, sizeof(state));
@@ -704,9 +730,7 @@ void checkasm_list_functions(const CheckasmConfig *config)
     state.skip_tests = 1;
     cfg              = *config;
 
-    check_cpu_flag(NULL);
-    for (const CheckasmCpuInfo *info = cfg.cpu_flags; info->flag; info++)
-        check_cpu_flag(info);
+    run_all_tests();
 
     print_functions(current.tree.root);
     checkasm_func_tree_uninit(&current.tree);
@@ -726,45 +750,79 @@ static void cpu_fprintf(void *priv, const char *fmt, ...)
 
 static COLD void print_info(void)
 {
-    checkasm_fprintf(stderr, COLOR_YELLOW, "checkasm:\n");
+    LOG_COLOR(COLOR_YELLOW, "checkasm:\n");
     checkasm_cpu_info(cpu_fprintf, stderr, &cfg);
 
     if (cfg.bench) {
-        fprintf(stderr, " - Timing source: %s\n", checkasm_perf.name);
+        LOG(" - Timing source: %s\n", checkasm_perf.name);
         if (cfg.verbose) {
             const CheckasmVar perf_scale = 
checkasm_measurement_result(state.perf_scale);
             const CheckasmVar nop_cycles = 
checkasm_measurement_result(state.nop_cycles);
             const CheckasmVar mhz = checkasm_var_div(checkasm_var_const(1e3), 
perf_scale);
-            fprintf(stderr,
-                    " - Timing resolution: %.4f +/- %.3f ns/%s (%.0f +/- %.1f "
-                    "MHz) (provisional)\n",
-                    checkasm_mode(perf_scale), checkasm_stddev(perf_scale),
-                    checkasm_perf.unit, checkasm_mode(mhz), 
checkasm_stddev(mhz));
+            LOG(" - Timing resolution: %.4f +/- %.3f ns/%s (%.0f +/- %.1f "
+                "MHz) (provisional)\n",
+                checkasm_mode(perf_scale), checkasm_stddev(perf_scale),
+                checkasm_perf.unit, checkasm_mode(mhz), checkasm_stddev(mhz));
 
-            fprintf(stderr,
-                    " - No-op overhead: %.2f +/- %.3f %ss per call 
(provisional)\n",
-                    checkasm_mode(nop_cycles), checkasm_stddev(nop_cycles),
-                    checkasm_perf.unit);
+            LOG(" - No-op overhead: %.2f +/- %.3f %ss per call 
(provisional)\n",
+                checkasm_mode(nop_cycles), checkasm_stddev(nop_cycles),
+                checkasm_perf.unit);
         }
-        fprintf(stderr, " - Bench duration: %d µs per function (%" PRIu64 " 
%ss)\n",
-                cfg.bench_usec, state.target_cycles, checkasm_perf.unit);
+        LOG(" - Bench duration: %d µs per function (%" PRIu64 " %ss)\n", 
cfg.bench_usec,
+            state.target_cycles, checkasm_perf.unit);
     }
-    fprintf(stderr, " - Random seed: %u\n", cfg.seed);
+    LOG(" - Random seed: %u\n", cfg.seed);
 }
 
-static int print_summary(void)
+static void update_statusline(void)
 {
+    if (state.skip_tests)
+        return;
+
+    char status[256];
+    int len = 0;
+
+    len += snprintf(status, sizeof(status), "checkasm: iter=%d/%d cpu=%s 
test=%s",
+                    state.test_iter + 1, cfg.repeat, cpu_suffix(current.cpu),
+                    current.test_name);
+
+    if (current.func && current.func->report_name) {
+        snprintf(status + len, sizeof(status) - len, " func=%s",
+                 current.func->report_name);
+    }
+
+    checkasm_statusline(status);
+}
+
+static int print_summary(int interrupted)
+{
+    checkasm_statusline(NULL);
+
+    LOG("checkasm: ");
+    if (interrupted)
+        LOG_COLOR(COLOR_BLUE, "(interrupted) ");
+
     /* Exclude C/ref versions from count reported to user */
     const int num_checked_asm = current.num_checked - current.num_funcs;
     if (current.num_failed) {
-        fprintf(stderr, "checkasm: %d of %d tests failed\n", 
current.num_failed,
-                num_checked_asm);
+        LOG_COLOR(COLOR_RED, "%d ", current.num_failed);
+        LOG("of %d tests failed", num_checked_asm);
     } else if (num_checked_asm) {
-        fprintf(stderr, "checkasm: all %d tests passed\n", num_checked_asm);
+        if (!interrupted)
+            LOG("all ");
+        LOG("%d tests passed", num_checked_asm);
+    } else if (interrupted) {
+        LOG("no tests performed");
     } else {
-        fprintf(stderr, "checkasm: no tests to perform\n");
+        /* User did not define any tests */
+        LOG_COLOR(COLOR_YELLOW, "no tests to perform");
     }
 
+    if (cfg.repeat > 1)
+        LOG(", iteration %d of %d, seed %u\n", state.test_iter + 1, 
cfg.repeat, cfg.seed);
+    else
+        LOG("\n");
+
     if (current.num_benched && !current.num_failed)
         print_benchmarks();
 
@@ -774,8 +832,7 @@ static int print_summary(void)
 static void handle_interrupt(void)
 {
     if (checkasm_interrupted) {
-        fprintf(stderr, "checkasm: interrupted\n");
-        print_summary();
+        print_summary(1);
         exit(128 + checkasm_interrupted);
     }
 }
@@ -784,7 +841,7 @@ int checkasm_run(const CheckasmConfig *config)
 {
 #if !HAVE_HTML_DATA
     if (cfg.format == CHECKASM_FORMAT_HTML) {
-        fprintf(stderr, "checkasm: built without HTML support\n");
+        LOG("checkasm: built without HTML support\n");
         return 1;
     }
 #endif
@@ -837,17 +894,10 @@ int checkasm_run(const CheckasmConfig *config)
 
     print_info();
 
-    for (unsigned i = 0; i < cfg.repeat; i++) {
-        if (i > 0) {
-            checkasm_fprintf(stderr, COLOR_YELLOW, "\nTest #%d:\n", i + 1);
-            fprintf(stderr, " - Random seed: %u\n", cfg.seed);
-        }
+    for (state.test_iter = 0; state.test_iter < cfg.repeat; state.test_iter++) 
{
+        run_all_tests();
 
-        check_cpu_flag(NULL);
-        for (const CheckasmCpuInfo *info = cfg.cpu_flags; info->flag; info++)
-            check_cpu_flag(info);
-
-        int res = print_summary();
+        int res = print_summary(0);
         checkasm_func_tree_uninit(&current.tree);
         if (res)
             return res;
@@ -949,6 +999,7 @@ CheckasmKey checkasm_check_key(const CheckasmKey version, 
const char *const name
     current.func_ver = v;
     current.num_checked++;
     checkasm_srand(cfg.seed);
+    update_statusline();
 
     if (cfg.bench) {
 #if ARCH_X86
@@ -982,8 +1033,8 @@ static int fail_internal(const char *const msg, va_list 
arg)
     if (v && v->state == CHECKASM_FUNC_OK) {
         if (!current.should_fail) {
             print_cpu_name();
-            checkasm_fprintf(stderr, COLOR_RED, "FAILURE:");
-            fprintf(stderr, " %s_%s (", current.func->name, ver_suffix(v));
+            LOG_COLOR(COLOR_RED, "FAILURE:");
+            LOG(" %s_%s (", current.func->name, ver_suffix(v));
             vfprintf(stderr, msg, arg);
             fputs(")\n", stderr);
         }
@@ -1054,28 +1105,27 @@ void checkasm_report(const char *const name, ...)
         if (current.should_fail)
             current.num_failed = current.prev_failed + (new_checked - fails);
 
-        /* Omit "OK" for non-verbose non-benchmark C function successes */
-        const int want_print = current.num_failed != current.prev_failed
-                            || current.should_fail || cfg.verbose || cfg.bench
-                            || current.cpu;
+        /* Omit 'OK' after the first run, unless failed or verbose */
+        int want_print = current.num_failed != current.prev_failed || 
cfg.verbose;
+        if (state.test_iter == 0)
+            want_print |= current.should_fail || current.cpu;
 
         if (want_print) {
             print_cpu_name();
             if (name) {
-                pad_length -= fprintf(stderr, " - %s.%s", current.test_name, 
report_name);
+                pad_length -= LOG(" - %s.%s", current.test_name, report_name);
             } else {
-                pad_length -= fprintf(stderr, " - %s", current.test_name);
+                pad_length -= LOG(" - %s", current.test_name);
             }
-            fprintf(stderr, "%*c", imax(pad_length, 0) + 2, '[');
+            LOG("%*c", imax(pad_length, 0) + 2, '[');
 
-            if (current.num_failed == current.prev_failed) {
-                checkasm_fprintf(stderr, COLOR_GREEN,
-                                 current.should_fail ? "EXPECTED" : "OK");
-            } else if (!current.should_fail)
-                checkasm_fprintf(stderr, COLOR_RED, "FAILED");
+            if (current.num_failed == current.prev_failed)
+                LOG_COLOR(COLOR_GREEN, current.should_fail ? "EXPECTED" : 
"OK");
+            else if (!current.should_fail)
+                LOG_COLOR(COLOR_RED, "FAILED");
             else
-                checkasm_fprintf(stderr, COLOR_RED, "%d/%d EXPECTED", fails, 
new_checked);
-            fprintf(stderr, "]\n");
+                LOG_COLOR(COLOR_RED, "%d/%d EXPECTED", fails, new_checked);
+            LOG("]\n");
         }
 
         current.prev_checked = current.num_checked;
@@ -1170,13 +1220,13 @@ int checkasm_main(CheckasmConfig *config, int argc, 
const char *argv[])
 #if HAVE_HTML_DATA
             config->format = CHECKASM_FORMAT_HTML;
 #else
-            fprintf(stderr, "checkasm: built without HTML support\n");
+            LOG("checkasm: built without HTML support\n");
             return 1;
 #endif
         } else if (!strncmp(argv[1], "--duration=", 11)) {
             const char *const s = argv[1] + 11;
             if (!parseu(&config->bench_usec, s, 10)) {
-                fprintf(stderr, "checkasm: invalid duration (%s)\n", s);
+                LOG("checkasm: invalid duration (%s)\n", s);
                 print_usage(argv[0]);
                 return 1;
             }
@@ -1198,14 +1248,14 @@ int checkasm_main(CheckasmConfig *config, int argc, 
const char *argv[])
             const char *const s      = argv[1] + 11;
             config->cpu_affinity_set = 1;
             if (!parseu(&config->cpu_affinity, s, 16)) {
-                fprintf(stderr, "checkasm: invalid cpu affinity (%s)\n", s);
+                LOG("checkasm: invalid cpu affinity (%s)\n", s);
                 print_usage(argv[0]);
                 return 1;
             }
         } else if (!strncmp(argv[1], "--repeat=", 9)) {
             const char *const s = argv[1] + 9;
             if (!parseu(&config->repeat, s, 10)) {
-                fprintf(stderr, "checkasm: invalid number of repetitions 
(%s)\n", s);
+                LOG("checkasm: invalid number of repetitions (%s)\n", s);
                 print_usage(argv[0]);
                 return 1;
             }
@@ -1214,7 +1264,7 @@ int checkasm_main(CheckasmConfig *config, int argc, const 
char *argv[])
         } else {
             config->seed_set = 1;
             if (!parseu(&config->seed, argv[1], 10)) {
-                fprintf(stderr, "checkasm: unknown option (%s)\n", argv[1]);
+                LOG("checkasm: unknown option (%s)\n", argv[1]);
                 print_usage(argv[0]);
                 return 1;
             }
diff --git a/src/internal.h b/src/internal.h
index dd698cbc84..6192ede221 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -109,8 +109,25 @@ NORETURN void checkasm_fail_abort(const char *msg, ...) 
CHECKASM_PRINTF(1, 2);
 
 /* Colored variant of fprintf for terminals that support it */
 void checkasm_setup_fprintf(void);
-void checkasm_fprintf(FILE *const f, const int color, const char *const fmt, 
...)
-    CHECKASM_PRINTF(3, 4);
+int checkasm_vfprintf(FILE *const f, int color, const char *fmt, va_list arg)
+    CHECKASM_PRINTF(3, 0);
+
+CHECKASM_PRINTF(3, 4)
+static inline int checkasm_fprintf(FILE *const f, int color, const char *fmt, 
...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    int ret = checkasm_vfprintf(f, color, fmt, ap);
+    va_end(ap);
+    return ret;
+}
+
+#define LOG_COLOR(...) checkasm_fprintf(stderr, __VA_ARGS__)
+#define LOG(...)       LOG_COLOR(COLOR_DEFAULT, __VA_ARGS__)
+
+/* Update the statusline, reprinted automatically as needed. Pass NULL or an
+ * empty string ("") to clear it entirely. Maximum 256 characters */
+void checkasm_statusline(const char *status);
 
 /* Light-weight helper for printing nested JSON objects */
 typedef struct CheckasmJson {
diff --git a/src/riscv/callcheck.S b/src/riscv/callcheck.S
index 2fa6d3a873..2fad998eec 100644
--- a/src/riscv/callcheck.S
+++ b/src/riscv/callcheck.S
@@ -312,7 +312,7 @@ function checked_call_ifv, export=1, ext=zve32x
 .Lclobber_v:
         # Clobber the vector registers
         vsetvli t1, zero, e32, m8, ta, ma
-        li      t1, -0xdeadbeef
+        li      t1, 0x0badf00d
         vmv.v.x v0, t1
         vmv.v.x v8, t1
         vmv.v.x v16, t1
diff --git a/src/riscv/cpu.c b/src/riscv/cpu.c
index 9248babedd..4f3121086c 100644
--- a/src/riscv/cpu.c
+++ b/src/riscv/cpu.c
@@ -44,6 +44,7 @@
     #include <sys/hwprobe.h>
   #elif HAVE_ASM_HWPROBE_H
     #include <asm/hwprobe.h>
+    #include <asm/unistd.h>
     #include <sys/syscall.h>
     #include <unistd.h>
 
diff --git a/src/utils.c b/src/utils.c
index 768d3028ef..96e33525bd 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -361,22 +361,57 @@ DEF_CHECKASM_INIT_MASK(8, uint8_t)
 DEF_CHECKASM_INIT_MASK(16, uint16_t)
 
 static int use_printf_color[2];
+static char statusline[256];
+static int statusline_visible;
 
 /* Print colored text to stderr if the terminal supports it */
-void checkasm_fprintf(FILE *const f, const int color, const char *const fmt, 
...)
+int checkasm_vfprintf(FILE *const f, const int color, const char *const fmt, 
va_list arg)
 {
-    va_list arg;
-    int     use_color = use_printf_color[f == stderr];
+    size_t fmt_len = strlen(fmt);
+    int use_color = use_printf_color[f == stderr];
+    if (!use_color || !fmt_len)
+        return vfprintf(f, fmt, arg);
 
-    if (color >= 0 && use_color)
+    if (f == stderr && statusline_visible) {
+        fprintf(f, "\r\033[K"); /* clear line */
+        statusline_visible = 0;
+    }
+
+    if (color >= 0)
         fprintf(f, "\x1b[0;%dm", color);
 
-    va_start(arg, fmt);
-    vfprintf(f, fmt, arg);
-    va_end(arg);
+    int ret = vfprintf(f, fmt, arg);
 
-    if (color >= 0 && use_color)
+    if (color >= 0)
         fprintf(f, "\x1b[0m");
+
+    if (f == stderr && statusline[0] && fmt[fmt_len - 1] == '\n') {
+        fprintf(f, "%s", statusline);
+        statusline_visible = 1;
+    }
+
+    return ret;
+}
+
+void checkasm_statusline(const char *status)
+{
+    if (!status)
+        status = "";
+
+    if (!use_printf_color[1] || !strcmp(statusline, status))
+        return; /* don't re-paint unchanged status */
+
+    snprintf(statusline, sizeof(statusline), "%s", status);
+
+    if (statusline_visible) {
+        fprintf(stderr, "\r\033[K");
+        statusline_visible = 0;
+    }
+
+    if (statusline[0]) {
+        fprintf(stderr, "%s", statusline);
+        statusline_visible = 1;
+    }
 }
 
 static COLD int should_use_color(FILE *const f)
diff --git a/src/x86/cpu.c b/src/x86/cpu.c
index 62fa4c55a0..f404204072 100644
--- a/src/x86/cpu.c
+++ b/src/x86/cpu.c
@@ -167,7 +167,7 @@ static COLD checkasm_simd_warmup_func get_simd_warmup(void)
         return simd_warmup;
 
     checkasm_cpu_cpuid(&r, 7, 0);
-    if (r.ebx & 0x00000020) /* AVX512F */
+    if (r.ebx & 0x00010000) /* AVX512F */
         simd_warmup = checkasm_warmup_avx512;
 
     return simd_warmup;
diff --git a/tests/selftest.c b/tests/selftest.c
index 7ac52d7a1b..4711129ed7 100644
--- a/tests/selftest.c
+++ b/tests/selftest.c
@@ -6,8 +6,8 @@ static const CheckasmCpuInfo cpus[] = {
 #if ARCH_X86
     { "Generic x86",     "x86",     SELFTEST_CPU_FLAG_X86     },
     { "MMX",             "mmx",     SELFTEST_CPU_FLAG_MMX     },
-    { "SSE2",            "sse2",    SELFTEST_CPU_FLAG_SSE2    },
-    { "AVX-2",           "avx2",    SELFTEST_CPU_FLAG_AVX2    },
+    { "SSE",             "sse",     SELFTEST_CPU_FLAG_SSE     },
+    { "AVX",             "avx",     SELFTEST_CPU_FLAG_AVX     },
     { "AVX-512",         "avx512",  SELFTEST_CPU_FLAG_AVX512  },
 #endif
 #if ARCH_RISCV
diff --git a/tests/tests.h b/tests/tests.h
index f3f9c04635..5f2d990802 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -41,8 +41,8 @@ enum {
 #if ARCH_X86
     SELFTEST_CPU_FLAG_X86    = 1 << 1,
     SELFTEST_CPU_FLAG_MMX    = 1 << 2,
-    SELFTEST_CPU_FLAG_SSE2   = 1 << 3,
-    SELFTEST_CPU_FLAG_AVX2   = 1 << 4,
+    SELFTEST_CPU_FLAG_SSE    = 1 << 3,
+    SELFTEST_CPU_FLAG_AVX    = 1 << 4,
     SELFTEST_CPU_FLAG_AVX512 = 1 << 5,
 #elif ARCH_RISCV
     SELFTEST_CPU_FLAG_RVI    = 1 << 1,
diff --git a/tests/x86/tests.c b/tests/x86/tests.c
index 7c7277d9d5..377ec428a0 100644
--- a/tests/x86/tests.c
+++ b/tests/x86/tests.c
@@ -20,31 +20,30 @@ uint64_t selftest_get_cpu_flags_x86(void)
     checkasm_cpu_cpuid(&r, 1, 0);
     if (r.edx & 0x00800000) /* MMX */
         flags |= SELFTEST_CPU_FLAG_MMX;
-    if (r.edx & 0x02000000) /* SSE2 */
-        flags |= SELFTEST_CPU_FLAG_SSE2;
+    if (r.edx & 0x02000000) /* SSE */
+        flags |= SELFTEST_CPU_FLAG_SSE;
     if (~r.ecx & 0x18000000) /* OSXSAVE/AVX */
         return flags;
 
     const uint64_t xcr0 = checkasm_cpu_xgetbv(0);
-    if (max_leaf < 7 || ~xcr0 & 0x6) /* XMM/YMM */
+    if (~xcr0 & 0x6) /* XMM/YMM */
+        return flags;
+
+    flags |= SELFTEST_CPU_FLAG_AVX;
+
+    if (max_leaf < 7 || ~xcr0 & 0xe0) /* ZMM/OPMASK */
         return flags;
 
     checkasm_cpu_cpuid(&r, 7, 0);
-    if (r.ebx & 0x00000020) /* AVX2 */
-        flags |= SELFTEST_CPU_FLAG_AVX2;
-
-    if (~xcr0 & 0xe0) /* ZMM/OPMASK */
-        return flags;
-
-    if (r.ebx & 0x00000020) /* AVX512F */
+    if (r.ebx & 0x00010000) /* AVX512F */
         flags |= SELFTEST_CPU_FLAG_AVX512;
     return flags;
 }
 
 DEF_COPY_FUNC(copy_x86);
 DEF_COPY_FUNC(copy_mmx);
-DEF_COPY_FUNC(copy_sse2);
-DEF_COPY_FUNC(copy_avx2);
+DEF_COPY_FUNC(copy_sse);
+DEF_COPY_FUNC(copy_avx);
 DEF_COPY_FUNC(copy_avx512);
 
 DEF_NOOP_FUNC(clobber_r0);
@@ -69,7 +68,7 @@ DEF_NOOP_FUNC(sigill_x86);
 DEF_NOOP_FUNC(corrupt_stack_x86);
 
 DEF_COPY_FUNC(copy_noemms_mmx);
-DEF_COPY_FUNC(copy_novzeroupper_avx2);
+DEF_COPY_FUNC(copy_novzeroupper_avx);
 
 static copy_func *get_copy_x86(void)
 {
@@ -77,10 +76,10 @@ static copy_func *get_copy_x86(void)
 #if ARCH_X86
     if (flags & SELFTEST_CPU_FLAG_AVX512)
         return selftest_copy_avx512;
-    if (flags & SELFTEST_CPU_FLAG_AVX2)
-        return selftest_copy_avx2;
-    if (flags & SELFTEST_CPU_FLAG_SSE2)
-        return selftest_copy_sse2;
+    if (flags & SELFTEST_CPU_FLAG_AVX)
+        return selftest_copy_avx;
+    if (flags & SELFTEST_CPU_FLAG_SSE)
+        return selftest_copy_sse;
     if (flags & SELFTEST_CPU_FLAG_MMX)
         return selftest_copy_mmx;
     if (flags & SELFTEST_CPU_FLAG_X86)
@@ -134,7 +133,7 @@ static noop_func *get_clobber(int reg)
 DEF_NOOP_GETTER(SELFTEST_CPU_FLAG_X86, sigill_x86)
 DEF_NOOP_GETTER(SELFTEST_CPU_FLAG_X86, corrupt_stack_x86)
 DEF_COPY_GETTER(SELFTEST_CPU_FLAG_MMX, copy_noemms_mmx)
-DEF_COPY_GETTER(SELFTEST_CPU_FLAG_AVX2, copy_novzeroupper_avx2)
+DEF_COPY_GETTER(SELFTEST_CPU_FLAG_AVX, copy_novzeroupper_avx)
 
 uintptr_t selftest_get_stack_pointer_x86(int unused);
 
@@ -214,7 +213,7 @@ void selftest_check_x86(void)
     check_clobber(NUM_SAFE, NUM_REGS);
 
     if (checkasm_get_check_vzeroupper())
-        selftest_test_copy(get_copy_novzeroupper_avx2(), "novzeroupper", 32);
+        selftest_test_copy(get_copy_novzeroupper_avx(), "novzeroupper", 32);
 }
 
 #endif
diff --git a/tests/x86/tests_asm.asm b/tests/x86/tests_asm.asm
index 1af9e12dae..a2eeff47ee 100644
--- a/tests/x86/tests_asm.asm
+++ b/tests/x86/tests_asm.asm
@@ -99,15 +99,15 @@ copy_mm _noemms
 cglobal noemms, 3, 3, 0, dst, src, size
     RET
 
-; SSE2 functions
-INIT_XMM sse2
+; SSE functions
+INIT_XMM sse
 copy_mm
 
-; AVX2 functions
-INIT_YMM avx2
+; AVX functions
+INIT_YMM avx
 copy_mm
 copy_mm _novzeroupper
 
 ; AVX512 functions
-INIT_YMM avx512
+INIT_ZMM avx512
 copy_mm
-- 
2.52.0


From ed072cd002fa41636b55bdda8aeb1ad57eed5864 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Tue, 28 Jul 2026 01:40:12 +0200
Subject: [PATCH 2/9] tests/checkasm/av_tx: Fix segfault when using --repeat

The TX tests require a context that is initialized
for a specific set of CPU flags. So in order to have
a context for the reference function to use, the last
context is stored (in static storage). This works well
in normal usage, but it does work the --repeat feature
that has been added to checkasm by the switch to libcheckasm:
When the C functions ought to be tested a second time,
there is a mismatch between the new function pointer
(which is the C version) and the reference context
(which is initialized to optimized CPU flags; up until now,
there was no stored context when testing the C versions),
leading to segfaults.

Fix this by adding an uninit callback for the TX test,
replacing the atexit handler.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 tests/checkasm/av_tx.c    | 8 +-------
 tests/checkasm/checkasm.c | 2 +-
 tests/checkasm/checkasm.h | 2 ++
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/tests/checkasm/av_tx.c b/tests/checkasm/av_tx.c
index 2d7b4e662d..3bc66edf25 100644
--- a/tests/checkasm/av_tx.c
+++ b/tests/checkasm/av_tx.c
@@ -45,9 +45,8 @@ static const int check_lens[] = {
 };
 
 static AVTXContext *tx_refs[AV_TX_NB][2 /* Direction 
*/][FF_ARRAY_ELEMS(check_lens)] = { 0 };
-static int init = 0;
 
-static void free_tx_refs(void)
+void checkasm_uninit_tx(void)
 {
     for (int i = 0; i < FF_ARRAY_ELEMS(tx_refs); i++)
         for (int j = 0; j < FF_ARRAY_ELEMS(*tx_refs); j++)
@@ -121,9 +120,4 @@ void checkasm_check_av_tx(void)
     av_free(in);
     av_free(out_ref);
     av_free(out_new);
-
-    if (!init) {
-        init = 1;
-        atexit(free_tx_refs);
-    }
 }
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index a8cad59d4c..d394d3c61a 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -307,7 +307,7 @@ static const CheckasmTest tests[] = {
 #if CONFIG_PIXELUTILS
         { "pixelutils",checkasm_check_pixelutils },
 #endif
-        { "av_tx",     checkasm_check_av_tx },
+        { "av_tx",     checkasm_check_av_tx, .uninit = checkasm_uninit_tx },
 #endif
     { NULL }
     /* NOTE: When adding a new test to this list here, it also needs to be
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 70987b52f1..3e266c1626 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -133,6 +133,8 @@ void checkasm_check_vvc_alf(void);
 void checkasm_check_vvc_mc(void);
 void checkasm_check_vvc_sao(void);
 
+void checkasm_uninit_tx(void);
+
 #define rnd checkasm_rand_uint32
 #define declare_func_float declare_func
 #define bench(...) checkasm_bench(__VA_ARGS__)
-- 
2.52.0


From ab83d6e7b94fec10a5b25fd6b11bbcd2e1ce111e Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Tue, 28 Jul 2026 12:12:47 +0200
Subject: [PATCH 3/9] tests/checkasm/crc: Reset static stuff on repeat

In order to test random endianness and polynomial combinations,
the parameters (endianness, nb of bits, polynomial) have to be
the same for the optimized and the reference tables; therefore
said parameters are kept (in static storage) and up until now
initialized during the first run.

This has the downside that with --repeat one only ever tests
one random polynomial. Fix this by initializing the parameters
in an init callback. Also init the sizes and offsets there
(they were also kept for benchmark stability).

Also free the previously allocated custom tables in an uninit
callback to avoid using unnecessarily large amounts of memory;
it also makes Valgrind no longer report them as "still reachable".

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 tests/checkasm/checkasm.c |  2 +-
 tests/checkasm/checkasm.h |  3 ++
 tests/checkasm/crc.c      | 65 ++++++++++++++++++++++++---------------
 3 files changed, 44 insertions(+), 26 deletions(-)

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index d394d3c61a..b9cfc027e4 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -300,7 +300,7 @@ static const CheckasmTest tests[] = {
 #endif
 #if CONFIG_AVUTIL
         { "aes",       checkasm_check_aes },
-        { "crc",       checkasm_check_crc },
+        { "crc",       checkasm_check_crc, .init = checkasm_init_crc, .uninit 
= checkasm_uninit_crc },
         { "fixed_dsp", checkasm_check_fixed_dsp },
         { "float_dsp", checkasm_check_float_dsp },
         { "lls",       checkasm_check_lls },
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 3e266c1626..8cc0eb72f2 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -133,6 +133,9 @@ void checkasm_check_vvc_alf(void);
 void checkasm_check_vvc_mc(void);
 void checkasm_check_vvc_sao(void);
 
+void checkasm_init_crc(void);
+
+void checkasm_uninit_crc(void);
 void checkasm_uninit_tx(void);
 
 #define rnd checkasm_rand_uint32
diff --git a/tests/checkasm/crc.c b/tests/checkasm/crc.c
index d6fc9c2526..070f8aa6d4 100644
--- a/tests/checkasm/crc.c
+++ b/tests/checkasm/crc.c
@@ -33,6 +33,41 @@
 #include "libavutil/macros.h"
 #include "libavutil/mem_internal.h"
 
+enum {
+    BUF_SIZE = 16384,
+};
+
+typedef struct CustomTest {
+    struct CustomTest *prev;
+    AVCRC ctx[1024];
+} CustomTest;
+
+static CustomTest *ctx_list = NULL;
+static size_t offsets[AV_CRC_MAX + 1];
+static size_t sizes[AV_CRC_MAX + 1];
+static uint32_t poly;
+static int le, bits;
+
+void checkasm_init_crc(void)
+{
+    for (size_t i = 0; i < FF_ARRAY_ELEMS(offsets); ++i) {
+        offsets[i] = rnd() & 31;
+        sizes[i]   = rnd() % (BUF_SIZE - 1 - offsets[i]);
+    }
+    le   = rnd() & 1;
+    bits = 8 + rnd() % 25; // av_crc_init() accepts between 8 and 32 bits
+    poly = rnd() >> (32 - bits);
+}
+
+void checkasm_uninit_crc(void)
+{
+    for (CustomTest *cur = ctx_list; cur;) {
+        CustomTest *prev = cur->prev;
+        av_free(cur);
+        cur = prev;
+    }
+    ctx_list = NULL;
+}
 
 static void check_crc(const AVCRC *table_new, const char *name, unsigned idx)
 {
@@ -43,18 +78,9 @@ static void check_crc(const AVCRC *table_new, const char 
*name, unsigned idx)
     if (!table_ref)
         return;
 
-    DECLARE_ALIGNED(4, uint8_t, buf)[16384];
-    static size_t offsets[AV_CRC_MAX + 1];
-    static size_t sizes[AV_CRC_MAX + 1];
-    static unsigned sizes_initialized = 0;
+    DECLARE_ALIGNED(4, uint8_t, buf)[BUF_SIZE];
     uint32_t prev_crc = rnd();
 
-    if (!(sizes_initialized & (1 << idx))) {
-        sizes_initialized |= 1 << idx;
-        offsets[idx] = rnd() & 31;
-        sizes[idx] = rnd() % (sizeof(buf) - 1 - offsets[idx]);
-    }
-
     size_t size = sizes[idx];
     size_t offset = offsets[idx];
 
@@ -83,30 +109,19 @@ void checkasm_check_crc(void)
     for (unsigned i = 0; i < AV_CRC_MAX; ++i)
         check_crc(av_crc_get_table(i), tests[i], i);
 
-    static struct CustomTest {
-        struct CustomTest *prev;
-        AVCRC ctx[1024];
-    } *ctx = NULL;
     struct CustomTest *new = av_mallocz(sizeof(*new));
-    static int le, bits;
-    static uint32_t poly;
 
     if (!new)
         fail();
 
-    if (!ctx) {
-        le   = rnd() & 1;
-        bits = 8 + rnd() % 25; // av_crc_init() accepts between 8 and 32 bits
-        poly = rnd() >> (32 - bits);
-    }
     av_assert0(av_crc_init(new->ctx, le, bits, poly, sizeof(new->ctx)) >= 0);
-    if (ctx && !memcmp(ctx->ctx, new->ctx, sizeof(new->ctx))) {
+    if (ctx_list && !memcmp(ctx_list->ctx, new->ctx, sizeof(new->ctx))) {
         av_free(new);
     } else {
-        new->prev = ctx;
-        ctx = new;
+        new->prev = ctx_list;
+        ctx_list = new;
     }
 
-    check_crc(ctx->ctx, "custom_polynomial", AV_CRC_MAX);
+    check_crc(ctx_list->ctx, "custom_polynomial", AV_CRC_MAX);
     report("crc");
 }
-- 
2.52.0


From 88e6d888529e762dbdcba64d3f370e53d9b5e319 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Tue, 28 Jul 2026 12:48:00 +0200
Subject: [PATCH 4/9] tests/checkasm/sbcdsp: Set nb of blocks to test in init

It means that one does not only test one number of blocks
when using --repeat.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 tests/checkasm/checkasm.c |  2 +-
 tests/checkasm/checkasm.h |  1 +
 tests/checkasm/sbcdsp.c   | 10 +++++++---
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index b9cfc027e4..66bce23764 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -191,7 +191,7 @@ static const CheckasmTest tests[] = {
         { "rv40dsp", checkasm_check_rv40dsp },
     #endif
     #if CONFIG_SBC_ENCODER
-        { "sbcdsp", checkasm_check_sbcdsp },
+        { "sbcdsp", checkasm_check_sbcdsp, .init = checkasm_init_sbc },
     #endif
     #if CONFIG_SNOW_DECODER
         { "snowdsp", checkasm_check_snowdsp },
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 8cc0eb72f2..449ecb188c 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -134,6 +134,7 @@ void checkasm_check_vvc_mc(void);
 void checkasm_check_vvc_sao(void);
 
 void checkasm_init_crc(void);
+void checkasm_init_sbc(void);
 
 void checkasm_uninit_crc(void);
 void checkasm_uninit_tx(void);
diff --git a/tests/checkasm/sbcdsp.c b/tests/checkasm/sbcdsp.c
index 802eb430ed..b772605b16 100644
--- a/tests/checkasm/sbcdsp.c
+++ b/tests/checkasm/sbcdsp.c
@@ -35,6 +35,13 @@ do {                                                 \
         buf[k] = rnd();                              \
 } while (0)
 
+static int blocks;
+
+void checkasm_init_sbc(void)
+{
+    blocks = ((const int[]){4, 8, 12, 15, 16})[rnd() % 5];
+}
+
 static void check_sbc_analyze(SBCDSPContext *sbcdsp)
 {
     DECLARE_ALIGNED(SBC_ALIGN, int16_t, in)[10 * SBC_MAX_SUBBANDS];
@@ -79,9 +86,6 @@ static void check_sbc_calc_scalefactors(const SBCDSPContext 
*const sbcdsp)
                        uint32_t scale_factor[2][8],
                        int blocks, int channels, int subbands);
 
-    static int blocks = 0;
-    if (!blocks)
-        blocks = ((const int[]){4, 8, 12, 15, 16})[rnd() % 5];
     int inited = 0;
 
     for (int ch = 1; ch <= 2; ++ch) {
-- 
2.52.0


From 9c014f30a0f8ec62a24dc422c9aa46646756a27f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Tue, 28 Jul 2026 12:57:07 +0200
Subject: [PATCH 5/9] tests/checkasm/huffyuvencdsp: Set width in init

It means that one now tests multiple width values when using
--repeat.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 tests/checkasm/checkasm.c      |  2 +-
 tests/checkasm/checkasm.h      |  1 +
 tests/checkasm/huffyuvencdsp.c | 15 ++++++++-------
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 66bce23764..9a156b3c23 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -140,7 +140,7 @@ static const CheckasmTest tests[] = {
         { "huffyuvdsp", checkasm_check_huffyuvdsp },
     #endif
     #if CONFIG_HUFFYUVENCDSP
-        { "huffyuvencdsp", checkasm_check_huffyuvencdsp },
+        { "huffyuvencdsp", checkasm_check_huffyuvencdsp, .init = 
checkasm_init_huffyuvencdsp },
     #endif
     #if CONFIG_IDCTDSP
         { "idctdsp", checkasm_check_idctdsp },
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 449ecb188c..350aa5cbc9 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -134,6 +134,7 @@ void checkasm_check_vvc_mc(void);
 void checkasm_check_vvc_sao(void);
 
 void checkasm_init_crc(void);
+void checkasm_init_huffyuvencdsp(void);
 void checkasm_init_sbc(void);
 
 void checkasm_uninit_crc(void);
diff --git a/tests/checkasm/huffyuvencdsp.c b/tests/checkasm/huffyuvencdsp.c
index b5d02cda6d..795be241ea 100644
--- a/tests/checkasm/huffyuvencdsp.c
+++ b/tests/checkasm/huffyuvencdsp.c
@@ -36,6 +36,13 @@ enum {
             buf[j] = rnd() & mask;         \
     } while (0)
 
+static unsigned saved_width;
+
+void checkasm_init_huffyuvencdsp(void)
+{
+    saved_width = rnd() % MAX_WIDTH;
+    saved_width = saved_width ? saved_width : 1;
+}
 
 static void check_sub_hfyu_median_pred_int16(const char *aligned, unsigned 
width)
 {
@@ -72,14 +79,8 @@ static void check_sub_hfyu_median_pred_int16(const char 
*aligned, unsigned width
 
 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();
+    unsigned width = saved_width;
 
     check_sub_hfyu_median_pred_int16("_aligned", FFALIGN(width, align / 
sizeof(uint16_t)));
     report("sub_hfyu_median_pred_int16_aligned");
-- 
2.52.0


From c8580223082074b7546407561e8dbce6db42701f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Tue, 28 Jul 2026 13:16:05 +0200
Subject: [PATCH 6/9] tests/checkasm/llviddsp: Set width in init

It means that one now tests multiple width values when using
--repeat.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 tests/checkasm/checkasm.c |  2 +-
 tests/checkasm/checkasm.h |  1 +
 tests/checkasm/llviddsp.c | 11 +++++++----
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 9a156b3c23..f50a2c8370 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -152,7 +152,7 @@ static const CheckasmTest tests[] = {
         { "llauddsp", checkasm_check_llauddsp },
     #endif
     #if CONFIG_HUFFYUVDSP
-        { "llviddsp", checkasm_check_llviddsp },
+        { "llviddsp", checkasm_check_llviddsp, .init = checkasm_init_llviddsp 
},
     #endif
     #if CONFIG_LLVIDENCDSP
         { "llvidencdsp", checkasm_check_llvidencdsp },
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 350aa5cbc9..4be611f136 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -135,6 +135,7 @@ void checkasm_check_vvc_sao(void);
 
 void checkasm_init_crc(void);
 void checkasm_init_huffyuvencdsp(void);
+void checkasm_init_llviddsp(void);
 void checkasm_init_sbc(void);
 
 void checkasm_uninit_crc(void);
diff --git a/tests/checkasm/llviddsp.c b/tests/checkasm/llviddsp.c
index 1094638229..19f73e4ee9 100644
--- a/tests/checkasm/llviddsp.c
+++ b/tests/checkasm/llviddsp.c
@@ -42,6 +42,13 @@
     randomize_buffers(a0, width * sizeof(type));\
     memcpy(a1, a0, width*sizeof(type));\
 
+static int saved_width;
+
+void checkasm_init_llviddsp()
+{
+    saved_width = 16 * av_clip(rnd(), 16, 128);
+}
+
 static void check_add_bytes(LLVidDSPContext *c, int width)
 {
     uint8_t *dst0 = av_mallocz(width);
@@ -183,13 +190,9 @@ static void check_add_gradient_pred(LLVidDSPContext *c, 
int w) {
 void checkasm_check_llviddsp(void)
 {
     LLVidDSPContext c;
-    static int saved_width = 0;
     int width = saved_width;
     int accRnd = rnd() & 0xFF;
 
-    if (!width)
-        saved_width = width = 16 * av_clip(rnd(), 16, 128);
-
     ff_llviddsp_init(&c);
 
     if (check_func(c.add_bytes, "add_bytes"))
-- 
2.52.0


From ddae9f4de47cb73cc6acd2c219959abd6bd4ab71 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Tue, 28 Jul 2026 13:33:15 +0200
Subject: [PATCH 7/9] tests/checkasm/hpeldsp: Set nb of lines to process during
 init

It ensures that height is not constant (per test) when using
--repeat.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 tests/checkasm/checkasm.c |  2 +-
 tests/checkasm/checkasm.h |  1 +
 tests/checkasm/hpeldsp.c  | 42 ++++++++++++++++++++++++---------------
 3 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index f50a2c8370..1078f1116d 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -134,7 +134,7 @@ static const CheckasmTest tests[] = {
         { "hevc_sao", checkasm_check_hevc_sao },
     #endif
     #if CONFIG_HPELDSP
-        { "hpeldsp", checkasm_check_hpeldsp },
+        { "hpeldsp", checkasm_check_hpeldsp, .init = checkasm_init_hpeldsp },
     #endif
     #if CONFIG_HUFFYUVDSP
         { "huffyuvdsp", checkasm_check_huffyuvdsp },
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 4be611f136..a30431a351 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -134,6 +134,7 @@ void checkasm_check_vvc_mc(void);
 void checkasm_check_vvc_sao(void);
 
 void checkasm_init_crc(void);
+void checkasm_init_hpeldsp(void);
 void checkasm_init_huffyuvencdsp(void);
 void checkasm_init_llviddsp(void);
 void checkasm_init_sbc(void);
diff --git a/tests/checkasm/hpeldsp.c b/tests/checkasm/hpeldsp.c
index fd87509ddc..de545b15b1 100644
--- a/tests/checkasm/hpeldsp.c
+++ b/tests/checkasm/hpeldsp.c
@@ -50,6 +50,32 @@
         }                                                  \
     } while (0)
 
+static const struct {
+    const char *name;
+    size_t offset;
+    unsigned nb_blocksizes;
+} tests[] = {
+#define TEST(NAME, NB) { .name = #NAME, .offset = offsetof(HpelDSPContext, 
NAME), .nb_blocksizes = NB }
+    TEST(put_pixels_tab, 4),
+    TEST(avg_pixels_tab, 4),
+    TEST(put_no_rnd_pixels_tab, 2), // put_no_rnd_pixels_tab only has two 
usable blocksizes
+    TEST(avg_no_rnd_pixels_tab, 1),
+};
+
+static int saved_heights[FF_ARRAY_ELEMS(tests)][4][4];
+
+void checkasm_init_hpeldsp(void)
+{
+    for (size_t i = 0; i < FF_ARRAY_ELEMS(saved_heights); ++i)
+        for (unsigned j = 0; j < tests[i].nb_blocksizes; ++j) {
+            const unsigned blocksize = MAX_BLOCK_SIZE >> j;
+            // h must always be a multiple of four, except when width is two 
or four.
+            const unsigned h_mult = blocksize <= 4 ? 2 : 4;
+
+            for (unsigned dxy = 0; dxy < 4; ++dxy)
+                saved_heights[i][j][dxy] = (rnd() % (MAX_HEIGHT / h_mult) + 1) 
* h_mult;
+        }
+}
 
 void checkasm_check_hpeldsp(void)
 {
@@ -58,17 +84,6 @@ void checkasm_check_hpeldsp(void)
     DECLARE_ALIGNED(MAX_BLOCK_SIZE, uint8_t, dstbuf0)[BUF_SIZE];
     DECLARE_ALIGNED(MAX_BLOCK_SIZE, uint8_t, dstbuf1)[BUF_SIZE];
     HpelDSPContext hdsp;
-    static const struct {
-        const char *name;
-        size_t offset;
-        unsigned nb_blocksizes;
-    } tests[] = {
-#define TEST(NAME, NB) { .name = #NAME, .offset = offsetof(HpelDSPContext, 
NAME), .nb_blocksizes = NB }
-        TEST(put_pixels_tab, 4),
-        TEST(avg_pixels_tab, 4),
-        TEST(put_no_rnd_pixels_tab, 2), // put_no_rnd_pixels_tab only has two 
usable blocksizes
-        TEST(avg_no_rnd_pixels_tab, 1),
-    };
     declare_func(void, uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int 
h);
 
     ff_hpeldsp_init(&hdsp, AV_CODEC_FLAG_BITEXACT);
@@ -77,8 +92,6 @@ void checkasm_check_hpeldsp(void)
         op_pixels_func (*func_tab)[4] = (op_pixels_func (*)[4])((char*)&hdsp + 
tests[i].offset);
         for (unsigned j = 0; j < tests[i].nb_blocksizes; ++j) {
             const unsigned blocksize = MAX_BLOCK_SIZE >> j;
-            // h must always be a multiple of four, except when width is two 
or four.
-            const unsigned h_mult = blocksize <= 4 ? 2 : 4;
 
             for (unsigned dxy = 0; dxy < 4; ++dxy) {
                 if (check_func(func_tab[j][dxy], "%s[%u][%u]", tests[i].name, 
j, dxy)) {
@@ -91,10 +104,7 @@ void checkasm_check_hpeldsp(void)
 
                     // Always use the same height for each test, so that 
comparisons of benchmarks
                     // from different instruction sets are meaningful.
-                    static int saved_heights[FF_ARRAY_ELEMS(tests)][4][4];
                     int h = saved_heights[i][j][dxy];
-                    if (!h)
-                        saved_heights[i][j][dxy] = h = (rnd() % (MAX_HEIGHT / 
h_mult) + 1) * h_mult;
 
                     if (rnd() & 1) {
                         // Flip stride.
-- 
2.52.0


From d65b5ebac8189c839ea55ca6c873dd953289a88e Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Tue, 28 Jul 2026 16:15:00 +0200
Subject: [PATCH 8/9] tests/checkasm/checkasm: Remove inappropriate headers

Since the switch to libcheckasm, checkasm no longer uses
FFmpeg's emms_c, timers, AVLFG or string handling functions,
so remove these headers.
This necessitated adding some missing headers (mostly string.h)
to some files.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 tests/checkasm/aacpsdsp.c      | 2 ++
 tests/checkasm/aes.c           | 2 ++
 tests/checkasm/af_afir.c       | 2 ++
 tests/checkasm/apv_dsp.c       | 2 +-
 tests/checkasm/cavsdsp.c       | 1 +
 tests/checkasm/checkasm.h      | 5 -----
 tests/checkasm/crc.c           | 1 +
 tests/checkasm/diracdsp.c      | 2 ++
 tests/checkasm/float_dsp.c     | 1 +
 tests/checkasm/lls.c           | 3 +++
 tests/checkasm/mpeg4videodsp.c | 1 +
 tests/checkasm/opusdsp.c       | 2 ++
 tests/checkasm/png.c           | 1 +
 tests/checkasm/qpeldsp.c       | 1 +
 tests/checkasm/sbcdsp.c        | 1 +
 tests/checkasm/sbrdsp.c        | 2 ++
 tests/checkasm/vf_nlmeans.c    | 2 ++
 tests/checkasm/vf_pp7.c        | 1 +
 tests/checkasm/vorbisdsp.c     | 2 ++
 19 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/tests/checkasm/aacpsdsp.c b/tests/checkasm/aacpsdsp.c
index 359b1e9a00..7388ed03ef 100644
--- a/tests/checkasm/aacpsdsp.c
+++ b/tests/checkasm/aacpsdsp.c
@@ -16,6 +16,8 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <string.h>
+
 #include "libavcodec/aacpsdsp.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/mem_internal.h"
diff --git a/tests/checkasm/aes.c b/tests/checkasm/aes.c
index 4bbfc5750b..b0391ab1cb 100644
--- a/tests/checkasm/aes.c
+++ b/tests/checkasm/aes.c
@@ -18,6 +18,8 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <string.h>
+
 #include "checkasm.h"
 #include "libavutil/aes.h"
 #include "libavutil/aes_internal.h"
diff --git a/tests/checkasm/af_afir.c b/tests/checkasm/af_afir.c
index dba1531473..f30d22f266 100644
--- a/tests/checkasm/af_afir.c
+++ b/tests/checkasm/af_afir.c
@@ -20,6 +20,8 @@
 
 #include <float.h>
 #include <stdint.h>
+#include <stdio.h>
+#include <string.h>
 
 #include "libavfilter/af_afirdsp.h"
 #include "libavutil/internal.h"
diff --git a/tests/checkasm/apv_dsp.c b/tests/checkasm/apv_dsp.c
index 68c0f0313c..149c463763 100644
--- a/tests/checkasm/apv_dsp.c
+++ b/tests/checkasm/apv_dsp.c
@@ -17,10 +17,10 @@
  */
 
 #include <stdint.h>
+#include <string.h>
 
 #include "checkasm.h"
 
-#include "libavutil/attributes.h"
 #include "libavutil/mem_internal.h"
 #include "libavcodec/apv_dsp.h"
 
diff --git a/tests/checkasm/cavsdsp.c b/tests/checkasm/cavsdsp.c
index ab6b695ae4..47c2510687 100644
--- a/tests/checkasm/cavsdsp.c
+++ b/tests/checkasm/cavsdsp.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <stddef.h>
+#include <string.h>
 
 #include "checkasm.h"
 #include "libavutil/intreadwrite.h"
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index a30431a351..49380c1898 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -27,13 +27,8 @@
 #include <checkasm/test.h>
 #include <checkasm/utils.h>
 
-#include "config.h"
-#include "libavutil/avstring.h"
 #include "libavutil/cpu.h"
-#include "libavutil/emms.h"
 #include "libavutil/internal.h"
-#include "libavutil/lfg.h"
-#include "libavutil/timer.h"
 
 void checkasm_check_aacencdsp(void);
 void checkasm_check_aacpsdsp(void);
diff --git a/tests/checkasm/crc.c b/tests/checkasm/crc.c
index 070f8aa6d4..1338830c8c 100644
--- a/tests/checkasm/crc.c
+++ b/tests/checkasm/crc.c
@@ -31,6 +31,7 @@
 #include "libavutil/crc.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/macros.h"
+#include "libavutil/mem.h"
 #include "libavutil/mem_internal.h"
 
 enum {
diff --git a/tests/checkasm/diracdsp.c b/tests/checkasm/diracdsp.c
index aa09c43ddf..47eaefc90b 100644
--- a/tests/checkasm/diracdsp.c
+++ b/tests/checkasm/diracdsp.c
@@ -18,6 +18,8 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <string.h>
+
 #include "checkasm.h"
 
 #include "libavcodec/diracdsp.h"
diff --git a/tests/checkasm/float_dsp.c b/tests/checkasm/float_dsp.c
index c28343e4a8..95fee57941 100644
--- a/tests/checkasm/float_dsp.c
+++ b/tests/checkasm/float_dsp.c
@@ -18,6 +18,7 @@
 
 #include <float.h>
 #include <stdint.h>
+#include <string.h>
 
 #include "libavutil/float_dsp.h"
 #include "libavutil/internal.h"
diff --git a/tests/checkasm/lls.c b/tests/checkasm/lls.c
index 8b876b1bb9..0670941403 100644
--- a/tests/checkasm/lls.c
+++ b/tests/checkasm/lls.c
@@ -17,6 +17,9 @@
  */
 
 #include <float.h>
+#include <stdio.h>
+#include <string.h>
+
 #include "libavutil/lls.h"
 #include "checkasm.h"
 
diff --git a/tests/checkasm/mpeg4videodsp.c b/tests/checkasm/mpeg4videodsp.c
index 7c7e82c4b0..49557224f5 100644
--- a/tests/checkasm/mpeg4videodsp.c
+++ b/tests/checkasm/mpeg4videodsp.c
@@ -17,6 +17,7 @@
  */
 
 #include <assert.h>
+#include <string.h>
 
 #include "checkasm.h"
 #include "libavcodec/mpeg4videodsp.h"
diff --git a/tests/checkasm/opusdsp.c b/tests/checkasm/opusdsp.c
index 88511f6e13..98313da2ec 100644
--- a/tests/checkasm/opusdsp.c
+++ b/tests/checkasm/opusdsp.c
@@ -16,6 +16,8 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <string.h>
+
 #include "libavutil/mem_internal.h"
 
 #include "libavcodec/opus/dsp.h"
diff --git a/tests/checkasm/png.c b/tests/checkasm/png.c
index 98888b99db..727a9b030c 100644
--- a/tests/checkasm/png.c
+++ b/tests/checkasm/png.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <string.h>
 
 #include "libavutil/mem_internal.h"
 #include "libavcodec/pngdsp.h"
diff --git a/tests/checkasm/qpeldsp.c b/tests/checkasm/qpeldsp.c
index 1f18b4ffda..2db720c130 100644
--- a/tests/checkasm/qpeldsp.c
+++ b/tests/checkasm/qpeldsp.c
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <stddef.h>
+#include <string.h>
 
 #include "checkasm.h"
 #include "libavutil/intreadwrite.h"
diff --git a/tests/checkasm/sbcdsp.c b/tests/checkasm/sbcdsp.c
index b772605b16..0e12fc497f 100644
--- a/tests/checkasm/sbcdsp.c
+++ b/tests/checkasm/sbcdsp.c
@@ -18,6 +18,7 @@
 
 #include <stddef.h>
 #include <stdint.h>
+#include <string.h>
 
 #include "checkasm.h"
 #include "libavcodec/sbcdsp.h"
diff --git a/tests/checkasm/sbrdsp.c b/tests/checkasm/sbrdsp.c
index d6c10853af..eee08a462f 100644
--- a/tests/checkasm/sbrdsp.c
+++ b/tests/checkasm/sbrdsp.c
@@ -16,6 +16,8 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <string.h>
+
 #include "libavutil/mem_internal.h"
 
 #include "libavcodec/sbrdsp.h"
diff --git a/tests/checkasm/vf_nlmeans.c b/tests/checkasm/vf_nlmeans.c
index 26bd2d5890..6ab50607f7 100644
--- a/tests/checkasm/vf_nlmeans.c
+++ b/tests/checkasm/vf_nlmeans.c
@@ -19,6 +19,8 @@
  */
 
 #include <math.h>
+#include <string.h>
+
 #include "checkasm.h"
 #include "libavfilter/vf_nlmeans_init.h"
 #include "libavutil/avassert.h"
diff --git a/tests/checkasm/vf_pp7.c b/tests/checkasm/vf_pp7.c
index e506eeb16c..3f1fa9a75f 100644
--- a/tests/checkasm/vf_pp7.c
+++ b/tests/checkasm/vf_pp7.c
@@ -19,6 +19,7 @@
 #include <assert.h>
 #include <stddef.h>
 #include <stdint.h>
+#include <string.h>
 
 #include "checkasm.h"
 #include "libavfilter/vf_pp7dsp.h"
diff --git a/tests/checkasm/vorbisdsp.c b/tests/checkasm/vorbisdsp.c
index b4d60cc446..e97ff96e0c 100644
--- a/tests/checkasm/vorbisdsp.c
+++ b/tests/checkasm/vorbisdsp.c
@@ -17,6 +17,8 @@
  */
 
 #include <float.h>
+#include <stdio.h>
+#include <string.h>
 
 #include "libavutil/mem_internal.h"
 
-- 
2.52.0


From 666f4ad2da72ee8e838857b38cd8a65f27174897 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Tue, 28 Jul 2026 16:33:34 +0200
Subject: [PATCH 9/9] tests/checkasm/mpegvideo_unquantize: Set parameters in
 init cb

It means that these parameters change randomly for each run
when using --repeat.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 tests/checkasm/checkasm.c             |   3 +-
 tests/checkasm/checkasm.h             |   1 +
 tests/checkasm/mpegvideo_unquantize.c | 139 +++++++++++++-------------
 3 files changed, 73 insertions(+), 70 deletions(-)

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 1078f1116d..498630af6d 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -167,7 +167,8 @@ static const CheckasmTest tests[] = {
         { "mpeg4videodsp", checkasm_check_mpeg4videodsp },
     #endif
     #if CONFIG_MPEGVIDEO
-        { "mpegvideo_unquantize", checkasm_check_mpegvideo_unquantize },
+        { "mpegvideo_unquantize", checkasm_check_mpegvideo_unquantize,
+          .init = checkasm_init_mpegvideo_unquantize },
     #endif
     #if CONFIG_MPEGVIDEOENCDSP
         { "mpegvideoencdsp", checkasm_check_mpegvideoencdsp },
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 49380c1898..b8e73189af 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -132,6 +132,7 @@ void checkasm_init_crc(void);
 void checkasm_init_hpeldsp(void);
 void checkasm_init_huffyuvencdsp(void);
 void checkasm_init_llviddsp(void);
+void checkasm_init_mpegvideo_unquantize(void);
 void checkasm_init_sbc(void);
 
 void checkasm_uninit_crc(void);
diff --git a/tests/checkasm/mpegvideo_unquantize.c 
b/tests/checkasm/mpegvideo_unquantize.c
index 9de0bb4284..852972116e 100644
--- a/tests/checkasm/mpegvideo_unquantize.c
+++ b/tests/checkasm/mpegvideo_unquantize.c
@@ -48,76 +48,86 @@ enum TestType {
     MPEG2,
 };
 
-static void init_idct_scantable(MPVContext *const s, int intra_scantable)
-{
-    static const enum idct_permutation_type permutation_types[] = {
-        FF_IDCT_PERM_NONE,
-        FF_IDCT_PERM_LIBMPEG2,
+static const enum idct_permutation_type permutation_types[] = {
+    FF_IDCT_PERM_NONE,
+    FF_IDCT_PERM_LIBMPEG2,
 #if ARCH_X86_32 && HAVE_X86ASM
-        FF_IDCT_PERM_SIMPLE,
+    FF_IDCT_PERM_SIMPLE,
 #endif
 #if ARCH_PPC || ARCH_X86
-        FF_IDCT_PERM_TRANSPOSE,
+    FF_IDCT_PERM_TRANSPOSE,
 #endif
 #if ARCH_ARM || ARCH_AARCH64
-        FF_IDCT_PERM_PARTTRANS,
+    FF_IDCT_PERM_PARTTRANS,
 #endif
 #if ARCH_X86 && HAVE_X86ASM
-        FF_IDCT_PERM_SSE2,
+    FF_IDCT_PERM_SSE2,
 #endif
-    };
-    // Copied here to avoid #ifs.
-    static const uint8_t ff_wmv1_scantable[][64] = {
-    { 0x00, 0x08, 0x01, 0x02, 0x09, 0x10, 0x18, 0x11,
-      0x0A, 0x03, 0x04, 0x0B, 0x12, 0x19, 0x20, 0x28,
-      0x30, 0x38, 0x29, 0x21, 0x1A, 0x13, 0x0C, 0x05,
-      0x06, 0x0D, 0x14, 0x1B, 0x22, 0x31, 0x39, 0x3A,
-      0x32, 0x2A, 0x23, 0x1C, 0x15, 0x0E, 0x07, 0x0F,
-      0x16, 0x1D, 0x24, 0x2B, 0x33, 0x3B, 0x3C, 0x34,
-      0x2C, 0x25, 0x1E, 0x17, 0x1F, 0x26, 0x2D, 0x35,
-      0x3D, 0x3E, 0x36, 0x2E, 0x27, 0x2F, 0x37, 0x3F, },
-    { 0x00, 0x08, 0x01, 0x02, 0x09, 0x10, 0x18, 0x11,
-      0x0A, 0x03, 0x04, 0x0B, 0x12, 0x19, 0x20, 0x28,
-      0x21, 0x30, 0x1A, 0x13, 0x0C, 0x05, 0x06, 0x0D,
-      0x14, 0x1B, 0x22, 0x29, 0x38, 0x31, 0x39, 0x2A,
-      0x23, 0x1C, 0x15, 0x0E, 0x07, 0x0F, 0x16, 0x1D,
-      0x24, 0x2B, 0x32, 0x3A, 0x33, 0x3B, 0x2C, 0x25,
-      0x1E, 0x17, 0x1F, 0x26, 0x2D, 0x34, 0x3C, 0x35,
-      0x3D, 0x2E, 0x27, 0x2F, 0x36, 0x3E, 0x37, 0x3F, },
-    { 0x00, 0x01, 0x08, 0x02, 0x03, 0x09, 0x10, 0x18,
-      0x11, 0x0A, 0x04, 0x05, 0x0B, 0x12, 0x19, 0x20,
-      0x28, 0x30, 0x21, 0x1A, 0x13, 0x0C, 0x06, 0x07,
-      0x0D, 0x14, 0x1B, 0x22, 0x29, 0x38, 0x31, 0x39,
-      0x2A, 0x23, 0x1C, 0x15, 0x0E, 0x0F, 0x16, 0x1D,
-      0x24, 0x2B, 0x32, 0x3A, 0x33, 0x2C, 0x25, 0x1E,
-      0x17, 0x1F, 0x26, 0x2D, 0x34, 0x3B, 0x3C, 0x35,
-      0x2E, 0x27, 0x2F, 0x36, 0x3D, 0x3E, 0x37, 0x3F, },
-    { 0x00, 0x08, 0x10, 0x01, 0x18, 0x20, 0x28, 0x09,
-      0x02, 0x03, 0x0A, 0x11, 0x19, 0x30, 0x38, 0x29,
-      0x21, 0x1A, 0x12, 0x0B, 0x04, 0x05, 0x0C, 0x13,
-      0x1B, 0x22, 0x31, 0x39, 0x32, 0x2A, 0x23, 0x1C,
-      0x14, 0x0D, 0x06, 0x07, 0x0E, 0x15, 0x1D, 0x24,
-      0x2B, 0x33, 0x3A, 0x3B, 0x34, 0x2C, 0x25, 0x1E,
-      0x16, 0x0F, 0x17, 0x1F, 0x26, 0x2D, 0x3C, 0x35,
-      0x2E, 0x27, 0x2F, 0x36, 0x3D, 0x3E, 0x37, 0x3F, }
-    };
+};
+// Copied here to avoid #ifs.
+static const uint8_t ff_wmv1_scantable[][64] = {
+  { 0x00, 0x08, 0x01, 0x02, 0x09, 0x10, 0x18, 0x11,
+    0x0A, 0x03, 0x04, 0x0B, 0x12, 0x19, 0x20, 0x28,
+    0x30, 0x38, 0x29, 0x21, 0x1A, 0x13, 0x0C, 0x05,
+    0x06, 0x0D, 0x14, 0x1B, 0x22, 0x31, 0x39, 0x3A,
+    0x32, 0x2A, 0x23, 0x1C, 0x15, 0x0E, 0x07, 0x0F,
+    0x16, 0x1D, 0x24, 0x2B, 0x33, 0x3B, 0x3C, 0x34,
+    0x2C, 0x25, 0x1E, 0x17, 0x1F, 0x26, 0x2D, 0x35,
+    0x3D, 0x3E, 0x36, 0x2E, 0x27, 0x2F, 0x37, 0x3F, },
+  { 0x00, 0x08, 0x01, 0x02, 0x09, 0x10, 0x18, 0x11,
+    0x0A, 0x03, 0x04, 0x0B, 0x12, 0x19, 0x20, 0x28,
+    0x21, 0x30, 0x1A, 0x13, 0x0C, 0x05, 0x06, 0x0D,
+    0x14, 0x1B, 0x22, 0x29, 0x38, 0x31, 0x39, 0x2A,
+    0x23, 0x1C, 0x15, 0x0E, 0x07, 0x0F, 0x16, 0x1D,
+    0x24, 0x2B, 0x32, 0x3A, 0x33, 0x3B, 0x2C, 0x25,
+    0x1E, 0x17, 0x1F, 0x26, 0x2D, 0x34, 0x3C, 0x35,
+    0x3D, 0x2E, 0x27, 0x2F, 0x36, 0x3E, 0x37, 0x3F, },
+  { 0x00, 0x01, 0x08, 0x02, 0x03, 0x09, 0x10, 0x18,
+    0x11, 0x0A, 0x04, 0x05, 0x0B, 0x12, 0x19, 0x20,
+    0x28, 0x30, 0x21, 0x1A, 0x13, 0x0C, 0x06, 0x07,
+    0x0D, 0x14, 0x1B, 0x22, 0x29, 0x38, 0x31, 0x39,
+    0x2A, 0x23, 0x1C, 0x15, 0x0E, 0x0F, 0x16, 0x1D,
+    0x24, 0x2B, 0x32, 0x3A, 0x33, 0x2C, 0x25, 0x1E,
+    0x17, 0x1F, 0x26, 0x2D, 0x34, 0x3B, 0x3C, 0x35,
+    0x2E, 0x27, 0x2F, 0x36, 0x3D, 0x3E, 0x37, 0x3F, },
+  { 0x00, 0x08, 0x10, 0x01, 0x18, 0x20, 0x28, 0x09,
+    0x02, 0x03, 0x0A, 0x11, 0x19, 0x30, 0x38, 0x29,
+    0x21, 0x1A, 0x12, 0x0B, 0x04, 0x05, 0x0C, 0x13,
+    0x1B, 0x22, 0x31, 0x39, 0x32, 0x2A, 0x23, 0x1C,
+    0x14, 0x0D, 0x06, 0x07, 0x0E, 0x15, 0x1D, 0x24,
+    0x2B, 0x33, 0x3A, 0x3B, 0x34, 0x2C, 0x25, 0x1E,
+    0x16, 0x0F, 0x17, 0x1F, 0x26, 0x2D, 0x3C, 0x35,
+    0x2E, 0x27, 0x2F, 0x36, 0x3D, 0x3E, 0x37, 0x3F, }
+};
 
-    static const uint8_t *const scantables[] = {
-        ff_alternate_vertical_scan,
-        ff_alternate_horizontal_scan,
-        ff_zigzag_direct,
-        ff_wmv1_scantable[0],
-        ff_wmv1_scantable[1],
-        ff_wmv1_scantable[2],
-        ff_wmv1_scantable[3],
-    };
-    static const uint8_t *scantable = NULL;
-    static enum idct_permutation_type idct_permutation;
+static const uint8_t *const scantables[] = {
+    ff_alternate_vertical_scan,
+    ff_alternate_horizontal_scan,
+    ff_zigzag_direct,
+    ff_wmv1_scantable[0],
+    ff_wmv1_scantable[1],
+    ff_wmv1_scantable[2],
+    ff_wmv1_scantable[3],
+};
+static const uint8_t *scantable;
+static enum idct_permutation_type idct_permutation;
 
-    if (!scantable) {
-        scantable        = scantables[rnd() % FF_ARRAY_ELEMS(scantables)];
-        idct_permutation = permutation_types[rnd() % 
FF_ARRAY_ELEMS(permutation_types)];
-    }
+static int h263_aic, ac_pred;
+static int block_last_index;
+
+void checkasm_init_mpegvideo_unquantize(void)
+{
+    scantable        = scantables[rnd() % FF_ARRAY_ELEMS(scantables)];
+    idct_permutation = permutation_types[rnd() % 
FF_ARRAY_ELEMS(permutation_types)];
+
+    h263_aic = rnd() & 1;
+    ac_pred  = rnd() & 1;
+
+    block_last_index = rnd() % 64;
+}
+
+static void init_idct_scantable(MPVContext *const s, int intra_scantable)
+{
     ff_init_scantable_permutation(s->idsp.idct_permutation, idct_permutation);
     ff_init_scantable(s->idsp.idct_permutation,
                       intra_scantable ? &s->intra_scantable : 
&s->inter_scantable,
@@ -131,11 +141,6 @@ static void init_h263_test(MPVContext *const s, int16_t 
block[64],
     if (intra) {
         permutation = s->intra_scantable.permutated;
         block[0]    = rnd() & 511;
-        static int h263_aic = -1, ac_pred;
-        if (h263_aic < 0) {
-            h263_aic = rnd() & 1;
-            ac_pred  = rnd() & 1;
-        }
         s->h263_aic = h263_aic;
         s->ac_pred  = ac_pred;
         if (s->ac_pred)
@@ -224,7 +229,6 @@ void checkasm_check_mpegvideo_unquantize(void)
             MPVContext new, ref;
             DECLARE_ALIGNED(16, int16_t, block_new)[64];
             DECLARE_ALIGNED(16, int16_t, block_ref)[64];
-            static int block_last_index = -1;
 
             randomize_struct(MPVContext, &ref);
 
@@ -232,9 +236,6 @@ void checkasm_check_mpegvideo_unquantize(void)
 
             init_idct_scantable(&ref, tests[i].intra_scantable);
 
-            if (block_last_index < 0)
-                block_last_index = rnd() % 64;
-
             memset(block_ref, 0, sizeof(block_ref));
 
             if (tests[i].intra) {
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to