OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 /****************************************************************** | 11 /****************************************************************** |
12 | 12 |
13 iLBC Speech Coder ANSI-C Source Code | 13 iLBC Speech Coder ANSI-C Source Code |
14 | 14 |
15 WebRtcIlbcfix_MyCorr.c | 15 WebRtcIlbcfix_MyCorr.c |
16 | 16 |
17 ******************************************************************/ | 17 ******************************************************************/ |
18 | 18 |
19 #include "defines.h" | 19 #include "defines.h" |
20 | 20 |
21 /*----------------------------------------------------------------* | 21 /*----------------------------------------------------------------* |
22 * compute cross correlation between sequences | 22 * compute cross correlation between sequences |
23 *---------------------------------------------------------------*/ | 23 *---------------------------------------------------------------*/ |
24 | 24 |
25 void WebRtcIlbcfix_MyCorr( | 25 void WebRtcIlbcfix_MyCorr( |
26 int32_t *corr, /* (o) correlation of seq1 and seq2 */ | 26 int32_t* corr, /* (o) correlation of seq1 and seq2 */ |
27 int16_t *seq1, /* (i) first sequence */ | 27 const int16_t* seq1, /* (i) first sequence */ |
28 int16_t dim1, /* (i) dimension first seq1 */ | 28 int16_t dim1, /* (i) dimension first seq1 */ |
29 const int16_t *seq2, /* (i) second sequence */ | 29 const int16_t* seq2, /* (i) second sequence */ |
30 int16_t dim2 /* (i) dimension seq2 */ | 30 int16_t dim2 /* (i) dimension seq2 */ |
31 ){ | 31 ){ |
32 int16_t max, scale, loops; | 32 int16_t max, scale, loops; |
33 | 33 |
34 /* Calculate correlation between the two sequences. Scale the | 34 /* Calculate correlation between the two sequences. Scale the |
35 result of the multiplcication to maximum 26 bits in order | 35 result of the multiplcication to maximum 26 bits in order |
36 to avoid overflow */ | 36 to avoid overflow */ |
37 max=WebRtcSpl_MaxAbsValueW16(seq1, dim1); | 37 max=WebRtcSpl_MaxAbsValueW16(seq1, dim1); |
38 scale=WebRtcSpl_GetSizeInBits(max); | 38 scale=WebRtcSpl_GetSizeInBits(max); |
39 | 39 |
40 scale = (int16_t)(2 * scale - 26); | 40 scale = (int16_t)(2 * scale - 26); |
41 if (scale<0) { | 41 if (scale<0) { |
42 scale=0; | 42 scale=0; |
43 } | 43 } |
44 | 44 |
45 loops=dim1-dim2+1; | 45 loops=dim1-dim2+1; |
46 | 46 |
47 /* Calculate the cross correlations */ | 47 /* Calculate the cross correlations */ |
48 WebRtcSpl_CrossCorrelation(corr, seq2, seq1, dim2, loops, scale, 1); | 48 WebRtcSpl_CrossCorrelation(corr, seq2, seq1, dim2, loops, scale, 1); |
49 | 49 |
50 return; | 50 return; |
51 } | 51 } |
OLD | NEW |