| 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 "config.h" | ||
| 20 | |||
| 21 | #include <float.h> | ||
| 22 | #include <stdint.h> | ||
| 23 | #include <stdio.h> | ||
| 24 | #include <string.h> | ||
| 25 | |||
| 26 | #include "libavfilter/af_afirdsp.h" | ||
| 27 | #include "libavutil/internal.h" | ||
| 28 | #include "libavutil/mem_internal.h" | ||
| 29 | #include "checkasm.h" | ||
| 30 | |||
| 31 | #define LEN 256 | ||
| 32 | |||
| 33 | 14 | static void test_fcmul_add(AudioFIRDSPContext *fir) | |
| 34 | { | ||
| 35 | #define BUF_SIZE LEN*2+8 | ||
| 36 | 14 | LOCAL_ALIGNED_32(float, src0, [BUF_SIZE]); | |
| 37 | 14 | LOCAL_ALIGNED_32(float, src1, [BUF_SIZE]); | |
| 38 | 14 | LOCAL_ALIGNED_32(float, src2, [BUF_SIZE]); | |
| 39 | |||
| 40 | 14 | randomize_stddev(src0, BUF_SIZE, 10.0); | |
| 41 | 14 | randomize_stddev(src1, BUF_SIZE, 10.0); | |
| 42 | 14 | randomize_stddev(src2, BUF_SIZE, 10.0); | |
| 43 | |||
| 44 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 10 times.
|
14 | if (check_func(fir->fcmul_add, "fcmul_add")) { |
| 45 | 4 | LOCAL_ALIGNED_32(float, cdst, [BUF_SIZE]); | |
| 46 | 4 | LOCAL_ALIGNED_32(float, odst, [BUF_SIZE]); | |
| 47 | int i; | ||
| 48 | |||
| 49 | 4 | declare_func(void, float *sum, const float *t, const float *c, | |
| 50 | ptrdiff_t len); | ||
| 51 | |||
| 52 | 4 | memcpy(cdst, src0, (BUF_SIZE) * sizeof(float)); | |
| 53 | 4 | memcpy(odst, src0, (BUF_SIZE) * sizeof(float)); | |
| 54 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
|
4 | call_ref(cdst, src1, src2, LEN); |
| 55 | 4 | call_new(odst, src1, src2, LEN); | |
| 56 |
2/2✓ Branch 0 taken 2052 times.
✓ Branch 1 taken 4 times.
|
2056 | for (i = 0; i <= LEN*2; i++) { |
| 57 | 2052 | int idx = i & ~1; | |
| 58 | 2052 | float cre = src2[idx]; | |
| 59 | 2052 | float cim = src2[idx + 1]; | |
| 60 | 2052 | float tre = src1[idx]; | |
| 61 | 2052 | float tim = src1[idx + 1]; | |
| 62 | 2052 | double t = fabs(src0[i]) + | |
| 63 | 2052 | fabs(tre) + fabs(tim) + fabs(cre) + fabs(cim) + | |
| 64 | 2052 | fabs(tre * cre) + fabs(tim * cim) + | |
| 65 | 2052 | fabs(tre * cim) + fabs(tim * cre) + | |
| 66 | 2052 | fabs(tre * cre - tim * cim) + | |
| 67 | 2052 | fabs(tre * cim + tim * cre) + | |
| 68 | 2052 | fabs(cdst[i]) + 1.0; | |
| 69 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2052 times.
|
2052 | if (!float_near_abs_eps(cdst[i], odst[i], t * 2 * FLT_EPSILON)) { |
| 70 | ✗ | fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", | |
| 71 | ✗ | i, cdst[i], odst[i], cdst[i] - odst[i]); | |
| 72 | ✗ | fail(); | |
| 73 | ✗ | break; | |
| 74 | } | ||
| 75 | } | ||
| 76 | 4 | memcpy(odst, src0, (BUF_SIZE) * sizeof(float)); | |
| 77 |
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(odst, src1, src2, LEN); |
| 78 | } | ||
| 79 | |||
| 80 | 14 | report("fcmul_add"); | |
| 81 | 14 | } | |
| 82 | |||
| 83 | 14 | static void test_dcmul_add(AudioFIRDSPContext *fir) | |
| 84 | { | ||
| 85 | #define BUF_SIZE LEN*2+8 | ||
| 86 | 14 | LOCAL_ALIGNED_32(double, src0, [BUF_SIZE]); | |
| 87 | 14 | LOCAL_ALIGNED_32(double, src1, [BUF_SIZE]); | |
| 88 | 14 | LOCAL_ALIGNED_32(double, src2, [BUF_SIZE]); | |
| 89 | |||
| 90 | 14 | randomize_stddev_dbl(src0, BUF_SIZE, 10.0); | |
| 91 | 14 | randomize_stddev_dbl(src1, BUF_SIZE, 10.0); | |
| 92 | 14 | randomize_stddev_dbl(src2, BUF_SIZE, 10.0); | |
| 93 | |||
| 94 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 13 times.
|
14 | if (check_func(fir->dcmul_add, "dcmul_add")) { |
| 95 | 1 | LOCAL_ALIGNED_32(double, cdst, [BUF_SIZE]); | |
| 96 | 1 | LOCAL_ALIGNED_32(double, odst, [BUF_SIZE]); | |
| 97 | int i; | ||
| 98 | |||
| 99 | 1 | declare_func(void, double *sum, const double *t, const double *c, | |
| 100 | ptrdiff_t len); | ||
| 101 | |||
| 102 | 1 | memcpy(cdst, src0, (BUF_SIZE) * sizeof(double)); | |
| 103 | 1 | memcpy(odst, src0, (BUF_SIZE) * sizeof(double)); | |
| 104 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | call_ref(cdst, src1, src2, LEN); |
| 105 | 1 | call_new(odst, src1, src2, LEN); | |
| 106 |
2/2✓ Branch 0 taken 513 times.
✓ Branch 1 taken 1 times.
|
514 | for (i = 0; i <= LEN*2; i++) { |
| 107 | 513 | int idx = i & ~1; | |
| 108 | 513 | double cre = src2[idx]; | |
| 109 | 513 | double cim = src2[idx + 1]; | |
| 110 | 513 | double tre = src1[idx]; | |
| 111 | 513 | double tim = src1[idx + 1]; | |
| 112 | 513 | double t = fabs(src0[i]) + | |
| 113 | 513 | fabs(tre) + fabs(tim) + fabs(cre) + fabs(cim) + | |
| 114 | 513 | fabs(tre * cre) + fabs(tim * cim) + | |
| 115 | 513 | fabs(tre * cim) + fabs(tim * cre) + | |
| 116 | 513 | fabs(tre * cre - tim * cim) + | |
| 117 | 513 | fabs(tre * cim + tim * cre) + | |
| 118 | 513 | fabs(cdst[i]) + 1.0; | |
| 119 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
513 | if (!double_near_abs_eps(cdst[i], odst[i], t * 2 * FLT_EPSILON)) { |
| 120 | ✗ | fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", | |
| 121 | ✗ | i, cdst[i], odst[i], cdst[i] - odst[i]); | |
| 122 | ✗ | fail(); | |
| 123 | ✗ | break; | |
| 124 | } | ||
| 125 | } | ||
| 126 | 1 | memcpy(odst, src0, (BUF_SIZE) * sizeof(double)); | |
| 127 |
1/18✗ Branch 1 not taken.
✓ Branch 2 taken 1 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.
|
1 | bench_new(odst, src1, src2, LEN); |
| 128 | } | ||
| 129 | |||
| 130 | 14 | report("dcmul_add"); | |
| 131 | 14 | } | |
| 132 | |||
| 133 | |||
| 134 | 14 | void checkasm_check_afir(void) | |
| 135 | { | ||
| 136 | 14 | AudioFIRDSPContext fir = { 0 }; | |
| 137 | |||
| 138 | 14 | ff_afir_init(&fir); | |
| 139 | 14 | test_fcmul_add(&fir); | |
| 140 | 14 | test_dcmul_add(&fir); | |
| 141 | 14 | } | |
| 142 |