FFmpeg
tests
checkasm
vf_blackdetect.c
Go to the documentation of this file.
1
/*
2
* This file is part of FFmpeg.
3
*
4
* FFmpeg is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
8
*
9
* FFmpeg is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with FFmpeg; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
*/
18
19
#include <string.h>
20
#include "
checkasm.h
"
21
22
#include "
libavfilter/vf_blackdetect.h
"
23
#include "
libavutil/mem_internal.h
"
24
25
#define WIDTH 256
26
#define HEIGHT 16
27
#define STRIDE (WIDTH + 32)
28
29
static
void
check_blackdetect
(
int
depth)
30
{
31
LOCAL_ALIGNED_32
(uint8_t, in, [
HEIGHT
*
STRIDE
]);
32
33
declare_func
(
unsigned
,
const
uint8_t *in, ptrdiff_t
stride
,
34
ptrdiff_t
width
, ptrdiff_t
height
,
35
unsigned
threshold);
36
37
memset(in, 0,
HEIGHT
*
STRIDE
);
38
for
(
int
y = 0; y <
HEIGHT
; y++) {
39
for
(
int
x = 0; x <
WIDTH
; x++)
40
in[y *
STRIDE
+ x] =
rnd
() & 0xFF;
41
}
42
43
const
unsigned
threshold = 16 << (depth - 8);
44
45
int
w
=
WIDTH
;
46
if
(depth == 16)
47
w
/= 2;
48
49
if
(
check_func
(
ff_blackdetect_get_fn
(depth),
"blackdetect%d"
, depth)) {
50
/* Ensure odd tail is handled correctly */
51
unsigned
count_ref =
call_ref
(in,
STRIDE
,
w
- 8,
HEIGHT
, threshold);
52
unsigned
count_new =
call_new
(in,
STRIDE
,
w
- 8,
HEIGHT
, threshold);
53
if
(count_ref != count_new) {
54
fprintf(stderr,
"blackdetect%d: count mismatch: %u != %u\n"
,
55
depth, count_ref, count_new);
56
fail
();
57
}
58
bench_new
(in,
STRIDE
,
w
,
HEIGHT
, 16);
59
}
60
}
61
62
void
checkasm_check_blackdetect
(
void
)
63
{
64
check_blackdetect
(8);
65
report
(
"blackdetect8"
);
66
67
check_blackdetect
(16);
68
report
(
"blackdetect16"
);
69
}
HEIGHT
#define HEIGHT
Definition:
vf_blackdetect.c:26
mem_internal.h
w
uint8_t w
Definition:
llviddspenc.c:38
check_func
#define check_func(func,...)
Definition:
checkasm.h:190
STRIDE
#define STRIDE
Definition:
vf_blackdetect.c:27
call_ref
#define call_ref(...)
Definition:
checkasm.h:205
vf_blackdetect.h
checkasm_check_blackdetect
void checkasm_check_blackdetect(void)
Definition:
vf_blackdetect.c:62
fail
#define fail()
Definition:
checkasm.h:199
checkasm.h
rnd
#define rnd()
Definition:
checkasm.h:183
call_new
#define call_new(...)
Definition:
checkasm.h:308
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition:
mem_internal.h:132
WIDTH
#define WIDTH
Definition:
vf_blackdetect.c:25
height
#define height
Definition:
dsp.h:89
report
#define report
Definition:
checkasm.h:202
bench_new
#define bench_new(...)
Definition:
checkasm.h:379
stride
#define stride
Definition:
h264pred_template.c:536
ff_blackdetect_get_fn
static ff_blackdetect_fn ff_blackdetect_get_fn(int depth)
Definition:
vf_blackdetect.h:59
declare_func
#define declare_func(ret,...)
Definition:
checkasm.h:194
width
#define width
Definition:
dsp.h:89
check_blackdetect
static void check_blackdetect(int depth)
Definition:
vf_blackdetect.c:29
Generated on Mon Aug 4 2025 19:22:53 for FFmpeg by
1.8.17