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]) {
388 off = sce->
sf_idx[w*16 + i];
424 if (sce->
zeroes[w*16 + i]) {
463 int i, namelen, padbits;
465 namelen = strlen(name) + 2;
473 for (i = 0; i < namelen - 2; i++)
489 for (ch = 0; ch < s->
channels; ch++) {
510 int i, ch, w,
g, chans,
tag, start_ch, ret;
511 int chan_el_counter[4];
531 for (i = 0; i < s->
chan_map[0]; i++) {
536 for (ch = 0; ch < chans; ch++) {
538 int cur_channel = start_ch + ch;
539 overlap = &samples[cur_channel][0];
540 samples2 = overlap + 1024;
541 la = samples2 + (448+64);
583 memset(chan_el_counter, 0,
sizeof(chan_el_counter));
584 for (i = 0; i < s->
chan_map[0]; i++) {
592 for (ch = 0; ch < chans; ch++)
595 for (ch = 0; ch < chans; ch++) {
601 && wi[0].window_type[0] == wi[1].window_type[0]
602 && wi[0].window_shape == wi[1].window_shape) {
606 if (wi[0].grouping[w] != wi[1].grouping[w]) {
617 for (g = 0; g < ics->
num_swb; g++)
631 for (ch = 0; ch < chans; ch++) {
639 if (frame_bits <= 6144 * s->channels - 3) {
682 #if FF_API_OLD_ENCODE_AUDIO
738 for (i = 0; i < 16; i++)
745 "Unsupported sample rate %d\n", avctx->
sample_rate);
747 "Unsupported number of channels: %d\n", s->
channels);
749 "Unsupported profile %d\n", avctx->
profile);
751 "Too many bits per frame requested\n");
770 for (i = 0; i < s->
chan_map[0]; i++)
781 for (i = 0; i < 428; i++)
793 #define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
795 {
"stereo_mode",
"Stereo coding method", offsetof(
AACEncContext,
options.stereo_mode),
AV_OPT_TYPE_INT, {.i64 = 0}, -1, 1,
AACENC_FLAGS,
"stereo_mode"},
798 {
"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"},
813 96000, 88200, 64000, 48000, 44100, 32000,
814 24000, 22050, 16000, 12000, 11025, 8000, 7350