22#ifndef AVCODEC_AACENC_H
23#define AVCODEC_AACENC_H
42#define CLIP_AVOIDANCE_FACTOR 0.95f
146 int win,
int group_len,
const float lambda);
148 int scale_idx,
int cb,
const float lambda,
int rtz);
AAC definitions and structures.
const AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB]
#define NMR_NCAND
per-band scalefactor candidates above the finest codeable sf (NMR coder)
void ff_quantize_band_cost_cache_init(struct AACEncContext *s)
static float win(SuperEqualizerContext *s, float n, int N)
Libavcodec external API header.
Public libavutil channel layout APIs header.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
void(* encode_tns_info)(struct AACEncContext *s, SingleChannelElement *sce)
void(* search_for_ms)(struct AACEncContext *s, ChannelElement *cpe)
void(* search_for_quantizers)(AVCodecContext *avctx, struct AACEncContext *s, SingleChannelElement *sce, const float lambda)
void(* mark_pns)(struct AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
void(* search_for_pns)(struct AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
void(* encode_window_bands_info)(struct AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda)
void(* apply_tns_filt)(struct AACEncContext *s, SingleChannelElement *sce)
void(* quantize_and_encode_band)(struct AACEncContext *s, PutBitContext *pb, const float *in, float *out, int size, int scale_idx, int cb, const float lambda, int rtz)
void(* set_special_band_scalefactors)(struct AACEncContext *s, SingleChannelElement *sce)
void(* search_for_tns)(struct AACEncContext *s, SingleChannelElement *sce)
void(* search_for_is)(struct AACEncContext *s, AVCodecContext *avctx, ChannelElement *cpe)
int profile
copied from avctx
AACPCEInfo pce
PCE data, if needed.
uint64_t stat_is
coded CPE pair-bands, of which M/S, I/S
AVTXContext * mdct1024
long (1024 samples) frame transform context
float * planar_samples[16]
saved preprocessed input
int last_frame_pb_count
number of bits for the previous frame
LPCContext lpc
used by TNS
const uint8_t * chan_map
channel configuration map
uint16_t quantize_band_cost_cache_generation
int qcoefs[96]
quantized coefficients
AACQuantizeBandCostCacheEntry quantize_band_cost_cache[256][128]
memoization area for quantize_band_cost
int bandwidth
coding bandwidth in Hz, fixed at init; the psy model and the coders' band cutoff agree on it
AVTXContext * mdct128
short (128 samples) frame transform context
float lambda_sum
sum(lambda), for Qvg reporting
AACNMRCurves * nmr
NMR coder scratch (NULL unless coder == nmr)
int channels
channel count
ChannelElement * cpe
channel elements
int needs_pce
flag for non-standard layout
uint64_t stat_pns
coded channel-bands, of which PNS
int lambda_count
count(lambda), for Qvg reporting
uint64_t stat_tns_short
TNS-active channels among long / short blocks.
int cur_channel
current channel for coder context
float scoefs[1024]
scaled coefficients
const AACCoefficientsEncoder * coder
uint64_t stat_short
coded channels, of which short-block (transient)
AACEncOptions options
encoding options
const uint8_t * reorder_map
lavc to aac reorder map
enum RawDataBlockType cur_type
channel group type cur_channel belongs to
int samplerate_index
MPEG-4 samplerate index.
int nmr_speed
NMR coder speed level: 0 = slowest/best, higher is faster.
float nd[2][128][NMR_NCAND]
dist / threshold per candidate, per pair slot
int frames_since_short
long-block frames since the last short run (the "gap"): large = isolated transient
float press
rate-pressure ramp [0,1]: lambda EMA against anchors that scale up when nd_ema flags noise-class cont...
int nb[2][128][NMR_NCAND]
spectral bits per candidate, per pair slot
uint8_t smode[16][128]
per-pair previous stereo mode per band, two banks per pair (long/short grid): each grid's memory pers...
float sema_es[16][128]
smoothed side energy per band (stereo-decision EMA)
uint8_t pns_prev[16][128]
per-channel PNS state last frame (decision hysteresis)
int zero_nw[16]
window count zero_prev was recorded on
uint8_t tns8_prev[16]
short-TNS accepted last frame (per channel): Schmitt state for the accept bar
float nd_ema
smoothed achieved distortion/real-mask over long-frame coded bands (1 = at threshold; >>1 flags psy-u...
NMRSlot slot[2]
pair slots (solo solves use slot 0)
float run_burst
transient bit-burst factor, set at run start and held across the short run
int rc_fill
virtual bit reservoir fill, + = bits saved vs nominal
int smode_nw[8]
window count the stored modes were decided on
int rc_gl
rc_global latched at frame start: the corridor bootstrap must not flip the CPE defer logic between ch...
uint8_t zero_prev[16][128]
per-channel band zero state last frame (zeroing hysteresis)
uint8_t smode_band[8][128]
last decided stereo mode per band index (side-band tests)
float lam_short_ema
smoothed operating lambda of short frames
float lam_floor
lambda min-tracker (snaps down, +2%/frame up): sustained-strain floor; bursty spikes at a comfortable...
uint8_t pns_run_off[16][128]
consecutive frames the band has wanted OUT
uint8_t pns_run_on[16][128]
consecutive frames the band has WANTED PNS
int64_t rc_frame_num
frame the reservoir was last advanced for
float lam_long_ema
smoothed operating lambda of long frames
int pending
slot 0 holds a deferred first channel
float sema_img[16][128]
smoothed I/S image-error/mask ratio per band
uint8_t sinit[16]
stereo state bank initialized
uint8_t thr_prev_ok[16]
thr_prev holds a long-frame measurement
int counted[16]
per-channel bits the trellis accounted for in the last solve
float thr_prev[16][64]
per-channel long-grid law thresholds of the previous frame
int prev_was_short
previous frame was a short block (for run-start detection)
int side_inited
side_ema holds a measurement
float lam_slew
final operating lambda of the previous RC frame (slew-limiter state)
float side_ema
running estimate of real-minus-counted bits per frame
float lam_rc
global-lambda rate control: operating lambda, 0 until bootstrapped
float sema_em[16][128]
smoothed mid energy per band
float lam[16]
per-channel operating lambda of the previous frame, 0 = none yet
int rc_fill_seeded
reservoir seeded full at stream start (decoder buffer starts full)
int pair
current element is a CPE: pool the pair budget
uint8_t num_ele[4]
front, side, back, lfe
uint8_t index[4][8]
front, side, back, lfe
uint8_t pairing[3][8]
front, side, back
uint8_t config_map[16]
configs the encoder's channel specific settings
uint8_t reorder_map[16]
maps channels from lavc to aac order
An AVChannelLayout holds information about the channel layout of audio data.
Describe the class of an AVClass context structure.
main external API structure.
channel element - generic struct for SCE/CPE/CCE/LFE
uint8_t ms_mask[128]
Set if mid/side stereo is used for each scalefactor window band.
SingleChannelElement ch[2]
uint8_t is_mask[128]
Set if intensity stereo is used.
int ms_mode
Signals mid/side stereo flags coding mode.
int common_window
Set if channels share a common 'IndividualChannelStream' in bitstream.
uint8_t is_mode
Set if any bands have been encoded using intensity stereo.
context used by psychoacoustic model
Individual Channel Stream.
uint8_t max_sfb
number of scalefactor bands per group
int num_swb
number of scalefactor window bands
uint8_t use_kb_window[2]
If set, use Kaiser-Bessel window, otherwise use a sine window.
float clip_avoidance_factor
set if any window is near clipping to the necessary atennuation factor to avoid it
const uint8_t * swb_sizes
table of scalefactor band sizes for a particular window
enum WindowSequence window_sequence[2]
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
uint8_t window_clipping[8]
set if a certain window is near clipping
NMR coder per-band candidate cost curves (~96 KiB) and rate-control carry-over.
float pspread[128]
band tonality spread (1 = noise)
float tnsg[128]
TNS synthesis gain per band for THIS solve (1 = uncovered), M/S-aware (pair max)
int bst[128]
window group, swb, coef start
struct SingleChannelElement * sce
int bnc[128]
number of candidates
float thr_real[128]
real masking threshold (PNS gates)
uint8_t is_pns[128]
band coded as noise
int si
curve-bank index (nd/nb slot)
float pener[128]
band energy (PNS noise target)
float thr[128]
allocation-law effective threshold
int bidx[128]
sce band index (w*16+g)
int nbnd
coded-band count, 0 = nothing codeable
int blo[128]
finest candidate scalefactor
int act[128]
active (non-PNS) band coding order
int is8
EIGHT_SHORT frame.
int cur_ch
encoder channel index (psy/cache context)
Single Channel Element - used for both SCE and LFE elements.
float pcoeffs[1024]
coefficients for IMDCT, pristine
uint8_t zeroes[128]
band is not coded
struct PredictorState * predictor_state
float coeffs[1024]
coefficients for IMDCT, maybe processed
float is_ener[128]
Intensity stereo pos.
uint8_t can_pns[128]
band is allowed to PNS (informative)
float pns_ener[128]
Noise energy values.
enum BandType band_alt[128]
alternative band type
float ret_buf[2048]
PCM output buffer.
enum BandType band_type[128]
band types
IndividualChannelStream ics
int sf_idx[128]
scalefactor indices
float coef[8][4][TNS_MAX_ORDER]
int coef_idx[8][4][TNS_MAX_ORDER]
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
static double cb(void *priv, double x, double y)