/src/libhevc/common/ihevc_recon.c
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore |
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 | | /** |
19 | | ******************************************************************************* |
20 | | * @file |
21 | | * ihevc_recon.c |
22 | | * |
23 | | * @brief |
24 | | * Functions definitions reconstruction |
25 | | * |
26 | | * @author |
27 | | * Ittiam |
28 | | * |
29 | | * @par List of Functions: |
30 | | * - ihevc_recon_4x4_ttype1() |
31 | | * - ihevc_recon_4x4() |
32 | | * - ihevc_recon_8x8() |
33 | | * - ihevc_recon_16x16() |
34 | | * - ihevc_recon_32x32() |
35 | | * |
36 | | * @remarks |
37 | | * None |
38 | | * |
39 | | ******************************************************************************* |
40 | | */ |
41 | | #include <stdio.h> |
42 | | #include <string.h> |
43 | | #include "ihevc_typedefs.h" |
44 | | #include "ihevc_macros.h" |
45 | | #include "ihevc_platform_macros.h" |
46 | | #include "ihevc_defs.h" |
47 | | #include "ihevc_trans_tables.h" |
48 | | #include "ihevc_recon.h" |
49 | | #include "ihevc_func_selector.h" |
50 | | #include "ihevc_trans_macros.h" |
51 | | |
52 | | /* All the functions here are replicated from ihevc.c and modified to */ |
53 | | /* include reconstruction */ |
54 | | |
55 | | /** |
56 | | ******************************************************************************* |
57 | | * |
58 | | * @brief |
59 | | * This function performs reconstruction for 4x4 input block |
60 | | * |
61 | | * @par Description: |
62 | | * Performs reconstruction of 4x4 input block by adding adding prediction |
63 | | * data to input and clipping it to 8 bit |
64 | | * |
65 | | * @param[in] pi2_src |
66 | | * Input 4x4 coefficients |
67 | | * |
68 | | * @param[in] pu1_pred |
69 | | * Prediction 4x4 block |
70 | | * |
71 | | * @param[out] pu1_dst |
72 | | * Output 4x4 block |
73 | | * |
74 | | * @param[in] src_strd |
75 | | * Input stride |
76 | | * |
77 | | * @param[in] pred_strd |
78 | | * Prediction stride |
79 | | * |
80 | | * @param[in] dst_strd |
81 | | * Output Stride |
82 | | * |
83 | | * @param[in] zero_cols |
84 | | * Zero columns in pi2_tmp |
85 | | * |
86 | | * @returns Void |
87 | | * |
88 | | * @remarks |
89 | | * None |
90 | | * |
91 | | ******************************************************************************* |
92 | | */ |
93 | | |
94 | | void ihevc_recon_4x4_ttype1(WORD16 *pi2_src, |
95 | | UWORD8 *pu1_pred, |
96 | | UWORD8 *pu1_dst, |
97 | | WORD32 src_strd, |
98 | | WORD32 pred_strd, |
99 | | WORD32 dst_strd, |
100 | | WORD32 zero_cols) |
101 | 160k | { |
102 | 160k | WORD32 i, j; |
103 | 160k | WORD32 trans_size; |
104 | | |
105 | 160k | trans_size = TRANS_SIZE_4; |
106 | | |
107 | | /* Reconstruction */ |
108 | | |
109 | 802k | for(i = 0; i < trans_size; i++) |
110 | 642k | { |
111 | | /* Checking for Zero Cols */ |
112 | 642k | if((zero_cols & 1) == 1) |
113 | 180k | { |
114 | 901k | for(j = 0; j < trans_size; j++) |
115 | 721k | { |
116 | 721k | pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd]; |
117 | 721k | } |
118 | 180k | } |
119 | 461k | else |
120 | 461k | { |
121 | 2.30M | for(j = 0; j < trans_size; j++) |
122 | 1.84M | { |
123 | 1.84M | pu1_dst[j * dst_strd] = |
124 | 1.84M | CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]); |
125 | 1.84M | } |
126 | 461k | } |
127 | 642k | pi2_src++; |
128 | 642k | pu1_dst++; |
129 | 642k | pu1_pred++; |
130 | 642k | zero_cols = zero_cols >> 1; |
131 | 642k | } |
132 | 160k | } |
133 | | |
134 | | /** |
135 | | ******************************************************************************* |
136 | | * |
137 | | * @brief |
138 | | * This function performs reconstruction for 4x4 input block |
139 | | * |
140 | | * @par Description: |
141 | | * Performs reconstruction of 4x4 input block by adding adding prediction |
142 | | * data to input and clipping it to 8 bit |
143 | | * |
144 | | * @param[in] pi2_src |
145 | | * Input 4x4 coefficients |
146 | | * |
147 | | * @param[in] pu1_pred |
148 | | * Prediction 4x4 block |
149 | | * |
150 | | * @param[out] pu1_dst |
151 | | * Output 4x4 block |
152 | | * |
153 | | * @param[in] src_strd |
154 | | * Input stride |
155 | | * |
156 | | * @param[in] pred_strd |
157 | | * Prediction stride |
158 | | * |
159 | | * @param[in] dst_strd |
160 | | * Output Stride |
161 | | * |
162 | | * @param[in] shift |
163 | | * Output shift |
164 | | * |
165 | | * @param[in] zero_cols |
166 | | * Zero columns in pi2_tmp |
167 | | * |
168 | | * @returns Void |
169 | | * |
170 | | * @remarks |
171 | | * None |
172 | | * |
173 | | ******************************************************************************* |
174 | | */ |
175 | | |
176 | | void ihevc_recon_4x4(WORD16 *pi2_src, |
177 | | UWORD8 *pu1_pred, |
178 | | UWORD8 *pu1_dst, |
179 | | WORD32 src_strd, |
180 | | WORD32 pred_strd, |
181 | | WORD32 dst_strd, |
182 | | WORD32 zero_cols) |
183 | 6.09k | { |
184 | 6.09k | WORD32 i, j; |
185 | 6.09k | WORD32 trans_size; |
186 | | |
187 | 6.09k | trans_size = TRANS_SIZE_4; |
188 | | |
189 | | /* Reconstruction */ |
190 | | |
191 | 30.4k | for(i = 0; i < trans_size; i++) |
192 | 24.3k | { |
193 | | /* Checking for Zero Cols */ |
194 | 24.3k | if((zero_cols & 1) == 1) |
195 | 10.8k | { |
196 | 54.0k | for(j = 0; j < trans_size; j++) |
197 | 43.2k | { |
198 | 43.2k | pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd]; |
199 | 43.2k | } |
200 | 10.8k | } |
201 | 13.5k | else |
202 | 13.5k | { |
203 | 67.8k | for(j = 0; j < trans_size; j++) |
204 | 54.2k | { |
205 | 54.2k | pu1_dst[j * dst_strd] = |
206 | 54.2k | CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]); |
207 | 54.2k | } |
208 | 13.5k | } |
209 | 24.3k | pi2_src++; |
210 | 24.3k | pu1_dst++; |
211 | 24.3k | pu1_pred++; |
212 | 24.3k | zero_cols = zero_cols >> 1; |
213 | 24.3k | } |
214 | 6.09k | } |
215 | | |
216 | | /** |
217 | | ******************************************************************************* |
218 | | * |
219 | | * @brief |
220 | | * This function performs reconstruction for 8x8 input block |
221 | | * |
222 | | * @par Description: |
223 | | * Performs reconstruction of 8x8 input block by adding adding prediction |
224 | | * data to input and clipping it to 8 bit |
225 | | * |
226 | | * @param[in] pi2_src |
227 | | * Input 8x8 coefficients |
228 | | * |
229 | | * @param[in] pu1_pred |
230 | | * Prediction 8x8 block |
231 | | * |
232 | | * @param[out] pu1_dst |
233 | | * Output 8x8 block |
234 | | * |
235 | | * @param[in] src_strd |
236 | | * Input stride |
237 | | * |
238 | | * @param[in] pred_strd |
239 | | * Prediction stride |
240 | | * |
241 | | * @param[in] dst_strd |
242 | | * Output Stride |
243 | | * |
244 | | * @param[in] shift |
245 | | * Output shift |
246 | | * |
247 | | * @param[in] zero_cols |
248 | | * Zero columns in pi2_tmp |
249 | | * |
250 | | * @returns Void |
251 | | * |
252 | | * @remarks |
253 | | * None |
254 | | * |
255 | | ******************************************************************************* |
256 | | */ |
257 | | |
258 | | void ihevc_recon_8x8(WORD16 *pi2_src, |
259 | | UWORD8 *pu1_pred, |
260 | | UWORD8 *pu1_dst, |
261 | | WORD32 src_strd, |
262 | | WORD32 pred_strd, |
263 | | WORD32 dst_strd, |
264 | | WORD32 zero_cols) |
265 | 5.31k | { |
266 | 5.31k | WORD32 i, j; |
267 | 5.31k | WORD32 trans_size; |
268 | | |
269 | 5.31k | trans_size = TRANS_SIZE_8; |
270 | | |
271 | | /* Reconstruction */ |
272 | | |
273 | 47.8k | for(i = 0; i < trans_size; i++) |
274 | 42.4k | { |
275 | | /* Checking for Zero Cols */ |
276 | 42.4k | if((zero_cols & 1) == 1) |
277 | 30.8k | { |
278 | 277k | for(j = 0; j < trans_size; j++) |
279 | 246k | { |
280 | 246k | pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd]; |
281 | 246k | } |
282 | 30.8k | } |
283 | 11.6k | else |
284 | 11.6k | { |
285 | 104k | for(j = 0; j < trans_size; j++) |
286 | 93.2k | { |
287 | 93.2k | pu1_dst[j * dst_strd] = |
288 | 93.2k | CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]); |
289 | 93.2k | } |
290 | 11.6k | } |
291 | 42.4k | pi2_src++; |
292 | 42.4k | pu1_dst++; |
293 | 42.4k | pu1_pred++; |
294 | 42.4k | zero_cols = zero_cols >> 1; |
295 | 42.4k | } |
296 | 5.31k | } |
297 | | |
298 | | /** |
299 | | ******************************************************************************* |
300 | | * |
301 | | * @brief |
302 | | * This function performs reconstruction for 16x16 input block |
303 | | * |
304 | | * @par Description: |
305 | | * Performs reconstruction of 16x16 input block by adding adding prediction |
306 | | * data to input and clipping it to 8 bit |
307 | | * |
308 | | * @param[in] pi2_src |
309 | | * Input 16x16 coefficients |
310 | | * |
311 | | * @param[in] pu1_pred |
312 | | * Prediction 16x16 block |
313 | | * |
314 | | * @param[out] pu1_dst |
315 | | * Output 16x16 block |
316 | | * |
317 | | * @param[in] src_strd |
318 | | * Input stride |
319 | | * |
320 | | * @param[in] pred_strd |
321 | | * Prediction stride |
322 | | * |
323 | | * @param[in] dst_strd |
324 | | * Output Stride |
325 | | * |
326 | | * @param[in] shift |
327 | | * Output shift |
328 | | * |
329 | | * @param[in] zero_cols |
330 | | * Zero columns in pi2_tmp |
331 | | * |
332 | | * @returns Void |
333 | | * |
334 | | * @remarks |
335 | | * None |
336 | | * |
337 | | ******************************************************************************* |
338 | | */ |
339 | | |
340 | | void ihevc_recon_16x16(WORD16 *pi2_src, |
341 | | UWORD8 *pu1_pred, |
342 | | UWORD8 *pu1_dst, |
343 | | WORD32 src_strd, |
344 | | WORD32 pred_strd, |
345 | | WORD32 dst_strd, |
346 | | WORD32 zero_cols) |
347 | 8.06k | { |
348 | 8.06k | WORD32 i, j; |
349 | 8.06k | WORD32 trans_size; |
350 | | |
351 | 8.06k | trans_size = TRANS_SIZE_16; |
352 | | |
353 | | /* Reconstruction */ |
354 | | |
355 | 137k | for(i = 0; i < trans_size; i++) |
356 | 129k | { |
357 | | /* Checking for Zero Cols */ |
358 | 129k | if((zero_cols & 1) == 1) |
359 | 105k | { |
360 | 1.79M | for(j = 0; j < trans_size; j++) |
361 | 1.69M | { |
362 | 1.69M | pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd]; |
363 | 1.69M | } |
364 | 105k | } |
365 | 23.1k | else |
366 | 23.1k | { |
367 | 394k | for(j = 0; j < trans_size; j++) |
368 | 371k | { |
369 | 371k | pu1_dst[j * dst_strd] = |
370 | 371k | CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]); |
371 | 371k | } |
372 | 23.1k | } |
373 | 129k | pi2_src++; |
374 | 129k | pu1_dst++; |
375 | 129k | pu1_pred++; |
376 | 129k | zero_cols = zero_cols >> 1; |
377 | 129k | } |
378 | 8.06k | } |
379 | | |
380 | | /** |
381 | | ******************************************************************************* |
382 | | * |
383 | | * @brief |
384 | | * This function performs reconstruction for 32x32 input block |
385 | | * |
386 | | * @par Description: |
387 | | * Performs reconstruction of 32x32 input block by adding adding prediction |
388 | | * data to input and clipping it to 8 bit |
389 | | * |
390 | | * @param[in] pi2_src |
391 | | * Input 32x32 coefficients |
392 | | * |
393 | | * @param[in] pu1_pred |
394 | | * Prediction 32x32 block |
395 | | * |
396 | | * @param[out] pu1_dst |
397 | | * Output 32x32 block |
398 | | * |
399 | | * @param[in] src_strd |
400 | | * Input stride |
401 | | * |
402 | | * @param[in] pred_strd |
403 | | * Prediction stride |
404 | | * |
405 | | * @param[in] dst_strd |
406 | | * Output Stride |
407 | | * |
408 | | * @param[in] shift |
409 | | * Output shift |
410 | | * |
411 | | * @param[in] zero_cols |
412 | | * Zero columns in pi2_tmp |
413 | | * |
414 | | * @returns Void |
415 | | * |
416 | | * @remarks |
417 | | * None |
418 | | * |
419 | | ******************************************************************************* |
420 | | */ |
421 | | |
422 | | void ihevc_recon_32x32(WORD16 *pi2_src, |
423 | | UWORD8 *pu1_pred, |
424 | | UWORD8 *pu1_dst, |
425 | | WORD32 src_strd, |
426 | | WORD32 pred_strd, |
427 | | WORD32 dst_strd, |
428 | | WORD32 zero_cols) |
429 | 7.35k | { |
430 | 7.35k | WORD32 i, j; |
431 | 7.35k | WORD32 trans_size; |
432 | | |
433 | 7.35k | trans_size = TRANS_SIZE_32; |
434 | | |
435 | | /* Reconstruction */ |
436 | | |
437 | 242k | for(i = 0; i < trans_size; i++) |
438 | 234k | { |
439 | | /* Checking for Zero Cols */ |
440 | 234k | if((zero_cols & 1) == 1) |
441 | 218k | { |
442 | 7.19M | for(j = 0; j < trans_size; j++) |
443 | 6.97M | { |
444 | 6.97M | pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd]; |
445 | 6.97M | } |
446 | 218k | } |
447 | 16.6k | else |
448 | 16.6k | { |
449 | 549k | for(j = 0; j < trans_size; j++) |
450 | 532k | { |
451 | 532k | pu1_dst[j * dst_strd] = |
452 | 532k | CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]); |
453 | 532k | } |
454 | 16.6k | } |
455 | 234k | pi2_src++; |
456 | 234k | pu1_dst++; |
457 | 234k | pu1_pred++; |
458 | 234k | zero_cols = zero_cols >> 1; |
459 | 234k | } |
460 | 7.35k | } |
461 | | |