FFmpeg
Loading...
Searching...
No Matches
vf_threshold.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"
24
25#define WIDTH 256
26#define HEIGHT 3
27#define WIDTH_PADDED (WIDTH + 32)
28#define LINESIZE_MAX (WIDTH_PADDED + 32)
29#define BUF_SIZE (LINESIZE_MAX * HEIGHT)
30
31#define randomize_buffers(buf, size) \
32 do { \
33 int j; \
34 uint8_t *tmp_buf = (uint8_t *)buf;\
35 for (j = 0; j < size; j++) \
36 tmp_buf[j] = rnd() & 0xFF; \
37 } while (0)
38
39static void check_threshold(int depth){
40 LOCAL_ALIGNED_32(uint8_t, in , [BUF_SIZE]);
41 LOCAL_ALIGNED_32(uint8_t, threshold, [BUF_SIZE]);
42 LOCAL_ALIGNED_32(uint8_t, min , [BUF_SIZE]);
43 LOCAL_ALIGNED_32(uint8_t, max , [BUF_SIZE]);
44 LOCAL_ALIGNED_32(uint8_t, out_ref , [BUF_SIZE]);
45 LOCAL_ALIGNED_32(uint8_t, out_new , [BUF_SIZE]);
46 ptrdiff_t line_size = WIDTH_PADDED;
47 int step = depth > 8 ? 2 : 1;
48 int w = WIDTH / step;
49
50 declare_func(void, const uint8_t *in, const uint8_t *threshold,
51 const uint8_t *min, const uint8_t *max, uint8_t *out,
52 ptrdiff_t ilinesize, ptrdiff_t tlinesize,
53 ptrdiff_t flinesize, ptrdiff_t slinesize,
54 ptrdiff_t olinesize, int w, int h);
55
57 s.depth = depth;
59
60 memset(in, 0, BUF_SIZE);
61 memset(threshold, 0, BUF_SIZE);
62 memset(min, 0, BUF_SIZE);
63 memset(max, 0, BUF_SIZE);
65 randomize_buffers(threshold, BUF_SIZE);
68
69 if (check_func(s.threshold, "threshold%d", depth)) {
70 for (int i = 1; i < w; i++) {
71 memset(out_ref, 0xAA, BUF_SIZE);
72 memset(out_new, 0xAA, BUF_SIZE);
73 call_ref(in, threshold, min, max, out_ref,
74 line_size, line_size, line_size, line_size, line_size, i, 1);
75 call_new(in, threshold, min, max, out_new,
76 line_size, line_size, line_size, line_size, line_size, i, 1);
77 if (memcmp(out_ref, out_new, BUF_SIZE))
78 fail();
79 }
80 memset(out_ref, 0xAA, BUF_SIZE);
81 memset(out_new, 0xAA, BUF_SIZE);
82 call_ref(in, threshold, min, max, out_ref,
83 line_size, line_size, line_size, line_size, line_size, w, HEIGHT);
84 call_new(in, threshold, min, max, out_new,
85 line_size, line_size, line_size, line_size, line_size, w, HEIGHT);
86 if (memcmp(out_ref, out_new, BUF_SIZE))
87 fail();
88 memset(out_ref, 0xAA, BUF_SIZE);
89 memset(out_new, 0xAA, BUF_SIZE);
90 call_ref(in, threshold, min, max, out_ref,
91 line_size + 0, line_size + 8, line_size + 16,
92 line_size + 24, line_size + 32, w, HEIGHT);
93 call_new(in, threshold, min, max, out_new,
94 line_size + 0, line_size + 8, line_size + 16,
95 line_size + 24, line_size + 32, w, HEIGHT);
96 if (memcmp(out_ref, out_new, BUF_SIZE))
97 fail();
98 bench_new(in, threshold, min, max, out_new,
99 line_size, line_size, line_size, line_size, line_size, w, 1);
100 }
101}
102
104{
106 report("threshold8");
107
108 check_threshold(10);
109 report("threshold10");
110
111 check_threshold(12);
112 report("threshold12");
113
114 check_threshold(16);
115 report("threshold16");
116}
static FILE * out
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define min(a, b)
#define max(a, b)
#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 BUF_SIZE
Definition setpts.c:159
#define WIDTH_PADDED
Definition utvideodsp.c:30
static void check_threshold(int depth)
#define randomize_buffers(buf, size)
void checkasm_check_vf_threshold(void)
static av_unused void ff_threshold_init(ThresholdContext *s)