ac3enc: halve the MDCT window size by using vector_fmul_reverse

This brings the encoder in-line with the rest of ours and saves
on a bit of memory.
This commit is contained in:
Lynne 2021-01-09 17:27:16 +01:00
parent 784c08af30
commit 238b2d4155
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
3 changed files with 11 additions and 17 deletions

View File

@ -101,15 +101,13 @@ static av_cold int ac3_fixed_mdct_init(AC3EncodeContext *s)
{
float fwin[AC3_BLOCK_SIZE];
int32_t *iwin = av_malloc_array(AC3_WINDOW_SIZE, sizeof(*iwin));
int32_t *iwin = av_malloc_array(AC3_BLOCK_SIZE, sizeof(*iwin));
if (!iwin)
return AVERROR(ENOMEM);
ff_kbd_window_init(fwin, 5.0, AC3_WINDOW_SIZE/2);
for (int i = 0; i < AC3_WINDOW_SIZE/2; i++) {
ff_kbd_window_init(fwin, 5.0, AC3_BLOCK_SIZE);
for (int i = 0; i < AC3_BLOCK_SIZE; i++)
iwin[i] = lrintf(fwin[i] * (1 << 22));
iwin[AC3_WINDOW_SIZE-1-i] = lrintf(fwin[i] * (1 << 22));
}
s->mdct_window = iwin;

View File

@ -108,23 +108,16 @@ static av_cold void ac3_float_mdct_end(AC3EncodeContext *s)
*/
static av_cold int ac3_float_mdct_init(AC3EncodeContext *s)
{
float *window;
int i, n, n2;
n = 1 << 9;
n2 = n >> 1;
window = av_malloc_array(n, sizeof(*window));
float *window = av_malloc_array(AC3_BLOCK_SIZE, sizeof(*window));
if (!window) {
av_log(s->avctx, AV_LOG_ERROR, "Cannot allocate memory.\n");
return AVERROR(ENOMEM);
}
ff_kbd_window_init(window, 5.0, n2);
for (i = 0; i < n2; i++)
window[n-1-i] = window[i];
ff_kbd_window_init(window, 5.0, AC3_BLOCK_SIZE);
s->mdct_window = window;
return ff_mdct_init(&s->mdct, 9, 0, -2.0 / n);
return ff_mdct_init(&s->mdct, 9, 0, -2.0 / AC3_WINDOW_SIZE);
}

View File

@ -92,7 +92,10 @@ static void apply_mdct(AC3EncodeContext *s)
const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE];
s->fdsp->vector_fmul(s->windowed_samples, input_samples,
s->mdct_window, AC3_WINDOW_SIZE);
s->mdct_window, AC3_BLOCK_SIZE);
s->fdsp->vector_fmul_reverse(s->windowed_samples + AC3_BLOCK_SIZE,
&input_samples[AC3_BLOCK_SIZE],
s->mdct_window, AC3_BLOCK_SIZE);
s->mdct.mdct_calc(&s->mdct, block->mdct_coef[ch+1],
s->windowed_samples);