xref: /aosp_15_r20/external/libavc/common/ih264_mem_fns.c (revision 495ae853bb871d1e5a258cb02c2cc13cde8ddb9a)
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  *******************************************************************************
23  * @file
24  *  ih264_mem_fns.c
25  *
26  * @brief
27  *  Functions used for memory operations
28  *
29  * @author
30  *  ittiam
31  *
32  * @par List of Functions:
33  *  ih264_memcpy
34  *  ih264_memcpy_mul_8
35  *  ih264_memset
36  *  ih264_memset_mul_8
37  *  ih264_memset_16bit
38  *  ih264_memset_16bit_mul_8
39  *
40  * @remarks
41  *  none
42  *
43  ******************************************************************************
44  */
45 
46 /*****************************************************************************/
47 /* File Includes                                                             */
48 /*****************************************************************************/
49 
50 /* System Include Files */
51 #include <stdio.h>
52 #include <stddef.h>
53 #include <stdlib.h>
54 #include <string.h>
55 #include <assert.h>
56 
57 /* User Include Files */
58 #include "ih264_typedefs.h"
59 
60 #include "ih264_debug.h"
61 #include "ih264_mem_fns.h"
62 
63 /**
64 *******************************************************************************
65 *
66 * @brief memcpy of a 8,16 or 32 bytes
67 *
68 * @par Description
69 *  Does memcpy of 8bit data from source to destination for 8,16 or 32 number of
70 *  bytes
71 *
72 * @param[in] pu1_dst
73 *  pointer to the destination
74 *
75 * @param[in] pu1_src
76 *  pointer to the source
77 *
78 * @param[in] num_bytes
79 *  number of bytes to copy
80 *
81 * @returns none
82 *
83 * @remarks none
84 *
85 *******************************************************************************
86 */
ih264_memcpy(UWORD8 * pu1_dst,UWORD8 * pu1_src,UWORD32 num_bytes)87 void ih264_memcpy(UWORD8 *pu1_dst, UWORD8 *pu1_src, UWORD32 num_bytes)
88 {
89     memcpy(pu1_dst, pu1_src, num_bytes);
90 }
91 
ih264_memcpy_mul_8(UWORD8 * pu1_dst,UWORD8 * pu1_src,UWORD32 num_bytes)92 void ih264_memcpy_mul_8(UWORD8 *pu1_dst, UWORD8 *pu1_src, UWORD32 num_bytes)
93 {
94     ASSERT(num_bytes % 8 == 0);
95     memcpy(pu1_dst, pu1_src, num_bytes);
96 }
97 
98 /**
99 *******************************************************************************
100 *
101 * @brief memset of a 8,16 or 32 bytes
102 *
103 * @par Description
104 *  Does memset of 8bit data for 8,16 or 32 number of bytes
105 *
106 * @param[in] pu1_dst
107 *  pointer to the destination
108 *
109 * @param[in] value
110 *  value used for memset
111 *
112 * @param[in] num_bytes
113 *  number of bytes to set
114 *
115 * @returns none
116 *
117 * @remarks none
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 
ih264_memset_mul_8(UWORD8 * pu1_dst,UWORD8 value,UWORD32 num_bytes)126 void ih264_memset_mul_8(UWORD8 *pu1_dst, UWORD8 value, UWORD32 num_bytes)
127 {
128     ASSERT(num_bytes % 8 == 0);
129     memset(pu1_dst, value, num_bytes);
130 }
131 
132 /**
133 *******************************************************************************
134 *
135 * @brief memset of 16bit data of a 8,16 or 32 bytes
136 *
137 * @par Description
138 *  Does memset of 16bit data for 8,16 or 32 number of bytes
139 *
140 * @param[in] pu2_dst
141 *  pointer to the destination
142 *
143 * @param[in] value
144 *  value used for memset
145 *
146 * @param[in] num_words
147 *  number of words to set
148 *
149 * @returns none
150 *
151 * @remarks none
152 *
153 *******************************************************************************
154 */
ih264_memset_16bit(UWORD16 * pu2_dst,UWORD16 value,UWORD32 num_words)155 void ih264_memset_16bit(UWORD16 *pu2_dst, UWORD16 value, UWORD32 num_words)
156 {
157     UWORD32 i;
158 
159     for(i = 0; i < num_words; i++)
160     {
161         *pu2_dst++ = value;
162     }
163 }
164 
ih264_memset_16bit_mul_8(UWORD16 * pu2_dst,UWORD16 value,UWORD32 num_words)165 void ih264_memset_16bit_mul_8(UWORD16 *pu2_dst,
166                               UWORD16 value,
167                               UWORD32 num_words)
168 {
169     UWORD32 i;
170 
171     ASSERT(num_words % 8 == 0);
172     for(i = 0; i < num_words; i++)
173     {
174         *pu2_dst++ = value;
175     }
176 }
177 
178