| 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 <stdint.h> | ||
| 20 | #include <string.h> | ||
| 21 | |||
| 22 | #include "libavcodec/dcadata.h" | ||
| 23 | #include "libavcodec/dcadsp.h" | ||
| 24 | #include "libavutil/common.h" | ||
| 25 | #include "libavutil/mem_internal.h" | ||
| 26 | |||
| 27 | #include "checkasm.h" | ||
| 28 | |||
| 29 | #define N 32 | ||
| 30 | #define BLOCKSIZE 128 | ||
| 31 | #define BUF_SIZE (N * BLOCKSIZE) | ||
| 32 | #define LFE_HISTORY 8 | ||
| 33 | #define LFE_SIZE (N + LFE_HISTORY + 1) | ||
| 34 | |||
| 35 | /* sign_extend(rnd(), 23) would be the correct approach here, | ||
| 36 | * but it results in differences that would require a much | ||
| 37 | * bigger EPS value, thus we use 16 (simplified as a cast). */ | ||
| 38 | #define randomize(buf, len) do { \ | ||
| 39 | for (int i = 0; i < len; i++) \ | ||
| 40 | (buf)[i] = (int16_t)rnd(); \ | ||
| 41 | } while (0) | ||
| 42 | |||
| 43 | #define EPS 0.0005f | ||
| 44 | |||
| 45 | 14 | static void test_lfe_fir_float(const DCADSPContext *dca) | |
| 46 | { | ||
| 47 | 14 | LOCAL_ALIGNED_16(float, dst0, [BUF_SIZE]); | |
| 48 | 14 | LOCAL_ALIGNED_16(float, dst1, [BUF_SIZE]); | |
| 49 | 14 | LOCAL_ALIGNED_16(int32_t, lfe, [LFE_SIZE]); | |
| 50 | |||
| 51 | 14 | declare_func(void, float *pcm_samples, const int32_t *lfe_samples, | |
| 52 | const float *filter_coeff, ptrdiff_t npcmblocks); | ||
| 53 | |||
| 54 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 14 times.
|
42 | for (int i = 0; i < 2; i++) { |
| 55 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
|
28 | const float *coeffs = i ? ff_dca_lfe_fir_128 : ff_dca_lfe_fir_64; |
| 56 |
2/2✓ Branch 3 taken 7 times.
✓ Branch 4 taken 21 times.
|
28 | if (check_func(dca->lfe_fir_float[i], "lfe_fir%d_float", i)) { |
| 57 | 7 | memset(dst0, 0, BUF_SIZE * sizeof(float)); | |
| 58 | 7 | memset(dst1, 0, BUF_SIZE * sizeof(float)); | |
| 59 |
2/2✓ Branch 1 taken 287 times.
✓ Branch 2 taken 7 times.
|
294 | randomize(lfe, LFE_SIZE); |
| 60 | 7 | call_ref(dst0, lfe + LFE_HISTORY, coeffs, N); | |
| 61 | 7 | call_new(dst1, lfe + LFE_HISTORY, coeffs, N); | |
| 62 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
|
7 | if (!float_near_abs_eps_array(dst0, dst1, EPS, BUF_SIZE)) |
| 63 | ✗ | fail(); | |
| 64 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
|
7 | bench_new(dst1, lfe + LFE_HISTORY, coeffs, N); |
| 65 | } | ||
| 66 | } | ||
| 67 | 14 | } | |
| 68 | |||
| 69 | 1 | static void test_lfe_fir_fixed(void) | |
| 70 | { | ||
| 71 | 1 | LOCAL_ALIGNED_16(int32_t, dst0, [BUF_SIZE]); | |
| 72 | 1 | LOCAL_ALIGNED_16(int32_t, dst1, [BUF_SIZE]); | |
| 73 | 1 | LOCAL_ALIGNED_16(int32_t, lfe, [LFE_SIZE]); | |
| 74 | 1 | const int32_t *coeffs = ff_dca_lfe_fir_64_fixed; | |
| 75 | |||
| 76 | 1 | declare_func(void, int32_t *pcm_samples, const int32_t *lfe_samples, | |
| 77 | const int32_t *filter_coeff, ptrdiff_t npcmblocks); | ||
| 78 | |||
| 79 | 1 | memset(dst0, 0, BUF_SIZE * sizeof(int32_t)); | |
| 80 | 1 | memset(dst1, 0, BUF_SIZE * sizeof(int32_t)); | |
| 81 |
2/2✓ Branch 1 taken 41 times.
✓ Branch 2 taken 1 times.
|
42 | randomize(lfe, LFE_SIZE); |
| 82 | 1 | call_ref(dst0, lfe + LFE_HISTORY, coeffs, N); | |
| 83 | 1 | call_new(dst1, lfe + LFE_HISTORY, coeffs, N); | |
| 84 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (memcmp(dst0, dst1, BUF_SIZE * sizeof(int32_t))) |
| 85 | ✗ | fail(); | |
| 86 |
1/8✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
|
1 | bench_new(dst1, lfe + LFE_HISTORY, coeffs, N); |
| 87 | 1 | } | |
| 88 | |||
| 89 | 14 | void checkasm_check_dcadsp(void) | |
| 90 | { | ||
| 91 | DCADSPContext dca; | ||
| 92 | |||
| 93 | 14 | ff_dcadsp_init(&dca); | |
| 94 | |||
| 95 | 14 | test_lfe_fir_float(&dca); | |
| 96 | 14 | report("lfe_fir_float"); | |
| 97 | |||
| 98 |
2/2✓ Branch 3 taken 1 times.
✓ Branch 4 taken 13 times.
|
14 | if (check_func(dca.lfe_fir_fixed, "lfe_fir_fixed")) |
| 99 | 1 | test_lfe_fir_fixed(); | |
| 100 | 14 | report("lfe_fir_fixed"); | |
| 101 | 14 | } | |
| 102 |