| 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 <stddef.h> | ||
| 20 | #include <stdint.h> | ||
| 21 | |||
| 22 | #include "checkasm.h" | ||
| 23 | #include "libavcodec/sbcdsp.h" | ||
| 24 | #include "libavcodec/sbcdsp_data.h" | ||
| 25 | #include "libavutil/macros.h" | ||
| 26 | #include "libavutil/mem_internal.h" | ||
| 27 | |||
| 28 | enum { | ||
| 29 | SBC_MAX_SUBBANDS = 8, | ||
| 30 | }; | ||
| 31 | |||
| 32 | #define randomize_buffer(buf) \ | ||
| 33 | do { \ | ||
| 34 | for (size_t k = 0; k < FF_ARRAY_ELEMS(buf); ++k) \ | ||
| 35 | buf[k] = rnd(); \ | ||
| 36 | } while (0) | ||
| 37 | |||
| 38 | 14 | static void check_sbc_analyze(SBCDSPContext *sbcdsp) | |
| 39 | { | ||
| 40 | DECLARE_ALIGNED(SBC_ALIGN, int16_t, in)[10 * SBC_MAX_SUBBANDS]; | ||
| 41 | DECLARE_ALIGNED(SBC_ALIGN, int32_t, out_ref)[SBC_MAX_SUBBANDS]; | ||
| 42 | DECLARE_ALIGNED(SBC_ALIGN, int32_t, out_new)[SBC_MAX_SUBBANDS]; | ||
| 43 | |||
| 44 | 14 | declare_func(void, const int16_t *in, int32_t *out, const int16_t *consts); | |
| 45 | |||
| 46 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 14 times.
|
42 | for (int i = 0; i < 2; ++i) { |
| 47 |
6/6✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 14 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 24 times.
|
28 | if (check_func(i ? sbcdsp->sbc_analyze_8 : sbcdsp->sbc_analyze_4, "sbc_analyze_%u", i ? 8 : 4)) { |
| 48 |
2/2✓ Branch 1 taken 320 times.
✓ Branch 2 taken 4 times.
|
324 | randomize_buffer(in); |
| 49 |
2/2✓ Branch 1 taken 32 times.
✓ Branch 2 taken 4 times.
|
36 | randomize_buffer(out_ref); |
| 50 | 4 | memcpy(out_new, out_ref, sizeof(out_new)); | |
| 51 | |||
| 52 | // the input is always 16-byte aligned for sbc_analyze_8 | ||
| 53 | // for sbc_analyze_4 it can be 0 or 8 mod 16. | ||
| 54 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
|
4 | const int16_t *const inp = i || rnd() & 1 ? in : in + 4; |
| 55 | // Use the proper const tables as random ones can cause overflow | ||
| 56 | #define CONST(SIZE, ODDEVEN) sbcdsp_analysis_consts_fixed ## SIZE ## _simd_ ## ODDEVEN | ||
| 57 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
6 | const int16_t *const consts = rnd() & 1 ? (i ? CONST(8, odd) : CONST(4, odd)) |
| 58 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
6 | : (i ? CONST(8, even) : CONST(4, even)); |
| 59 | |||
| 60 | 4 | call_ref(inp, out_ref, consts); | |
| 61 | 4 | call_new(inp, out_new, consts); | |
| 62 | |||
| 63 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (memcmp(out_ref, out_new, sizeof(out_new))) |
| 64 | ✗ | fail(); | |
| 65 | |||
| 66 |
1/18✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
|
4 | bench_new(inp, out_new, consts); |
| 67 | } | ||
| 68 | } | ||
| 69 | 14 | report("sbc_analyze"); | |
| 70 | 14 | } | |
| 71 | |||
| 72 | 14 | static void check_sbc_calc_scalefactors(const SBCDSPContext *const sbcdsp) | |
| 73 | { | ||
| 74 | DECLARE_ALIGNED(SBC_ALIGN, int32_t, sb_sample_f)[16][2][8]; | ||
| 75 | DECLARE_ALIGNED(SBC_ALIGN, uint32_t, scale_factor_ref)[2][8]; | ||
| 76 | DECLARE_ALIGNED(SBC_ALIGN, uint32_t, scale_factor_new)[2][8]; | ||
| 77 | |||
| 78 | 14 | declare_func(void, const int32_t sb_sample_f[16][2][8], | |
| 79 | uint32_t scale_factor[2][8], | ||
| 80 | int blocks, int channels, int subbands); | ||
| 81 | |||
| 82 | static int blocks = 0; | ||
| 83 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
|
14 | if (!blocks) |
| 84 | 1 | blocks = ((const int[]){4, 8, 12, 15, 16})[rnd() % 5]; | |
| 85 | 14 | int inited = 0; | |
| 86 | |||
| 87 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
|
18 | for (int ch = 1; ch <= 2; ++ch) { |
| 88 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4 times.
|
24 | for (int subbands = 4; subbands <= 8; subbands += 4) { |
| 89 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 2 taken 8 times.
|
20 | if (!check_func(sbcdsp->sbc_calc_scalefactors, "calc_scalefactors_%dch_%dsubbands", ch, subbands)) |
| 90 | 12 | return; | |
| 91 | |||
| 92 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | if (!inited) { |
| 93 |
2/2✓ Branch 0 taken 128 times.
✓ Branch 1 taken 8 times.
|
136 | for (size_t i = 0; i < FF_ARRAY_ELEMS(sb_sample_f); ++i) |
| 94 |
2/2✓ Branch 0 taken 256 times.
✓ Branch 1 taken 128 times.
|
384 | for (size_t j = 0; j < FF_ARRAY_ELEMS(sb_sample_f[0]); ++j) |
| 95 |
2/2✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 256 times.
|
2304 | for (size_t k = 0; k < FF_ARRAY_ELEMS(sb_sample_f[0][0]); ++k) |
| 96 | 2048 | sb_sample_f[i][j][k] = rnd(); | |
| 97 | } | ||
| 98 | |||
| 99 | 8 | call_ref(sb_sample_f, scale_factor_ref, blocks, ch, subbands); | |
| 100 | 8 | call_new(sb_sample_f, scale_factor_new, blocks, ch, subbands); | |
| 101 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8 times.
|
20 | for (int i = 0; i < ch; ++i) |
| 102 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
|
84 | for (int j = 0; j < subbands; ++j) |
| 103 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
|
72 | if (scale_factor_ref[i][j] != scale_factor_new[i][j]) |
| 104 | ✗ | fail(); | |
| 105 | |||
| 106 |
1/18✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
|
8 | bench_new(sb_sample_f, scale_factor_new, blocks, ch, subbands); |
| 107 | } | ||
| 108 | } | ||
| 109 | } | ||
| 110 | |||
| 111 | 14 | void checkasm_check_sbcdsp(void) | |
| 112 | { | ||
| 113 | SBCDSPContext sbcdsp; | ||
| 114 | |||
| 115 | 14 | ff_sbcdsp_init(&sbcdsp); | |
| 116 | |||
| 117 | 14 | check_sbc_analyze(&sbcdsp); | |
| 118 | |||
| 119 | 14 | check_sbc_calc_scalefactors(&sbcdsp); | |
| 120 | 14 | report("calc_scalefactors"); | |
| 121 | 14 | } | |
| 122 |