59 sizeof(*
s->windowed_samples), alloc_fail);
62 for (ch = 0; ch <
s->channels; ch++) {
83 for (ch = 0; ch < s->
channels; ch++) {
105 for (ch = 0; ch < s->
channels; ch++) {
110 #if CONFIG_AC3ENC_FLOAT
134 #if CONFIG_AC3ENC_FLOAT
141 int cpl_start, num_cpl_coefs;
144 #if CONFIG_AC3ENC_FLOAT
145 memset(fixed_cpl_coords, 0,
AC3_MAX_BLOCKS *
sizeof(*cpl_coords));
152 cpl_start =
FFMIN(256, cpl_start + num_cpl_coefs) - num_cpl_coefs;
160 memset(cpl_coef, 0, num_cpl_coefs *
sizeof(*cpl_coef));
165 for (i = 0; i < num_cpl_coefs; i++)
166 cpl_coef[i] += ch_coef[i];
184 for (j = 0; j < band_size; j++) {
234 coord_diff +=
FFABS(cpl_coords[
blk-1][ch][bnd] -
235 cpl_coords[
blk ][ch][bnd]);
264 energy_ch = energy[
blk][ch][bnd];
268 energy_cpl += energy[blk1][
CPL_CH][bnd];
269 energy_ch += energy[blk1][ch][bnd];
285 #if CONFIG_AC3ENC_FLOAT
291 fixed_cpl_coords[blk][1],
295 int bnd, min_exp, max_exp, master_exp;
304 min_exp =
FFMIN(exp, min_exp);
305 max_exp =
FFMAX(exp, max_exp);
307 master_exp = ((max_exp - 15) + 2) / 3;
308 master_exp =
FFMAX(master_exp, 0);
309 while (min_exp < master_exp * 3)
313 master_exp * 3, 0, 15);
320 int cpl_mant = (fixed_cpl_coords[
blk][ch][bnd] << (5 + cpl_exp + master_exp * 3)) >> 24;
331 if (CONFIG_EAC3_ENCODER && s->
eac3)
372 block->
mdct_coef[2] + start, end - start);
375 if (
FFMIN(sum[2], sum[3]) <
FFMIN(sum[0], sum[1]))
static void scale_coefficients(AC3EncodeContext *s)
uint8_t new_rematrixing_strategy
send new rematrixing flags in this block
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and/or allocate data.
static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl)
void(* float_to_fixed24)(int32_t *dst, const float *src, unsigned int len)
Convert an array of float in range [-1.0,1.0] to int32_t with range [-(1<<24),(1<<24)].
This structure describes decoded (raw) audio or video data.
int AC3_NAME() allocate_sample_buffers(AC3EncodeContext *s)
static void apply_mdct(AC3EncodeContext *s)
uint8_t ** cpl_coord_exp
coupling coord exponents (cplcoexp)
static void clip_coefficients(AudioDSPContext *adsp, CoefType *coef, unsigned int len)
void ff_ac3_process_exponents(AC3EncodeContext *s)
Calculate final exponents from the supplied MDCT coefficients and exponent shift. ...
void ff_eac3_set_cpl_states(AC3EncodeContext *s)
Set coupling states.
uint8_t ** cpl_coord_mant
coupling coord mantissas (cplcomant)
int start_freq[AC3_MAX_CHANNELS]
start frequency bin (strtmant)
AC3BitAllocParameters bit_alloc
bit allocation parameters
Macro definitions for various function/variable attributes.
int ff_ac3_validate_metadata(AC3EncodeContext *s)
Validate metadata options as set by AVOption system.
int rematrixing_enabled
stereo rematrixing enabled
static void apply_channel_coupling(AC3EncodeContext *s)
int channel_mode
channel mode (acmod)
int num_cpl_subbands
number of coupling subbands (ncplsubnd)
uint8_t rematrixing_flags[4]
rematrixing flags
int fbw_channels
number of full-bandwidth channels (nfchans)
uint8_t new_cpl_coords[AC3_MAX_CHANNELS]
send new coupling coordinates (cplcoe)
static av_cold int end(AVCodecContext *avctx)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t cpl_master_exp[AC3_MAX_CHANNELS]
coupling coord master exponents (mstrcplco)
int num_rematrixing_bands
number of rematrixing bands
AC3DSPContext ac3dsp
AC-3 optimized functions.
int num_cpl_bands
number of coupling bands (ncplbnd)
CoefType ** mdct_coef
MDCT coefficients.
uint8_t channel_in_cpl[AC3_MAX_CHANNELS]
channel in coupling (chincpl)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AC3EncOptions options
encoding options
void(* vector_fmul)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats and store the result in a vector of floats...
int channels
total number of channels (nchans)
int initial_padding
Audio only.
#define AC3_MAX_CHANNELS
maximum number of channels, including coupling channel
int cpl_on
coupling turned on for this frame
int fixed_point
indicates if fixed-point encoder is being used
int cpl_in_use
coupling in use for this block (cplinu)
int cpl_enabled
coupling enabled for all frames
static int normalize_samples(AC3EncodeContext *s)
Data for a single audio block.
common internal API header
int ff_ac3_compute_bit_allocation(AC3EncodeContext *s)
int eac3
indicates if this is E-AC-3 vs. AC-3
void ff_ac3_adjust_frame_size(AC3EncodeContext *s)
Adjust the frame size to make the average bit rate match the target bit rate.
FFTContext mdct
FFT context for MDCT calculation.
void(* extract_exponents)(uint8_t *exp, int32_t *coef, int nb_coefs)
int AC3_NAME() encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
const SampleType * mdct_window
MDCT window function array.
SampleType ** planar_samples
#define CPL_CH
coupling channel index
#define NEW_CPL_COORD_THRESHOLD
main external API structure.
const uint8_t * channel_map
channel map used to reorder channels
int end_freq[AC3_MAX_CHANNELS]
end frequency bin (endmant)
AC-3 encoder private context.
void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame)
Write the frame to the output bitstream.
void(* apply_window_int16)(int16_t *output, const int16_t *input, const int16_t *window, unsigned int len)
Apply symmetric window in 16-bit fixed-point.
AC3Block blocks[AC3_MAX_BLOCKS]
per-block info
SampleType * windowed_samples
void ff_ac3_quantize_mantissas(AC3EncodeContext *s)
Quantize mantissas using coefficients, exponents, and bit allocation pointers.
int num_blocks
number of blocks per frame
#define FF_ALLOC_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)
uint8_t coeff_shift[AC3_MAX_CHANNELS]
fixed-point coefficient shift values
int frame_size
current frame size in bytes
int cpl_end_freq
coupling channel end frequency bin
uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS]
number of coeffs in each coupling band
common internal api header.
static void sum_square_butterfly(AC3EncodeContext *s, CoefSumType sum[4], const CoefType *coef0, const CoefType *coef1, int len)
#define FF_ALLOC_OR_GOTO(ctx, p, size, label)
AVCodecContext * avctx
parent AVCodecContext
static void compute_rematrixing_strategy(AC3EncodeContext *s)
int allow_per_frame_metadata
static void copy_input_samples(AC3EncodeContext *s, SampleType **samples)
#define MAC_COEF(d, a, b)
AC-3 encoder & E-AC-3 encoder common header.
#define LOCAL_ALIGNED_16(t, v,...)
void ff_ac3_apply_rematrixing(AC3EncodeContext *s)
Apply stereo rematrixing to coefficients based on rematrixing flags.
const uint8_t ff_ac3_rematrix_band_tab[5]
Table of bin locations for rematrixing bands reference: Section 7.5.2 Rematrixing : Frequency Band De...
static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
void ff_ac3_group_exponents(AC3EncodeContext *s)
Group exponents.
uint8_t ** extended_data
pointers to the data planes/channels.
void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s)
Set the initial coupling strategy parameters prior to coupling analysis.
This structure stores compressed data.
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
#define AV_NOPTS_VALUE
Undefined timestamp value.
void(* mdct_calcw)(struct FFTContext *s, FFTDouble *output, const FFTSample *input)