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 
37 
38 static inline void abs_pow34_v(float *out, const float *in, const int size)
39 {
40  for (int i = 0; i < size; i++) {
41  float a = fabsf(in[i]);
42  out[i] = sqrtf(a * sqrtf(a));
43  }
44 }
45 
46 static inline void quantize_bands(int *out, const float *in, const float *scaled,
47  int size, int is_signed, int maxval, const float Q34,
48  const float rounding)
49 {
50  for (int i = 0; i < size; i++) {
51  float qc = scaled[i] * Q34;
52  int tmp = (int)FFMIN(qc + rounding, (float)maxval);
53  if (is_signed && in[i] < 0.0f) {
54  tmp = -tmp;
55  }
56  out[i] = tmp;
57  }
58 }
59 
61 {
62  s->abs_pow34 = abs_pow34_v;
63  s->quant_bands = quantize_bands;
64 
65 #if ARCH_RISCV
67 #elif ARCH_X86
69 #endif
70 }
71 
72 #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:38
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
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:46
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:60