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_chroma_recon.c
22  *
23  * @brief
24  *  Functions definitions reconstruction  of chroma interleaved data.
25  *
26  * @author
27  *  100470
28  *
29  * @par List of Functions:
30  *  - ihevc_chroma_recon_4x4()
31  *  - ihevc_chroma_recon_8x8()
32  *  - ihevc_chroma_recon_16x16()
33  *
34  * @remarks
35  *  None
36  *
37  *******************************************************************************
38  */
39 
40 #include <stdio.h>
41 #include <string.h>
42 #include "ihevc_typedefs.h"
43 #include "ihevc_macros.h"
44 #include "ihevc_platform_macros.h"
45 #include "ihevc_defs.h"
46 #include "ihevc_trans_tables.h"
47 #include "ihevc_chroma_recon.h"
48 #include "ihevc_func_selector.h"
49 #include "ihevc_trans_macros.h"
50 
51 /* All the functions work one component(U or V) of interleaved data depending upon pointers passed to it */
52 /* Data visualization */
53 /* U V U V U V U V */
54 /* U V U V U V U V */
55 /* U V U V U V U V */
56 /* U V U V U V U V */
57 /* If the pointer points to first byte of above stream (U) , functions will operate on U component */
58 /* If the pointer points to second byte of above stream (V) , functions will operate on V component */
59 
60 /**
61  *******************************************************************************
62  *
63  * @brief
64  *  This function performs reconstruction for  4x4 input block
65  *
66  * @par Description:
67  *  Performs reconstruction of 4x4 input block by adding  adding prediction
68  * data to input and clipping it to 8 bit
69  *
70  * @param[in] pi2_src
71  *  Input 4x4 coefficients
72  *
73  * @param[in] pu1_pred
74  *  Prediction 4x4 block
75  *
76  * @param[out] pu1_dst
77  *  Output 4x4 block
78  *
79  * @param[in] src_strd
80  *  Input stride
81  *
82  * @param[in] pred_strd
83  *  Prediction stride
84  *
85  * @param[in] dst_strd
86  *  Output Stride
87  *
88  * @param[in] shift
89  *  Output shift
90  *
91  * @param[in] zero_cols
92  *  Zero columns in pi2_tmp
93  *
94  * @returns  Void
95  *
96  * @remarks
97  *  None
98  *
99  *******************************************************************************
100  */
101 
102 
ihevc_chroma_recon_4x4(WORD16 * pi2_src,UWORD8 * pu1_pred,UWORD8 * pu1_dst,WORD32 src_strd,WORD32 pred_strd,WORD32 dst_strd,WORD32 zero_cols)103 void ihevc_chroma_recon_4x4(WORD16 *pi2_src,
104                             UWORD8 *pu1_pred,
105                             UWORD8 *pu1_dst,
106                             WORD32 src_strd,
107                             WORD32 pred_strd,
108                             WORD32 dst_strd,
109                             WORD32 zero_cols)
110 {
111     WORD32 i, j;
112     WORD32 trans_size;
113 
114     trans_size = TRANS_SIZE_4;
115 
116     /* Reconstruction */
117 
118     for(i = 0; i < trans_size; i++)
119     {
120         /* Checking for Zero Cols */
121         if((zero_cols & 1) == 1)
122         {
123             for(j = 0; j < trans_size; j++)
124             {
125                 pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd];
126             }
127         }
128         else
129         {
130             for(j = 0; j < trans_size; j++)
131             {
132                 pu1_dst[j * dst_strd] =
133                                 CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]);
134             }
135         }
136         pi2_src++;
137         pu1_dst += 2;
138         pu1_pred += 2;
139         zero_cols = zero_cols >> 1;
140     }
141 }
142 
143 /**
144  *******************************************************************************
145  *
146  * @brief
147  *  This function performs reconstruction for 8x8 input block
148  *
149  * @par Description:
150  *  Performs reconstruction of 8x8 input block by adding  adding prediction
151  * data to input and clipping it to 8 bit
152  *
153  * @param[in] pi2_src
154  *  Input 8x8 coefficients
155  *
156  * @param[in] pu1_pred
157  *  Prediction 8x8 block
158  *
159  * @param[out] pu1_dst
160  *  Output 8x8 block
161  *
162  * @param[in] src_strd
163  *  Input stride
164  *
165  * @param[in] pred_strd
166  *  Prediction stride
167  *
168  * @param[in] dst_strd
169  *  Output Stride
170  *
171  * @param[in] shift
172  *  Output shift
173  *
174  * @param[in] zero_cols
175  *  Zero columns in pi2_tmp
176  *
177  * @returns  Void
178  *
179  * @remarks
180  *  None
181  *
182  *******************************************************************************
183  */
184 
185 
ihevc_chroma_recon_8x8(WORD16 * pi2_src,UWORD8 * pu1_pred,UWORD8 * pu1_dst,WORD32 src_strd,WORD32 pred_strd,WORD32 dst_strd,WORD32 zero_cols)186 void ihevc_chroma_recon_8x8(WORD16 *pi2_src,
187                             UWORD8 *pu1_pred,
188                             UWORD8 *pu1_dst,
189                             WORD32 src_strd,
190                             WORD32 pred_strd,
191                             WORD32 dst_strd,
192                             WORD32 zero_cols)
193 {
194     WORD32 i, j;
195     WORD32 trans_size;
196 
197     trans_size = TRANS_SIZE_8;
198 
199     /* Reconstruction */
200 
201     for(i = 0; i < trans_size; i++)
202     {
203         /* Checking for Zero Cols */
204         if((zero_cols & 1) == 1)
205         {
206             for(j = 0; j < trans_size; j++)
207             {
208                 pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd];
209             }
210         }
211         else
212         {
213             for(j = 0; j < trans_size; j++)
214             {
215                 pu1_dst[j * dst_strd] =
216                                 CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]);
217             }
218         }
219         pi2_src++;
220         pu1_dst += 2;
221         pu1_pred += 2;
222         zero_cols = zero_cols >> 1;
223     }
224 }
225 
226 /**
227  *******************************************************************************
228  *
229  * @brief
230  *  This function performs reconstruction for  16x16 input block
231  *
232  * @par Description:
233  *  Performs reconstruction of 16x16 input block by adding  adding prediction
234  * data to input and clipping it to 8 bit
235  *
236  * @param[in] pi2_src
237  *  Input 16x16 coefficients
238  *
239  * @param[in] pu1_pred
240  *  Prediction 16x16 block
241  *
242  * @param[out] pu1_dst
243  *  Output 16x16 block
244  *
245  * @param[in] src_strd
246  *  Input stride
247  *
248  * @param[in] pred_strd
249  *  Prediction stride
250  *
251  * @param[in] dst_strd
252  *  Output Stride
253  *
254  * @param[in] shift
255  *  Output shift
256  *
257  * @param[in] zero_cols
258  *  Zero columns in pi2_tmp
259  *
260  * @returns  Void
261  *
262  * @remarks
263  *  None
264  *
265  *******************************************************************************
266  */
267 
268 
ihevc_chroma_recon_16x16(WORD16 * pi2_src,UWORD8 * pu1_pred,UWORD8 * pu1_dst,WORD32 src_strd,WORD32 pred_strd,WORD32 dst_strd,WORD32 zero_cols)269 void ihevc_chroma_recon_16x16(WORD16 *pi2_src,
270                               UWORD8 *pu1_pred,
271                               UWORD8 *pu1_dst,
272                               WORD32 src_strd,
273                               WORD32 pred_strd,
274                               WORD32 dst_strd,
275                               WORD32 zero_cols)
276 {
277     WORD32 i, j;
278     WORD32 trans_size;
279 
280     trans_size = TRANS_SIZE_16;
281 
282     /* Reconstruction */
283 
284     for(i = 0; i < trans_size; i++)
285     {
286         /* Checking for Zero Cols */
287         if((zero_cols & 1) == 1)
288         {
289             for(j = 0; j < trans_size; j++)
290             {
291                 pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd];
292             }
293         }
294         else
295         {
296             for(j = 0; j < trans_size; j++)
297             {
298                 pu1_dst[j * dst_strd] =
299                                 CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]);
300             }
301         }
302         pi2_src++;
303         pu1_dst += 2;
304         pu1_pred += 2;
305         zero_cols = zero_cols >> 1;
306     }
307 }
308 
309