• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavcodec/ac3.h

Go to the documentation of this file.
00001 /*
00002  * Common code between the AC-3 encoder and decoder
00003  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
00004  *
00005  * This file is part of Libav.
00006  *
00007  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00027 #ifndef AVCODEC_AC3_H
00028 #define AVCODEC_AC3_H
00029 
00030 #define AC3_MAX_CODED_FRAME_SIZE 3840 /* in bytes */
00031 #define AC3_MAX_CHANNELS 7            
00032 #define CPL_CH 0                      
00034 #define AC3_MAX_COEFS   256
00035 #define AC3_BLOCK_SIZE  256
00036 #define AC3_MAX_BLOCKS    6
00037 #define AC3_FRAME_SIZE (AC3_MAX_BLOCKS * 256)
00038 #define AC3_WINDOW_SIZE (AC3_BLOCK_SIZE * 2)
00039 #define AC3_CRITICAL_BANDS 50
00040 #define AC3_MAX_CPL_BANDS  18
00041 
00042 #include "ac3tab.h"
00043 
00044 /* exponent encoding strategy */
00045 #define EXP_REUSE 0
00046 #define EXP_NEW   1
00047 
00048 #define EXP_D15   1
00049 #define EXP_D25   2
00050 #define EXP_D45   3
00051 
00052 /* pre-defined gain values */
00053 #define LEVEL_PLUS_3DB          1.4142135623730950
00054 #define LEVEL_PLUS_1POINT5DB    1.1892071150027209
00055 #define LEVEL_MINUS_1POINT5DB   0.8408964152537145
00056 #define LEVEL_MINUS_3DB         0.7071067811865476
00057 #define LEVEL_MINUS_4POINT5DB   0.5946035575013605
00058 #define LEVEL_MINUS_6DB         0.5000000000000000
00059 #define LEVEL_MINUS_9DB         0.3535533905932738
00060 #define LEVEL_ZERO              0.0000000000000000
00061 #define LEVEL_ONE               1.0000000000000000
00062 
00064 typedef enum {
00065     DBA_REUSE = 0,
00066     DBA_NEW,
00067     DBA_NONE,
00068     DBA_RESERVED
00069 } AC3DeltaStrategy;
00070 
00072 typedef enum {
00073     AC3_CHMODE_DUALMONO = 0,
00074     AC3_CHMODE_MONO,
00075     AC3_CHMODE_STEREO,
00076     AC3_CHMODE_3F,
00077     AC3_CHMODE_2F1R,
00078     AC3_CHMODE_3F1R,
00079     AC3_CHMODE_2F2R,
00080     AC3_CHMODE_3F2R
00081 } AC3ChannelMode;
00082 
00083 typedef struct AC3BitAllocParameters {
00084     int sr_code;
00085     int sr_shift;
00086     int slow_gain, slow_decay, fast_decay, db_per_bit, floor;
00087     int cpl_fast_leak, cpl_slow_leak;
00088 } AC3BitAllocParameters;
00089 
00094 typedef struct {
00098     uint16_t sync_word;
00099     uint16_t crc1;
00100     uint8_t sr_code;
00101     uint8_t bitstream_id;
00102     uint8_t bitstream_mode;
00103     uint8_t channel_mode;
00104     uint8_t lfe_on;
00105     uint8_t frame_type;
00106     int substreamid;                        
00107     int center_mix_level;                   
00108     int surround_mix_level;                 
00109     uint16_t channel_map;
00110     int num_blocks;                         
00111 
00116     uint8_t sr_shift;
00117     uint16_t sample_rate;
00118     uint32_t bit_rate;
00119     uint8_t channels;
00120     uint16_t frame_size;
00121     uint64_t channel_layout;
00123 } AC3HeaderInfo;
00124 
00125 typedef enum {
00126     EAC3_FRAME_TYPE_INDEPENDENT = 0,
00127     EAC3_FRAME_TYPE_DEPENDENT,
00128     EAC3_FRAME_TYPE_AC3_CONVERT,
00129     EAC3_FRAME_TYPE_RESERVED
00130 } EAC3FrameType;
00131 
00132 void ff_ac3_common_init(void);
00133 
00148 void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
00149                                int16_t *band_psd);
00150 
00173 int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
00174                                int start, int end, int fast_gain, int is_lfe,
00175                                int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
00176                                uint8_t *dba_lengths, uint8_t *dba_values,
00177                                int16_t *mask);
00178 
00179 #endif /* AVCODEC_AC3_H */
Generated on Thu Jul 11 2013 15:38:18 for Libav by doxygen 1.7.1