FFmpeg
sbr.h
Go to the documentation of this file.
1 /*
2  * Spectral Band Replication definitions and structures
3  * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
4  * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
29 #ifndef AVCODEC_SBR_H
30 #define AVCODEC_SBR_H
31 
32 #include <stdint.h>
33 #include "fft.h"
34 #include "aacps.h"
35 #include "sbrdsp.h"
36 
37 typedef struct AACContext AACContext;
38 
42 typedef struct SpectrumParameters {
43  uint8_t bs_start_freq;
44  uint8_t bs_stop_freq;
45  uint8_t bs_xover_band;
46 
51  uint8_t bs_freq_scale;
52  uint8_t bs_alter_scale;
53  uint8_t bs_noise_bands;
56 
57 #define SBR_SYNTHESIS_BUF_SIZE ((1280-128)*2)
58 
62 typedef struct SBRData {
67  unsigned bs_frame_class;
68  unsigned bs_add_harmonic_flag;
69  AAC_SIGNE bs_num_env;
70  uint8_t bs_freq_res[7];
71  AAC_SIGNE bs_num_noise;
72  uint8_t bs_df_env[5];
73  uint8_t bs_df_noise[2];
74  uint8_t bs_invf_mode[2][5];
75  uint8_t bs_add_harmonic[48];
76  unsigned bs_amp_res;
83  DECLARE_ALIGNED(32, INTFLOAT, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE];
84  DECLARE_ALIGNED(32, INTFLOAT, analysis_filterbank_samples) [1312];
85  int synthesis_filterbank_samples_offset;
87  int e_a[2];
89  INTFLOAT bw_array[5];
91  INTFLOAT W[2][32][32][2];
93  int Ypos;
94  DECLARE_ALIGNED(16, INTFLOAT, Y)[2][38][64][2];
95  DECLARE_ALIGNED(16, AAC_FLOAT, g_temp)[42][48];
96  AAC_FLOAT q_temp[42][48];
97  uint8_t s_indexmapped[8][48];
99  uint8_t env_facs_q[6][48];
100  AAC_FLOAT env_facs[6][48];
102  uint8_t noise_facs_q[3][5];
103  AAC_FLOAT noise_facs[3][5];
105  uint8_t t_env[8];
109  uint8_t t_q[3];
110  unsigned f_indexnoise;
111  unsigned f_indexsine;
113 } SBRData;
114 
116 
120 typedef struct AACSBRContext {
121  int (*sbr_lf_gen)(AACContext *ac, SpectralBandReplication *sbr,
122  INTFLOAT X_low[32][40][2], const INTFLOAT W[2][32][32][2],
123  int buf_idx);
124  void (*sbr_hf_assemble)(INTFLOAT Y1[38][64][2],
125  const INTFLOAT X_high[64][40][2],
126  SpectralBandReplication *sbr, SBRData *ch_data,
127  const int e_a[2]);
128  int (*sbr_x_gen)(SpectralBandReplication *sbr, INTFLOAT X[2][38][64],
129  const INTFLOAT Y0[38][64][2], const INTFLOAT Y1[38][64][2],
130  const INTFLOAT X_low[32][40][2], int ch);
131  void (*sbr_hf_inverse_filter)(SBRDSPContext *dsp,
132  INTFLOAT (*alpha0)[2], INTFLOAT (*alpha1)[2],
133  const INTFLOAT X_low[32][40][2], int k0);
134 } AACSBRContext;
135 
140  int sample_rate;
141  int start;
142  int ready_for_dequant;
143  int id_aac;
144  int reset;
145  SpectrumParameters spectrum_params;
146  int bs_amp_res_header;
151  unsigned bs_limiter_bands;
152  unsigned bs_limiter_gains;
153  unsigned bs_interpol_freq;
154  unsigned bs_smoothing_mode;
156  unsigned bs_coupling;
157  AAC_SIGNE k[5];
158  AAC_SIGNE kx[2];
162  AAC_SIGNE m[2];
163  unsigned kx_and_m_pushed;
165  AAC_SIGNE n_master;
166  SBRData data[2];
167  PSContext ps;
169  AAC_SIGNE n[2];
171  AAC_SIGNE n_q;
173  AAC_SIGNE n_lim;
175  uint16_t f_master[49];
177  uint16_t f_tablelow[25];
179  uint16_t f_tablehigh[49];
181  uint16_t f_tablenoise[6];
183  uint16_t f_tablelim[30];
184  AAC_SIGNE num_patches;
185  uint8_t patch_num_subbands[6];
186  uint8_t patch_start_subband[6];
188  DECLARE_ALIGNED(16, INTFLOAT, X_low)[32][40][2];
190  DECLARE_ALIGNED(16, INTFLOAT, X_high)[64][40][2];
192  DECLARE_ALIGNED(16, INTFLOAT, X)[2][2][38][64];
194  DECLARE_ALIGNED(16, INTFLOAT, alpha0)[64][2];
196  DECLARE_ALIGNED(16, INTFLOAT, alpha1)[64][2];
198  AAC_FLOAT e_origmapped[7][48];
200  AAC_FLOAT q_mapped[7][48];
202  uint8_t s_mapped[7][48];
204  AAC_FLOAT e_curr[7][48];
206  AAC_FLOAT q_m[7][48];
208  AAC_FLOAT s_m[7][48];
209  AAC_FLOAT gain[7][48];
210  DECLARE_ALIGNED(32, INTFLOAT, qmf_filter_scratch)[5][64];
211  FFTContext mdct_ana;
212  FFTContext mdct;
213  SBRDSPContext dsp;
214  AACSBRContext c;
215 };
216 
217 #endif /* AVCODEC_SBR_H */
AAC_SIGNE n_lim
Number of limiter bands.
Definition: sbr.h:173
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
Definition: mem.h:120
Definition: sbrdsp.h:28
Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the pr...
Definition: sbr.h:42
struct SBRData SBRData
Spectral Band Replication per channel data.
uint8_t t_env_num_env_old
Envelope time border of the last envelope of the previous frame.
Definition: sbr.h:107
Definition: fft.h:88
Definition: aacps.h:41
main AAC context
Definition: aac.h:293
struct AACSBRContext AACSBRContext
aacsbr functions pointers
AAC_SIGNE n_master
The number of frequency bands in f_master.
Definition: sbr.h:165
aacsbr functions pointers
Definition: sbr.h:120
Spectral Band Replication per channel data.
Definition: sbr.h:62
int Ypos
QMF output of the HF adjustor.
Definition: sbr.h:93
struct SpectrumParameters SpectrumParameters
Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the pr...
AAC_SIGNE n_q
Number of noise floor bands.
Definition: sbr.h:171
Spectral Band Replication.
Definition: sbr.h:139