| 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 <math.h> | ||
| 20 | |||
| 21 | #include "config.h" | ||
| 22 | |||
| 23 | #include "libavutil/macros.h" | ||
| 24 | #include "aacencdsp.h" | ||
| 25 | |||
| 26 | 576312 | static void abs_pow34_v(float *out, const float *in, const int size) | |
| 27 | { | ||
| 28 |
2/2✓ Branch 0 taken 32203032 times.
✓ Branch 1 taken 576312 times.
|
32779344 | for (int i = 0; i < size; i++) { |
| 29 | 32203032 | float a = fabsf(in[i]); | |
| 30 | 32203032 | out[i] = sqrtf(a * sqrtf(a)); | |
| 31 | } | ||
| 32 | 576312 | } | |
| 33 | |||
| 34 | 6968528 | static void quantize_bands(int *out, const float *in, const float *scaled, | |
| 35 | int size, int is_signed, int maxval, const float Q34, | ||
| 36 | const float rounding) | ||
| 37 | { | ||
| 38 |
2/2✓ Branch 0 taken 142709304 times.
✓ Branch 1 taken 6968528 times.
|
149677832 | for (int i = 0; i < size; i++) { |
| 39 | 142709304 | float qc = scaled[i] * Q34; | |
| 40 |
2/2✓ Branch 0 taken 14863268 times.
✓ Branch 1 taken 127846036 times.
|
142709304 | int tmp = (int)FFMIN((float)(qc + rounding), (float)maxval); |
| 41 |
4/4✓ Branch 0 taken 58675508 times.
✓ Branch 1 taken 84033796 times.
✓ Branch 2 taken 29171284 times.
✓ Branch 3 taken 29504224 times.
|
142709304 | if (is_signed && in[i] < 0.0f) { |
| 42 | 29171284 | tmp = -tmp; | |
| 43 | } | ||
| 44 | 142709304 | out[i] = tmp; | |
| 45 | } | ||
| 46 | 6968528 | } | |
| 47 | |||
| 48 | 25 | void ff_aacenc_dsp_init(AACEncDSPContext *s) | |
| 49 | { | ||
| 50 | 25 | s->abs_pow34 = abs_pow34_v; | |
| 51 | 25 | s->quant_bands = quantize_bands; | |
| 52 | |||
| 53 | #if ARCH_RISCV | ||
| 54 | ff_aacenc_dsp_init_riscv(s); | ||
| 55 | #elif ARCH_X86 && HAVE_X86ASM | ||
| 56 | 25 | ff_aacenc_dsp_init_x86(s); | |
| 57 | #elif ARCH_AARCH64 | ||
| 58 | ff_aacenc_dsp_init_aarch64(s); | ||
| 59 | #endif | ||
| 60 | 25 | } | |
| 61 |