Coverage Report

Created: 2026-09-01 06:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libhevc/common/ihevc_chroma_itrans_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_itrans_recon.c
22
 *
23
 * @brief
24
 *  Contains function definitions for 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_4x4()
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_trans_macros.h"
48
49
/* All the functions work one component(U or V) of interleaved data depending upon pointers passed to it */
50
/* Data visualization */
51
/* U V U V U V U V */
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
/* If the pointer points to first byte of above stream (U) , functions will operate on U component */
56
/* If the pointer points to second byte of above stream (V) , functions will operate on V component */
57
58
/**
59
 *******************************************************************************
60
 *
61
 * @brief
62
 *  This function performs Inverse transform  and reconstruction for 4x4
63
 * input block
64
 *
65
 * @par Description:
66
 *  Performs inverse transform and adds the prediction  data and clips output
67
 * to 8 bit
68
 *
69
 * @param[in] pi2_src
70
 *  Input 4x4 coefficients
71
 *
72
 * @param[in] pi2_tmp
73
 *  Temporary 4x4 buffer for storing inverse transform
74
 *  1st stage output
75
 *
76
 * @param[in] pu1_pred
77
 *  Prediction 4x4 block
78
 *
79
 * @param[out] pu1_dst
80
 *  Output 4x4 block
81
 *
82
 * @param[in] src_strd
83
 *  Input stride
84
 *
85
 * @param[in] pred_strd
86
 *  Prediction stride
87
 *
88
 * @param[in] dst_strd
89
 *  Output Stride
90
 *
91
 * @param[in] shift
92
 *  Output shift
93
 *
94
 * @param[in] zero_cols
95
 *  Zero columns in pi2_src
96
 *
97
 * @returns  Void
98
 *
99
 * @remarks
100
 *  None
101
 *
102
 *******************************************************************************
103
 */
104
105
106
void ihevc_chroma_itrans_recon_4x4(WORD16 *pi2_src,
107
                                   WORD16 *pi2_tmp,
108
                                   UWORD8 *pu1_pred,
109
                                   UWORD8 *pu1_dst,
110
                                   WORD32 src_strd,
111
                                   WORD32 pred_strd,
112
                                   WORD32 dst_strd,
113
                                   WORD32 zero_cols,
114
                                   WORD32 zero_rows)
115
460k
{
116
460k
    WORD32 j;
117
460k
    WORD32 e[2], o[2];
118
460k
    WORD32 add;
119
460k
    WORD32 shift;
120
460k
    WORD16 *pi2_tmp_orig;
121
460k
    WORD32 trans_size;
122
460k
    UNUSED(zero_rows);
123
460k
    trans_size = TRANS_SIZE_4;
124
125
460k
    pi2_tmp_orig = pi2_tmp;
126
127
    /* Inverse Transform 1st stage */
128
460k
    shift = IT_SHIFT_STAGE_1;
129
460k
    add = 1 << (shift - 1);
130
131
2.30M
    for(j = 0; j < trans_size; j++)
132
1.84M
    {
133
        /* Checking for Zero Cols */
134
1.84M
        if((zero_cols & 1) == 1)
135
0
        {
136
0
            memset(pi2_tmp, 0, trans_size * sizeof(WORD16));
137
0
        }
138
1.84M
        else
139
1.84M
        {
140
141
            /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
142
1.84M
            o[0] = g_ai2_ihevc_trans_4[1][0] * pi2_src[src_strd]
143
1.84M
                            + g_ai2_ihevc_trans_4[3][0] * pi2_src[3 * src_strd];
144
1.84M
            o[1] = g_ai2_ihevc_trans_4[1][1] * pi2_src[src_strd]
145
1.84M
                            + g_ai2_ihevc_trans_4[3][1] * pi2_src[3 * src_strd];
146
1.84M
            e[0] = g_ai2_ihevc_trans_4[0][0] * pi2_src[0]
147
1.84M
                            + g_ai2_ihevc_trans_4[2][0] * pi2_src[2 * src_strd];
148
1.84M
            e[1] = g_ai2_ihevc_trans_4[0][1] * pi2_src[0]
149
1.84M
                            + g_ai2_ihevc_trans_4[2][1] * pi2_src[2 * src_strd];
150
151
1.84M
            pi2_tmp[0] =
152
1.84M
                            CLIP_S16(((e[0] + o[0] + add) >> shift));
153
1.84M
            pi2_tmp[1] =
154
1.84M
                            CLIP_S16(((e[1] + o[1] + add) >> shift));
155
1.84M
            pi2_tmp[2] =
156
1.84M
                            CLIP_S16(((e[1] - o[1] + add) >> shift));
157
1.84M
            pi2_tmp[3] =
158
1.84M
                            CLIP_S16(((e[0] - o[0] + add) >> shift));
159
160
1.84M
        }
161
1.84M
        pi2_src++;
162
1.84M
        pi2_tmp += trans_size;
163
1.84M
        zero_cols = zero_cols >> 1;
164
1.84M
    }
165
166
460k
    pi2_tmp = pi2_tmp_orig;
167
168
    /* Inverse Transform 2nd stage */
169
460k
    shift = IT_SHIFT_STAGE_2;
170
460k
    add = 1 << (shift - 1);
171
172
2.30M
    for(j = 0; j < trans_size; j++)
173
1.84M
    {
174
1.84M
        WORD32 itrans_out;
175
        /* Utilizing symmetry properties to the maximum to minimize the number of multiplications */
176
1.84M
        o[0] = g_ai2_ihevc_trans_4[1][0] * pi2_tmp[trans_size]
177
1.84M
                        + g_ai2_ihevc_trans_4[3][0] * pi2_tmp[3 * trans_size];
178
1.84M
        o[1] = g_ai2_ihevc_trans_4[1][1] * pi2_tmp[trans_size]
179
1.84M
                        + g_ai2_ihevc_trans_4[3][1] * pi2_tmp[3 * trans_size];
180
1.84M
        e[0] = g_ai2_ihevc_trans_4[0][0] * pi2_tmp[0]
181
1.84M
                        + g_ai2_ihevc_trans_4[2][0] * pi2_tmp[2 * trans_size];
182
1.84M
        e[1] = g_ai2_ihevc_trans_4[0][1] * pi2_tmp[0]
183
1.84M
                        + g_ai2_ihevc_trans_4[2][1] * pi2_tmp[2 * trans_size];
184
185
1.84M
        itrans_out =
186
1.84M
                        CLIP_S16(((e[0] + o[0] + add) >> shift));
187
1.84M
        pu1_dst[0 * 2] = CLIP_U8((itrans_out + pu1_pred[0 * 2]));
188
1.84M
        itrans_out =
189
1.84M
                        CLIP_S16(((e[1] + o[1] + add) >> shift));
190
1.84M
        pu1_dst[1 * 2] = CLIP_U8((itrans_out + pu1_pred[1 * 2]));
191
1.84M
        itrans_out =
192
1.84M
                        CLIP_S16(((e[1] - o[1] + add) >> shift));
193
1.84M
        pu1_dst[2 * 2] = CLIP_U8((itrans_out + pu1_pred[2 * 2]));
194
1.84M
        itrans_out =
195
1.84M
                        CLIP_S16(((e[0] - o[0] + add) >> shift));
196
1.84M
        pu1_dst[3 * 2] = CLIP_U8((itrans_out + pu1_pred[3 * 2]));
197
198
1.84M
        pi2_tmp++;
199
1.84M
        pu1_pred += pred_strd;
200
1.84M
        pu1_dst += dst_strd;
201
202
1.84M
    }
203
460k
}
204