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)
396 if (!sce->
zeroes[w*16 + i]) {
399 off = sce->
sf_idx[w*16 + i];
435 if (sce->
zeroes[w*16 + i]) {
474 int i, namelen, padbits;
476 namelen = strlen(name) + 2;
484 for (i = 0; i < namelen - 2; i++)
500 for (ch = 0; ch < s->
channels; ch++) {
521 int i, ch, w,
g, chans,
tag, start_ch,
ret, ms_mode = 0;
522 int chan_el_counter[4];
542 for (i = 0; i < s->
chan_map[0]; i++) {
547 for (ch = 0; ch < chans; ch++) {
549 int cur_channel = start_ch + ch;
550 overlap = &samples[cur_channel][0];
551 samples2 = overlap + 1024;
552 la = samples2 + (448+64);
598 memset(chan_el_counter, 0,
sizeof(chan_el_counter));
599 for (i = 0; i < s->
chan_map[0]; i++) {
601 const float *coeffs[2];
607 for (ch = 0; ch < chans; ch++)
610 for (ch = 0; ch < chans; ch++) {
616 && wi[0].window_type[0] == wi[1].window_type[0]
617 && wi[0].window_shape == wi[1].window_shape) {
621 if (wi[0].grouping[w] != wi[1].grouping[w]) {
632 for (g = 0; g < ics->
num_swb; g++)
647 for (ch = 0; ch < chans; ch++) {
655 if (frame_bits <= 6144 * s->channels - 3) {
660 for (i = 0; i < s->
chan_map[0]; i++) {
664 for (ch = 0; ch < chans; ch++)
758 for (i = 0; i < 16; i++)
767 "Unsupported sample rate %d\n", avctx->
sample_rate);
769 "Unsupported number of channels: %d\n", s->
channels);
771 "Unsupported profile %d\n", avctx->
profile);
773 "Too many bits per frame requested, clamping to max\n");
796 for (i = 0; i < s->
chan_map[0]; i++)
811 for (i = 0; i < 428; i++)
823 #define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
825 {
"stereo_mode",
"Stereo coding method", offsetof(
AACEncContext,
options.stereo_mode),
AV_OPT_TYPE_INT, {.i64 = 0}, -1, 1,
AACENC_FLAGS,
"stereo_mode"},
828 {
"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"},
829 {
"aac_coder",
"", offsetof(
AACEncContext,
options.aac_coder),
AV_OPT_TYPE_INT, {.i64 =
AAC_CODER_TWOLOOP}, 0,
AAC_CODER_NB-1,
AACENC_FLAGS,
"aac_coder"},
847 96000, 88200, 64000, 48000, 44100, 32000,
848 24000, 22050, 16000, 12000, 11025, 8000, 7350