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 "libavutil/mem_internal.h" | ||
20 | |||
21 | #include "libavcodec/lpc.h" | ||
22 | |||
23 | #include "checkasm.h" | ||
24 | |||
25 | #define randomize_int32(buf, len) \ | ||
26 | do { \ | ||
27 | for (int i = 0; i < len; i++) { \ | ||
28 | int32_t f = ((int)(UINT32_MAX >> 17)) - ((int)(rnd() >> 16)); \ | ||
29 | buf[i] = f; \ | ||
30 | } \ | ||
31 | } while (0) | ||
32 | |||
33 | #define EPS 0.005 | ||
34 | |||
35 | 6 | static void test_window(int len) | |
36 | { | ||
37 | 6 | LOCAL_ALIGNED(16, int32_t, src, [5000]); | |
38 | 6 | LOCAL_ALIGNED(16, double, dst0, [5000]); | |
39 | 6 | LOCAL_ALIGNED(16, double, dst1, [5000]); | |
40 | |||
41 | 6 | declare_func(void, const int32_t *in, ptrdiff_t len, double *out); | |
42 | |||
43 |
2/2✓ Branch 1 taken 10583 times.
✓ Branch 2 taken 6 times.
|
10589 | randomize_int32(src, len); |
44 | |||
45 | 6 | call_ref(src, len, dst0); | |
46 | 6 | call_new(src, len, dst1); | |
47 | |||
48 |
2/2✓ Branch 0 taken 10583 times.
✓ Branch 1 taken 6 times.
|
10589 | for (int i = 0; i < len; i++) { |
49 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 10583 times.
|
10583 | if (!double_near_abs_eps(dst0[i], dst1[i], EPS)) { |
50 | ✗ | fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", | |
51 | ✗ | i, dst0[i], dst1[i], dst0[i] - dst1[i]); | |
52 | ✗ | fail(); | |
53 | ✗ | break; | |
54 | } | ||
55 | } | ||
56 | |||
57 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 6 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.
|
6 | bench_new(src, len, dst1); |
58 | 6 | } | |
59 | |||
60 | 13 | void checkasm_check_lpc(void) | |
61 | { | ||
62 | LPCContext ctx; | ||
63 | 13 | int len = rnd() % 5000; | |
64 | 13 | ff_lpc_init(&ctx, 32, 16, FF_LPC_TYPE_DEFAULT); | |
65 | |||
66 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
|
13 | if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_even")) { |
67 | 3 | test_window(len & ~1); | |
68 | } | ||
69 | 13 | report("apply_welch_window_even"); | |
70 | |||
71 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
|
13 | if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_odd")) { |
72 | 3 | test_window(len | 1); | |
73 | } | ||
74 | 13 | report("apply_welch_window_odd"); | |
75 | |||
76 | 13 | ff_lpc_end(&ctx); | |
77 | 13 | } | |
78 |