| 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 <string.h> | ||
| 20 | |||
| 21 | #include "libavutil/mem_internal.h" | ||
| 22 | |||
| 23 | #include "libavcodec/opus/dsp.h" | ||
| 24 | #include "libavcodec/opus/tab.h" | ||
| 25 | |||
| 26 | #include "checkasm.h" | ||
| 27 | |||
| 28 | #define randomize_float(buf, len) \ | ||
| 29 | do { \ | ||
| 30 | for (int i = 0; i < len; i++) { \ | ||
| 31 | float f = (float)rnd() / (UINT_MAX >> 5) - 16.0f; \ | ||
| 32 | buf[i] = f; \ | ||
| 33 | } \ | ||
| 34 | } while (0) | ||
| 35 | |||
| 36 | #define EPS 0.005 | ||
| 37 | #define MAX_SIZE (960) | ||
| 38 | |||
| 39 | /* period is between 15 and 1022, inclusive */ | ||
| 40 | 6 | static void test_postfilter(int period) | |
| 41 | { | ||
| 42 | 6 | LOCAL_ALIGNED(16, float, data0, [MAX_SIZE + 1024]); | |
| 43 | 6 | LOCAL_ALIGNED(16, float, data1, [MAX_SIZE + 1024]); | |
| 44 | |||
| 45 | /* This filter can explode very easily, so use a tapset from the codec. | ||
| 46 | * In the codec these are usually multiplied by at least 0.09375f, | ||
| 47 | * so its outside the largest filter value, but the filter is still stable | ||
| 48 | * so use it. */ | ||
| 49 | 6 | float gains[3] = { 0.3066406250f, 0.2170410156f, 0.1296386719f }; | |
| 50 | |||
| 51 | /* The codec will always call with an offset which is aligned once | ||
| 52 | * (period + 2) is subtracted, but here we have to align it ourselves. */ | ||
| 53 | 6 | int offset = FFALIGN(period + 2, 4); | |
| 54 | |||
| 55 | 6 | declare_func(void, float *data, int period, float *gains, int len); | |
| 56 | |||
| 57 |
2/2✓ Branch 1 taken 11904 times.
✓ Branch 2 taken 6 times.
|
11910 | randomize_float(data0, MAX_SIZE + 1024); |
| 58 | 6 | memcpy(data1, data0, (MAX_SIZE + 1024)*sizeof(float)); | |
| 59 | |||
| 60 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
|
6 | call_ref(data0 + offset, period, gains, MAX_SIZE); |
| 61 | 6 | call_new(data1 + offset, period, gains, MAX_SIZE); | |
| 62 | |||
| 63 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
|
6 | if (!float_near_abs_eps_array(data0 + offset, data1 + offset, EPS, MAX_SIZE)) |
| 64 | ✗ | fail(); | |
| 65 |
1/18✗ Branch 1 not taken.
✓ Branch 2 taken 6 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.
|
6 | bench_new(data1 + offset, period, gains, MAX_SIZE); |
| 66 | 6 | } | |
| 67 | |||
| 68 | 2 | static void test_deemphasis(void) | |
| 69 | { | ||
| 70 | 2 | LOCAL_ALIGNED(16, float, src, [FFALIGN(MAX_SIZE, 4)]); | |
| 71 | 2 | LOCAL_ALIGNED(16, float, dst0, [FFALIGN(MAX_SIZE, 4)]); | |
| 72 | 2 | LOCAL_ALIGNED(16, float, dst1, [FFALIGN(MAX_SIZE, 4)]); | |
| 73 | 2 | float coeff0 = (float)rnd() / (UINT_MAX >> 5) - 16.0f, coeff1 = coeff0; | |
| 74 | |||
| 75 | 2 | declare_func_float(float, float *out, float *in, float coeff, const float *weights, int len); | |
| 76 | |||
| 77 |
2/2✓ Branch 1 taken 1920 times.
✓ Branch 2 taken 2 times.
|
1922 | randomize_float(src, MAX_SIZE); |
| 78 | |||
| 79 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | coeff0 = call_ref(dst0, src, coeff0, ff_opus_deemph_weights, MAX_SIZE); |
| 80 | 2 | coeff1 = call_new(dst1, src, coeff1, ff_opus_deemph_weights, MAX_SIZE); | |
| 81 | |||
| 82 |
2/4✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
|
4 | if (!float_near_abs_eps(coeff0, coeff1, EPS) || |
| 83 | 2 | !float_near_abs_eps_array(dst0, dst1, EPS, MAX_SIZE)) | |
| 84 | ✗ | fail(); | |
| 85 |
1/18✗ Branch 1 not taken.
✓ Branch 2 taken 2 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.
|
2 | bench_new(dst1, src, coeff1, ff_opus_deemph_weights, MAX_SIZE); |
| 86 | 2 | } | |
| 87 | |||
| 88 | 14 | void checkasm_check_opusdsp(void) | |
| 89 | { | ||
| 90 | OpusDSP ctx; | ||
| 91 | 14 | ff_opus_dsp_init(&ctx); | |
| 92 | |||
| 93 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 12 times.
|
14 | if (check_func(ctx.postfilter, "postfilter_15")) |
| 94 | 2 | test_postfilter(15); | |
| 95 | 14 | report("postfilter_15"); | |
| 96 | |||
| 97 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 12 times.
|
14 | if (check_func(ctx.postfilter, "postfilter_512")) |
| 98 | 2 | test_postfilter(512); | |
| 99 | 14 | report("postfilter_512"); | |
| 100 | |||
| 101 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 12 times.
|
14 | if (check_func(ctx.postfilter, "postfilter_1022")) |
| 102 | 2 | test_postfilter(1022); | |
| 103 | 14 | report("postfilter_1022"); | |
| 104 | |||
| 105 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 12 times.
|
14 | if (check_func(ctx.deemphasis, "deemphasis")) |
| 106 | 2 | test_deemphasis(); | |
| 107 | 14 | report("deemphasis"); | |
| 108 | 14 | } | |
| 109 |