1470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com/* 2470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * 4470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * Use of this source code is governed by a BSD-style license 5470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * that can be found in the LICENSE file in the root of the source 6470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * tree. An additional intellectual property rights grant can be found 7470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * in the file PATENTS. All contributing project authors may 8470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com * be found in the AUTHORS file in the root of the source tree. 9470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com */ 10470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 11470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com/****************************************************************** 12470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 13470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com iLBC Speech Coder ANSI-C Source Code 14470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 15470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com WebRtcIlbcfix_AugmentedCbCorr.c 16470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 17470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com******************************************************************/ 18470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 19470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com#include "defines.h" 20470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com#include "constants.h" 21470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com#include "augmented_cb_corr.h" 22470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 23470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.comvoid WebRtcIlbcfix_AugmentedCbCorr( 240946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int16_t *target, /* (i) Target vector */ 250946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int16_t *buffer, /* (i) Memory buffer */ 260946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int16_t *interpSamples, /* (i) buffer with 27470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com interpolated samples */ 280946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int32_t *crossDot, /* (o) The cross correlation between 29470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com the target and the Augmented 30470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com vector */ 31dce40cf804019a9898b6ab8d8262466b697c56e0Peter Kasting size_t low, /* (i) Lag to start from (typically 32470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 20) */ 33dce40cf804019a9898b6ab8d8262466b697c56e0Peter Kasting size_t high, /* (i) Lag to end at (typically 39) */ 34a8b335c709b244685345cfabb3b72ce672a09d96Peter Kasting int scale) /* (i) Scale factor to use for 35470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com the crossDot */ 36470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com{ 37dce40cf804019a9898b6ab8d8262466b697c56e0Peter Kasting size_t lagcount; 38dce40cf804019a9898b6ab8d8262466b697c56e0Peter Kasting size_t ilow; 390946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int16_t *targetPtr; 400946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int32_t *crossDotPtr; 410946a56023d821e0deca04029bb016ae1f23aa82pbos@webrtc.org int16_t *iSPtr=interpSamples; 42470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 43470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com /* Calculate the correlation between the target and the 44470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com interpolated codebook. The correlation is calculated in 45470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 3 sections with the interpolated part in the middle */ 46470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com crossDotPtr=crossDot; 47470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com for (lagcount=low; lagcount<=high; lagcount++) { 48470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 49dce40cf804019a9898b6ab8d8262466b697c56e0Peter Kasting ilow = lagcount - 4; 50470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 51470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com /* Compute dot product for the first (lagcount-4) samples */ 52470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com (*crossDotPtr) = WebRtcSpl_DotProductWithScale(target, buffer-lagcount, ilow, scale); 53470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 54470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com /* Compute dot product on the interpolated samples */ 55470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com (*crossDotPtr) += WebRtcSpl_DotProductWithScale(target+ilow, iSPtr, 4, scale); 56470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com targetPtr = target + lagcount; 57470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com iSPtr += lagcount-ilow; 58470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com 59470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com /* Compute dot product for the remaining samples */ 60470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com (*crossDotPtr) += WebRtcSpl_DotProductWithScale(targetPtr, buffer-lagcount, SUBL-lagcount, scale); 61470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com crossDotPtr++; 62470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com } 63470e71d3649f6cac4688e83819640b012b5d38bbniklase@google.com} 64