Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright (c) 2015 James Almer | ||
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 <string.h> | ||
22 | #include "checkasm.h" | ||
23 | #include "libavcodec/flacdsp.h" | ||
24 | #include "libavutil/common.h" | ||
25 | #include "libavutil/internal.h" | ||
26 | #include "libavutil/intreadwrite.h" | ||
27 | #include "libavutil/mem_internal.h" | ||
28 | |||
29 | #define BUF_SIZE 256 | ||
30 | #define MAX_CHANNELS 8 | ||
31 | |||
32 | #define randomize_buffers() \ | ||
33 | do { \ | ||
34 | int i, j; \ | ||
35 | for (i = 0; i < BUF_SIZE; i += 4) { \ | ||
36 | for (j = 0; j < channels; j++) { \ | ||
37 | uint32_t r = rnd() & (1 << (bits - 2)) - 1; \ | ||
38 | AV_WN32A(ref_src[j] + i, r); \ | ||
39 | AV_WN32A(new_src[j] + i, r); \ | ||
40 | } \ | ||
41 | } \ | ||
42 | } while (0) | ||
43 | |||
44 | 32 | static void check_decorrelate(uint8_t **ref_dst, uint8_t **ref_src, uint8_t **new_dst, uint8_t **new_src, | |
45 | int channels, int bits) { | ||
46 | 32 | declare_func(void, uint8_t **out, int32_t **in, int channels, int len, int shift); | |
47 | |||
48 |
4/4✓ Branch 1 taken 8320 times.
✓ Branch 2 taken 2048 times.
✓ Branch 3 taken 2048 times.
✓ Branch 4 taken 32 times.
|
10400 | randomize_buffers(); |
49 | 32 | call_ref(ref_dst, (int32_t **)ref_src, channels, BUF_SIZE / sizeof(int32_t), 8); | |
50 | 32 | call_new(new_dst, (int32_t **)new_src, channels, BUF_SIZE / sizeof(int32_t), 8); | |
51 |
3/4✓ Branch 0 taken 15 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
|
32 | if (memcmp(*ref_dst, *new_dst, bits == 16 ? BUF_SIZE * (channels/2) : BUF_SIZE * channels) || |
52 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
|
32 | memcmp(*ref_src, *new_src, BUF_SIZE * channels)) |
53 | ✗ | fail(); | |
54 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 32 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.
|
32 | bench_new(new_dst, (int32_t **)new_src, channels, BUF_SIZE / sizeof(int32_t), 8); |
55 | 32 | } | |
56 | |||
57 | 12 | static void check_lpc(int pred_order) | |
58 | { | ||
59 | 12 | int qlevel = rnd() % 16; | |
60 | 12 | LOCAL_ALIGNED_16(int32_t, coeffs, [32]); | |
61 | 12 | LOCAL_ALIGNED_16(int32_t, dst0, [BUF_SIZE]); | |
62 | 12 | LOCAL_ALIGNED_16(int32_t, dst1, [BUF_SIZE]); | |
63 | |||
64 | 12 | declare_func(void, int32_t *, const int[32], int, int, int); | |
65 | |||
66 |
2/2✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
|
396 | for (int i = 0; i < 32; i++) |
67 | 384 | coeffs[i] = rnd(); | |
68 |
2/2✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
|
3084 | for (int i = 0; i < BUF_SIZE; i++) |
69 | 3072 | dst0[i] = rnd(); | |
70 | |||
71 | 12 | memcpy(dst1, dst0, BUF_SIZE * sizeof (int32_t)); | |
72 | 12 | call_ref(dst0, coeffs, pred_order, qlevel, BUF_SIZE); | |
73 | 12 | call_new(dst1, coeffs, pred_order, qlevel, BUF_SIZE); | |
74 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if (memcmp(dst0, dst1, BUF_SIZE * sizeof (int32_t)) != 0) |
75 | ✗ | fail(); | |
76 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 12 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.
|
12 | bench_new(dst1, coeffs, pred_order, qlevel, BUF_SIZE); |
77 | 12 | } | |
78 | |||
79 | 13 | void checkasm_check_flacdsp(void) | |
80 | { | ||
81 | 13 | LOCAL_ALIGNED_16(uint8_t, ref_dst, [BUF_SIZE*MAX_CHANNELS]); | |
82 | 13 | LOCAL_ALIGNED_16(uint8_t, ref_buf, [BUF_SIZE*MAX_CHANNELS]); | |
83 | 13 | LOCAL_ALIGNED_16(uint8_t, new_dst, [BUF_SIZE*MAX_CHANNELS]); | |
84 | 13 | LOCAL_ALIGNED_16(uint8_t, new_buf, [BUF_SIZE*MAX_CHANNELS]); | |
85 | 13 | uint8_t *ref_src[] = { &ref_buf[BUF_SIZE*0], &ref_buf[BUF_SIZE*1], &ref_buf[BUF_SIZE*2], &ref_buf[BUF_SIZE*3], | |
86 | 13 | &ref_buf[BUF_SIZE*4], &ref_buf[BUF_SIZE*5], &ref_buf[BUF_SIZE*6], &ref_buf[BUF_SIZE*7] }; | |
87 | 13 | uint8_t *new_src[] = { &new_buf[BUF_SIZE*0], &new_buf[BUF_SIZE*1], &new_buf[BUF_SIZE*2], &new_buf[BUF_SIZE*3], | |
88 | 13 | &new_buf[BUF_SIZE*4], &new_buf[BUF_SIZE*5], &new_buf[BUF_SIZE*6], &new_buf[BUF_SIZE*7] }; | |
89 | static const char * const names[3] = { "ls", "rs", "ms" }; | ||
90 | static const struct { | ||
91 | enum AVSampleFormat fmt; | ||
92 | int bits; | ||
93 | } fmts[] = { | ||
94 | { AV_SAMPLE_FMT_S16, 16 }, | ||
95 | { AV_SAMPLE_FMT_S32, 32 }, | ||
96 | }; | ||
97 | static const signed char pred_orders[] = { 13, 16, 29, 32 }; | ||
98 | FLACDSPContext h; | ||
99 | int i, j; | ||
100 | |||
101 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 13 times.
|
39 | for (i = 0; i < 2; i++) { |
102 | 26 | ff_flacdsp_init(&h, fmts[i].fmt, 2); | |
103 |
2/2✓ Branch 0 taken 78 times.
✓ Branch 1 taken 26 times.
|
104 | for (j = 0; j < 3; j++) |
104 |
2/2✓ Branch 3 taken 12 times.
✓ Branch 4 taken 66 times.
|
78 | if (check_func(h.decorrelate[j + 1], "flac_decorrelate_%s_%d", names[j], fmts[i].bits)) |
105 | 12 | check_decorrelate(&ref_dst, ref_src, &new_dst, new_src, 2, fmts[i].bits); | |
106 |
2/2✓ Branch 0 taken 104 times.
✓ Branch 1 taken 26 times.
|
130 | for (j = 2; j <= MAX_CHANNELS; j += 2) { |
107 | 104 | ff_flacdsp_init(&h, fmts[i].fmt, j); | |
108 |
2/2✓ Branch 3 taken 20 times.
✓ Branch 4 taken 84 times.
|
104 | if (check_func(h.decorrelate[0], "flac_decorrelate_indep%d_%d", j, fmts[i].bits)) |
109 | 20 | check_decorrelate(&ref_dst, ref_src, &new_dst, new_src, j, fmts[i].bits); | |
110 | } | ||
111 | } | ||
112 | |||
113 | 13 | report("decorrelate"); | |
114 | |||
115 |
2/2✓ Branch 0 taken 52 times.
✓ Branch 1 taken 13 times.
|
65 | for (i = 0; i < FF_ARRAY_ELEMS(pred_orders); i++) |
116 |
2/2✓ Branch 3 taken 4 times.
✓ Branch 4 taken 48 times.
|
52 | if (check_func(h.lpc16, "flac_lpc_16_%d", pred_orders[i])) |
117 | 4 | check_lpc(pred_orders[i]); | |
118 |
2/2✓ Branch 0 taken 52 times.
✓ Branch 1 taken 13 times.
|
65 | for (i = 0; i < FF_ARRAY_ELEMS(pred_orders); i++) |
119 |
2/2✓ Branch 3 taken 8 times.
✓ Branch 4 taken 44 times.
|
52 | if (check_func(h.lpc32, "flac_lpc_32_%d", pred_orders[i])) |
120 | 8 | check_lpc(pred_orders[i]); | |
121 | |||
122 | 13 | report("lpc"); | |
123 | 13 | } | |
124 |