annotate src/opus-1.3/celt/mips/celt_mipsr1.h @ 79:91c729825bca pa_catalina

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