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_CompCorr.c | 15 WebRtcIlbcfix_CompCorr.c |
16 | 16 |
17 ******************************************************************/ | 17 ******************************************************************/ |
18 | 18 |
19 #include "defines.h" | 19 #include "defines.h" |
20 | 20 |
21 /*----------------------------------------------------------------* | 21 /*----------------------------------------------------------------* |
22 * Compute cross correlation and pitch gain for pitch prediction | 22 * Compute cross correlation and pitch gain for pitch prediction |
23 * of last subframe at given lag. | 23 * of last subframe at given lag. |
24 *---------------------------------------------------------------*/ | 24 *---------------------------------------------------------------*/ |
25 | 25 |
26 void WebRtcIlbcfix_CompCorr( | 26 void WebRtcIlbcfix_CompCorr( |
27 int32_t *corr, /* (o) cross correlation */ | 27 int32_t *corr, /* (o) cross correlation */ |
28 int32_t *ener, /* (o) energy */ | 28 int32_t *ener, /* (o) energy */ |
29 int16_t *buffer, /* (i) signal buffer */ | 29 int16_t *buffer, /* (i) signal buffer */ |
30 int16_t lag, /* (i) pitch lag */ | 30 size_t lag, /* (i) pitch lag */ |
31 int16_t bLen, /* (i) length of buffer */ | 31 size_t bLen, /* (i) length of buffer */ |
32 int16_t sRange, /* (i) correlation search length */ | 32 size_t sRange, /* (i) correlation search length */ |
33 int16_t scale /* (i) number of rightshifts to use */ | 33 int16_t scale /* (i) number of rightshifts to use */ |
34 ){ | 34 ){ |
35 int16_t *w16ptr; | 35 int16_t *w16ptr; |
36 | 36 |
37 w16ptr=&buffer[bLen-sRange-lag]; | 37 w16ptr=&buffer[bLen-sRange-lag]; |
38 | 38 |
39 /* Calculate correlation and energy */ | 39 /* Calculate correlation and energy */ |
40 (*corr)=WebRtcSpl_DotProductWithScale(&buffer[bLen-sRange], w16ptr, sRange, sc
ale); | 40 (*corr)=WebRtcSpl_DotProductWithScale(&buffer[bLen-sRange], w16ptr, sRange, sc
ale); |
41 (*ener)=WebRtcSpl_DotProductWithScale(w16ptr, w16ptr, sRange, scale); | 41 (*ener)=WebRtcSpl_DotProductWithScale(w16ptr, w16ptr, sRange, scale); |
42 | 42 |
43 /* For zero energy set the energy to 0 in order to avoid potential | 43 /* For zero energy set the energy to 0 in order to avoid potential |
44 problems for coming divisions */ | 44 problems for coming divisions */ |
45 if (*ener == 0) { | 45 if (*ener == 0) { |
46 *corr = 0; | 46 *corr = 0; |
47 *ener = 1; | 47 *ener = 1; |
48 } | 48 } |
49 } | 49 } |
OLD | NEW |