diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 4b98142536..2a2d43f0a4 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -1211,7 +1211,7 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) AAC_RENAME_32(ff_mdct_init)(&ac->mdct_small, 8, 1, 1.0 / RANGE15(128.0)); AAC_RENAME_32(ff_mdct_init)(&ac->mdct_ltp, 11, 0, RANGE15(-2.0)); #if !USE_FIXED - ret = ff_mdct15_init(&ac->mdct480, 1, 5, -1.0f); + ret = ff_mdct15_init(&ac->mdct480, 1, 5, -1.0f/(16*1024*960)); if (ret < 0) return ret; #endif @@ -2664,7 +2664,7 @@ static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement *sce) } #if !USE_FIXED if (n == 480) - ac->mdct480->imdct_half(ac->mdct480, buf, in, 1, -1.f/(16*1024*960)); + ac->mdct480->imdct_half(ac->mdct480, buf, in, 1); else #endif ac->mdct.imdct_half(&ac->mdct_ld, buf, in); diff --git a/libavcodec/mdct15.c b/libavcodec/mdct15.c index f93881fbed..cc7d833165 100644 --- a/libavcodec/mdct15.c +++ b/libavcodec/mdct15.c @@ -207,7 +207,7 @@ static void mdct15(MDCT15Context *s, float *dst, const float *src, ptrdiff_t str } static void imdct15_half(MDCT15Context *s, float *dst, const float *src, - ptrdiff_t stride, float scale) + ptrdiff_t stride) { FFTComplex fft15in[15]; FFTComplex *z = (FFTComplex *)dst; @@ -230,16 +230,11 @@ static void imdct15_half(MDCT15Context *s, float *dst, const float *src, /* Reindex again, apply twiddles and output */ for (i = 0; i < len8; i++) { - float re0, im0, re1, im1; const int i0 = len8 + i, i1 = len8 - i - 1; const int s0 = s->pfa_postreindex[i0], s1 = s->pfa_postreindex[i1]; - CMUL(re0, im1, s->tmp[s1].im, s->tmp[s1].re, s->twiddle_exptab[i1].im, s->twiddle_exptab[i1].re); - CMUL(re1, im0, s->tmp[s0].im, s->tmp[s0].re, s->twiddle_exptab[i0].im, s->twiddle_exptab[i0].re); - z[i1].re = scale * re0; - z[i1].im = scale * im0; - z[i0].re = scale * re1; - z[i0].im = scale * im1; + CMUL(z[i1].re, z[i0].im, s->tmp[s1].im, s->tmp[s1].re, s->twiddle_exptab[i1].im, s->twiddle_exptab[i1].re); + CMUL(z[i0].re, z[i1].im, s->tmp[s0].im, s->tmp[s0].re, s->twiddle_exptab[i0].im, s->twiddle_exptab[i0].re); } } diff --git a/libavcodec/mdct15.h b/libavcodec/mdct15.h index 7d83f3ebdf..1c2149d436 100644 --- a/libavcodec/mdct15.h +++ b/libavcodec/mdct15.h @@ -47,7 +47,7 @@ typedef struct MDCT15Context { /* Calculate the middle half of the iMDCT */ void (*imdct_half)(struct MDCT15Context *s, float *dst, const float *src, - ptrdiff_t src_stride, float scale); + ptrdiff_t stride); } MDCT15Context; /* Init an (i)MDCT of the length 2 * 15 * (2^N) */ diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c index 3de92f0cb2..13bfe986be 100644 --- a/libavcodec/opus_celt.c +++ b/libavcodec/opus_celt.c @@ -775,10 +775,9 @@ int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc, float **output, int channels, int frame_size, int start_band, int end_band) { - int i, j; + int i, j, downmix = 0; int consumed; // bits of entropy consumed thus far for this frame MDCT15Context *imdct; - float imdct_scale = 1.0; if (channels != 1 && channels != 2) { av_log(f->avctx, AV_LOG_ERROR, "Invalid number of coded channels: %d\n", @@ -870,7 +869,7 @@ int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc, /* stereo -> mono downmix */ if (f->output_channels < f->channels) { f->dsp->vector_fmac_scalar(f->block[0].coeffs, f->block[1].coeffs, 1.0, FFALIGN(frame_size, 16)); - imdct_scale = 0.5; + downmix = 1; } else if (f->output_channels > f->channels) memcpy(f->block[1].coeffs, f->block[0].coeffs, frame_size * sizeof(float)); @@ -895,11 +894,14 @@ int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc, float *dst = block->buf + 1024 + j * f->blocksize; imdct->imdct_half(imdct, dst + CELT_OVERLAP / 2, f->block[i].coeffs + j, - f->blocks, imdct_scale); + f->blocks); f->dsp->vector_fmul_window(dst, dst, dst + CELT_OVERLAP / 2, ff_celt_window, CELT_OVERLAP / 2); } + if (downmix) + f->dsp->vector_fmul_scalar(&block->buf[1024], &block->buf[1024], 0.5f, frame_size); + /* postfilter */ celt_postfilter(f, block);