• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
ihevc_recon_4x4_ttype1(WORD16 * pi2_src,UWORD8 * pu1_pred,UWORD8 * pu1_dst,WORD32 src_strd,WORD32 pred_strd,WORD32 dst_strd,WORD32 zero_cols)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 {
102     WORD32 i, j;
103     WORD32 trans_size;
104 
105     trans_size = TRANS_SIZE_4;
106 
107     /* Reconstruction */
108 
109     for(i = 0; i < trans_size; i++)
110     {
111         /* Checking for Zero Cols */
112         if((zero_cols & 1) == 1)
113         {
114             for(j = 0; j < trans_size; j++)
115             {
116                 pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd];
117             }
118         }
119         else
120         {
121             for(j = 0; j < trans_size; j++)
122             {
123                 pu1_dst[j * dst_strd] =
124                                 CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]);
125             }
126         }
127         pi2_src++;
128         pu1_dst++;
129         pu1_pred++;
130         zero_cols = zero_cols >> 1;
131     }
132 }
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 
ihevc_recon_4x4(WORD16 * pi2_src,UWORD8 * pu1_pred,UWORD8 * pu1_dst,WORD32 src_strd,WORD32 pred_strd,WORD32 dst_strd,WORD32 zero_cols)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 {
184     WORD32 i, j;
185     WORD32 trans_size;
186 
187     trans_size = TRANS_SIZE_4;
188 
189     /* Reconstruction */
190 
191     for(i = 0; i < trans_size; i++)
192     {
193         /* Checking for Zero Cols */
194         if((zero_cols & 1) == 1)
195         {
196             for(j = 0; j < trans_size; j++)
197             {
198                 pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd];
199             }
200         }
201         else
202         {
203             for(j = 0; j < trans_size; j++)
204             {
205                 pu1_dst[j * dst_strd] =
206                                 CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]);
207             }
208         }
209         pi2_src++;
210         pu1_dst++;
211         pu1_pred++;
212         zero_cols = zero_cols >> 1;
213     }
214 }
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 
ihevc_recon_8x8(WORD16 * pi2_src,UWORD8 * pu1_pred,UWORD8 * pu1_dst,WORD32 src_strd,WORD32 pred_strd,WORD32 dst_strd,WORD32 zero_cols)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 {
266     WORD32 i, j;
267     WORD32 trans_size;
268 
269     trans_size = TRANS_SIZE_8;
270 
271     /* Reconstruction */
272 
273     for(i = 0; i < trans_size; i++)
274     {
275         /* Checking for Zero Cols */
276         if((zero_cols & 1) == 1)
277         {
278             for(j = 0; j < trans_size; j++)
279             {
280                 pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd];
281             }
282         }
283         else
284         {
285             for(j = 0; j < trans_size; j++)
286             {
287                 pu1_dst[j * dst_strd] =
288                                 CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]);
289             }
290         }
291         pi2_src++;
292         pu1_dst++;
293         pu1_pred++;
294         zero_cols = zero_cols >> 1;
295     }
296 }
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 
ihevc_recon_16x16(WORD16 * pi2_src,UWORD8 * pu1_pred,UWORD8 * pu1_dst,WORD32 src_strd,WORD32 pred_strd,WORD32 dst_strd,WORD32 zero_cols)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 {
348     WORD32 i, j;
349     WORD32 trans_size;
350 
351     trans_size = TRANS_SIZE_16;
352 
353     /* Reconstruction */
354 
355     for(i = 0; i < trans_size; i++)
356     {
357         /* Checking for Zero Cols */
358         if((zero_cols & 1) == 1)
359         {
360             for(j = 0; j < trans_size; j++)
361             {
362                 pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd];
363             }
364         }
365         else
366         {
367             for(j = 0; j < trans_size; j++)
368             {
369                 pu1_dst[j * dst_strd] =
370                                 CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]);
371             }
372         }
373         pi2_src++;
374         pu1_dst++;
375         pu1_pred++;
376         zero_cols = zero_cols >> 1;
377     }
378 }
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 
ihevc_recon_32x32(WORD16 * pi2_src,UWORD8 * pu1_pred,UWORD8 * pu1_dst,WORD32 src_strd,WORD32 pred_strd,WORD32 dst_strd,WORD32 zero_cols)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 {
430     WORD32 i, j;
431     WORD32 trans_size;
432 
433     trans_size = TRANS_SIZE_32;
434 
435     /* Reconstruction */
436 
437     for(i = 0; i < trans_size; i++)
438     {
439         /* Checking for Zero Cols */
440         if((zero_cols & 1) == 1)
441         {
442             for(j = 0; j < trans_size; j++)
443             {
444                 pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd];
445             }
446         }
447         else
448         {
449             for(j = 0; j < trans_size; j++)
450             {
451                 pu1_dst[j * dst_strd] =
452                                 CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]);
453             }
454         }
455         pi2_src++;
456         pu1_dst++;
457         pu1_pred++;
458         zero_cols = zero_cols >> 1;
459     }
460 }
461 
462