FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/llauddsp.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 45 47 95.7%
Functions: 3 3 100.0%
Branches: 22 40 55.0%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2016 Alexandra Hájková
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include <string.h>
22
23 #include "libavutil/common.h"
24 #include "libavutil/intreadwrite.h"
25 #include "libavutil/mem.h"
26 #include "libavutil/mem_internal.h"
27
28 #include "libavcodec/lossless_audiodsp.h"
29
30 #include "checkasm.h"
31
32 #define randomize_buf(buf, len) \
33 do { \
34 for (int i = 0; i < len; i++) \
35 buf[i] = rnd(); \
36 } while (0)
37
38 13 static void check_scalarproduct_and_madd_int16(LLAudDSPContext *c)
39 {
40 #define BUF_SIZE 1088 // multiple of 16
41 13 LOCAL_ALIGNED_16(int16_t, v1, [BUF_SIZE]);
42 13 LOCAL_ALIGNED_16(int16_t, v2, [BUF_SIZE]);
43 13 LOCAL_ALIGNED_16(int16_t, v3, [BUF_SIZE]);
44 int mul;
45
46 13 declare_func(int32_t, int16_t *, const int16_t *, const int16_t *,
47 int, int);
48
49
2/2
✓ Branch 1 taken 14144 times.
✓ Branch 2 taken 13 times.
14157 randomize_buf(v1, BUF_SIZE);
50
2/2
✓ Branch 1 taken 14144 times.
✓ Branch 2 taken 13 times.
14157 randomize_buf(v2, BUF_SIZE);
51
2/2
✓ Branch 1 taken 14144 times.
✓ Branch 2 taken 13 times.
14157 randomize_buf(v3, BUF_SIZE);
52 13 mul = (int16_t)rnd();
53
54
2/2
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
13 if (check_func(c->scalarproduct_and_madd_int16,
55 "scalarproduct_and_madd_int16")) {
56 3 LOCAL_ALIGNED_16(int16_t, dst0, [BUF_SIZE]);
57 3 LOCAL_ALIGNED_16(int16_t, dst1, [BUF_SIZE]);
58 int ref, val;
59
60 3 memcpy(dst0, v1, sizeof (*dst0) * BUF_SIZE);
61 3 memcpy(dst1, v1, sizeof (*dst1) * BUF_SIZE);
62 3 ref = call_ref(dst0, v2, v3, BUF_SIZE, mul);
63 3 val = call_new(dst1, v2, v3, BUF_SIZE, mul);
64
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 if (memcmp(dst0, dst1, sizeof (*dst0) * BUF_SIZE) != 0 || ref != val)
65 fail();
66
67
1/8
✗ Branch 1 not taken.
✓ Branch 2 taken 3 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.
3 bench_new(v1, v2, v3, BUF_SIZE, mul);
68 }
69
70 13 report("scalarproduct_and_madd_int16");
71 13 }
72
73 13 static void check_scalarproduct_and_madd_int32(LLAudDSPContext *c)
74 {
75 #define BUF_SIZE 1088 // multiple of 16
76 13 LOCAL_ALIGNED_16(int16_t, v1, [BUF_SIZE]);
77 13 LOCAL_ALIGNED_16(int32_t, v2, [BUF_SIZE]);
78 13 LOCAL_ALIGNED_16(int16_t, v3, [BUF_SIZE]);
79 int mul;
80
81 13 declare_func(int32_t, int16_t *, const int32_t *, const int16_t *,
82 int, int);
83
84
2/2
✓ Branch 1 taken 14144 times.
✓ Branch 2 taken 13 times.
14157 randomize_buf(v1, BUF_SIZE);
85
2/2
✓ Branch 1 taken 14144 times.
✓ Branch 2 taken 13 times.
14157 randomize_buf(v2, BUF_SIZE);
86
2/2
✓ Branch 1 taken 14144 times.
✓ Branch 2 taken 13 times.
14157 randomize_buf(v3, BUF_SIZE);
87 13 mul = (int16_t)rnd();
88
89
2/2
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 11 times.
13 if (check_func(c->scalarproduct_and_madd_int32,
90 "scalarproduct_and_madd_int32")) {
91 2 LOCAL_ALIGNED_16(int16_t, dst0, [BUF_SIZE]);
92 2 LOCAL_ALIGNED_16(int16_t, dst1, [BUF_SIZE]);
93 int ref, val;
94
95 2 memcpy(dst0, v1, sizeof (*dst0) * BUF_SIZE);
96 2 memcpy(dst1, v1, sizeof (*dst1) * BUF_SIZE);
97 2 ref = call_ref(dst0, v2, v3, BUF_SIZE, mul);
98 2 val = call_new(dst1, v2, v3, BUF_SIZE, mul);
99
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if (memcmp(dst0, dst1, sizeof (*dst0) * BUF_SIZE) != 0 || ref != val)
100 fail();
101
102
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(v1, v2, v3, BUF_SIZE, mul);
103 }
104
105 13 report("scalarproduct_and_madd_int32");
106 13 }
107
108 13 void checkasm_check_llauddsp(void)
109 {
110 LLAudDSPContext c;
111
112 13 ff_llauddsp_init(&c);
113 13 check_scalarproduct_and_madd_int16(&c);
114 13 check_scalarproduct_and_madd_int32(&c);
115 13 }
116