sbr_dec.h

00001 /*
00002 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
00003 ** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com
00004 **  
00005 ** This program is free software; you can redistribute it and/or modify
00006 ** it under the terms of the GNU General Public License as published by
00007 ** the Free Software Foundation; either version 2 of the License, or
00008 ** (at your option) any later version.
00009 ** 
00010 ** This program is distributed in the hope that it will be useful,
00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 ** GNU General Public License for more details.
00014 ** 
00015 ** You should have received a copy of the GNU General Public License
00016 ** along with this program; if not, write to the Free Software 
00017 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 **
00019 ** Any non-GPL usage of this software or parts of this software is strictly
00020 ** forbidden.
00021 **
00022 ** Software using this code must display the following message visibly in the
00023 ** software:
00024 ** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Ahead Software, www.nero.com"
00025 ** in, for example, the about-box or help/startup screen.
00026 **
00027 ** Commercial non-GPL licensing of this software is possible.
00028 ** For more info contact Ahead Software through [email protected].
00029 **
00030 ** $Id: sbr_dec.h,v 1.3 2005/11/01 21:41:43 gabest Exp $
00031 **/
00032 
00033 #ifndef __SBR_DEC_H__
00034 #define __SBR_DEC_H__
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 #ifdef PS_DEC
00041 #include "ps_dec.h"
00042 #endif
00043 #ifdef DRM_PS
00044 #include "drm_dec.h"
00045 #endif
00046 
00047 /* MAX_NTSRHFG: maximum of number_time_slots * rate + HFGen. 16*2+8 */
00048 #define MAX_NTSRHFG 40
00049 #define MAX_NTSR    32 /* max number_time_slots * rate, ok for DRM and not DRM mode */
00050 
00051 /* MAX_M: maximum value for M */
00052 #define MAX_M       49
00053 /* MAX_L_E: maximum value for L_E */
00054 #define MAX_L_E      5
00055 
00056 typedef struct {
00057     real_t *x;
00058     int16_t x_index;
00059     uint8_t channels;
00060 } qmfa_info;
00061 
00062 typedef struct {
00063     real_t *v;
00064     int16_t v_index;
00065     uint8_t channels;
00066 } qmfs_info;
00067 
00068 typedef struct
00069 {
00070     uint32_t sample_rate;
00071     uint32_t maxAACLine;
00072 
00073     uint8_t rate;
00074     uint8_t just_seeked;
00075     uint8_t ret;
00076 
00077     uint8_t amp_res[2];
00078 
00079     uint8_t k0;
00080     uint8_t kx;
00081     uint8_t M;
00082     uint8_t N_master;
00083     uint8_t N_high;
00084     uint8_t N_low;
00085     uint8_t N_Q;
00086     uint8_t N_L[4];
00087     uint8_t n[2];
00088 
00089     uint8_t f_master[64];
00090     uint8_t f_table_res[2][64];
00091     uint8_t f_table_noise[64];
00092     uint8_t f_table_lim[4][64];
00093 #ifdef SBR_LOW_POWER
00094     uint8_t f_group[5][64];
00095     uint8_t N_G[5];
00096 #endif
00097 
00098     uint8_t table_map_k_to_g[64];
00099 
00100     uint8_t abs_bord_lead[2];
00101     uint8_t abs_bord_trail[2];
00102     uint8_t n_rel_lead[2];
00103     uint8_t n_rel_trail[2];
00104 
00105     uint8_t L_E[2];
00106     uint8_t L_E_prev[2];
00107     uint8_t L_Q[2];
00108 
00109     uint8_t t_E[2][MAX_L_E+1];
00110     uint8_t t_Q[2][3];
00111     uint8_t f[2][MAX_L_E+1];
00112     uint8_t f_prev[2];
00113 
00114     real_t *G_temp_prev[2][5];
00115     real_t *Q_temp_prev[2][5];
00116     int8_t GQ_ringbuf_index[2];
00117 
00118     int16_t E[2][64][MAX_L_E];
00119     int16_t E_prev[2][64];
00120 #ifndef FIXED_POINT
00121     real_t E_orig[2][64][MAX_L_E];
00122 #endif
00123     real_t E_curr[2][64][MAX_L_E];
00124     int32_t Q[2][64][2];
00125 #ifndef FIXED_POINT
00126     real_t Q_div[2][64][2];
00127     real_t Q_div2[2][64][2];
00128 #endif
00129     int32_t Q_prev[2][64];
00130 
00131     int8_t l_A[2];
00132     int8_t l_A_prev[2];
00133 
00134     uint8_t bs_invf_mode[2][MAX_L_E];
00135     uint8_t bs_invf_mode_prev[2][MAX_L_E];
00136     real_t bwArray[2][64];
00137     real_t bwArray_prev[2][64];
00138 
00139     uint8_t noPatches;
00140     uint8_t patchNoSubbands[64];
00141     uint8_t patchStartSubband[64];
00142 
00143     uint8_t bs_add_harmonic[2][64];
00144     uint8_t bs_add_harmonic_prev[2][64];
00145 
00146     uint16_t index_noise_prev[2];
00147     uint8_t psi_is_prev[2];
00148 
00149     uint8_t bs_start_freq_prev;
00150     uint8_t bs_stop_freq_prev;
00151     uint8_t bs_xover_band_prev;
00152     uint8_t bs_freq_scale_prev;
00153     uint8_t bs_alter_scale_prev;
00154     uint8_t bs_noise_bands_prev;
00155 
00156     int8_t prevEnvIsShort[2];
00157 
00158     int8_t kx_prev;
00159     uint8_t bsco;
00160     uint8_t bsco_prev;
00161     uint8_t M_prev;
00162     uint16_t frame_len;
00163 
00164     uint8_t Reset;
00165     uint32_t frame;
00166     uint32_t header_count;
00167 
00168     uint8_t id_aac;
00169     qmfa_info *qmfa[2];
00170     qmfs_info *qmfs[2];
00171 
00172     qmf_t Xsbr[2][MAX_NTSRHFG][64];
00173 
00174 #ifdef DRM
00175     uint8_t Is_DRM_SBR;
00176 #ifdef DRM_PS
00177     drm_ps_info *drm_ps;
00178 #endif
00179 #endif
00180 
00181     uint8_t numTimeSlotsRate;
00182     uint8_t numTimeSlots;
00183     uint8_t tHFGen;
00184     uint8_t tHFAdj;
00185 
00186 #ifdef PS_DEC
00187     ps_info *ps;
00188 #endif
00189 #if (defined(PS_DEC) || defined(DRM_PS))
00190     uint8_t ps_used;
00191 #endif
00192 
00193     /* to get it compiling */
00194     /* we'll see during the coding of all the tools, whether
00195        these are all used or not.
00196     */
00197     uint8_t bs_header_flag;
00198     uint8_t bs_crc_flag;
00199     uint16_t bs_sbr_crc_bits;
00200     uint8_t bs_protocol_version;
00201     uint8_t bs_amp_res;
00202     uint8_t bs_start_freq;
00203     uint8_t bs_stop_freq;
00204     uint8_t bs_xover_band;
00205     uint8_t bs_freq_scale;
00206     uint8_t bs_alter_scale;
00207     uint8_t bs_noise_bands;
00208     uint8_t bs_limiter_bands;
00209     uint8_t bs_limiter_gains;
00210     uint8_t bs_interpol_freq;
00211     uint8_t bs_smoothing_mode;
00212     uint8_t bs_samplerate_mode;
00213     uint8_t bs_add_harmonic_flag[2];
00214     uint8_t bs_add_harmonic_flag_prev[2];
00215     uint8_t bs_extended_data;
00216     uint8_t bs_extension_id;
00217     uint8_t bs_extension_data;
00218     uint8_t bs_coupling;
00219     uint8_t bs_frame_class[2];
00220     uint8_t bs_rel_bord[2][9];
00221     uint8_t bs_rel_bord_0[2][9];
00222     uint8_t bs_rel_bord_1[2][9];
00223     uint8_t bs_pointer[2];
00224     uint8_t bs_abs_bord_0[2];
00225     uint8_t bs_abs_bord_1[2];
00226     uint8_t bs_num_rel_0[2];
00227     uint8_t bs_num_rel_1[2];
00228     uint8_t bs_df_env[2][9];
00229     uint8_t bs_df_noise[2][3];
00230 } sbr_info;
00231 
00232 sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
00233                         uint32_t sample_rate, uint8_t downSampledSBR
00234 #ifdef DRM
00235                         , uint8_t IsDRM
00236 #endif
00237                         );
00238 void sbrDecodeEnd(sbr_info *sbr);
00239 void sbrReset(sbr_info *sbr);
00240 
00241 uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan,
00242                              const uint8_t just_seeked, const uint8_t downSampledSBR);
00243 uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel,
00244                              const uint8_t just_seeked, const uint8_t downSampledSBR);
00245 #if (defined(PS_DEC) || defined(DRM_PS))
00246 uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *right_channel,
00247                                const uint8_t just_seeked, const uint8_t downSampledSBR);
00248 #endif
00249 
00250 
00251 #ifdef __cplusplus
00252 }
00253 #endif
00254 #endif
00255 

Generated on Tue Dec 13 14:47:44 2005 for guliverkli by  doxygen 1.4.5