vector_operations.c (2961B)
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 #include "common_audio/signal_processing/include/signal_processing_library.h" 12 13 void WebRtcSpl_ReverseOrderMultArrayElements(int16_t* out, 14 const int16_t* in, 15 const int16_t* win, 16 size_t vector_length, 17 int16_t right_shifts) { 18 size_t i; 19 int16_t* outptr = out; 20 const int16_t* inptr = in; 21 const int16_t* winptr = win; 22 for (i = 0; i < vector_length; i++) { 23 *outptr++ = (int16_t)((*inptr++ * *winptr--) >> right_shifts); 24 } 25 } 26 27 void WebRtcSpl_ElementwiseVectorMult(int16_t* out, 28 const int16_t* in, 29 const int16_t* win, 30 size_t vector_length, 31 int16_t right_shifts) { 32 size_t i; 33 int16_t* outptr = out; 34 const int16_t* inptr = in; 35 const int16_t* winptr = win; 36 for (i = 0; i < vector_length; i++) { 37 *outptr++ = (int16_t)((*inptr++ * *winptr++) >> right_shifts); 38 } 39 } 40 41 void WebRtcSpl_AddVectorsAndShift(int16_t* out, 42 const int16_t* in1, 43 const int16_t* in2, 44 size_t vector_length, 45 int16_t right_shifts) { 46 size_t i; 47 int16_t* outptr = out; 48 const int16_t* in1ptr = in1; 49 const int16_t* in2ptr = in2; 50 for (i = vector_length; i > 0; i--) { 51 (*outptr++) = (int16_t)(((*in1ptr++) + (*in2ptr++)) >> right_shifts); 52 } 53 } 54 55 void WebRtcSpl_AddAffineVectorToVector(int16_t* out, 56 const int16_t* in, 57 int16_t gain, 58 int32_t add_constant, 59 int16_t right_shifts, 60 size_t vector_length) { 61 size_t i; 62 63 for (i = 0; i < vector_length; i++) { 64 out[i] += (int16_t)((in[i] * gain + add_constant) >> right_shifts); 65 } 66 } 67 68 void WebRtcSpl_AffineTransformVector(int16_t* out, 69 const int16_t* in, 70 int16_t gain, 71 int32_t add_constant, 72 int16_t right_shifts, 73 size_t vector_length) { 74 size_t i; 75 76 for (i = 0; i < vector_length; i++) { 77 out[i] = (int16_t)((in[i] * gain + add_constant) >> right_shifts); 78 } 79 }