diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index eab086cdab..7a8a77fb93 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -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; diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index b17b3a2365..74f3ab8d86 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -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); } diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index 4f1e181e0b..5ecef3b178 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -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);