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()
20 *
21 * The description header can be found in signal_processing_library.h
22 *
23 */
24
25 #include <string.h>
26 #include "common_audio/signal_processing/include/signal_processing_library.h"
27
28
WebRtcSpl_MemSetW16(int16_t * ptr,int16_t set_value,size_t length)29 void WebRtcSpl_MemSetW16(int16_t *ptr, int16_t set_value, size_t length)
30 {
31 size_t j;
32 int16_t *arrptr = ptr;
33
34 for (j = length; j > 0; j--)
35 {
36 *arrptr++ = set_value;
37 }
38 }
39
WebRtcSpl_MemSetW32(int32_t * ptr,int32_t set_value,size_t length)40 void WebRtcSpl_MemSetW32(int32_t *ptr, int32_t set_value, size_t length)
41 {
42 size_t j;
43 int32_t *arrptr = ptr;
44
45 for (j = length; j > 0; j--)
46 {
47 *arrptr++ = set_value;
48 }
49 }
50
WebRtcSpl_MemCpyReversedOrder(int16_t * dest,int16_t * source,size_t length)51 void WebRtcSpl_MemCpyReversedOrder(int16_t* dest,
52 int16_t* source,
53 size_t length)
54 {
55 size_t j;
56 int16_t* destPtr = dest;
57 int16_t* sourcePtr = source;
58
59 for (j = 0; j < length; j++)
60 {
61 *destPtr-- = *sourcePtr++;
62 }
63 }
64
WebRtcSpl_CopyFromEndW16(const int16_t * vector_in,size_t length,size_t samples,int16_t * vector_out)65 void WebRtcSpl_CopyFromEndW16(const int16_t *vector_in,
66 size_t length,
67 size_t samples,
68 int16_t *vector_out)
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);
72 }
73
WebRtcSpl_ZerosArrayW16(int16_t * vector,size_t length)74 void WebRtcSpl_ZerosArrayW16(int16_t *vector, size_t length)
75 {
76 WebRtcSpl_MemSetW16(vector, 0, length);
77 }
78
WebRtcSpl_ZerosArrayW32(int32_t * vector,size_t length)79 void WebRtcSpl_ZerosArrayW32(int32_t *vector, size_t length)
80 {
81 WebRtcSpl_MemSetW32(vector, 0, length);
82 }
83