Line | Branch | Exec | 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 | #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 | 161 | static void init_tables_float_fn(void) | |
53 | { | ||
54 | 161 | AAC_RENAME(ff_cbrt_tableinit)(); | |
55 | |||
56 | 161 | AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_long_1024), 4.0, 1024); | |
57 | 161 | AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_short_128), 6.0, 128); | |
58 | |||
59 | 161 | AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_long_960), 4.0, 960); | |
60 | 161 | AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_short_120), 6.0, 120); | |
61 | |||
62 | 161 | AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_960), 960); | |
63 | 161 | AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_120), 120); | |
64 | 161 | AAC_RENAME(ff_init_ff_sine_windows)(9); | |
65 | |||
66 | 161 | AAC_RENAME(ff_aac_sbr_init)(); | |
67 | 161 | } | |
68 | |||
69 | 268 | static int init(AACDecContext *ac) | |
70 | { | ||
71 | static AVOnce init_float_once = AV_ONCE_INIT; | ||
72 | 268 | ff_thread_once(&init_float_once, init_tables_float_fn); | |
73 | |||
74 | 268 | ac->fdsp = avpriv_float_dsp_alloc(ac->avctx->flags & AV_CODEC_FLAG_BITEXACT); | |
75 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
|
268 | if (!ac->fdsp) |
76 | ✗ | return AVERROR(ENOMEM); | |
77 | |||
78 | 268 | ff_aac_float_common_init(); | |
79 | |||
80 | 268 | 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 | 1815116 | static inline float *VMUL2(float *dst, const float *v, unsigned idx, | |
96 | const float *scale) | ||
97 | { | ||
98 | 1815116 | float s = *scale; | |
99 | 1815116 | *dst++ = v[idx & 15] * s; | |
100 | 1815116 | *dst++ = v[idx>>4 & 15] * s; | |
101 | 1815116 | return dst; | |
102 | } | ||
103 | #endif | ||
104 | |||
105 | #ifndef VMUL4 | ||
106 | 2273024 | static inline float *VMUL4(float *dst, const float *v, unsigned idx, | |
107 | const float *scale) | ||
108 | { | ||
109 | 2273024 | float s = *scale; | |
110 | 2273024 | *dst++ = v[idx & 3] * s; | |
111 | 2273024 | *dst++ = v[idx>>2 & 3] * s; | |
112 | 2273024 | *dst++ = v[idx>>4 & 3] * s; | |
113 | 2273024 | *dst++ = v[idx>>6 & 3] * s; | |
114 | 2273024 | return dst; | |
115 | } | ||
116 | #endif | ||
117 | |||
118 | #ifndef VMUL2S | ||
119 | 2274420 | 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 | 2274420 | s0.f = s1.f = *scale; | |
125 | 2274420 | s0.i ^= sign >> 1 << 31; | |
126 | 2274420 | s1.i ^= sign << 31; | |
127 | |||
128 | 2274420 | *dst++ = v[idx & 15] * s0.f; | |
129 | 2274420 | *dst++ = v[idx>>4 & 15] * s1.f; | |
130 | |||
131 | 2274420 | return dst; | |
132 | } | ||
133 | #endif | ||
134 | |||
135 | #ifndef VMUL4S | ||
136 | 1809834 | static inline float *VMUL4S(float *dst, const float *v, unsigned idx, | |
137 | unsigned sign, const float *scale) | ||
138 | { | ||
139 | 1809834 | unsigned nz = idx >> 12; | |
140 | 1809834 | union av_intfloat32 s = { .f = *scale }; | |
141 | union av_intfloat32 t; | ||
142 | |||
143 | 1809834 | t.i = s.i ^ (sign & 1U<<31); | |
144 | 1809834 | *dst++ = v[idx & 3] * t.f; | |
145 | |||
146 | 1809834 | sign <<= nz & 1; nz >>= 1; | |
147 | 1809834 | t.i = s.i ^ (sign & 1U<<31); | |
148 | 1809834 | *dst++ = v[idx>>2 & 3] * t.f; | |
149 | |||
150 | 1809834 | sign <<= nz & 1; nz >>= 1; | |
151 | 1809834 | t.i = s.i ^ (sign & 1U<<31); | |
152 | 1809834 | *dst++ = v[idx>>4 & 3] * t.f; | |
153 | |||
154 | 1809834 | sign <<= nz & 1; | |
155 | 1809834 | t.i = s.i ^ (sign & 1U<<31); | |
156 | 1809834 | *dst++ = v[idx>>6 & 3] * t.f; | |
157 | |||
158 | 1809834 | 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" | ||
166 |