Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2015 Janne Grunau | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with FFmpeg; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #include <math.h> | ||
22 | #include <string.h> | ||
23 | #include <stdio.h> | ||
24 | #include <stdlib.h> | ||
25 | |||
26 | #include "libavutil/internal.h" | ||
27 | #include "libavutil/intfloat.h" | ||
28 | #include "libavutil/mem_internal.h" | ||
29 | #include "libavutil/tx.h" | ||
30 | |||
31 | #include "libavcodec/dcadata.h" | ||
32 | #include "libavcodec/synth_filter.h" | ||
33 | |||
34 | #include "checkasm.h" | ||
35 | |||
36 | #define BUF_SIZE 32 | ||
37 | |||
38 | #define randomize_input() \ | ||
39 | do { \ | ||
40 | int i; \ | ||
41 | for (i = 0; i < BUF_SIZE; i++) { \ | ||
42 | float f = (float)rnd() / (UINT_MAX >> 5) - 16.0f; \ | ||
43 | in[i] = f; \ | ||
44 | } \ | ||
45 | } while (0) | ||
46 | |||
47 | 13 | void checkasm_check_synth_filter(void) | |
48 | { | ||
49 | 13 | float scale = 1.0; | |
50 | AVTXContext *imdct; | ||
51 | av_tx_fn imdct_fn; | ||
52 | SynthFilterContext synth; | ||
53 | |||
54 | 13 | av_tx_init(&imdct, &imdct_fn, AV_TX_FLOAT_MDCT, 0, 16, &scale, 0); | |
55 | 13 | ff_synth_filter_init(&synth); | |
56 | |||
57 |
2/2✓ Branch 3 taken 4 times.
✓ Branch 4 taken 9 times.
|
13 | if (check_func(synth.synth_filter_float, "synth_filter_float")) { |
58 | 4 | LOCAL_ALIGNED(32, float, out0, [BUF_SIZE]); | |
59 | 4 | LOCAL_ALIGNED(32, float, out1, [BUF_SIZE]); | |
60 | 4 | LOCAL_ALIGNED(32, float, out_b, [BUF_SIZE]); | |
61 | 4 | LOCAL_ALIGNED(32, float, in, [BUF_SIZE]); | |
62 | 4 | LOCAL_ALIGNED(32, float, buf2_0, [BUF_SIZE]); | |
63 | 4 | LOCAL_ALIGNED(32, float, buf2_1, [BUF_SIZE]); | |
64 | 4 | LOCAL_ALIGNED(32, float, buf2_b, [BUF_SIZE]); | |
65 | 4 | LOCAL_ALIGNED(32, float, buf0, [512]); | |
66 | 4 | LOCAL_ALIGNED(32, float, buf1, [512]); | |
67 | 4 | LOCAL_ALIGNED(32, float, buf_b, [512]); | |
68 | 4 | float scale = 1.0f; | |
69 | 4 | int i, offset0 = 0, offset1 = 0, offset_b = 0; | |
70 | |||
71 | 4 | declare_func(void, AVTXContext *, float *, int *, | |
72 | float[32], const float[512], float[32], float[32], float, av_tx_fn); | ||
73 | |||
74 | 4 | memset(buf2_0, 0, sizeof(*buf2_0) * BUF_SIZE); | |
75 | 4 | memset(buf2_1, 0, sizeof(*buf2_1) * BUF_SIZE); | |
76 | 4 | memset(buf2_b, 0, sizeof(*buf2_b) * BUF_SIZE); | |
77 | 4 | memset(buf0, 0, sizeof(*buf2_0) * 512); | |
78 | 4 | memset(buf1, 0, sizeof(*buf2_1) * 512); | |
79 | 4 | memset(buf_b, 0, sizeof(*buf2_b) * 512); | |
80 | |||
81 | /* more than 1 synth_buf_offset wrap-around */ | ||
82 |
2/2✓ Branch 0 taken 80 times.
✓ Branch 1 taken 4 times.
|
84 | for (i = 0; i < 20; i++) { |
83 | int j; | ||
84 |
2/2✓ Branch 0 taken 40 times.
✓ Branch 1 taken 40 times.
|
80 | const float * window = (i & 1) ? ff_dca_fir_32bands_perfect : ff_dca_fir_32bands_nonperfect; |
85 | |||
86 | 80 | memset(out0, 0, sizeof(*out0) * BUF_SIZE); | |
87 | 80 | memset(out1, 0, sizeof(*out1) * BUF_SIZE); | |
88 | 80 | memset(out_b, 0, sizeof(*out_b) * BUF_SIZE); | |
89 | |||
90 |
2/2✓ Branch 1 taken 2560 times.
✓ Branch 2 taken 80 times.
|
2640 | randomize_input(); |
91 | |||
92 | 80 | call_ref(imdct, buf0, &offset0, buf2_0, window, | |
93 | out0, in, scale, imdct_fn); | ||
94 | 80 | call_new(imdct, buf1, &offset1, buf2_1, window, | |
95 | out1, in, scale, imdct_fn); | ||
96 | |||
97 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
|
80 | if (offset0 != offset1) { |
98 | ✗ | fail(); | |
99 | ✗ | fprintf(stderr, "offsets do not match: %d, %d", offset0, offset1); | |
100 | ✗ | break; | |
101 | } | ||
102 | |||
103 |
2/2✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 80 times.
|
2640 | for (j = 0; j < BUF_SIZE; j++) { |
104 |
1/2✓ Branch 1 taken 2560 times.
✗ Branch 2 not taken.
|
2560 | if (!float_near_abs_eps_ulp(out0[j], out1[j], 7.0e-7, 16) || |
105 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2560 times.
|
2560 | !float_near_abs_eps_ulp(buf2_0[j], buf2_1[j], 7.0e-7, 16)) { |
106 | union av_intfloat32 o0, o1, b0, b1; | ||
107 | |||
108 | ✗ | fail(); | |
109 | ✗ | o0.f = out0[j]; o1.f = out1[j]; | |
110 | ✗ | b0.f = buf2_0[j], b1.f = buf2_1[j]; | |
111 | ✗ | fprintf(stderr, "out: %11g (0x%08x); %11g (0x%08x); abs diff %11g\n", | |
112 | ✗ | o0.f, o0.i, o1.f, o1.i, fabsf(o0.f - o1.f)); | |
113 | ✗ | fprintf(stderr, "buf2: %11g (0x%08x); %11g (0x%08x); abs diff %11g\n", | |
114 | ✗ | b0.f, b0.i, b1.f, b1.i, fabsf(b0.f - b1.f)); | |
115 | ✗ | break; | |
116 | } | ||
117 | } | ||
118 | |||
119 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 80 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.
|
80 | bench_new(imdct, buf_b, &offset_b, buf2_b, window, |
120 | out_b, in, scale, imdct_fn); | ||
121 | } | ||
122 | } | ||
123 | 13 | av_tx_uninit(&imdct); | |
124 | |||
125 | 13 | report("synth_filter"); | |
126 | 13 | } | |
127 |