/src/ffmpeg/libavcodec/aac/aacdec_float.c
Line | Count | Source |
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 | 1.66M | #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 | 2 | { |
58 | 2 | ff_cbrt_tableinit(); |
59 | | |
60 | 2 | ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); |
61 | 2 | ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128); |
62 | | |
63 | 2 | ff_kbd_window_init(aac_kbd_long_960, 4.0, 960); |
64 | 2 | ff_kbd_window_init(aac_kbd_short_120, 6.0, 120); |
65 | | |
66 | 2 | ff_sine_window_init(sine_960, 960); |
67 | 2 | ff_sine_window_init(sine_120, 120); |
68 | 2 | ff_init_ff_sine_windows(9); |
69 | | |
70 | 2 | ff_aac_sbr_init(); |
71 | | |
72 | 2 | ff_aac_float_common_init(); |
73 | 2 | } |
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 | 247k | { |
95 | 247k | float s = *scale; |
96 | 247k | *dst++ = v[idx & 15] * s; |
97 | 247k | *dst++ = v[idx>>4 & 15] * s; |
98 | 247k | return dst; |
99 | 247k | } |
100 | | #endif |
101 | | |
102 | | #ifndef VMUL4 |
103 | | static inline float *VMUL4(float *dst, const float *v, unsigned idx, |
104 | | const float *scale) |
105 | 186k | { |
106 | 186k | float s = *scale; |
107 | 186k | *dst++ = v[idx & 3] * s; |
108 | 186k | *dst++ = v[idx>>2 & 3] * s; |
109 | 186k | *dst++ = v[idx>>4 & 3] * s; |
110 | 186k | *dst++ = v[idx>>6 & 3] * s; |
111 | 186k | return dst; |
112 | 186k | } |
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 | 2.22M | { |
119 | 2.22M | union av_intfloat32 s0, s1; |
120 | | |
121 | 2.22M | s0.f = s1.f = *scale; |
122 | 2.22M | s0.i ^= sign >> 1 << 31; |
123 | 2.22M | s1.i ^= sign << 31; |
124 | | |
125 | 2.22M | *dst++ = v[idx & 15] * s0.f; |
126 | 2.22M | *dst++ = v[idx>>4 & 15] * s1.f; |
127 | | |
128 | 2.22M | return dst; |
129 | 2.22M | } |
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 | 118k | { |
136 | 118k | unsigned nz = idx >> 12; |
137 | 118k | union av_intfloat32 s = { .f = *scale }; |
138 | 118k | union av_intfloat32 t; |
139 | | |
140 | 118k | t.i = s.i ^ (sign & 1U<<31); |
141 | 118k | *dst++ = v[idx & 3] * t.f; |
142 | | |
143 | 118k | sign <<= nz & 1; nz >>= 1; |
144 | 118k | t.i = s.i ^ (sign & 1U<<31); |
145 | 118k | *dst++ = v[idx>>2 & 3] * t.f; |
146 | | |
147 | 118k | sign <<= nz & 1; nz >>= 1; |
148 | 118k | t.i = s.i ^ (sign & 1U<<31); |
149 | 118k | *dst++ = v[idx>>4 & 3] * t.f; |
150 | | |
151 | 118k | sign <<= nz & 1; |
152 | 118k | t.i = s.i ^ (sign & 1U<<31); |
153 | 118k | *dst++ = v[idx>>6 & 3] * t.f; |
154 | | |
155 | 118k | return dst; |
156 | 118k | } |
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 | | |
164 | | av_cold int ff_aac_decode_init_float(AVCodecContext *avctx) |
165 | 14.5k | { |
166 | 14.5k | static AVOnce init_float_once = AV_ONCE_INIT; |
167 | 14.5k | AACDecContext *ac = avctx->priv_data; |
168 | | |
169 | 14.5k | ac->is_fixed = 0; |
170 | 14.5k | avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; |
171 | | |
172 | 14.5k | aac_dsp_init(&ac->dsp); |
173 | 14.5k | aac_proc_init(&ac->proc); |
174 | | |
175 | 14.5k | ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); |
176 | 14.5k | if (!ac->fdsp) |
177 | 0 | return AVERROR(ENOMEM); |
178 | | |
179 | 14.5k | ff_thread_once(&init_float_once, init_tables_float_fn); |
180 | | |
181 | 14.5k | return ff_aac_decode_init(avctx); |
182 | 14.5k | } |