Coverage Report

Created: 2026-02-14 06:43

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libhevc/common/ihevc_chroma_itrans_recon_8x8.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_chroma_itrans_recon_8x8.c
22
 *
23
 * @brief
24
 *  Contains function definitions for 8x8 inverse transform  and reconstruction
25
 * of chroma interleaved data.
26
 *
27
 * @author
28
 *  100470
29
 *
30
 * @par List of Functions:
31
 *  - ihevc_chroma_itrans_recon_8x8()
32
 *
33
 * @remarks
34
 *  None
35
 *
36
 *******************************************************************************
37
 */
38
39
#include <stdio.h>
40
#include <string.h>
41
#include "ihevc_typedefs.h"
42
#include "ihevc_macros.h"
43
#include "ihevc_platform_macros.h"
44
#include "ihevc_defs.h"
45
#include "ihevc_trans_tables.h"
46
#include "ihevc_chroma_itrans_recon.h"
47
#include "ihevc_func_selector.h"
48
#include "ihevc_trans_macros.h"
49
50
/* All the functions work one component(U or V) of interleaved data depending upon pointers passed to it */
51
/* Data visualization */
52
/* U V U V U V U V */
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
/* If the pointer points to first byte of above stream (U) , functions will operate on U component */
57
/* If the pointer points to second byte of above stream (V) , functions will operate on V component */
58
59
/**
60
 *******************************************************************************
61
 *
62
 * @brief
63
 *  This function performs Inverse transform  and reconstruction for 8x8
64
 * input block
65
 *
66
 * @par Description:
67
 *  Performs inverse transform and adds the prediction  data and clips output
68
 * to 8 bit
69
 *
70
 * @param[in] pi2_src
71
 *  Input 8x8 coefficients
72
 *
73
 * @param[in] pi2_tmp
74
 *  Temporary 8x8 buffer for storing inverse transform
75
 *  1st stage output
76
 *
77
 * @param[in] pu1_pred
78
 *  Prediction 8x8 block
79
 *
80
 * @param[out] pu1_dst
81
 *  Output 8x8 block
82
 *
83
 * @param[in] src_strd
84
 *  Input stride
85
 *
86
 * @param[in] pred_strd
87
 *  Prediction stride
88
 *
89
 * @param[in] dst_strd
90
 *  Output Stride
91
 *
92
 * @param[in] shift
93
 *  Output shift
94
 *
95
 * @param[in] zero_cols
96
 *  Zero columns in pi2_src
97
 *
98
 * @returns  Void
99
 *
100
 * @remarks
101
 *  None
102
 *
103
 *******************************************************************************
104
 */
105
106
107
void ihevc_chroma_itrans_recon_8x8(WORD16 *pi2_src,
108
                                   WORD16 *pi2_tmp,
109
                                   UWORD8 *pu1_pred,
110
                                   UWORD8 *pu1_dst,
111
                                   WORD32 src_strd,
112
                                   WORD32 pred_strd,
113
                                   WORD32 dst_strd,
114
                                   WORD32 zero_cols,
115
                                   WORD32 zero_rows)
116
114k
{
117
114k
    WORD32 j, k;
118
114k
    WORD32 e[4], o[4];
119
114k
    WORD32 ee[2], eo[2];
120
114k
    WORD32 add;
121
114k
    WORD32 shift;
122
114k
    WORD16 *pi2_tmp_orig;
123
114k
    WORD32 trans_size;
124
114k
    WORD32 zero_rows_2nd_stage = zero_cols;
125
114k
    WORD32 row_limit_2nd_stage;
126
114k
    UNUSED(zero_rows);
127
114k
    trans_size = TRANS_SIZE_8;
128
129
114k
    pi2_tmp_orig = pi2_tmp;
130
131
114k
    if((zero_cols & 0xF0) == 0xF0)
132
58.1k
        row_limit_2nd_stage = 4;
133
56.7k
    else
134
56.7k
        row_limit_2nd_stage = TRANS_SIZE_8;
135
136
    /* Inverse Transform 1st stage */
137
114k
    shift = IT_SHIFT_STAGE_1;
138
114k
    add = 1 << (shift - 1);
139
114k
    {
140
        /************************************************************************************************/
141
        /**********************************START - IT_RECON_8x8******************************************/
142
        /************************************************************************************************/
143
144
801k
        for(j = 0; j < row_limit_2nd_stage; j++)
145
686k
        {
146
            /* Checking for Zero Cols */
147
686k
            if((zero_cols & 1) == 1)
148
144k
            {
149
144k
                memset(pi2_tmp, 0, trans_size * sizeof(WORD16));
150
144k
            }
151
542k
            else
152
542k
            {
153
                /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
154
2.71M
                for(k = 0; k < 4; k++)
155
2.16M
                {
156
2.16M
                    o[k] = g_ai2_ihevc_trans_8[1][k] * pi2_src[src_strd]
157
2.16M
                                    + g_ai2_ihevc_trans_8[3][k]
158
2.16M
                                                    * pi2_src[3 * src_strd]
159
2.16M
                                    + g_ai2_ihevc_trans_8[5][k]
160
2.16M
                                                    * pi2_src[5 * src_strd]
161
2.16M
                                    + g_ai2_ihevc_trans_8[7][k]
162
2.16M
                                                    * pi2_src[7 * src_strd];
163
2.16M
                }
164
165
542k
                eo[0] = g_ai2_ihevc_trans_8[2][0] * pi2_src[2 * src_strd]
166
542k
                                + g_ai2_ihevc_trans_8[6][0] * pi2_src[6 * src_strd];
167
542k
                eo[1] = g_ai2_ihevc_trans_8[2][1] * pi2_src[2 * src_strd]
168
542k
                                + g_ai2_ihevc_trans_8[6][1] * pi2_src[6 * src_strd];
169
542k
                ee[0] = g_ai2_ihevc_trans_8[0][0] * pi2_src[0]
170
542k
                                + g_ai2_ihevc_trans_8[4][0] * pi2_src[4 * src_strd];
171
542k
                ee[1] = g_ai2_ihevc_trans_8[0][1] * pi2_src[0]
172
542k
                                + g_ai2_ihevc_trans_8[4][1] * pi2_src[4 * src_strd];
173
174
                /* Combining e and o terms at each hierarchy levels to calculate the final spatial domain vector */
175
542k
                e[0] = ee[0] + eo[0];
176
542k
                e[3] = ee[0] - eo[0];
177
542k
                e[1] = ee[1] + eo[1];
178
542k
                e[2] = ee[1] - eo[1];
179
2.71M
                for(k = 0; k < 4; k++)
180
2.16M
                {
181
2.16M
                    pi2_tmp[k] =
182
2.16M
                                    CLIP_S16(((e[k] + o[k] + add) >> shift));
183
2.16M
                    pi2_tmp[k + 4] =
184
2.16M
                                    CLIP_S16(((e[3 - k] - o[3 - k] + add) >> shift));
185
2.16M
                }
186
542k
            }
187
686k
            pi2_src++;
188
686k
            pi2_tmp += trans_size;
189
686k
            zero_cols = zero_cols >> 1;
190
686k
        }
191
192
114k
        pi2_tmp = pi2_tmp_orig;
193
194
        /* Inverse Transform 2nd stage */
195
114k
        shift = IT_SHIFT_STAGE_2;
196
114k
        add = 1 << (shift - 1);
197
198
114k
        if((zero_rows_2nd_stage & 0xF0) == 0xF0) /* First 4 rows of output of 1st stage are non-zero */
199
58.1k
        {
200
523k
            for(j = 0; j < trans_size; j++)
201
465k
            {
202
                /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
203
2.32M
                for(k = 0; k < 4; k++)
204
1.86M
                {
205
1.86M
                    o[k] = g_ai2_ihevc_trans_8[1][k] * pi2_tmp[trans_size]
206
1.86M
                                    + g_ai2_ihevc_trans_8[3][k]
207
1.86M
                                                    * pi2_tmp[3 * trans_size];
208
1.86M
                }
209
465k
                eo[0] = g_ai2_ihevc_trans_8[2][0] * pi2_tmp[2 * trans_size];
210
465k
                eo[1] = g_ai2_ihevc_trans_8[2][1] * pi2_tmp[2 * trans_size];
211
465k
                ee[0] = g_ai2_ihevc_trans_8[0][0] * pi2_tmp[0];
212
465k
                ee[1] = g_ai2_ihevc_trans_8[0][1] * pi2_tmp[0];
213
214
                /* Combining e and o terms at each hierarchy levels to calculate the final spatial domain vector */
215
465k
                e[0] = ee[0] + eo[0];
216
465k
                e[3] = ee[0] - eo[0];
217
465k
                e[1] = ee[1] + eo[1];
218
465k
                e[2] = ee[1] - eo[1];
219
2.32M
                for(k = 0; k < 4; k++)
220
1.85M
                {
221
1.85M
                    WORD32 itrans_out;
222
1.85M
                    itrans_out =
223
1.85M
                                    CLIP_S16(((e[k] + o[k] + add) >> shift));
224
1.85M
                    pu1_dst[k * 2] = CLIP_U8((itrans_out + pu1_pred[k * 2]));
225
1.85M
                    itrans_out =
226
1.85M
                                    CLIP_S16(((e[3 - k] - o[3 - k] + add) >> shift));
227
1.85M
                    pu1_dst[(k + 4) * 2] =
228
1.85M
                                    CLIP_U8((itrans_out + pu1_pred[(k + 4) * 2]));
229
1.85M
                }
230
465k
                pi2_tmp++;
231
465k
                pu1_pred += pred_strd;
232
465k
                pu1_dst += dst_strd;
233
465k
            }
234
58.1k
        }
235
56.7k
        else /* All rows of output of 1st stage are non-zero */
236
56.7k
        {
237
510k
            for(j = 0; j < trans_size; j++)
238
454k
            {
239
                /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
240
2.27M
                for(k = 0; k < 4; k++)
241
1.81M
                {
242
1.81M
                    o[k] = g_ai2_ihevc_trans_8[1][k] * pi2_tmp[trans_size]
243
1.81M
                                    + g_ai2_ihevc_trans_8[3][k]
244
1.81M
                                                    * pi2_tmp[3 * trans_size]
245
1.81M
                                    + g_ai2_ihevc_trans_8[5][k]
246
1.81M
                                                    * pi2_tmp[5 * trans_size]
247
1.81M
                                    + g_ai2_ihevc_trans_8[7][k]
248
1.81M
                                                    * pi2_tmp[7 * trans_size];
249
1.81M
                }
250
251
454k
                eo[0] = g_ai2_ihevc_trans_8[2][0] * pi2_tmp[2 * trans_size]
252
454k
                                + g_ai2_ihevc_trans_8[6][0] * pi2_tmp[6 * trans_size];
253
454k
                eo[1] = g_ai2_ihevc_trans_8[2][1] * pi2_tmp[2 * trans_size]
254
454k
                                + g_ai2_ihevc_trans_8[6][1] * pi2_tmp[6 * trans_size];
255
454k
                ee[0] = g_ai2_ihevc_trans_8[0][0] * pi2_tmp[0]
256
454k
                                + g_ai2_ihevc_trans_8[4][0] * pi2_tmp[4 * trans_size];
257
454k
                ee[1] = g_ai2_ihevc_trans_8[0][1] * pi2_tmp[0]
258
454k
                                + g_ai2_ihevc_trans_8[4][1] * pi2_tmp[4 * trans_size];
259
260
                /* Combining e and o terms at each hierarchy levels to calculate the final spatial domain vector */
261
454k
                e[0] = ee[0] + eo[0];
262
454k
                e[3] = ee[0] - eo[0];
263
454k
                e[1] = ee[1] + eo[1];
264
454k
                e[2] = ee[1] - eo[1];
265
2.27M
                for(k = 0; k < 4; k++)
266
1.81M
                {
267
1.81M
                    WORD32 itrans_out;
268
1.81M
                    itrans_out =
269
1.81M
                                    CLIP_S16(((e[k] + o[k] + add) >> shift));
270
1.81M
                    pu1_dst[k * 2] = CLIP_U8((itrans_out + pu1_pred[k * 2]));
271
1.81M
                    itrans_out =
272
1.81M
                                    CLIP_S16(((e[3 - k] - o[3 - k] + add) >> shift));
273
1.81M
                    pu1_dst[(k + 4) * 2] =
274
1.81M
                                    CLIP_U8((itrans_out + pu1_pred[(k + 4) * 2]));
275
1.81M
                }
276
454k
                pi2_tmp++;
277
454k
                pu1_pred += pred_strd;
278
454k
                pu1_dst += dst_strd;
279
454k
            }
280
56.7k
        }
281
        /************************************************************************************************/
282
        /************************************END - IT_RECON_8x8******************************************/
283
        /************************************************************************************************/
284
114k
    }
285
114k
}