]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/ext/faad/sbr_dec.h
wwww
[16.git] / src / lib / doslib / ext / faad / sbr_dec.h
1 /*
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
3 ** Copyright (C) 2003-2005 M. Bakker, Nero 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 ** The "appropriate copyright message" mentioned in section 2c of the GPLv2
23 ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
24 **
25 ** Commercial non-GPL licensing of this software is possible.
26 ** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
27 **
28 ** $Id: sbr_dec.h,v 1.39 2007/11/01 12:33:34 menno Exp $
29 **/
30
31 #ifndef __SBR_DEC_H__
32 #define __SBR_DEC_H__
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 #ifdef PS_DEC
39 #include "ps_dec.h"
40 #endif
41 #ifdef DRM_PS
42 #include "drm_dec.h"
43 #endif
44
45 /* MAX_NTSRHFG: maximum of number_time_slots * rate + HFGen. 16*2+8 */
46 #define MAX_NTSRHFG 40
47 #define MAX_NTSR    32 /* max number_time_slots * rate, ok for DRM and not DRM mode */
48
49 /* MAX_M: maximum value for M */
50 #define MAX_M       49
51 /* MAX_L_E: maximum value for L_E */
52 #define MAX_L_E      5
53
54 typedef struct {
55     real_t *x;
56     int16_t x_index;
57     uint8_t channels;
58 } qmfa_info;
59
60 typedef struct {
61     real_t *v;
62     int16_t v_index;
63     uint8_t channels;
64 } qmfs_info;
65
66 typedef struct
67 {
68     uint32_t sample_rate;
69     uint32_t maxAACLine;
70
71     uint8_t rate;
72     uint8_t just_seeked;
73     uint8_t ret;
74
75     uint8_t amp_res[2];
76
77     uint8_t k0;
78     uint8_t kx;
79     uint8_t M;
80     uint8_t N_master;
81     uint8_t N_high;
82     uint8_t N_low;
83     uint8_t N_Q;
84     uint8_t N_L[4];
85     uint8_t n[2];
86
87     uint8_t f_master[64];
88     uint8_t f_table_res[2][64];
89     uint8_t f_table_noise[64];
90     uint8_t f_table_lim[4][64];
91 #ifdef SBR_LOW_POWER
92     uint8_t f_group[5][64];
93     uint8_t N_G[5];
94 #endif
95
96     uint8_t table_map_k_to_g[64];
97
98     uint8_t abs_bord_lead[2];
99     uint8_t abs_bord_trail[2];
100     uint8_t n_rel_lead[2];
101     uint8_t n_rel_trail[2];
102
103     uint8_t L_E[2];
104     uint8_t L_E_prev[2];
105     uint8_t L_Q[2];
106
107     uint8_t t_E[2][MAX_L_E+1];
108     uint8_t t_Q[2][3];
109     uint8_t f[2][MAX_L_E+1];
110     uint8_t f_prev[2];
111
112     real_t *G_temp_prev[2][5];
113     real_t *Q_temp_prev[2][5];
114     int8_t GQ_ringbuf_index[2];
115
116     int16_t E[2][64][MAX_L_E];
117     int16_t E_prev[2][64];
118 #ifndef FIXED_POINT
119     real_t E_orig[2][64][MAX_L_E];
120 #endif
121     real_t E_curr[2][64][MAX_L_E];
122     int32_t Q[2][64][2];
123 #ifndef FIXED_POINT
124     real_t Q_div[2][64][2];
125     real_t Q_div2[2][64][2];
126 #endif
127     int32_t Q_prev[2][64];
128
129     int8_t l_A[2];
130     int8_t l_A_prev[2];
131
132     uint8_t bs_invf_mode[2][MAX_L_E];
133     uint8_t bs_invf_mode_prev[2][MAX_L_E];
134     real_t bwArray[2][64];
135     real_t bwArray_prev[2][64];
136
137     uint8_t noPatches;
138     uint8_t patchNoSubbands[64];
139     uint8_t patchStartSubband[64];
140
141     uint8_t bs_add_harmonic[2][64];
142     uint8_t bs_add_harmonic_prev[2][64];
143
144     uint16_t index_noise_prev[2];
145     uint8_t psi_is_prev[2];
146
147     uint8_t bs_start_freq_prev;
148     uint8_t bs_stop_freq_prev;
149     uint8_t bs_xover_band_prev;
150     uint8_t bs_freq_scale_prev;
151     uint8_t bs_alter_scale_prev;
152     uint8_t bs_noise_bands_prev;
153
154     int8_t prevEnvIsShort[2];
155
156     int8_t kx_prev;
157     uint8_t bsco;
158     uint8_t bsco_prev;
159     uint8_t M_prev;
160     uint16_t frame_len;
161
162     uint8_t Reset;
163     uint32_t frame;
164     uint32_t header_count;
165
166     uint8_t id_aac;
167     qmfa_info *qmfa[2];
168     qmfs_info *qmfs[2];
169
170     qmf_t Xsbr[2][MAX_NTSRHFG][64];
171
172 #ifdef DRM
173     uint8_t Is_DRM_SBR;
174 #ifdef DRM_PS
175     drm_ps_info *drm_ps;
176 #endif
177 #endif
178
179     uint8_t numTimeSlotsRate;
180     uint8_t numTimeSlots;
181     uint8_t tHFGen;
182     uint8_t tHFAdj;
183
184 #ifdef PS_DEC
185     ps_info *ps;
186 #endif
187 #if (defined(PS_DEC) || defined(DRM_PS))
188     uint8_t ps_used;
189     uint8_t psResetFlag;
190 #endif
191
192     /* to get it compiling */
193     /* we'll see during the coding of all the tools, whether
194        these are all used or not.
195     */
196     uint8_t bs_header_flag;
197     uint8_t bs_crc_flag;
198     uint16_t bs_sbr_crc_bits;
199     uint8_t bs_protocol_version;
200     uint8_t bs_amp_res;
201     uint8_t bs_start_freq;
202     uint8_t bs_stop_freq;
203     uint8_t bs_xover_band;
204     uint8_t bs_freq_scale;
205     uint8_t bs_alter_scale;
206     uint8_t bs_noise_bands;
207     uint8_t bs_limiter_bands;
208     uint8_t bs_limiter_gains;
209     uint8_t bs_interpol_freq;
210     uint8_t bs_smoothing_mode;
211     uint8_t bs_samplerate_mode;
212     uint8_t bs_add_harmonic_flag[2];
213     uint8_t bs_add_harmonic_flag_prev[2];
214     uint8_t bs_extended_data;
215     uint8_t bs_extension_id;
216     uint8_t bs_extension_data;
217     uint8_t bs_coupling;
218     uint8_t bs_frame_class[2];
219     uint8_t bs_rel_bord[2][9];
220     uint8_t bs_rel_bord_0[2][9];
221     uint8_t bs_rel_bord_1[2][9];
222     uint8_t bs_pointer[2];
223     uint8_t bs_abs_bord_0[2];
224     uint8_t bs_abs_bord_1[2];
225     uint8_t bs_num_rel_0[2];
226     uint8_t bs_num_rel_1[2];
227     uint8_t bs_df_env[2][9];
228     uint8_t bs_df_noise[2][3];
229 } sbr_info;
230
231 sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
232                         uint32_t sample_rate, uint8_t downSampledSBR
233 #ifdef DRM
234                         , uint8_t IsDRM
235 #endif
236                         );
237 void sbrDecodeEnd(sbr_info *sbr);
238 void sbrReset(sbr_info *sbr);
239
240 uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan,
241                              const uint8_t just_seeked, const uint8_t downSampledSBR);
242 uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel,
243                              const uint8_t just_seeked, const uint8_t downSampledSBR);
244 #if (defined(PS_DEC) || defined(DRM_PS))
245 uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *right_channel,
246                                const uint8_t just_seeked, const uint8_t downSampledSBR);
247 #endif
248
249
250 #ifdef __cplusplus
251 }
252 #endif
253 #endif
254