• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright (C) 2022 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_padding_atom_intr.c
24 *
25 * @brief
26 *  Contains function definitions for Padding
27 *
28 * @author
29 *  Srinivas T
30 *
31 * @par List of Functions:
32 *   - isvc_pad_left_luma_ssse3()
33 *   - isvc_pad_left_chroma_ssse3()
34 *   - isvc_pad_right_luma_ssse3()
35 *   - isvc_pad_right_chroma_ssse3()
36 *
37 * @remarks
38 *  None
39 *
40 *******************************************************************************
41 */
42 
43 #include <string.h>
44 #include <assert.h>
45 #include "ih264_typedefs.h"
46 #include "ih264_platform_macros.h"
47 #include "isvc_mem_fns.h"
48 #include "ih264_debug.h"
49 
50 #include <immintrin.h>
51 
52 /**
53 *******************************************************************************
54 *
55 * @brief
56 *   Padding (luma block) at the left of a 2d array
57 *
58 * @par Description:
59 *   The left column of a 2d array is replicated for pad_size times at the left
60 *
61 *
62 * @param[in] pu1_src
63 *  UWORD8 pointer to the source
64 *
65 * @param[in] src_strd
66 *  integer source stride
67 *
68 * @param[in] ht
69 *  integer height of the array
70 *
71 * @param[in] wd
72 *  integer width of the array
73 *
74 * @param[in] pad_size
75 *  integer -padding size of the array
76 *
77 * @param[in] ht
78 *  integer height of the array
79 *
80 * @param[in] wd
81 *  integer width of the array
82 *
83 * @returns
84 *
85 * @remarks
86 *  None
87 *
88 *******************************************************************************
89 */
90 
isvc_pad_left_luma_ssse3(UWORD8 * pu1_src,WORD32 src_strd,WORD32 ht,WORD32 pad_size)91 void isvc_pad_left_luma_ssse3(UWORD8 *pu1_src, WORD32 src_strd, WORD32 ht, WORD32 pad_size)
92 {
93     WORD32 row;
94     WORD32 i;
95     UWORD8 *pu1_dst;
96 
97     ASSERT(pad_size % 8 == 0);
98 
99     for(row = 0; row < ht; row++)
100     {
101         __m128i src_temp0_16x8b;
102 
103         pu1_dst = pu1_src - pad_size;
104         src_temp0_16x8b = _mm_set1_epi8(*pu1_src);
105         for(i = 0; i < pad_size; i += 8)
106         {
107             _mm_storel_epi64((__m128i *) (pu1_dst + i), src_temp0_16x8b);
108         }
109         pu1_src += src_strd;
110     }
111 }
112 
113 /**
114 *******************************************************************************
115 *
116 * @brief
117 *   Padding (chroma block) at the left of a 2d array
118 *
119 * @par Description:
120 *   The left column of a 2d array is replicated for pad_size times at the left
121 *
122 *
123 * @param[in] pu1_src
124 *  UWORD8 pointer to the source
125 *
126 * @param[in] src_strd
127 *  integer source stride
128 *
129 * @param[in] ht
130 *  integer height of the array
131 *
132 * @param[in] wd
133 *  integer width of the array (each colour component)
134 *
135 * @param[in] pad_size
136 *  integer -padding size of the array
137 *
138 * @param[in] ht
139 *  integer height of the array
140 *
141 * @param[in] wd
142 *  integer width of the array
143 *
144 * @returns
145 *
146 * @remarks
147 *  None
148 *
149 *******************************************************************************
150 */
151 
isvc_pad_left_chroma_ssse3(UWORD8 * pu1_src,WORD32 src_strd,WORD32 ht,WORD32 pad_size)152 void isvc_pad_left_chroma_ssse3(UWORD8 *pu1_src, WORD32 src_strd, WORD32 ht, WORD32 pad_size)
153 {
154     WORD32 row;
155     WORD32 col;
156     UWORD8 *pu1_dst;
157 
158     ASSERT(pad_size % 8 == 0);
159     for(row = 0; row < ht; row++)
160     {
161         __m128i src_temp0_16x8b;
162 
163         pu1_dst = pu1_src - pad_size;
164         src_temp0_16x8b = _mm_set1_epi16(*((UWORD16 *) pu1_src));
165         for(col = 0; col < pad_size; col += 8)
166         {
167             _mm_storel_epi64((__m128i *) (pu1_dst + col), src_temp0_16x8b);
168         }
169         pu1_src += src_strd;
170     }
171 }
172 
173 /**
174 *******************************************************************************
175 *
176 * @brief
177 * Padding (luma block) at the right of a 2d array
178 *
179 * @par Description:
180 * The right column of a 2d array is replicated for pad_size times at the right
181 *
182 *
183 * @param[in] pu1_src
184 *  UWORD8 pointer to the source
185 *
186 * @param[in] src_strd
187 *  integer source stride
188 *
189 * @param[in] ht
190 *  integer height of the array
191 *
192 * @param[in] wd
193 *  integer width of the array
194 *
195 * @param[in] pad_size
196 *  integer -padding size of the array
197 *
198 * @param[in] ht
199 *  integer height of the array
200 *
201 * @param[in] wd
202 *  integer width of the array
203 *
204 * @returns
205 *
206 * @remarks
207 *  None
208 *
209 *******************************************************************************
210 */
211 
isvc_pad_right_luma_ssse3(UWORD8 * pu1_src,WORD32 src_strd,WORD32 ht,WORD32 pad_size)212 void isvc_pad_right_luma_ssse3(UWORD8 *pu1_src, WORD32 src_strd, WORD32 ht, WORD32 pad_size)
213 {
214     WORD32 row;
215     WORD32 col;
216     UWORD8 *pu1_dst;
217 
218     ASSERT(pad_size % 8 == 0);
219 
220     for(row = 0; row < ht; row++)
221     {
222         __m128i src_temp0_16x8b;
223 
224         pu1_dst = pu1_src;
225         src_temp0_16x8b = _mm_set1_epi8(*(pu1_src - 1));
226         for(col = 0; col < pad_size; col += 8)
227         {
228             _mm_storel_epi64((__m128i *) (pu1_dst + col), src_temp0_16x8b);
229         }
230         pu1_src += src_strd;
231     }
232 }
233 
234 /**
235 *******************************************************************************
236 *
237 * @brief
238 * Padding (chroma block) at the right of a 2d array
239 *
240 * @par Description:
241 * The right column of a 2d array is replicated for pad_size times at the right
242 *
243 *
244 * @param[in] pu1_src
245 *  UWORD8 pointer to the source
246 *
247 * @param[in] src_strd
248 *  integer source stride
249 *
250 * @param[in] ht
251 *  integer height of the array
252 *
253 * @param[in] wd
254 *  integer width of the array (each colour component)
255 *
256 * @param[in] pad_size
257 *  integer -padding size of the array
258 *
259 * @param[in] ht
260 *  integer height of the array
261 *
262 * @param[in] wd
263 *  integer width of the array
264 *
265 * @returns
266 *
267 * @remarks
268 *  None
269 *
270 *******************************************************************************
271 */
272 
isvc_pad_right_chroma_ssse3(UWORD8 * pu1_src,WORD32 src_strd,WORD32 ht,WORD32 pad_size)273 void isvc_pad_right_chroma_ssse3(UWORD8 *pu1_src, WORD32 src_strd, WORD32 ht, WORD32 pad_size)
274 {
275     WORD32 row;
276     WORD32 col;
277     UWORD8 *pu1_dst;
278 
279     ASSERT(pad_size % 8 == 0);
280 
281     for(row = 0; row < ht; row++)
282     {
283         __m128i src_temp0_16x8b;
284 
285         pu1_dst = pu1_src;
286         src_temp0_16x8b = _mm_set1_epi16(*((UWORD16 *) (pu1_src - 2)));
287         for(col = 0; col < pad_size; col += 8)
288         {
289             _mm_storel_epi64((__m128i *) (pu1_dst + col), src_temp0_16x8b);
290         }
291 
292         pu1_src += src_strd;
293     }
294 }
295