webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
vq_mipsr1.h
Go to the documentation of this file.
1 /* Copyright (c) 2007-2008 CSIRO
2  Copyright (c) 2007-2009 Xiph.Org Foundation
3  Written by Jean-Marc Valin */
4 /*
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions
7  are met:
8 
9  - Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11 
12  - Redistributions in binary form must reproduce the above copyright
13  notice, this list of conditions and the following disclaimer in the
14  documentation and/or other materials provided with the distribution.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
20  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef __VQ_MIPSR1_H__
30 #define __VQ_MIPSR1_H__
31 
32 #ifdef HAVE_CONFIG_H
33 #include "config.h"
34 #endif
35 
36 #include "mathops.h"
37 #include "arch.h"
38 
39 static unsigned extract_collapse_mask(int *iy, int N, int B);
40 static void normalise_residual(int * OPUS_RESTRICT iy, celt_norm * OPUS_RESTRICT X, int N, opus_val32 Ryy, opus_val16 gain);
41 static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int spread);
42 static void renormalise_vector_mips(celt_norm *X, int N, opus_val16 gain, int arch);
43 
44 #define OVERRIDE_vq_exp_rotation1
45 static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_val16 s)
46 {
47  int i;
48  opus_val16 ms;
49  celt_norm *Xptr;
50  Xptr = X;
51  ms = NEG16(s);
52  for (i=0;i<len-stride;i++)
53  {
54  celt_norm x1, x2;
55  x1 = Xptr[0];
56  x2 = Xptr[stride];
57  Xptr[stride] = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x2), s, x1), 15));
58  *Xptr++ = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x1), ms, x2), 15));
59  }
60  Xptr = &X[len-2*stride-1];
61  for (i=len-2*stride-1;i>=0;i--)
62  {
63  celt_norm x1, x2;
64  x1 = Xptr[0];
65  x2 = Xptr[stride];
66  Xptr[stride] = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x2), s, x1), 15));
67  *Xptr-- = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x1), ms, x2), 15));
68  }
69 }
70 
71 #define OVERRIDE_renormalise_vector
72 
73 #define renormalise_vector(X, N, gain, arch) \
74  (renormalise_vector_mips(X, N, gain, arch))
75 
76 void renormalise_vector_mips(celt_norm *X, int N, opus_val16 gain, int arch)
77 {
78  int i;
79 #ifdef FIXED_POINT
80  int k;
81 #endif
83  opus_val16 g;
84  opus_val32 t;
85  celt_norm *xptr = X;
86  int X0, X1;
87 
88  (void)arch;
89 
90  asm volatile("mult $ac1, $0, $0");
91  asm volatile("MTLO %0, $ac1" : :"r" (E));
92  /*if(N %4)
93  printf("error");*/
94  for (i=0;i<N-2;i+=2)
95  {
96  X0 = (int)*xptr++;
97  asm volatile("MADD $ac1, %0, %1" : : "r" (X0), "r" (X0));
98 
99  X1 = (int)*xptr++;
100  asm volatile("MADD $ac1, %0, %1" : : "r" (X1), "r" (X1));
101  }
102 
103  for (;i<N;i++)
104  {
105  X0 = (int)*xptr++;
106  asm volatile("MADD $ac1, %0, %1" : : "r" (X0), "r" (X0));
107  }
108 
109  asm volatile("MFLO %0, $ac1" : "=r" (E));
110 #ifdef FIXED_POINT
111  k = celt_ilog2(E)>>1;
112 #endif
113  t = VSHR32(E, 2*(k-7));
114  g = MULT16_16_P15(celt_rsqrt_norm(t),gain);
115 
116  xptr = X;
117  for (i=0;i<N;i++)
118  {
119  *xptr = EXTRACT16(PSHR32(MULT16_16(g, *xptr), k+1));
120  xptr++;
121  }
122  /*return celt_sqrt(E);*/
123 }
124 
125 #endif /* __VQ_MIPSR1_H__ */
#define NEG16(x)
Definition: arch.h:187
GLboolean GLboolean g
Definition: gl2ext.h:306
int c
Definition: cpp_unittests.cpp:275
#define MULT16_16_P15(a, b)
Definition: arch.h:229
#define MULT16_16(a, b)
Definition: arch.h:213
Definition: type_traits_unittest.cc:113
#define B(x, j)
Definition: sha512.c:425
bool t
Definition: UpdateContents.py:37
#define celt_rsqrt_norm(x)
Definition: mathops.h:86
float opus_val16
Definition: arch.h:148
#define EXTRACT16(x)
Definition: arch.h:189
void
Definition: AVFoundationCFSoftLinking.h:81
#define K
Definition: gcc-loops.cpp:16
int
Definition: runtests.py:53
#define EPSILON
Definition: arch.h:175
OPENSSL_EXPORT const ASN1_OBJECT int const unsigned char int len
Definition: x509.h:1053
DOMString k
Definition: WebCryptoAPI.idl:122
float celt_norm
Definition: arch.h:152
#define X(sym)
Definition: alsasymboltable_linux.h:139
Various math functions.
#define VSHR32(a, shift)
Definition: arch.h:196
DOMException E
Definition: TestTypedefs.idl:86
#define N
Definition: gcc-loops.cpp:14
#define MAC16_16(c, a, b)
Definition: arch.h:214
string arch
Definition: runtests.py:65
#define PSHR32(a, shift)
Definition: arch.h:195
for i
Definition: complexityMeasures.m:24
struct A s
Various architecture definitions for CELT.
float opus_val32
Definition: arch.h:149
EGLImageKHR EGLint EGLint EGLint * stride
Definition: eglext.h:851