FFmpeg
aacdec_float.c
Go to the documentation of this file.
1 /*
2  * AAC decoder
3  * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
4  * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
5  * Copyright (c) 2008-2013 Alex Converse <alex.converse@gmail.com>
6  *
7  * AAC LATM decoder
8  * Copyright (c) 2008-2010 Paul Kendall <paul@kcbbs.gen.nz>
9  * Copyright (c) 2010 Janne Grunau <janne-libav@jannau.net>
10  *
11  * AAC decoder fixed-point implementation
12  * Copyright (c) 2013
13  * MIPS Technologies, Inc., California.
14  *
15  * This file is part of FFmpeg.
16  *
17  * FFmpeg is free software; you can redistribute it and/or
18  * modify it under the terms of the GNU Lesser General Public
19  * License as published by the Free Software Foundation; either
20  * version 2.1 of the License, or (at your option) any later version.
21  *
22  * FFmpeg is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25  * Lesser General Public License for more details.
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with FFmpeg; if not, write to the Free Software
29  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30  */
31 
32 #define USE_FIXED 0
33 
34 #include "libavutil/thread.h"
35 
36 #include "libavcodec/aac_defines.h"
37 
38 #include "libavcodec/avcodec.h"
39 #include "aacdec.h"
40 #include "libavcodec/aactab.h"
41 #include "libavcodec/sinewin.h"
42 #include "libavcodec/kbdwin.h"
43 #include "libavcodec/cbrt_data.h"
44 #include "libavutil/mathematics.h"
45 #include "libavcodec/aacsbr.h"
46 
47 DECLARE_ALIGNED(32, static float, sine_120)[120];
48 DECLARE_ALIGNED(32, static float, sine_960)[960];
49 DECLARE_ALIGNED(32, static float, aac_kbd_long_960)[960];
50 DECLARE_ALIGNED(32, static float, aac_kbd_short_120)[120];
51 
52 static void init_tables_float_fn(void)
53 {
55 
58 
61 
65 
67 
69 }
70 
71 static const float cce_scale[] = {
72  1.09050773266525765921, //2^(1/8)
73  1.18920711500272106672, //2^(1/4)
74  M_SQRT2,
75  2,
76 };
77 
78 /** Dequantization-related **/
79 #include "aacdec_tab.h"
80 #include "libavutil/intfloat.h"
81 
82 #ifndef VMUL2
83 static inline float *VMUL2(float *dst, const float *v, unsigned idx,
84  const float *scale)
85 {
86  float s = *scale;
87  *dst++ = v[idx & 15] * s;
88  *dst++ = v[idx>>4 & 15] * s;
89  return dst;
90 }
91 #endif
92 
93 #ifndef VMUL4
94 static inline float *VMUL4(float *dst, const float *v, unsigned idx,
95  const float *scale)
96 {
97  float s = *scale;
98  *dst++ = v[idx & 3] * s;
99  *dst++ = v[idx>>2 & 3] * s;
100  *dst++ = v[idx>>4 & 3] * s;
101  *dst++ = v[idx>>6 & 3] * s;
102  return dst;
103 }
104 #endif
105 
106 #ifndef VMUL2S
107 static inline float *VMUL2S(float *dst, const float *v, unsigned idx,
108  unsigned sign, const float *scale)
109 {
110  union av_intfloat32 s0, s1;
111 
112  s0.f = s1.f = *scale;
113  s0.i ^= sign >> 1 << 31;
114  s1.i ^= sign << 31;
115 
116  *dst++ = v[idx & 15] * s0.f;
117  *dst++ = v[idx>>4 & 15] * s1.f;
118 
119  return dst;
120 }
121 #endif
122 
123 #ifndef VMUL4S
124 static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
125  unsigned sign, const float *scale)
126 {
127  unsigned nz = idx >> 12;
128  union av_intfloat32 s = { .f = *scale };
129  union av_intfloat32 t;
130 
131  t.i = s.i ^ (sign & 1U<<31);
132  *dst++ = v[idx & 3] * t.f;
133 
134  sign <<= nz & 1; nz >>= 1;
135  t.i = s.i ^ (sign & 1U<<31);
136  *dst++ = v[idx>>2 & 3] * t.f;
137 
138  sign <<= nz & 1; nz >>= 1;
139  t.i = s.i ^ (sign & 1U<<31);
140  *dst++ = v[idx>>4 & 3] * t.f;
141 
142  sign <<= nz & 1;
143  t.i = s.i ^ (sign & 1U<<31);
144  *dst++ = v[idx>>6 & 3] * t.f;
145 
146  return dst;
147 }
148 #endif
149 
150 #include "aacdec_float_coupling.h"
151 #include "aacdec_float_prediction.h"
152 #include "aacdec_dsp_template.c"
153 #include "aacdec_proc_template.c"
154 
156 {
157  static AVOnce init_float_once = AV_ONCE_INIT;
158  AACDecContext *ac = avctx->priv_data;
159 
160  ac->is_fixed = 0;
162 
163  aac_dsp_init(&ac->dsp);
164  aac_proc_init(&ac->proc);
165 
167  if (!ac->fdsp)
168  return AVERROR(ENOMEM);
169 
170  ff_thread_once(&init_float_once, init_tables_float_fn);
171 
172  return ff_aac_decode_init(avctx);
173 }
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
ff_aac_kbd_short_128
float ff_aac_kbd_short_128[128]
sine_120
static float sine_120[120]
Definition: aacdec_float.c:47
VMUL2
static float * VMUL2(float *dst, const float *v, unsigned idx, const float *scale)
Dequantization-related.
Definition: aacdec_float.c:83
aac_proc_init
static av_cold void AAC_RENAME() aac_proc_init(AACDecProc *aac_proc)
Definition: aacdec_proc_template.c:436
thread.h
ff_cbrt_tableinit
void ff_cbrt_tableinit(void)
Definition: cbrt_tablegen.h:40
aacsbr.h
av_intfloat32::i
uint32_t i
Definition: intfloat.h:28
VMUL2S
static float * VMUL2S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
Definition: aacdec_float.c:107
aacdec_dsp_template.c
mathematics.h
AACDecContext::proc
AACDecProc proc
Definition: aacdec.h:263
intfloat.h
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:502
aacdec_proc_template.c
ff_thread_once
static int ff_thread_once(char *control, void(*routine)(void))
Definition: thread.h:205
av_cold
#define av_cold
Definition: attributes.h:90
ff_aac_decode_init
av_cold int ff_aac_decode_init(AVCodecContext *avctx)
Definition: aacdec.c:1170
s
#define s(width, name)
Definition: cbs_vp9.c:198
s1
#define s1
Definition: regdef.h:38
VMUL4
static float * VMUL4(float *dst, const float *v, unsigned idx, const float *scale)
Definition: aacdec_float.c:94
kbdwin.h
AACDecContext::fdsp
AVFloatDSPContext * fdsp
Definition: aacdec.h:310
ff_aac_decode_init_float
av_cold int ff_aac_decode_init_float(AVCodecContext *avctx)
Definition: aacdec_float.c:155
AV_ONCE_INIT
#define AV_ONCE_INIT
Definition: thread.h:203
sine_960
static float sine_960[960]
Definition: aacdec_float.c:48
ff_aac_sbr_init
FF_VISIBILITY_PUSH_HIDDEN void ff_aac_sbr_init(void)
Initialize SBR.
Definition: aacsbr_template.c:52
aactab.h
av_intfloat32
Definition: intfloat.h:27
AVOnce
#define AVOnce
Definition: thread.h:202
AACDecContext::dsp
AACDecDSP dsp
Definition: aacdec.h:262
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem_internal.h:109
ff_aac_float_common_init
void ff_aac_float_common_init(void)
aac_dsp_init
static av_cold void AAC_RENAME() aac_dsp_init(AACDecDSP *aac_dsp)
Definition: aacdec_dsp_template.c:618
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1057
aac_kbd_long_960
static float aac_kbd_long_960[960]
Definition: aacdec_float.c:49
aacdec_float_coupling.h
sinewin.h
ff_sine_window_init
void ff_sine_window_init(float *window, int n)
Generate a sine window.
Definition: sinewin_tablegen.h:59
cbrt_data.h
VMUL4S
static float * VMUL4S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
Definition: aacdec_float.c:124
AACDecContext::is_fixed
int is_fixed
Definition: aacdec.h:340
ff_aac_kbd_long_1024
float ff_aac_kbd_long_1024[1024]
avcodec.h
U
#define U(x)
Definition: vpx_arith.h:37
aacdec.h
AACDecContext
main AAC decoding context
Definition: aacdec.h:258
aacdec_float_prediction.h
AVCodecContext
main external API structure.
Definition: avcodec.h:445
cce_scale
static const float cce_scale[]
Definition: aacdec_float.c:71
aacdec_tab.h
ff_init_ff_sine_windows
void ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
Definition: sinewin_tablegen.h:101
ff_kbd_window_init
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
Generate a Kaiser-Bessel Derived Window.
Definition: kbdwin.c:54
av_intfloat32::f
float f
Definition: intfloat.h:29
AV_CODEC_FLAG_BITEXACT
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
Definition: avcodec.h:342
s0
#define s0
Definition: regdef.h:37
M_SQRT2
#define M_SQRT2
Definition: mathematics.h:109
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:291
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:472
init_tables_float_fn
static void init_tables_float_fn(void)
Definition: aacdec_float.c:52
avpriv_float_dsp_alloc
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
Definition: float_dsp.c:135
aac_defines.h
aac_kbd_short_120
static float aac_kbd_short_120[120]
Definition: aacdec_float.c:50