ac3dec.h

Go to the documentation of this file.
00001 /*
00002  * Common code between AC3 and E-AC3 decoder
00003  * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com>
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00022 /**
00023  * @file ac3.h
00024  * Common code between AC3 and E-AC3 decoder.
00025  */
00026 
00027 #ifndef FFMPEG_AC3DEC_H
00028 #define FFMPEG_AC3DEC_H
00029 
00030 #include "libavutil/random.h"
00031 #include "ac3tab.h"
00032 #include "ac3.h"
00033 #include "bitstream.h"
00034 #include "dsputil.h"
00035 
00036 /* override ac3.h to include coupling channel */
00037 #undef AC3_MAX_CHANNELS
00038 #define AC3_MAX_CHANNELS 7
00039 #define CPL_CH 0
00040 
00041 #define AC3_OUTPUT_LFEON  8
00042 
00043 #define AC3_MAX_COEFS   256
00044 #define AC3_BLOCK_SIZE  256
00045 #define MAX_BLOCKS        6
00046 
00047 typedef struct {
00048     AVCodecContext *avctx;                  ///< parent context
00049     GetBitContext gbc;                      ///< bitstream reader
00050     uint8_t *input_buffer;                  ///< temp buffer to prevent overread
00051 
00052 ///@defgroup bsi bit stream information
00053 ///@{
00054     int frame_type;                         ///< frame type                             (strmtyp)
00055     int substreamid;                        ///< substream identification
00056     int frame_size;                         ///< current frame size, in bytes
00057     int bit_rate;                           ///< stream bit rate, in bits-per-second
00058     int sample_rate;                        ///< sample frequency, in Hz
00059     int num_blocks;                         ///< number of audio blocks
00060     int channel_mode;                       ///< channel mode                           (acmod)
00061     int lfe_on;                             ///< lfe channel in use
00062     int channel_map;                        ///< custom channel map
00063     int center_mix_level;                   ///< Center mix level index
00064     int surround_mix_level;                 ///< Surround mix level index
00065     int eac3;                               ///< indicates if current frame is E-AC-3
00066 ///@}
00067 
00068 ///@defgroup audfrm frame syntax parameters
00069     int snr_offset_strategy;                ///< SNR offset strategy                    (snroffststr)
00070     int block_switch_syntax;                ///< block switch syntax enabled            (blkswe)
00071     int dither_flag_syntax;                 ///< dither flag syntax enabled             (dithflage)
00072     int bit_allocation_syntax;              ///< bit allocation model syntax enabled    (bamode)
00073     int fast_gain_syntax;                   ///< fast gain codes enabled                (frmfgaincode)
00074     int dba_syntax;                         ///< delta bit allocation syntax enabled    (dbaflde)
00075     int skip_syntax;                        ///< skip field syntax enabled              (skipflde)
00076  ///@}
00077 
00078 ///@defgroup cpl standard coupling
00079     int cpl_in_use[MAX_BLOCKS];             ///< coupling in use                        (cplinu)
00080     int cpl_strategy_exists[MAX_BLOCKS];    ///< coupling strategy exists               (cplstre)
00081     int channel_in_cpl[AC3_MAX_CHANNELS];   ///< channel in coupling                    (chincpl)
00082     int phase_flags_in_use;                 ///< phase flags in use                     (phsflginu)
00083     int phase_flags[18];                    ///< phase flags                            (phsflg)
00084     int num_cpl_subbands;                   ///< number of coupling sub bands           (ncplsubnd)
00085     int num_cpl_bands;                      ///< number of coupling bands               (ncplbnd)
00086     int cpl_band_struct[18];                ///< coupling band structure                (cplbndstrc)
00087     int firstchincpl;                       ///< first channel in coupling
00088     int first_cpl_coords[AC3_MAX_CHANNELS]; ///< first coupling coordinates states      (firstcplcos)
00089     int cpl_coords[AC3_MAX_CHANNELS][18];   ///< coupling coordinates                   (cplco)
00090 ///@}
00091 
00092 ///@defgroup aht adaptive hybrid transform
00093     int channel_uses_aht[AC3_MAX_CHANNELS];                 ///< channel AHT in use     (chahtinu)
00094     int pre_mantissa[6][AC3_MAX_CHANNELS][AC3_MAX_COEFS];   ///< pre-IDCT mantissas
00095 ///@}
00096 
00097 ///@defgroup channel channel
00098     int fbw_channels;                           ///< number of full-bandwidth channels
00099     int channels;                               ///< number of total channels
00100     int lfe_ch;                                 ///< index of LFE channel
00101     float downmix_coeffs[AC3_MAX_CHANNELS][2];  ///< stereo downmix coefficients
00102     float downmix_coeff_adjust[2];              ///< adjustment needed for each output channel when downmixing
00103     int downmixed;                              ///< indicates if coeffs are currently downmixed
00104     int output_mode;                            ///< output channel configuration
00105     int out_channels;                           ///< number of output channels
00106 ///@}
00107 
00108 ///@defgroup dynrng dynamic range
00109     float dynamic_range[2];                 ///< dynamic range
00110 ///@}
00111 
00112 ///@defgroup bandwidth bandwidth
00113     int start_freq[AC3_MAX_CHANNELS];       ///< start frequency bin                    (strtmant)
00114     int end_freq[AC3_MAX_CHANNELS];         ///< end frequency bin                      (endmant)
00115 ///@}
00116 
00117 ///@defgroup rematrixing rematrixing
00118     int num_rematrixing_bands;              ///< number of rematrixing bands            (nrematbnd)
00119     int rematrixing_flags[4];               ///< rematrixing flags                      (rematflg)
00120 ///@}
00121 
00122 ///@defgroup exponents exponents
00123     int num_exp_groups[AC3_MAX_CHANNELS];           ///< Number of exponent groups      (nexpgrp)
00124     int8_t dexps[AC3_MAX_CHANNELS][AC3_MAX_COEFS];  ///< decoded exponents
00125     int exp_strategy[MAX_BLOCKS][AC3_MAX_CHANNELS]; ///< exponent strategies            (expstr)
00126 ///@}
00127 
00128 ///@defgroup bitalloc bit allocation
00129     AC3BitAllocParameters bit_alloc_params;         ///< bit allocation parameters
00130     int first_cpl_leak;                             ///< first coupling leak state      (firstcplleak)
00131     int snr_offset[AC3_MAX_CHANNELS];               ///< signal-to-noise ratio offsets  (snroffst)
00132     int fast_gain[AC3_MAX_CHANNELS];                ///< fast gain values/SMR's         (fgain)
00133     uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS];   ///< bit allocation pointers
00134     int16_t psd[AC3_MAX_CHANNELS][AC3_MAX_COEFS];   ///< scaled exponents
00135     int16_t band_psd[AC3_MAX_CHANNELS][50];         ///< interpolated exponents
00136     int16_t mask[AC3_MAX_CHANNELS][50];             ///< masking curve values
00137     int dba_mode[AC3_MAX_CHANNELS];                 ///< delta bit allocation mode
00138     int dba_nsegs[AC3_MAX_CHANNELS];                ///< number of delta segments
00139     uint8_t dba_offsets[AC3_MAX_CHANNELS][8];       ///< delta segment offsets
00140     uint8_t dba_lengths[AC3_MAX_CHANNELS][8];       ///< delta segment lengths
00141     uint8_t dba_values[AC3_MAX_CHANNELS][8];        ///< delta values for each segment
00142 ///@}
00143 
00144 ///@defgroup dithering zero-mantissa dithering
00145     int dither_all;                         ///< true if all channels are dithered
00146     int dither_flag[AC3_MAX_CHANNELS];      ///< dither flags                           (dithflg)
00147     AVRandomState dith_state;               ///< for dither generation
00148 ///@}
00149 
00150 ///@defgroup imdct IMDCT
00151     int block_switch[AC3_MAX_CHANNELS];     ///< block switch flags                     (blksw)
00152     MDCTContext imdct_512;                  ///< for 512 sample IMDCT
00153     MDCTContext imdct_256;                  ///< for 256 sample IMDCT
00154 ///@}
00155 
00156 ///@defgroup opt optimization
00157     DSPContext dsp;                         ///< for optimization
00158     float add_bias;                         ///< offset for float_to_int16 conversion
00159     float mul_bias;                         ///< scaling for float_to_int16 conversion
00160 ///@}
00161 
00162     int fixed_coeffs[AC3_MAX_CHANNELS][AC3_MAX_COEFS];  ///> fixed-point transform coefficients
00163 
00164 ///@defgroup arrays aligned arrays
00165     DECLARE_ALIGNED_16(float, transform_coeffs[AC3_MAX_CHANNELS][AC3_MAX_COEFS]);   ///< transform coefficients
00166     DECLARE_ALIGNED_16(float, delay[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]);             ///< delay - added to the next block
00167     DECLARE_ALIGNED_16(float, window[AC3_BLOCK_SIZE]);                              ///< window coefficients
00168     DECLARE_ALIGNED_16(float, tmp_output[AC3_BLOCK_SIZE*2]);                        ///< temporary storage for output before windowing
00169     DECLARE_ALIGNED_16(float, tmp_imdct[AC3_BLOCK_SIZE]);                           ///< temporary storage for imdct transform
00170     DECLARE_ALIGNED_16(float, output[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]);            ///< output after imdct transform and windowing
00171     DECLARE_ALIGNED_16(short, int_output[AC3_MAX_CHANNELS-1][AC3_BLOCK_SIZE]);      ///< final 16-bit integer output
00172 ///@}
00173 } AC3DecodeContext;
00174 
00175 #endif /* FFMPEG_AC3DEC_H */

Generated on Sat Oct 11 19:44:26 2008 for libextractor by  doxygen 1.5.1