49 #define AAC_MAX_CHANNELS 6
51 #define ERROR_IF(cond, ...) \
53 av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
54 return AVERROR(EINVAL); \
60 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8,
61 12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44,
62 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
66 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8,
67 12, 12, 12, 16, 16, 16, 20, 24, 24, 28, 36,
68 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40
72 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
73 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
74 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
79 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
80 12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
81 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
85 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
86 12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28,
87 32, 36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 64
91 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
92 12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 28, 28,
93 32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 64
97 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
98 16, 16, 16, 16, 16, 16, 16, 20, 20, 20, 20, 24, 24, 24, 28, 28,
99 32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 80
110 4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36
114 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16
118 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 20
122 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 20
126 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 16, 20, 20
157 { 2, 0, 1, 4, 5, 3 },
185 #define WINDOW_FUNC(type) \
186 static void apply_ ##type ##_window(DSPContext *dsp, AVFloatDSPContext *fdsp, \
187 SingleChannelElement *sce, \
194 float *out = sce->ret_buf;
196 fdsp->vector_fmul (out, audio, lwindow, 1024);
197 dsp->vector_fmul_reverse(out + 1024, audio + 1024, pwindow, 1024);
204 float *out = sce->ret_buf;
206 fdsp->vector_fmul(out, audio, lwindow, 1024);
207 memcpy(out + 1024, audio + 1024,
sizeof(out[0]) * 448);
208 dsp->vector_fmul_reverse(out + 1024 + 448, audio + 1024 + 448, swindow, 128);
209 memset(out + 1024 + 576, 0,
sizeof(out[0]) * 448);
216 float *out = sce->ret_buf;
218 memset(out, 0,
sizeof(out[0]) * 448);
219 fdsp->vector_fmul(out + 448, audio + 448, swindow, 128);
220 memcpy(out + 576, audio + 576,
sizeof(out[0]) * 448);
221 dsp->vector_fmul_reverse(out + 1024, audio + 1024, lwindow, 1024);
228 const float *in = audio + 448;
229 float *out = sce->ret_buf;
232 for (w = 0; w < 8; w++) {
233 fdsp->vector_fmul (out, in, w ? pwindow : swindow, 128);
236 dsp->vector_fmul_reverse(out, in, swindow, 128);
243 const float *audio) = {
261 for (i = 0; i < 1024; i += 128)
263 memcpy(audio, audio + 1024,
sizeof(audio[0]) * 1024);
282 for (w = 1; w < 8; w++)
308 int start, maxsfb, cmaxsfb;
310 for (ch = 0; ch < chans; ch++) {
316 for (g = 0; g < ics->
num_swb; g++) {
326 for (cmaxsfb = ics->
num_swb; cmaxsfb > 0 && cpe->
ch[ch].
zeroes[w+cmaxsfb-1]; cmaxsfb--)
328 maxsfb =
FFMAX(maxsfb, cmaxsfb);
334 for (g = 0; g < ics->
max_sfb; g++) {
336 for (w2 = w; w2 < w + ics->
group_len[w]; w2++) {
337 if (!cpe->
ch[ch].
zeroes[w2*16 + g]) {
354 for (i = 0; i < ics0->
max_sfb; i++)
357 if (msc == 0 || ics0->
max_sfb == 0)
386 if (!sce->
zeroes[w*16 + i]) {
388 if (diff < 0 || diff > 120)
390 off = sce->
sf_idx[w*16 + i];
426 if (sce->
zeroes[w*16 + i]) {
465 int i, namelen, padbits;
467 namelen = strlen(name) + 2;
475 for (i = 0; i < namelen - 2; i++)
487 int end = 2048 + (frame ? frame->
nb_samples : 0);
491 for (ch = 0; ch < s->
channels; ch++) {
507 const AVFrame *frame,
int *got_packet_ptr)
512 int i, ch, w,
g, chans,
tag, start_ch, ret;
513 int chan_el_counter[4];
533 for (i = 0; i < s->
chan_map[0]; i++) {
538 for (ch = 0; ch < chans; ch++) {
540 int cur_channel = start_ch + ch;
541 overlap = &samples[cur_channel][0];
542 samples2 = overlap + 1024;
543 la = samples2 + (448+64);
588 memset(chan_el_counter, 0,
sizeof(chan_el_counter));
589 for (i = 0; i < s->
chan_map[0]; i++) {
597 for (ch = 0; ch < chans; ch++)
600 for (ch = 0; ch < chans; ch++) {
606 && wi[0].window_type[0] == wi[1].window_type[0]
607 && wi[0].window_shape == wi[1].window_shape) {
611 if (wi[0].grouping[w] != wi[1].grouping[w]) {
622 for (g = 0; g < ics->
num_swb; g++)
636 for (ch = 0; ch < chans; ch++) {
644 if (frame_bits <= 6144 * s->channels - 3) {
687 #if FF_API_OLD_ENCODE_AUDIO
744 for (i = 0; i < 16; i++)
751 "Unsupported sample rate %d\n", avctx->
sample_rate);
753 "Unsupported number of channels: %d\n", s->
channels);
755 "Unsupported profile %d\n", avctx->
profile);
757 "Too many bits per frame requested\n");
776 for (i = 0; i < s->
chan_map[0]; i++)
787 for (i = 0; i < 428; i++)
799 #define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
801 {
"stereo_mode",
"Stereo coding method", offsetof(
AACEncContext,
options.stereo_mode),
AV_OPT_TYPE_INT, {.i64 = 0}, -1, 1,
AACENC_FLAGS,
"stereo_mode"},
804 {
"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"},