74 #define WINDOW_FUNC(type) \
75 static void apply_ ##type ##_window(AVFloatDSPContext *fdsp, \
76 SingleChannelElement *sce, \
83 float *
out = sce->ret_buf;
85 fdsp->vector_fmul (out, audio, lwindow, 1024);
86 fdsp->vector_fmul_reverse(out + 1024, audio + 1024, pwindow, 1024);
93 float *
out = sce->ret_buf;
95 fdsp->vector_fmul(out, audio, lwindow, 1024);
96 memcpy(out + 1024, audio + 1024,
sizeof(out[0]) * 448);
97 fdsp->vector_fmul_reverse(out + 1024 + 448, audio + 1024 + 448, swindow, 128);
98 memset(out + 1024 + 576, 0,
sizeof(out[0]) * 448);
105 float *
out = sce->ret_buf;
107 memset(out, 0,
sizeof(out[0]) * 448);
108 fdsp->vector_fmul(out + 448, audio + 448, swindow, 128);
109 memcpy(out + 576, audio + 576,
sizeof(out[0]) * 448);
110 fdsp->vector_fmul_reverse(out + 1024, audio + 1024, lwindow, 1024);
117 const float *
in = audio + 448;
118 float *
out = sce->ret_buf;
121 for (w = 0; w < 8; w++) {
122 fdsp->vector_fmul (out, in, w ? pwindow : swindow, 128);
125 fdsp->vector_fmul_reverse(out, in, swindow, 128);
132 const float *audio) = {
150 for (i = 0; i < 1024; i += 128)
152 memcpy(audio, audio + 1024,
sizeof(audio[0]) * 1024);
172 for (w = 1; w < 8; w++)
200 for (ch = 0; ch < chans; ch++) {
205 for (w2 = 0; w2 < ics->
group_len[w]; w2++) {
206 for (cmaxsfb = ics->
num_swb; cmaxsfb > 0 && cpe->
ch[ch].
zeroes[w*16+cmaxsfb-1]; cmaxsfb--)
208 maxsfb =
FFMAX(maxsfb, cmaxsfb);
215 for (g = 0; g < ics->
max_sfb; g++) {
217 for (w2 = w; w2 < w + ics->
group_len[w]; w2++) {
218 if (!cpe->
ch[ch].
zeroes[w2*16 + g]) {
235 for (i = 0; i < ics0->
max_sfb; i++)
238 if (msc == 0 || ics0->
max_sfb == 0)
252 for (w2 = 0; w2 < ics->
group_len[w]; w2++) {
253 int start = (w+w2) * 128;
254 for (g = 0; g < ics->
num_swb; g++) {
262 float sum = (cpe->
ch[0].
coeffs[start+i] + p*cpe->
ch[1].
coeffs[start+i])*scale;
279 for (w2 = 0; w2 < ics->
group_len[w]; w2++) {
280 int start = (w+w2) * 128;
281 for (g = 0; g < ics->
num_swb; g++) {
288 float R = L - cpe->
ch[1].
coeffs[start+i];
319 int off_is = 0, noise_flag = 1;
324 if (!sce->
zeroes[w*16 + i]) {
326 diff = sce->
sf_idx[w*16 + i] - off_pns;
327 off_pns = sce->
sf_idx[w*16 + i];
328 if (noise_flag-- > 0) {
334 diff = sce->
sf_idx[w*16 + i] - off_is;
335 off_is = sce->
sf_idx[w*16 + i];
337 diff = sce->
sf_idx[w*16 + i] - off_sf;
338 off_sf = sce->
sf_idx[w*16 + i];
377 if (sce->
zeroes[w*16 + i]) {
383 &sce->
coeffs[start + w2*128],
406 float *swb_coeffs = &sce->
coeffs[start + w*128];
423 if (!common_window) {
444 int i, namelen, padbits;
446 namelen = strlen(name) + 2;
454 for (i = 0; i < namelen - 2; i++)
470 for (ch = 0; ch < s->
channels; ch++) {
492 int i, ch, w, chans,
tag, start_ch, ret;
493 int ms_mode = 0, is_mode = 0, tns_mode = 0, pred_mode = 0;
494 int chan_el_counter[4];
514 for (i = 0; i < s->
chan_map[0]; i++) {
519 for (ch = 0; ch < chans; ch++) {
521 int cur_channel = start_ch + ch;
522 float clip_avoidance_factor;
523 overlap = &samples[cur_channel][0];
524 samples2 = overlap + 1024;
525 la = samples2 + (448+64);
556 clip_avoidance_factor = 0.0f;
562 clip_avoidance_factor =
FFMAX(clip_avoidance_factor, wi[ch].clipping[w]);
592 memset(chan_el_counter, 0,
sizeof(chan_el_counter));
593 for (i = 0; i < s->
chan_map[0]; i++) {
604 for (ch = 0; ch < chans; ch++) {
610 for (w = 0; w < 128; w++)
615 for (ch = 0; ch < chans; ch++) {
620 && wi[0].window_type[0] == wi[1].window_type[0]
621 && wi[0].window_shape == wi[1].window_shape) {
625 if (wi[0].grouping[w] != wi[1].grouping[w]) {
631 for (ch = 0; ch < chans; ch++) {
651 for (ch = 0; ch < chans; ch++) {
660 for (ch = 0; ch < chans; ch++) {
673 for (w = 0; w < 128; w++)
688 for (ch = 0; ch < chans; ch++) {
696 if (frame_bits <= 6144 * s->channels - 3) {
700 if (is_mode || ms_mode || tns_mode || pred_mode) {
701 for (i = 0; i < s->
chan_map[0]; i++) {
705 for (ch = 0; ch < chans; ch++)
800 for (i = 0; i < 16; i++)
807 "Unsupported sample rate %d\n", avctx->
sample_rate);
809 "Unsupported number of channels: %d\n", s->
channels);
811 "Too many bits per frame requested, clamping to max\n");
817 WARN_IF(1,
"Prediction requested, changing profile to AAC-Main\n");
851 for (i = 0; i < s->
chan_map[0]; i++)
876 #define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
878 {
"stereo_mode",
"Stereo coding method", offsetof(
AACEncContext,
options.stereo_mode),
AV_OPT_TYPE_INT, {.i64 = 0}, -1, 1,
AACENC_FLAGS,
"stereo_mode"},
881 {
"ms_force",
"Force Mid/Side for the whole frame if possible", 0,
AV_OPT_TYPE_CONST, {.i64 = 1 }, INT_MIN, INT_MAX,
AACENC_FLAGS,
"stereo_mode"},
882 {
"aac_coder",
"Coding algorithm", offsetof(
AACEncContext,
options.aac_coder),
AV_OPT_TYPE_INT, {.i64 =
AAC_CODER_TWOLOOP}, 0,
AAC_CODER_NB-1,
AACENC_FLAGS,
"aac_coder"},
887 {
"aac_pns",
"Perceptual Noise Substitution", offsetof(
AACEncContext,
options.pns),
AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1,
AACENC_FLAGS,
"aac_pns"},
890 {
"aac_is",
"Intensity stereo coding", offsetof(
AACEncContext,
options.intensity_stereo),
AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1,
AACENC_FLAGS,
"intensity_stereo"},
893 {
"aac_tns",
"Temporal noise shaping", offsetof(
AACEncContext,
options.tns),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1,
AACENC_FLAGS,
"aac_tns"},
896 {
"aac_pred",
"AAC-Main prediction", offsetof(
AACEncContext,
options.pred),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1,
AACENC_FLAGS,
"aac_pred"},
void(* search_for_pns)(struct AACEncContext *s, AVCodecContext *avctx, SingleChannelElement *sce)
Band types following are encoded differently from others.
uint8_t use_kb_window[2]
If set, use Kaiser-Bessel window, otherwise use a sine window.
AACCoefficientsEncoder ff_aac_coders[AAC_CODER_NB]
This structure describes decoded (raw) audio or video data.
#define FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)
int grouping[8]
window grouping (for e.g. AAC)
uint8_t ** bands
scalefactor band sizes for possible frame sizes
void(* mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
static const AVClass aacenc_class
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
Generate a Kaiser-Bessel Derived Window.
float pcoeffs[1024]
coefficients for IMDCT, pristine
#define LIBAVUTIL_VERSION_INT
#define SCALE_DIFF_ZERO
codebook index corresponding to zero scalefactor indices difference
uint8_t window_clipping[8]
set if a certain window is near clipping
static av_cold int init(AVCodecContext *avctx)
av_cold void ff_psy_preprocess_end(struct FFPsyPreprocessContext *ctx)
Cleanup audio preprocessing module.
#define WARN_IF(cond,...)
const int ff_aac_swb_size_1024_len
AACCoefficientsEncoder * coder
void avpriv_align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
static void put_ics_info(AACEncContext *s, IndividualChannelStream *info)
Encode ics_info element.
int common_window
Set if channels share a common 'IndividualChannelStream' in bitstream.
const uint8_t * ff_aac_swb_size_1024[]
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
av_cold 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)
Initialize psychoacoustic model.
uint8_t ms_mask[128]
Set if mid/side stereo is used for each scalefactor window band.
#define NOISE_PRE
preamble for NOISE_BT, put in bitstream with the first noise band
void(* search_for_tns)(struct AACEncContext *s, SingleChannelElement *sce)
static void encode_spectral_coeffs(AACEncContext *s, SingleChannelElement *sce)
Encode spectral coefficients processed by psychoacoustic model.
Spectral data are scaled white noise not coded in the bitstream.
struct FFPsyContext::@78 bitres
int * num_bands
number of scalefactor bands for possible frame sizes
const uint8_t ff_aac_num_swb_128[]
const uint16_t * swb_offset
table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular wind...
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AACEncOptions options
encoding options
#define WINDOW_FUNC(type)
LPCContext lpc
used by TNS
static av_always_inline av_const int isnan(float x)
void ff_aac_coder_init_mips(AACEncContext *c)
SingleChannelElement ch[2]
int samplerate_index
MPEG-4 samplerate index.
av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq)
Initialize AudioFrameQueue.
static av_cold int end(AVCodecContext *avctx)
const uint8_t * chan_map
channel configuration map
#define FF_PROFILE_UNKNOWN
const uint8_t ff_aac_scalefactor_bits[121]
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static const uint8_t aac_chan_maps[AAC_MAX_CHANNELS][AAC_MAX_CHANNELS]
Table to remap channels from libavcodec's default order to AAC order.
const uint8_t * ff_aac_swb_size_128[]
Scalefactor data are intensity stereo positions (in phase).
int profile
copied from avctx
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
const OptionDef options[]
static void adjust_frame_information(ChannelElement *cpe, int chans)
Produce integer coefficients from scalefactors provided by the model.
static const AVOption aacenc_options[]
float coeffs[1024]
coefficients for IMDCT, maybe processed
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_PROFILE_AAC_MAIN
static const int sizes[][2]
const uint8_t ff_aac_num_swb_1024[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
float is_ener[128]
Intensity stereo pos (used by encoder)
int initial_padding
Audio only.
float ff_aac_kbd_long_1024[1024]
int flags
AV_CODEC_FLAG_*.
static const int mpeg4audio_sample_rates[16]
const char * name
Name of the codec implementation.
int num_windows
number of windows in a frame
static void copy_input_samples(AACEncContext *s, const AVFrame *frame)
uint8_t max_sfb
number of scalefactor bands per group
void(* set_special_band_scalefactors)(struct AACEncContext *s, SingleChannelElement *sce)
int num_swb
number of scalefactor window bands
int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
Add a frame to the queue.
Libavcodec external API header.
void(* search_for_quantizers)(AVCodecContext *avctx, struct AACEncContext *s, SingleChannelElement *sce, const float lambda)
static int put_bits_count(PutBitContext *s)
void(* search_for_is)(struct AACEncContext *s, AVCodecContext *avctx, ChannelElement *cpe)
int bit_rate
the average bitrate
enum WindowSequence window_sequence[2]
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
av_cold void ff_lpc_end(LPCContext *s)
Uninitialize LPCContext.
#define AV_CODEC_FLAG_QSCALE
Use fixed qscale.
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
static void apply_intensity_stereo(ChannelElement *cpe)
static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
void(* apply_tns_filt)(struct AACEncContext *s, SingleChannelElement *sce)
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...
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
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)
int channels
channel count
void(* encode_main_pred)(struct AACEncContext *s, SingleChannelElement *sce)
AAC definitions and structures.
void(* adjust_common_prediction)(struct AACEncContext *s, ChannelElement *cpe)
const uint8_t ff_tns_max_bands_1024[]
FFTContext mdct128
short (128 samples) frame transform context
static void(*const apply_window[4])(AVFloatDSPContext *fdsp, SingleChannelElement *sce, const float *audio)
void(* search_for_pred)(struct AACEncContext *s, SingleChannelElement *sce)
static av_cold int aac_encode_end(AVCodecContext *avctx)
int frame_size
Number of samples per channel in an audio frame.
#define CLIP_AVOIDANCE_FACTOR
AVSampleFormat
Audio sample formats.
void(* search_for_ms)(struct AACEncContext *s, ChannelElement *cpe)
static void put_audio_specific_config(AVCodecContext *avctx)
Make AAC audio config object.
int sample_rate
samples per second
float ff_aac_kbd_short_128[128]
static void encode_ms_info(PutBitContext *pb, ChannelElement *cpe)
Encode MS data.
FFPsyWindowInfo(* window)(FFPsyContext *ctx, const float *audio, const float *la, int channel, int prev_type)
Suggest window sequence for channel.
int frame_bits
number of bits used for the previously encoded frame
void(* apply_main_pred)(struct AACEncContext *s, SingleChannelElement *sce)
main external API structure.
int bits
number of bits used in the bitresevoir
#define NOISE_PRE_BITS
length of preamble
#define FF_PROFILE_AAC_LOW
Levinson-Durbin recursion.
IndividualChannelStream ics
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
void(* encode_window_bands_info)(struct AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda)
Describe the class of an AVClass context structure.
static void put_bitstream_info(AACEncContext *s, const char *name)
Write some auxiliary information about the created AAC file.
const int ff_aac_swb_size_128_len
int window_shape
window shape (sine/KBD/whatever)
static void encode_pulses(AACEncContext *s, Pulse *pulse)
Encode pulse data.
const uint8_t * swb_sizes
table of scalefactor band sizes for a particular window
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
const uint32_t ff_aac_scalefactor_code[121]
static av_cold int alloc_buffers(AVCodecContext *avctx, AACEncContext *s)
const struct FFPsyModel * model
encoder-specific model functions
av_cold int ff_lpc_init(LPCContext *s, int blocksize, int max_order, enum FFLPCType lpc_type)
Initialize LPCContext.
struct AACEncContext::@28 buffer
int ms_mode
Signals mid/side stereo flags coding mode (used by encoder)
const uint8_t ff_tns_max_bands_128[]
struct FFPsyPreprocessContext * psypp
#define NOISE_OFFSET
subtracted from global gain, used as offset for the preamble
void(* encode_tns_info)(struct AACEncContext *s, SingleChannelElement *sce)
int global_quality
Global quality for codecs which cannot change it per frame.
uint8_t zeroes[128]
band is not coded (used by encoder)
int sf_idx[128]
scalefactor indices (used by encoder)
uint8_t is_mode
Set if any bands have been encoded using intensity stereo (used by encoder)
const int avpriv_mpeg4audio_sample_rates[16]
Scalefactor data are intensity stereo positions (out of phase).
av_cold void ff_aac_tableinit(void)
Y Spectral Band Replication.
uint8_t prediction_used[41]
static av_cold int aac_encode_init(AVCodecContext *avctx)
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Single Channel Element - used for both SCE and LFE elements.
windowing related information
av_cold struct FFPsyPreprocessContext * ff_psy_preprocess_init(AVCodecContext *avctx)
psychoacoustic model audio preprocessing initialization
const uint16_t *const ff_swb_offset_1024[]
void ff_psy_preprocess(struct FFPsyPreprocessContext *ctx, float **audio, int channels)
Preprocess several channel in audio frame in order to compress it better.
static void encode_scale_factors(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce)
Encode scalefactors.
ChannelElement * cpe
channel elements
Individual Channel Stream.
float clip_avoidance_factor
set if any window is near clipping to the necessary atennuation factor to avoid it ...
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
#define ERROR_IF(cond,...)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
channel element - generic struct for SCE/CPE/CCE/LFE
FFTContext mdct1024
long (1024 samples) frame transform context
static av_always_inline int diff(const uint32_t a, const uint32_t b)
static const int16_t coeffs[]
void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts, int *duration)
Remove frame(s) from the queue.
int channels
number of audio channels
static const uint8_t aac_chan_configs[6][5]
default channel configurations
static void encode_band_info(AACEncContext *s, SingleChannelElement *sce)
Encode scalefactor band coding type.
static void apply_mid_side_stereo(ChannelElement *cpe)
void ff_af_queue_close(AudioFrameQueue *afq)
Close AudioFrameQueue.
enum BandType band_type[128]
band types
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
static enum AVSampleFormat sample_fmts[]
int frame_number
Frame counter, set by libavcodec.
float ret_buf[2048]
PCM output buffer.
static int encode_individual_channel(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, int common_window)
Encode one channel of audio data.
static void apply_window_and_mdct(AACEncContext *s, SingleChannelElement *sce, float *audio)
const uint16_t *const ff_swb_offset_128[]
uint8_t is_mask[128]
Set if intensity stereo is used (used by encoder)
uint8_t ** extended_data
pointers to the data planes/channels.
av_cold void ff_psy_end(FFPsyContext *ctx)
Cleanup model context at the end.
This structure stores compressed data.
static void avoid_clipping(AACEncContext *s, SingleChannelElement *sce)
Downscale spectral coefficients for near-clipping windows to avoid artifacts.
int window_type[3]
window type (short/long/transitional, etc.) - current, previous and next
int nb_samples
number of audio samples (per channel) described by this frame
static av_cold int dsp_init(AVCodecContext *avctx, AACEncContext *s)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
void AAC_RENAME() ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
float * planar_samples[6]
saved preprocessed input