Chris@69: /* Copyright (c) 2007-2008 CSIRO Chris@69: Copyright (c) 2007-2010 Xiph.Org Foundation Chris@69: Copyright (c) 2008 Gregory Maxwell Chris@69: Written by Jean-Marc Valin and Gregory Maxwell */ Chris@69: /* Chris@69: Redistribution and use in source and binary forms, with or without Chris@69: modification, are permitted provided that the following conditions Chris@69: are met: Chris@69: Chris@69: - Redistributions of source code must retain the above copyright Chris@69: notice, this list of conditions and the following disclaimer. Chris@69: Chris@69: - Redistributions in binary form must reproduce the above copyright Chris@69: notice, this list of conditions and the following disclaimer in the Chris@69: documentation and/or other materials provided with the distribution. Chris@69: Chris@69: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS Chris@69: ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT Chris@69: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR Chris@69: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER Chris@69: OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, Chris@69: EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, Chris@69: PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR Chris@69: PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF Chris@69: LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING Chris@69: NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS Chris@69: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Chris@69: */ Chris@69: Chris@69: #ifndef __CELT_MIPSR1_H__ Chris@69: #define __CELT_MIPSR1_H__ Chris@69: Chris@69: #ifdef HAVE_CONFIG_H Chris@69: #include "config.h" Chris@69: #endif Chris@69: Chris@69: #define CELT_C Chris@69: Chris@69: #include "os_support.h" Chris@69: #include "mdct.h" Chris@69: #include Chris@69: #include "celt.h" Chris@69: #include "pitch.h" Chris@69: #include "bands.h" Chris@69: #include "modes.h" Chris@69: #include "entcode.h" Chris@69: #include "quant_bands.h" Chris@69: #include "rate.h" Chris@69: #include "stack_alloc.h" Chris@69: #include "mathops.h" Chris@69: #include "float_cast.h" Chris@69: #include Chris@69: #include "celt_lpc.h" Chris@69: #include "vq.h" Chris@69: Chris@69: #define OVERRIDE_comb_filter Chris@69: void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, Chris@69: opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, Chris@69: const opus_val16 *window, int overlap, int arch) Chris@69: { Chris@69: int i; Chris@69: opus_val32 x0, x1, x2, x3, x4; Chris@69: Chris@69: (void)arch; Chris@69: Chris@69: /* printf ("%d %d %f %f\n", T0, T1, g0, g1); */ Chris@69: opus_val16 g00, g01, g02, g10, g11, g12; Chris@69: static const opus_val16 gains[3][3] = { Chris@69: {QCONST16(0.3066406250f, 15), QCONST16(0.2170410156f, 15), QCONST16(0.1296386719f, 15)}, Chris@69: {QCONST16(0.4638671875f, 15), QCONST16(0.2680664062f, 15), QCONST16(0.f, 15)}, Chris@69: {QCONST16(0.7998046875f, 15), QCONST16(0.1000976562f, 15), QCONST16(0.f, 15)}}; Chris@69: Chris@69: if (g0==0 && g1==0) Chris@69: { Chris@69: /* OPT: Happens to work without the OPUS_MOVE(), but only because the current encoder already copies x to y */ Chris@69: if (x!=y) Chris@69: OPUS_MOVE(y, x, N); Chris@69: return; Chris@69: } Chris@69: Chris@69: g00 = MULT16_16_P15(g0, gains[tapset0][0]); Chris@69: g01 = MULT16_16_P15(g0, gains[tapset0][1]); Chris@69: g02 = MULT16_16_P15(g0, gains[tapset0][2]); Chris@69: g10 = MULT16_16_P15(g1, gains[tapset1][0]); Chris@69: g11 = MULT16_16_P15(g1, gains[tapset1][1]); Chris@69: g12 = MULT16_16_P15(g1, gains[tapset1][2]); Chris@69: x1 = x[-T1+1]; Chris@69: x2 = x[-T1 ]; Chris@69: x3 = x[-T1-1]; Chris@69: x4 = x[-T1-2]; Chris@69: /* If the filter didn't change, we don't need the overlap */ Chris@69: if (g0==g1 && T0==T1 && tapset0==tapset1) Chris@69: overlap=0; Chris@69: Chris@69: for (i=0;i