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 
56  AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_long_1024), 4.0, 1024);
57  AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_short_128), 6.0, 128);
58 
61 
65 
67 }
68 
69 static int init(AACDecContext *ac)
70 {
71  static AVOnce init_float_once = AV_ONCE_INIT;
72  ff_thread_once(&init_float_once, init_tables_float_fn);
73 
75  if (!ac->fdsp)
76  return AVERROR(ENOMEM);
77 
79 
80  return 0;
81 }
82 
83 static const float cce_scale[] = {
84  1.09050773266525765921, //2^(1/8)
85  1.18920711500272106672, //2^(1/4)
86  M_SQRT2,
87  2,
88 };
89 
90 /** Dequantization-related **/
91 #include "aacdec_tab.h"
92 #include "libavutil/intfloat.h"
93 
94 #ifndef VMUL2
95 static inline float *VMUL2(float *dst, const float *v, unsigned idx,
96  const float *scale)
97 {
98  float s = *scale;
99  *dst++ = v[idx & 15] * s;
100  *dst++ = v[idx>>4 & 15] * s;
101  return dst;
102 }
103 #endif
104 
105 #ifndef VMUL4
106 static inline float *VMUL4(float *dst, const float *v, unsigned idx,
107  const float *scale)
108 {
109  float s = *scale;
110  *dst++ = v[idx & 3] * s;
111  *dst++ = v[idx>>2 & 3] * s;
112  *dst++ = v[idx>>4 & 3] * s;
113  *dst++ = v[idx>>6 & 3] * s;
114  return dst;
115 }
116 #endif
117 
118 #ifndef VMUL2S
119 static inline float *VMUL2S(float *dst, const float *v, unsigned idx,
120  unsigned sign, const float *scale)
121 {
122  union av_intfloat32 s0, s1;
123 
124  s0.f = s1.f = *scale;
125  s0.i ^= sign >> 1 << 31;
126  s1.i ^= sign << 31;
127 
128  *dst++ = v[idx & 15] * s0.f;
129  *dst++ = v[idx>>4 & 15] * s1.f;
130 
131  return dst;
132 }
133 #endif
134 
135 #ifndef VMUL4S
136 static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
137  unsigned sign, const float *scale)
138 {
139  unsigned nz = idx >> 12;
140  union av_intfloat32 s = { .f = *scale };
141  union av_intfloat32 t;
142 
143  t.i = s.i ^ (sign & 1U<<31);
144  *dst++ = v[idx & 3] * t.f;
145 
146  sign <<= nz & 1; nz >>= 1;
147  t.i = s.i ^ (sign & 1U<<31);
148  *dst++ = v[idx>>2 & 3] * t.f;
149 
150  sign <<= nz & 1; nz >>= 1;
151  t.i = s.i ^ (sign & 1U<<31);
152  *dst++ = v[idx>>4 & 3] * t.f;
153 
154  sign <<= nz & 1;
155  t.i = s.i ^ (sign & 1U<<31);
156  *dst++ = v[idx>>6 & 3] * t.f;
157 
158  return dst;
159 }
160 #endif
161 
162 #include "aacdec_float_coupling.h"
163 #include "aacdec_float_prediction.h"
164 #include "aacdec_dsp_template.c"
165 #include "aacdec_proc_template.c"
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
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:95
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:119
aacdec_dsp_template.c
mathematics.h
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
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:106
kbdwin.h
AACDecContext::fdsp
AVFloatDSPContext * fdsp
Definition: aacdec.h:305
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
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_kbd_long_960
static float aac_kbd_long_960[960]
Definition: aacdec_float.c:49
AAC_RENAME2
#define AAC_RENAME2(x)
Definition: aac_defines.h:100
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:136
AAC_RENAME
#define AAC_RENAME(x)
Definition: aac_defines.h:99
avcodec.h
U
#define U(x)
Definition: vpx_arith.h:37
aacdec.h
AACDecContext
main AAC decoding context
Definition: aacdec.h:253
aacdec_float_prediction.h
cce_scale
static const float cce_scale[]
Definition: aacdec_float.c:83
AACDecContext::avctx
struct AVCodecContext * avctx
Definition: aacdec.h:255
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
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
init
static int init(AACDecContext *ac)
Definition: aacdec_float.c:69
aac_kbd_short_120
static float aac_kbd_short_120[120]
Definition: aacdec_float.c:50