1 /******************************************************************************
2  *
3  * Copyright (C) 2015 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************
18  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 /**
21  *******************************************************************************
22  * @file
23  *  ih264_mem_fns.c
24  *
25  * @brief
26  *  Functions used for memory operations
27  *
28  * @author
29  *  Ittiam
30  *
31  * @par List of Functions:
32  *  ih264_memcpy()
33  *  ih264_memcpy_mul_8()
34  *  ih264_memset()
35  *  ih264_memset_mul_8()
36  *  ih264_memset_16bit()
37  *  ih264_memset_16bit_mul_8()
38  *
39  * @remarks
40  *  None
41  *
42  ******************************************************************************
43  */
44 
45 /*****************************************************************************/
46 /* File Includes                                                             */
47 /*****************************************************************************/
48 /* System include files */
49 #include <stdio.h>
50 #include <stddef.h>
51 #include <stdlib.h>
52 #include <string.h>
53 #include <assert.h>
54 
55 
56 /* User include files */
57 #include "ih264_typedefs.h"
58 #include "ih264_mem_fns.h"
59 
60 /**
61  *******************************************************************************
62  *
63  * @brief
64  *   memcpy of a 8,16 or 32 bytes
65  *
66  * @par Description:
67  *   Does memcpy of 8bit data from source to destination for 8,16 or 32 number of bytes
68  *
69  * @param[in] pu1_dst
70  *  UWORD8 pointer to the destination
71  *
72  * @param[in] pu1_src
73  *  UWORD8 pointer to the source
74  *
75  * @param[in] num_bytes
76  *  number of bytes to copy
77  * @returns
78  *
79  * @remarks
80  *  None
81  *
82  *******************************************************************************
83  */
84 
ih264_memcpy(UWORD8 * pu1_dst,UWORD8 * pu1_src,UWORD32 num_bytes)85 void ih264_memcpy(UWORD8 *pu1_dst, UWORD8 *pu1_src, UWORD32 num_bytes)
86 {
87     memcpy(pu1_dst, pu1_src, num_bytes);
88 }
89 
90 
ih264_memcpy_mul_8(UWORD8 * pu1_dst,UWORD8 * pu1_src,UWORD32 num_bytes)91 void ih264_memcpy_mul_8(UWORD8 *pu1_dst, UWORD8 *pu1_src, UWORD32 num_bytes)
92 {
93     memcpy(pu1_dst, pu1_src, num_bytes);
94 }
95 
96 /**
97  *******************************************************************************
98  *
99  * @brief
100  *   memset of a 8,16 or 32 bytes
101  *
102  * @par Description:
103  *   Does memset of 8bit data for 8,16 or 32 number of bytes
104  *
105  * @param[in] pu1_dst
106  *  UWORD8 pointer to the destination
107  *
108  * @param[in] value
109  *  UWORD8 value used for memset
110  *
111  * @param[in] num_bytes
112  *  number of bytes to set
113  * @returns
114  *
115  * @remarks
116  *  None
117  *
118  *******************************************************************************
119  */
120 
ih264_memset(UWORD8 * pu1_dst,UWORD8 value,UWORD32 num_bytes)121 void ih264_memset(UWORD8 *pu1_dst, UWORD8 value, UWORD32 num_bytes)
122 {
123     memset(pu1_dst, value, num_bytes);
124 }
125 
126 
ih264_memset_mul_8(UWORD8 * pu1_dst,UWORD8 value,UWORD32 num_bytes)127 void ih264_memset_mul_8(UWORD8 *pu1_dst, UWORD8 value, UWORD32 num_bytes)
128 {
129     memset(pu1_dst, value, num_bytes);
130 }
131 
132 /**
133  *******************************************************************************
134  *
135  * @brief
136  *   memset of 16bit data of a 8,16 or 32 bytes
137  *
138  * @par Description:
139  *   Does memset of 16bit data for 8,16 or 32 number of bytes
140  *
141  * @param[in] pu2_dst
142  *  UWORD8 pointer to the destination
143  *
144  * @param[in] value
145  *  UWORD16 value used for memset
146  *
147  * @param[in] num_words
148  *  number of words to set
149  * @returns
150  *
151  * @remarks
152  *  None
153  *
154  *******************************************************************************
155  */
156 
ih264_memset_16bit(UWORD16 * pu2_dst,UWORD16 value,UWORD32 num_words)157 void ih264_memset_16bit(UWORD16 *pu2_dst, UWORD16 value, UWORD32 num_words)
158 {
159     UWORD32 i;
160     for(i = 0; i < num_words; i++)
161     {
162         *pu2_dst++ = value;
163     }
164 }
165 
ih264_memset_16bit_mul_8(UWORD16 * pu2_dst,UWORD16 value,UWORD32 num_words)166 void ih264_memset_16bit_mul_8(UWORD16 *pu2_dst,
167                               UWORD16 value,
168                               UWORD32 num_words)
169 {
170     UWORD32 i;
171     for(i = 0; i < num_words; i++)
172     {
173         *pu2_dst++ = value;
174     }
175 }
176 
177