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 "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 23 24 void WebRtcSpl_ReverseOrderMultArrayElements(int16_t *out, const int16_t *in, 25 const int16_t *win, 26 size_t vector_length, 27 int16_t right_shifts) 28 { 29 size_t 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)((*inptr++ * *winptr--) >> right_shifts); 36 } 37 } 38 39 void WebRtcSpl_ElementwiseVectorMult(int16_t *out, const int16_t *in, 40 const int16_t *win, size_t vector_length, 41 int16_t right_shifts) 42 { 43 size_t i; 44 int16_t *outptr = out; 45 const int16_t *inptr = in; 46 const int16_t *winptr = win; 47 for (i = 0; i < vector_length; i++) 48 { 49 *outptr++ = (int16_t)((*inptr++ * *winptr++) >> right_shifts); 50 } 51 } 52 53 void WebRtcSpl_AddVectorsAndShift(int16_t *out, const int16_t *in1, 54 const int16_t *in2, size_t vector_length, 55 int16_t right_shifts) 56 { 57 size_t i; 58 int16_t *outptr = out; 59 const int16_t *in1ptr = in1; 60 const int16_t *in2ptr = in2; 61 for (i = vector_length; i > 0; i--) 62 { 63 (*outptr++) = (int16_t)(((*in1ptr++) + (*in2ptr++)) >> right_shifts); 64 } 65 } 66 67 void WebRtcSpl_AddAffineVectorToVector(int16_t *out, int16_t *in, 68 int16_t gain, int32_t add_constant, 69 int16_t right_shifts, 70 size_t vector_length) 71 { 72 size_t i; 73 74 for (i = 0; i < vector_length; i++) 75 { 76 out[i] += (int16_t)((in[i] * gain + add_constant) >> right_shifts); 77 } 78 } 79 80 void WebRtcSpl_AffineTransformVector(int16_t *out, int16_t *in, 81 int16_t gain, int32_t add_constant, 82 int16_t right_shifts, size_t vector_length) 83 { 84 size_t i; 85 86 for (i = 0; i < vector_length; i++) 87 { 88 out[i] = (int16_t)((in[i] * gain + add_constant) >> right_shifts); 89 } 90 } 91