FFmpeg
aacencdsp.h
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 #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);
34 
38 
39 static inline void abs_pow34_v(float *out, const float *in, const int size)
40 {
41  for (int i = 0; i < size; i++) {
42  float a = fabsf(in[i]);
43  out[i] = sqrtf(a * sqrtf(a));
44  }
45 }
46 
47 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  for (int i = 0; i < size; i++) {
52  float qc = scaled[i] * Q34;
53  int tmp = (int)FFMIN(qc + rounding, (float)maxval);
54  if (is_signed && in[i] < 0.0f) {
55  tmp = -tmp;
56  }
57  out[i] = tmp;
58  }
59 }
60 
62 {
63  s->abs_pow34 = abs_pow34_v;
64  s->quant_bands = quantize_bands;
65 
66 #if ARCH_RISCV
68 #elif ARCH_X86
70 #elif ARCH_AARCH64
72 #endif
73 }
74 
75 #endif
ff_aacenc_dsp_init_riscv
void ff_aacenc_dsp_init_riscv(AACEncDSPContext *s)
Definition: aacencdsp_init.c:32
out
FILE * out
Definition: movenc.c:55
AACEncDSPContext
Definition: aacencdsp.h:28
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
abs_pow34_v
static void abs_pow34_v(float *out, const float *in, const int size)
Definition: aacencdsp.h:39
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
AACEncDSPContext::quant_bands
void(* quant_bands)(int *out, const float *in, const float *scaled, int size, int is_signed, int maxval, const float Q34, const float rounding)
Definition: aacencdsp.h:30
AACEncDSPContext::abs_pow34
void(* abs_pow34)(float *out, const float *in, const int size)
Definition: aacencdsp.h:29
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.h:47
sqrtf
static __device__ float sqrtf(float a)
Definition: cuda_runtime.h:184
f
f
Definition: af_crystalizer.c:122
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
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
ff_aacenc_dsp_init
static void ff_aacenc_dsp_init(AACEncDSPContext *s)
Definition: aacencdsp.h:61