ilbc_specific_functions.c revision e4b6064f8e6b0b448f070155b1b6c4b6788107df
1/* 2 * Copyright (c) 2012 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 * This file contains implementations of the iLBC specific functions 14 * WebRtcSpl_ReverseOrderMultArrayElements() 15 * WebRtcSpl_ElementwiseVectorMult() 16 * WebRtcSpl_AddVectorsAndShift() 17 * WebRtcSpl_AddAffineVectorToVector() 18 * WebRtcSpl_AffineTransformVector() 19 * 20 */ 21 22#include "signal_processing_library.h" 23 24void WebRtcSpl_ReverseOrderMultArrayElements(int16_t *out, const int16_t *in, 25 const int16_t *win, 26 int16_t vector_length, 27 int16_t right_shifts) 28{ 29 int i; 30 int16_t *outptr = out; 31 const int16_t *inptr = in; 32 const int16_t *winptr = win; 33 for (i = 0; i < vector_length; i++) 34 { 35 (*outptr++) = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, 36 *winptr--, right_shifts); 37 } 38} 39 40void WebRtcSpl_ElementwiseVectorMult(int16_t *out, const int16_t *in, 41 const int16_t *win, int16_t vector_length, 42 int16_t right_shifts) 43{ 44 int i; 45 int16_t *outptr = out; 46 const int16_t *inptr = in; 47 const int16_t *winptr = win; 48 for (i = 0; i < vector_length; i++) 49 { 50 (*outptr++) = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, 51 *winptr++, right_shifts); 52 } 53} 54 55void WebRtcSpl_AddVectorsAndShift(int16_t *out, const int16_t *in1, 56 const int16_t *in2, int16_t vector_length, 57 int16_t right_shifts) 58{ 59 int i; 60 int16_t *outptr = out; 61 const int16_t *in1ptr = in1; 62 const int16_t *in2ptr = in2; 63 for (i = vector_length; i > 0; i--) 64 { 65 (*outptr++) = (int16_t)(((*in1ptr++) + (*in2ptr++)) >> right_shifts); 66 } 67} 68 69void WebRtcSpl_AddAffineVectorToVector(int16_t *out, int16_t *in, 70 int16_t gain, int32_t add_constant, 71 int16_t right_shifts, int vector_length) 72{ 73 int16_t *inPtr; 74 int16_t *outPtr; 75 int i; 76 77 inPtr = in; 78 outPtr = out; 79 for (i = 0; i < vector_length; i++) 80 { 81 (*outPtr++) += (int16_t)((WEBRTC_SPL_MUL_16_16((*inPtr++), gain) 82 + (int32_t)add_constant) >> right_shifts); 83 } 84} 85 86void WebRtcSpl_AffineTransformVector(int16_t *out, int16_t *in, 87 int16_t gain, int32_t add_constant, 88 int16_t right_shifts, int vector_length) 89{ 90 int16_t *inPtr; 91 int16_t *outPtr; 92 int i; 93 94 inPtr = in; 95 outPtr = out; 96 for (i = 0; i < vector_length; i++) 97 { 98 (*outPtr++) = (int16_t)((WEBRTC_SPL_MUL_16_16((*inPtr++), gain) 99 + (int32_t)add_constant) >> right_shifts); 100 } 101} 102