1 /*
2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 /******************************************************************
12 
13  iLBC Speech Coder ANSI-C Source Code
14 
15  WebRtcIlbcfix_AugmentedCbCorr.c
16 
17 ******************************************************************/
18 
19 #include "defines.h"
20 #include "constants.h"
21 #include "augmented_cb_corr.h"
22 
WebRtcIlbcfix_AugmentedCbCorr(int16_t * target,int16_t * buffer,int16_t * interpSamples,int32_t * crossDot,size_t low,size_t high,int scale)23 void WebRtcIlbcfix_AugmentedCbCorr(
24     int16_t *target,   /* (i) Target vector */
25     int16_t *buffer,   /* (i) Memory buffer */
26     int16_t *interpSamples, /* (i) buffer with
27                                      interpolated samples */
28     int32_t *crossDot,  /* (o) The cross correlation between
29                                  the target and the Augmented
30                                  vector */
31     size_t low,    /* (i) Lag to start from (typically
32                              20) */
33     size_t high,   /* (i) Lag to end at (typically 39) */
34     int scale)   /* (i) Scale factor to use for
35                               the crossDot */
36 {
37   size_t lagcount;
38   size_t ilow;
39   int16_t *targetPtr;
40   int32_t *crossDotPtr;
41   int16_t *iSPtr=interpSamples;
42 
43   /* Calculate the correlation between the target and the
44      interpolated codebook. The correlation is calculated in
45      3 sections with the interpolated part in the middle */
46   crossDotPtr=crossDot;
47   for (lagcount=low; lagcount<=high; lagcount++) {
48 
49     ilow = lagcount - 4;
50 
51     /* Compute dot product for the first (lagcount-4) samples */
52     (*crossDotPtr) = WebRtcSpl_DotProductWithScale(target, buffer-lagcount, ilow, scale);
53 
54     /* Compute dot product on the interpolated samples */
55     (*crossDotPtr) += WebRtcSpl_DotProductWithScale(target+ilow, iSPtr, 4, scale);
56     targetPtr = target + lagcount;
57     iSPtr += lagcount-ilow;
58 
59     /* Compute dot product for the remaining samples */
60     (*crossDotPtr) += WebRtcSpl_DotProductWithScale(targetPtr, buffer-lagcount, SUBL-lagcount, scale);
61     crossDotPtr++;
62   }
63 }
64