FFmpeg
Loading...
Searching...
No Matches
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
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"
45#include "libavcodec/aacsbr.h"
46
47DECLARE_ALIGNED(32, static float, sine_96)[96];
48DECLARE_ALIGNED(32, static float, sine_120)[120];
49DECLARE_ALIGNED(32, static float, sine_768)[768];
50DECLARE_ALIGNED(32, static float, sine_960)[960];
51DECLARE_ALIGNED(32, static float, aac_kbd_long_960)[960];
52DECLARE_ALIGNED(32, static float, aac_kbd_short_120)[120];
53DECLARE_ALIGNED(32, static float, aac_kbd_long_768)[768];
54DECLARE_ALIGNED(32, static float, aac_kbd_short_96)[96];
55
74
75static 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
92static 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
103static 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
116static 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
133static 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
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}
AAC decoder definitions and structures.
static av_cold void AAC_RENAME aac_dsp_init(AACDecDSP *aac_dsp)
static float * VMUL4S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
static float sine_768[768]
static float sine_120[120]
static float sine_96[96]
static float aac_kbd_short_120[120]
static float * VMUL2S(float *dst, const float *v, unsigned idx, unsigned sign, const float *scale)
static float aac_kbd_long_960[960]
static float aac_kbd_long_768[768]
av_cold int ff_aac_decode_init_float(AVCodecContext *avctx)
static float sine_960[960]
static float aac_kbd_short_96[96]
static float * VMUL2(float *dst, const float *v, unsigned idx, const float *scale)
Dequantization-related.
static void init_tables_float_fn(void)
static float * VMUL4(float *dst, const float *v, unsigned idx, const float *scale)
static const float cce_scale[]
static av_cold void AAC_RENAME aac_proc_init(AACDecProc *aac_proc)
AAC decoder data.
AAC Spectral Band Replication function declarations.
FF_VISIBILITY_PUSH_HIDDEN void ff_aac_sbr_init(void)
Initialize SBR.
AAC data declarations.
float ff_aac_kbd_long_1024[1024]
void ff_aac_float_common_init(void)
float ff_aac_kbd_short_128[128]
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
Libavcodec external API header.
#define ff_cbrt_tableinit()
Definition cbrt_data.h:35
#define s(width, name)
Definition cbs_vp9.c:198
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
Definition avcodec.h:322
#define AVERROR(e)
Definition error.h:45
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition samplefmt.h:66
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition intra.c:278
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
Generate a Kaiser-Bessel Derived Window.
Definition kbdwin.c:54
av_cold int ff_aac_decode_init(AVCodecContext *avctx)
Definition aacdec.c:1298
#define av_cold
Definition attributes.h:117
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
Definition float_dsp.c:135
#define AVOnce
Definition thread.h:202
static int ff_thread_once(char *control, void(*routine)(void))
Definition thread.h:205
#define AV_ONCE_INIT
Definition thread.h:203
#define M_SQRT2
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
void ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
void ff_sine_window_init(float *window, int n)
Generate a sine window.
main AAC decoding context
Definition aacdec.h:500
AACDecProc proc
Definition aacdec.h:505
AACDecDSP dsp
Definition aacdec.h:504
AVFloatDSPContext * fdsp
Definition aacdec.h:556
main external API structure.
Definition avcodec.h:443
enum AVSampleFormat sample_fmt
audio sample format
Definition avcodec.h:1047
int flags
AV_CODEC_FLAG_*.
Definition avcodec.h:500
void * priv_data
Definition avcodec.h:470
uint32_t i
Definition intfloat.h:28