Coverage Report

Created: 2026-08-13 06:09

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