diff options
Diffstat (limited to 'lib/rbcodec/codecs/libopus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h')
-rw-r--r-- | lib/rbcodec/codecs/libopus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libopus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h b/lib/rbcodec/codecs/libopus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h new file mode 100644 index 0000000000..fcbd96c88d --- /dev/null +++ b/lib/rbcodec/codecs/libopus/silk/fixed/mips/warped_autocorrelation_FIX_mipsr1.h | |||
@@ -0,0 +1,166 @@ | |||
1 | /*********************************************************************** | ||
2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. | ||
3 | Redistribution and use in source and binary forms, with or without | ||
4 | modification, are permitted provided that the following conditions | ||
5 | are met: | ||
6 | - Redistributions of source code must retain the above copyright notice, | ||
7 | this list of conditions and the following disclaimer. | ||
8 | - Redistributions in binary form must reproduce the above copyright | ||
9 | notice, this list of conditions and the following disclaimer in the | ||
10 | documentation and/or other materials provided with the distribution. | ||
11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the | ||
12 | names of specific contributors, may be used to endorse or promote | ||
13 | products derived from this software without specific prior written | ||
14 | permission. | ||
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
25 | POSSIBILITY OF SUCH DAMAGE. | ||
26 | ***********************************************************************/ | ||
27 | |||
28 | #ifndef __WARPED_AUTOCORRELATION_FIX_MIPSR1_H__ | ||
29 | #define __WARPED_AUTOCORRELATION_FIX_MIPSR1_H__ | ||
30 | |||
31 | #ifdef HAVE_CONFIG_H | ||
32 | #include "config.h" | ||
33 | #endif | ||
34 | |||
35 | #include "main_FIX.h" | ||
36 | |||
37 | #undef QC | ||
38 | #define QC 10 | ||
39 | |||
40 | #undef QS | ||
41 | #define QS 14 | ||
42 | |||
43 | /* Autocorrelations for a warped frequency axis */ | ||
44 | #define OVERRIDE_silk_warped_autocorrelation_FIX | ||
45 | void silk_warped_autocorrelation_FIX( | ||
46 | opus_int32 *corr, /* O Result [order + 1] */ | ||
47 | opus_int *scale, /* O Scaling of the correlation vector */ | ||
48 | const opus_int16 *input, /* I Input data to correlate */ | ||
49 | const opus_int warping_Q16, /* I Warping coefficient */ | ||
50 | const opus_int length, /* I Length of input */ | ||
51 | const opus_int order, /* I Correlation order (even) */ | ||
52 | int arch /* I Run-time architecture */ | ||
53 | ) | ||
54 | { | ||
55 | opus_int n, i, lsh; | ||
56 | opus_int32 tmp1_QS=0, tmp2_QS=0, tmp3_QS=0, tmp4_QS=0, tmp5_QS=0, tmp6_QS=0, tmp7_QS=0, tmp8_QS=0, start_1=0, start_2=0, start_3=0; | ||
57 | opus_int32 state_QS[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; | ||
58 | opus_int64 corr_QC[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 }; | ||
59 | opus_int64 temp64; | ||
60 | |||
61 | opus_int32 val; | ||
62 | val = 2 * QS - QC; | ||
63 | |||
64 | /* Order must be even */ | ||
65 | silk_assert( ( order & 1 ) == 0 ); | ||
66 | silk_assert( 2 * QS - QC >= 0 ); | ||
67 | |||
68 | /* Loop over samples */ | ||
69 | for( n = 0; n < length; n=n+4 ) { | ||
70 | |||
71 | tmp1_QS = silk_LSHIFT32( (opus_int32)input[ n ], QS ); | ||
72 | start_1 = tmp1_QS; | ||
73 | tmp3_QS = silk_LSHIFT32( (opus_int32)input[ n+1], QS ); | ||
74 | start_2 = tmp3_QS; | ||
75 | tmp5_QS = silk_LSHIFT32( (opus_int32)input[ n+2], QS ); | ||
76 | start_3 = tmp5_QS; | ||
77 | tmp7_QS = silk_LSHIFT32( (opus_int32)input[ n+3], QS ); | ||
78 | |||
79 | /* Loop over allpass sections */ | ||
80 | for( i = 0; i < order; i += 2 ) { | ||
81 | /* Output of allpass section */ | ||
82 | tmp2_QS = silk_SMLAWB( state_QS[ i ], state_QS[ i + 1 ] - tmp1_QS, warping_Q16 ); | ||
83 | corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp1_QS, start_1); | ||
84 | |||
85 | tmp4_QS = silk_SMLAWB( tmp1_QS, tmp2_QS - tmp3_QS, warping_Q16 ); | ||
86 | corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp3_QS, start_2); | ||
87 | |||
88 | tmp6_QS = silk_SMLAWB( tmp3_QS, tmp4_QS - tmp5_QS, warping_Q16 ); | ||
89 | corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp5_QS, start_3); | ||
90 | |||
91 | tmp8_QS = silk_SMLAWB( tmp5_QS, tmp6_QS - tmp7_QS, warping_Q16 ); | ||
92 | state_QS[ i ] = tmp7_QS; | ||
93 | corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp7_QS, state_QS[0]); | ||
94 | |||
95 | /* Output of allpass section */ | ||
96 | tmp1_QS = silk_SMLAWB( state_QS[ i + 1 ], state_QS[ i + 2 ] - tmp2_QS, warping_Q16 ); | ||
97 | corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp2_QS, start_1); | ||
98 | |||
99 | tmp3_QS = silk_SMLAWB( tmp2_QS, tmp1_QS - tmp4_QS, warping_Q16 ); | ||
100 | corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp4_QS, start_2); | ||
101 | |||
102 | tmp5_QS = silk_SMLAWB( tmp4_QS, tmp3_QS - tmp6_QS, warping_Q16 ); | ||
103 | corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp6_QS, start_3); | ||
104 | |||
105 | tmp7_QS = silk_SMLAWB( tmp6_QS, tmp5_QS - tmp8_QS, warping_Q16 ); | ||
106 | state_QS[ i + 1 ] = tmp8_QS; | ||
107 | corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp8_QS, state_QS[ 0 ]); | ||
108 | |||
109 | } | ||
110 | state_QS[ order ] = tmp7_QS; | ||
111 | |||
112 | corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp1_QS, start_1); | ||
113 | corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp3_QS, start_2); | ||
114 | corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp5_QS, start_3); | ||
115 | corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp7_QS, state_QS[ 0 ]); | ||
116 | } | ||
117 | |||
118 | for(;n< length; n++ ) { | ||
119 | |||
120 | tmp1_QS = silk_LSHIFT32( (opus_int32)input[ n ], QS ); | ||
121 | |||
122 | /* Loop over allpass sections */ | ||
123 | for( i = 0; i < order; i += 2 ) { | ||
124 | |||
125 | /* Output of allpass section */ | ||
126 | tmp2_QS = silk_SMLAWB( state_QS[ i ], state_QS[ i + 1 ] - tmp1_QS, warping_Q16 ); | ||
127 | state_QS[ i ] = tmp1_QS; | ||
128 | corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp1_QS, state_QS[ 0 ]); | ||
129 | |||
130 | /* Output of allpass section */ | ||
131 | tmp1_QS = silk_SMLAWB( state_QS[ i + 1 ], state_QS[ i + 2 ] - tmp2_QS, warping_Q16 ); | ||
132 | state_QS[ i + 1 ] = tmp2_QS; | ||
133 | corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp2_QS, state_QS[ 0 ]); | ||
134 | } | ||
135 | state_QS[ order ] = tmp1_QS; | ||
136 | corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp1_QS, state_QS[ 0 ]); | ||
137 | } | ||
138 | |||
139 | temp64 = corr_QC[ 0 ]; | ||
140 | temp64 = __builtin_mips_shilo(temp64, val); | ||
141 | |||
142 | lsh = silk_CLZ64( temp64 ) - 35; | ||
143 | lsh = silk_LIMIT( lsh, -12 - QC, 30 - QC ); | ||
144 | *scale = -( QC + lsh ); | ||
145 | silk_assert( *scale >= -30 && *scale <= 12 ); | ||
146 | if( lsh >= 0 ) { | ||
147 | for( i = 0; i < order + 1; i++ ) { | ||
148 | temp64 = corr_QC[ i ]; | ||
149 | //temp64 = __builtin_mips_shilo(temp64, val); | ||
150 | temp64 = (val >= 0) ? (temp64 >> val) : (temp64 << -val); | ||
151 | corr[ i ] = (opus_int32)silk_CHECK_FIT32( __builtin_mips_shilo( temp64, -lsh ) ); | ||
152 | } | ||
153 | } else { | ||
154 | for( i = 0; i < order + 1; i++ ) { | ||
155 | temp64 = corr_QC[ i ]; | ||
156 | //temp64 = __builtin_mips_shilo(temp64, val); | ||
157 | temp64 = (val >= 0) ? (temp64 >> val) : (temp64 << -val); | ||
158 | corr[ i ] = (opus_int32)silk_CHECK_FIT32( __builtin_mips_shilo( temp64, -lsh ) ); | ||
159 | } | ||
160 | } | ||
161 | |||
162 | corr_QC[ 0 ] = __builtin_mips_shilo(corr_QC[ 0 ], val); | ||
163 | |||
164 | silk_assert( corr_QC[ 0 ] >= 0 ); /* If breaking, decrease QC*/ | ||
165 | } | ||
166 | #endif /* __WARPED_AUTOCORRELATION_FIX_MIPSR1_H__ */ | ||