From a3fadcb9f48c2504abe9d375adb2837b2c2cd4e3 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Fri, 9 Sep 2016 16:13:43 -0400 Subject: [PATCH] Fixes surround_analysis() for frame size > 20 ms --- src/opus_multistream_encoder.c | 35 +++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/opus_multistream_encoder.c b/src/opus_multistream_encoder.c index c07132f1..645dfa15 100644 --- a/src/opus_multistream_encoder.c +++ b/src/opus_multistream_encoder.c @@ -240,6 +240,7 @@ void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *b int pos[8] = {0}; int upsample; int frame_size; + int freq_size; opus_val16 channel_offset; opus_val32 bandE[21]; opus_val16 maskLogE[3][21]; @@ -250,6 +251,7 @@ void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *b upsample = resampling_factor(rate); frame_size = len*upsample; + freq_size = IMIN(960, frame_size); /* LM = log2(frame_size / 120) */ for (LM=0;LMmaxLM;LM++) @@ -258,7 +260,7 @@ void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *b ALLOC(in, frame_size+overlap, opus_val32); ALLOC(x, len, opus_val16); - ALLOC(freq, frame_size, opus_val32); + ALLOC(freq, freq_size, opus_val32); channel_pos(channels, pos); @@ -268,6 +270,9 @@ void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *b for (c=0;cpreemph, preemph_mem+c, 0); @@ -284,18 +289,26 @@ void surround_analysis(const CELTMode *celt_mode, const void *pcm, opus_val16 *b } } #endif - clt_mdct_forward(&celt_mode->mdct, in, freq, celt_mode->window, - overlap, celt_mode->maxLM-LM, 1, arch); - if (upsample != 1) + OPUS_CLEAR(bandE, 21); + for (frame=0;framemdct, in+960*frame, freq, celt_mode->window, + overlap, celt_mode->maxLM-LM, 1, arch); + if (upsample != 1) + { + int bound = freq_size/upsample; + for (i=0;i