From 2fe4700f761e21788dd3c23c7eca9dc0d436ef10 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin <jmvalin@jmvalin.ca> Date: Sun, 26 May 2013 18:50:13 -0400 Subject: [PATCH] Skip down-sampling in deemphasis() when not needed. --- celt/celt_decoder.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/celt/celt_decoder.c b/celt/celt_decoder.c index d5d2c57f9..cfb5b36d9 100644 --- a/celt/celt_decoder.c +++ b/celt/celt_decoder.c @@ -191,6 +191,7 @@ void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, c { int c; int Nd; + int apply_downsampling=0; opus_val16 coef0; coef0 = coef[0]; @@ -215,8 +216,10 @@ void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, c tmp = SHL32(MULT16_32_Q15(coef3, tmp), 2); scratch[j] = tmp; } + apply_downsampling=1; } else #endif + if (downsample>1) { /* Shortcut for the standard (non-custom modes) case */ for (j=0;j<N;j++) @@ -225,12 +228,24 @@ void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, c m = MULT16_32_Q15(coef0, tmp); scratch[j] = tmp; } + apply_downsampling=1; + } else { + /* Shortcut for the standard (non-custom modes) case */ + for (j=0;j<N;j++) + { + celt_sig tmp = x[j] + m; + m = MULT16_32_Q15(coef0, tmp); + y[j*C] = SCALEOUT(SIG2WORD16(tmp)); + } } mem[c] = m; - /* Perform down-sampling */ - for (j=0;j<Nd;j++) - y[j*C] = SCALEOUT(SIG2WORD16(scratch[j*downsample])); + if (apply_downsampling) + { + /* Perform down-sampling */ + for (j=0;j<Nd;j++) + y[j*C] = SCALEOUT(SIG2WORD16(scratch[j*downsample])); + } } while (++c<C); } -- GitLab