49 for (ch = 0; ch < s->
channels; ch++) {
67 for (ch = 0; ch < s->
channels; ch++) {
89 for (ch = 0; ch < s->
channels; ch++) {
120 int cpl_start, num_cpl_coefs;
124 memset(fixed_cpl_coords, 0,
AC3_MAX_BLOCKS *
sizeof(*cpl_coords));
131 cpl_start =
FFMIN(256, cpl_start + num_cpl_coefs) - num_cpl_coefs;
139 memset(cpl_coef, 0, num_cpl_coefs *
sizeof(*cpl_coef));
144 for (i = 0; i < num_cpl_coefs; i++)
145 cpl_coef[i] += ch_coef[i];
163 for (j = 0; j < band_size; j++) {
213 coord_diff +=
FFABS(cpl_coords[
blk-1][ch][bnd] -
214 cpl_coords[
blk ][ch][bnd]);
243 energy_ch = energy[
blk][ch][bnd];
247 energy_cpl += energy[blk1][
CPL_CH][bnd];
248 energy_ch += energy[blk1][ch][bnd];
270 fixed_cpl_coords[blk][1],
274 int bnd, min_exp, max_exp, master_exp;
283 min_exp =
FFMIN(exp, min_exp);
284 max_exp =
FFMAX(exp, max_exp);
286 master_exp = ((max_exp - 15) + 2) / 3;
287 master_exp =
FFMAX(master_exp, 0);
288 while (min_exp < master_exp * 3)
292 master_exp * 3, 0, 15);
299 int cpl_mant = (fixed_cpl_coords[
blk][ch][bnd] << (5 + cpl_exp + master_exp * 3)) >> 24;
351 block->
mdct_coef[2] + start, end - start);
354 if (
FFMIN(sum[2], sum[3]) <
FFMIN(sum[0], sum[1]))
uint8_t new_rematrixing_strategy
send new rematrixing flags in this block
This structure describes decoded (raw) audio or video data.
static void apply_mdct(AC3EncodeContext *s)
static int allocate_sample_buffers(AC3EncodeContext *s)
uint8_t ** cpl_coord_exp
coupling coord exponents (cplcoexp)
#define FF_ALLOC_TYPED_ARRAY(p, nelem)
void ff_eac3_set_cpl_states(AC3EncodeContext *s)
Set coupling states.
uint8_t ** cpl_coord_mant
coupling coord mantissas (cplcomant)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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
#define LOCAL_ALIGNED_16(t, v,...)
static void apply_channel_coupling(AC3EncodeContext *s)
void(* extract_exponents)(uint8_t *exp, int32_t *coef, int nb_coefs)
int channel_mode
channel mode (acmod)
int num_cpl_subbands
number of coupling subbands (ncplsubnd)
The exact code depends on how similar the blocks are and how related they are to the block
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)
uint8_t cpl_master_exp[AC3_MAX_CHANNELS]
coupling coord master exponents (mstrcplco)
void(* vector_fmul_reverse)(int *dst, const int *src0, const int *src1, int len)
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)
AC3EncOptions options
encoding options
int channels
total number of channels (nchans)
#define AC3_MAX_CHANNELS
maximum number of channels, including coupling channel
void(* mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
int cpl_on
coupling turned on for this frame
int cpl_in_use
coupling in use for this block (cplinu)
int cpl_enabled
coupling enabled for all frames
Data for a single audio block.
common internal API header
int eac3
indicates if this is E-AC-3 vs. AC-3
static void scale_coefficients(AC3EncodeContext *s)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
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.
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
static void clip_coefficients(AudioDSPContext *adsp, int32_t *coef, unsigned int len)
#define CPL_CH
coupling channel index
static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl)
#define NEW_CPL_COORD_THRESHOLD
main external API structure.
const uint8_t * channel_map
channel map used to reorder channels
void(* vector_fmul)(int *dst, const int *src0, const int *src1, int len)
Fixed-point multiplication that calculates the entry wise product of two vectors of integers and stor...
int end_freq[AC3_MAX_CHANNELS]
end frequency bin (endmant)
AC-3 encoder private context.
AC3Block blocks[AC3_MAX_BLOCKS]
per-block info
SampleType * windowed_samples
int num_blocks
number of blocks per frame
int ff_ac3_encode_frame_common_end(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
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.
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.
Filter the word “frame” indicates either a video frame or a group of audio samples
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 void sum_square_butterfly(AC3EncodeContext *s, int64_t sum[4], const int32_t *coef0, const int32_t *coef1, int len)
#define FF_ALLOCZ_TYPED_ARRAY(p, nelem)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s)
Set the initial coupling strategy parameters prior to coupling analysis.
This structure stores compressed data.
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)].