48 #define AAC_MAX_CHANNELS 6
50 #define ERROR_IF(cond, ...) \
52 av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
53 return AVERROR(EINVAL); \
59 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8,
60 12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44,
61 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
65 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8,
66 12, 12, 12, 16, 16, 16, 20, 24, 24, 28, 36,
67 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40
71 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
72 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
73 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
78 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
79 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
80 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
84 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
85 12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28,
86 32, 36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 64
90 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
91 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, 28,
92 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 64
96 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
97 16, 16, 16, 16, 16, 16, 16, 20, 20, 20, 20, 24, 24, 24, 28, 28,
98 32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 80
109 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36
113 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16
117 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 20
121 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 20
125 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 16, 20, 20
156 { 2, 0, 1, 4, 5, 3 },
184 #define WINDOW_FUNC(type) \
185 static void apply_ ##type ##_window(AVFloatDSPContext *fdsp, \
186 SingleChannelElement *sce, \
193 float *
out = sce->ret_buf;
195 fdsp->vector_fmul (out, audio, lwindow, 1024);
196 fdsp->vector_fmul_reverse(out + 1024, audio + 1024, pwindow, 1024);
203 float *
out = sce->ret_buf;
205 fdsp->vector_fmul(out, audio, lwindow, 1024);
206 memcpy(out + 1024, audio + 1024,
sizeof(out[0]) * 448);
207 fdsp->vector_fmul_reverse(out + 1024 + 448, audio + 1024 + 448, swindow, 128);
208 memset(out + 1024 + 576, 0,
sizeof(out[0]) * 448);
215 float *
out = sce->ret_buf;
217 memset(out, 0,
sizeof(out[0]) * 448);
218 fdsp->vector_fmul(out + 448, audio + 448, swindow, 128);
219 memcpy(out + 576, audio + 576,
sizeof(out[0]) * 448);
220 fdsp->vector_fmul_reverse(out + 1024, audio + 1024, lwindow, 1024);
227 const float *
in = audio + 448;
228 float *
out = sce->ret_buf;
231 for (w = 0; w < 8; w++) {
232 fdsp->vector_fmul (out, in, w ? pwindow : swindow, 128);
235 fdsp->vector_fmul_reverse(out, in, swindow, 128);
242 const float *audio) = {
260 for (i = 0; i < 1024; i += 128)
262 memcpy(audio, audio + 1024,
sizeof(audio[0]) * 1024);
281 for (w = 1; w < 8; w++)
307 int start, maxsfb, cmaxsfb;
309 for (ch = 0; ch < chans; ch++) {
315 for (g = 0; g < ics->
num_swb; g++) {
325 for (cmaxsfb = ics->
num_swb; cmaxsfb > 0 && cpe->
ch[ch].
zeroes[w+cmaxsfb-1]; cmaxsfb--)
327 maxsfb =
FFMAX(maxsfb, cmaxsfb);
333 for (g = 0; g < ics->
max_sfb; g++) {
335 for (w2 = w; w2 < w + ics->
group_len[w]; w2++) {
336 if (!cpe->
ch[ch].
zeroes[w2*16 + g]) {
353 for (i = 0; i < ics0->
max_sfb; i++)
356 if (msc == 0 || ics0->
max_sfb == 0)
385 if (!sce->
zeroes[w*16 + i]) {
387 if (diff < 0 || diff > 120)
389 off = sce->
sf_idx[w*16 + i];
425 if (sce->
zeroes[w*16 + i]) {
464 int i, namelen, padbits;
466 namelen = strlen(name) + 2;
474 for (i = 0; i < namelen - 2; i++)
486 int end = 2048 + (frame ? frame->
nb_samples : 0);
490 for (ch = 0; ch < s->
channels; ch++) {
506 const AVFrame *frame,
int *got_packet_ptr)
511 int i, ch, w,
g, chans,
tag, start_ch, ret;
512 int chan_el_counter[4];
532 for (i = 0; i < s->
chan_map[0]; i++) {
537 for (ch = 0; ch < chans; ch++) {
539 int cur_channel = start_ch + ch;
540 overlap = &samples[cur_channel][0];
541 samples2 = overlap + 1024;
542 la = samples2 + (448+64);
587 memset(chan_el_counter, 0,
sizeof(chan_el_counter));
588 for (i = 0; i < s->
chan_map[0]; i++) {
590 const float *coeffs[2];
596 for (ch = 0; ch < chans; ch++)
599 for (ch = 0; ch < chans; ch++) {
605 && wi[0].window_type[0] == wi[1].window_type[0]
606 && wi[0].window_shape == wi[1].window_shape) {
610 if (wi[0].grouping[w] != wi[1].grouping[w]) {
621 for (g = 0; g < ics->
num_swb; g++)
635 for (ch = 0; ch < chans; ch++) {
643 if (frame_bits <= 6144 * s->channels - 3) {
734 for (i = 0; i < 16; i++)
741 "Unsupported sample rate %d\n", avctx->
sample_rate);
743 "Unsupported number of channels: %d\n", s->
channels);
745 "Unsupported profile %d\n", avctx->
profile);
747 "Too many bits per frame requested\n");
766 for (i = 0; i < s->
chan_map[0]; i++)
778 for (i = 0; i < 428; i++)
790 #define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
792 {
"stereo_mode",
"Stereo coding method", offsetof(
AACEncContext,
options.stereo_mode),
AV_OPT_TYPE_INT, {.i64 = 0}, -1, 1,
AACENC_FLAGS,
"stereo_mode"},
795 {
"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"},
static const uint8_t aac_chan_configs[6][5]
default channel configurations
uint8_t use_kb_window[2]
If set, use Kaiser-Bessel window, otherwise use a sine window.
This structure describes decoded (raw) audio or video data.
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
static const AVClass aacenc_class
av_cold void ff_kbd_window_init(float *window, float alpha, int n)
Generate a Kaiser-Bessel Derived Window.
#define SCALE_DIFF_ZERO
codebook index corresponding to zero scalefactor indices difference
av_cold void ff_psy_preprocess_end(struct FFPsyPreprocessContext *ctx)
Cleanup audio preprocessing module.
struct AACEncContext::@3 buffer
AACCoefficientsEncoder * coder
void avpriv_align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
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_dlog(ac->avr,"%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
static void put_ics_info(AACEncContext *s, IndividualChannelStream *info)
Encode ics_info element.
void(* search_for_ms)(struct AACEncContext *s, ChannelElement *cpe, const float lambda)
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[]
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.
int * num_bands
number of scalefactor bands for possible frame sizes
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const uint8_t ff_aac_num_swb_128[]
void(* search_for_quantizers)(AVCodecContext *avctx, struct AACEncContext *s, SingleChannelElement *sce, const float lambda)
AACEncOptions options
encoding options
#define WINDOW_FUNC(type)
SingleChannelElement ch[2]
int samplerate_index
MPEG-4 samplerate index.
av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq)
Initialize AudioFrameQueue.
const uint8_t * chan_map
channel configuration map
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.
static void adjust_frame_information(ChannelElement *cpe, int chans)
Produce integer coefficients from scalefactors provided by the model.
static const AVOption aacenc_options[]
const OptionDef options[]
static const uint8_t swb_size_1024_24[]
float coeffs[1024]
coefficients for IMDCT
#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. ...
void(* quantize_and_encode_band)(struct AACEncContext *s, PutBitContext *pb, const float *in, int size, int scale_idx, int cb, const float lambda)
float ff_aac_kbd_long_1024[1024]
void(* mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input)
#define CODEC_FLAG_QSCALE
Use fixed qscale.
void av_log(void *avcl, int level, const char *fmt,...)
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
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
int num_swb
number of scalefactor window bands
int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
Add a frame to the queue.
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)
#define FF_PROFILE_AAC_LOW
#define FF_PROFILE_UNKNOWN
static const uint8_t aac_chan_maps[AAC_MAX_CHANNELS][AAC_MAX_CHANNELS]
Table to remap channels from Libav's default order to AAC order.
int channels
channel count
int ff_alloc_packet(AVPacket *avpkt, int size)
Check AVPacket size and/or allocate data.
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[]
if(ac->has_optimized_func)
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[]
Libavcodec external API header.
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.
int frame_bits
number of bits used for the previously encoded frame
main external API structure.
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
static void close(AVCodecParserContext *s)
int bits
number of bits used in the bitresevoir
IndividualChannelStream ics
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
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
FFPsyWindowInfo(* window)(FFPsyContext *ctx, const float *audio, const float *la, int channel, int prev_type)
Suggest window sequence for channel.
int ms_mode
Signals mid/side stereo flags coding mode (used by encoder)
static const uint8_t * swb_size_1024[]
struct FFPsyPreprocessContext * psypp
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)
av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
Initialize a float DSP context.
const int avpriv_mpeg4audio_sample_rates[16]
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_dlog(ac->avr,"%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
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
AACCoefficientsEncoder ff_aac_coders[]
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 av_cold int init(AVCodecParserContext *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
#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(* 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...
void ff_af_queue_close(AudioFrameQueue *afq)
Close AudioFrameQueue.
enum BandType band_type[128]
band types
int frame_number
Frame counter, set by libavcodec.
float ret_buf[2048]
PCM output buffer.
void ff_aac_tableinit(void)
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)
struct FFPsyContext::@56 bitres
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
void(* encode_window_bands_info)(struct AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda)