FFmpeg
Loading...
Searching...
No Matches
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
24
25#define WIDTH 256
26#define HEIGHT 16
27#define STRIDE (WIDTH + 32)
28
29static 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
63{
65 report("blackdetect8");
66
68 report("blackdetect16");
69}
#define STRIDE
Definition aacpsdsp.c:28
#define rnd
Definition checkasm.h:136
#define declare_func
Definition test.h:489
#define fail
Definition test.h:479
#define bench_new
Definition test.h:487
#define check_func
Definition test.h:481
#define call_new
Definition test.h:486
#define call_ref
Definition test.h:485
#define report
Definition test.h:480
#define WIDTH
Definition c93.c:45
#define HEIGHT
Definition c93.c:46
uint8_t w
Definition llvidencdsp.c:39
#define LOCAL_ALIGNED_32(t, v,...)
#define stride
void checkasm_check_blackdetect(void)
static void check_blackdetect(int depth)
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
static ff_blackdetect_fn ff_blackdetect_get_fn(int depth)