annotate src/opus-1.3/celt/mips/celt_mipsr1.h @ 168:ceec0dd9ec9c

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 07 Feb 2020 11:51:13 +0000
parents 4664ac0c1032
children
rev   line source
cannam@154 1 /* Copyright (c) 2007-2008 CSIRO
cannam@154 2 Copyright (c) 2007-2010 Xiph.Org Foundation
cannam@154 3 Copyright (c) 2008 Gregory Maxwell
cannam@154 4 Written by Jean-Marc Valin and Gregory Maxwell */
cannam@154 5 /*
cannam@154 6 Redistribution and use in source and binary forms, with or without
cannam@154 7 modification, are permitted provided that the following conditions
cannam@154 8 are met:
cannam@154 9
cannam@154 10 - Redistributions of source code must retain the above copyright
cannam@154 11 notice, this list of conditions and the following disclaimer.
cannam@154 12
cannam@154 13 - Redistributions in binary form must reproduce the above copyright
cannam@154 14 notice, this list of conditions and the following disclaimer in the
cannam@154 15 documentation and/or other materials provided with the distribution.
cannam@154 16
cannam@154 17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
cannam@154 18 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
cannam@154 19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
cannam@154 20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
cannam@154 21 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
cannam@154 22 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
cannam@154 23 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
cannam@154 24 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
cannam@154 25 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
cannam@154 26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
cannam@154 27 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cannam@154 28 */
cannam@154 29
cannam@154 30 #ifndef __CELT_MIPSR1_H__
cannam@154 31 #define __CELT_MIPSR1_H__
cannam@154 32
cannam@154 33 #ifdef HAVE_CONFIG_H
cannam@154 34 #include "config.h"
cannam@154 35 #endif
cannam@154 36
cannam@154 37 #define CELT_C
cannam@154 38
cannam@154 39 #include "os_support.h"
cannam@154 40 #include "mdct.h"
cannam@154 41 #include <math.h>
cannam@154 42 #include "celt.h"
cannam@154 43 #include "pitch.h"
cannam@154 44 #include "bands.h"
cannam@154 45 #include "modes.h"
cannam@154 46 #include "entcode.h"
cannam@154 47 #include "quant_bands.h"
cannam@154 48 #include "rate.h"
cannam@154 49 #include "stack_alloc.h"
cannam@154 50 #include "mathops.h"
cannam@154 51 #include "float_cast.h"
cannam@154 52 #include <stdarg.h>
cannam@154 53 #include "celt_lpc.h"
cannam@154 54 #include "vq.h"
cannam@154 55
cannam@154 56 #define OVERRIDE_comb_filter
cannam@154 57 void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N,
cannam@154 58 opus_val16 g0, opus_val16 g1, int tapset0, int tapset1,
cannam@154 59 const opus_val16 *window, int overlap, int arch)
cannam@154 60 {
cannam@154 61 int i;
cannam@154 62 opus_val32 x0, x1, x2, x3, x4;
cannam@154 63
cannam@154 64 (void)arch;
cannam@154 65
cannam@154 66 /* printf ("%d %d %f %f\n", T0, T1, g0, g1); */
cannam@154 67 opus_val16 g00, g01, g02, g10, g11, g12;
cannam@154 68 static const opus_val16 gains[3][3] = {
cannam@154 69 {QCONST16(0.3066406250f, 15), QCONST16(0.2170410156f, 15), QCONST16(0.1296386719f, 15)},
cannam@154 70 {QCONST16(0.4638671875f, 15), QCONST16(0.2680664062f, 15), QCONST16(0.f, 15)},
cannam@154 71 {QCONST16(0.7998046875f, 15), QCONST16(0.1000976562f, 15), QCONST16(0.f, 15)}};
cannam@154 72
cannam@154 73 if (g0==0 && g1==0)
cannam@154 74 {
cannam@154 75 /* OPT: Happens to work without the OPUS_MOVE(), but only because the current encoder already copies x to y */
cannam@154 76 if (x!=y)
cannam@154 77 OPUS_MOVE(y, x, N);
cannam@154 78 return;
cannam@154 79 }
cannam@154 80
cannam@154 81 g00 = MULT16_16_P15(g0, gains[tapset0][0]);
cannam@154 82 g01 = MULT16_16_P15(g0, gains[tapset0][1]);
cannam@154 83 g02 = MULT16_16_P15(g0, gains[tapset0][2]);
cannam@154 84 g10 = MULT16_16_P15(g1, gains[tapset1][0]);
cannam@154 85 g11 = MULT16_16_P15(g1, gains[tapset1][1]);
cannam@154 86 g12 = MULT16_16_P15(g1, gains[tapset1][2]);
cannam@154 87 x1 = x[-T1+1];
cannam@154 88 x2 = x[-T1 ];
cannam@154 89 x3 = x[-T1-1];
cannam@154 90 x4 = x[-T1-2];
cannam@154 91 /* If the filter didn't change, we don't need the overlap */
cannam@154 92 if (g0==g1 && T0==T1 && tapset0==tapset1)
cannam@154 93 overlap=0;
cannam@154 94
cannam@154 95 for (i=0;i<overlap;i++)
cannam@154 96 {
cannam@154 97 opus_val16 f;
cannam@154 98 opus_val32 res;
cannam@154 99 f = MULT16_16_Q15(window[i],window[i]);
cannam@154 100 x0= x[i-T1+2];
cannam@154 101
cannam@154 102 asm volatile("MULT $ac1, %0, %1" : : "r" ((int)MULT16_16_Q15((Q15ONE-f),g00)), "r" ((int)x[i-T0]));
cannam@154 103
cannam@154 104 asm volatile("MADD $ac1, %0, %1" : : "r" ((int)MULT16_16_Q15((Q15ONE-f),g01)), "r" ((int)ADD32(x[i-T0-1],x[i-T0+1])));
cannam@154 105 asm volatile("MADD $ac1, %0, %1" : : "r" ((int)MULT16_16_Q15((Q15ONE-f),g02)), "r" ((int)ADD32(x[i-T0-2],x[i-T0+2])));
cannam@154 106 asm volatile("MADD $ac1, %0, %1" : : "r" ((int)MULT16_16_Q15(f,g10)), "r" ((int)x2));
cannam@154 107 asm volatile("MADD $ac1, %0, %1" : : "r" ((int)MULT16_16_Q15(f,g11)), "r" ((int)ADD32(x3,x1)));
cannam@154 108 asm volatile("MADD $ac1, %0, %1" : : "r" ((int)MULT16_16_Q15(f,g12)), "r" ((int)ADD32(x4,x0)));
cannam@154 109
cannam@154 110 asm volatile("EXTR.W %0,$ac1, %1" : "=r" (res): "i" (15));
cannam@154 111
cannam@154 112 y[i] = x[i] + res;
cannam@154 113
cannam@154 114 x4=x3;
cannam@154 115 x3=x2;
cannam@154 116 x2=x1;
cannam@154 117 x1=x0;
cannam@154 118 }
cannam@154 119
cannam@154 120 x4 = x[i-T1-2];
cannam@154 121 x3 = x[i-T1-1];
cannam@154 122 x2 = x[i-T1];
cannam@154 123 x1 = x[i-T1+1];
cannam@154 124
cannam@154 125 if (g1==0)
cannam@154 126 {
cannam@154 127 /* OPT: Happens to work without the OPUS_MOVE(), but only because the current encoder already copies x to y */
cannam@154 128 if (x!=y)
cannam@154 129 OPUS_MOVE(y+overlap, x+overlap, N-overlap);
cannam@154 130 return;
cannam@154 131 }
cannam@154 132
cannam@154 133 for (i=overlap;i<N;i++)
cannam@154 134 {
cannam@154 135 opus_val32 res;
cannam@154 136 x0=x[i-T1+2];
cannam@154 137
cannam@154 138 asm volatile("MULT $ac1, %0, %1" : : "r" ((int)g10), "r" ((int)x2));
cannam@154 139
cannam@154 140 asm volatile("MADD $ac1, %0, %1" : : "r" ((int)g11), "r" ((int)ADD32(x3,x1)));
cannam@154 141 asm volatile("MADD $ac1, %0, %1" : : "r" ((int)g12), "r" ((int)ADD32(x4,x0)));
cannam@154 142 asm volatile("EXTR.W %0,$ac1, %1" : "=r" (res): "i" (15));
cannam@154 143 y[i] = x[i] + res;
cannam@154 144 x4=x3;
cannam@154 145 x3=x2;
cannam@154 146 x2=x1;
cannam@154 147 x1=x0;
cannam@154 148 }
cannam@154 149 }
cannam@154 150
cannam@154 151 #endif /* __CELT_MIPSR1_H__ */