22#ifndef AVCODEC_PSYMODEL_H
23#define AVCODEC_PSYMODEL_H
28#define PSY_MAX_BANDS 128
30#define PSY_MAX_CHANS 20
35#define AAC_CUTOFF_FROM_BITRATE(bit_rate,channels,sample_rate) (bit_rate ? FFMIN3(FFMIN3( \
36 FFMAX(bit_rate/channels/5, bit_rate/channels*15/32 - 5500), \
37 3000 + bit_rate/channels/4, \
38 12000 + bit_rate/channels/16), \
40 sample_rate / 2): (sample_rate / 2))
41#define AAC_CUTOFF(s) ( \
42 (s->flags & AV_CODEC_FLAG_QSCALE) \
43 ? s->sample_rate / 2 \
44 : AAC_CUTOFF_FROM_BITRATE(s->bit_rate, s->ch_layout.nb_channels, s->sample_rate) \
140 const float *audio1,
const float *la1,
141 int channel0,
int channel1,
172 const uint8_t **
bands,
const int *num_bands,
173 int num_groups,
const uint8_t *group_map,
int cutoff);
197struct FFPsyPreprocessContext;
static const float bands[]
static AVFormatContext * ctx
Libavcodec external API header.
channel
Use these values when setting the channel map with ebur128_set_channel().
#define PSY_MAX_BANDS
maximum possible number of bands
void ff_psy_preprocess_end(struct FFPsyPreprocessContext *ctx)
Cleanup audio preprocessing module.
#define PSY_MAX_CHANS
maximum number of channels
void ff_psy_end(FFPsyContext *ctx)
Cleanup model context at the end.
FFPsyChannelGroup * ff_psy_find_group(FFPsyContext *ctx, int channel)
Determine what group a channel belongs to.
struct FFPsyPreprocessContext * ff_psy_preprocess_init(AVCodecContext *avctx)
psychoacoustic model audio preprocessing initialization
void ff_psy_preprocess(struct FFPsyPreprocessContext *ctx, float **audio, int channels)
Preprocess several channel in audio frame in order to compress it better.
int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens, const uint8_t **bands, const int *num_bands, int num_groups, const uint8_t *group_map, int cutoff)
Initialize psychoacoustic model.
main external API structure.
single band psychoacoustic information
psychoacoustic information for an arbitrary group of channels
FFPsyChannel * ch[PSY_MAX_CHANS]
pointers to the individual channels in the group
uint8_t coupling[PSY_MAX_BANDS]
allow coupling for this band in the group
uint8_t num_ch
number of channels in this group
single channel psychoacoustic information
FFPsyBand psy_bands[PSY_MAX_BANDS]
channel bands information
float entropy
total PE for this channel
context used by psychoacoustic model
uint8_t pair_decoupled[16]
Schmitt state over pair_joint: 1 = joint tools dead on this pair, joint windowing/M-S coupling suspen...
void * model_priv_data
psychoacoustic model implementation private data
AVCodecContext * avctx
encoder context
int cutoff
lowpass frequency cutoff for analysis
FFPsyChannel * ch
single channel information
FFPsyChannelGroup * group
channel group information
const struct FFPsyModel * model
encoder-specific model functions
int * num_bands
number of scalefactor bands for possible frame sizes
uint8_t ** bands
scalefactor band sizes for possible frame sizes
int size
size of the bitresevoir in bits
int num_lens
number of scalefactor band sets
float pair_joint[16]
encoder-fed per-CPE joint-tool candidacy fraction EMA (bands M/S would adopt or I/S renders; ~0 = joi...
int bits
number of bits used in the bitresevoir
int alloc
number of bits allocated by the psy, or -1 if no allocation was done
int num_groups
number of channel groups
struct FFPsyContext::@046037375253270226212313061064125320053063174221 bitres
codec-specific psychoacoustic model implementation
FFPsyWindowInfo(* window)(FFPsyContext *ctx, const float *audio, const float *la, int channel, int prev_type)
Suggest window sequence for channel.
void(* window_pair)(FFPsyContext *ctx, const float *audio0, const float *la0, const float *audio1, const float *la1, int channel0, int channel1, int prev_type0, int prev_type1, FFPsyWindowInfo wi[2])
Suggest window sequences for both channels of a CPE with block switching synchronized across the pair...
int(* init)(FFPsyContext *apc)
void(* end)(FFPsyContext *apc)
void(* analyze)(FFPsyContext *ctx, int channel, const float **coeffs, const FFPsyWindowInfo *wi)
Perform psychoacoustic analysis and set band info (threshold, energy) for a group of channels.
windowing related information
int num_windows
number of windows in a frame
int grouping[8]
window grouping (for e.g. AAC)
int * window_sizes
sequence of window sizes inside one frame (for eg. WMA)
float clipping[8]
maximum absolute normalized intensity in the given window for clip avoidance
int window_shape
window shape (sine/KBD/whatever)
int window_type[3]
window type (short/long/transitional, etc.) - current, previous and next