1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

tests/checkasm: add test for vf_blackdetect

This commit is contained in:
Niklas Haas
2025-07-17 12:39:26 +02:00
parent 75cd42c48a
commit bfab026298
5 changed files with 75 additions and 0 deletions

View File

@ -54,6 +54,7 @@ CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes)
# libavfilter tests # libavfilter tests
AVFILTEROBJS-$(CONFIG_SCENE_SAD) += scene_sad.o AVFILTEROBJS-$(CONFIG_SCENE_SAD) += scene_sad.o
AVFILTEROBJS-$(CONFIG_AFIR_FILTER) += af_afir.o AVFILTEROBJS-$(CONFIG_AFIR_FILTER) += af_afir.o
AVFILTEROBJS-$(CONFIG_BLACKDETECT_FILTER) += vf_blackdetect.o
AVFILTEROBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o AVFILTEROBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o
AVFILTEROBJS-$(CONFIG_BWDIF_FILTER) += vf_bwdif.o AVFILTEROBJS-$(CONFIG_BWDIF_FILTER) += vf_bwdif.o
AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o

View File

@ -266,6 +266,9 @@ static const struct {
#if CONFIG_AFIR_FILTER #if CONFIG_AFIR_FILTER
{ "af_afir", checkasm_check_afir }, { "af_afir", checkasm_check_afir },
#endif #endif
#if CONFIG_BLACKDETECT_FILTER
{ "vf_blackdetect", checkasm_check_blackdetect },
#endif
#if CONFIG_BLEND_FILTER #if CONFIG_BLEND_FILTER
{ "vf_blend", checkasm_check_blend }, { "vf_blend", checkasm_check_blend },
#endif #endif

View File

@ -86,6 +86,7 @@ void checkasm_check_alacdsp(void);
void checkasm_check_apv_dsp(void); void checkasm_check_apv_dsp(void);
void checkasm_check_audiodsp(void); void checkasm_check_audiodsp(void);
void checkasm_check_av_tx(void); void checkasm_check_av_tx(void);
void checkasm_check_blackdetect(void);
void checkasm_check_blend(void); void checkasm_check_blend(void);
void checkasm_check_blockdsp(void); void checkasm_check_blockdsp(void);
void checkasm_check_bswapdsp(void); void checkasm_check_bswapdsp(void);

View File

@ -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");
}

View File

@ -56,6 +56,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp \
fate-checkasm-v210dec \ fate-checkasm-v210dec \
fate-checkasm-v210enc \ fate-checkasm-v210enc \
fate-checkasm-vc1dsp \ fate-checkasm-vc1dsp \
fate-checkasm-vf_blackdetect \
fate-checkasm-vf_blend \ fate-checkasm-vf_blend \
fate-checkasm-vf_bwdif \ fate-checkasm-vf_bwdif \
fate-checkasm-vf_colorspace \ fate-checkasm-vf_colorspace \