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]) {
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++)
490 for (ch = 0; ch < s->
channels; ch++) {
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);
586 memset(chan_el_counter, 0,
sizeof(chan_el_counter));
587 for (i = 0; i < s->
chan_map[0]; i++) {
595 for (ch = 0; ch < chans; ch++)
598 for (ch = 0; ch < chans; ch++) {
604 && wi[0].window_type[0] == wi[1].window_type[0]
605 && wi[0].window_shape == wi[1].window_shape) {
609 if (wi[0].grouping[w] != wi[1].grouping[w]) {
620 for (g = 0; g < ics->
num_swb; g++)
634 for (ch = 0; ch < chans; ch++) {
642 if (frame_bits <= 6144 * s->channels - 3) {
685 #if FF_API_OLD_ENCODE_AUDIO
742 for (i = 0; i < 16; i++)
749 "Unsupported sample rate %d\n", avctx->
sample_rate);
751 "Unsupported number of channels: %d\n", s->
channels);
753 "Unsupported profile %d\n", avctx->
profile);
755 "Too many bits per frame requested\n");
774 for (i = 0; i < s->
chan_map[0]; i++)
785 for (i = 0; i < 428; i++)
797 #define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
799 {
"stereo_mode",
"Stereo coding method", offsetof(
AACEncContext,
options.stereo_mode),
AV_OPT_TYPE_INT, {.i64 = 0}, -1, 1,
AACENC_FLAGS,
"stereo_mode"},
802 {
"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"},
817 96000, 88200, 64000, 48000, 44100, 32000,
818 24000, 22050, 16000, 12000, 11025, 8000, 7350