Coverage Report

Created: 2025-07-18 07:04

/src/libavc/decoder/svc/isvcd_pred_residual_recon.c
Line
Count
Source (jump to first uncovered line)
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
 *  isvcd_pred_residual_recon.c
24
 *
25
 * @brief
26
 *  Contains definition of functions for svc inverse quantization inverse
27
 *    transformation and resd comp
28
 *
29
 * @author
30
 *  Kishore
31
 *
32
 * @par List of Functions:
33
 *  - isvcd_pred_residual_recon_chroma_8x8()
34
 *  - isvcd_residual_chroma_cb_cr_8x8()
35
 *  - isvcd_pred_residual_recon_chroma_4x4()
36
 *  - isvcd_pred_residual_recon_16x16()
37
 *  - isvcd_pred_residual_recon_4x4()
38
 *  - isvcd_pred_residual_recon_8x8()
39
 *  - isvcd_residual_luma_4x4()
40
 *  - isvcd_residual_luma_8x8()
41
 *  - isvcd_residual_luma_16x16()
42
 *
43
 * @remarks
44
 *   None
45
 *
46
 *******************************************************************************
47
 */
48
49
/*****************************************************************************/
50
/* File Includes                                                             */
51
/*****************************************************************************/
52
53
/* User include files */
54
#include "ih264_typedefs.h"
55
#include "ih264_defs.h"
56
#include "ih264_trans_macros.h"
57
#include "ih264_macros.h"
58
#include "ih264_platform_macros.h"
59
#include "ih264_trans_data.h"
60
#include "ih264_size_defs.h"
61
#include "ih264_structs.h"
62
#include "isvcd_pred_residual_recon.h"
63
64
/*****************************************************************************/
65
/*                                                                           */
66
/*  Function Name : isvcd_pred_residual_recon_chroma_8x8                      */
67
/*                                                                           */
68
/*  Description   : this function computes the recon from                    */
69
/*                  the residual and pred buffer                             */
70
/*  Inputs        :                                                          */
71
/*  Globals       : none                                                     */
72
/*  Processing    :                                                          */
73
/*                                                                           */
74
/*  Outputs       : none                                                     */
75
/*  Returns       : nnz                                                      */
76
/*                                                                           */
77
/*  Issues        : none                                                     */
78
/*                                                                           */
79
/*  Revision History:                                                        */
80
/*                                                                           */
81
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
82
/*         25 11 2021   Kishore               creation                       */
83
/*                                                                           */
84
/*****************************************************************************/
85
86
void isvcd_pred_residual_recon_chroma_8x8(UWORD8 *pu1_pred, WORD16 *pi2_rsd, UWORD8 *pu1_out,
87
                                          WORD32 pred_strd, WORD32 rsd_strd, WORD32 out_strd)
88
174k
{
89
174k
    UWORD8 *pu1_pred_ptr = pu1_pred;
90
174k
    WORD16 *pi2_rsd_ptr = pi2_rsd;
91
174k
    UWORD8 *pu1_out_ptr = pu1_out;
92
174k
    WORD16 i, j;
93
174k
    WORD16 i_macro;
94
95
1.56M
    for(i = 0; i < 8; i++)
96
1.39M
    {
97
1.39M
        pu1_pred_ptr = pu1_pred;
98
1.39M
        pi2_rsd_ptr = pi2_rsd;
99
1.39M
        pu1_out = pu1_out_ptr;
100
101
12.5M
        for(j = 0; j < 8; j++)
102
11.1M
        {
103
11.1M
            i_macro = *pu1_pred_ptr + *pi2_rsd_ptr;
104
11.1M
            *pu1_out = CLIP_U8(i_macro);
105
11.1M
            pu1_pred_ptr += pred_strd;
106
11.1M
            pi2_rsd_ptr += rsd_strd;
107
11.1M
            pu1_out += out_strd;
108
11.1M
        }
109
110
1.39M
        pu1_out_ptr += 2;  // Interleaved store for output
111
1.39M
        pu1_pred += 2;     // Interleaved load for pred buffer
112
1.39M
        pi2_rsd += 2;
113
1.39M
    }
114
174k
}
115
116
/*****************************************************************************/
117
/*                                                                           */
118
/*  Function Name : isvcd_residual_chroma_cb_cr_8x8                           */
119
/*                                                                           */
120
/*  Description   : this function computes the nnz from the resd             */
121
/*                                                                           */
122
/*  Inputs        :                                                          */
123
/*  Globals       : none                                                     */
124
/*  Processing    :                                                          */
125
/*                                                                           */
126
/*  Outputs       : none                                                     */
127
/*  Returns       : nnz                                                      */
128
/*                                                                           */
129
/*  Issues        : none                                                     */
130
/*                                                                           */
131
/*  Revision History:                                                        */
132
/*                                                                           */
133
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
134
/*         25 11 2021   Kishore               creation                       */
135
/*                                                                           */
136
/*****************************************************************************/
137
138
WORD32 isvcd_residual_chroma_cb_cr_8x8(WORD16 *pi2_rsd, WORD32 rsd_strd)
139
0
{
140
0
    WORD16 *pi2_rsd_ptr_Cb = pi2_rsd;
141
0
    WORD16 *pi2_rsd_ptr_Cr = pi2_rsd + 1;
142
0
    WORD16 i, j;
143
0
    WORD32 i4_nnz = 0, ai4_nnz_Cb[2][2] = {0}, ai4_nnz_Cr[2][2] = {0};
144
145
0
    for(i = 0; i < 8; i++)
146
0
    {
147
0
        pi2_rsd_ptr_Cb = pi2_rsd;
148
0
        pi2_rsd_ptr_Cr = pi2_rsd + 1;
149
150
0
        for(j = 0; j < 8; j++)
151
0
        {
152
0
            ai4_nnz_Cb[j >> 2][i >> 2] |= !!(*pi2_rsd_ptr_Cb);
153
0
            ai4_nnz_Cr[j >> 2][i >> 2] |= !!(*pi2_rsd_ptr_Cr);
154
0
            pi2_rsd_ptr_Cb += rsd_strd;
155
0
            pi2_rsd_ptr_Cr += rsd_strd;
156
0
        }
157
0
        pi2_rsd += 2;
158
0
    }
159
0
    i4_nnz = ai4_nnz_Cr[0][0] | (ai4_nnz_Cr[1][0] << 2);
160
0
    i4_nnz |= (ai4_nnz_Cr[0][1] << 1) | (ai4_nnz_Cr[1][1] << 3);
161
0
    i4_nnz <<= 4;
162
0
    i4_nnz |= ai4_nnz_Cb[0][0] | (ai4_nnz_Cb[1][0] << 2);
163
0
    i4_nnz |= (ai4_nnz_Cb[0][1] << 1) | (ai4_nnz_Cb[1][1] << 3);
164
0
    return i4_nnz;
165
0
}
166
167
/*****************************************************************************/
168
/*                                                                           */
169
/*  Function Name : isvcd_pred_residual_recon_chroma_4x4                      */
170
/*                                                                           */
171
/*  Description   : this function computes the recon from                    */
172
/*                  the residual and pred buffer                             */
173
/*  Inputs        :                                                          */
174
/*  Globals       : none                                                     */
175
/*  Processing    :                                                          */
176
/*                                                                           */
177
/*  Outputs       : none                                                     */
178
/*  Returns       : none                                                     */
179
/*                                                                           */
180
/*  Issues        : none                                                     */
181
/*                                                                           */
182
/*  Revision History:                                                        */
183
/*                                                                           */
184
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
185
/*         25 11 2021   Kishore               creation                       */
186
/*                                                                           */
187
/*****************************************************************************/
188
void isvcd_pred_residual_recon_chroma_4x4(UWORD8 *pu1_pred, WORD16 *pi2_rsd, UWORD8 *pu1_out,
189
                                          WORD32 pred_strd, WORD32 rsd_strd, WORD32 out_strd)
190
17.9k
{
191
17.9k
    UWORD8 *pu1_pred_ptr = pu1_pred;
192
17.9k
    WORD16 *pi2_rsd_ptr = pi2_rsd;
193
17.9k
    UWORD8 *pu1_out_ptr = pu1_out;
194
17.9k
    WORD16 i, j;
195
17.9k
    WORD16 i_macro;
196
197
89.5k
    for(i = 0; i < 4; i++)
198
71.6k
    {
199
71.6k
        pu1_pred_ptr = pu1_pred;
200
71.6k
        pi2_rsd_ptr = pi2_rsd;
201
71.6k
        pu1_out = pu1_out_ptr;
202
203
358k
        for(j = 0; j < 4; j++)
204
286k
        {
205
286k
            i_macro = *pu1_pred_ptr + *pi2_rsd_ptr;
206
286k
            *pu1_out = CLIP_U8(i_macro);
207
286k
            pu1_pred_ptr += pred_strd;
208
286k
            pi2_rsd_ptr += rsd_strd;
209
286k
            pu1_out += out_strd;
210
286k
        }
211
212
71.6k
        pu1_out_ptr += 2;  // Interleaved store for output
213
71.6k
        pu1_pred += 2;     // Interleaved load for pred buffer
214
71.6k
        pi2_rsd += 2;
215
71.6k
    }
216
17.9k
}
217
218
/*****************************************************************************/
219
/*                                                                           */
220
/*  Function Name : isvcd_pred_residual_recon_16x16                           */
221
/*                                                                           */
222
/*  Description   : this function computes the recon from                    */
223
/*                  the residual and pred buffer                             */
224
/*  Inputs        :                                                          */
225
/*  Globals       : none                                                     */
226
/*  Processing    :                                                          */
227
/*                                                                           */
228
/*  Outputs       : none                                                     */
229
/*  Returns       : nnz                                                     */
230
/*                                                                           */
231
/*  Issues        : none                                                     */
232
/*                                                                           */
233
/*  Revision History:                                                        */
234
/*                                                                           */
235
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
236
/*         25 11 2021   Kishore               creation                       */
237
/*                                                                           */
238
/*****************************************************************************/
239
240
WORD32 isvcd_pred_residual_recon_16x16(UWORD8 *pu1_pred, WORD16 *pi2_rsd, UWORD8 *pu1_out,
241
                                       WORD32 pred_strd, WORD32 rsd_strd, WORD32 out_strd)
242
77.5k
{
243
77.5k
    WORD32 i4_nnz = 0, i4_nnz_blk[4][4] = {0};
244
77.5k
    UWORD8 *pu1_pred_ptr = pu1_pred;
245
77.5k
    WORD16 *pi2_rsd_ptr = pi2_rsd;
246
77.5k
    UWORD8 *pu1_out_ptr = pu1_out;
247
77.5k
    WORD16 i, j;
248
77.5k
    WORD16 i_macro;
249
250
1.31M
    for(i = 0; i < 16; i++)
251
1.24M
    {
252
1.24M
        pu1_pred_ptr = pu1_pred;
253
1.24M
        pi2_rsd_ptr = pi2_rsd;
254
1.24M
        pu1_out = pu1_out_ptr;
255
256
21.0M
        for(j = 0; j < 16; j++)
257
19.8M
        {
258
19.8M
            i_macro = *pi2_rsd_ptr;
259
19.8M
            i4_nnz_blk[j >> 2][i >> 2] |= !!i_macro;
260
19.8M
            i_macro += *pu1_pred_ptr;
261
19.8M
            *pu1_out = CLIP_U8(i_macro);
262
19.8M
            pu1_pred_ptr += pred_strd;
263
19.8M
            pi2_rsd_ptr += rsd_strd;
264
19.8M
            pu1_out += out_strd;
265
19.8M
        }
266
267
1.24M
        pu1_out_ptr++;
268
1.24M
        pi2_rsd++;
269
1.24M
        pu1_pred++;
270
1.24M
    }
271
272
387k
    for(i = 0; i < 4; i++)
273
310k
    {
274
1.55M
        for(j = 0; j < 4; j++)
275
1.24M
        {
276
1.24M
            i4_nnz |= (i4_nnz_blk[j][i]) << (i + (j << 2));
277
1.24M
        }
278
310k
    }
279
280
77.5k
    return i4_nnz;
281
77.5k
}
282
283
/*****************************************************************************/
284
/*                                                                           */
285
/*  Function Name : isvcd_pred_residual_recon_4x4                             */
286
/*                                                                           */
287
/*  Description   : this function computes the recon from                    */
288
/*                  the residual and pred buffer                             */
289
/*  Inputs        :                                                          */
290
/*  Globals       : none                                                     */
291
/*  Processing    :                                                          */
292
/*                                                                           */
293
/*  Outputs       : none                                                     */
294
/*  Returns       : nnz                                                      */
295
/*                                                                           */
296
/*  Issues        : none                                                     */
297
/*                                                                           */
298
/*  Revision History:                                                        */
299
/*                                                                           */
300
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
301
/*         25 11 2021   Kishore               creation                       */
302
/*                                                                           */
303
/*****************************************************************************/
304
305
WORD32 isvcd_pred_residual_recon_4x4(UWORD8 *pu1_pred, WORD16 *pi2_rsd, UWORD8 *pu1_out,
306
                                     WORD32 pred_strd, WORD32 rsd_strd, WORD32 out_strd)
307
111k
{
308
111k
    WORD32 i4_nnz_blk[4][4] = {0};
309
111k
    UWORD8 *pu1_pred_ptr = pu1_pred;
310
111k
    WORD16 *pi2_rsd_ptr = pi2_rsd;
311
111k
    UWORD8 *pu1_out_ptr = pu1_out;
312
111k
    WORD16 i, j;
313
111k
    WORD16 i_macro;
314
315
559k
    for(i = 0; i < 4; i++)
316
447k
    {
317
447k
        pu1_pred_ptr = pu1_pred;
318
447k
        pi2_rsd_ptr = pi2_rsd;
319
447k
        pu1_out = pu1_out_ptr;
320
321
2.23M
        for(j = 0; j < 4; j++)
322
1.79M
        {
323
1.79M
            i_macro = *pi2_rsd_ptr;
324
1.79M
            i4_nnz_blk[j >> 2][i >> 2] |= !!i_macro;
325
1.79M
            i_macro += *pu1_pred_ptr;
326
1.79M
            *pu1_out = CLIP_U8(i_macro);
327
1.79M
            pu1_pred_ptr += pred_strd;
328
1.79M
            pi2_rsd_ptr += rsd_strd;
329
1.79M
            pu1_out += out_strd;
330
1.79M
        }
331
332
447k
        pu1_out_ptr++;
333
447k
        pi2_rsd++;
334
447k
        pu1_pred++;
335
447k
    }
336
337
111k
    return i4_nnz_blk[0][0];
338
111k
}
339
340
/*****************************************************************************/
341
/*                                                                           */
342
/*  Function Name : isvcd_pred_residual_recon_8x8                             */
343
/*                                                                           */
344
/*  Description   : this function computes the recon from                    */
345
/*                  the residual and pred buffer                             */
346
/*  Inputs        :                                                          */
347
/*  Globals       : none                                                     */
348
/*  Processing    :                                                          */
349
/*                                                                           */
350
/*  Outputs       : none                                                     */
351
/*  Returns       : nnz                                                      */
352
/*                                                                           */
353
/*  Issues        : none                                                     */
354
/*                                                                           */
355
/*  Revision History:                                                        */
356
/*                                                                           */
357
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
358
/*         25 11 2021   Kishore               creation                       */
359
/*                                                                           */
360
/*****************************************************************************/
361
362
WORD32 isvcd_pred_residual_recon_8x8(UWORD8 *pu1_pred, WORD16 *pi2_rsd, UWORD8 *pu1_out,
363
                                     WORD32 pred_strd, WORD32 rsd_strd, WORD32 out_strd)
364
10.8k
{
365
10.8k
    WORD32 i4_nnz = 0, i4_nnz_blk[4][4] = {0};
366
10.8k
    UWORD8 *pu1_pred_ptr = pu1_pred;
367
10.8k
    WORD16 *pi2_rsd_ptr = pi2_rsd;
368
10.8k
    UWORD8 *pu1_out_ptr = pu1_out;
369
10.8k
    WORD16 i, j;
370
10.8k
    WORD16 i_macro;
371
372
97.5k
    for(i = 0; i < 8; i++)
373
86.6k
    {
374
86.6k
        pu1_pred_ptr = pu1_pred;
375
86.6k
        pi2_rsd_ptr = pi2_rsd;
376
86.6k
        pu1_out = pu1_out_ptr;
377
378
780k
        for(j = 0; j < 8; j++)
379
693k
        {
380
693k
            i_macro = *pi2_rsd_ptr;
381
693k
            i4_nnz_blk[j >> 2][i >> 2] |= !!i_macro;
382
693k
            i_macro += *pu1_pred_ptr;
383
693k
            *pu1_out = CLIP_U8(i_macro);
384
693k
            pu1_pred_ptr += pred_strd;
385
693k
            pi2_rsd_ptr += rsd_strd;
386
693k
            pu1_out += out_strd;
387
693k
        }
388
389
86.6k
        pu1_out_ptr++;
390
86.6k
        pi2_rsd++;
391
86.6k
        pu1_pred++;
392
86.6k
    }
393
394
10.8k
    i4_nnz = i4_nnz_blk[0][0] | (i4_nnz_blk[1][0] << 4);
395
10.8k
    i4_nnz |= (i4_nnz_blk[0][1] << 1) | (i4_nnz_blk[1][1] << 5);
396
397
10.8k
    return i4_nnz;
398
10.8k
}
399
400
/*****************************************************************************/
401
/*                                                                           */
402
/*  Function Name : isvcd_residual_luma_4x4                                   */
403
/*                                                                           */
404
/*  Description   : this function computes the nnz from resd                 */
405
/*                                                                           */
406
/*  Inputs        :                                                          */
407
/*  Globals       : none                                                     */
408
/*  Processing    :                                                          */
409
/*                                                                           */
410
/*  Outputs       : none                                                     */
411
/*  Returns       : nnz                                                      */
412
/*                                                                           */
413
/*  Issues        : none                                                     */
414
/*                                                                           */
415
/*  Revision History:                                                        */
416
/*                                                                           */
417
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
418
/*         25 11 2021   Kishore               creation                       */
419
/*                                                                           */
420
/*****************************************************************************/
421
422
WORD32 isvcd_residual_luma_4x4(WORD16 *pi2_rsd, WORD32 rsd_strd)
423
0
{
424
0
    WORD32 i4_nnz_blk[4][4] = {0};
425
0
    WORD16 *pi2_rsd_ptr = pi2_rsd;
426
0
    WORD16 i, j;
427
0
    WORD16 i_macro;
428
429
0
    for(i = 0; i < 4; i++)
430
0
    {
431
0
        pi2_rsd_ptr = pi2_rsd;
432
433
0
        for(j = 0; j < 4; j++)
434
0
        {
435
0
            i_macro = *pi2_rsd_ptr;
436
0
            i4_nnz_blk[j >> 2][i >> 2] |= !!i_macro;
437
0
            pi2_rsd_ptr += rsd_strd;
438
0
        }
439
0
        pi2_rsd++;
440
0
    }
441
0
    return i4_nnz_blk[0][0];
442
0
}
443
444
/*****************************************************************************/
445
/*                                                                           */
446
/*  Function Name : isvcd_residual_luma_8x8                                   */
447
/*                                                                           */
448
/*  Description   : this function computes the nnz from resd                 */
449
/*                                                                           */
450
/*  Inputs        :                                                          */
451
/*  Globals       : none                                                     */
452
/*  Processing    :                                                          */
453
/*                                                                           */
454
/*  Outputs       : none                                                     */
455
/*  Returns       : nnz                                                      */
456
/*                                                                           */
457
/*  Issues        : none                                                     */
458
/*                                                                           */
459
/*  Revision History:                                                        */
460
/*                                                                           */
461
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
462
/*         25 11 2021   Kishore               creation                       */
463
/*                                                                           */
464
/*****************************************************************************/
465
466
WORD32 isvcd_residual_luma_8x8(WORD16 *pi2_rsd, WORD32 rsd_strd)
467
0
{
468
0
    WORD32 i4_nnz = 0, i4_nnz_blk[4][4] = {0};
469
0
    WORD16 *pi2_rsd_ptr = pi2_rsd;
470
0
    WORD16 i, j;
471
0
    WORD16 i_macro;
472
473
0
    for(i = 0; i < 8; i++)
474
0
    {
475
0
        pi2_rsd_ptr = pi2_rsd;
476
477
0
        for(j = 0; j < 8; j++)
478
0
        {
479
0
            i_macro = *pi2_rsd_ptr;
480
0
            i4_nnz_blk[j >> 2][i >> 2] |= !!i_macro;
481
0
            pi2_rsd_ptr += rsd_strd;
482
0
        }
483
0
        pi2_rsd++;
484
0
    }
485
486
0
    i4_nnz = i4_nnz_blk[0][0] | (i4_nnz_blk[1][0] << 4);
487
0
    i4_nnz |= (i4_nnz_blk[0][1] << 1) | (i4_nnz_blk[1][1] << 5);
488
0
    return i4_nnz;
489
0
}
490
491
/*****************************************************************************/
492
/*                                                                           */
493
/*  Function Name : isvcd_residual_luma_16x16                                 */
494
/*                                                                           */
495
/*  Description   : this function computes the nnz from resd                 */
496
/*                                                                           */
497
/*  Inputs        :                                                          */
498
/*  Globals       : none                                                     */
499
/*  Processing    :                                                          */
500
/*                                                                           */
501
/*  Outputs       : none                                                     */
502
/*  Returns       : nnz                                                      */
503
/*                                                                           */
504
/*  Issues        : none                                                     */
505
/*                                                                           */
506
/*  Revision History:                                                        */
507
/*                                                                           */
508
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
509
/*         25 11 2021   Kishore               creation                       */
510
/*                                                                           */
511
/*****************************************************************************/
512
513
WORD32 isvcd_residual_luma_16x16(WORD16 *pi2_rsd, WORD32 rsd_strd)
514
0
{
515
0
    WORD32 i4_nnz = 0, i4_nnz_blk[4][4] = {0};
516
0
    WORD16 *pi2_rsd_ptr = pi2_rsd;
517
0
    WORD16 i, j;
518
0
    WORD16 i_macro;
519
520
0
    for(i = 0; i < 16; i++)
521
0
    {
522
0
        pi2_rsd_ptr = pi2_rsd;
523
524
0
        for(j = 0; j < 16; j++)
525
0
        {
526
0
            i_macro = *pi2_rsd_ptr;
527
0
            i4_nnz_blk[j >> 2][i >> 2] |= !!i_macro;
528
0
            pi2_rsd_ptr += rsd_strd;
529
0
        }
530
0
        pi2_rsd++;
531
0
    }
532
533
0
    for(i = 0; i < 4; i++)
534
0
    {
535
0
        for(j = 0; j < 4; j++)
536
0
        {
537
0
            i4_nnz |= (i4_nnz_blk[j][i]) << (i + (j << 2));
538
0
        }
539
0
    }
540
0
    return i4_nnz;
541
0
}