Coverage Report

Created: 2025-12-31 07:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libavcodec/cbs_vp8_syntax_template.c
Line
Count
Source
1
/*
2
 * This file is part of FFmpeg.
3
 *
4
 * FFmpeg is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9
 * FFmpeg is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with FFmpeg; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
 */
18
19
static int FUNC(update_segmentation)(CodedBitstreamContext *ctx,
20
                                     CBSVP8BoolCodingRW *bool_coding_rw,
21
                                     VP8RawFrameHeader *current)
22
28.6k
{
23
28.6k
    bc_f(1, update_segment_map);
24
27.4k
    bc_f(1, update_segment_feature_data);
25
26
27.4k
    if (current->update_segment_feature_data) {
27
19.9k
        bc_f(1, segment_feature_mode);
28
        // quantizer
29
95.8k
        for (int i = 0; i < 4; i++) {
30
78.5k
            bc_b(segment_qp_update[i]);
31
78.5k
            if (current->segment_qp_update[i])
32
78.5k
                bc_ss(7, segment_qp[i], 1, i);
33
78.5k
        }
34
        // loop filter
35
80.6k
        for (int i = 0; i < 4; i++) {
36
65.0k
            bc_b(segment_loop_filter_level_update[i]);
37
64.2k
            if (current->segment_loop_filter_level_update[i])
38
64.2k
                bc_ss(6, segment_loop_filter_level[i], 1, i);
39
64.2k
        }
40
17.2k
    }
41
42
23.0k
    if (current->update_segment_map) {
43
41.9k
        for (int i = 0; i < 3; i++) {
44
31.8k
            bc_b(segment_probs_update[i]);
45
31.5k
            if (current->segment_probs_update[i])
46
31.5k
                bc_fs(8, segment_probs[i], 1, i);
47
31.5k
        }
48
10.8k
    }
49
50
22.2k
    return 0;
51
23.0k
}
52
53
static int FUNC(mode_ref_lf_deltas)(CodedBitstreamContext *ctx,
54
                                    CBSVP8BoolCodingRW *bool_coding_rw,
55
                                    VP8RawFrameHeader *current)
56
80.0k
{
57
80.0k
    bc_f(1, mode_ref_lf_delta_enable);
58
79.9k
    if (current->mode_ref_lf_delta_enable) {
59
33.9k
        bc_b(mode_ref_lf_delta_update);
60
33.8k
        if (current->mode_ref_lf_delta_update) {
61
            // ref_lf_deltas
62
86.3k
            for (int i = 0; i < 4; i++) {
63
69.6k
                bc_b(ref_lf_deltas_update[i]);
64
69.6k
                if (current->ref_lf_deltas_update[i])
65
69.6k
                    bc_ss(6, ref_lf_deltas[i], 1, i);
66
69.6k
            }
67
            // mode_lf_deltas
68
81.8k
            for (int i = 0; i < 4; i++) {
69
65.9k
                bc_b(mode_lf_deltas_update[i]);
70
65.6k
                if (current->mode_lf_deltas_update[i])
71
65.6k
                    bc_ss(6, mode_lf_deltas[i], 1, i);
72
65.6k
            }
73
16.6k
        }
74
33.8k
    }
75
76
77.7k
    return 0;
77
79.9k
}
78
79
static int FUNC(quantization_params)(CodedBitstreamContext *ctx,
80
                                     CBSVP8BoolCodingRW *bool_coding_rw,
81
                                     VP8RawFrameHeader *current)
82
77.5k
{
83
77.5k
    bc_f(7, base_qindex);
84
85
76.5k
    bc_b(y1dc_delta_q_present);
86
76.3k
    if (current->y1dc_delta_q_present)
87
76.3k
        bc_s(4, y1dc_delta_q);
88
89
76.0k
    bc_b(y2dc_delta_q_present);
90
76.0k
    if (current->y2dc_delta_q_present)
91
76.0k
        bc_s(4, y2dc_delta_q);
92
93
75.5k
    bc_b(y2ac_delta_q_present);
94
74.8k
    if (current->y2ac_delta_q_present)
95
74.8k
        bc_s(4, y2ac_delta_q);
96
97
73.4k
    bc_b(uvdc_delta_q_present);
98
71.3k
    if (current->uvdc_delta_q_present)
99
71.3k
        bc_s(4, uvdc_delta_q);
100
101
70.9k
    bc_b(uvac_delta_q_present);
102
70.8k
    if (current->uvac_delta_q_present)
103
70.8k
        bc_s(4, uvac_delta_q);
104
105
70.5k
    return 0;
106
70.8k
}
107
108
static int FUNC(update_token_probs)(CodedBitstreamContext *ctx,
109
                                    CBSVP8BoolCodingRW *bool_coding_rw,
110
                                    VP8RawFrameHeader *current)
111
66.7k
{
112
291k
    for (int i = 0; i < 4; ++i) {
113
2.07M
        for (int j = 0; j < 8; ++j) {
114
7.35M
            for (int k = 0; k < 3; ++k) {
115
66.2M
                for (int l = 0; l < 11; ++l) {
116
60.6M
                    bc_b_prob(ff_vp8_token_update_probs[i][j][k][l],
117
60.6M
                              coeff_prob_update[i][j][k][l]);
118
60.6M
                    if (current->coeff_prob_update[i][j][k][l])
119
60.6M
                        bc_fs(8, coeff_prob[i][j][k][l], 4, i, j, k, l);
120
60.6M
                }
121
5.52M
            }
122
1.84M
        }
123
238k
    }
124
125
52.3k
    return 0;
126
66.7k
}
127
128
static int FUNC(update_mv_probs)(CodedBitstreamContext *ctx,
129
                                 CBSVP8BoolCodingRW *bool_coding_rw,
130
                                 VP8RawFrameHeader *current)
131
47.1k
{
132
116k
    for (int i = 0; i < 2; ++i) {
133
1.53M
        for (int j = 0; j < 19; ++j) {
134
1.46M
            bc_b(mv_prob_update[i][j]);
135
1.46M
            if (current->mv_prob_update[i][j])
136
1.46M
                bc_fs(7, mv_prob[i][j], 2, i, j);
137
1.46M
        }
138
84.4k
    }
139
140
31.9k
    return 0;
141
47.1k
}
142
143
static int FUNC(frame_tag)(CodedBitstreamContext *ctx, RWContext *rw,
144
                           VP8RawFrameHeader *current)
145
257k
{
146
257k
    f(1, frame_type);
147
257k
    f(3, profile);
148
257k
    f(1, show_frame);
149
257k
    f(19, first_partition_length_in_bytes);
150
151
241k
    if (current->frame_type == VP8_KEY_FRAME) {
152
151k
        fixed(8, start_code_0, VP8_START_CODE_0);
153
836
        fixed(8, start_code_1, VP8_START_CODE_1);
154
386
        fixed(8, start_code_2, VP8_START_CODE_2);
155
156
383
        f(14, width);
157
383
        f(2, horizontal_scale);
158
383
        f(14, height);
159
382
        f(2, vertical_scale);
160
382
    }
161
162
90.1k
    return 0;
163
241k
}
164
165
static int FUNC(frame_header)(CodedBitstreamContext *ctx,
166
                              CBSVP8BoolCodingRW *bool_coding_rw,
167
                              VP8RawFrameHeader *current)
168
90.1k
{
169
90.1k
    if (current->frame_type == VP8_KEY_FRAME) {
170
382
        bc_f(1, color_space);
171
310
        bc_f(1, clamping_type);
172
310
    }
173
174
90.0k
    bc_f(1, segmentation_enable);
175
89.1k
    if (current->segmentation_enable)
176
28.6k
        CHECK(FUNC(update_segmentation)(ctx, bool_coding_rw, current));
177
178
82.7k
    bc_f(1, loop_filter_type);
179
82.7k
    bc_f(6, loop_filter_level);
180
81.3k
    bc_f(3, loop_filter_sharpness);
181
182
80.0k
    CHECK(FUNC(mode_ref_lf_deltas)(ctx, bool_coding_rw, current));
183
184
77.7k
    bc_f(2, log2_token_partitions);
185
186
77.5k
    CHECK(FUNC(quantization_params)(ctx, bool_coding_rw, current));
187
188
70.5k
    if (current->frame_type != VP8_KEY_FRAME) {
189
70.3k
        bc_f(1, refresh_golden_frame);
190
70.2k
        bc_f(1, refresh_alternate_frame);
191
69.5k
        if (!current->refresh_golden_frame)
192
69.5k
            bc_f(2, copy_buffer_to_golden);
193
69.0k
        if (!current->refresh_alternate_frame)
194
69.0k
            bc_f(2, copy_buffer_to_alternate);
195
68.2k
        bc_f(1, ref_frame_sign_bias_golden);
196
67.8k
        bc_f(1, ref_frame_sign_bias_alternate);
197
67.8k
    }
198
67.5k
    bc_f(1, refresh_entropy_probs);
199
67.3k
    if (current->frame_type != VP8_KEY_FRAME)
200
67.3k
        bc_f(1, refresh_last_frame);
201
202
66.7k
    CHECK(FUNC(update_token_probs)(ctx, bool_coding_rw, current));
203
204
52.3k
    bc_f(1, mb_no_skip_coeff);
205
52.2k
    if (current->mb_no_skip_coeff)
206
52.2k
        bc_f(8, prob_skip_false);
207
208
52.0k
    if (current->frame_type != VP8_KEY_FRAME) {
209
51.9k
        bc_f(8, prob_intra);
210
51.0k
        bc_f(8, prob_last);
211
50.2k
        bc_f(8, prob_golden);
212
213
        // intra_16x16_prob
214
49.7k
        bc_b(intra_16x16_prob_update);
215
49.3k
        if (current->intra_16x16_prob_update)
216
101k
            for (int i = 0; i < 4; i++)
217
81.7k
                bc_fs(8, intra_16x16_prob[i], 1, i);
218
219
        // intra_chroma_prob
220
48.1k
        bc_b(intra_chrome_prob_update);
221
48.0k
        if (current->intra_chrome_prob_update)
222
73.2k
            for (int i = 0; i < 3; i++)
223
55.4k
                bc_fs(8, intra_chrome_prob[i], 1, i);
224
225
47.1k
        CHECK(FUNC(update_mv_probs)(ctx, bool_coding_rw, current));
226
47.1k
    }
227
228
32.0k
    return 0;
229
52.0k
}
230
231
static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
232
                                     VP8RawFrame *current)
233
257k
{
234
257k
    HEADER("Frame");
235
236
257k
    CHECK(FUNC(frame_tag)(ctx, rw, &current->header));
237
238
90.1k
    return 0;
239
257k
}
240
241
static int FUNC(compressed_header)(CodedBitstreamContext *ctx,
242
                                   CBSVP8BoolCodingRW *bool_coding_rw,
243
                                   VP8RawFrame *current)
244
90.1k
{
245
90.1k
    CHECK(FUNC(frame_header)(ctx, bool_coding_rw, &current->header));
246
247
32.0k
    return 0;
248
90.1k
}