| 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 | 575385 | static inline void abs_pow34_v(float *out, const float *in, const int size) | |
| 40 | { | ||
| 41 |
2/2✓ Branch 0 taken 32069300 times.
✓ Branch 1 taken 575385 times.
|
32644685 | for (int i = 0; i < size; i++) { |
| 42 | 32069300 | float a = fabsf(in[i]); | |
| 43 | 32069300 | out[i] = sqrtf(a * sqrtf(a)); | |
| 44 | } | ||
| 45 | 575385 | } | |
| 46 | |||
| 47 | 6871253 | 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 140788080 times.
✓ Branch 1 taken 6871253 times.
|
147659333 | for (int i = 0; i < size; i++) { |
| 52 | 140788080 | float qc = scaled[i] * Q34; | |
| 53 |
2/2✓ Branch 0 taken 14738255 times.
✓ Branch 1 taken 126049825 times.
|
140788080 | int tmp = (int)FFMIN((float)(qc + rounding), (float)maxval); |
| 54 |
4/4✓ Branch 0 taken 57923928 times.
✓ Branch 1 taken 82864152 times.
✓ Branch 2 taken 28789102 times.
✓ Branch 3 taken 29134826 times.
|
140788080 | if (is_signed && in[i] < 0.0f) { |
| 55 | 28789102 | tmp = -tmp; | |
| 56 | } | ||
| 57 | 140788080 | out[i] = tmp; | |
| 58 | } | ||
| 59 | 6871253 | } | |
| 60 | |||
| 61 | 24 | static inline void ff_aacenc_dsp_init(AACEncDSPContext *s) | |
| 62 | { | ||
| 63 | 24 | s->abs_pow34 = abs_pow34_v; | |
| 64 | 24 | s->quant_bands = quantize_bands; | |
| 65 | |||
| 66 | #if ARCH_RISCV | ||
| 67 | ff_aacenc_dsp_init_riscv(s); | ||
| 68 | #elif ARCH_X86 && HAVE_X86ASM | ||
| 69 | 24 | ff_aacenc_dsp_init_x86(s); | |
| 70 | #elif ARCH_AARCH64 | ||
| 71 | ff_aacenc_dsp_init_aarch64(s); | ||
| 72 | #endif | ||
| 73 | 24 | } | |
| 74 | |||
| 75 | #endif | ||
| 76 |