FFmpeg
Loading...
Searching...
No Matches
aacenc.h
Go to the documentation of this file.
1/*
2 * AAC encoder
3 * Copyright (C) 2008 Konstantin Shishkov
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef AVCODEC_AACENC_H
23#define AVCODEC_AACENC_H
24
25#include <stdint.h>
26
28#include "libavutil/float_dsp.h"
30#include "libavutil/tx.h"
31
32#include "avcodec.h"
33#include "put_bits.h"
34
35#include "aac.h"
36#include "aacencdsp.h"
37#include "audio_frame_queue.h"
38#include "psymodel.h"
39
40#include "lpc.h"
41
42#define CLIP_AVOIDANCE_FACTOR 0.95f
43
51
52/**
53 * Predictor State
54 */
55typedef struct PredictorState {
56 float cor0;
57 float cor1;
58 float var0;
59 float var1;
60 float r0;
61 float r1;
62 float k1;
63 float x_est;
65
66typedef struct AACEncOptions {
67 int coder;
68 int pns;
69 int tns;
70 int pce;
73 int nmr_speed; ///< NMR coder speed level: 0 = slowest/best, higher is faster
75 int rc; ///< rate-control mode: 0 = cbr (corridor+bucket), 1 = abr (nd-target + slow servo)
77
78/**
79 * Individual Channel Stream
80 */
81typedef struct IndividualChannelStream {
82 uint8_t max_sfb; ///< number of scalefactor bands per group
84 uint8_t use_kb_window[2]; ///< If set, use Kaiser-Bessel window, otherwise use a sine window.
85 uint8_t group_len[8];
86 const uint16_t *swb_offset; ///< table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular window
87 const uint8_t *swb_sizes; ///< table of scalefactor band sizes for a particular window
88 int num_swb; ///< number of scalefactor window bands
89 int num_windows;
90 int tns_max_bands;
91 uint8_t window_clipping[8]; ///< set if a certain window is near clipping
92 float clip_avoidance_factor; ///< set if any window is near clipping to the necessary atennuation factor to avoid it
94
95/**
96 * Temporal Noise Shaping
97 */
98typedef struct TemporalNoiseShaping {
99 int present;
100 int n_filt[8];
101 int length[8][4];
102 int direction[8][4];
103 int order[8][4];
105 float coef[8][4][TNS_MAX_ORDER];
107
108/**
109 * Single Channel Element - used for both SCE and LFE elements.
110 */
111typedef struct SingleChannelElement {
115 enum BandType band_type[128]; ///< band types
116 enum BandType band_alt[128]; ///< alternative band type
117 int sf_idx[128]; ///< scalefactor indices
118 uint8_t zeroes[128]; ///< band is not coded
119 uint8_t can_pns[128]; ///< band is allowed to PNS (informative)
120 float is_ener[128]; ///< Intensity stereo pos
121 float pns_ener[128]; ///< Noise energy values
122 DECLARE_ALIGNED(32, float, pcoeffs)[1024]; ///< coefficients for IMDCT, pristine
123 DECLARE_ALIGNED(32, float, coeffs)[1024]; ///< coefficients for IMDCT, maybe processed
124 DECLARE_ALIGNED(32, float, ret_buf)[2048]; ///< PCM output buffer
127
128/**
129 * channel element - generic struct for SCE/CPE/CCE/LFE
130 */
131typedef struct ChannelElement {
132 // CPE specific
133 int common_window; ///< Set if channels share a common 'IndividualChannelStream' in bitstream.
134 int ms_mode; ///< Signals mid/side stereo flags coding mode
135 uint8_t is_mode; ///< Set if any bands have been encoded using intensity stereo
136 uint8_t ms_mask[128]; ///< Set if mid/side stereo is used for each scalefactor window band
137 uint8_t is_mask[128]; ///< Set if intensity stereo is used
138 // shared
141
142struct AACEncContext;
143
146 SingleChannelElement *sce, const float lambda);
148 int win, int group_len, const float lambda);
149 void (*quantize_and_encode_band)(struct AACEncContext *s, PutBitContext *pb, const float *in, float *out, int size,
150 int scale_idx, int cb, const float lambda, int rtz);
160
162
171
172/** per-band scalefactor candidates above the finest codeable sf (NMR coder) */
173#define NMR_NCAND 96
174
175/**
176 * NMR coder per-band candidate cost curves (~96 KiB) and rate-control carry-over
177 */
178/**
179 * Per-channel trellis state for one solve. A channel pair (CPE) is solved
180 * jointly against a pooled budget: the first channel's setup is stored here
181 * and committed together with the second channel under one shared lambda.
182 */
183typedef struct NMRSlot {
185 int si; ///< curve-bank index (nd/nb slot)
186 int cur_ch; ///< encoder channel index (psy/cache context)
187 int nbnd; ///< coded-band count, 0 = nothing codeable
188 int is8; ///< EIGHT_SHORT frame
189 int bidx[128]; ///< sce band index (w*16+g)
190 int bw[128], bg[128], bst[128]; ///< window group, swb, coef start
191 int blo[128]; ///< finest candidate scalefactor
192 int bnc[128]; ///< number of candidates
193 int chosen[128];
194 int act[128]; ///< active (non-PNS) band coding order
195 int nact;
196 int minsf[128];
197 float maxvals[128];
198 float thr[128]; ///< allocation-law effective threshold
199 float thr_real[128]; ///< real masking threshold (PNS gates)
200 float tnsg[128]; ///< TNS synthesis gain per band for THIS solve (1 = uncovered), M/S-aware (pair max)
201 float pener[128]; ///< band energy (PNS noise target)
202 float pspread[128]; ///< band tonality spread (1 = noise)
203 uint8_t is_pns[128]; ///< band coded as noise
204 uint8_t hftx[128]; ///< band strongly HF-tapered: excluded from the nd stat (deficit is by design)
205} NMRSlot;
206
207typedef struct AACNMRCurves {
208 float nd[2][128][NMR_NCAND]; ///< dist / threshold per candidate, per pair slot
209 int nb[2][128][NMR_NCAND]; ///< spectral bits per candidate, per pair slot
210 NMRSlot slot[2]; ///< pair slots (solo solves use slot 0)
211 int pair; ///< current element is a CPE: pool the pair budget
212 int rc_gl; ///< rc_global latched at frame start: the corridor bootstrap must not flip the CPE defer logic between channels of one frame
213 int rc_fill_seeded; ///< reservoir seeded full at stream start (decoder buffer starts full)
214 int pending; ///< slot 0 holds a deferred first channel
215 uint8_t zero_prev[16][128]; ///< per-channel band zero state last frame (zeroing hysteresis)
216 int zero_nw[16]; ///< window count zero_prev was recorded on
217 float thr_prev[16][64]; ///< per-channel long-grid law thresholds of the previous frame
218 uint8_t thr_prev_ok[16]; ///< thr_prev holds a long-frame measurement
219 uint8_t pns_prev[16][128]; ///< per-channel PNS state last frame (decision hysteresis)
220 uint8_t pns_run_on[16][128]; ///< consecutive frames the band has WANTED PNS
221 uint8_t pns_run_off[16][128]; ///< consecutive frames the band has wanted OUT
222 uint8_t smode[16][128]; ///< per-pair previous stereo mode per band, two banks per pair (long/short grid): each grid's memory persists across the other's frames instead of being wiped at window switches
223 uint8_t smode_band[8][128]; ///< last decided stereo mode per band index (side-band tests)
224 uint8_t tns8_prev[16]; ///< short-TNS accepted last frame (per channel): Schmitt state for the accept bar
225 uint8_t sinit[16]; ///< stereo state bank initialized
226 int smode_nw[8]; ///< window count the stored modes were decided on
227 float sema_es[16][128]; ///< smoothed side energy per band (stereo-decision EMA)
228 float sema_em[16][128]; ///< smoothed mid energy per band
229 float sema_img[16][128]; ///< smoothed I/S image-error/mask ratio per band
230 float lam[16]; ///< per-channel operating lambda of the previous frame, 0 = none yet
231 int counted[16]; ///< per-channel bits the trellis accounted for in the last solve
232 float side_ema; ///< running estimate of real-minus-counted bits per frame
233 int side_inited; ///< side_ema holds a measurement
234
235 int64_t rc_frame_num; ///< frame the reservoir was last advanced for
236 float lam_rc; ///< global-lambda rate control: operating lambda, 0 until bootstrapped
237 int rc_fill; ///< virtual bit reservoir fill, + = bits saved vs nominal
238 int rc_satrun; ///< consecutive frames with saturated reservoir debt (cap escalation)
239 int rc_sat_frame; ///< the current frame hit a saturated overage
240 int frames_since_short; ///< long-block frames since the last short run (the "gap"): large = isolated transient
241 int prev_was_short; ///< previous frame was a short block (for run-start detection)
242 int64_t win_frame_num; ///< frame the window history was last advanced for
243 float run_burst; ///< transient bit-burst factor, set at run start and held across the short run
244 float lam_slew; ///< final operating lambda of the previous RC frame (slew-limiter state)
245 float lam_slew_ch[16]; ///< per-channel slew state for decoupled solo solves (a shared slew cross-contaminates the pair)
246 float vbr_infl[16]; ///< per-channel grouped-stat inflation measured at shorts-run entry
247 float nd_ema; ///< smoothed achieved distortion/real-mask over long-frame coded bands (1 = at threshold; >>1 flags psy-unreliable noise-class content)
248 float press; ///< rate-pressure ramp [0,1]: lambda EMA against anchors that scale up when nd_ema flags noise-class content (psy masks unreliable there, lambda reads inflated)
249 float lam_short_ema; ///< smoothed operating lambda of short frames
250 float lam_long_ema; ///< smoothed operating lambda of long frames
251 float lam_floor; ///< lambda min-tracker (snaps down, +2%/frame up): sustained-strain floor; bursty spikes at a comfortable rate cannot raise it
252
253 /* ABR: nd-target set-point servoed to hold the long-run mean rate */
254 float abr_t; ///< current nd target (log2 dist/mask)
255 float abr_glide; ///< pending set-point correction, drained per-frame (no discrete quality steps)
256 float abr_ema; ///< EMA of real frame bits
257 float abr_acc; ///< accumulated set-point correction
258 int abr_hold; ///< frames since the target last stepped
259 int abr_booted; ///< seed correction applied (re-armed while the rate is still off)
260 int abr_boots; ///< open-loop corrections fired so far
261 float abr_alloc_ema; ///< EMA of psy bit demand (fill shaping)
262 int abr_longs; ///< long frames seen during bootstrap
263 int64_t abr_frame_num; ///< once-per-frame servo guard
265
266typedef struct AACPCEInfo {
268 uint8_t num_ele[4]; ///< front, side, back, lfe
269 uint8_t pairing[3][8]; ///< front, side, back
270 uint8_t index[4][8]; ///< front, side, back, lfe
271 uint8_t height[3][8]; ///< front, side, back
272 uint8_t config_map[16]; ///< configs the encoder's channel specific settings
273 uint8_t reorder_map[16]; ///< maps channels from lavc to aac order
274} AACPCEInfo;
275
276/**
277 * AAC encoder context
278 */
279typedef struct AACEncContext {
281 AACEncOptions options; ///< encoding options
283 AVTXContext *mdct1024; ///< long (1024 samples) frame transform context
285 AVTXContext *mdct128; ///< short (128 samples) frame transform context
288 AACPCEInfo pce; ///< PCE data, if needed
289 float *planar_samples[16]; ///< saved preprocessed input
290
291 int profile; ///< copied from avctx
292 int needs_pce; ///< flag for non-standard layout
293 int needs_height_ext; ///< flag for PCE height extension
294 LPCContext lpc; ///< used by TNS
295 int samplerate_index; ///< MPEG-4 samplerate index
296 int channels; ///< channel count
297 int bandwidth; ///< coding bandwidth in Hz, fixed at init; the psy model and the coders' band cutoff agree on it
298 const uint8_t *reorder_map; ///< lavc to aac reorder map
299 const uint8_t *chan_map; ///< channel configuration map
300
301 ChannelElement *cpe; ///< channel elements
304 int cur_channel; ///< current channel for coder context
306 float lambda;
307 int last_frame_pb_count; ///< number of bits for the previous frame
308 float lambda_sum; ///< sum(lambda), for Qvg reporting
309 int lambda_count; ///< count(lambda), for Qvg reporting
310 /* tool-usage stats, reported at close: per-coded-band for PNS (channel bands),
311 * per-coded-pair-band for M/S and I/S (CPE bands) */
312 uint64_t stat_ch_bands, stat_pns; ///< coded channel-bands, of which PNS
313 uint64_t stat_cpe_bands, stat_ms, stat_is; ///< coded CPE pair-bands, of which M/S, I/S
314 uint64_t stat_chans, stat_short; ///< coded channels, of which short-block (transient)
315 uint64_t stat_tns_long, stat_tns_short; ///< TNS-active channels among long / short blocks
316 enum RawDataBlockType cur_type; ///< channel group type cur_channel belongs to
317
319 DECLARE_ALIGNED(32, int, qcoefs)[96]; ///< quantized coefficients
320 DECLARE_ALIGNED(32, float, scoefs)[1024]; ///< scaled coefficients
321
323 AACQuantizeBandCostCacheEntry quantize_band_cost_cache[256][128]; ///< memoization area for quantize_band_cost
324
326 AACNMRCurves *nmr; ///< NMR coder scratch (NULL unless coder == nmr)
327
328 struct {
329 float *samples;
332
334
335
336#endif /* AVCODEC_AACENC_H */
AAC definitions and structures.
WindowSequence
Definition aac.h:63
BandType
Definition aac.h:70
RawDataBlockType
Definition aac.h:43
#define TNS_MAX_ORDER
Definition aac.h:36
#define MAX_PREDICTORS
Definition aac.h:89
const AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB]
Definition aaccoder.c:827
#define NMR_NCAND
per-band scalefactor candidates above the finest codeable sf (NMR coder)
Definition aacenc.h:173
AACCoder
Definition aacenc.h:44
@ AAC_CODER_FAST
Definition aacenc.h:46
@ AAC_CODER_NMR
Definition aacenc.h:47
@ AAC_CODER_NB
Definition aacenc.h:49
@ AAC_CODER_TWOLOOP
Definition aacenc.h:45
void ff_quantize_band_cost_cache_init(struct AACEncContext *s)
Definition aacenc.c:557
static float win(SuperEqualizerContext *s, float n, int N)
static FILE * out
Libavcodec external API header.
#define s(width, name)
Definition cbs_vp9.c:198
Public libavutil channel layout APIs header.
long long int64_t
Definition coverity.c:34
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
bitstream writer API
void(* encode_tns_info)(struct AACEncContext *s, SingleChannelElement *sce)
Definition aacenc.h:151
void(* search_for_ms)(struct AACEncContext *s, ChannelElement *cpe)
Definition aacenc.h:157
void(* search_for_quantizers)(AVCodecContext *avctx, struct AACEncContext *s, SingleChannelElement *sce, const float lambda)
Definition aacenc.h:145
void(* mark_pns)(struct AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
Definition aacenc.h:155
void(* search_for_pns)(struct AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
Definition aacenc.h:154
void(* encode_window_bands_info)(struct AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda)
Definition aacenc.h:147
void(* apply_tns_filt)(struct AACEncContext *s, SingleChannelElement *sce)
Definition aacenc.h:152
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)
Definition aacenc.h:149
void(* set_special_band_scalefactors)(struct AACEncContext *s, SingleChannelElement *sce)
Definition aacenc.h:153
void(* search_for_tns)(struct AACEncContext *s, SingleChannelElement *sce)
Definition aacenc.h:156
void(* search_for_is)(struct AACEncContext *s, AVCodecContext *avctx, ChannelElement *cpe)
Definition aacenc.h:158
AAC encoder context.
Definition aacenc.h:279
int profile
copied from avctx
Definition aacenc.h:291
AudioFrameQueue afq
Definition aacenc.h:318
AACPCEInfo pce
PCE data, if needed.
Definition aacenc.h:288
uint64_t stat_is
coded CPE pair-bands, of which M/S, I/S
Definition aacenc.h:313
AVTXContext * mdct1024
long (1024 samples) frame transform context
Definition aacenc.h:283
float * planar_samples[16]
saved preprocessed input
Definition aacenc.h:289
FFPsyContext psy
Definition aacenc.h:302
int last_frame_pb_count
number of bits for the previous frame
Definition aacenc.h:307
int needs_height_ext
flag for PCE height extension
Definition aacenc.h:293
float * samples
Definition aacenc.h:329
uint64_t stat_tns_long
Definition aacenc.h:315
int random_state
Definition aacenc.h:305
LPCContext lpc
used by TNS
Definition aacenc.h:294
const uint8_t * chan_map
channel configuration map
Definition aacenc.h:299
uint16_t quantize_band_cost_cache_generation
Definition aacenc.h:322
int qcoefs[96]
quantized coefficients
Definition aacenc.h:319
AACQuantizeBandCostCacheEntry quantize_band_cost_cache[256][128]
memoization area for quantize_band_cost
Definition aacenc.h:323
uint64_t stat_ms
Definition aacenc.h:313
AVFloatDSPContext * fdsp
Definition aacenc.h:287
int bandwidth
coding bandwidth in Hz, fixed at init; the psy model and the coders' band cutoff agree on it
Definition aacenc.h:297
AVTXContext * mdct128
short (128 samples) frame transform context
Definition aacenc.h:285
AACEncDSPContext aacdsp
Definition aacenc.h:325
float lambda_sum
sum(lambda), for Qvg reporting
Definition aacenc.h:308
av_tx_fn mdct1024_fn
Definition aacenc.h:284
AACNMRCurves * nmr
NMR coder scratch (NULL unless coder == nmr)
Definition aacenc.h:326
int channels
channel count
Definition aacenc.h:296
ChannelElement * cpe
channel elements
Definition aacenc.h:301
av_tx_fn mdct128_fn
Definition aacenc.h:286
int needs_pce
flag for non-standard layout
Definition aacenc.h:292
uint64_t stat_ch_bands
Definition aacenc.h:312
uint64_t stat_pns
coded channel-bands, of which PNS
Definition aacenc.h:312
float lambda
Definition aacenc.h:306
int lambda_count
count(lambda), for Qvg reporting
Definition aacenc.h:309
PutBitContext pb
Definition aacenc.h:282
uint64_t stat_tns_short
TNS-active channels among long / short blocks.
Definition aacenc.h:315
int cur_channel
current channel for coder context
Definition aacenc.h:304
float scoefs[1024]
scaled coefficients
Definition aacenc.h:320
const AACCoefficientsEncoder * coder
Definition aacenc.h:303
uint64_t stat_short
coded channels, of which short-block (transient)
Definition aacenc.h:314
AACEncOptions options
encoding options
Definition aacenc.h:281
const uint8_t * reorder_map
lavc to aac reorder map
Definition aacenc.h:298
enum RawDataBlockType cur_type
channel group type cur_channel belongs to
Definition aacenc.h:316
int samplerate_index
MPEG-4 samplerate index.
Definition aacenc.h:295
uint64_t stat_chans
Definition aacenc.h:314
uint64_t stat_cpe_bands
Definition aacenc.h:313
AVClass * av_class
Definition aacenc.h:280
int mid_side
Definition aacenc.h:71
int nmr_speed
NMR coder speed level: 0 = slowest/best, higher is faster.
Definition aacenc.h:73
int intensity_stereo
Definition aacenc.h:72
int allow_71wide
Definition aacenc.h:74
int rc
rate-control mode: 0 = cbr (corridor+bucket), 1 = abr (nd-target + slow servo)
Definition aacenc.h:75
float nd[2][128][NMR_NCAND]
dist / threshold per candidate, per pair slot
Definition aacenc.h:208
int frames_since_short
long-block frames since the last short run (the "gap"): large = isolated transient
Definition aacenc.h:240
float press
rate-pressure ramp [0,1]: lambda EMA against anchors that scale up when nd_ema flags noise-class cont...
Definition aacenc.h:248
int nb[2][128][NMR_NCAND]
spectral bits per candidate, per pair slot
Definition aacenc.h:209
uint8_t smode[16][128]
per-pair previous stereo mode per band, two banks per pair (long/short grid): each grid's memory pers...
Definition aacenc.h:222
int64_t win_frame_num
frame the window history was last advanced for
Definition aacenc.h:242
float sema_es[16][128]
smoothed side energy per band (stereo-decision EMA)
Definition aacenc.h:227
uint8_t pns_prev[16][128]
per-channel PNS state last frame (decision hysteresis)
Definition aacenc.h:219
int zero_nw[16]
window count zero_prev was recorded on
Definition aacenc.h:216
uint8_t tns8_prev[16]
short-TNS accepted last frame (per channel): Schmitt state for the accept bar
Definition aacenc.h:224
float lam_slew_ch[16]
per-channel slew state for decoupled solo solves (a shared slew cross-contaminates the pair)
Definition aacenc.h:245
float nd_ema
smoothed achieved distortion/real-mask over long-frame coded bands (1 = at threshold; >>1 flags psy-u...
Definition aacenc.h:247
NMRSlot slot[2]
pair slots (solo solves use slot 0)
Definition aacenc.h:210
int rc_sat_frame
the current frame hit a saturated overage
Definition aacenc.h:239
int rc_satrun
consecutive frames with saturated reservoir debt (cap escalation)
Definition aacenc.h:238
int abr_longs
long frames seen during bootstrap
Definition aacenc.h:262
float run_burst
transient bit-burst factor, set at run start and held across the short run
Definition aacenc.h:243
int64_t abr_frame_num
once-per-frame servo guard
Definition aacenc.h:263
float abr_ema
EMA of real frame bits.
Definition aacenc.h:256
int rc_fill
virtual bit reservoir fill, + = bits saved vs nominal
Definition aacenc.h:237
float abr_t
current nd target (log2 dist/mask)
Definition aacenc.h:254
int smode_nw[8]
window count the stored modes were decided on
Definition aacenc.h:226
int rc_gl
rc_global latched at frame start: the corridor bootstrap must not flip the CPE defer logic between ch...
Definition aacenc.h:212
uint8_t zero_prev[16][128]
per-channel band zero state last frame (zeroing hysteresis)
Definition aacenc.h:215
uint8_t smode_band[8][128]
last decided stereo mode per band index (side-band tests)
Definition aacenc.h:223
float lam_short_ema
smoothed operating lambda of short frames
Definition aacenc.h:249
float lam_floor
lambda min-tracker (snaps down, +2%/frame up): sustained-strain floor; bursty spikes at a comfortable...
Definition aacenc.h:251
uint8_t pns_run_off[16][128]
consecutive frames the band has wanted OUT
Definition aacenc.h:221
uint8_t pns_run_on[16][128]
consecutive frames the band has WANTED PNS
Definition aacenc.h:220
int64_t rc_frame_num
frame the reservoir was last advanced for
Definition aacenc.h:235
float lam_long_ema
smoothed operating lambda of long frames
Definition aacenc.h:250
int pending
slot 0 holds a deferred first channel
Definition aacenc.h:214
int abr_boots
open-loop corrections fired so far
Definition aacenc.h:260
float sema_img[16][128]
smoothed I/S image-error/mask ratio per band
Definition aacenc.h:229
float abr_glide
pending set-point correction, drained per-frame (no discrete quality steps)
Definition aacenc.h:255
float vbr_infl[16]
per-channel grouped-stat inflation measured at shorts-run entry
Definition aacenc.h:246
int abr_booted
seed correction applied (re-armed while the rate is still off)
Definition aacenc.h:259
uint8_t sinit[16]
stereo state bank initialized
Definition aacenc.h:225
uint8_t thr_prev_ok[16]
thr_prev holds a long-frame measurement
Definition aacenc.h:218
int abr_hold
frames since the target last stepped
Definition aacenc.h:258
int counted[16]
per-channel bits the trellis accounted for in the last solve
Definition aacenc.h:231
float thr_prev[16][64]
per-channel long-grid law thresholds of the previous frame
Definition aacenc.h:217
int prev_was_short
previous frame was a short block (for run-start detection)
Definition aacenc.h:241
int side_inited
side_ema holds a measurement
Definition aacenc.h:233
float lam_slew
final operating lambda of the previous RC frame (slew-limiter state)
Definition aacenc.h:244
float side_ema
running estimate of real-minus-counted bits per frame
Definition aacenc.h:232
float abr_alloc_ema
EMA of psy bit demand (fill shaping)
Definition aacenc.h:261
float lam_rc
global-lambda rate control: operating lambda, 0 until bootstrapped
Definition aacenc.h:236
float sema_em[16][128]
smoothed mid energy per band
Definition aacenc.h:228
float lam[16]
per-channel operating lambda of the previous frame, 0 = none yet
Definition aacenc.h:230
int rc_fill_seeded
reservoir seeded full at stream start (decoder buffer starts full)
Definition aacenc.h:213
float abr_acc
accumulated set-point correction
Definition aacenc.h:257
int pair
current element is a CPE: pool the pair budget
Definition aacenc.h:211
uint8_t num_ele[4]
front, side, back, lfe
Definition aacenc.h:268
AVChannelLayout layout
Definition aacenc.h:267
uint8_t index[4][8]
front, side, back, lfe
Definition aacenc.h:270
uint8_t pairing[3][8]
front, side, back
Definition aacenc.h:269
uint8_t config_map[16]
configs the encoder's channel specific settings
Definition aacenc.h:272
uint8_t height[3][8]
front, side, back
Definition aacenc.h:271
uint8_t reorder_map[16]
maps channels from lavc to aac order
Definition aacenc.h:273
An AVChannelLayout holds information about the channel layout of audio data.
Describe the class of an AVClass context structure.
Definition log.h:76
main external API structure.
Definition avcodec.h:443
channel element - generic struct for SCE/CPE/CCE/LFE
Definition aacdec.h:296
uint8_t ms_mask[128]
Set if mid/side stereo is used for each scalefactor window band.
Definition aacdec.h:300
SingleChannelElement ch[2]
Definition aacdec.h:302
uint8_t is_mask[128]
Set if intensity stereo is used.
Definition aacenc.h:137
int ms_mode
Signals mid/side stereo flags coding mode.
Definition aacenc.h:134
int common_window
Set if channels share a common 'IndividualChannelStream' in bitstream.
Definition aacenc.h:133
uint8_t is_mode
Set if any bands have been encoded using intensity stereo.
Definition aacenc.h:135
context used by psychoacoustic model
Definition psymodel.h:89
Individual Channel Stream.
Definition aacdec.h:169
uint8_t max_sfb
number of scalefactor bands per group
Definition aacdec.h:170
int num_swb
number of scalefactor window bands
Definition aacdec.h:178
uint8_t group_len[8]
Definition aacdec.h:175
uint8_t use_kb_window[2]
If set, use Kaiser-Bessel window, otherwise use a sine window.
Definition aacdec.h:172
float clip_avoidance_factor
set if any window is near clipping to the necessary atennuation factor to avoid it
Definition aacenc.h:92
const uint8_t * swb_sizes
table of scalefactor band sizes for a particular window
Definition aacenc.h:87
enum WindowSequence window_sequence[2]
Definition aacdec.h:171
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
Definition aacdec.h:177
uint8_t window_clipping[8]
set if a certain window is near clipping
Definition aacdec.h:185
NMR coder per-band candidate cost curves (~96 KiB) and rate-control carry-over.
Definition aacenc.h:183
int chosen[128]
Definition aacenc.h:193
float pspread[128]
band tonality spread (1 = noise)
Definition aacenc.h:202
int nact
Definition aacenc.h:195
int minsf[128]
Definition aacenc.h:196
float tnsg[128]
TNS synthesis gain per band for THIS solve (1 = uncovered), M/S-aware (pair max)
Definition aacenc.h:200
int bst[128]
window group, swb, coef start
Definition aacenc.h:190
struct SingleChannelElement * sce
Definition aacenc.h:184
int bnc[128]
number of candidates
Definition aacenc.h:192
uint8_t hftx[128]
band strongly HF-tapered: excluded from the nd stat (deficit is by design)
Definition aacenc.h:204
float thr_real[128]
real masking threshold (PNS gates)
Definition aacenc.h:199
uint8_t is_pns[128]
band coded as noise
Definition aacenc.h:203
int si
curve-bank index (nd/nb slot)
Definition aacenc.h:185
int bw[128]
Definition aacenc.h:190
float pener[128]
band energy (PNS noise target)
Definition aacenc.h:201
int bg[128]
Definition aacenc.h:190
float thr[128]
allocation-law effective threshold
Definition aacenc.h:198
int bidx[128]
sce band index (w*16+g)
Definition aacenc.h:189
int nbnd
coded-band count, 0 = nothing codeable
Definition aacenc.h:187
int blo[128]
finest candidate scalefactor
Definition aacenc.h:191
int act[128]
active (non-PNS) band coding order
Definition aacenc.h:194
float maxvals[128]
Definition aacenc.h:197
int is8
EIGHT_SHORT frame.
Definition aacenc.h:188
int cur_ch
encoder channel index (psy/cache context)
Definition aacenc.h:186
Predictor State.
Definition aac.h:103
Single Channel Element - used for both SCE and LFE elements.
Definition aacdec.h:217
float pcoeffs[1024]
coefficients for IMDCT, pristine
Definition aacenc.h:122
uint8_t zeroes[128]
band is not coded
Definition aacenc.h:118
struct PredictorState * predictor_state
Definition aacdec.h:231
float coeffs[1024]
coefficients for IMDCT, maybe processed
Definition aacenc.h:123
float is_ener[128]
Intensity stereo pos.
Definition aacenc.h:120
uint8_t can_pns[128]
band is allowed to PNS (informative)
Definition aacenc.h:119
TemporalNoiseShaping tns
Definition aacdec.h:220
float pns_ener[128]
Noise energy values.
Definition aacenc.h:121
enum BandType band_alt[128]
alternative band type
Definition aacenc.h:116
float ret_buf[2048]
PCM output buffer.
Definition aacenc.h:124
enum BandType band_type[128]
band types
Definition aacdec.h:221
IndividualChannelStream ics
Definition aacdec.h:218
int sf_idx[128]
scalefactor indices
Definition aacenc.h:117
Temporal Noise Shaping.
Definition aacdec.h:191
int direction[8][4]
Definition aacdec.h:195
int length[8][4]
Definition aacdec.h:194
int order[8][4]
Definition aacdec.h:196
float coef[8][4][TNS_MAX_ORDER]
Definition aacenc.h:105
int coef_idx[8][4][TNS_MAX_ORDER]
Definition aacenc.h:104
static char buffer[20]
Definition seek.c:32
int size
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
Definition tx.h:151
static double cb(void *priv, double x, double y)
Definition vf_geq.c:247