annotate sbr.h @ 12500:9575307cbb82 libavcodec

Don't access upper 32 bits of a 32-bit int on 64-bit systems.
author rbultje
date Fri, 17 Sep 2010 12:24:22 +0000
parents fe1a6abe310a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11401
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
1 /*
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
2 * Spectral Band Replication definitions and structures
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
3 * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
4 * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
5 *
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
6 * This file is part of FFmpeg.
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
7 *
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
12 *
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
16 * Lesser General Public License for more details.
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
17 *
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
21 */
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
22
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
23 /**
11644
7dd2a45249a9 Remove explicit filename from Doxygen @file commands.
diego
parents: 11446
diff changeset
24 * @file
11401
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
25 * Spectral Band Replication definitions and structures
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
26 * @author Robert Swain ( rob opendot cl )
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
27 */
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
28
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
29 #ifndef AVCODEC_SBR_H
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
30 #define AVCODEC_SBR_H
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
31
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
32 #include <stdint.h>
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
33 #include "fft.h"
11922
8c657be75c11 Move Parametric Stereo related ps* files to aacps*.
alexc
parents: 11886
diff changeset
34 #include "aacps.h"
11401
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
35
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
36 /**
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
37 * Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the previous header.
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
38 */
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
39 typedef struct {
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
40 uint8_t bs_start_freq;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
41 uint8_t bs_stop_freq;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
42 uint8_t bs_xover_band;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
43
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
44 /**
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
45 * @defgroup bs_header_extra_1 Variables associated with bs_header_extra_1
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
46 * @{
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
47 */
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
48 uint8_t bs_freq_scale;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
49 uint8_t bs_alter_scale;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
50 uint8_t bs_noise_bands;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
51 /** @} */
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
52 } SpectrumParameters;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
53
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
54 #define SBR_SYNTHESIS_BUF_SIZE ((1280-128)*2)
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
55
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
56 /**
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
57 * Spectral Band Replication per channel data
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
58 */
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
59 typedef struct {
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
60 /**
12074
fe1a6abe310a Disambiguate bitstream groups for AAC and RV30/RV40.
diego
parents: 11922
diff changeset
61 * @defgroup aac_bitstream Main bitstream data variables
11401
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
62 * @{
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
63 */
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
64 unsigned bs_frame_class;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
65 unsigned bs_add_harmonic_flag;
11446
806dc446061d aacsbr: Make the previous value of bs_num_env local to read_sbr_data().
alexc
parents: 11437
diff changeset
66 unsigned bs_num_env;
11401
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
67 uint8_t bs_freq_res[7];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
68 unsigned bs_num_noise;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
69 uint8_t bs_df_env[5];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
70 uint8_t bs_df_noise[2];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
71 uint8_t bs_invf_mode[2][5];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
72 uint8_t bs_add_harmonic[48];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
73 unsigned bs_amp_res;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
74 /** @} */
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
75
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
76 /**
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
77 * @defgroup state State variables
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
78 * @{
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
79 */
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
80 DECLARE_ALIGNED(16, float, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
81 DECLARE_ALIGNED(16, float, analysis_filterbank_samples) [1312];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
82 int synthesis_filterbank_samples_offset;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
83 ///l_APrev and l_A
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
84 int e_a[2];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
85 ///Chirp factors
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
86 float bw_array[5];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
87 ///QMF values of the original signal
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
88 float W[2][32][32][2];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
89 ///QMF output of the HF adjustor
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
90 float Y[2][38][64][2];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
91 float g_temp[42][48];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
92 float q_temp[42][48];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
93 uint8_t s_indexmapped[8][48];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
94 ///Envelope scalefactors
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
95 float env_facs[6][48];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
96 ///Noise scalefactors
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
97 float noise_facs[3][5];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
98 ///Envelope time borders
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
99 uint8_t t_env[8];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
100 ///Envelope time border of the last envelope of the previous frame
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
101 uint8_t t_env_num_env_old;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
102 ///Noise time borders
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
103 uint8_t t_q[3];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
104 unsigned f_indexnoise;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
105 unsigned f_indexsine;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
106 /** @} */
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
107 } SBRData;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
108
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
109 /**
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
110 * Spectral Band Replication
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
111 */
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
112 typedef struct {
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
113 int sample_rate;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
114 int start;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
115 int reset;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
116 SpectrumParameters spectrum_params;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
117 int bs_amp_res_header;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
118 /**
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
119 * @defgroup bs_header_extra_2 variables associated with bs_header_extra_2
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
120 * @{
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
121 */
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
122 unsigned bs_limiter_bands;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
123 unsigned bs_limiter_gains;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
124 unsigned bs_interpol_freq;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
125 unsigned bs_smoothing_mode;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
126 /** @} */
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
127 unsigned bs_coupling;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
128 unsigned k[5]; ///< k0, k1, k2
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
129 ///kx', and kx respectively, kx is the first QMF subband where SBR is used.
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
130 ///kx' is its value from the previous frame
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
131 unsigned kx[2];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
132 ///M' and M respectively, M is the number of QMF subbands that use SBR.
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
133 unsigned m[2];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
134 ///The number of frequency bands in f_master
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
135 unsigned n_master;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
136 SBRData data[2];
11886
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents: 11847
diff changeset
137 PSContext ps;
11401
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
138 ///N_Low and N_High respectively, the number of frequency bands for low and high resolution
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
139 unsigned n[2];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
140 ///Number of noise floor bands
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
141 unsigned n_q;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
142 ///Number of limiter bands
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
143 unsigned n_lim;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
144 ///The master QMF frequency grouping
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
145 uint16_t f_master[49];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
146 ///Frequency borders for low resolution SBR
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
147 uint16_t f_tablelow[25];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
148 ///Frequency borders for high resolution SBR
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
149 uint16_t f_tablehigh[49];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
150 ///Frequency borders for noise floors
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
151 uint16_t f_tablenoise[6];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
152 ///Frequency borders for the limiter
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
153 uint16_t f_tablelim[29];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
154 unsigned num_patches;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
155 uint8_t patch_num_subbands[6];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
156 uint8_t patch_start_subband[6];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
157 ///QMF low frequency input to the HF generator
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
158 float X_low[32][40][2];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
159 ///QMF output of the HF generator
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
160 float X_high[64][40][2];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
161 ///QMF values of the reconstructed signal
11886
2d81202be6e2 Add HE-AAC v2 support to the AAC decoder.
alexc
parents: 11847
diff changeset
162 DECLARE_ALIGNED(16, float, X)[2][2][38][64];
11401
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
163 ///Zeroth coefficient used to filter the subband signals
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
164 float alpha0[64][2];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
165 ///First coefficient used to filter the subband signals
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
166 float alpha1[64][2];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
167 ///Dequantized envelope scalefactors, remapped
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
168 float e_origmapped[7][48];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
169 ///Dequantized noise scalefactors, remapped
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
170 float q_mapped[7][48];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
171 ///Sinusoidal presence, remapped
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
172 uint8_t s_mapped[7][48];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
173 ///Estimated envelope
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
174 float e_curr[7][48];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
175 ///Amplitude adjusted noise scalefactors
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
176 float q_m[7][48];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
177 ///Sinusoidal levels
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
178 float s_m[7][48];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
179 float gain[7][48];
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
180 DECLARE_ALIGNED(16, float, qmf_filter_scratch)[5][64];
11847
67206bbbab10 Rewrite the SBR decoder QMF analysis filter on top of the IMDCT instead of the RDFT.
alexc
parents: 11677
diff changeset
181 FFTContext mdct_ana;
11401
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
182 FFTContext mdct;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
183 } SpectralBandReplication;
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
184
e340262ba532 Add an HE-AAC v1 decoder.
alexc
parents:
diff changeset
185 #endif /* AVCODEC_SBR_H */