annotate ffmpeg/libavcodec/sbr.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 6840f77b83aa
children
rev   line source
yading@10 1 /*
yading@10 2 * Spectral Band Replication definitions and structures
yading@10 3 * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
yading@10 4 * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
yading@10 5 *
yading@10 6 * This file is part of FFmpeg.
yading@10 7 *
yading@10 8 * FFmpeg is free software; you can redistribute it and/or
yading@10 9 * modify it under the terms of the GNU Lesser General Public
yading@10 10 * License as published by the Free Software Foundation; either
yading@10 11 * version 2.1 of the License, or (at your option) any later version.
yading@10 12 *
yading@10 13 * FFmpeg is distributed in the hope that it will be useful,
yading@10 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@10 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@10 16 * Lesser General Public License for more details.
yading@10 17 *
yading@10 18 * You should have received a copy of the GNU Lesser General Public
yading@10 19 * License along with FFmpeg; if not, write to the Free Software
yading@10 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@10 21 */
yading@10 22
yading@10 23 /**
yading@10 24 * @file
yading@10 25 * Spectral Band Replication definitions and structures
yading@10 26 * @author Robert Swain ( rob opendot cl )
yading@10 27 */
yading@10 28
yading@10 29 #ifndef AVCODEC_SBR_H
yading@10 30 #define AVCODEC_SBR_H
yading@10 31
yading@10 32 #include <stdint.h>
yading@10 33 #include "fft.h"
yading@10 34 #include "aacps.h"
yading@10 35 #include "sbrdsp.h"
yading@10 36
yading@10 37 typedef struct AACContext AACContext;
yading@10 38
yading@10 39 /**
yading@10 40 * Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the previous header.
yading@10 41 */
yading@10 42 typedef struct SpectrumParameters {
yading@10 43 uint8_t bs_start_freq;
yading@10 44 uint8_t bs_stop_freq;
yading@10 45 uint8_t bs_xover_band;
yading@10 46
yading@10 47 /**
yading@10 48 * @name Variables associated with bs_header_extra_1
yading@10 49 * @{
yading@10 50 */
yading@10 51 uint8_t bs_freq_scale;
yading@10 52 uint8_t bs_alter_scale;
yading@10 53 uint8_t bs_noise_bands;
yading@10 54 /** @} */
yading@10 55 } SpectrumParameters;
yading@10 56
yading@10 57 #define SBR_SYNTHESIS_BUF_SIZE ((1280-128)*2)
yading@10 58
yading@10 59 /**
yading@10 60 * Spectral Band Replication per channel data
yading@10 61 */
yading@10 62 typedef struct SBRData {
yading@10 63 /**
yading@10 64 * @name Main bitstream data variables
yading@10 65 * @{
yading@10 66 */
yading@10 67 unsigned bs_frame_class;
yading@10 68 unsigned bs_add_harmonic_flag;
yading@10 69 unsigned bs_num_env;
yading@10 70 uint8_t bs_freq_res[7];
yading@10 71 unsigned bs_num_noise;
yading@10 72 uint8_t bs_df_env[5];
yading@10 73 uint8_t bs_df_noise[2];
yading@10 74 uint8_t bs_invf_mode[2][5];
yading@10 75 uint8_t bs_add_harmonic[48];
yading@10 76 unsigned bs_amp_res;
yading@10 77 /** @} */
yading@10 78
yading@10 79 /**
yading@10 80 * @name State variables
yading@10 81 * @{
yading@10 82 */
yading@10 83 DECLARE_ALIGNED(32, float, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE];
yading@10 84 DECLARE_ALIGNED(32, float, analysis_filterbank_samples) [1312];
yading@10 85 int synthesis_filterbank_samples_offset;
yading@10 86 ///l_APrev and l_A
yading@10 87 int e_a[2];
yading@10 88 ///Chirp factors
yading@10 89 float bw_array[5];
yading@10 90 ///QMF values of the original signal
yading@10 91 float W[2][32][32][2];
yading@10 92 ///QMF output of the HF adjustor
yading@10 93 int Ypos;
yading@10 94 DECLARE_ALIGNED(16, float, Y)[2][38][64][2];
yading@10 95 DECLARE_ALIGNED(16, float, g_temp)[42][48];
yading@10 96 float q_temp[42][48];
yading@10 97 uint8_t s_indexmapped[8][48];
yading@10 98 ///Envelope scalefactors
yading@10 99 float env_facs[6][48];
yading@10 100 ///Noise scalefactors
yading@10 101 float noise_facs[3][5];
yading@10 102 ///Envelope time borders
yading@10 103 uint8_t t_env[8];
yading@10 104 ///Envelope time border of the last envelope of the previous frame
yading@10 105 uint8_t t_env_num_env_old;
yading@10 106 ///Noise time borders
yading@10 107 uint8_t t_q[3];
yading@10 108 unsigned f_indexnoise;
yading@10 109 unsigned f_indexsine;
yading@10 110 /** @} */
yading@10 111 } SBRData;
yading@10 112
yading@10 113 typedef struct SpectralBandReplication SpectralBandReplication;
yading@10 114
yading@10 115 /**
yading@10 116 * aacsbr functions pointers
yading@10 117 */
yading@10 118 typedef struct AACSBRContext {
yading@10 119 int (*sbr_lf_gen)(AACContext *ac, SpectralBandReplication *sbr,
yading@10 120 float X_low[32][40][2], const float W[2][32][32][2],
yading@10 121 int buf_idx);
yading@10 122 void (*sbr_hf_assemble)(float Y1[38][64][2],
yading@10 123 const float X_high[64][40][2],
yading@10 124 SpectralBandReplication *sbr, SBRData *ch_data,
yading@10 125 const int e_a[2]);
yading@10 126 int (*sbr_x_gen)(SpectralBandReplication *sbr, float X[2][38][64],
yading@10 127 const float Y0[38][64][2], const float Y1[38][64][2],
yading@10 128 const float X_low[32][40][2], int ch);
yading@10 129 void (*sbr_hf_inverse_filter)(SBRDSPContext *dsp,
yading@10 130 float (*alpha0)[2], float (*alpha1)[2],
yading@10 131 const float X_low[32][40][2], int k0);
yading@10 132 } AACSBRContext;
yading@10 133
yading@10 134 /**
yading@10 135 * Spectral Band Replication
yading@10 136 */
yading@10 137 struct SpectralBandReplication {
yading@10 138 int sample_rate;
yading@10 139 int start;
yading@10 140 int reset;
yading@10 141 SpectrumParameters spectrum_params;
yading@10 142 int bs_amp_res_header;
yading@10 143 /**
yading@10 144 * @name Variables associated with bs_header_extra_2
yading@10 145 * @{
yading@10 146 */
yading@10 147 unsigned bs_limiter_bands;
yading@10 148 unsigned bs_limiter_gains;
yading@10 149 unsigned bs_interpol_freq;
yading@10 150 unsigned bs_smoothing_mode;
yading@10 151 /** @} */
yading@10 152 unsigned bs_coupling;
yading@10 153 unsigned k[5]; ///< k0, k1, k2
yading@10 154 ///kx', and kx respectively, kx is the first QMF subband where SBR is used.
yading@10 155 ///kx' is its value from the previous frame
yading@10 156 unsigned kx[2];
yading@10 157 ///M' and M respectively, M is the number of QMF subbands that use SBR.
yading@10 158 unsigned m[2];
yading@10 159 unsigned kx_and_m_pushed;
yading@10 160 ///The number of frequency bands in f_master
yading@10 161 unsigned n_master;
yading@10 162 SBRData data[2];
yading@10 163 PSContext ps;
yading@10 164 ///N_Low and N_High respectively, the number of frequency bands for low and high resolution
yading@10 165 unsigned n[2];
yading@10 166 ///Number of noise floor bands
yading@10 167 unsigned n_q;
yading@10 168 ///Number of limiter bands
yading@10 169 unsigned n_lim;
yading@10 170 ///The master QMF frequency grouping
yading@10 171 uint16_t f_master[49];
yading@10 172 ///Frequency borders for low resolution SBR
yading@10 173 uint16_t f_tablelow[25];
yading@10 174 ///Frequency borders for high resolution SBR
yading@10 175 uint16_t f_tablehigh[49];
yading@10 176 ///Frequency borders for noise floors
yading@10 177 uint16_t f_tablenoise[6];
yading@10 178 ///Frequency borders for the limiter
yading@10 179 uint16_t f_tablelim[30];
yading@10 180 unsigned num_patches;
yading@10 181 uint8_t patch_num_subbands[6];
yading@10 182 uint8_t patch_start_subband[6];
yading@10 183 ///QMF low frequency input to the HF generator
yading@10 184 DECLARE_ALIGNED(16, float, X_low)[32][40][2];
yading@10 185 ///QMF output of the HF generator
yading@10 186 DECLARE_ALIGNED(16, float, X_high)[64][40][2];
yading@10 187 ///QMF values of the reconstructed signal
yading@10 188 DECLARE_ALIGNED(16, float, X)[2][2][38][64];
yading@10 189 ///Zeroth coefficient used to filter the subband signals
yading@10 190 DECLARE_ALIGNED(16, float, alpha0)[64][2];
yading@10 191 ///First coefficient used to filter the subband signals
yading@10 192 DECLARE_ALIGNED(16, float, alpha1)[64][2];
yading@10 193 ///Dequantized envelope scalefactors, remapped
yading@10 194 float e_origmapped[7][48];
yading@10 195 ///Dequantized noise scalefactors, remapped
yading@10 196 float q_mapped[7][48];
yading@10 197 ///Sinusoidal presence, remapped
yading@10 198 uint8_t s_mapped[7][48];
yading@10 199 ///Estimated envelope
yading@10 200 float e_curr[7][48];
yading@10 201 ///Amplitude adjusted noise scalefactors
yading@10 202 float q_m[7][48];
yading@10 203 ///Sinusoidal levels
yading@10 204 float s_m[7][48];
yading@10 205 float gain[7][48];
yading@10 206 DECLARE_ALIGNED(32, float, qmf_filter_scratch)[5][64];
yading@10 207 FFTContext mdct_ana;
yading@10 208 FFTContext mdct;
yading@10 209 SBRDSPContext dsp;
yading@10 210 AACSBRContext c;
yading@10 211 };
yading@10 212
yading@10 213 #endif /* AVCODEC_SBR_H */