FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 
23 /**
24  * @file
25  * Spectral Band Replication definitions and structures
26  * @author Robert Swain ( rob opendot cl )
27  */
28 
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 
39 /**
40  * Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the previous header.
41  */
42 typedef struct SpectrumParameters {
46 
47  /**
48  * @name Variables associated with bs_header_extra_1
49  * @{
50  */
54  /** @} */
56 
57 #define SBR_SYNTHESIS_BUF_SIZE ((1280-128)*2)
58 
59 /**
60  * Spectral Band Replication per channel data
61  */
62 typedef struct SBRData {
63  /**
64  * @name Main bitstream data variables
65  * @{
66  */
67  unsigned bs_frame_class;
76  unsigned bs_amp_res;
77  /** @} */
78 
79  /**
80  * @name State variables
81  * @{
82  */
86  ///l_APrev and l_A
87  int e_a[2];
88  ///Chirp factors
90  ///QMF values of the original signal
91  INTFLOAT W[2][32][32][2];
92  ///QMF output of the HF adjustor
93  int Ypos;
94  DECLARE_ALIGNED(16, INTFLOAT, Y)[2][38][64][2];
96  AAC_FLOAT q_temp[42][48];
98  ///Envelope scalefactors
100  ///Noise scalefactors
102  ///Envelope time borders
104  ///Envelope time border of the last envelope of the previous frame
106  ///Noise time borders
108  unsigned f_indexnoise;
109  unsigned f_indexsine;
110  /** @} */
111 } SBRData;
112 
114 
115 /**
116  * aacsbr functions pointers
117  */
118 typedef struct AACSBRContext {
120  INTFLOAT X_low[32][40][2], const INTFLOAT W[2][32][32][2],
121  int buf_idx);
122  void (*sbr_hf_assemble)(INTFLOAT Y1[38][64][2],
123  const INTFLOAT X_high[64][40][2],
124  SpectralBandReplication *sbr, SBRData *ch_data,
125  const int e_a[2]);
126  int (*sbr_x_gen)(SpectralBandReplication *sbr, INTFLOAT X[2][38][64],
127  const INTFLOAT Y0[38][64][2], const INTFLOAT Y1[38][64][2],
128  const INTFLOAT X_low[32][40][2], int ch);
130  INTFLOAT (*alpha0)[2], INTFLOAT (*alpha1)[2],
131  const INTFLOAT X_low[32][40][2], int k0);
132 } AACSBRContext;
133 
134 /**
135  * Spectral Band Replication
136  */
139  int start;
140  int id_aac;
141  int reset;
144  /**
145  * @name Variables associated with bs_header_extra_2
146  * @{
147  */
152  /** @} */
153  unsigned bs_coupling;
154  AAC_SIGNE k[5]; ///< k0, k1, k2
155  ///kx', and kx respectively, kx is the first QMF subband where SBR is used.
156  ///kx' is its value from the previous frame
158  ///M' and M respectively, M is the number of QMF subbands that use SBR.
160  unsigned kx_and_m_pushed;
161  ///The number of frequency bands in f_master
165  ///N_Low and N_High respectively, the number of frequency bands for low and high resolution
167  ///Number of noise floor bands
169  ///Number of limiter bands
171  ///The master QMF frequency grouping
172  uint16_t f_master[49];
173  ///Frequency borders for low resolution SBR
174  uint16_t f_tablelow[25];
175  ///Frequency borders for high resolution SBR
176  uint16_t f_tablehigh[49];
177  ///Frequency borders for noise floors
178  uint16_t f_tablenoise[6];
179  ///Frequency borders for the limiter
180  uint16_t f_tablelim[30];
184  ///QMF low frequency input to the HF generator
185  DECLARE_ALIGNED(16, INTFLOAT, X_low)[32][40][2];
186  ///QMF output of the HF generator
187  DECLARE_ALIGNED(16, INTFLOAT, X_high)[64][40][2];
188  ///QMF values of the reconstructed signal
189  DECLARE_ALIGNED(16, INTFLOAT, X)[2][2][38][64];
190  ///Zeroth coefficient used to filter the subband signals
192  ///First coefficient used to filter the subband signals
194  ///Dequantized envelope scalefactors, remapped
196  ///Dequantized noise scalefactors, remapped
198  ///Sinusoidal presence, remapped
200  ///Estimated envelope
202  ///Amplitude adjusted noise scalefactors
203  AAC_FLOAT q_m[7][48];
204  ///Sinusoidal levels
205  AAC_FLOAT s_m[7][48];
206  AAC_FLOAT gain[7][48];
212 };
213 
214 #endif /* AVCODEC_SBR_H */
uint8_t s_indexmapped[8][48]
Definition: sbr.h:97
unsigned bs_add_harmonic_flag
Definition: sbr.h:68
float alpha1[64][2]
First coefficient used to filter the subband signals.
Definition: sbr.h:193
unsigned bs_smoothing_mode
Definition: sbr.h:151
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
INTFLOAT bw_array[5]
Chirp factors.
Definition: sbr.h:89
float Y[2][38][64][2]
Definition: sbr.h:94
float X[2][2][38][64]
QMF values of the reconstructed signal.
Definition: sbr.h:189
int e_a[2]
l_APrev and l_A
Definition: sbr.h:87
#define DECLARE_ALIGNED(n, t, v)
Definition: mem.h:53
AAC_SIGNE kx[2]
kx', and kx respectively, kx is the first QMF subband where SBR is used.
Definition: sbr.h:157
void(* sbr_hf_assemble)(INTFLOAT Y1[38][64][2], const INTFLOAT X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data, const int e_a[2])
Definition: sbr.h:122
int(* sbr_x_gen)(SpectralBandReplication *sbr, INTFLOAT X[2][38][64], const INTFLOAT Y0[38][64][2], const INTFLOAT Y1[38][64][2], const INTFLOAT X_low[32][40][2], int ch)
Definition: sbr.h:126
FFTContext mdct
Definition: sbr.h:209
AAC_FLOAT gain[7][48]
Definition: sbr.h:206
uint8_t bs_xover_band
Definition: sbr.h:45
SpectrumParameters spectrum_params
Definition: sbr.h:142
float qmf_filter_scratch[5][64]
Definition: sbr.h:207
unsigned kx_and_m_pushed
Definition: sbr.h:160
AAC_SIGNE num_patches
Definition: sbr.h:181
uint8_t
AAC_FLOAT noise_facs[3][5]
Noise scalefactors.
Definition: sbr.h:101
AAC_SIGNE n_lim
Number of limiter bands.
Definition: sbr.h:170
#define INTFLOAT
Definition: aac_defines.h:85
uint16_t f_tablehigh[49]
Frequency borders for high resolution SBR.
Definition: sbr.h:176
AAC_SIGNE bs_num_noise
Definition: sbr.h:71
uint8_t bs_df_noise[2]
Definition: sbr.h:73
void(* sbr_hf_inverse_filter)(SBRDSPContext *dsp, INTFLOAT(*alpha0)[2], INTFLOAT(*alpha1)[2], const INTFLOAT X_low[32][40][2], int k0)
Definition: sbr.h:129
uint8_t patch_num_subbands[6]
Definition: sbr.h:182
uint16_t f_tablenoise[6]
Frequency borders for noise floors.
Definition: sbr.h:178
uint8_t t_q[3]
Noise time borders.
Definition: sbr.h:107
uint16_t f_tablelow[25]
Frequency borders for low resolution SBR.
Definition: sbr.h:174
Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the pr...
Definition: sbr.h:42
AAC_SIGNE k[5]
k0, k1, k2
Definition: sbr.h:154
AAC_SIGNE m[2]
M' and M respectively, M is the number of QMF subbands that use SBR.
Definition: sbr.h:159
INTFLOAT W[2][32][32][2]
QMF values of the original signal.
Definition: sbr.h:91
float alpha0[64][2]
Zeroth coefficient used to filter the subband signals.
Definition: sbr.h:191
unsigned bs_interpol_freq
Definition: sbr.h:150
FFTContext mdct_ana
Definition: sbr.h:208
float synthesis_filterbank_samples[SBR_SYNTHESIS_BUF_SIZE]
Definition: sbr.h:83
unsigned f_indexnoise
Definition: sbr.h:108
uint8_t t_env_num_env_old
Envelope time border of the last envelope of the previous frame.
Definition: sbr.h:105
Definition: fft.h:88
unsigned bs_amp_res
Definition: sbr.h:76
#define AAC_FLOAT
Definition: aac_defines.h:88
uint8_t bs_freq_scale
Definition: sbr.h:51
unsigned bs_limiter_gains
Definition: sbr.h:149
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
AAC_FLOAT e_origmapped[7][48]
Dequantized envelope scalefactors, remapped.
Definition: sbr.h:195
uint8_t s_mapped[7][48]
Sinusoidal presence, remapped.
Definition: sbr.h:199
float X_low[32][40][2]
QMF low frequency input to the HF generator.
Definition: sbr.h:185
uint8_t bs_freq_res[7]
Definition: sbr.h:70
AAC_FLOAT q_temp[42][48]
Definition: sbr.h:96
AAC_SIGNE bs_num_env
Definition: sbr.h:69
#define SBR_SYNTHESIS_BUF_SIZE
Definition: sbr.h:57
AAC_FLOAT q_mapped[7][48]
Dequantized noise scalefactors, remapped.
Definition: sbr.h:197
float X_high[64][40][2]
QMF output of the HF generator.
Definition: sbr.h:187
#define W(a, i, v)
Definition: jpegls.h:122
int synthesis_filterbank_samples_offset
Definition: sbr.h:85
AAC_FLOAT q_m[7][48]
Amplitude adjusted noise scalefactors.
Definition: sbr.h:203
AAC_FLOAT env_facs[6][48]
Envelope scalefactors.
Definition: sbr.h:99
uint8_t bs_noise_bands
Definition: sbr.h:53
main AAC context
Definition: aac.h:288
AAC_SIGNE n_master
The number of frequency bands in f_master.
Definition: sbr.h:162
AACSBRContext c
Definition: sbr.h:211
AAC_FLOAT e_curr[7][48]
Estimated envelope.
Definition: sbr.h:201
uint8_t bs_stop_freq
Definition: sbr.h:44
uint16_t f_master[49]
The master QMF frequency grouping.
Definition: sbr.h:172
uint8_t bs_invf_mode[2][5]
Definition: sbr.h:74
int(* sbr_lf_gen)(AACContext *ac, SpectralBandReplication *sbr, INTFLOAT X_low[32][40][2], const INTFLOAT W[2][32][32][2], int buf_idx)
Definition: sbr.h:119
float analysis_filterbank_samples[1312]
Definition: sbr.h:84
unsigned f_indexsine
Definition: sbr.h:109
uint8_t patch_start_subband[6]
Definition: sbr.h:183
uint8_t t_env[8]
Envelope time borders.
Definition: sbr.h:103
aacsbr functions pointers
Definition: sbr.h:118
AAC_FLOAT s_m[7][48]
Sinusoidal levels.
Definition: sbr.h:205
uint16_t f_tablelim[30]
Frequency borders for the limiter.
Definition: sbr.h:180
Spectral Band Replication per channel data.
Definition: sbr.h:62
unsigned bs_limiter_bands
Definition: sbr.h:148
int Ypos
QMF output of the HF adjustor.
Definition: sbr.h:93
uint8_t bs_alter_scale
Definition: sbr.h:52
unsigned bs_frame_class
Definition: sbr.h:67
uint8_t bs_df_env[5]
Definition: sbr.h:72
SBRDSPContext dsp
Definition: sbr.h:210
#define AAC_SIGNE
Definition: aac_defines.h:89
float g_temp[42][48]
Definition: sbr.h:95
AAC_SIGNE n_q
Number of noise floor bands.
Definition: sbr.h:168
unsigned bs_coupling
Definition: sbr.h:153
Spectral Band Replication.
Definition: sbr.h:137
uint8_t bs_add_harmonic[48]
Definition: sbr.h:75
PSContext ps
Definition: sbr.h:164
uint8_t bs_start_freq
Definition: sbr.h:43
AAC_SIGNE n[2]
N_Low and N_High respectively, the number of frequency bands for low and high resolution.
Definition: sbr.h:166