webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
warped_autocorrelation_FIX_mipsr1.h
Go to the documentation of this file.
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
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 )
53 {
54  opus_int n, i, lsh;
55  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;
56  opus_int32 state_QS[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 };
57  opus_int64 corr_QC[ MAX_SHAPE_LPC_ORDER + 1 ] = { 0 };
58  opus_int64 temp64;
59 
61  val = 2 * QS - QC;
62 
63  /* Order must be even */
64  silk_assert( ( order & 1 ) == 0 );
65  silk_assert( 2 * QS - QC >= 0 );
66 
67  /* Loop over samples */
68  for( n = 0; n < length; n=n+4 ) {
69 
70  tmp1_QS = silk_LSHIFT32( (opus_int32)input[ n ], QS );
71  start_1 = tmp1_QS;
72  tmp3_QS = silk_LSHIFT32( (opus_int32)input[ n+1], QS );
73  start_2 = tmp3_QS;
74  tmp5_QS = silk_LSHIFT32( (opus_int32)input[ n+2], QS );
75  start_3 = tmp5_QS;
76  tmp7_QS = silk_LSHIFT32( (opus_int32)input[ n+3], QS );
77 
78  /* Loop over allpass sections */
79  for( i = 0; i < order; i += 2 ) {
80  /* Output of allpass section */
81  tmp2_QS = silk_SMLAWB( state_QS[ i ], state_QS[ i + 1 ] - tmp1_QS, warping_Q16 );
82  corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp1_QS, start_1);
83 
84  tmp4_QS = silk_SMLAWB( tmp1_QS, tmp2_QS - tmp3_QS, warping_Q16 );
85  corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp3_QS, start_2);
86 
87  tmp6_QS = silk_SMLAWB( tmp3_QS, tmp4_QS - tmp5_QS, warping_Q16 );
88  corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp5_QS, start_3);
89 
90  tmp8_QS = silk_SMLAWB( tmp5_QS, tmp6_QS - tmp7_QS, warping_Q16 );
91  state_QS[ i ] = tmp7_QS;
92  corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp7_QS, state_QS[0]);
93 
94  /* Output of allpass section */
95  tmp1_QS = silk_SMLAWB( state_QS[ i + 1 ], state_QS[ i + 2 ] - tmp2_QS, warping_Q16 );
96  corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp2_QS, start_1);
97 
98  tmp3_QS = silk_SMLAWB( tmp2_QS, tmp1_QS - tmp4_QS, warping_Q16 );
99  corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp4_QS, start_2);
100 
101  tmp5_QS = silk_SMLAWB( tmp4_QS, tmp3_QS - tmp6_QS, warping_Q16 );
102  corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp6_QS, start_3);
103 
104  tmp7_QS = silk_SMLAWB( tmp6_QS, tmp5_QS - tmp8_QS, warping_Q16 );
105  state_QS[ i + 1 ] = tmp8_QS;
106  corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp8_QS, state_QS[ 0 ]);
107 
108  }
109  state_QS[ order ] = tmp7_QS;
110 
111  corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp1_QS, start_1);
112  corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp3_QS, start_2);
113  corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp5_QS, start_3);
114  corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp7_QS, state_QS[ 0 ]);
115  }
116 
117  for(;n< length; n++ ) {
118 
119  tmp1_QS = silk_LSHIFT32( (opus_int32)input[ n ], QS );
120 
121  /* Loop over allpass sections */
122  for( i = 0; i < order; i += 2 ) {
123 
124  /* Output of allpass section */
125  tmp2_QS = silk_SMLAWB( state_QS[ i ], state_QS[ i + 1 ] - tmp1_QS, warping_Q16 );
126  state_QS[ i ] = tmp1_QS;
127  corr_QC[ i ] = __builtin_mips_madd( corr_QC[ i ], tmp1_QS, state_QS[ 0 ]);
128 
129  /* Output of allpass section */
130  tmp1_QS = silk_SMLAWB( state_QS[ i + 1 ], state_QS[ i + 2 ] - tmp2_QS, warping_Q16 );
131  state_QS[ i + 1 ] = tmp2_QS;
132  corr_QC[ i+1 ] = __builtin_mips_madd( corr_QC[ i+1 ], tmp2_QS, state_QS[ 0 ]);
133  }
134  state_QS[ order ] = tmp1_QS;
135  corr_QC[ order ] = __builtin_mips_madd( corr_QC[ order ], tmp1_QS, state_QS[ 0 ]);
136  }
137 
138  temp64 = corr_QC[ 0 ];
139  temp64 = __builtin_mips_shilo(temp64, val);
140 
141  lsh = silk_CLZ64( temp64 ) - 35;
142  lsh = silk_LIMIT( lsh, -12 - QC, 30 - QC );
143  *scale = -( QC + lsh );
144  silk_assert( *scale >= -30 && *scale <= 12 );
145  if( lsh >= 0 ) {
146  for( i = 0; i < order + 1; i++ ) {
147  temp64 = corr_QC[ i ];
148  //temp64 = __builtin_mips_shilo(temp64, val);
149  temp64 = (val >= 0) ? (temp64 >> val) : (temp64 << -val);
150  corr[ i ] = (opus_int32)silk_CHECK_FIT32( __builtin_mips_shilo( temp64, -lsh ) );
151  }
152  } else {
153  for( i = 0; i < order + 1; i++ ) {
154  temp64 = corr_QC[ i ];
155  //temp64 = __builtin_mips_shilo(temp64, val);
156  temp64 = (val >= 0) ? (temp64 >> val) : (temp64 << -val);
157  corr[ i ] = (opus_int32)silk_CHECK_FIT32( __builtin_mips_shilo( temp64, -lsh ) );
158  }
159  }
160 
161  corr_QC[ 0 ] = __builtin_mips_shilo(corr_QC[ 0 ], val);
162 
163  silk_assert( corr_QC[ 0 ] >= 0 ); /* If breaking, decrease QC*/
164 }
165 #endif /* __WARPED_AUTOCORRELATION_FIX_MIPSR1_H__ */
short opus_int16
Definition: opus_types.h:144
#define opus_int
Definition: opus_types.h:151
#define silk_SMLAWB(a, b, c)
Definition: macros_armv4.h:49
#define QS
Definition: warped_autocorrelation_FIX_mipsr1.h:41
void silk_warped_autocorrelation_FIX(opus_int32 *corr, opus_int *scale, const opus_int16 *input, const opus_int warping_Q16, const opus_int length, const opus_int order)
Definition: warped_autocorrelation_FIX_mipsr1.h:45
#define silk_CHECK_FIT32(a)
Definition: SigProc_FIX.h:456
EGLStreamKHR EGLint n
Definition: eglext.h:984
int opus_int32
Definition: opus_types.h:146
#define silk_LSHIFT32(a, shift)
Definition: SigProc_FIX.h:479
#define silk_assert(COND)
Definition: typedef.h:74
#define QC
Definition: warped_autocorrelation_FIX_mipsr1.h:38
#define MAX_SHAPE_LPC_ORDER
Definition: define.h:150
for i
Definition: complexityMeasures.m:24
#define silk_LIMIT(a, limit1, limit2)
Definition: SigProc_FIX.h:557
string input
Definition: tokenizer_unittest.cc:198
#define opus_int64
Definition: opus_types.h:152
GLuint GLsizei GLsizei GLfloat * val
Definition: gl2ext.h:3301
GLuint GLsizei GLsizei * length
Definition: gl2.h:435