FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/vorbisdsp.c
Date: 2024-05-03 15:42:48
Exec Total Coverage
Lines: 27 33 81.8%
Functions: 2 2 100.0%
Branches: 11 20 55.0%

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 <float.h>
20
21 #include "libavutil/mem_internal.h"
22
23 #include "libavcodec/vorbisdsp.h"
24
25 #include "checkasm.h"
26
27 #define LEN 512
28
29 #define randomize_buffer(buf) \
30 do { \
31 double bmg[2], stddev = 10.0, mean = 0.0; \
32 \
33 for (int i = 0; i < LEN; i += 2) { \
34 av_bmg_get(&checkasm_lfg, bmg); \
35 buf[i] = bmg[0] * stddev + mean; \
36 buf[i + 1] = bmg[1] * stddev + mean; \
37 } \
38 } while(0);
39
40 2 static void test_inverse_coupling(void)
41 {
42 2 LOCAL_ALIGNED_16(float, src0, [LEN]);
43 2 LOCAL_ALIGNED_16(float, src1, [LEN]);
44 2 LOCAL_ALIGNED_16(float, cdst, [LEN]);
45 2 LOCAL_ALIGNED_16(float, odst, [LEN]);
46 2 LOCAL_ALIGNED_16(float, cdst1, [LEN]);
47 2 LOCAL_ALIGNED_16(float, odst1, [LEN]);
48
49 2 declare_func(void, float *restrict mag, float *restrict ang,
50 ptrdiff_t blocksize);
51
52
2/2
✓ Branch 1 taken 512 times.
✓ Branch 2 taken 2 times.
514 randomize_buffer(src0);
53
2/2
✓ Branch 1 taken 512 times.
✓ Branch 2 taken 2 times.
514 randomize_buffer(src1);
54
55 2 memcpy(cdst, src0, LEN * sizeof(*src0));
56 2 memcpy(cdst1, src1, LEN * sizeof(*src1));
57 2 memcpy(odst, src0, LEN * sizeof(*src0));
58 2 memcpy(odst1, src1, LEN * sizeof(*src1));
59
60 2 call_ref(cdst, cdst1, LEN);
61 2 call_new(odst, odst1, LEN);
62
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 2 times.
1026 for (int i = 0; i < LEN; i++) {
63
2/4
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1024 times.
2048 if (!float_near_abs_eps(cdst[i], odst[i], FLT_EPSILON) ||
64 1024 !float_near_abs_eps(cdst1[i], odst1[i], FLT_EPSILON)) {
65 fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
66 i, cdst[i], odst[i], cdst[i] - odst[i]);
67 fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
68 i, cdst1[i], odst1[i], cdst1[i] - odst1[i]);
69 fail();
70 break;
71 }
72 }
73
1/8
✗ Branch 1 not taken.
✓ Branch 2 taken 2 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.
2 bench_new(src0, src1, LEN);
74 2 }
75
76 13 void checkasm_check_vorbisdsp(void)
77 {
78 VorbisDSPContext dsp;
79
80 13 ff_vorbisdsp_init(&dsp);
81
82
2/2
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
13 if (check_func(dsp.vorbis_inverse_coupling, "inverse_coupling"))
83 2 test_inverse_coupling();
84 13 report("inverse_coupling");
85 13 }
86