diff options
author | William Wilgus <me.theuser@yahoo.com> | 2019-01-04 02:01:18 -0600 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2021-04-23 14:23:04 +0000 |
commit | 14c6bb798d6bebc80f07e863236adbaf8d156a9c (patch) | |
tree | 551a4b641906c2626af844fa3239c1b2b1ff0ad3 /lib/rbcodec/codecs/libopus/celt/mips/vq_mipsr1.h | |
parent | 75d93937965ec4df70d37df6d4feea04577c996b (diff) | |
download | rockbox-14c6bb798d6bebc80f07e863236adbaf8d156a9c.tar.gz rockbox-14c6bb798d6bebc80f07e863236adbaf8d156a9c.zip |
Sync opus codec to upstream git
Change-Id: I0cfcc0005c4ad7bfbb1aaf454188ce70fb043dc1
Diffstat (limited to 'lib/rbcodec/codecs/libopus/celt/mips/vq_mipsr1.h')
-rw-r--r-- | lib/rbcodec/codecs/libopus/celt/mips/vq_mipsr1.h | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/mips/vq_mipsr1.h b/lib/rbcodec/codecs/libopus/celt/mips/vq_mipsr1.h new file mode 100644 index 0000000000..fd18eab7a9 --- /dev/null +++ b/lib/rbcodec/codecs/libopus/celt/mips/vq_mipsr1.h | |||
@@ -0,0 +1,122 @@ | |||
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 void renormalise_vector_mips(celt_norm *X, int N, opus_val16 gain, int arch); | ||
40 | |||
41 | #define OVERRIDE_vq_exp_rotation1 | ||
42 | static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_val16 s) | ||
43 | { | ||
44 | int i; | ||
45 | opus_val16 ms; | ||
46 | celt_norm *Xptr; | ||
47 | Xptr = X; | ||
48 | ms = NEG16(s); | ||
49 | for (i=0;i<len-stride;i++) | ||
50 | { | ||
51 | celt_norm x1, x2; | ||
52 | x1 = Xptr[0]; | ||
53 | x2 = Xptr[stride]; | ||
54 | Xptr[stride] = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x2), s, x1), 15)); | ||
55 | *Xptr++ = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x1), ms, x2), 15)); | ||
56 | } | ||
57 | Xptr = &X[len-2*stride-1]; | ||
58 | for (i=len-2*stride-1;i>=0;i--) | ||
59 | { | ||
60 | celt_norm x1, x2; | ||
61 | x1 = Xptr[0]; | ||
62 | x2 = Xptr[stride]; | ||
63 | Xptr[stride] = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x2), s, x1), 15)); | ||
64 | *Xptr-- = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x1), ms, x2), 15)); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | #define OVERRIDE_renormalise_vector | ||
69 | |||
70 | #define renormalise_vector(X, N, gain, arch) \ | ||
71 | (renormalise_vector_mips(X, N, gain, arch)) | ||
72 | |||
73 | void renormalise_vector_mips(celt_norm *X, int N, opus_val16 gain, int arch) | ||
74 | { | ||
75 | int i; | ||
76 | #ifdef FIXED_POINT | ||
77 | int k; | ||
78 | #endif | ||
79 | opus_val32 E = EPSILON; | ||
80 | opus_val16 g; | ||
81 | opus_val32 t; | ||
82 | celt_norm *xptr = X; | ||
83 | int X0, X1; | ||
84 | |||
85 | (void)arch; | ||
86 | |||
87 | asm volatile("mult $ac1, $0, $0"); | ||
88 | asm volatile("MTLO %0, $ac1" : :"r" (E)); | ||
89 | /*if(N %4) | ||
90 | printf("error");*/ | ||
91 | for (i=0;i<N-2;i+=2) | ||
92 | { | ||
93 | X0 = (int)*xptr++; | ||
94 | asm volatile("MADD $ac1, %0, %1" : : "r" (X0), "r" (X0)); | ||
95 | |||
96 | X1 = (int)*xptr++; | ||
97 | asm volatile("MADD $ac1, %0, %1" : : "r" (X1), "r" (X1)); | ||
98 | } | ||
99 | |||
100 | for (;i<N;i++) | ||
101 | { | ||
102 | X0 = (int)*xptr++; | ||
103 | asm volatile("MADD $ac1, %0, %1" : : "r" (X0), "r" (X0)); | ||
104 | } | ||
105 | |||
106 | asm volatile("MFLO %0, $ac1" : "=r" (E)); | ||
107 | #ifdef FIXED_POINT | ||
108 | k = celt_ilog2(E)>>1; | ||
109 | #endif | ||
110 | t = VSHR32(E, 2*(k-7)); | ||
111 | g = MULT16_16_P15(celt_rsqrt_norm(t),gain); | ||
112 | |||
113 | xptr = X; | ||
114 | for (i=0;i<N;i++) | ||
115 | { | ||
116 | *xptr = EXTRACT16(PSHR32(MULT16_16(g, *xptr), k+1)); | ||
117 | xptr++; | ||
118 | } | ||
119 | /*return celt_sqrt(E);*/ | ||
120 | } | ||
121 | |||
122 | #endif /* __VQ_MIPSR1_H__ */ | ||