blob: ae709d40f0487f5fbad327a3f1d3ce2e21b2848f [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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.com470e71d2011-07-07 08:21:25 +000020 *
21 * The description header can be found in signal_processing_library.h
22 *
23 */
24
25#include <string.h>
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020026#include "common_audio/signal_processing/include/signal_processing_library.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000027
28
Peter Kastingdce40cf2015-08-24 14:52:23 -070029void WebRtcSpl_MemSetW16(int16_t *ptr, int16_t set_value, size_t length)
niklase@google.com470e71d2011-07-07 08:21:25 +000030{
Peter Kastingdce40cf2015-08-24 14:52:23 -070031 size_t j;
pbos@webrtc.orgb0913072013-04-09 16:40:28 +000032 int16_t *arrptr = ptr;
niklase@google.com470e71d2011-07-07 08:21:25 +000033
34 for (j = length; j > 0; j--)
35 {
36 *arrptr++ = set_value;
37 }
38}
39
Peter Kastingdce40cf2015-08-24 14:52:23 -070040void WebRtcSpl_MemSetW32(int32_t *ptr, int32_t set_value, size_t length)
niklase@google.com470e71d2011-07-07 08:21:25 +000041{
Peter Kastingdce40cf2015-08-24 14:52:23 -070042 size_t j;
pbos@webrtc.orgb0913072013-04-09 16:40:28 +000043 int32_t *arrptr = ptr;
niklase@google.com470e71d2011-07-07 08:21:25 +000044
45 for (j = length; j > 0; j--)
46 {
47 *arrptr++ = set_value;
48 }
49}
50
Peter Kastingdce40cf2015-08-24 14:52:23 -070051void WebRtcSpl_MemCpyReversedOrder(int16_t* dest,
52 int16_t* source,
53 size_t length)
niklase@google.com470e71d2011-07-07 08:21:25 +000054{
Peter Kastingdce40cf2015-08-24 14:52:23 -070055 size_t j;
pbos@webrtc.orgb0913072013-04-09 16:40:28 +000056 int16_t* destPtr = dest;
57 int16_t* sourcePtr = source;
niklase@google.com470e71d2011-07-07 08:21:25 +000058
59 for (j = 0; j < length; j++)
60 {
61 *destPtr-- = *sourcePtr++;
62 }
63}
64
bjornv@webrtc.org3cbd6c22014-09-04 13:21:44 +000065void WebRtcSpl_CopyFromEndW16(const int16_t *vector_in,
Peter Kastingdce40cf2015-08-24 14:52:23 -070066 size_t length,
67 size_t samples,
bjornv@webrtc.org3cbd6c22014-09-04 13:21:44 +000068 int16_t *vector_out)
niklase@google.com470e71d2011-07-07 08:21:25 +000069{
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.com470e71d2011-07-07 08:21:25 +000072}
73
Peter Kastingdce40cf2015-08-24 14:52:23 -070074void WebRtcSpl_ZerosArrayW16(int16_t *vector, size_t length)
niklase@google.com470e71d2011-07-07 08:21:25 +000075{
76 WebRtcSpl_MemSetW16(vector, 0, length);
niklase@google.com470e71d2011-07-07 08:21:25 +000077}
78
Peter Kastingdce40cf2015-08-24 14:52:23 -070079void WebRtcSpl_ZerosArrayW32(int32_t *vector, size_t length)
niklase@google.com470e71d2011-07-07 08:21:25 +000080{
81 WebRtcSpl_MemSetW32(vector, 0, length);
niklase@google.com470e71d2011-07-07 08:21:25 +000082}