Line | Branch | Exec | Source |
---|---|---|---|
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 <float.h> | ||
20 | #include <string.h> | ||
21 | #include "checkasm.h" | ||
22 | #include "libavutil/mem.h" | ||
23 | #include "libavfilter/vf_gblur_init.h" | ||
24 | |||
25 | #define WIDTH 256 | ||
26 | #define HEIGHT 256 | ||
27 | #define PIXELS (WIDTH * HEIGHT) | ||
28 | #define BUF_SIZE (PIXELS * 4) | ||
29 | |||
30 | #define randomize_buffers(buf, size) \ | ||
31 | do { \ | ||
32 | int j; \ | ||
33 | float *tmp_buf = (float *)buf; \ | ||
34 | for (j = 0; j < size; j++) \ | ||
35 | tmp_buf[j] = (float)(rnd() & 0xFF); \ | ||
36 | } while (0) | ||
37 | |||
38 | 3 | static void check_horiz_slice(float *dst_ref, float *dst_new, float *localbuf) | |
39 | { | ||
40 | 3 | int steps = 2; | |
41 | 3 | float nu = 0.101f; | |
42 | 3 | float bscale = 1.112f; | |
43 | |||
44 | 3 | declare_func(void, float *dst, int w, int h, int steps, float nu, float bscale, float *localbuf); | |
45 | 3 | call_ref(dst_ref, WIDTH, HEIGHT, steps, nu, bscale, localbuf); | |
46 | 3 | call_new(dst_new, WIDTH, HEIGHT, steps, nu, bscale, localbuf); | |
47 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) { |
48 | ✗ | fail(); | |
49 | } | ||
50 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
3 | bench_new(dst_new, WIDTH, HEIGHT, 1, nu, bscale, localbuf); |
51 | 3 | } | |
52 | |||
53 | 2 | static void check_verti_slice(float *dst_ref, float *dst_new) | |
54 | { | ||
55 | 2 | int steps = 2; | |
56 | 2 | float nu = 0.101f; | |
57 | 2 | float bscale = 1.112f; | |
58 | |||
59 | 2 | declare_func(void, float *buffer, int width, int height, int column_begin, | |
60 | int column_end, int steps, float nu, float bscale); | ||
61 | 2 | call_ref(dst_ref, WIDTH, HEIGHT, 0, WIDTH, steps, nu, bscale); | |
62 | 2 | call_new(dst_new, WIDTH, HEIGHT, 0, WIDTH, steps, nu, bscale); | |
63 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) { |
64 | ✗ | fail(); | |
65 | } | ||
66 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
2 | bench_new(dst_new, WIDTH, HEIGHT, 0, WIDTH, 1, nu, bscale); |
67 | 2 | } | |
68 | |||
69 | 3 | static void check_postscale_slice(float *dst_ref, float *dst_new) | |
70 | { | ||
71 | 3 | float postscale = 0.0603f; | |
72 | |||
73 | 3 | declare_func(void, float *dst, int len, float postscale, float min, float max); | |
74 | 3 | call_ref(dst_ref, PIXELS, postscale, -FLT_MAX, FLT_MAX); | |
75 | 3 | call_new(dst_new, PIXELS, postscale, -FLT_MAX, FLT_MAX); | |
76 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (!float_near_abs_eps_array(dst_ref, dst_new, FLT_EPSILON, PIXELS)) { |
77 | ✗ | fail(); | |
78 | } | ||
79 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
3 | bench_new(dst_new, PIXELS, postscale, -FLT_MAX, FLT_MAX); |
80 | 3 | } | |
81 | |||
82 | 13 | void checkasm_check_vf_gblur(void) | |
83 | { | ||
84 | 13 | float *dst_ref = av_malloc(BUF_SIZE); | |
85 | 13 | float *dst_new = av_malloc(BUF_SIZE); | |
86 | GBlurContext s; | ||
87 | |||
88 |
2/2✓ Branch 1 taken 851968 times.
✓ Branch 2 taken 13 times.
|
851981 | randomize_buffers(dst_ref, PIXELS); |
89 | 13 | memcpy(dst_new, dst_ref, BUF_SIZE); | |
90 | |||
91 | 13 | s.planewidth[0] = WIDTH; | |
92 | 13 | s.planeheight[0] = HEIGHT; | |
93 | 13 | ff_gblur_init(&s); | |
94 | |||
95 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
|
13 | if (check_func(s.horiz_slice, "horiz_slice")) { |
96 | 3 | check_horiz_slice(dst_ref, dst_new, s.localbuf); | |
97 | } | ||
98 | 13 | report("horiz_slice"); | |
99 | |||
100 |
2/2✓ Branch 1 taken 851968 times.
✓ Branch 2 taken 13 times.
|
851981 | randomize_buffers(dst_ref, PIXELS); |
101 | 13 | memcpy(dst_new, dst_ref, BUF_SIZE); | |
102 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
|
13 | if (check_func(s.postscale_slice, "postscale_slice")) { |
103 | 3 | check_postscale_slice(dst_ref, dst_new); | |
104 | } | ||
105 | 13 | report("postscale_slice"); | |
106 | |||
107 |
2/2✓ Branch 1 taken 851968 times.
✓ Branch 2 taken 13 times.
|
851981 | randomize_buffers(dst_ref, PIXELS); |
108 | 13 | memcpy(dst_new, dst_ref, BUF_SIZE); | |
109 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
|
13 | if (check_func(s.verti_slice, "verti_slice")) { |
110 | 2 | check_verti_slice(dst_ref, dst_new); | |
111 | } | ||
112 | 13 | report("verti_slice"); | |
113 | |||
114 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
|
13 | if (s.localbuf) |
115 | 1 | av_free(s.localbuf); | |
116 | |||
117 | 13 | av_freep(&dst_ref); | |
118 | 13 | av_freep(&dst_new); | |
119 | 13 | } | |
120 |