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