2
|
1 /*
|
|
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
|
|
3 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
|
|
4 **
|
|
5 ** This program is free software; you can redistribute it and/or modify
|
|
6 ** it under the terms of the GNU General Public License as published by
|
|
7 ** the Free Software Foundation; either version 2 of the License, or
|
|
8 ** (at your option) any later version.
|
|
9 **
|
|
10 ** This program is distributed in the hope that it will be useful,
|
|
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 ** GNU General Public License for more details.
|
|
14 **
|
|
15 ** You should have received a copy of the GNU General Public License
|
|
16 ** along with this program; if not, write to the Free Software
|
|
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
18 **
|
|
19 ** Any non-GPL usage of this software or parts of this software is strictly
|
|
20 ** forbidden.
|
|
21 **
|
|
22 ** Commercial non-GPL licensing of this software is possible.
|
|
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
|
|
24 **
|
|
25 ** $Id: sbr_dec.h,v 1.12 2003/11/12 20:47:58 menno Exp $
|
|
26 **/
|
|
27
|
|
28 #ifndef __SBR_DEC_H__
|
|
29 #define __SBR_DEC_H__
|
|
30
|
|
31 #ifdef __cplusplus
|
|
32 extern "C" {
|
|
33 #endif
|
|
34
|
|
35
|
|
36 /* MAX_NTSRHFG: maximum of number_time_slots * rate + HFGen. DRM: 15*2+32, else 16*2+8 */
|
|
37 #ifdef DRM
|
|
38 # define MAX_NTSRHFG 62
|
|
39 #else
|
|
40 # define MAX_NTSRHFG 40
|
|
41 #endif
|
|
42 #define MAX_NTSR 32 /* max number_time_slots * rate, ok for DRM and not DRM mode */
|
|
43
|
|
44
|
|
45 typedef struct {
|
|
46 real_t *x;
|
|
47 uint8_t channels;
|
|
48 } qmfa_info;
|
|
49
|
|
50 typedef struct {
|
|
51 real_t *v[2];
|
|
52 uint8_t v_index;
|
|
53 uint8_t channels;
|
|
54 } qmfs_info;
|
|
55
|
|
56 typedef struct
|
|
57 {
|
|
58 uint32_t sample_rate;
|
|
59
|
|
60 uint8_t rate;
|
|
61 uint8_t just_seeked;
|
|
62
|
|
63 uint8_t amp_res[2];
|
|
64
|
|
65 uint8_t k0;
|
|
66 uint8_t kx;
|
|
67 uint8_t M;
|
|
68 uint8_t N_master;
|
|
69 uint8_t N_high;
|
|
70 uint8_t N_low;
|
|
71 uint8_t N_Q;
|
|
72 uint8_t N_L[4];
|
|
73 uint8_t n[2];
|
|
74
|
|
75 uint8_t f_master[64];
|
|
76 uint8_t f_table_res[2][64];
|
|
77 uint8_t f_table_noise[64];
|
|
78 uint8_t f_table_lim[4][64];
|
|
79 #ifdef SBR_LOW_POWER
|
|
80 uint8_t f_group[5][64];
|
|
81 uint8_t N_G[5];
|
|
82 #endif
|
|
83
|
|
84 uint8_t table_map_k_to_g[64];
|
|
85
|
|
86 uint8_t abs_bord_lead[2];
|
|
87 uint8_t abs_bord_trail[2];
|
|
88 uint8_t n_rel_lead[2];
|
|
89 uint8_t n_rel_trail[2];
|
|
90
|
|
91 uint8_t L_E[2];
|
|
92 uint8_t L_E_prev[2];
|
|
93 uint8_t L_Q[2];
|
|
94
|
|
95 uint8_t t_E[2][6];
|
|
96 uint8_t t_Q[2][3];
|
|
97 uint8_t f[2][6];
|
|
98 uint8_t f_prev[2];
|
|
99
|
|
100 real_t *G_temp_prev[2][5];
|
|
101 real_t *Q_temp_prev[2][5];
|
|
102
|
|
103 int16_t E[2][64][5];
|
|
104 int16_t E_prev[2][64];
|
|
105 real_t E_orig[2][64][5];
|
|
106 real_t E_curr[2][64][5];
|
|
107 int32_t Q[2][64][2];
|
|
108 int32_t Q_prev[2][64];
|
|
109 real_t Q_orig[2][64][2];
|
|
110
|
|
111 int8_t l_A[2];
|
|
112 int8_t l_A_prev[2];
|
|
113
|
|
114 uint8_t bs_invf_mode[2][5];
|
|
115 uint8_t bs_invf_mode_prev[2][5];
|
|
116 real_t bwArray[2][64];
|
|
117 real_t bwArray_prev[2][64];
|
|
118
|
|
119 uint8_t noPatches;
|
|
120 uint8_t patchNoSubbands[64];
|
|
121 uint8_t patchStartSubband[64];
|
|
122
|
|
123 uint8_t bs_add_harmonic[2][64];
|
|
124 uint8_t bs_add_harmonic_prev[2][64];
|
|
125
|
|
126 uint16_t index_noise_prev[2];
|
|
127 uint8_t psi_is_prev[2];
|
|
128
|
|
129 uint8_t bs_start_freq_prev;
|
|
130 uint8_t bs_stop_freq_prev;
|
|
131 uint8_t bs_xover_band_prev;
|
|
132 uint8_t bs_freq_scale_prev;
|
|
133 uint8_t bs_alter_scale_prev;
|
|
134 uint8_t bs_noise_bands_prev;
|
|
135
|
|
136 int8_t prevEnvIsShort[2];
|
|
137
|
|
138 int8_t kx_prev;
|
|
139
|
|
140 uint8_t Reset;
|
|
141 uint32_t frame;
|
|
142 uint32_t header_count;
|
|
143
|
|
144 uint8_t *data;
|
|
145 uint16_t data_size;
|
|
146
|
|
147 uint8_t id_aac;
|
|
148 qmfa_info *qmfa[2];
|
|
149 qmfs_info *qmfs[2];
|
|
150
|
|
151 qmf_t Xsbr[2][MAX_NTSRHFG][64];
|
|
152 qmf_t Xcodec[2][MAX_NTSRHFG][32];
|
|
153
|
|
154 #ifdef DRM
|
|
155 int8_t lcstereo_flag;
|
|
156 uint8_t bs_dataextra;
|
|
157 uint16_t data_size_bits;
|
|
158 uint8_t Is_DRM_SBR;
|
|
159 #endif
|
|
160
|
|
161 uint16_t numTimeSlotsRate;
|
|
162 uint16_t numTimeSlots;
|
|
163 uint8_t tHFGen;
|
|
164 uint8_t tHFAdj;
|
|
165
|
|
166 /* to get it compiling */
|
|
167 /* we'll see during the coding of all the tools, whether
|
|
168 these are all used or not.
|
|
169 */
|
|
170 uint8_t bs_header_flag;
|
|
171 uint8_t bs_crc_flag;
|
|
172 uint16_t bs_sbr_crc_bits;
|
|
173 uint8_t bs_protocol_version;
|
|
174 uint8_t bs_amp_res;
|
|
175 uint8_t bs_start_freq;
|
|
176 uint8_t bs_stop_freq;
|
|
177 uint8_t bs_xover_band;
|
|
178 uint8_t bs_freq_scale;
|
|
179 uint8_t bs_alter_scale;
|
|
180 uint8_t bs_noise_bands;
|
|
181 uint8_t bs_limiter_bands;
|
|
182 uint8_t bs_limiter_gains;
|
|
183 uint8_t bs_interpol_freq;
|
|
184 uint8_t bs_smoothing_mode;
|
|
185 uint8_t bs_samplerate_mode;
|
|
186 uint8_t bs_add_harmonic_flag[2];
|
|
187 uint8_t bs_add_harmonic_flag_prev[2];
|
|
188 uint8_t bs_extended_data;
|
|
189 uint8_t bs_extension_id;
|
|
190 uint8_t bs_extension_data;
|
|
191 uint8_t bs_coupling;
|
|
192 uint8_t bs_frame_class[2];
|
|
193 uint8_t bs_rel_bord[2][9];
|
|
194 uint8_t bs_rel_bord_0[2][9];
|
|
195 uint8_t bs_rel_bord_1[2][9];
|
|
196 uint8_t bs_pointer[2];
|
|
197 uint8_t bs_abs_bord_0[2];
|
|
198 uint8_t bs_abs_bord_1[2];
|
|
199 uint8_t bs_num_rel_0[2];
|
|
200 uint8_t bs_num_rel_1[2];
|
|
201 uint8_t bs_df_env[2][9];
|
|
202 uint8_t bs_df_noise[2][3];
|
|
203 } sbr_info;
|
|
204
|
|
205 sbr_info *sbrDecodeInit(uint16_t framelength
|
|
206 #ifdef DRM
|
|
207 , uint8_t IsDRM
|
|
208 #endif
|
|
209 );
|
|
210 void sbrDecodeEnd(sbr_info *sbr);
|
|
211
|
|
212 void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel,
|
|
213 real_t *right_channel,
|
|
214 const uint8_t just_seeked, const uint8_t upsample_only);
|
|
215
|
|
216
|
|
217 #ifdef __cplusplus
|
|
218 }
|
|
219 #endif
|
|
220 #endif
|
|
221
|