28 #ifndef AVCODEC_AC3ENC_H 29 #define AVCODEC_AC3ENC_H 33 #include "libavutil/float_dsp.h" 44 #ifndef CONFIG_AC3ENC_FLOAT 45 #define CONFIG_AC3ENC_FLOAT 0 48 #define OFFSET(param) offsetof(AC3EncodeContext, options.param) 49 #define AC3ENC_PARAM (AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) 51 #define AC3ENC_TYPE_AC3_FIXED 0 52 #define AC3ENC_TYPE_AC3 1 53 #define AC3ENC_TYPE_EAC3 2 55 #if CONFIG_AC3ENC_FLOAT 56 #define AC3_NAME(x) ff_ac3_float_ ## x 57 #define MAC_COEF(d,a,b) ((d)+=(a)*(b)) 58 #define COEF_MIN (-16777215.0/16777216.0) 59 #define COEF_MAX ( 16777215.0/16777216.0) 60 #define NEW_CPL_COORD_THRESHOLD 0.03 61 typedef float SampleType;
62 typedef float CoefType;
63 typedef float CoefSumType;
65 #define AC3_NAME(x) ff_ac3_fixed_ ## x 66 #define MAC_COEF(d,a,b) MAC64(d,a,b) 67 #define COEF_MIN -16777215 68 #define COEF_MAX 16777215 69 #define NEW_CPL_COORD_THRESHOLD 503317 70 typedef int16_t SampleType;
71 typedef int32_t CoefType;
72 typedef int64_t CoefSumType;
76 #define AC3ENC_OPT_NONE -1 77 #define AC3ENC_OPT_AUTO -1 78 #define AC3ENC_OPT_OFF 0 79 #define AC3ENC_OPT_ON 1 80 #define AC3ENC_OPT_NOT_INDICATED 0 81 #define AC3ENC_OPT_MODE_ON 2 82 #define AC3ENC_OPT_MODE_OFF 1 83 #define AC3ENC_OPT_DSUREX_DPLIIZ 3 86 #define AC3ENC_OPT_LARGE_ROOM 1 87 #define AC3ENC_OPT_SMALL_ROOM 2 88 #define AC3ENC_OPT_DOWNMIX_LTRT 1 89 #define AC3ENC_OPT_DOWNMIX_LORO 2 90 #define AC3ENC_OPT_DOWNMIX_DPLII 3 // reserved value in A/52, but used by encoders to indicate DPL2 91 #define AC3ENC_OPT_ADCONV_STANDARD 0 92 #define AC3ENC_OPT_ADCONV_HDCD 1 102 float center_mix_level;
103 float surround_mix_level;
104 int dolby_surround_mode;
105 int audio_production_info;
111 int preferred_stereo_downmix;
112 float ltrt_center_mix_level;
113 float ltrt_surround_mix_level;
114 float loro_center_mix_level;
115 float loro_surround_mix_level;
117 int dolby_surround_ex_mode;
118 int dolby_headphone_mode;
119 int ad_converter_type;
120 int eac3_mixing_metadata;
121 int eac3_info_metadata;
124 int allow_per_frame_metadata;
125 int stereo_rematrixing;
126 int channel_coupling;
135 int32_t **fixed_coef;
147 uint8_t rematrixing_flags[4];
218 uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS];
236 SampleType *windowed_samples;
237 SampleType **planar_samples;
239 uint8_t *bap1_buffer;
240 CoefType *mdct_coef_buffer;
241 int32_t *fixed_coef_buffer;
243 uint8_t *grouped_exp_buffer;
245 int16_t *band_psd_buffer;
246 int16_t *mask_buffer;
247 int16_t *qmant_buffer;
248 uint8_t *cpl_coord_exp_buffer;
249 uint8_t *cpl_coord_mant_buffer;
311 const AVFrame *frame,
int *got_packet_ptr);
313 const AVFrame *frame,
int *got_packet_ptr);
uint8_t new_rematrixing_strategy
send new rematrixing flags in this block
Definition: ac3enc.h:145
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
int db_per_bit_code
dB/bit code (dbpbcod)
Definition: ac3enc.h:226
int slow_decay_code
slow decay code (sdcycod)
Definition: ac3enc.h:224
struct AC3EncodeContext AC3EncodeContext
AC-3 encoder private context.
Definition: put_bits.h:35
Encoding Options used by AVOption.
Definition: ac3enc.h:98
uint8_t ** cpl_coord_exp
coupling coord exponents (cplcoexp)
Definition: ac3enc.h:142
int bandwidth_code
bandwidth code (0 to 60) (chbwcod)
Definition: ac3enc.h:210
int16_t ** psd
psd per frequency bin
Definition: ac3enc.h:138
int frame_size_code
frame size code (frmsizecod)
Definition: ac3enc.h:188
int frame_bits
all frame bits except exponents and mantissas
Definition: ac3enc.h:233
const uint64_t ff_ac3_channel_layouts[19]
List of supported channel layouts.
Definition: ac3enc.c:81
uint8_t ** cpl_coord_mant
coupling coord mantissas (cplcomant)
Definition: ac3enc.h:143
uint16_t ** qmant
quantized mantissas
Definition: ac3enc.h:141
int ff_ac3_validate_metadata(AC3EncodeContext *s)
Validate metadata options as set by AVOption system.
Definition: ac3enc.c:1833
PutBitContext pb
bitstream writer context
Definition: ac3enc.h:166
int num_cpl_channels
number of channels in coupling
Definition: ac3enc.h:151
AC3BitAllocParameters bit_alloc
bit allocation parameters
Definition: ac3enc.h:228
int new_cpl_leak
send new coupling leak info
Definition: ac3enc.h:155
int rematrixing_enabled
stereo rematrixing enabled
Definition: ac3enc.h:220
int channel_mode
channel mode (acmod)
Definition: ac3enc.h:199
int num_cpl_subbands
number of coupling subbands (ncplsubnd)
Definition: ac3enc.h:216
int fbw_channels
number of full-bandwidth channels (nfchans)
Definition: ac3enc.h:193
int slow_gain_code
slow gain code (sgaincod)
Definition: ac3enc.h:223
uint8_t ** exp
original exponents
Definition: ac3enc.h:136
int num_rematrixing_bands
number of rematrixing bands
Definition: ac3enc.h:146
AC3DSPContext ac3dsp
AC-3 optimized functions.
Definition: ac3enc.h:170
int loro_center_mix_level
Lo/Ro center mix level code.
Definition: ac3enc.h:206
int num_cpl_bands
number of coupling bands (ncplbnd)
Definition: ac3enc.h:217
void ff_ac3_fixed_mdct_end(AC3EncodeContext *s)
Finalize MDCT and free allocated memory.
Definition: ac3enc_fixed.c:118
int lfe_channel
channel index of the LFE channel
Definition: ac3enc.h:196
int ref_bap_set
indicates if ref_bap pointers have been set
Definition: ac3enc.h:256
void ff_ac3_quantize_mantissas(AC3EncodeContext *s)
Quantize mantissas using coefficients, exponents, and bit allocation pointers.
Definition: ac3enc.c:1300
int new_snr_offsets
send new SNR offsets
Definition: ac3enc.h:154
int loro_surround_mix_level
Lo/Ro surround mix level code.
Definition: ac3enc.h:207
CoefType ** mdct_coef
MDCT coefficients.
Definition: ac3enc.h:134
int num_blks_code
number of blocks code (numblkscod)
Definition: ac3enc.h:184
AC3EncOptions options
encoding options
Definition: ac3enc.h:164
int16_t ** band_psd
psd per critical band
Definition: ac3enc.h:139
AVClass * av_class
AVClass used for AVOption.
Definition: ac3enc.h:163
int channels
total number of channels (nchans)
Definition: ac3enc.h:194
#define AC3_MAX_CHANNELS
maximum number of channels, including coupling channel
Definition: ac3.h:32
int cpl_on
coupling turned on for this frame
Definition: ac3enc.h:214
int fixed_point
indicates if fixed-point encoder is being used
Definition: ac3enc.h:176
int ltrt_surround_mix_level
Lt/Rt surround mix level code.
Definition: ac3enc.h:205
int new_cpl_strategy
send new coupling strategy
Definition: ac3enc.h:148
int surround_mix_level
surround mix level code
Definition: ac3enc.h:203
int cpl_in_use
coupling in use for this block (cplinu)
Definition: ac3enc.h:149
int cpl_enabled
coupling enabled for all frames
Definition: ac3enc.h:215
Data for a single audio block.
Definition: ac3enc.h:133
int floor_code
floor code (floorcod)
Definition: ac3enc.h:227
int bitstream_mode
bitstream mode (bsmod)
Definition: ac3enc.h:179
int has_surround
indicates if there are one or more surround channels
Definition: ac3enc.h:198
int eac3
indicates if this is E-AC-3 vs. AC-3
Definition: ac3enc.h:177
void ff_ac3_apply_rematrixing(AC3EncodeContext *s)
Apply stereo rematrixing to coefficients based on rematrixing flags.
Definition: ac3enc.c:272
int ff_ac3_float_mdct_init(AC3EncodeContext *s)
Initialize MDCT tables.
Definition: ac3enc_float.c:110
struct AC3Block AC3Block
Data for a single audio block.
void ff_ac3_process_exponents(AC3EncodeContext *s)
Calculate final exponents from the supplied MDCT coefficients and exponent shift. ...
Definition: ac3enc.c:637
void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s)
Set the initial coupling strategy parameters prior to coupling analysis.
Definition: ac3enc.c:201
int exponent_bits
number of bits used for exponents
Definition: ac3enc.h:234
Definition: float_dsp.h:24
int coarse_snr_offset
coarse SNR offsets (csnroffst)
Definition: ac3enc.h:229
int16_t ** mask
masking curve
Definition: ac3enc.h:140
FFTContext mdct
FFT context for MDCT calculation.
Definition: ac3enc.h:171
const SampleType * mdct_window
MDCT window function array.
Definition: ac3enc.h:172
int fast_decay_code
fast decay code (fdcycod)
Definition: ac3enc.h:225
Libavcodec external API header.
struct AC3EncOptions AC3EncOptions
Encoding Options used by AVOption.
main external API structure.
Definition: avcodec.h:1518
int sample_rate
sampling frequency, in Hz
Definition: ac3enc.h:182
int has_center
indicates if there is a center channel
Definition: ac3enc.h:197
int bit_rate
target bit rate, in bits-per-second
Definition: ac3enc.h:181
const uint8_t * channel_map
channel map used to reorder channels
Definition: ac3enc.h:200
int frame_bits_fixed
number of non-coefficient bits for fixed parameters
Definition: ac3enc.h:232
Describe the class of an AVClass context structure.
Definition: log.h:67
int ltrt_center_mix_level
Lt/Rt center mix level code.
Definition: ac3enc.h:204
int center_mix_level
center mix level code
Definition: ac3enc.h:202
AC-3 encoder private context.
Definition: ac3enc.h:162
int num_blocks
number of blocks per frame
Definition: ac3enc.h:185
void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame)
Write the frame to the output bitstream.
Definition: ac3enc.c:1661
int ff_ac3_encode_close(AVCodecContext *avctx)
Finalize encoding and free any memory allocated by the encoder.
Definition: ac3enc.c:2017
int frame_size
current frame size in bytes
Definition: ac3enc.h:187
uint8_t ** grouped_exp
grouped exponents
Definition: ac3enc.h:137
int cpl_end_freq
coupling channel end frequency bin
Definition: ac3enc.h:212
int64_t bits_written
bit count (used to avg. bitrate)
Definition: ac3enc.h:190
int bitstream_id
bitstream id (bsid)
Definition: ac3enc.h:178
AVCodecContext * avctx
parent AVCodecContext
Definition: ac3enc.h:165
int frame_size_min
minimum frame size in case rounding is necessary
Definition: ac3enc.h:186
void ff_ac3_float_mdct_end(AC3EncodeContext *s)
Finalize MDCT and free allocated memory.
Definition: ac3enc_float.c:97
int64_t samples_written
sample count (used to avg. bitrate)
Definition: ac3enc.h:191
int use_frame_exp_strategy
indicates use of frame exp strategy
Definition: ac3enc.h:253
int ff_ac3_fixed_mdct_init(AC3EncodeContext *s)
Initialize MDCT tables.
Definition: ac3enc_fixed.c:130
int cutoff
user-specified cutoff frequency, in Hz
Definition: ac3enc.h:209
void ff_ac3_adjust_frame_size(AC3EncodeContext *s)
Adjust the frame size to make the average bit rate match the target bit rate.
Definition: ac3enc.c:183
int lfe_on
indicates if there is an LFE channel (lfeon)
Definition: ac3enc.h:195
This structure stores compressed data.
Definition: avcodec.h:1407
Common code between the AC-3 encoder and decoder.
void ff_ac3_group_exponents(AC3EncodeContext *s)
Group exponents.
Definition: ac3enc.c:579
Definition: audiodsp.h:24