00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #ifndef AVCODEC_AC3_H
00028 #define AVCODEC_AC3_H
00029
00030 #include "ac3tab.h"
00031
00032 #define AC3_MAX_CODED_FRAME_SIZE 3840
00033 #define AC3_MAX_CHANNELS 6
00034
00035 #define NB_BLOCKS 6
00036 #define AC3_FRAME_SIZE (NB_BLOCKS * 256)
00037
00038
00039 #define EXP_REUSE 0
00040 #define EXP_NEW 1
00041
00042 #define EXP_D15 1
00043 #define EXP_D25 2
00044 #define EXP_D45 3
00045
00047 typedef enum {
00048 DBA_REUSE = 0,
00049 DBA_NEW,
00050 DBA_NONE,
00051 DBA_RESERVED
00052 } AC3DeltaStrategy;
00053
00055 typedef enum {
00056 AC3_CHMODE_DUALMONO = 0,
00057 AC3_CHMODE_MONO,
00058 AC3_CHMODE_STEREO,
00059 AC3_CHMODE_3F,
00060 AC3_CHMODE_2F1R,
00061 AC3_CHMODE_3F1R,
00062 AC3_CHMODE_2F2R,
00063 AC3_CHMODE_3F2R
00064 } AC3ChannelMode;
00065
00066 typedef struct AC3BitAllocParameters {
00067 int sr_code;
00068 int sr_shift;
00069 int slow_gain, slow_decay, fast_decay, db_per_bit, floor;
00070 int cpl_fast_leak, cpl_slow_leak;
00071 } AC3BitAllocParameters;
00072
00077 typedef struct {
00081 uint16_t sync_word;
00082 uint16_t crc1;
00083 uint8_t sr_code;
00084 uint8_t bitstream_id;
00085 uint8_t channel_mode;
00086 uint8_t lfe_on;
00087 uint8_t frame_type;
00088 int substreamid;
00089 int center_mix_level;
00090 int surround_mix_level;
00091 uint16_t channel_map;
00092 int num_blocks;
00093
00098 uint8_t sr_shift;
00099 uint16_t sample_rate;
00100 uint32_t bit_rate;
00101 uint8_t channels;
00102 uint16_t frame_size;
00103 int64_t channel_layout;
00105 } AC3HeaderInfo;
00106
00107 typedef enum {
00108 EAC3_FRAME_TYPE_INDEPENDENT = 0,
00109 EAC3_FRAME_TYPE_DEPENDENT,
00110 EAC3_FRAME_TYPE_AC3_CONVERT,
00111 EAC3_FRAME_TYPE_RESERVED
00112 } EAC3FrameType;
00113
00114 void ac3_common_init(void);
00115
00130 void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
00131 int16_t *band_psd);
00132
00155 int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
00156 int start, int end, int fast_gain, int is_lfe,
00157 int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
00158 uint8_t *dba_lengths, uint8_t *dba_values,
00159 int16_t *mask);
00160
00176 void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
00177 int snr_offset, int floor,
00178 const uint8_t *bap_tab, uint8_t *bap);
00179
00180 void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
00181 int8_t *exp, int start, int end,
00182 int snr_offset, int fast_gain, int is_lfe,
00183 int dba_mode, int dba_nsegs,
00184 uint8_t *dba_offsets, uint8_t *dba_lengths,
00185 uint8_t *dba_values);
00186
00187 #endif