niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | * This file contains the implementation of functions |
| 14 | * WebRtcSpl_MemSetW16() |
| 15 | * WebRtcSpl_MemSetW32() |
| 16 | * WebRtcSpl_MemCpyReversedOrder() |
| 17 | * WebRtcSpl_CopyFromEndW16() |
| 18 | * WebRtcSpl_ZerosArrayW16() |
| 19 | * WebRtcSpl_ZerosArrayW32() |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | * |
| 21 | * The description header can be found in signal_processing_library.h |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <string.h> |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 26 | #include "common_audio/signal_processing/include/signal_processing_library.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | |
| 28 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 29 | void WebRtcSpl_MemSetW16(int16_t *ptr, int16_t set_value, size_t length) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 30 | { |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 31 | size_t j; |
pbos@webrtc.org | b091307 | 2013-04-09 16:40:28 +0000 | [diff] [blame] | 32 | int16_t *arrptr = ptr; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | |
| 34 | for (j = length; j > 0; j--) |
| 35 | { |
| 36 | *arrptr++ = set_value; |
| 37 | } |
| 38 | } |
| 39 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 40 | void WebRtcSpl_MemSetW32(int32_t *ptr, int32_t set_value, size_t length) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | { |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 42 | size_t j; |
pbos@webrtc.org | b091307 | 2013-04-09 16:40:28 +0000 | [diff] [blame] | 43 | int32_t *arrptr = ptr; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | |
| 45 | for (j = length; j > 0; j--) |
| 46 | { |
| 47 | *arrptr++ = set_value; |
| 48 | } |
| 49 | } |
| 50 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 51 | void WebRtcSpl_MemCpyReversedOrder(int16_t* dest, |
| 52 | int16_t* source, |
| 53 | size_t length) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 54 | { |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 55 | size_t j; |
pbos@webrtc.org | b091307 | 2013-04-09 16:40:28 +0000 | [diff] [blame] | 56 | int16_t* destPtr = dest; |
| 57 | int16_t* sourcePtr = source; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | |
| 59 | for (j = 0; j < length; j++) |
| 60 | { |
| 61 | *destPtr-- = *sourcePtr++; |
| 62 | } |
| 63 | } |
| 64 | |
bjornv@webrtc.org | 3cbd6c2 | 2014-09-04 13:21:44 +0000 | [diff] [blame] | 65 | void WebRtcSpl_CopyFromEndW16(const int16_t *vector_in, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 66 | size_t length, |
| 67 | size_t samples, |
bjornv@webrtc.org | 3cbd6c2 | 2014-09-04 13:21:44 +0000 | [diff] [blame] | 68 | int16_t *vector_out) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 69 | { |
| 70 | // Copy the last <samples> of the input vector to vector_out |
| 71 | WEBRTC_SPL_MEMCPY_W16(vector_out, &vector_in[length - samples], samples); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 72 | } |
| 73 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 74 | void WebRtcSpl_ZerosArrayW16(int16_t *vector, size_t length) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 75 | { |
| 76 | WebRtcSpl_MemSetW16(vector, 0, length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 77 | } |
| 78 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 79 | void WebRtcSpl_ZerosArrayW32(int32_t *vector, size_t length) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 80 | { |
| 81 | WebRtcSpl_MemSetW32(vector, 0, length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 82 | } |