48 #define MAX_CHANNELS 64
49 #define MAX_ELEM_ID 16
51 #define TNS_MAX_ORDER 20
52 #define MAX_LTP_LONG_SFB 40
54 #define CLIP_AVOIDANCE_FACTOR 0.95f
93 #define IS_CODEBOOK_UNSIGNED(x) (((x) - 1) & 10)
147 #define MAX_PREDICTORS 672
149 #define SCALE_DIV_512 36
150 #define SCALE_ONE_POS 140
151 #define SCALE_MAX_POS 255
152 #define SCALE_MAX_DIFF 60
153 #define SCALE_DIFF_ZERO 60
155 #define POW_SF2_ZERO 200
157 #define NOISE_PRE 256
158 #define NOISE_PRE_BITS 9
159 #define NOISE_OFFSET 90
@ INTENSITY_BT
Scalefactor data are intensity stereo positions (in phase).
@ ZERO_BT
Scalefactors and spectral data are all zero.
@ INTENSITY_BT2
Scalefactor data are intensity stereo positions (out of phase).
@ RESERVED_BT
Band types following are encoded differently from others.
@ ESC_BT
Spectral data are coded with an escape sequence.
@ FIRST_PAIR_BT
This and later band types encode two values (rather than four) with one code word.
@ NOISE_BT
Spectral data are scaled white noise not coded in the bitstream.
CouplingPoint
The point during decoding at which channel coupling is applied.
OCStatus
Output configuration status.
@ OC_TRIAL_FRAME
Output configuration under trial specified by a frame header.
@ OC_TRIAL_PCE
Output configuration under trial specified by an inband PCE.
@ OC_LOCKED
Output configuration locked in place.
@ OC_GLOBAL_HDR
Output configuration set in a global header but not yet locked.
@ OC_NONE
Output unconfigured.
void ff_aacdec_init_mips(AACContext *c)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Libavcodec external API header.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
typedef void(RENAME(mix_any_func_type))
Spectral Band Replication definitions and structures.
SingleChannelElement * output_element[MAX_CHANNELS]
Points to each SingleChannelElement.
void(* update_ltp)(AACContext *ac, SingleChannelElement *sce)
int dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
DynamicRangeControl che_drc
void(* vector_pow43)(int *coefs, int len)
OutputConfiguration oc[2]
int is_saved
Set if elements have stored overlap from previous frame.
int force_dmono_mode
0->not dmono, 1->use first channel, 2->use second channel
void(* apply_ltp)(AACContext *ac, SingleChannelElement *sce)
int warned_num_aac_frames
void(* imdct_and_windowing)(AACContext *ac, SingleChannelElement *sce)
void(* subband_scale)(int *dst, int *src, int scale, int offset, int len, void *log_context)
int warned_remapping_once
ChannelElement * tag_che_map[4][MAX_ELEM_ID]
ChannelElement * che[4][MAX_ELEM_ID]
void(* apply_tns)(INTFLOAT coef[1024], TemporalNoiseShaping *tns, IndividualChannelStream *ics, int decode)
void(* windowing_and_mdct_ltp)(AACContext *ac, INTFLOAT *out, INTFLOAT *in, IndividualChannelStream *ics)
Describe the class of an AVClass context structure.
main external API structure.
This structure describes decoded (raw) audio or video data.
int id_select[8]
element id
enum CouplingPoint coupling_point
The point during decoding at which coupling is applied.
int num_coupled
number of target elements
int ch_select[8]
[0] shared list of gains; [1] list of gains for right channel; [2] list of gains for left channel; [3...
enum RawDataBlockType type[8]
Type of channel element to be coupled - SCE or CPE.
channel element - generic struct for SCE/CPE/CCE/LFE
uint8_t is_mask[128]
Set if intensity stereo is used (used by encoder)
int ms_mode
Signals mid/side stereo flags coding mode (used by encoder)
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 (used by encoder)
uint8_t ms_mask[128]
Set if mid/side stereo is used for each scalefactor window band.
SpectralBandReplication sbr
SingleChannelElement ch[2]
Dynamic Range Control - decoded from the bitstream but not processed further.
int interpolation_scheme
Indicates the interpolation scheme used in the SBR QMF domain.
int exclude_mask[MAX_CHANNELS]
Channels to be excluded from DRC processing.
int band_incr
Number of DRC bands greater than 1 having DRC info.
int dyn_rng_ctl[17]
DRC magnitude information.
int prog_ref_level
A reference level for the long-term program audio level for all channels combined.
int pce_instance_tag
Indicates with which program the DRC info is associated.
int band_top[17]
Indicates the top of the i-th DRC band in units of 4 spectral lines.
int dyn_rng_sgn[17]
DRC sign information; 0 - positive, 1 - negative.
Individual Channel Stream.
uint8_t max_sfb
number of scalefactor bands per group
int predictor_reset_count[31]
used by encoder to count prediction resets
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.
int predictor_reset_group
uint8_t prediction_used[41]
int predictor_initialized
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]
uint8_t window_clipping[8]
set if a certain window is near clipping
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
int8_t used[MAX_LTP_LONG_SFB]
uint8_t layout_map[MAX_ELEM_ID *4][3]
Single Channel Element - used for both SCE and LFE elements.
uint8_t zeroes[128]
band is not coded (used by encoder)
INTFLOAT * ret
PCM output.
enum BandType band_type[128]
band types
float is_ener[128]
Intensity stereo pos (used by encoder)
INTFLOAT pcoeffs[1024]
coefficients for IMDCT, pristine
PredictorState predictor_state[MAX_PREDICTORS]
int band_type_run_end[120]
band type run end points
uint8_t can_pns[128]
band is allowed to PNS (informative)
INTFLOAT ret_buf[2048]
PCM output buffer.
INTFLOAT sf[120]
scalefactors
float pns_ener[128]
Noise energy values (used by encoder)
INTFLOAT coeffs[1024]
coefficients for IMDCT, maybe processed
enum BandType band_alt[128]
alternative band type (used by encoder)
INTFLOAT saved[1536]
overlap
AAC_FLOAT prcoeffs[1024]
Main prediction coefs (used by encoder)
INTFLOAT ltp_state[3072]
time signal for LTP
AAC_FLOAT lcoeffs[1024]
MDCT of LTP coefficients (used by encoder)
IndividualChannelStream ics
int sf_idx[128]
scalefactor indices (used by encoder)
Spectral Band Replication.
INTFLOAT coef[8][4][TNS_MAX_ORDER]
int coef_idx[8][4][TNS_MAX_ORDER]
static const uint8_t offset[127][2]