From: Niklas Haas <ffmpeg@haasn.xyz> To: ffmpeg-devel@ffmpeg.org Cc: Niklas Haas <git@haasn.dev> Subject: [FFmpeg-devel] [PATCH v2 2/2] tests/checkasm: add test for vf_blackdetect Date: Thu, 17 Jul 2025 12:45:25 +0200 Message-ID: <20250717104525.1290708-2-ffmpeg@haasn.xyz> (raw) In-Reply-To: <20250717104525.1290708-1-ffmpeg@haasn.xyz> From: Niklas Haas <git@haasn.dev> --- tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 3 ++ tests/checkasm/checkasm.h | 1 + tests/checkasm/vf_blackdetect.c | 69 +++++++++++++++++++++++++++++++++ tests/fate/checkasm.mak | 1 + 5 files changed, 75 insertions(+) create mode 100644 tests/checkasm/vf_blackdetect.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 1938468bbd..c6d5b0ba1f 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -54,6 +54,7 @@ CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes) # libavfilter tests AVFILTEROBJS-$(CONFIG_SCENE_SAD) += scene_sad.o AVFILTEROBJS-$(CONFIG_AFIR_FILTER) += af_afir.o +AVFILTEROBJS-$(CONFIG_BLACKDETECT_FILTER) += vf_blackdetect.o AVFILTEROBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o AVFILTEROBJS-$(CONFIG_BWDIF_FILTER) += vf_bwdif.o AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 66a8f8ff86..2532405f29 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -266,6 +266,9 @@ static const struct { #if CONFIG_AFIR_FILTER { "af_afir", checkasm_check_afir }, #endif + #if CONFIG_BLACKDETECT_FILTER + { "vf_blackdetect", checkasm_check_blackdetect }, + #endif #if CONFIG_BLEND_FILTER { "vf_blend", checkasm_check_blend }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 825e7ef52f..d85bbaf7fa 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -86,6 +86,7 @@ void checkasm_check_alacdsp(void); void checkasm_check_apv_dsp(void); void checkasm_check_audiodsp(void); void checkasm_check_av_tx(void); +void checkasm_check_blackdetect(void); void checkasm_check_blend(void); void checkasm_check_blockdsp(void); void checkasm_check_bswapdsp(void); 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"); +} diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak index 2dd46f1001..0ae402cad4 100644 --- a/tests/fate/checkasm.mak +++ b/tests/fate/checkasm.mak @@ -56,6 +56,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp \ fate-checkasm-v210dec \ fate-checkasm-v210enc \ fate-checkasm-vc1dsp \ + fate-checkasm-vf_blackdetect \ fate-checkasm-vf_blend \ fate-checkasm-vf_bwdif \ fate-checkasm-vf_colorspace \ -- 2.50.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2025-07-17 10:45 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-07-17 10:45 [FFmpeg-devel] [PATCH v2 1/2] avfilter/vf_blackdetect: add AVX2 SIMD version Niklas Haas 2025-07-17 10:45 ` Niklas Haas [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250717104525.1290708-2-ffmpeg@haasn.xyz \ --to=ffmpeg@haasn.xyz \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=git@haasn.dev \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git