Coverage Report

Created: 2026-04-01 06:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libhevc/encoder/ihevce_common_utils.h
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Copyright (C) 2018 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
******************************************************************************
23
* @file ihevce_common_utils.h
24
*
25
* @brief
26
*  Contains the declarations and definitions of common utils for encoder
27
*
28
* @author
29
*  ittiam
30
*
31
******************************************************************************
32
*/
33
34
#ifndef _IHEVCE_COMMON_UTILS_H_
35
#define _IHEVCE_COMMON_UTILS_H_
36
37
#include <math.h>
38
#include <limits.h>
39
40
/*****************************************************************************/
41
/* Constant Macros                                                           */
42
/*****************************************************************************/
43
44
/*****************************************************************************/
45
/* Function Macros                                                           */
46
/*****************************************************************************/
47
48
/**
49
******************************************************************************
50
*  @macro  IHEVCE_WT_PRED
51
*  @brief Implements wt pred formula as per spec
52
******************************************************************************
53
*/
54
#define IHEVCE_WT_PRED(p0, p1, w0, w1, rnd, shift)                                                 \
55
8.92M
    (((((WORD32)w0) * ((WORD32)p0) + ((WORD32)w1) * ((WORD32)p1)) >> shift) + rnd)
56
57
#define SORT_PRIMARY_INTTYPE_ARRAY_AND_REORDER_GENERIC_COMPANION_ARRAY(                            \
58
    primary_array, companion_array, array_length, type_companion)                                  \
59
889k
    {                                                                                              \
60
889k
        WORD32 i, j;                                                                               \
61
889k
                                                                                                   \
62
1.12M
        for(i = 0; i < (array_length - 1); i++)                                                    \
63
889k
        {                                                                                          \
64
591k
            for(j = (i + 1); j < array_length; j++)                                                \
65
353k
            {                                                                                      \
66
353k
                if(primary_array[i] > primary_array[j])                                            \
67
353k
                {                                                                                  \
68
167k
                    type_companion t;                                                              \
69
167k
                                                                                                   \
70
167k
                    SWAP(primary_array[i], primary_array[j]);                                      \
71
167k
                                                                                                   \
72
167k
                    t = companion_array[i];                                                        \
73
167k
                    companion_array[i] = companion_array[j];                                       \
74
167k
                    companion_array[j] = t;                                                        \
75
167k
                }                                                                                  \
76
353k
            }                                                                                      \
77
238k
        }                                                                                          \
78
889k
    }
79
80
#define SORT_PRIMARY_INTTYPE_ARRAY_AND_REORDER_INTTYPE_COMPANION_ARRAY(                            \
81
    primary_array, companion_array, array_length)                                                  \
82
    {                                                                                              \
83
        WORD32 i, j;                                                                               \
84
                                                                                                   \
85
        for(i = 0; i < (array_length - 1); i++)                                                    \
86
        {                                                                                          \
87
            for(j = (i + 1); j < array_length; j++)                                                \
88
            {                                                                                      \
89
                if(primary_array[i] > primary_array[j])                                            \
90
                {                                                                                  \
91
                    type_companion t;                                                              \
92
                                                                                                   \
93
                    SWAP(primary_array[i], primary_array[j]);                                      \
94
                    SWAP(companion_array[i], companion_array[j]);                                  \
95
                }                                                                                  \
96
            }                                                                                      \
97
        }                                                                                          \
98
    }
99
100
#define SORT_INTTYPE_ARRAY(primary_array, array_length)                                            \
101
    {                                                                                              \
102
        WORD32 i, j;                                                                               \
103
                                                                                                   \
104
        for(i = 0; i < (array_length - 1); i++)                                                    \
105
        {                                                                                          \
106
            for(j = (i + 1); j < array_length; j++)                                                \
107
            {                                                                                      \
108
                if(primary_array[i] > primary_array[j])                                            \
109
                {                                                                                  \
110
                    SWAP(primary_array[i], primary_array[j]);                                      \
111
                }                                                                                  \
112
            }                                                                                      \
113
        }                                                                                          \
114
    }
115
116
#define SET_BIT(x, bitpos) ((x) | (1 << (bitpos)))
117
118
7.81M
#define CLEAR_BIT(x, bitpos) ((x) & (~(1 << (bitpos))))
119
120
#define CU_TREE_NODE_FILL(ps_node, valid_flag, posx, posy, size, inter_eval_enable)                \
121
679k
    {                                                                                              \
122
679k
        ps_node->is_node_valid = valid_flag;                                                       \
123
679k
        ps_node->u1_cu_size = size;                                                                \
124
679k
        ps_node->u1_intra_eval_enable = 0;                                                         \
125
679k
        ps_node->b3_cu_pos_x = posx;                                                               \
126
679k
        ps_node->b3_cu_pos_y = posy;                                                               \
127
679k
        ps_node->u1_inter_eval_enable = inter_eval_enable;                                         \
128
679k
    }
129
130
/*****************************************************************************/
131
/* Extern Function Declarations                                              */
132
/*****************************************************************************/
133
134
void ihevce_copy_2d(
135
    UWORD8 *pu1_dst,
136
    WORD32 dst_stride,
137
    UWORD8 *pu1_src,
138
    WORD32 src_stride,
139
    WORD32 blk_wd,
140
    WORD32 blk_ht);
141
142
void ihevce_2d_square_copy_luma(
143
    void *p_dst,
144
    WORD32 dst_strd,
145
    void *p_src,
146
    WORD32 src_strd,
147
    WORD32 num_cols_to_copy,
148
    WORD32 unit_size);
149
150
void ihevce_wt_avg_2d(
151
    UWORD8 *pu1_pred0,
152
    UWORD8 *pu1_pred1,
153
    WORD32 pred0_strd,
154
    WORD32 pred1_strd,
155
    WORD32 wd,
156
    WORD32 ht,
157
    UWORD8 *pu1_dst,
158
    WORD32 dst_strd,
159
    WORD32 w0,
160
    WORD32 w1,
161
    WORD32 o0,
162
    WORD32 o1,
163
    WORD32 log_wdc);
164
165
void ihevce_itrans_recon_dc(
166
    UWORD8 *pu1_pred,
167
    WORD32 pred_strd,
168
    UWORD8 *pu1_dst,
169
    WORD32 dst_strd,
170
    WORD32 trans_size,
171
    WORD16 i2_deq_value,
172
    CHROMA_PLANE_ID_T e_chroma_plane);
173
174
WORD32 ihevce_find_num_clusters_of_identical_points_1D(
175
    UWORD8 *pu1_inp_array,
176
    UWORD8 *pu1_out_array,
177
    UWORD8 *pu1_freq_of_out_data_in_inp,
178
    WORD32 i4_num_inp_array_elements);
179
180
void ihevce_scale_mv(mv_t *ps_mv, WORD32 i4_poc_to, WORD32 i4_poc_from, WORD32 i4_curr_poc);
181
182
WORD32 ihevce_compare_pu_mv_t(
183
    pu_mv_t *ps_1, pu_mv_t *ps_2, WORD32 i4_pred_mode_1, WORD32 i4_pred_mode_2);
184
185
void ihevce_set_pred_buf_as_free(UWORD32 *pu4_idx_array, UWORD8 u1_buf_id);
186
187
UWORD8 ihevce_get_free_pred_buf_indices(
188
    UWORD8 *pu1_idx_array, UWORD32 *pu4_bitfield, UWORD8 u1_num_bufs_requested);
189
190
WORD32 ihevce_osal_init(void *pv_hle_ctxt);
191
192
WORD32 ihevce_osal_delete(void *pv_hle_ctxt);
193
194
static INLINE UWORD32 ihevce_num_ones_generic(UWORD32 bitfield)
195
1.83M
{
196
1.83M
    bitfield = bitfield - ((bitfield >> 1) & 0x55555555);
197
1.83M
    bitfield = (bitfield & 0x33333333) + ((bitfield >> 2) & 0x33333333);
198
1.83M
    return (((bitfield + (bitfield >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
199
1.83M
}
Unexecuted instantiation: ihevce_hle_interface.c:ihevce_num_ones_generic
Unexecuted instantiation: ihevce_memory_init.c:ihevce_num_ones_generic
Unexecuted instantiation: hme_refine.c:ihevce_num_ones_generic
Unexecuted instantiation: hme_search_algo.c:ihevce_num_ones_generic
Unexecuted instantiation: hme_subpel.c:ihevce_num_ones_generic
Unexecuted instantiation: hme_utils.c:ihevce_num_ones_generic
Unexecuted instantiation: ihevce_cabac_tu.c:ihevce_num_ones_generic
ihevce_common_utils.c:ihevce_num_ones_generic
Line
Count
Source
195
1.83M
{
196
1.83M
    bitfield = bitfield - ((bitfield >> 1) & 0x55555555);
197
1.83M
    bitfield = (bitfield & 0x33333333) + ((bitfield >> 2) & 0x33333333);
198
1.83M
    return (((bitfield + (bitfield >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
199
1.83M
}
Unexecuted instantiation: ihevce_enc_loop_pass.c:ihevce_num_ones_generic
Unexecuted instantiation: ihevce_enc_loop_utils.c:ihevce_num_ones_generic
Unexecuted instantiation: ihevce_enc_subpel_gen.c:ihevce_num_ones_generic
Unexecuted instantiation: ihevce_frame_process.c:ihevce_num_ones_generic
Unexecuted instantiation: ihevce_mv_pred.c:ihevce_num_ones_generic
Unexecuted instantiation: ihevce_mv_pred_merge.c:ihevce_num_ones_generic
Unexecuted instantiation: ihevce_deblk.c:ihevce_num_ones_generic
Unexecuted instantiation: ihevce_enc_loop_inter_mode_sifter.c:ihevce_num_ones_generic
200
201
static INLINE UWORD32 ihevce_num_ones_popcnt(UWORD32 bitfield)
202
0
{
203
0
    return __builtin_popcount(bitfield);
204
0
}
Unexecuted instantiation: ihevce_hle_interface.c:ihevce_num_ones_popcnt
Unexecuted instantiation: ihevce_memory_init.c:ihevce_num_ones_popcnt
Unexecuted instantiation: hme_refine.c:ihevce_num_ones_popcnt
Unexecuted instantiation: hme_search_algo.c:ihevce_num_ones_popcnt
Unexecuted instantiation: hme_subpel.c:ihevce_num_ones_popcnt
Unexecuted instantiation: hme_utils.c:ihevce_num_ones_popcnt
Unexecuted instantiation: ihevce_cabac_tu.c:ihevce_num_ones_popcnt
Unexecuted instantiation: ihevce_common_utils.c:ihevce_num_ones_popcnt
Unexecuted instantiation: ihevce_enc_loop_pass.c:ihevce_num_ones_popcnt
Unexecuted instantiation: ihevce_enc_loop_utils.c:ihevce_num_ones_popcnt
Unexecuted instantiation: ihevce_enc_subpel_gen.c:ihevce_num_ones_popcnt
Unexecuted instantiation: ihevce_frame_process.c:ihevce_num_ones_popcnt
Unexecuted instantiation: ihevce_mv_pred.c:ihevce_num_ones_popcnt
Unexecuted instantiation: ihevce_mv_pred_merge.c:ihevce_num_ones_popcnt
Unexecuted instantiation: ihevce_deblk.c:ihevce_num_ones_popcnt
Unexecuted instantiation: ihevce_enc_loop_inter_mode_sifter.c:ihevce_num_ones_popcnt
205
206
WORD32 ihevce_compute_area_of_valid_cus_in_ctb(cur_ctb_cu_tree_t *ps_cu_tree);
207
208
void ihevce_cu_tree_init(
209
    cur_ctb_cu_tree_t *ps_cu_tree,
210
    cur_ctb_cu_tree_t *ps_cu_tree_root,
211
    WORD32 *pi4_nodes_created_in_cu_tree,
212
    WORD32 tree_depth,
213
    CU_POS_T e_grandparent_blk_pos,
214
    CU_POS_T e_parent_blk_pos,
215
    CU_POS_T e_cur_blk_pos);
216
217
#endif /* _IHEVCE_COMMON_UTILS_H_ */