FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/aacencdsp.h
Date: 2024-04-19 17:50:32
Exec Total Coverage
Lines: 18 18 100.0%
Functions: 3 3 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 #ifndef AVCODEC_AACENCDSP_H
20 #define AVCODEC_AACENCDSP_H
21
22 #include <math.h>
23
24 #include "config.h"
25
26 #include "libavutil/macros.h"
27
28 typedef struct AACEncDSPContext {
29 void (*abs_pow34)(float *out, const float *in, const int size);
30 void (*quant_bands)(int *out, const float *in, const float *scaled,
31 int size, int is_signed, int maxval, const float Q34,
32 const float rounding);
33 } AACEncDSPContext;
34
35 void ff_aacenc_dsp_init_riscv(AACEncDSPContext *s);
36 void ff_aacenc_dsp_init_x86(AACEncDSPContext *s);
37
38 700658 static inline void abs_pow34_v(float *out, const float *in, const int size)
39 {
40
2/2
✓ Branch 0 taken 36497400 times.
✓ Branch 1 taken 700658 times.
37198058 for (int i = 0; i < size; i++) {
41 36497400 float a = fabsf(in[i]);
42 36497400 out[i] = sqrtf(a * sqrtf(a));
43 }
44 700658 }
45
46 7557065 static inline void quantize_bands(int *out, const float *in, const float *scaled,
47 int size, int is_signed, int maxval, const float Q34,
48 const float rounding)
49 {
50
2/2
✓ Branch 0 taken 154649036 times.
✓ Branch 1 taken 7557065 times.
162206101 for (int i = 0; i < size; i++) {
51 154649036 float qc = scaled[i] * Q34;
52
2/2
✓ Branch 0 taken 15789745 times.
✓ Branch 1 taken 138859291 times.
154649036 int tmp = (int)FFMIN(qc + rounding, (float)maxval);
53
4/4
✓ Branch 0 taken 65026328 times.
✓ Branch 1 taken 89622708 times.
✓ Branch 2 taken 32324013 times.
✓ Branch 3 taken 32702315 times.
154649036 if (is_signed && in[i] < 0.0f) {
54 32324013 tmp = -tmp;
55 }
56 154649036 out[i] = tmp;
57 }
58 7557065 }
59
60 24 static inline void ff_aacenc_dsp_init(AACEncDSPContext *s)
61 {
62 24 s->abs_pow34 = abs_pow34_v;
63 24 s->quant_bands = quantize_bands;
64
65 #if ARCH_RISCV
66 ff_aacenc_dsp_init_riscv(s);
67 #elif ARCH_X86
68 24 ff_aacenc_dsp_init_x86(s);
69 #endif
70 24 }
71
72 #endif
73