FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/aac/aacdec_float.c
Date: 2024-11-12 23:50:39
Exec Total Coverage
Lines: 56 57 98.2%
Functions: 6 6 100.0%
Branches: 1 2 50.0%

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_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 165 static void init_tables_float_fn(void)
57 {
58 165 ff_cbrt_tableinit();
59
60 165 ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
61 165 ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
62
63 165 ff_kbd_window_init(aac_kbd_long_960, 4.0, 960);
64 165 ff_kbd_window_init(aac_kbd_short_120, 6.0, 120);
65
66 165 ff_sine_window_init(sine_960, 960);
67 165 ff_sine_window_init(sine_120, 120);
68 165 ff_init_ff_sine_windows(9);
69
70 165 ff_aac_sbr_init();
71
72 165 ff_aac_float_common_init();
73 165 }
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 1815116 static inline float *VMUL2(float *dst, const float *v, unsigned idx,
93 const float *scale)
94 {
95 1815116 float s = *scale;
96 1815116 *dst++ = v[idx & 15] * s;
97 1815116 *dst++ = v[idx>>4 & 15] * s;
98 1815116 return dst;
99 }
100 #endif
101
102 #ifndef VMUL4
103 2273024 static inline float *VMUL4(float *dst, const float *v, unsigned idx,
104 const float *scale)
105 {
106 2273024 float s = *scale;
107 2273024 *dst++ = v[idx & 3] * s;
108 2273024 *dst++ = v[idx>>2 & 3] * s;
109 2273024 *dst++ = v[idx>>4 & 3] * s;
110 2273024 *dst++ = v[idx>>6 & 3] * s;
111 2273024 return dst;
112 }
113 #endif
114
115 #ifndef VMUL2S
116 2274420 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 2274420 s0.f = s1.f = *scale;
122 2274420 s0.i ^= sign >> 1 << 31;
123 2274420 s1.i ^= sign << 31;
124
125 2274420 *dst++ = v[idx & 15] * s0.f;
126 2274420 *dst++ = v[idx>>4 & 15] * s1.f;
127
128 2274420 return dst;
129 }
130 #endif
131
132 #ifndef VMUL4S
133 1809834 static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
134 unsigned sign, const float *scale)
135 {
136 1809834 unsigned nz = idx >> 12;
137 1809834 union av_intfloat32 s = { .f = *scale };
138 union av_intfloat32 t;
139
140 1809834 t.i = s.i ^ (sign & 1U<<31);
141 1809834 *dst++ = v[idx & 3] * t.f;
142
143 1809834 sign <<= nz & 1; nz >>= 1;
144 1809834 t.i = s.i ^ (sign & 1U<<31);
145 1809834 *dst++ = v[idx>>2 & 3] * t.f;
146
147 1809834 sign <<= nz & 1; nz >>= 1;
148 1809834 t.i = s.i ^ (sign & 1U<<31);
149 1809834 *dst++ = v[idx>>4 & 3] * t.f;
150
151 1809834 sign <<= nz & 1;
152 1809834 t.i = s.i ^ (sign & 1U<<31);
153 1809834 *dst++ = v[idx>>6 & 3] * t.f;
154
155 1809834 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
164 275 av_cold int ff_aac_decode_init_float(AVCodecContext *avctx)
165 {
166 static AVOnce init_float_once = AV_ONCE_INIT;
167 275 AACDecContext *ac = avctx->priv_data;
168
169 275 ac->is_fixed = 0;
170 275 avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
171
172 275 aac_dsp_init(&ac->dsp);
173 275 aac_proc_init(&ac->proc);
174
175 275 ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275 times.
275 if (!ac->fdsp)
177 return AVERROR(ENOMEM);
178
179 275 ff_thread_once(&init_float_once, init_tables_float_fn);
180
181 275 return ff_aac_decode_init(avctx);
182 }
183