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