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 #define AC3_MAX_CODED_FRAME_SIZE 3840
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 "libavutil/opt.h"
00043 #include "avcodec.h"
00044 #include "ac3tab.h"
00045
00046
00047 #define EXP_REUSE 0
00048 #define EXP_NEW 1
00049
00050 #define EXP_D15 1
00051 #define EXP_D25 2
00052 #define EXP_D45 3
00053
00054
00055 #define LEVEL_PLUS_3DB 1.4142135623730950
00056 #define LEVEL_PLUS_1POINT5DB 1.1892071150027209
00057 #define LEVEL_MINUS_1POINT5DB 0.8408964152537145
00058 #define LEVEL_MINUS_3DB 0.7071067811865476
00059 #define LEVEL_MINUS_4POINT5DB 0.5946035575013605
00060 #define LEVEL_MINUS_6DB 0.5000000000000000
00061 #define LEVEL_MINUS_9DB 0.3535533905932738
00062 #define LEVEL_ZERO 0.0000000000000000
00063 #define LEVEL_ONE 1.0000000000000000
00064
00066 typedef enum {
00067 DBA_REUSE = 0,
00068 DBA_NEW,
00069 DBA_NONE,
00070 DBA_RESERVED
00071 } AC3DeltaStrategy;
00072
00074 typedef enum {
00075 AC3_CHMODE_DUALMONO = 0,
00076 AC3_CHMODE_MONO,
00077 AC3_CHMODE_STEREO,
00078 AC3_CHMODE_3F,
00079 AC3_CHMODE_2F1R,
00080 AC3_CHMODE_3F1R,
00081 AC3_CHMODE_2F2R,
00082 AC3_CHMODE_3F2R
00083 } AC3ChannelMode;
00084
00085 typedef struct AC3BitAllocParameters {
00086 int sr_code;
00087 int sr_shift;
00088 int slow_gain, slow_decay, fast_decay, db_per_bit, floor;
00089 int cpl_fast_leak, cpl_slow_leak;
00090 } AC3BitAllocParameters;
00091
00096 typedef struct {
00100 uint16_t sync_word;
00101 uint16_t crc1;
00102 uint8_t sr_code;
00103 uint8_t bitstream_id;
00104 uint8_t bitstream_mode;
00105 uint8_t channel_mode;
00106 uint8_t lfe_on;
00107 uint8_t frame_type;
00108 int substreamid;
00109 int center_mix_level;
00110 int surround_mix_level;
00111 uint16_t channel_map;
00112 int num_blocks;
00113
00118 uint8_t sr_shift;
00119 uint16_t sample_rate;
00120 uint32_t bit_rate;
00121 uint8_t channels;
00122 uint16_t frame_size;
00123 int64_t channel_layout;
00125 } AC3HeaderInfo;
00126
00127 typedef enum {
00128 EAC3_FRAME_TYPE_INDEPENDENT = 0,
00129 EAC3_FRAME_TYPE_DEPENDENT,
00130 EAC3_FRAME_TYPE_AC3_CONVERT,
00131 EAC3_FRAME_TYPE_RESERVED
00132 } EAC3FrameType;
00133
00137 typedef struct AC3EncOptions {
00138
00139 int dialogue_level;
00140 int bitstream_mode;
00141 float center_mix_level;
00142 float surround_mix_level;
00143 int dolby_surround_mode;
00144 int audio_production_info;
00145 int mixing_level;
00146 int room_type;
00147 int copyright;
00148 int original;
00149 int extended_bsi_1;
00150 int preferred_stereo_downmix;
00151 float ltrt_center_mix_level;
00152 float ltrt_surround_mix_level;
00153 float loro_center_mix_level;
00154 float loro_surround_mix_level;
00155 int extended_bsi_2;
00156 int dolby_surround_ex_mode;
00157 int dolby_headphone_mode;
00158 int ad_converter_type;
00159
00160
00161 int allow_per_frame_metadata;
00162 int stereo_rematrixing;
00163 int channel_coupling;
00164 int cpl_start;
00165 } AC3EncOptions;
00166
00167 void ff_ac3_common_init(void);
00168
00169 extern const int64_t ff_ac3_channel_layouts[];
00170 extern const AVOption ff_ac3_options[];
00171
00172 extern AVCodec ff_ac3_float_encoder;
00173 extern AVCodec ff_ac3_fixed_encoder;
00174
00189 void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
00190 int16_t *band_psd);
00191
00214 int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
00215 int start, int end, int fast_gain, int is_lfe,
00216 int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
00217 uint8_t *dba_lengths, uint8_t *dba_values,
00218 int16_t *mask);
00219
00220 #endif