FFmpeg
aacencdsp.c
Go to the documentation of this file.
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 static void abs_pow34_v(float *out, const float *in, const int size)
27 {
28  for (int i = 0; i < size; i++) {
29  float a = fabsf(in[i]);
30  out[i] = sqrtf(a * sqrtf(a));
31  }
32 }
33 
34 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  for (int i = 0; i < size; i++) {
39  float qc = scaled[i] * Q34;
40  int tmp = (int)FFMIN((float)(qc + rounding), (float)maxval);
41  if (is_signed && in[i] < 0.0f) {
42  tmp = -tmp;
43  }
44  out[i] = tmp;
45  }
46 }
47 
49 {
50  s->abs_pow34 = abs_pow34_v;
51  s->quant_bands = quantize_bands;
52 
53 #if ARCH_RISCV
55 #elif ARCH_X86 && HAVE_X86ASM
57 #elif ARCH_AARCH64
59 #endif
60 }
ff_aacenc_dsp_init_riscv
void ff_aacenc_dsp_init_riscv(AACEncDSPContext *s)
Definition: aacencdsp_init.c:32
out
static FILE * out
Definition: movenc.c:55
AACEncDSPContext
Definition: aacencdsp.h:22
macros.h
fabsf
static __device__ float fabsf(float a)
Definition: cuda_runtime.h:181
s
#define s(width, name)
Definition: cbs_vp9.c:198
ff_aacenc_dsp_init_x86
void ff_aacenc_dsp_init_x86(AACEncDSPContext *s)
Definition: aacencdsp_init.c:37
ff_aacenc_dsp_init_aarch64
void ff_aacenc_dsp_init_aarch64(AACEncDSPContext *s)
Definition: aacencdsp_init.c:31
tmp
static uint8_t tmp[40]
Definition: aes_ctr.c:52
abs_pow34_v
static void abs_pow34_v(float *out, const float *in, const int size)
Definition: aacencdsp.c:26
sqrtf
static __device__ float sqrtf(float a)
Definition: cuda_runtime.h:184
f
f
Definition: af_crystalizer.c:122
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
size
int size
Definition: twinvq_data.h:10344
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
quantize_bands
static void quantize_bands(int *out, const float *in, const float *scaled, int size, int is_signed, int maxval, const float Q34, const float rounding)
Definition: aacencdsp.c:34
aacencdsp.h
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
ff_aacenc_dsp_init
void ff_aacenc_dsp_init(AACEncDSPContext *s)
Definition: aacencdsp.c:48