• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * WebRtcSpl_OnesArrayW16()
21  * WebRtcSpl_OnesArrayW32()
22  *
23  * The description header can be found in signal_processing_library.h
24  *
25  */
26 
27 #include <string.h>
28 #include "signal_processing_library.h"
29 
30 
WebRtcSpl_MemSetW16(WebRtc_Word16 * ptr,WebRtc_Word16 set_value,int length)31 void WebRtcSpl_MemSetW16(WebRtc_Word16 *ptr, WebRtc_Word16 set_value, int length)
32 {
33     int j;
34     WebRtc_Word16 *arrptr = ptr;
35 
36     for (j = length; j > 0; j--)
37     {
38         *arrptr++ = set_value;
39     }
40 }
41 
WebRtcSpl_MemSetW32(WebRtc_Word32 * ptr,WebRtc_Word32 set_value,int length)42 void WebRtcSpl_MemSetW32(WebRtc_Word32 *ptr, WebRtc_Word32 set_value, int length)
43 {
44     int j;
45     WebRtc_Word32 *arrptr = ptr;
46 
47     for (j = length; j > 0; j--)
48     {
49         *arrptr++ = set_value;
50     }
51 }
52 
WebRtcSpl_MemCpyReversedOrder(WebRtc_Word16 * dest,WebRtc_Word16 * source,int length)53 void WebRtcSpl_MemCpyReversedOrder(WebRtc_Word16* dest, WebRtc_Word16* source, int length)
54 {
55     int j;
56     WebRtc_Word16* destPtr = dest;
57     WebRtc_Word16* sourcePtr = source;
58 
59     for (j = 0; j < length; j++)
60     {
61         *destPtr-- = *sourcePtr++;
62     }
63 }
64 
WebRtcSpl_CopyFromEndW16(G_CONST WebRtc_Word16 * vector_in,WebRtc_Word16 length,WebRtc_Word16 samples,WebRtc_Word16 * vector_out)65 WebRtc_Word16 WebRtcSpl_CopyFromEndW16(G_CONST WebRtc_Word16 *vector_in,
66                                        WebRtc_Word16 length,
67                                        WebRtc_Word16 samples,
68                                        WebRtc_Word16 *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     return samples;
74 }
75 
WebRtcSpl_ZerosArrayW16(WebRtc_Word16 * vector,WebRtc_Word16 length)76 WebRtc_Word16 WebRtcSpl_ZerosArrayW16(WebRtc_Word16 *vector, WebRtc_Word16 length)
77 {
78     WebRtcSpl_MemSetW16(vector, 0, length);
79     return length;
80 }
81 
WebRtcSpl_ZerosArrayW32(WebRtc_Word32 * vector,WebRtc_Word16 length)82 WebRtc_Word16 WebRtcSpl_ZerosArrayW32(WebRtc_Word32 *vector, WebRtc_Word16 length)
83 {
84     WebRtcSpl_MemSetW32(vector, 0, length);
85     return length;
86 }
87 
WebRtcSpl_OnesArrayW16(WebRtc_Word16 * vector,WebRtc_Word16 length)88 WebRtc_Word16 WebRtcSpl_OnesArrayW16(WebRtc_Word16 *vector, WebRtc_Word16 length)
89 {
90     WebRtc_Word16 i;
91     WebRtc_Word16 *tmpvec = vector;
92     for (i = 0; i < length; i++)
93     {
94         *tmpvec++ = 1;
95     }
96     return length;
97 }
98 
WebRtcSpl_OnesArrayW32(WebRtc_Word32 * vector,WebRtc_Word16 length)99 WebRtc_Word16 WebRtcSpl_OnesArrayW32(WebRtc_Word32 *vector, WebRtc_Word16 length)
100 {
101     WebRtc_Word16 i;
102     WebRtc_Word32 *tmpvec = vector;
103     for (i = 0; i < length; i++)
104     {
105         *tmpvec++ = 1;
106     }
107     return length;
108 }
109