aboutsummaryrefslogtreecommitdiffstats
path: root/tests/checkasm/vf_blackdetect.c
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2025-07-17 12:39:26 +0200
committerNiklas Haas <git@haasn.dev>2025-07-18 10:47:31 +0200
commitbfab0262980550097ea6672a91834c576a8320c0 (patch)
tree7cb266214c7aa5a0eb1c86da9381d2efd7ddc5f3 /tests/checkasm/vf_blackdetect.c
parent75cd42c48a1d6f997af76a90298ee1c5d5780030 (diff)
downloadffmpeg-bfab0262980550097ea6672a91834c576a8320c0.tar.gz
tests/checkasm: add test for vf_blackdetect
Diffstat (limited to 'tests/checkasm/vf_blackdetect.c')
-rw-r--r--tests/checkasm/vf_blackdetect.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/checkasm/vf_blackdetect.c b/tests/checkasm/vf_blackdetect.c
new file mode 100644
index 0000000000..30e59740d7
--- /dev/null
+++ b/tests/checkasm/vf_blackdetect.c
@@ -0,0 +1,69 @@
+/*
+ * 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 <string.h>
+#include "checkasm.h"
+
+#include "libavfilter/vf_blackdetect.h"
+#include "libavutil/mem_internal.h"
+
+#define WIDTH 256
+#define HEIGHT 16
+#define STRIDE (WIDTH + 32)
+
+static void check_blackdetect(int depth)
+{
+ LOCAL_ALIGNED_32(uint8_t, in, [HEIGHT * STRIDE]);
+
+ declare_func(unsigned, const uint8_t *in, ptrdiff_t stride,
+ ptrdiff_t width, ptrdiff_t height,
+ unsigned threshold);
+
+ memset(in, 0, HEIGHT * STRIDE);
+ for (int y = 0; y < HEIGHT; y++) {
+ for (int x = 0; x < WIDTH; x++)
+ in[y * STRIDE + x] = rnd() & 0xFF;
+ }
+
+ const unsigned threshold = 16 << (depth - 8);
+
+ int w = WIDTH;
+ if (depth == 16)
+ w /= 2;
+
+ if (check_func(ff_blackdetect_get_fn(depth), "blackdetect%d", depth)) {
+ /* Ensure odd tail is handled correctly */
+ unsigned count_ref = call_ref(in, STRIDE, w - 8, HEIGHT, threshold);
+ unsigned count_new = call_new(in, STRIDE, w - 8, HEIGHT, threshold);
+ if (count_ref != count_new) {
+ fprintf(stderr, "blackdetect%d: count mismatch: %u != %u\n",
+ depth, count_ref, count_new);
+ fail();
+ }
+ bench_new(in, STRIDE, w, HEIGHT, 16);
+ }
+}
+
+void checkasm_check_blackdetect(void)
+{
+ check_blackdetect(8);
+ report("blackdetect8");
+
+ check_blackdetect(16);
+ report("blackdetect16");
+}