FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/audiodsp.c
Date: 2026-09-11 16:39:37
Exec Total Coverage
Lines: 30 30 100.0%
Functions: 4 4 100.0%
Branches: 10 10 100.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
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (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 GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <stdint.h>
20
21 #include "libavutil/attributes.h"
22 #include "libavutil/common.h"
23 #include "audiodsp.h"
24
25 4140 static void vector_clipf_c(float *dst, const float *src, int len,
26 float min, float max)
27 {
28
2/2
✓ Branch 0 taken 93930 times.
✓ Branch 1 taken 4140 times.
98070 for (int i = 0; i < len; i += 8) {
29 float tmp[8];
30
31
2/2
✓ Branch 0 taken 751440 times.
✓ Branch 1 taken 93930 times.
845370 for (int j = 0; j < 8; j++)
32 751440 tmp[j]= av_clipf(src[i + j], min, max);
33
2/2
✓ Branch 0 taken 751440 times.
✓ Branch 1 taken 93930 times.
845370 for (int j = 0; j < 8; j++)
34 751440 dst[i + j] = tmp[j];
35 }
36 4140 }
37
38 861033 static int32_t scalarproduct_int16_c(const int16_t *v1, const int16_t *v2,
39 int order)
40 {
41 861033 unsigned res = 0;
42
43
2/2
✓ Branch 0 taken 46930456 times.
✓ Branch 1 taken 861033 times.
47791489 while (order--)
44 46930456 res += *v1++ **v2++;
45
46 861033 return res;
47 }
48
49 1342 static void vector_clip_int32_c(int32_t *dst, const int32_t *src, int32_t min,
50 int32_t max, unsigned int len)
51 {
52 do {
53 13028 *dst++ = av_clip(*src++, min, max);
54 13028 *dst++ = av_clip(*src++, min, max);
55 13028 *dst++ = av_clip(*src++, min, max);
56 13028 *dst++ = av_clip(*src++, min, max);
57 13028 *dst++ = av_clip(*src++, min, max);
58 13028 *dst++ = av_clip(*src++, min, max);
59 13028 *dst++ = av_clip(*src++, min, max);
60 13028 *dst++ = av_clip(*src++, min, max);
61 13028 len -= 8;
62
2/2
✓ Branch 0 taken 11686 times.
✓ Branch 1 taken 1342 times.
13028 } while (len > 0);
63 1342 }
64
65 45 av_cold void ff_audiodsp_init(AudioDSPContext *c)
66 {
67 45 c->scalarproduct_int16 = scalarproduct_int16_c;
68 45 c->vector_clip_int32 = vector_clip_int32_c;
69 45 c->vector_clipf = vector_clipf_c;
70
71 #if ARCH_ARM
72 ff_audiodsp_init_arm(c);
73 #elif ARCH_PPC
74 ff_audiodsp_init_ppc(c);
75 #elif ARCH_RISCV
76 ff_audiodsp_init_riscv(c);
77 #elif ARCH_X86 && HAVE_X86ASM
78 45 ff_audiodsp_init_x86(c);
79 #endif
80 45 }
81