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 /**
38  * Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the previous header.
39  */
40 typedef struct SpectrumParameters {
44 
45  /**
46  * @name Variables associated with bs_header_extra_1
47  * @{
48  */
52  /** @} */
54 
55 #define SBR_SYNTHESIS_BUF_SIZE ((1280-128)*2)
56 
57 /**
58  * Spectral Band Replication per channel data
59  */
60 typedef struct SBRData {
61  /**
62  * @name Main bitstream data variables
63  * @{
64  */
65  unsigned bs_frame_class;
67  unsigned bs_num_env;
69  unsigned bs_num_noise;
74  unsigned bs_amp_res;
75  /** @} */
76 
77  /**
78  * @name State variables
79  * @{
80  */
84  ///l_APrev and l_A
85  int e_a[2];
86  ///Chirp factors
87  float bw_array[5];
88  ///QMF values of the original signal
89  float W[2][32][32][2];
90  ///QMF output of the HF adjustor
91  int Ypos;
92  DECLARE_ALIGNED(16, float, Y)[2][38][64][2];
93  DECLARE_ALIGNED(16, float, g_temp)[42][48];
94  float q_temp[42][48];
96  ///Envelope scalefactors
97  float env_facs[6][48];
98  ///Noise scalefactors
99  float noise_facs[3][5];
100  ///Envelope time borders
102  ///Envelope time border of the last envelope of the previous frame
104  ///Noise time borders
106  unsigned f_indexnoise;
107  unsigned f_indexsine;
108  /** @} */
109 } SBRData;
110 
111 /**
112  * Spectral Band Replication
113  */
114 typedef struct SpectralBandReplication {
116  int start;
117  int reset;
120  /**
121  * @name Variables associated with bs_header_extra_2
122  * @{
123  */
128  /** @} */
129  unsigned bs_coupling;
130  unsigned k[5]; ///< k0, k1, k2
131  ///kx', and kx respectively, kx is the first QMF subband where SBR is used.
132  ///kx' is its value from the previous frame
133  unsigned kx[2];
134  ///M' and M respectively, M is the number of QMF subbands that use SBR.
135  unsigned m[2];
136  unsigned kx_and_m_pushed;
137  ///The number of frequency bands in f_master
138  unsigned n_master;
141  ///N_Low and N_High respectively, the number of frequency bands for low and high resolution
142  unsigned n[2];
143  ///Number of noise floor bands
144  unsigned n_q;
145  ///Number of limiter bands
146  unsigned n_lim;
147  ///The master QMF frequency grouping
148  uint16_t f_master[49];
149  ///Frequency borders for low resolution SBR
150  uint16_t f_tablelow[25];
151  ///Frequency borders for high resolution SBR
152  uint16_t f_tablehigh[49];
153  ///Frequency borders for noise floors
154  uint16_t f_tablenoise[6];
155  ///Frequency borders for the limiter
156  uint16_t f_tablelim[30];
157  unsigned num_patches;
160  ///QMF low frequency input to the HF generator
161  DECLARE_ALIGNED(16, float, X_low)[32][40][2];
162  ///QMF output of the HF generator
163  DECLARE_ALIGNED(16, float, X_high)[64][40][2];
164  ///QMF values of the reconstructed signal
165  DECLARE_ALIGNED(16, float, X)[2][2][38][64];
166  ///Zeroth coefficient used to filter the subband signals
167  DECLARE_ALIGNED(16, float, alpha0)[64][2];
168  ///First coefficient used to filter the subband signals
169  DECLARE_ALIGNED(16, float, alpha1)[64][2];
170  ///Dequantized envelope scalefactors, remapped
171  float e_origmapped[7][48];
172  ///Dequantized noise scalefactors, remapped
173  float q_mapped[7][48];
174  ///Sinusoidal presence, remapped
176  ///Estimated envelope
177  float e_curr[7][48];
178  ///Amplitude adjusted noise scalefactors
179  float q_m[7][48];
180  ///Sinusoidal levels
181  float s_m[7][48];
182  float gain[7][48];
188 
189 #endif /* AVCODEC_SBR_H */