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_96)[96];
48 DECLARE_ALIGNED(32, static float, sine_120)[120];
49 DECLARE_ALIGNED(32, static float, sine_768)[768];
50 DECLARE_ALIGNED(32, static float, sine_960)[960];
51 DECLARE_ALIGNED(32, static float, aac_kbd_long_960)[960];
52 DECLARE_ALIGNED(32, static float, aac_kbd_short_120)[120];
53 DECLARE_ALIGNED(32, static float, aac_kbd_long_768)[768];
54 DECLARE_ALIGNED(32, static float, aac_kbd_short_96)[96];
55 
56 static void init_tables_float_fn(void)
57 {
59 
62 
65 
69 
71 
73 }
74 
75 static const float cce_scale[] = {
76  1.09050773266525765921, //2^(1/8)
77  1.18920711500272106672, //2^(1/4)
78  M_SQRT2,
79  2,
80 };
81 
82 /** Dequantization-related **/
83 #include "aacdec_tab.h"
84 #include "libavutil/intfloat.h"
85 
86 #include "config.h"
87 #if ARCH_ARM
88 #include "libavcodec/arm/aac.h"
89 #endif
90 
91 #ifndef VMUL2
92 static inline float *VMUL2(float *dst, const float *v, unsigned idx,
93  const float *scale)
94 {
95  float s = *scale;
96  *dst++ = v[idx & 15] * s;
97  *dst++ = v[idx>>4 & 15] * s;
98  return dst;
99 }
100 #endif
101 
102 #ifndef VMUL4
103 static inline float *VMUL4(float *dst, const float *v, unsigned idx,
104  const float *scale)
105 {
106  float s = *scale;
107  *dst++ = v[idx & 3] * s;
108  *dst++ = v[idx>>2 & 3] * s;
109  *dst++ = v[idx>>4 & 3] * s;
110  *dst++ = v[idx>>6 & 3] * s;
111  return dst;
112 }
113 #endif
114 
115 #ifndef VMUL2S
116 static inline float *VMUL2S(float *dst, const float *v, unsigned idx,
117  unsigned sign, const float *scale)
118 {
119  union av_intfloat32 s0, s1;
120 
121  s0.f = s1.f = *scale;
122  s0.i ^= sign >> 1 << 31;
123  s1.i ^= sign << 31;
124 
125  *dst++ = v[idx & 15] * s0.f;
126  *dst++ = v[idx>>4 & 15] * s1.f;
127 
128  return dst;
129 }
130 #endif
131 
132 #ifndef VMUL4S
133 static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
134  unsigned sign, const float *scale)
135 {
136  unsigned nz = idx >> 12;
137  union av_intfloat32 s = { .f = *scale };
138  union av_intfloat32 t;
139 
140  t.i = s.i ^ (sign & 1U<<31);
141  *dst++ = v[idx & 3] * t.f;
142 
143  sign <<= nz & 1; nz >>= 1;
144  t.i = s.i ^ (sign & 1U<<31);
145  *dst++ = v[idx>>2 & 3] * t.f;
146 
147  sign <<= nz & 1; nz >>= 1;
148  t.i = s.i ^ (sign & 1U<<31);
149  *dst++ = v[idx>>4 & 3] * t.f;
150 
151  sign <<= nz & 1;
152  t.i = s.i ^ (sign & 1U<<31);
153  *dst++ = v[idx>>6 & 3] * t.f;
154 
155  return dst;
156 }
157 #endif
158 
159 #include "aacdec_float_coupling.h"
160 #include "aacdec_float_prediction.h"
161 #include "aacdec_dsp_template.c"
162 #include "aacdec_proc_template.c"
163 
165 {
166  static AVOnce init_float_once = AV_ONCE_INIT;
167  AACDecContext *ac = avctx->priv_data;
168 
169  ac->is_fixed = 0;
171 
172  aac_dsp_init(&ac->dsp);
173  aac_proc_init(&ac->proc);
174 
176  if (!ac->fdsp)
177  return AVERROR(ENOMEM);
178 
179  ff_thread_once(&init_float_once, init_tables_float_fn);
180 
181  return ff_aac_decode_init(avctx);
182 }
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:48
VMUL2
static float * VMUL2(float *dst, const float *v, unsigned idx, const float *scale)
Dequantization-related.
Definition: aacdec_float.c:92
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:116
aacdec_dsp_template.c
mathematics.h
AACDecContext::proc
AACDecProc proc
Definition: aacdec.h:453
intfloat.h
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:508
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:1177
s
#define s(width, name)
Definition: cbs_vp9.c:198
VMUL4
static float * VMUL4(float *dst, const float *v, unsigned idx, const float *scale)
Definition: aacdec_float.c:103
kbdwin.h
AACDecContext::fdsp
AVFloatDSPContext * fdsp
Definition: aacdec.h:504
ff_aac_decode_init_float
av_cold int ff_aac_decode_init_float(AVCodecContext *avctx)
Definition: aacdec_float.c:164
AV_ONCE_INIT
#define AV_ONCE_INIT
Definition: thread.h:203
sine_960
static float sine_960[960]
Definition: aacdec_float.c:50
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:452
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem_internal.h:104
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
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:665
AVCodecContext::sample_fmt
enum AVSampleFormat sample_fmt
audio sample format
Definition: avcodec.h:1071
aac_kbd_long_960
static float aac_kbd_long_960[960]
Definition: aacdec_float.c:51
aacdec_float_coupling.h
aac_kbd_short_96
static float aac_kbd_short_96[96]
Definition: aacdec_float.c:54
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:133
AACDecContext::is_fixed
int is_fixed
Definition: aacdec.h:534
aac.h
ff_aac_kbd_long_1024
float ff_aac_kbd_long_1024[1024]
avcodec.h
sine_96
static float sine_96[96]
Definition: aacdec_float.c:47
sine_768
static float sine_768[768]
Definition: aacdec_float.c:49
U
#define U(x)
Definition: vpx_arith.h:37
aacdec.h
AACDecContext
main AAC decoding context
Definition: aacdec.h:448
aacdec_float_prediction.h
AVCodecContext
main external API structure.
Definition: avcodec.h:451
cce_scale
static const float cce_scale[]
Definition: aacdec_float.c:75
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
aac_kbd_long_768
static float aac_kbd_long_768[768]
Definition: aacdec_float.c:53
AV_CODEC_FLAG_BITEXACT
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
Definition: avcodec.h:342
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:478
init_tables_float_fn
static void init_tables_float_fn(void)
Definition: aacdec_float.c:56
avpriv_float_dsp_alloc
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
Definition: float_dsp.c:146
aac_defines.h
aac_kbd_short_120
static float aac_kbd_short_120[120]
Definition: aacdec_float.c:52