00001 /* 00002 * Spectral Band Replication definitions and structures 00003 * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl ) 00004 * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> 00005 * 00006 * This file is part of FFmpeg. 00007 * 00008 * FFmpeg is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * FFmpeg is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with FFmpeg; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00029 #ifndef AVCODEC_SBR_H 00030 #define AVCODEC_SBR_H 00031 00032 #include <stdint.h> 00033 #include "fft.h" 00034 #include "aacps.h" 00035 00039 typedef struct { 00040 uint8_t bs_start_freq; 00041 uint8_t bs_stop_freq; 00042 uint8_t bs_xover_band; 00043 00048 uint8_t bs_freq_scale; 00049 uint8_t bs_alter_scale; 00050 uint8_t bs_noise_bands; 00052 } SpectrumParameters; 00053 00054 #define SBR_SYNTHESIS_BUF_SIZE ((1280-128)*2) 00055 00059 typedef struct { 00064 unsigned bs_frame_class; 00065 unsigned bs_add_harmonic_flag; 00066 unsigned bs_num_env; 00067 uint8_t bs_freq_res[7]; 00068 unsigned bs_num_noise; 00069 uint8_t bs_df_env[5]; 00070 uint8_t bs_df_noise[2]; 00071 uint8_t bs_invf_mode[2][5]; 00072 uint8_t bs_add_harmonic[48]; 00073 unsigned bs_amp_res; 00080 DECLARE_ALIGNED(16, float, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE]; 00081 DECLARE_ALIGNED(16, float, analysis_filterbank_samples) [1312]; 00082 int synthesis_filterbank_samples_offset; 00084 int e_a[2]; 00086 float bw_array[5]; 00088 float W[2][32][32][2]; 00090 float Y[2][38][64][2]; 00091 float g_temp[42][48]; 00092 float q_temp[42][48]; 00093 uint8_t s_indexmapped[8][48]; 00095 float env_facs[6][48]; 00097 float noise_facs[3][5]; 00099 uint8_t t_env[8]; 00101 uint8_t t_env_num_env_old; 00103 uint8_t t_q[3]; 00104 unsigned f_indexnoise; 00105 unsigned f_indexsine; 00107 } SBRData; 00108 00112 typedef struct { 00113 int sample_rate; 00114 int start; 00115 int reset; 00116 SpectrumParameters spectrum_params; 00117 int bs_amp_res_header; 00122 unsigned bs_limiter_bands; 00123 unsigned bs_limiter_gains; 00124 unsigned bs_interpol_freq; 00125 unsigned bs_smoothing_mode; 00127 unsigned bs_coupling; 00128 unsigned k[5]; 00129 00130 00131 unsigned kx[2]; 00133 unsigned m[2]; 00135 unsigned n_master; 00136 SBRData data[2]; 00137 PSContext ps; 00139 unsigned n[2]; 00141 unsigned n_q; 00143 unsigned n_lim; 00145 uint16_t f_master[49]; 00147 uint16_t f_tablelow[25]; 00149 uint16_t f_tablehigh[49]; 00151 uint16_t f_tablenoise[6]; 00153 uint16_t f_tablelim[29]; 00154 unsigned num_patches; 00155 uint8_t patch_num_subbands[6]; 00156 uint8_t patch_start_subband[6]; 00158 float X_low[32][40][2]; 00160 float X_high[64][40][2]; 00162 DECLARE_ALIGNED(16, float, X)[2][2][38][64]; 00164 float alpha0[64][2]; 00166 float alpha1[64][2]; 00168 float e_origmapped[7][48]; 00170 float q_mapped[7][48]; 00172 uint8_t s_mapped[7][48]; 00174 float e_curr[7][48]; 00176 float q_m[7][48]; 00178 float s_m[7][48]; 00179 float gain[7][48]; 00180 DECLARE_ALIGNED(16, float, qmf_filter_scratch)[5][64]; 00181 FFTContext mdct_ana; 00182 FFTContext mdct; 00183 } SpectralBandReplication; 00184 00185 #endif /* AVCODEC_SBR_H */