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;
00104 } AC3HeaderInfo;
00105
00106 typedef enum {
00107 EAC3_FRAME_TYPE_INDEPENDENT = 0,
00108 EAC3_FRAME_TYPE_DEPENDENT,
00109 EAC3_FRAME_TYPE_AC3_CONVERT,
00110 EAC3_FRAME_TYPE_RESERVED
00111 } EAC3FrameType;
00112
00113 void ac3_common_init(void);
00114
00129 void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
00130 int16_t *band_psd);
00131
00154 int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
00155 int start, int end, int fast_gain, int is_lfe,
00156 int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
00157 uint8_t *dba_lengths, uint8_t *dba_values,
00158 int16_t *mask);
00159
00175 void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
00176 int snr_offset, int floor,
00177 const uint8_t *bap_tab, uint8_t *bap);
00178
00179 void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
00180 int8_t *exp, int start, int end,
00181 int snr_offset, int fast_gain, int is_lfe,
00182 int dba_mode, int dba_nsegs,
00183 uint8_t *dba_offsets, uint8_t *dba_lengths,
00184 uint8_t *dba_values);
00185
00186 #endif