Commit baa68e68b3 for ffmpeg
commit baa68e68b34e2de912eb7e94342cebd2545f05ed
Author: Rodrigo Camacho <rodrigompcamacho@gmail.com>
Date: Mon Oct 12 14:12:28 2026 +0100
tests/checkasm: add test for vf_limiter
Signed-off-by: Rodrigo Camacho <rodrigompcamacho@gmail.com>
diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index e465c580a2..ab1cc17b56 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -81,6 +81,7 @@ AVFILTEROBJS-$(CONFIG_FSPP_FILTER) += vf_fspp.o
AVFILTEROBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o
AVFILTEROBJS-$(CONFIG_HFLIP_FILTER) += vf_hflip.o
AVFILTEROBJS-$(CONFIG_IDET_FILTER) += vf_idet.o
+AVFILTEROBJS-$(CONFIG_LIMITER_FILTER) += vf_limiter.o
AVFILTEROBJS-$(CONFIG_PP7_FILTER) += vf_pp7.o
AVFILTEROBJS-$(CONFIG_THRESHOLD_FILTER) += vf_threshold.o
AVFILTEROBJS-$(CONFIG_NLMEANS_FILTER) += vf_nlmeans.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 6a5c2c23fb..b79195adf0 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -288,6 +288,9 @@ static const CheckasmTest tests[] = {
#if CONFIG_NLMEANS_FILTER
{ "vf_nlmeans", checkasm_check_nlmeans },
#endif
+ #if CONFIG_LIMITER_FILTER
+ { "vf_limiter", checkasm_check_vf_limiter },
+ #endif
#if CONFIG_PP7_FILTER
{ "vf_pp7", checkasm_check_vf_pp7 },
#endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index f713fe36da..0fc6823c4f 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -119,6 +119,7 @@ void checkasm_check_vf_eq(void);
void checkasm_check_vf_fspp(void);
void checkasm_check_vf_gblur(void);
void checkasm_check_vf_hflip(void);
+void checkasm_check_vf_limiter(void);
void checkasm_check_vf_pp7(void);
void checkasm_check_vf_threshold(void);
void checkasm_check_vf_sobel(void);
diff --git a/tests/checkasm/vf_limiter.c b/tests/checkasm/vf_limiter.c
new file mode 100644
index 0000000000..2cfc1ee647
--- /dev/null
+++ b/tests/checkasm/vf_limiter.c
@@ -0,0 +1,75 @@
+/*
+ * 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 "checkasm.h"
+#include "libavfilter/limiter.h"
+#include "libavfilter/vf_limiter_init.h"
+#include "libavutil/mem_internal.h"
+#include <stddef.h>
+#include <stdint.h>
+
+#define WIDTH 256
+#define HEIGHT 16
+#define WIDTH_PADDED (WIDTH + 32)
+
+static void check_limiter(int depth)
+{
+ LOCAL_ALIGNED_32(uint8_t, src, [HEIGHT * WIDTH_PADDED]);
+ LOCAL_ALIGNED_32(uint8_t, dst_ref, [HEIGHT * WIDTH_PADDED]);
+ LOCAL_ALIGNED_32(uint8_t, dst_new, [HEIGHT * WIDTH_PADDED]);
+
+ declare_func(void, const uint8_t *, uint8_t *,
+ ptrdiff_t, ptrdiff_t, int, int, int, int);
+
+ memset(dst_ref, 0, HEIGHT * WIDTH_PADDED);
+ memset(dst_new, 0, HEIGHT * WIDTH_PADDED);
+ memset(src, 0, HEIGHT * WIDTH_PADDED);
+ for (int y = 0; y < HEIGHT; y++) {
+ for (int x = 0; x < WIDTH; x++)
+ src[y * WIDTH_PADDED + x] = rnd() & 0xFF;
+ }
+
+ const int min = 16 << (depth - 8);
+ const int max = 235 << (depth - 8);
+
+ int w = WIDTH;
+ if (depth == 16)
+ w /= 2;
+
+ LimiterContext s;
+ ff_limiter_init(&s, depth);
+
+ if (check_func(s.dsp.limiter, "limiter%d", depth)) {
+ call_ref(src, dst_ref, WIDTH_PADDED, WIDTH_PADDED, w, HEIGHT, min, max);
+ call_new(src, dst_new, WIDTH_PADDED, WIDTH_PADDED, w, HEIGHT, min, max);
+
+ if (memcmp(dst_ref, dst_new, HEIGHT * WIDTH_PADDED))
+ fail();
+
+ bench_new(src, dst_new, WIDTH_PADDED, WIDTH_PADDED, w, HEIGHT, min, max);
+ }
+}
+
+void checkasm_check_vf_limiter(void)
+{
+ check_limiter(8);
+ report("limiter8");
+
+ check_limiter(16);
+ report("limiter16");
+}
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index 4da6f6a3a3..19bbe7e571 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -87,6 +87,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp \
fate-checkasm-vf_gblur \
fate-checkasm-vf_hflip \
fate-checkasm-vf_idet \
+ fate-checkasm-vf_limiter \
fate-checkasm-vf_nlmeans \
fate-checkasm-vf_pp7 \
fate-checkasm-vf_threshold \