FFmpeg
 All Data Structures 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;
69  unsigned bs_num_env;
71  unsigned bs_num_noise;
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
89  float bw_array[5];
90  ///QMF values of the original signal
91  float W[2][32][32][2];
92  ///QMF output of the HF adjustor
93  int Ypos;
94  DECLARE_ALIGNED(16, float, Y)[2][38][64][2];
95  DECLARE_ALIGNED(16, float, g_temp)[42][48];
96  float q_temp[42][48];
98  ///Envelope scalefactors
99  float env_facs[6][48];
100  ///Noise scalefactors
101  float noise_facs[3][5];
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  float X_low[32][40][2], const float W[2][32][32][2],
121  int buf_idx);
122  void (*sbr_hf_assemble)(float Y1[38][64][2],
123  const float X_high[64][40][2],
124  SpectralBandReplication *sbr, SBRData *ch_data,
125  const int e_a[2]);
126  int (*sbr_x_gen)(SpectralBandReplication *sbr, float X[2][38][64],
127  const float Y0[38][64][2], const float Y1[38][64][2],
128  const float X_low[32][40][2], int ch);
130  float (*alpha0)[2], float (*alpha1)[2],
131  const float X_low[32][40][2], int k0);
132 } AACSBRContext;
133 
134 /**
135  * Spectral Band Replication
136  */
139  int start;
140  int reset;
143  /**
144  * @name Variables associated with bs_header_extra_2
145  * @{
146  */
151  /** @} */
152  unsigned bs_coupling;
153  unsigned k[5]; ///< k0, k1, k2
154  ///kx', and kx respectively, kx is the first QMF subband where SBR is used.
155  ///kx' is its value from the previous frame
156  unsigned kx[2];
157  ///M' and M respectively, M is the number of QMF subbands that use SBR.
158  unsigned m[2];
159  unsigned kx_and_m_pushed;
160  ///The number of frequency bands in f_master
161  unsigned n_master;
164  ///N_Low and N_High respectively, the number of frequency bands for low and high resolution
165  unsigned n[2];
166  ///Number of noise floor bands
167  unsigned n_q;
168  ///Number of limiter bands
169  unsigned n_lim;
170  ///The master QMF frequency grouping
171  uint16_t f_master[49];
172  ///Frequency borders for low resolution SBR
173  uint16_t f_tablelow[25];
174  ///Frequency borders for high resolution SBR
175  uint16_t f_tablehigh[49];
176  ///Frequency borders for noise floors
177  uint16_t f_tablenoise[6];
178  ///Frequency borders for the limiter
179  uint16_t f_tablelim[30];
180  unsigned num_patches;
183  ///QMF low frequency input to the HF generator
184  DECLARE_ALIGNED(16, float, X_low)[32][40][2];
185  ///QMF output of the HF generator
186  DECLARE_ALIGNED(16, float, X_high)[64][40][2];
187  ///QMF values of the reconstructed signal
188  DECLARE_ALIGNED(16, float, X)[2][2][38][64];
189  ///Zeroth coefficient used to filter the subband signals
190  DECLARE_ALIGNED(16, float, alpha0)[64][2];
191  ///First coefficient used to filter the subband signals
192  DECLARE_ALIGNED(16, float, alpha1)[64][2];
193  ///Dequantized envelope scalefactors, remapped
194  float e_origmapped[7][48];
195  ///Dequantized noise scalefactors, remapped
196  float q_mapped[7][48];
197  ///Sinusoidal presence, remapped
199  ///Estimated envelope
200  float e_curr[7][48];
201  ///Amplitude adjusted noise scalefactors
202  float q_m[7][48];
203  ///Sinusoidal levels
204  float s_m[7][48];
205  float gain[7][48];
211 };
212 
213 #endif /* AVCODEC_SBR_H */