48 #define AAC_MAX_CHANNELS 6
50 #define ERROR_IF(cond, ...) \
52 av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
53 return AVERROR(EINVAL); \
56 #define WARN_IF(cond, ...) \
58 av_log(avctx, AV_LOG_WARNING, __VA_ARGS__); \
64 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8,
65 12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44,
66 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
70 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8,
71 12, 12, 12, 16, 16, 16, 20, 24, 24, 28, 36,
72 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40
76 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
77 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
78 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
83 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
84 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
85 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
89 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
90 12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28,
91 32, 36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 64
95 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
96 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, 28,
97 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 64
101 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
102 16, 16, 16, 16, 16, 16, 16, 20, 20, 20, 20, 24, 24, 24, 28, 28,
103 32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 80
115 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36
119 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16
123 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 20
127 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 20
131 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 16, 20, 20
163 { 2, 0, 1, 4, 5, 3 },
191 #define WINDOW_FUNC(type) \
192 static void apply_ ##type ##_window(AVFloatDSPContext *fdsp, \
193 SingleChannelElement *sce, \
200 float *
out = sce->ret_buf;
202 fdsp->vector_fmul (out, audio, lwindow, 1024);
203 fdsp->vector_fmul_reverse(out + 1024, audio + 1024, pwindow, 1024);
210 float *
out = sce->ret_buf;
212 fdsp->vector_fmul(out, audio, lwindow, 1024);
213 memcpy(out + 1024, audio + 1024,
sizeof(out[0]) * 448);
214 fdsp->vector_fmul_reverse(out + 1024 + 448, audio + 1024 + 448, swindow, 128);
215 memset(out + 1024 + 576, 0,
sizeof(out[0]) * 448);
222 float *
out = sce->ret_buf;
224 memset(out, 0,
sizeof(out[0]) * 448);
225 fdsp->vector_fmul(out + 448, audio + 448, swindow, 128);
226 memcpy(out + 576, audio + 576,
sizeof(out[0]) * 448);
227 fdsp->vector_fmul_reverse(out + 1024, audio + 1024, lwindow, 1024);
234 const float *
in = audio + 448;
235 float *
out = sce->ret_buf;
238 for (w = 0; w < 8; w++) {
239 fdsp->vector_fmul (out, in, w ? pwindow : swindow, 128);
242 fdsp->vector_fmul_reverse(out, in, swindow, 128);
249 const float *audio) = {
267 for (i = 0; i < 1024; i += 128)
269 memcpy(audio, audio + 1024,
sizeof(audio[0]) * 1024);
289 for (w = 1; w < 8; w++)
315 int start, maxsfb, cmaxsfb;
317 for (ch = 0; ch < chans; ch++) {
323 for (w2 = 0; w2 < ics->
group_len[w]; w2++) {
324 start = (w+w2) * 128;
325 for (g = 0; g < ics->
num_swb; g++) {
335 for (cmaxsfb = ics->
num_swb; cmaxsfb > 0 && cpe->
ch[ch].
zeroes[w*16+cmaxsfb-1]; cmaxsfb--)
337 maxsfb =
FFMAX(maxsfb, cmaxsfb);
344 for (g = 0; g < ics->
max_sfb; g++) {
346 for (w2 = w; w2 < w + ics->
group_len[w]; w2++) {
347 if (!cpe->
ch[ch].
zeroes[w2*16 + g]) {
364 for (i = 0; i < ics0->
max_sfb; i++)
367 if (msc == 0 || ics0->
max_sfb == 0)
397 if (!sce->
zeroes[w*16 + i]) {
399 diff = sce->
sf_idx[w*16 + i] - off_pns;
400 off_pns = sce->
sf_idx[w*16 + i];
401 if (noise_flag-- > 0) {
406 diff = sce->
sf_idx[w*16 + i] - off_sf;
407 off_sf = sce->
sf_idx[w*16 + i];
446 if (sce->
zeroes[w*16 + i]) {
485 int i, namelen, padbits;
487 namelen = strlen(name) + 2;
495 for (i = 0; i < namelen - 2; i++)
511 for (ch = 0; ch < s->
channels; ch++) {
532 int i, ch, w,
g, chans,
tag, start_ch,
ret, ms_mode = 0;
533 int chan_el_counter[4];
553 for (i = 0; i < s->
chan_map[0]; i++) {
558 for (ch = 0; ch < chans; ch++) {
560 int cur_channel = start_ch + ch;
561 overlap = &samples[cur_channel][0];
562 samples2 = overlap + 1024;
563 la = samples2 + (448+64);
609 memset(chan_el_counter, 0,
sizeof(chan_el_counter));
610 for (i = 0; i < s->
chan_map[0]; i++) {
612 const float *coeffs[2];
618 for (ch = 0; ch < chans; ch++)
621 for (ch = 0; ch < chans; ch++) {
627 && wi[0].window_type[0] == wi[1].window_type[0]
628 && wi[0].window_shape == wi[1].window_shape) {
632 if (wi[0].grouping[w] != wi[1].grouping[w]) {
643 for (g = 0; g < ics->
num_swb; g++)
658 for (ch = 0; ch < chans; ch++) {
666 if (frame_bits <= 6144 * s->channels - 3) {
671 for (i = 0; i < s->
chan_map[0]; i++) {
675 for (ch = 0; ch < chans; ch++)
769 for (i = 0; i < 16; i++)
778 "Unsupported sample rate %d\n", avctx->
sample_rate);
780 "Unsupported number of channels: %d\n", s->
channels);
782 "Unsupported profile %d\n", avctx->
profile);
784 "Too many bits per frame requested, clamping to max\n");
807 for (i = 0; i < s->
chan_map[0]; i++)
822 for (i = 0; i < 428; i++)
834 #define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
836 {
"stereo_mode",
"Stereo coding method", offsetof(
AACEncContext,
options.stereo_mode),
AV_OPT_TYPE_INT, {.i64 = 0}, -1, 1,
AACENC_FLAGS,
"stereo_mode"},
839 {
"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"},
840 {
"aac_coder",
"", offsetof(
AACEncContext,
options.aac_coder),
AV_OPT_TYPE_INT, {.i64 =
AAC_CODER_TWOLOOP}, 0,
AAC_CODER_NB-1,
AACENC_FLAGS,
"aac_coder"},
845 {
"aac_pns",
"Perceptual Noise Substitution", offsetof(
AACEncContext,
options.pns),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1,
AACENC_FLAGS,
"aac_pns"},
861 96000, 88200, 64000, 48000, 44100, 32000,
862 24000, 22050, 16000, 12000, 11025, 8000, 7350
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and/or allocate data.
static const uint8_t aac_chan_configs[6][5]
default channel configurations
void(* search_for_ms)(struct AACEncContext *s, ChannelElement *cpe, const float lambda)
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)
static const uint8_t swb_size_1024_64[]
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
static av_cold int init(AVCodecContext *avctx)
av_cold void ff_psy_preprocess_end(struct FFPsyPreprocessContext *ctx)
Cleanup audio preprocessing module.
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.
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.
static const uint8_t swb_size_128_8[]
#define NOISE_PRE
preamble for NOISE_BT, put in bitstream with the first noise band
static const uint8_t swb_size_1024_8[]
static const uint8_t swb_size_128_96[]
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.
int * num_bands
number of scalefactor bands for possible frame sizes
const uint8_t ff_aac_num_swb_128[]
static const int mpeg4audio_sample_rates[16]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AACEncOptions options
encoding options
#define WINDOW_FUNC(type)
static av_always_inline av_const int isnan(float x)
void ff_aac_coder_init_mips(AACEncContext *c)
void(* quantize_and_encode_band)(struct AACEncContext *s, PutBitContext *pb, const float *in, int size, int scale_idx, int cb, const float lambda)
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 swb_size_1024_48[]
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
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[]
static const uint8_t swb_size_1024_24[]
float coeffs[1024]
coefficients for IMDCT, maybe processed
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
static const int sizes[][2]
const uint8_t ff_aac_num_swb_1024[]
#define CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int initial_padding
Audio only.
float ff_aac_kbd_long_1024[1024]
struct FFPsyContext::@77 bitres
#define CODEC_FLAG_QSCALE
Use fixed qscale.
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
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)
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int bit_rate
the average bitrate
enum WindowSequence window_sequence[2]
static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
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)
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.
int channels
channel count
AAC definitions and structures.
FFTContext mdct128
short (128 samples) frame transform context
static void(*const apply_window[4])(AVFloatDSPContext *fdsp, SingleChannelElement *sce, const float *audio)
float ff_aac_pow34sf_tab[428]
static const uint8_t swb_size_128_48[]
static const uint8_t swb_size_128_24[]
static const uint8_t swb_size_1024_16[]
static av_cold int aac_encode_end(AVCodecContext *avctx)
int frame_size
Number of samples per channel in an audio frame.
static const uint8_t swb_size_1024_32[]
#define WARN_IF(cond,...)
AVSampleFormat
Audio sample formats.
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
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
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.
static const uint8_t swb_size_1024_96[]
int window_shape
window shape (sine/KBD/whatever)
static void encode_pulses(AACEncContext *s, Pulse *pulse)
Encode pulse data.
static const uint8_t swb_size_128_16[]
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.
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
struct AACEncContext::@28 buffer
int ms_mode
Signals mid/side stereo flags coding mode (used by encoder)
static const uint8_t * swb_size_1024[]
struct FFPsyPreprocessContext * psypp
#define NOISE_OFFSET
subtracted from global gain, used as offset for the preamble
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)
const int avpriv_mpeg4audio_sample_rates[16]
av_cold void ff_aac_tableinit(void)
Y Spectral Band Replication.
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
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.
#define CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
ChannelElement * cpe
channel elements
Individual Channel Stream.
float ff_aac_pow2sf_tab[428]
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static const uint8_t * swb_size_128[]
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)
#define ERROR_IF(cond,...)
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 void encode_band_info(AACEncContext *s, SingleChannelElement *sce)
Encode scalefactor band coding type.
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)
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.
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...
void ff_init_ff_sine_windows(int index)
initialize the specified entry of ff_sine_windows
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
float * planar_samples[6]
saved preprocessed input