Skip to content
Snippets Groups Projects
Commit 0045499d authored by Nathan Caldwell's avatar Nathan Caldwell Committed by Alex Converse
Browse files

aacenc: Refactor apply_window_and_mdct() so it no longer takes an offset channel.

Patch by Nathan Caldwell <saintdev@gmail.com>

Originally committed as revision 24331 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 7c1bb914
No related branches found
No related tags found
No related merge requests found
...@@ -213,9 +213,10 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) ...@@ -213,9 +213,10 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
} }
static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s, static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s,
SingleChannelElement *sce, short *audio, int channel) SingleChannelElement *sce, short *audio)
{ {
int i, j, k; int i, k;
const int chans = avctx->channels;
const float * lwindow = sce->ics.use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; const float * lwindow = sce->ics.use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024;
const float * swindow = sce->ics.use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; const float * swindow = sce->ics.use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;
const float * pwindow = sce->ics.use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; const float * pwindow = sce->ics.use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128;
...@@ -230,18 +231,18 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s, ...@@ -230,18 +231,18 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s,
s->output[i] = sce->saved[i]; s->output[i] = sce->saved[i];
} }
if (sce->ics.window_sequence[0] != LONG_START_SEQUENCE) { if (sce->ics.window_sequence[0] != LONG_START_SEQUENCE) {
for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) { for (i = 0; i < 1024; i++) {
s->output[i+1024] = audio[j] * lwindow[1024 - i - 1]; s->output[i+1024] = audio[i * chans] * lwindow[1024 - i - 1];
sce->saved[i] = audio[j] * lwindow[i]; sce->saved[i] = audio[i * chans] * lwindow[i];
} }
} else { } else {
for (i = 0, j = channel; i < 448; i++, j += avctx->channels) for (i = 0; i < 448; i++)
s->output[i+1024] = audio[j]; s->output[i+1024] = audio[i * chans];
for (; i < 576; i++, j += avctx->channels) for (; i < 576; i++)
s->output[i+1024] = audio[j] * swindow[576 - i - 1]; s->output[i+1024] = audio[i * chans] * swindow[576 - i - 1];
memset(s->output+1024+576, 0, sizeof(s->output[0]) * 448); memset(s->output+1024+576, 0, sizeof(s->output[0]) * 448);
for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) for (i = 0; i < 1024; i++)
sce->saved[i] = audio[j]; sce->saved[i] = audio[i * chans];
} }
ff_mdct_calc(&s->mdct1024, sce->coeffs, s->output); ff_mdct_calc(&s->mdct1024, sce->coeffs, s->output);
} else { } else {
...@@ -249,13 +250,13 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s, ...@@ -249,13 +250,13 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s,
for (i = 448 + k; i < 448 + k + 256; i++) for (i = 448 + k; i < 448 + k + 256; i++)
s->output[i - 448 - k] = (i < 1024) s->output[i - 448 - k] = (i < 1024)
? sce->saved[i] ? sce->saved[i]
: audio[channel + (i-1024)*avctx->channels]; : audio[(i-1024)*chans];
s->dsp.vector_fmul (s->output, k ? swindow : pwindow, 128); s->dsp.vector_fmul (s->output, k ? swindow : pwindow, 128);
s->dsp.vector_fmul_reverse(s->output+128, s->output+128, swindow, 128); s->dsp.vector_fmul_reverse(s->output+128, s->output+128, swindow, 128);
ff_mdct_calc(&s->mdct128, sce->coeffs + k, s->output); ff_mdct_calc(&s->mdct128, sce->coeffs + k, s->output);
} }
for (i = 0, j = channel; i < 1024; i++, j += avctx->channels) for (i = 0; i < 1024; i++)
sce->saved[i] = audio[j]; sce->saved[i] = audio[i * chans];
} }
} }
...@@ -543,7 +544,7 @@ static int aac_encode_frame(AVCodecContext *avctx, ...@@ -543,7 +544,7 @@ static int aac_encode_frame(AVCodecContext *avctx,
ics->group_len[k] = wi[j].grouping[k]; ics->group_len[k] = wi[j].grouping[k];
s->cur_channel = start_ch + j; s->cur_channel = start_ch + j;
apply_window_and_mdct(avctx, s, &cpe->ch[j], samples2, j); apply_window_and_mdct(avctx, s, &cpe->ch[j], samples2 + j);
} }
start_ch += chans; start_ch += chans;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment