comparison ac3dec.h @ 11559:444f4b594fdb libavcodec

Add spectral extension to the E-AC-3 decoder. Original patch by Justin, updated and resubmitted by Christophe Gisquet, christophe D gisquet A gmail
author cehoyos
date Tue, 30 Mar 2010 22:09:14 +0000
parents 84963c795459
children 7dd2a45249a9
comparison
equal deleted inserted replaced
11558:44c5c540722c 11559:444f4b594fdb
20 */ 20 */
21 21
22 /** 22 /**
23 * @file libavcodec/ac3.h 23 * @file libavcodec/ac3.h
24 * Common code between the AC-3 and E-AC-3 decoders. 24 * Common code between the AC-3 and E-AC-3 decoders.
25 *
26 * Summary of MDCT Coefficient Grouping:
27 * The individual MDCT coefficient indices are often referred to in the
28 * (E-)AC-3 specification as frequency bins. These bins are grouped together
29 * into subbands of 12 coefficients each. The subbands are grouped together
30 * into bands as defined in the bitstream by the band structures, which
31 * determine the number of bands and the size of each band. The full spectrum
32 * of 256 frequency bins is divided into 1 DC bin + 21 subbands = 253 bins.
33 * This system of grouping coefficients is used for channel bandwidth, stereo
34 * rematrixing, channel coupling, enhanced coupling, and spectral extension.
35 *
36 * +-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-+
37 * |1| |12| | [12|12|12|12] | | | | | | | | | | | | |3|
38 * +-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-+
39 * ~~~ ~~~~ ~~~~~~~~~~~~~ ~~~
40 * | | | |
41 * | | | 3 unused frequency bins--+
42 * | | |
43 * | | +--1 band containing 4 subbands
44 * | |
45 * | +--1 subband of 12 frequency bins
46 * |
47 * +--DC frequency bin
25 */ 48 */
26 49
27 #ifndef AVCODEC_AC3DEC_H 50 #ifndef AVCODEC_AC3DEC_H
28 #define AVCODEC_AC3DEC_H 51 #define AVCODEC_AC3DEC_H
29 52
41 #define AC3_OUTPUT_LFEON 8 64 #define AC3_OUTPUT_LFEON 8
42 65
43 #define AC3_MAX_COEFS 256 66 #define AC3_MAX_COEFS 256
44 #define AC3_BLOCK_SIZE 256 67 #define AC3_BLOCK_SIZE 256
45 #define MAX_BLOCKS 6 68 #define MAX_BLOCKS 6
69 #define SPX_MAX_BANDS 17
46 70
47 typedef struct { 71 typedef struct {
48 AVCodecContext *avctx; ///< parent context 72 AVCodecContext *avctx; ///< parent context
49 GetBitContext gbc; ///< bitstream reader 73 GetBitContext gbc; ///< bitstream reader
50 uint8_t *input_buffer; ///< temp buffer to prevent overread 74 uint8_t *input_buffer; ///< temp buffer to prevent overread
87 int firstchincpl; ///< first channel in coupling 111 int firstchincpl; ///< first channel in coupling
88 int first_cpl_coords[AC3_MAX_CHANNELS]; ///< first coupling coordinates states (firstcplcos) 112 int first_cpl_coords[AC3_MAX_CHANNELS]; ///< first coupling coordinates states (firstcplcos)
89 int cpl_coords[AC3_MAX_CHANNELS][18]; ///< coupling coordinates (cplco) 113 int cpl_coords[AC3_MAX_CHANNELS][18]; ///< coupling coordinates (cplco)
90 ///@} 114 ///@}
91 115
116 ///@defgroup spx spectral extension
117 ///@{
118 int spx_in_use; ///< spectral extension in use (spxinu)
119 uint8_t channel_uses_spx[AC3_MAX_CHANNELS]; ///< channel uses spectral extension (chinspx)
120 int8_t spx_atten_code[AC3_MAX_CHANNELS]; ///< spx attenuation code (spxattencod)
121 int spx_src_start_freq; ///< spx start frequency bin
122 int spx_dst_end_freq; ///< spx end frequency bin
123 int spx_dst_start_freq; ///< spx starting frequency bin for copying (copystartmant)
124 ///< the copy region ends at the start of the spx region.
125 int num_spx_bands; ///< number of spx bands (nspxbnds)
126 uint8_t spx_band_sizes[SPX_MAX_BANDS]; ///< number of bins in each spx band
127 uint8_t first_spx_coords[AC3_MAX_CHANNELS]; ///< first spx coordinates states (firstspxcos)
128 float spx_noise_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS]; ///< spx noise blending factor (nblendfact)
129 float spx_signal_blend[AC3_MAX_CHANNELS][SPX_MAX_BANDS];///< spx signal blending factor (sblendfact)
130 ///@}
131
92 ///@defgroup aht adaptive hybrid transform 132 ///@defgroup aht adaptive hybrid transform
93 int channel_uses_aht[AC3_MAX_CHANNELS]; ///< channel AHT in use (chahtinu) 133 int channel_uses_aht[AC3_MAX_CHANNELS]; ///< channel AHT in use (chahtinu)
94 int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][MAX_BLOCKS]; ///< pre-IDCT mantissas 134 int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][MAX_BLOCKS]; ///< pre-IDCT mantissas
95 ///@} 135 ///@}
96 136
180 void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch); 220 void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch);
181 221
182 void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2], 222 void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2],
183 int out_ch, int in_ch, int len); 223 int out_ch, int in_ch, int len);
184 224
225 /**
226 * Apply spectral extension to each channel by copying lower frequency
227 * coefficients to higher frequency bins and applying side information to
228 * approximate the original high frequency signal.
229 */
230 void ff_eac3_apply_spectral_extension(AC3DecodeContext *s);
231
185 #endif /* AVCODEC_AC3DEC_H */ 232 #endif /* AVCODEC_AC3DEC_H */