Coverage Report

Created: 2025-07-18 07:02

/src/libhevc/common/ihevc_chroma_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_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
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
204k
{
111
204k
    WORD32 i, j;
112
204k
    WORD32 trans_size;
113
114
204k
    trans_size = TRANS_SIZE_4;
115
116
    /* Reconstruction */
117
118
1.02M
    for(i = 0; i < trans_size; i++)
119
819k
    {
120
        /* Checking for Zero Cols */
121
819k
        if((zero_cols & 1) == 1)
122
544k
        {
123
2.72M
            for(j = 0; j < trans_size; j++)
124
2.17M
            {
125
2.17M
                pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd];
126
2.17M
            }
127
544k
        }
128
274k
        else
129
274k
        {
130
1.37M
            for(j = 0; j < trans_size; j++)
131
1.09M
            {
132
1.09M
                pu1_dst[j * dst_strd] =
133
1.09M
                                CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]);
134
1.09M
            }
135
274k
        }
136
819k
        pi2_src++;
137
819k
        pu1_dst += 2;
138
819k
        pu1_pred += 2;
139
819k
        zero_cols = zero_cols >> 1;
140
819k
    }
141
204k
}
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
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
3.05k
{
194
3.05k
    WORD32 i, j;
195
3.05k
    WORD32 trans_size;
196
197
3.05k
    trans_size = TRANS_SIZE_8;
198
199
    /* Reconstruction */
200
201
27.4k
    for(i = 0; i < trans_size; i++)
202
24.4k
    {
203
        /* Checking for Zero Cols */
204
24.4k
        if((zero_cols & 1) == 1)
205
18.7k
        {
206
168k
            for(j = 0; j < trans_size; j++)
207
150k
            {
208
150k
                pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd];
209
150k
            }
210
18.7k
        }
211
5.64k
        else
212
5.64k
        {
213
50.8k
            for(j = 0; j < trans_size; j++)
214
45.1k
            {
215
45.1k
                pu1_dst[j * dst_strd] =
216
45.1k
                                CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]);
217
45.1k
            }
218
5.64k
        }
219
24.4k
        pi2_src++;
220
24.4k
        pu1_dst += 2;
221
24.4k
        pu1_pred += 2;
222
24.4k
        zero_cols = zero_cols >> 1;
223
24.4k
    }
224
3.05k
}
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
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
1.12k
{
277
1.12k
    WORD32 i, j;
278
1.12k
    WORD32 trans_size;
279
280
1.12k
    trans_size = TRANS_SIZE_16;
281
282
    /* Reconstruction */
283
284
19.1k
    for(i = 0; i < trans_size; i++)
285
18.0k
    {
286
        /* Checking for Zero Cols */
287
18.0k
        if((zero_cols & 1) == 1)
288
15.5k
        {
289
264k
            for(j = 0; j < trans_size; j++)
290
249k
            {
291
249k
                pu1_dst[j * dst_strd] = pu1_pred[j * pred_strd];
292
249k
            }
293
15.5k
        }
294
2.45k
        else
295
2.45k
        {
296
41.6k
            for(j = 0; j < trans_size; j++)
297
39.2k
            {
298
39.2k
                pu1_dst[j * dst_strd] =
299
39.2k
                                CLIP_U8(pi2_src[j * src_strd] + pu1_pred[j * pred_strd]);
300
39.2k
            }
301
2.45k
        }
302
18.0k
        pi2_src++;
303
18.0k
        pu1_dst += 2;
304
18.0k
        pu1_pred += 2;
305
18.0k
        zero_cols = zero_cols >> 1;
306
18.0k
    }
307
1.12k
}
308