FFmpeg
vf_idet.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 "checkasm.h"
20 
21 #include "libavfilter/vf_idetdsp.h"
22 #include "libavutil/mem_internal.h"
23 
24 #define WIDTH 512
25 
26 static void check_idet(int depth)
27 {
28  IDETDSPContext dsp;
29 
30  LOCAL_ALIGNED_32(uint8_t, in0, [WIDTH]);
31  LOCAL_ALIGNED_32(uint8_t, in1, [WIDTH]);
32  LOCAL_ALIGNED_32(uint8_t, in2, [WIDTH]);
33 
34  declare_func(int, const uint8_t *a, const uint8_t *b,
35  const uint8_t *c, int w);
36 
37  ff_idet_dsp_init(&dsp, depth > 8);
38 
39  for (int x = 0; x < WIDTH; x++) {
40  in0[x] = rnd() & 0xFF;
41  in1[x] = rnd() & 0xFF;
42  in2[x] = rnd() & 0xFF;
43  }
44 
45  if (check_func(dsp.filter_line, "idet%d", depth)) {
46  /* Ensure odd tail is handled correctly */
47  int res_ref = call_ref(in0, in1, in2, WIDTH - 8);
48  int res_new = call_new(in0, in1, in2, WIDTH - 8);
49  if (res_ref != res_new) {
50  fprintf(stderr, "idet%d: result mismatch: %u != %u\n",
51  depth, res_ref, res_new);
52  fail();
53  }
54  bench_new(in0, in1, in2, WIDTH);
55  }
56 }
57 
59 {
60  check_idet(8);
61  report("idet8");
62 
63  check_idet(16);
64  report("idet16");
65 }
mem_internal.h
w
uint8_t w
Definition: llviddspenc.c:38
check_func
#define check_func(func,...)
Definition: checkasm.h:195
b
#define b
Definition: input.c:42
call_ref
#define call_ref(...)
Definition: checkasm.h:210
checkasm_check_idet
void checkasm_check_idet(void)
Definition: vf_idet.c:58
fail
#define fail()
Definition: checkasm.h:204
checkasm.h
rnd
#define rnd()
Definition: checkasm.h:188
vf_idetdsp.h
call_new
#define call_new(...)
Definition: checkasm.h:313
IDETDSPContext::filter_line
ff_idet_filter_func filter_line
Definition: vf_idetdsp.h:27
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition: mem_internal.h:132
WIDTH
#define WIDTH
Definition: vf_idet.c:24
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
report
#define report
Definition: checkasm.h:207
bench_new
#define bench_new(...)
Definition: checkasm.h:398
ff_idet_dsp_init
void av_cold ff_idet_dsp_init(IDETDSPContext *dsp, int depth)
Definition: vf_idetdsp.c:56
IDETDSPContext
Definition: vf_idetdsp.h:26
declare_func
#define declare_func(ret,...)
Definition: checkasm.h:199
check_idet
static void check_idet(int depth)
Definition: vf_idet.c:26