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 | void ff_aacenc_dsp_init_aarch64(AACEncDSPContext *s); | ||
38 | |||
39 | 576213 | static inline void abs_pow34_v(float *out, const float *in, const int size) | |
40 | { | ||
41 |
2/2✓ Branch 0 taken 32186924 times.
✓ Branch 1 taken 576213 times.
|
32763137 | for (int i = 0; i < size; i++) { |
42 | 32186924 | float a = fabsf(in[i]); | |
43 | 32186924 | out[i] = sqrtf(a * sqrtf(a)); | |
44 | } | ||
45 | 576213 | } | |
46 | |||
47 | 6862076 | static inline void quantize_bands(int *out, const float *in, const float *scaled, | |
48 | int size, int is_signed, int maxval, const float Q34, | ||
49 | const float rounding) | ||
50 | { | ||
51 |
2/2✓ Branch 0 taken 140015912 times.
✓ Branch 1 taken 6862076 times.
|
146877988 | for (int i = 0; i < size; i++) { |
52 | 140015912 | float qc = scaled[i] * Q34; | |
53 |
2/2✓ Branch 0 taken 14550256 times.
✓ Branch 1 taken 125465656 times.
|
140015912 | int tmp = (int)FFMIN(qc + rounding, (float)maxval); |
54 |
4/4✓ Branch 0 taken 57762776 times.
✓ Branch 1 taken 82253136 times.
✓ Branch 2 taken 28697436 times.
✓ Branch 3 taken 29065340 times.
|
140015912 | if (is_signed && in[i] < 0.0f) { |
55 | 28697436 | tmp = -tmp; | |
56 | } | ||
57 | 140015912 | out[i] = tmp; | |
58 | } | ||
59 | 6862076 | } | |
60 | |||
61 | 23 | static inline void ff_aacenc_dsp_init(AACEncDSPContext *s) | |
62 | { | ||
63 | 23 | s->abs_pow34 = abs_pow34_v; | |
64 | 23 | s->quant_bands = quantize_bands; | |
65 | |||
66 | #if ARCH_RISCV | ||
67 | ff_aacenc_dsp_init_riscv(s); | ||
68 | #elif ARCH_X86 | ||
69 | 23 | ff_aacenc_dsp_init_x86(s); | |
70 | #elif ARCH_AARCH64 | ||
71 | ff_aacenc_dsp_init_aarch64(s); | ||
72 | #endif | ||
73 | 23 | } | |
74 | |||
75 | #endif | ||
76 |