Coverage Report

Created: 2026-07-16 06:20

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libavc/encoder/irc_frame_info_collector.c
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Copyright (C) 2015 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 Includes                                                              */
23
/******************************************************************************/
24
25
/* User include files */
26
#include "irc_datatypes.h"
27
#include "irc_cntrl_param.h"
28
#include "irc_frame_info_collector.h"
29
30
void irc_init_frame_info(frame_info_t *frame_info)
31
63.2k
{
32
63.2k
    WORD32 i;
33
34
189k
    for(i = 0; i < MAX_MB_TYPE; i++)
35
126k
    {
36
126k
        frame_info->mb_header_bits[i] = 0;
37
126k
        frame_info->tot_mb_sad[i] = 0;
38
126k
        frame_info->num_mbs[i] = 0;
39
126k
        frame_info->qp_sum[i] = 0;
40
126k
        frame_info->mb_texture_bits[i] = 0;
41
126k
    }
42
43
63.2k
    frame_info->other_header_bits = 0;
44
63.2k
    frame_info->activity_sum = 0;
45
63.2k
    frame_info->intra_mb_cost_sum = 0;
46
63.2k
}
47
48
/******************************************************************************
49
 * GET Functions: Sending back collected information to the rate control module
50
 ******************************************************************************/
51
WORD32 irc_fi_get_total_header_bits(frame_info_t *frame_info)
52
63.2k
{
53
63.2k
    WORD32 total_header_bits = 0, i;
54
55
189k
    for(i = 0; i < MAX_MB_TYPE; i++)
56
126k
    {
57
126k
        total_header_bits += frame_info->mb_header_bits[i];
58
126k
    }
59
63.2k
    total_header_bits += frame_info->other_header_bits;
60
61
63.2k
    return (total_header_bits);
62
63.2k
}
63
64
WORD32 irc_fi_get_total_texture_bits(frame_info_t *frame_info)
65
0
{
66
0
    WORD32 total_texture_bits = 0, i;
67
68
0
    for(i = 0; i < MAX_MB_TYPE; i++)
69
0
    {
70
0
        total_texture_bits += frame_info->mb_texture_bits[i];
71
0
    }
72
73
0
    return (total_texture_bits);
74
0
}
75
76
WORD32 irc_fi_get_total_frame_sad(frame_info_t *frame_info)
77
0
{
78
0
    WORD32 total_sad = 0, i;
79
80
0
    for(i = 0; i < MAX_MB_TYPE; i++)
81
0
    {
82
0
        total_sad += frame_info->tot_mb_sad[i];
83
0
    }
84
85
0
    return (total_sad);
86
0
}
87
88
WORD32 irc_fi_get_average_qp(frame_info_t *frame_info)
89
0
{
90
0
    WORD32 i, total_qp = 0, total_mbs = 0;
91
92
0
    for(i = 0; i < MAX_MB_TYPE; i++)
93
0
    {
94
0
        total_qp += frame_info->qp_sum[i];
95
0
        total_mbs += frame_info->num_mbs[i];
96
0
    }
97
98
0
    if(total_mbs)
99
0
    {
100
0
        return (total_qp / total_mbs);
101
0
    }
102
0
    else
103
0
    {
104
0
        return 0;
105
0
    }
106
0
}
107
108
WORD32 irc_fi_get_avg_mb_header(frame_info_t *frame_info, UWORD8 mb_type)
109
0
{
110
0
    if(frame_info->num_mbs[mb_type])
111
0
    {
112
0
        return (frame_info->mb_header_bits[mb_type]
113
0
                        / frame_info->num_mbs[mb_type]);
114
0
    }
115
0
    else
116
0
    {
117
0
        return 0;
118
0
    }
119
0
}
120
121
WORD32 irc_fi_get_total_mb_texture_bits(frame_info_t *frame_info,
122
                                        UWORD8 mb_type)
123
126k
{
124
126k
    return (frame_info->mb_texture_bits[mb_type]);
125
126k
}
126
127
WORD32 irc_fi_get_total_mb_sad(frame_info_t *frame_info, UWORD8 mb_type)
128
126k
{
129
126k
    return (frame_info->tot_mb_sad[mb_type]);
130
126k
}
131
132
WORD32 irc_fi_get_total_mb_qp(frame_info_t *frame_info, UWORD8 mb_type)
133
126k
{
134
126k
    if(frame_info->num_mbs[mb_type])
135
79.9k
    {
136
79.9k
        return (frame_info->qp_sum[mb_type]);
137
79.9k
    }
138
46.5k
    else
139
46.5k
    {
140
46.5k
        return 0;
141
46.5k
    }
142
126k
}
143
144
WORD32 irc_fi_get_total_mb(frame_info_t *frame_info, UWORD8 mb_type)
145
126k
{
146
126k
    return (frame_info->num_mbs[mb_type]);
147
126k
}
148
149
WORD32 irc_fi_get_num_intra_mb(frame_info_t *frame_info)
150
0
{
151
0
    return (frame_info->num_mbs[MB_TYPE_INTRA]);
152
0
}
153
154
WORD32 irc_fi_get_avg_activity(frame_info_t *frame_info)
155
63.2k
{
156
63.2k
    WORD32 i;
157
63.2k
    WORD32 i4_tot_mbs = 0;
158
159
189k
    for(i = 0; i < MAX_MB_TYPE; i++)
160
126k
    {
161
126k
        i4_tot_mbs += frame_info->num_mbs[i];
162
126k
    }
163
164
63.2k
    if(i4_tot_mbs)
165
63.2k
    {
166
63.2k
        return (frame_info->activity_sum / i4_tot_mbs);
167
63.2k
    }
168
0
    else
169
0
    {
170
0
        return 0;
171
0
    }
172
63.2k
}
173
174
WORD32 irc_fi_get_total_intra_mb_cost(frame_info_t *frame_info)
175
63.2k
{
176
63.2k
    return (frame_info->intra_mb_cost_sum);
177
63.2k
}