FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/cbs_h265_syntax_template.c
Date: 2021-09-24 20:55:06
Exec Total Coverage
Lines: 832 1223 68.0%
Branches: 863 2080 41.5%

Line Branch Exec 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 7872 static int FUNC(rbsp_trailing_bits)(CodedBitstreamContext *ctx, RWContext *rw)
20 {
21 int err;
22
23
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3936 times.
7872 fixed(1, rbsp_stop_one_bit, 1);
24
2/2
✓ Branch 1 taken 24644 times.
✓ Branch 2 taken 3936 times.
57160 while (byte_alignment(rw) != 0)
25
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24644 times.
49288 fixed(1, rbsp_alignment_zero_bit, 0);
26
27 7872 return 0;
28 }
29
30 31328 static int FUNC(nal_unit_header)(CodedBitstreamContext *ctx, RWContext *rw,
31 H265RawNALUnitHeader *current,
32 int expected_nal_unit_type)
33 {
34 int err;
35
36
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15664 times.
31328 fixed(1, forbidden_zero_bit, 0);
37
38
2/2
✓ Branch 0 taken 3936 times.
✓ Branch 1 taken 11728 times.
31328 if (expected_nal_unit_type >= 0)
39
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3936 times.
7872 u(6, nal_unit_type, expected_nal_unit_type,
40 expected_nal_unit_type);
41 else
42
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 11728 times.
23456 ub(6, nal_unit_type);
43
44
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15664 times.
31328 u(6, nuh_layer_id, 0, 62);
45
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15664 times.
31328 u(3, nuh_temporal_id_plus1, 1, 7);
46
47 31328 return 0;
48 }
49
50 23456 static int FUNC(byte_alignment)(CodedBitstreamContext *ctx, RWContext *rw)
51 {
52 int err;
53
54
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 11728 times.
23456 fixed(1, alignment_bit_equal_to_one, 1);
55
2/2
✓ Branch 1 taken 47440 times.
✓ Branch 2 taken 11728 times.
118336 while (byte_alignment(rw) != 0)
56
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 47440 times.
94880 fixed(1, alignment_bit_equal_to_zero, 0);
57
58 23456 return 0;
59 }
60
61 static int FUNC(extension_data)(CodedBitstreamContext *ctx, RWContext *rw,
62 H265RawExtensionData *current)
63 {
64 int err;
65 size_t k;
66 #ifdef READ
67 GetBitContext start;
68 uint8_t bit;
69 start = *rw;
70 for (k = 0; cbs_h2645_read_more_rbsp_data(rw); k++)
71 skip_bits(rw, 1);
72 current->bit_length = k;
73 if (k > 0) {
74 *rw = start;
75 allocate(current->data, (current->bit_length + 7) / 8);
76 for (k = 0; k < current->bit_length; k++) {
77 xu(1, extension_data, bit, 0, 1, 0);
78 current->data[k / 8] |= bit << (7 - k % 8);
79 }
80 }
81 #else
82 for (k = 0; k < current->bit_length; k++)
83 xu(1, extension_data, current->data[k / 8] >> (7 - k % 8) & 1, 0, 1, 0);
84 #endif
85 return 0;
86 }
87
88 392 static int FUNC(profile_tier_level)(CodedBitstreamContext *ctx, RWContext *rw,
89 H265RawProfileTierLevel *current,
90 int profile_present_flag,
91 int max_num_sub_layers_minus1)
92 {
93 int err, i, j;
94
95
1/2
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
392 if (profile_present_flag) {
96
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
392 u(2, general_profile_space, 0, 0);
97
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
392 flag(general_tier_flag);
98
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
392 ub(5, general_profile_idc);
99
100
2/2
✓ Branch 0 taken 6272 times.
✓ Branch 1 taken 196 times.
12936 for (j = 0; j < 32; j++)
101
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6272 times.
12544 flags(general_profile_compatibility_flag[j], 1, j);
102
103
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
392 flag(general_progressive_source_flag);
104
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
392 flag(general_interlaced_source_flag);
105
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
392 flag(general_non_packed_constraint_flag);
106
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
392 flag(general_frame_only_constraint_flag);
107
108 #define profile_compatible(x) (current->general_profile_idc == (x) || \
109 current->general_profile_compatibility_flag[x])
110
4/8
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 196 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 196 times.
✗ Branch 7 not taken.
392 if (profile_compatible(4) || profile_compatible(5) ||
111
4/8
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 196 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 196 times.
✗ Branch 7 not taken.
392 profile_compatible(6) || profile_compatible(7) ||
112
4/8
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 196 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 196 times.
✗ Branch 7 not taken.
392 profile_compatible(8) || profile_compatible(9) ||
113
4/8
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 196 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 196 times.
392 profile_compatible(10) || profile_compatible(11)) {
114 flag(general_max_12bit_constraint_flag);
115 flag(general_max_10bit_constraint_flag);
116 flag(general_max_8bit_constraint_flag);
117 flag(general_max_422chroma_constraint_flag);
118 flag(general_max_420chroma_constraint_flag);
119 flag(general_max_monochrome_constraint_flag);
120 flag(general_intra_constraint_flag);
121 flag(general_one_picture_only_constraint_flag);
122 flag(general_lower_bit_rate_constraint_flag);
123
124 if (profile_compatible(5) || profile_compatible(9) ||
125 profile_compatible(10) || profile_compatible(11)) {
126 flag(general_max_14bit_constraint_flag);
127 fixed(24, general_reserved_zero_33bits, 0);
128 fixed( 9, general_reserved_zero_33bits, 0);
129 } else {
130 fixed(24, general_reserved_zero_34bits, 0);
131 fixed(10, general_reserved_zero_34bits, 0);
132 }
133
3/4
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 156 times.
✓ Branch 3 taken 40 times.
392 } else if (profile_compatible(2)) {
134
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 156 times.
312 fixed(7, general_reserved_zero_7bits, 0);
135
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 156 times.
312 flag(general_one_picture_only_constraint_flag);
136
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 156 times.
312 fixed(24, general_reserved_zero_35bits, 0);
137
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 156 times.
312 fixed(11, general_reserved_zero_35bits, 0);
138 } else {
139
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
80 fixed(24, general_reserved_zero_43bits, 0);
140
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
80 fixed(19, general_reserved_zero_43bits, 0);
141 }
142
143
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
392 if (profile_compatible(1) || profile_compatible(2) ||
144 profile_compatible(3) || profile_compatible(4) ||
145 profile_compatible(5) || profile_compatible(9) ||
146 profile_compatible(11)) {
147
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
392 flag(general_inbld_flag);
148 } else {
149 fixed(1, general_reserved_zero_bit, 0);
150 }
151 #undef profile_compatible
152 }
153
154
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
392 ub(8, general_level_idc);
155
156
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 196 times.
584 for (i = 0; i < max_num_sub_layers_minus1; i++) {
157
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 flags(sub_layer_profile_present_flag[i], 1, i);
158
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 flags(sub_layer_level_present_flag[i], 1, i);
159 }
160
161
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 148 times.
392 if (max_num_sub_layers_minus1 > 0) {
162
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 48 times.
672 for (i = max_num_sub_layers_minus1; i < 8; i++)
163
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 288 times.
576 fixed(2, reserved_zero_2bits, 0);
164 }
165
166
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 196 times.
584 for (i = 0; i < max_num_sub_layers_minus1; i++) {
167
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 80 times.
192 if (current->sub_layer_profile_present_flag[i]) {
168
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 us(2, sub_layer_profile_space[i], 0, 0, 1, i);
169
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 flags(sub_layer_tier_flag[i], 1, i);
170
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 ubs(5, sub_layer_profile_idc[i], 1, i);
171
172
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 16 times.
1056 for (j = 0; j < 32; j++)
173
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
1024 flags(sub_layer_profile_compatibility_flag[i][j], 2, i, j);
174
175
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 flags(sub_layer_progressive_source_flag[i], 1, i);
176
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 flags(sub_layer_interlaced_source_flag[i], 1, i);
177
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 flags(sub_layer_non_packed_constraint_flag[i], 1, i);
178
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 flags(sub_layer_frame_only_constraint_flag[i], 1, i);
179
180 #define profile_compatible(x) (current->sub_layer_profile_idc[i] == (x) || \
181 current->sub_layer_profile_compatibility_flag[i][x])
182
4/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
32 if (profile_compatible(4) || profile_compatible(5) ||
183
4/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
32 profile_compatible(6) || profile_compatible(7) ||
184
4/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
32 profile_compatible(8) || profile_compatible(9) ||
185
4/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 16 times.
32 profile_compatible(10) || profile_compatible(11)) {
186 flags(sub_layer_max_12bit_constraint_flag[i], 1, i);
187 flags(sub_layer_max_10bit_constraint_flag[i], 1, i);
188 flags(sub_layer_max_8bit_constraint_flag[i], 1, i);
189 flags(sub_layer_max_422chroma_constraint_flag[i], 1, i);
190 flags(sub_layer_max_420chroma_constraint_flag[i], 1, i);
191 flags(sub_layer_max_monochrome_constraint_flag[i], 1, i);
192 flags(sub_layer_intra_constraint_flag[i], 1, i);
193 flags(sub_layer_one_picture_only_constraint_flag[i], 1, i);
194 flags(sub_layer_lower_bit_rate_constraint_flag[i], 1, i);
195
196 if (profile_compatible(5) || profile_compatible(9) ||
197 profile_compatible(10) || profile_compatible(11)) {
198 flags(sub_layer_max_14bit_constraint_flag[i], 1, i);
199 fixed(24, sub_layer_reserved_zero_33bits, 0);
200 fixed( 9, sub_layer_reserved_zero_33bits, 0);
201 } else {
202 fixed(24, sub_layer_reserved_zero_34bits, 0);
203 fixed(10, sub_layer_reserved_zero_34bits, 0);
204 }
205
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
32 } else if (profile_compatible(2)) {
206 fixed(7, sub_layer_reserved_zero_7bits, 0);
207 flags(sub_layer_one_picture_only_constraint_flag[i], 1, i);
208 fixed(24, sub_layer_reserved_zero_43bits, 0);
209 fixed(11, sub_layer_reserved_zero_43bits, 0);
210 } else {
211
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 fixed(24, sub_layer_reserved_zero_43bits, 0);
212
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 fixed(19, sub_layer_reserved_zero_43bits, 0);
213 }
214
215
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32 if (profile_compatible(1) || profile_compatible(2) ||
216 profile_compatible(3) || profile_compatible(4) ||
217 profile_compatible(5) || profile_compatible(9) ||
218 profile_compatible(11)) {
219
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 flags(sub_layer_inbld_flag[i], 1, i);
220 } else {
221 fixed(1, sub_layer_reserved_zero_bit, 0);
222 }
223 #undef profile_compatible
224 }
225
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 80 times.
192 if (current->sub_layer_level_present_flag[i])
226
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 ubs(8, sub_layer_level_idc[i], 1, i);
227 }
228
229 392 return 0;
230 }
231
232 32 static int FUNC(sub_layer_hrd_parameters)(CodedBitstreamContext *ctx, RWContext *rw,
233 H265RawHRDParameters *hrd,
234 int nal, int sub_layer_id)
235 {
236 H265RawSubLayerHRDParameters *current;
237 int err, i;
238
239
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
32 if (nal)
240 16 current = &hrd->nal_sub_layer_hrd_parameters[sub_layer_id];
241 else
242 16 current = &hrd->vcl_sub_layer_hrd_parameters[sub_layer_id];
243
244
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
64 for (i = 0; i <= hrd->cpb_cnt_minus1[sub_layer_id]; i++) {
245
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 ues(bit_rate_value_minus1[i], 0, UINT32_MAX - 1, 1, i);
246
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 ues(cpb_size_value_minus1[i], 0, UINT32_MAX - 1, 1, i);
247
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
32 if (hrd->sub_pic_hrd_params_present_flag) {
248
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 ues(cpb_size_du_value_minus1[i], 0, UINT32_MAX - 1, 1, i);
249
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 ues(bit_rate_du_value_minus1[i], 0, UINT32_MAX - 1, 1, i);
250 }
251
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
32 flags(cbr_flag[i], 1, i);
252 }
253
254 32 return 0;
255 }
256
257 16 static int FUNC(hrd_parameters)(CodedBitstreamContext *ctx, RWContext *rw,
258 H265RawHRDParameters *current, int common_inf_present_flag,
259 int max_num_sub_layers_minus1)
260 {
261 int err, i;
262
263
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
16 if (common_inf_present_flag) {
264
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 flag(nal_hrd_parameters_present_flag);
265
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 flag(vcl_hrd_parameters_present_flag);
266
267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
16 if (current->nal_hrd_parameters_present_flag ||
268 current->vcl_hrd_parameters_present_flag) {
269
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 flag(sub_pic_hrd_params_present_flag);
270
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
16 if (current->sub_pic_hrd_params_present_flag) {
271
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ub(8, tick_divisor_minus2);
272
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ub(5, du_cpb_removal_delay_increment_length_minus1);
273
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 flag(sub_pic_cpb_params_in_pic_timing_sei_flag);
274
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ub(5, dpb_output_delay_du_length_minus1);
275 }
276
277
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 ub(4, bit_rate_scale);
278
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 ub(4, cpb_size_scale);
279
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
16 if (current->sub_pic_hrd_params_present_flag)
280
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ub(4, cpb_size_du_scale);
281
282
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 ub(5, initial_cpb_removal_delay_length_minus1);
283
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 ub(5, au_cpb_removal_delay_length_minus1);
284
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 ub(5, dpb_output_delay_length_minus1);
285 } else {
286 infer(sub_pic_hrd_params_present_flag, 0);
287
288 infer(initial_cpb_removal_delay_length_minus1, 23);
289 infer(au_cpb_removal_delay_length_minus1, 23);
290 infer(dpb_output_delay_length_minus1, 23);
291 }
292 }
293
294
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
32 for (i = 0; i <= max_num_sub_layers_minus1; i++) {
295
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 flags(fixed_pic_rate_general_flag[i], 1, i);
296
297
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
16 if (!current->fixed_pic_rate_general_flag[i])
298
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 flags(fixed_pic_rate_within_cvs_flag[i], 1, i);
299 else
300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
8 infer(fixed_pic_rate_within_cvs_flag[i], 1);
301
302
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
16 if (current->fixed_pic_rate_within_cvs_flag[i]) {
303
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ues(elemental_duration_in_tc_minus1[i], 0, 2047, 1, i);
304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
8 infer(low_delay_hrd_flag[i], 0);
305 } else
306
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 flags(low_delay_hrd_flag[i], 1, i);
307
308
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
16 if (!current->low_delay_hrd_flag[i])
309
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 ues(cpb_cnt_minus1[i], 0, 31, 1, i);
310 else
311 infer(cpb_cnt_minus1[i], 0);
312
313
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
16 if (current->nal_hrd_parameters_present_flag)
314
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 CHECK(FUNC(sub_layer_hrd_parameters)(ctx, rw, current, 0, i));
315
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
16 if (current->vcl_hrd_parameters_present_flag)
316
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 CHECK(FUNC(sub_layer_hrd_parameters)(ctx, rw, current, 1, i));
317 }
318
319 16 return 0;
320 }
321
322 72 static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, RWContext *rw,
323 H265RawVUI *current, const H265RawSPS *sps)
324 {
325 int err;
326
327
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
72 flag(aspect_ratio_info_present_flag);
328
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 24 times.
72 if (current->aspect_ratio_info_present_flag) {
329
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
24 ub(8, aspect_ratio_idc);
330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
24 if (current->aspect_ratio_idc == 255) {
331 ub(16, sar_width);
332 ub(16, sar_height);
333 }
334 } else {
335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
48 infer(aspect_ratio_idc, 0);
336 }
337
338
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
72 flag(overscan_info_present_flag);
339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
72 if (current->overscan_info_present_flag)
340 flag(overscan_appropriate_flag);
341
342
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
72 flag(video_signal_type_present_flag);
343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
72 if (current->video_signal_type_present_flag) {
344 ub(3, video_format);
345 flag(video_full_range_flag);
346 flag(colour_description_present_flag);
347 if (current->colour_description_present_flag) {
348 ub(8, colour_primaries);
349 ub(8, transfer_characteristics);
350 ub(8, matrix_coefficients);
351 } else {
352 infer(colour_primaries, 2);
353 infer(transfer_characteristics, 2);
354 infer(matrix_coefficients, 2);
355 }
356 } else {
357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
72 infer(video_format, 5);
358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
72 infer(video_full_range_flag, 0);
359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
72 infer(colour_primaries, 2);
360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
72 infer(transfer_characteristics, 2);
361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
72 infer(matrix_coefficients, 2);
362 }
363
364
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
72 flag(chroma_loc_info_present_flag);
365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
72 if (current->chroma_loc_info_present_flag) {
366 ue(chroma_sample_loc_type_top_field, 0, 5);
367 ue(chroma_sample_loc_type_bottom_field, 0, 5);
368 } else {
369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
72 infer(chroma_sample_loc_type_top_field, 0);
370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
72 infer(chroma_sample_loc_type_bottom_field, 0);
371 }
372
373
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
72 flag(neutral_chroma_indication_flag);
374
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
72 flag(field_seq_flag);
375
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
72 flag(frame_field_info_present_flag);
376
377
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
72 flag(default_display_window_flag);
378
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 24 times.
72 if (current->default_display_window_flag) {
379
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
24 ue(def_disp_win_left_offset, 0, 16384);
380
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
24 ue(def_disp_win_right_offset, 0, 16384);
381
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
24 ue(def_disp_win_top_offset, 0, 16384);
382
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
24 ue(def_disp_win_bottom_offset, 0, 16384);
383 }
384
385
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
72 flag(vui_timing_info_present_flag);
386
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 28 times.
72 if (current->vui_timing_info_present_flag) {
387
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 u(32, vui_num_units_in_tick, 1, UINT32_MAX);
388
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 u(32, vui_time_scale, 1, UINT32_MAX);
389
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 flag(vui_poc_proportional_to_timing_flag);
390
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
16 if (current->vui_poc_proportional_to_timing_flag)
391
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ue(vui_num_ticks_poc_diff_one_minus1, 0, UINT32_MAX - 1);
392
393
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 flag(vui_hrd_parameters_present_flag);
394
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
16 if (current->vui_hrd_parameters_present_flag) {
395
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 CHECK(FUNC(hrd_parameters)(ctx, rw, &current->hrd_parameters,
396 1, sps->sps_max_sub_layers_minus1));
397 }
398 }
399
400
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
72 flag(bitstream_restriction_flag);
401
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
72 if (current->bitstream_restriction_flag) {
402
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
48 flag(tiles_fixed_structure_flag);
403
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
48 flag(motion_vectors_over_pic_boundaries_flag);
404
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
48 flag(restricted_ref_pic_lists_flag);
405
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
48 ue(min_spatial_segmentation_idc, 0, 4095);
406
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
48 ue(max_bytes_per_pic_denom, 0, 16);
407
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
48 ue(max_bits_per_min_cu_denom, 0, 16);
408
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
48 ue(log2_max_mv_length_horizontal, 0, 16);
409
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
48 ue(log2_max_mv_length_vertical, 0, 16);
410 } else {
411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
24 infer(tiles_fixed_structure_flag, 0);
412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
24 infer(motion_vectors_over_pic_boundaries_flag, 1);
413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
24 infer(min_spatial_segmentation_idc, 0);
414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
24 infer(max_bytes_per_pic_denom, 2);
415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
24 infer(max_bits_per_min_cu_denom, 1);
416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
24 infer(log2_max_mv_length_horizontal, 15);
417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
24 infer(log2_max_mv_length_vertical, 15);
418 }
419
420 72 return 0;
421 }
422
423 192 static int FUNC(vps)(CodedBitstreamContext *ctx, RWContext *rw,
424 H265RawVPS *current)
425 {
426 int err, i, j;
427
428 192 HEADER("Video Parameter Set");
429
430
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header, HEVC_NAL_VPS));
431
432
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 ub(4, vps_video_parameter_set_id);
433
434
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 flag(vps_base_layer_internal_flag);
435
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 flag(vps_base_layer_available_flag);
436
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 u(6, vps_max_layers_minus1, 0, HEVC_MAX_LAYERS - 1);
437
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 u(3, vps_max_sub_layers_minus1, 0, HEVC_MAX_SUB_LAYERS - 1);
438
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 flag(vps_temporal_id_nesting_flag);
439
440
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 24 times.
192 if (current->vps_max_sub_layers_minus1 == 0 &&
441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
144 current->vps_temporal_id_nesting_flag != 1) {
442 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
443 "vps_temporal_id_nesting_flag must be 1 if "
444 "vps_max_sub_layers_minus1 is 0.\n");
445 return AVERROR_INVALIDDATA;
446 }
447
448
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 fixed(16, vps_reserved_0xffff_16bits, 0xffff);
449
450
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 CHECK(FUNC(profile_tier_level)(ctx, rw, &current->profile_tier_level,
451 1, current->vps_max_sub_layers_minus1));
452
453
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 flag(vps_sub_layer_ordering_info_present_flag);
454 192 for (i = (current->vps_sub_layer_ordering_info_present_flag ?
455
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 72 times.
192 0 : current->vps_max_sub_layers_minus1);
456
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 96 times.
400 i <= current->vps_max_sub_layers_minus1; i++) {
457
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
208 ues(vps_max_dec_pic_buffering_minus1[i],
458 0, HEVC_MAX_DPB_SIZE - 1, 1, i);
459
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
208 ues(vps_max_num_reorder_pics[i],
460 0, current->vps_max_dec_pic_buffering_minus1[i], 1, i);
461
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
208 ues(vps_max_latency_increase_plus1[i],
462 0, UINT32_MAX - 1, 1, i);
463 }
464
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 72 times.
192 if (!current->vps_sub_layer_ordering_info_present_flag) {
465
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 24 times.
128 for (i = 0; i < current->vps_max_sub_layers_minus1; i++) {
466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
80 infer(vps_max_dec_pic_buffering_minus1[i],
467 current->vps_max_dec_pic_buffering_minus1[current->vps_max_sub_layers_minus1]);
468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
80 infer(vps_max_num_reorder_pics[i],
469 current->vps_max_num_reorder_pics[current->vps_max_sub_layers_minus1]);
470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
80 infer(vps_max_latency_increase_plus1[i],
471 current->vps_max_latency_increase_plus1[current->vps_max_sub_layers_minus1]);
472 }
473 }
474
475
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 u(6, vps_max_layer_id, 0, HEVC_MAX_LAYERS - 1);
476
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 ue(vps_num_layer_sets_minus1, 0, HEVC_MAX_LAYER_SETS - 1);
477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
192 for (i = 1; i <= current->vps_num_layer_sets_minus1; i++) {
478 for (j = 0; j <= current->vps_max_layer_id; j++)
479 flags(layer_id_included_flag[i][j], 2, i, j);
480 }
481
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 96 times.
384 for (j = 0; j <= current->vps_max_layer_id; j++)
482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
192 infer(layer_id_included_flag[0][j], j == 0);
483
484
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 flag(vps_timing_info_present_flag);
485
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 92 times.
192 if (current->vps_timing_info_present_flag) {
486
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 u(32, vps_num_units_in_tick, 1, UINT32_MAX);
487
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 u(32, vps_time_scale, 1, UINT32_MAX);
488
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 flag(vps_poc_proportional_to_timing_flag);
489
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 if (current->vps_poc_proportional_to_timing_flag)
490
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ue(vps_num_ticks_poc_diff_one_minus1, 0, UINT32_MAX - 1);
491
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ue(vps_num_hrd_parameters, 0, current->vps_num_layer_sets_minus1 + 1);
492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
8 for (i = 0; i < current->vps_num_hrd_parameters; i++) {
493 ues(hrd_layer_set_idx[i],
494 current->vps_base_layer_internal_flag ? 0 : 1,
495 current->vps_num_layer_sets_minus1, 1, i);
496 if (i > 0)
497 flags(cprms_present_flag[i], 1, i);
498 else
499 infer(cprms_present_flag[0], 1);
500
501 CHECK(FUNC(hrd_parameters)(ctx, rw, &current->hrd_parameters[i],
502 current->cprms_present_flag[i],
503 current->vps_max_sub_layers_minus1));
504 }
505 }
506
507
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 flag(vps_extension_flag);
508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
192 if (current->vps_extension_flag)
509 CHECK(FUNC(extension_data)(ctx, rw, &current->extension_data));
510
511
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
192 CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
512
513 192 return 0;
514 }
515
516 9116 static int FUNC(st_ref_pic_set)(CodedBitstreamContext *ctx, RWContext *rw,
517 H265RawSTRefPicSet *current, int st_rps_idx,
518 const H265RawSPS *sps)
519 {
520 int err, i, j;
521
522
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 148 times.
9116 if (st_rps_idx != 0)
523
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4410 times.
8820 flag(inter_ref_pic_set_prediction_flag);
524 else
525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
296 infer(inter_ref_pic_set_prediction_flag, 0);
526
527
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 3534 times.
9116 if (current->inter_ref_pic_set_prediction_flag) {
528 unsigned int ref_rps_idx, num_delta_pocs, num_ref_pics;
529 const H265RawSTRefPicSet *ref;
530 int delta_rps, d_poc;
531 int ref_delta_poc_s0[HEVC_MAX_REFS], ref_delta_poc_s1[HEVC_MAX_REFS];
532 int delta_poc_s0[HEVC_MAX_REFS], delta_poc_s1[HEVC_MAX_REFS];
533 uint8_t used_by_curr_pic_s0[HEVC_MAX_REFS],
534 used_by_curr_pic_s1[HEVC_MAX_REFS];
535
536
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 652 times.
2048 if (st_rps_idx == sps->num_short_term_ref_pic_sets)
537
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 372 times.
744 ue(delta_idx_minus1, 0, st_rps_idx - 1);
538 else
539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
1304 infer(delta_idx_minus1, 0);
540
541 2048 ref_rps_idx = st_rps_idx - (current->delta_idx_minus1 + 1);
542 2048 ref = &sps->st_ref_pic_set[ref_rps_idx];
543 2048 num_delta_pocs = ref->num_negative_pics + ref->num_positive_pics;
544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
2048 av_assert0(num_delta_pocs < HEVC_MAX_DPB_SIZE);
545
546
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1024 times.
2048 flag(delta_rps_sign);
547
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1024 times.
2048 ue(abs_delta_rps_minus1, 0, INT16_MAX);
548 2048 delta_rps = (1 - 2 * current->delta_rps_sign) *
549 2048 (current->abs_delta_rps_minus1 + 1);
550
551 2048 num_ref_pics = 0;
552
2/2
✓ Branch 0 taken 4484 times.
✓ Branch 1 taken 1024 times.
11016 for (j = 0; j <= num_delta_pocs; j++) {
553
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4484 times.
8968 flags(used_by_curr_pic_flag[j], 1, j);
554
2/2
✓ Branch 0 taken 1022 times.
✓ Branch 1 taken 3462 times.
8968 if (!current->used_by_curr_pic_flag[j])
555
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1022 times.
2044 flags(use_delta_flag[j], 1, j);
556 else
557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1731 times.
6924 infer(use_delta_flag[j], 1);
558
2/2
✓ Branch 0 taken 3462 times.
✓ Branch 1 taken 1022 times.
8968 if (current->use_delta_flag[j])
559 6924 ++num_ref_pics;
560 }
561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
2048 if (num_ref_pics >= HEVC_MAX_DPB_SIZE) {
562 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
563 "short-term ref pic set %d "
564 "contains too many pictures.\n", st_rps_idx);
565 return AVERROR_INVALIDDATA;
566 }
567
568 // Since the stored form of an RPS here is actually the delta-step
569 // form used when inter_ref_pic_set_prediction_flag is not set, we
570 // need to reconstruct that here in order to be able to refer to
571 // the RPS later (which is required for parsing, because we don't
572 // even know what syntax elements appear without it). Therefore,
573 // this code takes the delta-step form of the reference set, turns
574 // it into the delta-array form, applies the prediction process of
575 // 7.4.8, converts the result back to the delta-step form, and
576 // stores that as the current set for future use. Note that the
577 // inferences here mean that writers using prediction will need
578 // to fill in the delta-step values correctly as well - since the
579 // whole RPS prediction process is somewhat overly sophisticated,
580 // this hopefully forms a useful check for them to ensure their
581 // predicted form actually matches what was intended rather than
582 // an onerous additional requirement.
583
584 2048 d_poc = 0;
585
2/2
✓ Branch 0 taken 2338 times.
✓ Branch 1 taken 1024 times.
6724 for (i = 0; i < ref->num_negative_pics; i++) {
586 4676 d_poc -= ref->delta_poc_s0_minus1[i] + 1;
587 4676 ref_delta_poc_s0[i] = d_poc;
588 }
589 2048 d_poc = 0;
590
2/2
✓ Branch 0 taken 1122 times.
✓ Branch 1 taken 1024 times.
4292 for (i = 0; i < ref->num_positive_pics; i++) {
591 2244 d_poc += ref->delta_poc_s1_minus1[i] + 1;
592 2244 ref_delta_poc_s1[i] = d_poc;
593 }
594
595 2048 i = 0;
596
2/2
✓ Branch 0 taken 1122 times.
✓ Branch 1 taken 1024 times.
4292 for (j = ref->num_positive_pics - 1; j >= 0; j--) {
597 2244 d_poc = ref_delta_poc_s1[j] + delta_rps;
598
3/4
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 834 times.
✓ Branch 2 taken 288 times.
✗ Branch 3 not taken.
2244 if (d_poc < 0 && current->use_delta_flag[ref->num_negative_pics + j]) {
599 576 delta_poc_s0[i] = d_poc;
600 576 used_by_curr_pic_s0[i++] =
601 576 current->used_by_curr_pic_flag[ref->num_negative_pics + j];
602 }
603 }
604
4/4
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 236 times.
✓ Branch 3 taken 308 times.
2048 if (delta_rps < 0 && current->use_delta_flag[num_delta_pocs]) {
605 472 delta_poc_s0[i] = delta_rps;
606 472 used_by_curr_pic_s0[i++] =
607 472 current->used_by_curr_pic_flag[num_delta_pocs];
608 }
609
2/2
✓ Branch 0 taken 2338 times.
✓ Branch 1 taken 1024 times.
6724 for (j = 0; j < ref->num_negative_pics; j++) {
610 4676 d_poc = ref_delta_poc_s0[j] + delta_rps;
611
3/4
✓ Branch 0 taken 2338 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 638 times.
4676 if (d_poc < 0 && current->use_delta_flag[j]) {
612 3400 delta_poc_s0[i] = d_poc;
613 3400 used_by_curr_pic_s0[i++] = current->used_by_curr_pic_flag[j];
614 }
615 }
616
617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
2048 infer(num_negative_pics, i);
618
2/2
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 1024 times.
6496 for (i = 0; i < current->num_negative_pics; i++) {
619
3/6
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1112 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4448 infer(delta_poc_s0_minus1[i],
620 -(delta_poc_s0[i] - (i == 0 ? 0 : delta_poc_s0[i - 1])) - 1);
621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1112 times.
4448 infer(used_by_curr_pic_s0_flag[i], used_by_curr_pic_s0[i]);
622 }
623
624 2048 i = 0;
625
2/2
✓ Branch 0 taken 2338 times.
✓ Branch 1 taken 1024 times.
6724 for (j = ref->num_negative_pics - 1; j >= 0; j--) {
626 4676 d_poc = ref_delta_poc_s0[j] + delta_rps;
627
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2338 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4676 if (d_poc > 0 && current->use_delta_flag[j]) {
628 delta_poc_s1[i] = d_poc;
629 used_by_curr_pic_s1[i++] = current->used_by_curr_pic_flag[j];
630 }
631 }
632
4/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 544 times.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 14 times.
2048 if (delta_rps > 0 && current->use_delta_flag[num_delta_pocs]) {
633 932 delta_poc_s1[i] = delta_rps;
634 932 used_by_curr_pic_s1[i++] =
635 932 current->used_by_curr_pic_flag[num_delta_pocs];
636 }
637
2/2
✓ Branch 0 taken 1122 times.
✓ Branch 1 taken 1024 times.
4292 for (j = 0; j < ref->num_positive_pics; j++) {
638 2244 d_poc = ref_delta_poc_s1[j] + delta_rps;
639
4/4
✓ Branch 0 taken 834 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 772 times.
✓ Branch 3 taken 62 times.
2244 if (d_poc > 0 && current->use_delta_flag[ref->num_negative_pics + j]) {
640 1544 delta_poc_s1[i] = d_poc;
641 1544 used_by_curr_pic_s1[i++] =
642 1544 current->used_by_curr_pic_flag[ref->num_negative_pics + j];
643 }
644 }
645
646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
2048 infer(num_positive_pics, i);
647
2/2
✓ Branch 0 taken 1238 times.
✓ Branch 1 taken 1024 times.
4524 for (i = 0; i < current->num_positive_pics; i++) {
648
3/6
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 740 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2476 infer(delta_poc_s1_minus1[i],
649 delta_poc_s1[i] - (i == 0 ? 0 : delta_poc_s1[i - 1]) - 1);
650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
2476 infer(used_by_curr_pic_s1_flag[i], used_by_curr_pic_s1[i]);
651 }
652
653 } else {
654
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3534 times.
7068 ue(num_negative_pics, 0, 15);
655
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3534 times.
7068 ue(num_positive_pics, 0, 15 - current->num_negative_pics);
656
657
2/2
✓ Branch 0 taken 9712 times.
✓ Branch 1 taken 3534 times.
26492 for (i = 0; i < current->num_negative_pics; i++) {
658
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9712 times.
19424 ues(delta_poc_s0_minus1[i], 0, INT16_MAX, 1, i);
659
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9712 times.
19424 flags(used_by_curr_pic_s0_flag[i], 1, i);
660 }
661
662
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 3534 times.
8688 for (i = 0; i < current->num_positive_pics; i++) {
663
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 810 times.
1620 ues(delta_poc_s1_minus1[i], 0, INT16_MAX, 1, i);
664
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 810 times.
1620 flags(used_by_curr_pic_s1_flag[i], 1, i);
665 }
666 }
667
668 9116 return 0;
669 }
670
671 352 static int FUNC(scaling_list_data)(CodedBitstreamContext *ctx, RWContext *rw,
672 H265RawScalingList *current)
673 {
674 int sizeId, matrixId;
675 int err, n, i;
676
677
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 176 times.
1760 for (sizeId = 0; sizeId < 4; sizeId++) {
678
4/4
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 3168 times.
✓ Branch 2 taken 3520 times.
✓ Branch 3 taken 704 times.
8448 for (matrixId = 0; matrixId < 6; matrixId += (sizeId == 3 ? 3 : 1)) {
679
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3520 times.
7040 flags(scaling_list_pred_mode_flag[sizeId][matrixId],
680 2, sizeId, matrixId);
681
2/2
✓ Branch 0 taken 1564 times.
✓ Branch 1 taken 1956 times.
7040 if (!current->scaling_list_pred_mode_flag[sizeId][matrixId]) {
682
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1556 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1564 times.
3128 ues(scaling_list_pred_matrix_id_delta[sizeId][matrixId],
683 0, sizeId == 3 ? matrixId / 3 : matrixId,
684 2, sizeId, matrixId);
685 } else {
686 3912 n = FFMIN(64, 1 << (4 + (sizeId << 1)));
687
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 768 times.
3912 if (sizeId > 1) {
688
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1188 times.
2376 ses(scaling_list_dc_coef_minus8[sizeId - 2][matrixId], -7, +247,
689 2, sizeId - 2, matrixId);
690 }
691
2/2
✓ Branch 0 taken 105600 times.
✓ Branch 1 taken 1956 times.
215112 for (i = 0; i < n; i++) {
692
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 105600 times.
211200 ses(scaling_list_delta_coeff[sizeId][matrixId][i],
693 -128, +127, 3, sizeId, matrixId, i);
694 }
695 }
696 }
697 }
698
699 352 return 0;
700 }
701
702 static int FUNC(sps_range_extension)(CodedBitstreamContext *ctx, RWContext *rw,
703 H265RawSPS *current)
704 {
705 int err;
706
707 flag(transform_skip_rotation_enabled_flag);
708 flag(transform_skip_context_enabled_flag);
709 flag(implicit_rdpcm_enabled_flag);
710 flag(explicit_rdpcm_enabled_flag);
711 flag(extended_precision_processing_flag);
712 flag(intra_smoothing_disabled_flag);
713 flag(high_precision_offsets_enabled_flag);
714 flag(persistent_rice_adaptation_enabled_flag);
715 flag(cabac_bypass_alignment_enabled_flag);
716
717 return 0;
718 }
719
720 static int FUNC(sps_scc_extension)(CodedBitstreamContext *ctx, RWContext *rw,
721 H265RawSPS *current)
722 {
723 int err, comp, i;
724
725 flag(sps_curr_pic_ref_enabled_flag);
726
727 flag(palette_mode_enabled_flag);
728 if (current->palette_mode_enabled_flag) {
729 ue(palette_max_size, 0, 64);
730 ue(delta_palette_max_predictor_size, 0, 128);
731
732 flag(sps_palette_predictor_initializer_present_flag);
733 if (current->sps_palette_predictor_initializer_present_flag) {
734 ue(sps_num_palette_predictor_initializer_minus1, 0, 127);
735 for (comp = 0; comp < (current->chroma_format_idc ? 3 : 1); comp++) {
736 int bit_depth = comp == 0 ? current->bit_depth_luma_minus8 + 8
737 : current->bit_depth_chroma_minus8 + 8;
738 for (i = 0; i <= current->sps_num_palette_predictor_initializer_minus1; i++)
739 ubs(bit_depth, sps_palette_predictor_initializers[comp][i], 2, comp, i);
740 }
741 }
742 }
743
744 u(2, motion_vector_resolution_control_idc, 0, 2);
745 flag(intra_boundary_filtering_disable_flag);
746
747 return 0;
748 }
749
750 128 static int FUNC(vui_parameters_default)(CodedBitstreamContext *ctx,
751 RWContext *rw, H265RawVUI *current,
752 H265RawSPS *sps)
753 {
754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(aspect_ratio_idc, 0);
755
756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(video_format, 5);
757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(video_full_range_flag, 0);
758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(colour_primaries, 2);
759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(transfer_characteristics, 2);
760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(matrix_coefficients, 2);
761
762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(chroma_sample_loc_type_top_field, 0);
763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(chroma_sample_loc_type_bottom_field, 0);
764
765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(tiles_fixed_structure_flag, 0);
766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(motion_vectors_over_pic_boundaries_flag, 1);
767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(min_spatial_segmentation_idc, 0);
768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(max_bytes_per_pic_denom, 2);
769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(max_bits_per_min_cu_denom, 1);
770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(log2_max_mv_length_horizontal, 15);
771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
128 infer(log2_max_mv_length_vertical, 15);
772
773 128 return 0;
774 }
775
776 200 static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
777 H265RawSPS *current)
778 {
779 200 CodedBitstreamH265Context *h265 = ctx->priv_data;
780 const H265RawVPS *vps;
781 int err, i;
782 unsigned int min_cb_log2_size_y, ctb_log2_size_y,
783 min_cb_size_y, min_tb_log2_size_y;
784
785 200 HEADER("Sequence Parameter Set");
786
787
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header, HEVC_NAL_SPS));
788
789
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ub(4, sps_video_parameter_set_id);
790 200 h265->active_vps = vps = h265->vps[current->sps_video_parameter_set_id];
791
792
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 u(3, sps_max_sub_layers_minus1, 0, HEVC_MAX_SUB_LAYERS - 1);
793
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 flag(sps_temporal_id_nesting_flag);
794
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
200 if (vps) {
795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
200 if (vps->vps_max_sub_layers_minus1 > current->sps_max_sub_layers_minus1) {
796 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
797 "sps_max_sub_layers_minus1 (%d) must be less than or equal to "
798 "vps_max_sub_layers_minus1 (%d).\n",
799 vps->vps_max_sub_layers_minus1,
800 current->sps_max_sub_layers_minus1);
801 return AVERROR_INVALIDDATA;
802 }
803
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 24 times.
200 if (vps->vps_temporal_id_nesting_flag &&
804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
152 !current->sps_temporal_id_nesting_flag) {
805 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
806 "sps_temporal_id_nesting_flag must be 1 if "
807 "vps_temporal_id_nesting_flag is 1.\n");
808 return AVERROR_INVALIDDATA;
809 }
810 }
811
812
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 CHECK(FUNC(profile_tier_level)(ctx, rw, &current->profile_tier_level,
813 1, current->sps_max_sub_layers_minus1));
814
815
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(sps_seq_parameter_set_id, 0, 15);
816
817
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(chroma_format_idc, 0, 3);
818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
200 if (current->chroma_format_idc == 3)
819 flag(separate_colour_plane_flag);
820 else
821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
200 infer(separate_colour_plane_flag, 0);
822
823
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(pic_width_in_luma_samples, 1, HEVC_MAX_WIDTH);
824
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(pic_height_in_luma_samples, 1, HEVC_MAX_HEIGHT);
825
826
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 flag(conformance_window_flag);
827
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 24 times.
200 if (current->conformance_window_flag) {
828
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
152 ue(conf_win_left_offset, 0, current->pic_width_in_luma_samples);
829
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
152 ue(conf_win_right_offset, 0, current->pic_width_in_luma_samples);
830
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
152 ue(conf_win_top_offset, 0, current->pic_height_in_luma_samples);
831
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
152 ue(conf_win_bottom_offset, 0, current->pic_height_in_luma_samples);
832 } else {
833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
48 infer(conf_win_left_offset, 0);
834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
48 infer(conf_win_right_offset, 0);
835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
48 infer(conf_win_top_offset, 0);
836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
48 infer(conf_win_bottom_offset, 0);
837 }
838
839
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(bit_depth_luma_minus8, 0, 8);
840
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(bit_depth_chroma_minus8, 0, 8);
841
842
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(log2_max_pic_order_cnt_lsb_minus4, 0, 12);
843
844
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 flag(sps_sub_layer_ordering_info_present_flag);
845 200 for (i = (current->sps_sub_layer_ordering_info_present_flag ?
846
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 76 times.
200 0 : current->sps_max_sub_layers_minus1);
847
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 100 times.
416 i <= current->sps_max_sub_layers_minus1; i++) {
848
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 108 times.
216 ues(sps_max_dec_pic_buffering_minus1[i],
849 0, HEVC_MAX_DPB_SIZE - 1, 1, i);
850
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 108 times.
216 ues(sps_max_num_reorder_pics[i],
851 0, current->sps_max_dec_pic_buffering_minus1[i], 1, i);
852
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 108 times.
216 ues(sps_max_latency_increase_plus1[i],
853 0, UINT32_MAX - 1, 1, i);
854 }
855
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 76 times.
200 if (!current->sps_sub_layer_ordering_info_present_flag) {
856
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 24 times.
128 for (i = 0; i < current->sps_max_sub_layers_minus1; i++) {
857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
80 infer(sps_max_dec_pic_buffering_minus1[i],
858 current->sps_max_dec_pic_buffering_minus1[current->sps_max_sub_layers_minus1]);
859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
80 infer(sps_max_num_reorder_pics[i],
860 current->sps_max_num_reorder_pics[current->sps_max_sub_layers_minus1]);
861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
80 infer(sps_max_latency_increase_plus1[i],
862 current->sps_max_latency_increase_plus1[current->sps_max_sub_layers_minus1]);
863 }
864 }
865
866
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(log2_min_luma_coding_block_size_minus3, 0, 3);
867 200 min_cb_log2_size_y = current->log2_min_luma_coding_block_size_minus3 + 3;
868
869
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(log2_diff_max_min_luma_coding_block_size, 0, 3);
870 200 ctb_log2_size_y = min_cb_log2_size_y +
871 200 current->log2_diff_max_min_luma_coding_block_size;
872
873 200 min_cb_size_y = 1 << min_cb_log2_size_y;
874
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
200 if (current->pic_width_in_luma_samples % min_cb_size_y ||
875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
200 current->pic_height_in_luma_samples % min_cb_size_y) {
876 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid dimensions: %ux%u not divisible "
877 "by MinCbSizeY = %u.\n", current->pic_width_in_luma_samples,
878 current->pic_height_in_luma_samples, min_cb_size_y);
879 return AVERROR_INVALIDDATA;
880 }
881
882
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(log2_min_luma_transform_block_size_minus2, 0, min_cb_log2_size_y - 3);
883 200 min_tb_log2_size_y = current->log2_min_luma_transform_block_size_minus2 + 2;
884
885
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(log2_diff_max_min_luma_transform_block_size,
886 0, FFMIN(ctb_log2_size_y, 5) - min_tb_log2_size_y);
887
888
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(max_transform_hierarchy_depth_inter,
889 0, ctb_log2_size_y - min_tb_log2_size_y);
890
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(max_transform_hierarchy_depth_intra,
891 0, ctb_log2_size_y - min_tb_log2_size_y);
892
893
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 flag(scaling_list_enabled_flag);
894
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 92 times.
200 if (current->scaling_list_enabled_flag) {
895
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 flag(sps_scaling_list_data_present_flag);
896
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
16 if (current->sps_scaling_list_data_present_flag)
897
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
16 CHECK(FUNC(scaling_list_data)(ctx, rw, &current->scaling_list));
898 } else {
899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
184 infer(sps_scaling_list_data_present_flag, 0);
900 }
901
902
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 flag(amp_enabled_flag);
903
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 flag(sample_adaptive_offset_enabled_flag);
904
905
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 flag(pcm_enabled_flag);
906
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 96 times.
200 if (current->pcm_enabled_flag) {
907
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 u(4, pcm_sample_bit_depth_luma_minus1,
908 0, current->bit_depth_luma_minus8 + 8 - 1);
909
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 u(4, pcm_sample_bit_depth_chroma_minus1,
910 0, current->bit_depth_chroma_minus8 + 8 - 1);
911
912
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ue(log2_min_pcm_luma_coding_block_size_minus3,
913 FFMIN(min_cb_log2_size_y, 5) - 3, FFMIN(ctb_log2_size_y, 5) - 3);
914
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ue(log2_diff_max_min_pcm_luma_coding_block_size,
915 0, FFMIN(ctb_log2_size_y, 5) - (current->log2_min_pcm_luma_coding_block_size_minus3 + 3));
916
917
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 flag(pcm_loop_filter_disabled_flag);
918 }
919
920
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 ue(num_short_term_ref_pic_sets, 0, HEVC_MAX_SHORT_TERM_REF_PIC_SETS);
921
2/2
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 100 times.
1856 for (i = 0; i < current->num_short_term_ref_pic_sets; i++)
922
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 828 times.
1656 CHECK(FUNC(st_ref_pic_set)(ctx, rw, &current->st_ref_pic_set[i], i, current));
923
924
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 flag(long_term_ref_pics_present_flag);
925
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 72 times.
200 if (current->long_term_ref_pics_present_flag) {
926
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
56 ue(num_long_term_ref_pics_sps, 0, HEVC_MAX_LONG_TERM_REF_PICS);
927
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 28 times.
120 for (i = 0; i < current->num_long_term_ref_pics_sps; i++) {
928
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
64 ubs(current->log2_max_pic_order_cnt_lsb_minus4 + 4,
929 lt_ref_pic_poc_lsb_sps[i], 1, i);
930
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
64 flags(used_by_curr_pic_lt_sps_flag[i], 1, i);
931 }
932 }
933
934
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 flag(sps_temporal_mvp_enabled_flag);
935
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 flag(strong_intra_smoothing_enabled_flag);
936
937
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 flag(vui_parameters_present_flag);
938
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 64 times.
200 if (current->vui_parameters_present_flag)
939
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
72 CHECK(FUNC(vui_parameters)(ctx, rw, &current->vui, current));
940 else
941
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
128 CHECK(FUNC(vui_parameters_default)(ctx, rw, &current->vui, current));
942
943
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 flag(sps_extension_present_flag);
944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
200 if (current->sps_extension_present_flag) {
945 flag(sps_range_extension_flag);
946 flag(sps_multilayer_extension_flag);
947 flag(sps_3d_extension_flag);
948 flag(sps_scc_extension_flag);
949 ub(4, sps_extension_4bits);
950 }
951
952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
200 if (current->sps_range_extension_flag)
953 CHECK(FUNC(sps_range_extension)(ctx, rw, current));
954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
200 if (current->sps_multilayer_extension_flag)
955 return AVERROR_PATCHWELCOME;
956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
200 if (current->sps_3d_extension_flag)
957 return AVERROR_PATCHWELCOME;
958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
200 if (current->sps_scc_extension_flag)
959 CHECK(FUNC(sps_scc_extension)(ctx, rw, current));
960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
200 if (current->sps_extension_4bits)
961 CHECK(FUNC(extension_data)(ctx, rw, &current->extension_data));
962
963
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
200 CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
964
965 200 return 0;
966 }
967
968 static int FUNC(pps_range_extension)(CodedBitstreamContext *ctx, RWContext *rw,
969 H265RawPPS *current)
970 {
971 CodedBitstreamH265Context *h265 = ctx->priv_data;
972 const H265RawSPS *sps = h265->active_sps;
973 int err, i;
974
975 if (current->transform_skip_enabled_flag)
976 ue(log2_max_transform_skip_block_size_minus2, 0, 3);
977 flag(cross_component_prediction_enabled_flag);
978
979 flag(chroma_qp_offset_list_enabled_flag);
980 if (current->chroma_qp_offset_list_enabled_flag) {
981 ue(diff_cu_chroma_qp_offset_depth,
982 0, sps->log2_diff_max_min_luma_coding_block_size);
983 ue(chroma_qp_offset_list_len_minus1, 0, 5);
984 for (i = 0; i <= current->chroma_qp_offset_list_len_minus1; i++) {
985 ses(cb_qp_offset_list[i], -12, +12, 1, i);
986 ses(cr_qp_offset_list[i], -12, +12, 1, i);
987 }
988 }
989
990 ue(log2_sao_offset_scale_luma, 0, FFMAX(0, sps->bit_depth_luma_minus8 - 2));
991 ue(log2_sao_offset_scale_chroma, 0, FFMAX(0, sps->bit_depth_chroma_minus8 - 2));
992
993 return 0;
994 }
995
996 static int FUNC(pps_scc_extension)(CodedBitstreamContext *ctx, RWContext *rw,
997 H265RawPPS *current)
998 {
999 int err, comp, i;
1000
1001 flag(pps_curr_pic_ref_enabled_flag);
1002
1003 flag(residual_adaptive_colour_transform_enabled_flag);
1004 if (current->residual_adaptive_colour_transform_enabled_flag) {
1005 flag(pps_slice_act_qp_offsets_present_flag);
1006 se(pps_act_y_qp_offset_plus5, -7, +17);
1007 se(pps_act_cb_qp_offset_plus5, -7, +17);
1008 se(pps_act_cr_qp_offset_plus3, -9, +15);
1009 } else {
1010 infer(pps_slice_act_qp_offsets_present_flag, 0);
1011 infer(pps_act_y_qp_offset_plus5, 0);
1012 infer(pps_act_cb_qp_offset_plus5, 0);
1013 infer(pps_act_cr_qp_offset_plus3, 0);
1014 }
1015
1016 flag(pps_palette_predictor_initializer_present_flag);
1017 if (current->pps_palette_predictor_initializer_present_flag) {
1018 ue(pps_num_palette_predictor_initializer, 0, 128);
1019 if (current->pps_num_palette_predictor_initializer > 0) {
1020 flag(monochrome_palette_flag);
1021 ue(luma_bit_depth_entry_minus8, 0, 8);
1022 if (!current->monochrome_palette_flag)
1023 ue(chroma_bit_depth_entry_minus8, 0, 8);
1024 for (comp = 0; comp < (current->monochrome_palette_flag ? 1 : 3); comp++) {
1025 int bit_depth = comp == 0 ? current->luma_bit_depth_entry_minus8 + 8
1026 : current->chroma_bit_depth_entry_minus8 + 8;
1027 for (i = 0; i < current->pps_num_palette_predictor_initializer; i++)
1028 ubs(bit_depth, pps_palette_predictor_initializers[comp][i], 2, comp, i);
1029 }
1030 }
1031 }
1032
1033 return 0;
1034 }
1035
1036 1100 static int FUNC(pps)(CodedBitstreamContext *ctx, RWContext *rw,
1037 H265RawPPS *current)
1038 {
1039 1100 CodedBitstreamH265Context *h265 = ctx->priv_data;
1040 const H265RawSPS *sps;
1041 int err, i;
1042
1043 1100 HEADER("Picture Parameter Set");
1044
1045
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header, HEVC_NAL_PPS));
1046
1047
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 ue(pps_pic_parameter_set_id, 0, 63);
1048
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 ue(pps_seq_parameter_set_id, 0, 15);
1049 1100 sps = h265->sps[current->pps_seq_parameter_set_id];
1050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
1100 if (!sps) {
1051 av_log(ctx->log_ctx, AV_LOG_ERROR, "SPS id %d not available.\n",
1052 current->pps_seq_parameter_set_id);
1053 return AVERROR_INVALIDDATA;
1054 }
1055 1100 h265->active_sps = sps;
1056
1057
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(dependent_slice_segments_enabled_flag);
1058
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(output_flag_present_flag);
1059
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 ub(3, num_extra_slice_header_bits);
1060
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(sign_data_hiding_enabled_flag);
1061
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(cabac_init_present_flag);
1062
1063
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 ue(num_ref_idx_l0_default_active_minus1, 0, 14);
1064
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 ue(num_ref_idx_l1_default_active_minus1, 0, 14);
1065
1066
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 se(init_qp_minus26, -(26 + 6 * sps->bit_depth_luma_minus8), +25);
1067
1068
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(constrained_intra_pred_flag);
1069
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(transform_skip_enabled_flag);
1070
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(cu_qp_delta_enabled_flag);
1071
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 538 times.
1100 if (current->cu_qp_delta_enabled_flag)
1072
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
24 ue(diff_cu_qp_delta_depth,
1073 0, sps->log2_diff_max_min_luma_coding_block_size);
1074 else
1075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 269 times.
1076 infer(diff_cu_qp_delta_depth, 0);
1076
1077
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 se(pps_cb_qp_offset, -12, +12);
1078
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 se(pps_cr_qp_offset, -12, +12);
1079
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(pps_slice_chroma_qp_offsets_present_flag);
1080
1081
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(weighted_pred_flag);
1082
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(weighted_bipred_flag);
1083
1084
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(transquant_bypass_enabled_flag);
1085
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(tiles_enabled_flag);
1086
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(entropy_coding_sync_enabled_flag);
1087
1088
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 340 times.
1100 if (current->tiles_enabled_flag) {
1089
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
420 ue(num_tile_columns_minus1, 0, HEVC_MAX_TILE_COLUMNS);
1090
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
420 ue(num_tile_rows_minus1, 0, HEVC_MAX_TILE_ROWS);
1091
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
420 flag(uniform_spacing_flag);
1092
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 8 times.
420 if (!current->uniform_spacing_flag) {
1093
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 202 times.
2020 for (i = 0; i < current->num_tile_columns_minus1; i++)
1094
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
1616 ues(column_width_minus1[i], 0, sps->pic_width_in_luma_samples, 1, i);
1095
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 202 times.
2020 for (i = 0; i < current->num_tile_rows_minus1; i++)
1096
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
1616 ues(row_height_minus1[i], 0, sps->pic_height_in_luma_samples, 1, i);
1097 }
1098
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
420 flag(loop_filter_across_tiles_enabled_flag);
1099 } else {
1100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
680 infer(num_tile_columns_minus1, 0);
1101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170 times.
680 infer(num_tile_rows_minus1, 0);
1102 }
1103
1104
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(pps_loop_filter_across_slices_enabled_flag);
1105
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(deblocking_filter_control_present_flag);
1106
2/2
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 324 times.
1100 if (current->deblocking_filter_control_present_flag) {
1107
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 226 times.
452 flag(deblocking_filter_override_enabled_flag);
1108
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 226 times.
452 flag(pps_deblocking_filter_disabled_flag);
1109
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 4 times.
452 if (!current->pps_deblocking_filter_disabled_flag) {
1110
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 222 times.
444 se(pps_beta_offset_div2, -6, +6);
1111
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 222 times.
444 se(pps_tc_offset_div2, -6, +6);
1112 } else {
1113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
8 infer(pps_beta_offset_div2, 0);
1114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
8 infer(pps_tc_offset_div2, 0);
1115 }
1116 } else {
1117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
648 infer(deblocking_filter_override_enabled_flag, 0);
1118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
648 infer(pps_deblocking_filter_disabled_flag, 0);
1119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
648 infer(pps_beta_offset_div2, 0);
1120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
648 infer(pps_tc_offset_div2, 0);
1121 }
1122
1123
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(pps_scaling_list_data_present_flag);
1124
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 382 times.
1100 if (current->pps_scaling_list_data_present_flag)
1125
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
336 CHECK(FUNC(scaling_list_data)(ctx, rw, &current->scaling_list));
1126
1127
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(lists_modification_present_flag);
1128
1129
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 ue(log2_parallel_merge_level_minus2,
1130 0, (sps->log2_min_luma_coding_block_size_minus3 + 3 +
1131 sps->log2_diff_max_min_luma_coding_block_size - 2));
1132
1133
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(slice_segment_header_extension_present_flag);
1134
1135
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 flag(pps_extension_present_flag);
1136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
1100 if (current->pps_extension_present_flag) {
1137 flag(pps_range_extension_flag);
1138 flag(pps_multilayer_extension_flag);
1139 flag(pps_3d_extension_flag);
1140 flag(pps_scc_extension_flag);
1141 ub(4, pps_extension_4bits);
1142 }
1143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
1100 if (current->pps_range_extension_flag)
1144 CHECK(FUNC(pps_range_extension)(ctx, rw, current));
1145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
1100 if (current->pps_multilayer_extension_flag)
1146 return AVERROR_PATCHWELCOME;
1147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
1100 if (current->pps_3d_extension_flag)
1148 return AVERROR_PATCHWELCOME;
1149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
1100 if (current->pps_scc_extension_flag)
1150 CHECK(FUNC(pps_scc_extension)(ctx, rw, current));
1151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
1100 if (current->pps_extension_4bits)
1152 CHECK(FUNC(extension_data)(ctx, rw, &current->extension_data));
1153
1154
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
1100 CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
1155
1156 1100 return 0;
1157 }
1158
1159 240 static int FUNC(aud)(CodedBitstreamContext *ctx, RWContext *rw,
1160 H265RawAUD *current)
1161 {
1162 int err;
1163
1164 240 HEADER("Access Unit Delimiter");
1165
1166
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
240 CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header, HEVC_NAL_AUD));
1167
1168
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
240 u(3, pic_type, 0, 2);
1169
1170
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
240 CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
1171
1172 240 return 0;
1173 }
1174
1175 2992 static int FUNC(ref_pic_lists_modification)(CodedBitstreamContext *ctx, RWContext *rw,
1176 H265RawSliceHeader *current,
1177 unsigned int num_pic_total_curr)
1178 {
1179 unsigned int entry_size;
1180 int err, i;
1181
1182 2992 entry_size = av_log2(num_pic_total_curr - 1) + 1;
1183
1184
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1496 times.
2992 flag(ref_pic_list_modification_flag_l0);
1185
2/2
✓ Branch 0 taken 726 times.
✓ Branch 1 taken 770 times.
2992 if (current->ref_pic_list_modification_flag_l0) {
1186
2/2
✓ Branch 0 taken 1672 times.
✓ Branch 1 taken 726 times.
4796 for (i = 0; i <= current->num_ref_idx_l0_active_minus1; i++)
1187
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1672 times.
3344 us(entry_size, list_entry_l0[i], 0, num_pic_total_curr - 1, 1, i);
1188 }
1189
1190
1/2
✓ Branch 0 taken 1496 times.
✗ Branch 1 not taken.
2992 if (current->slice_type == HEVC_SLICE_B) {
1191
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1496 times.
2992 flag(ref_pic_list_modification_flag_l1);
1192
2/2
✓ Branch 0 taken 426 times.
✓ Branch 1 taken 1070 times.
2992 if (current->ref_pic_list_modification_flag_l1) {
1193
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 426 times.
2872 for (i = 0; i <= current->num_ref_idx_l1_active_minus1; i++)
1194
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1010 times.
2020 us(entry_size, list_entry_l1[i], 0, num_pic_total_curr - 1, 1, i);
1195 }
1196 }
1197
1198 2992 return 0;
1199 }
1200
1201 1020 static int FUNC(pred_weight_table)(CodedBitstreamContext *ctx, RWContext *rw,
1202 H265RawSliceHeader *current)
1203 {
1204 1020 CodedBitstreamH265Context *h265 = ctx->priv_data;
1205 1020 const H265RawSPS *sps = h265->active_sps;
1206 int err, i, j;
1207
1/2
✓ Branch 0 taken 510 times.
✗ Branch 1 not taken.
2040 int chroma = !sps->separate_colour_plane_flag &&
1208
1/2
✓ Branch 0 taken 510 times.
✗ Branch 1 not taken.
1020 sps->chroma_format_idc != 0;
1209
1210
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 510 times.
1020 ue(luma_log2_weight_denom, 0, 7);
1211
1/2
✓ Branch 0 taken 510 times.
✗ Branch 1 not taken.
1020 if (chroma)
1212
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 510 times.
1020 se(delta_chroma_log2_weight_denom, -7, 7);
1213 else
1214 infer(delta_chroma_log2_weight_denom, 0);
1215
1216
2/2
✓ Branch 0 taken 2028 times.
✓ Branch 1 taken 510 times.
5076 for (i = 0; i <= current->num_ref_idx_l0_active_minus1; i++) {
1217 if (1 /* is not same POC and same layer_id */)
1218
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2028 times.
4056 flags(luma_weight_l0_flag[i], 1, i);
1219 else
1220 infer(luma_weight_l0_flag[i], 0);
1221 }
1222
1/2
✓ Branch 0 taken 510 times.
✗ Branch 1 not taken.
1020 if (chroma) {
1223
2/2
✓ Branch 0 taken 2028 times.
✓ Branch 1 taken 510 times.
5076 for (i = 0; i <= current->num_ref_idx_l0_active_minus1; i++) {
1224 if (1 /* is not same POC and same layer_id */)
1225
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2028 times.
4056 flags(chroma_weight_l0_flag[i], 1, i);
1226 else
1227 infer(chroma_weight_l0_flag[i], 0);
1228 }
1229 }
1230
1231
2/2
✓ Branch 0 taken 2028 times.
✓ Branch 1 taken 510 times.
5076 for (i = 0; i <= current->num_ref_idx_l0_active_minus1; i++) {
1232
2/2
✓ Branch 0 taken 1540 times.
✓ Branch 1 taken 488 times.
4056 if (current->luma_weight_l0_flag[i]) {
1233
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1540 times.
3080 ses(delta_luma_weight_l0[i], -128, +127, 1, i);
1234
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1540 times.
3080 ses(luma_offset_l0[i],
1235 -(1 << (sps->bit_depth_luma_minus8 + 8 - 1)),
1236 ((1 << (sps->bit_depth_luma_minus8 + 8 - 1)) - 1), 1, i);
1237 } else {
1238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244 times.
976 infer(delta_luma_weight_l0[i], 0);
1239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244 times.
976 infer(luma_offset_l0[i], 0);
1240 }
1241
2/2
✓ Branch 0 taken 506 times.
✓ Branch 1 taken 1522 times.
4056 if (current->chroma_weight_l0_flag[i]) {
1242
2/2
✓ Branch 0 taken 1012 times.
✓ Branch 1 taken 506 times.
3036 for (j = 0; j < 2; j++) {
1243
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1012 times.
2024 ses(delta_chroma_weight_l0[i][j], -128, +127, 2, i, j);
1244
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1012 times.
2024 ses(chroma_offset_l0[i][j],
1245 -(4 << (sps->bit_depth_chroma_minus8 + 8 - 1)),
1246 ((4 << (sps->bit_depth_chroma_minus8 + 8 - 1)) - 1), 2, i, j);
1247 }
1248 } else {
1249
2/2
✓ Branch 0 taken 3044 times.
✓ Branch 1 taken 1522 times.
9132 for (j = 0; j < 2; j++) {
1250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1522 times.
6088 infer(delta_chroma_weight_l0[i][j], 0);
1251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1522 times.
6088 infer(chroma_offset_l0[i][j], 0);
1252 }
1253 }
1254 }
1255
1256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 510 times.
1020 if (current->slice_type == HEVC_SLICE_B) {
1257 for (i = 0; i <= current->num_ref_idx_l1_active_minus1; i++) {
1258 if (1 /* RefPicList1[i] is not CurrPic, nor is it in a different layer */)
1259 flags(luma_weight_l1_flag[i], 1, i);
1260 else
1261 infer(luma_weight_l1_flag[i], 0);
1262 }
1263 if (chroma) {
1264 for (i = 0; i <= current->num_ref_idx_l1_active_minus1; i++) {
1265 if (1 /* RefPicList1[i] is not CurrPic, nor is it in a different layer */)
1266 flags(chroma_weight_l1_flag[i], 1, i);
1267 else
1268 infer(chroma_weight_l1_flag[i], 0);
1269 }
1270 }
1271
1272 for (i = 0; i <= current->num_ref_idx_l1_active_minus1; i++) {
1273 if (current->luma_weight_l1_flag[i]) {
1274 ses(delta_luma_weight_l1[i], -128, +127, 1, i);
1275 ses(luma_offset_l1[i],
1276 -(1 << (sps->bit_depth_luma_minus8 + 8 - 1)),
1277 ((1 << (sps->bit_depth_luma_minus8 + 8 - 1)) - 1), 1, i);
1278 } else {
1279 infer(delta_luma_weight_l1[i], 0);
1280 infer(luma_offset_l1[i], 0);
1281 }
1282 if (current->chroma_weight_l1_flag[i]) {
1283 for (j = 0; j < 2; j++) {
1284 ses(delta_chroma_weight_l1[i][j], -128, +127, 2, i, j);
1285 ses(chroma_offset_l1[i][j],
1286 -(4 << (sps->bit_depth_chroma_minus8 + 8 - 1)),
1287 ((4 << (sps->bit_depth_chroma_minus8 + 8 - 1)) - 1), 2, i, j);
1288 }
1289 } else {
1290 for (j = 0; j < 2; j++) {
1291 infer(delta_chroma_weight_l1[i][j], 0);
1292 infer(chroma_offset_l1[i][j], 0);
1293 }
1294 }
1295 }
1296 }
1297
1298 1020 return 0;
1299 }
1300
1301 23456 static int FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
1302 H265RawSliceHeader *current)
1303 {
1304 23456 CodedBitstreamH265Context *h265 = ctx->priv_data;
1305 const H265RawSPS *sps;
1306 const H265RawPPS *pps;
1307 unsigned int min_cb_log2_size_y, ctb_log2_size_y, ctb_size_y;
1308 unsigned int pic_width_in_ctbs_y, pic_height_in_ctbs_y, pic_size_in_ctbs_y;
1309 23456 unsigned int num_pic_total_curr = 0;
1310 int err, i;
1311
1312 23456 HEADER("Slice Segment Header");
1313
1314
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 11728 times.
23456 CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header, -1));
1315
1316
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 11728 times.
23456 flag(first_slice_segment_in_pic_flag);
1317
1318
2/2
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 11470 times.
23456 if (current->nal_unit_header.nal_unit_type >= HEVC_NAL_BLA_W_LP &&
1319
1/2
✓ Branch 0 taken 258 times.
✗ Branch 1 not taken.
516 current->nal_unit_header.nal_unit_type <= HEVC_NAL_RSV_IRAP_VCL23)
1320
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 258 times.
516 flag(no_output_of_prior_pics_flag);
1321
1322
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 11728 times.
23456 ue(slice_pic_parameter_set_id, 0, 63);
1323
1324 23456 pps = h265->pps[current->slice_pic_parameter_set_id];
1325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11728 times.
23456 if (!pps) {
1326 av_log(ctx->log_ctx, AV_LOG_ERROR, "PPS id %d not available.\n",
1327 current->slice_pic_parameter_set_id);
1328 return AVERROR_INVALIDDATA;
1329 }
1330 23456 h265->active_pps = pps;
1331
1332 23456 sps = h265->sps[pps->pps_seq_parameter_set_id];
1333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11728 times.
23456 if (!sps) {
1334 av_log(ctx->log_ctx, AV_LOG_ERROR, "SPS id %d not available.\n",
1335 pps->pps_seq_parameter_set_id);
1336 return AVERROR_INVALIDDATA;
1337 }
1338 23456 h265->active_sps = sps;
1339
1340 23456 min_cb_log2_size_y = sps->log2_min_luma_coding_block_size_minus3 + 3;
1341 23456 ctb_log2_size_y = min_cb_log2_size_y + sps->log2_diff_max_min_luma_coding_block_size;
1342 23456 ctb_size_y = 1 << ctb_log2_size_y;
1343 23456 pic_width_in_ctbs_y =
1344 23456 (sps->pic_width_in_luma_samples + ctb_size_y - 1) / ctb_size_y;
1345 23456 pic_height_in_ctbs_y =
1346 23456 (sps->pic_height_in_luma_samples + ctb_size_y - 1) / ctb_size_y;
1347 23456 pic_size_in_ctbs_y = pic_width_in_ctbs_y * pic_height_in_ctbs_y;
1348
1349
2/2
✓ Branch 0 taken 7464 times.
✓ Branch 1 taken 4264 times.
23456 if (!current->first_slice_segment_in_pic_flag) {
1350 14928 unsigned int address_size = av_log2(pic_size_in_ctbs_y - 1) + 1;
1351
2/2
✓ Branch 0 taken 4082 times.
✓ Branch 1 taken 3382 times.
14928 if (pps->dependent_slice_segments_enabled_flag)
1352
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4082 times.
8164 flag(dependent_slice_segment_flag);
1353 else
1354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1691 times.
6764 infer(dependent_slice_segment_flag, 0);
1355
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7464 times.
14928 u(address_size, slice_segment_address, 0, pic_size_in_ctbs_y - 1);
1356 } else {
1357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2132 times.
8528 infer(dependent_slice_segment_flag, 0);
1358 }
1359
1360
2/2
✓ Branch 0 taken 7960 times.
✓ Branch 1 taken 3768 times.
23456 if (!current->dependent_slice_segment_flag) {
1361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7960 times.
15920 for (i = 0; i < pps->num_extra_slice_header_bits; i++)
1362 flags(slice_reserved_flag[i], 1, i);
1363
1364
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7960 times.
15920 ue(slice_type, 0, 2);
1365
1366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7960 times.
15920 if (pps->output_flag_present_flag)
1367 flag(pic_output_flag);
1368
1369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7960 times.
15920 if (sps->separate_colour_plane_flag)
1370 u(2, colour_plane_id, 0, 2);
1371
1372
2/2
✓ Branch 0 taken 7854 times.
✓ Branch 1 taken 106 times.
15920 if (current->nal_unit_header.nal_unit_type != HEVC_NAL_IDR_W_RADL &&
1373
2/2
✓ Branch 0 taken 7852 times.
✓ Branch 1 taken 2 times.
15708 current->nal_unit_header.nal_unit_type != HEVC_NAL_IDR_N_LP) {
1374 const H265RawSTRefPicSet *rps;
1375 int dpb_slots_remaining;
1376
1377
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7852 times.
15704 ub(sps->log2_max_pic_order_cnt_lsb_minus4 + 4, slice_pic_order_cnt_lsb);
1378
1379
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7852 times.
15704 flag(short_term_ref_pic_set_sps_flag);
1380
2/2
✓ Branch 0 taken 3730 times.
✓ Branch 1 taken 4122 times.
15704 if (!current->short_term_ref_pic_set_sps_flag) {
1381
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3730 times.
7460 CHECK(FUNC(st_ref_pic_set)(ctx, rw, &current->short_term_ref_pic_set,
1382 sps->num_short_term_ref_pic_sets, sps));
1383 7460 rps = &current->short_term_ref_pic_set;
1384
1/2
✓ Branch 0 taken 4122 times.
✗ Branch 1 not taken.
8244 } else if (sps->num_short_term_ref_pic_sets > 1) {
1385 8244 unsigned int idx_size = av_log2(sps->num_short_term_ref_pic_sets - 1) + 1;
1386
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4122 times.
8244 u(idx_size, short_term_ref_pic_set_idx,
1387 0, sps->num_short_term_ref_pic_sets - 1);
1388 8244 rps = &sps->st_ref_pic_set[current->short_term_ref_pic_set_idx];
1389 } else {
1390 infer(short_term_ref_pic_set_idx, 0);
1391 rps = &sps->st_ref_pic_set[0];
1392 }
1393
1394 15704 dpb_slots_remaining = HEVC_MAX_DPB_SIZE - 1 -
1395 15704 rps->num_negative_pics - rps->num_positive_pics;
1396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7852 times.
15704 if (pps->pps_curr_pic_ref_enabled_flag &&
1397 (sps->sample_adaptive_offset_enabled_flag ||
1398 !pps->pps_deblocking_filter_disabled_flag ||
1399 pps->deblocking_filter_override_enabled_flag)) {
1400 // This picture will occupy two DPB slots.
1401 if (dpb_slots_remaining == 0) {
1402 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
1403 "short-term ref pic set contains too many pictures "
1404 "to use with current picture reference enabled.\n");
1405 return AVERROR_INVALIDDATA;
1406 }
1407 --dpb_slots_remaining;
1408 }
1409
1410 15704 num_pic_total_curr = 0;
1411
2/2
✓ Branch 0 taken 21572 times.
✓ Branch 1 taken 7852 times.
58848 for (i = 0; i < rps->num_negative_pics; i++)
1412
2/2
✓ Branch 0 taken 20524 times.
✓ Branch 1 taken 1048 times.
43144 if (rps->used_by_curr_pic_s0_flag[i])
1413 41048 ++num_pic_total_curr;
1414
2/2
✓ Branch 0 taken 5182 times.
✓ Branch 1 taken 7852 times.
26068 for (i = 0; i < rps->num_positive_pics; i++)
1415
2/2
✓ Branch 0 taken 4892 times.
✓ Branch 1 taken 290 times.
10364 if (rps->used_by_curr_pic_s1_flag[i])
1416 9784 ++num_pic_total_curr;
1417
1418
2/2
✓ Branch 0 taken 1664 times.
✓ Branch 1 taken 6188 times.
15704 if (sps->long_term_ref_pics_present_flag) {
1419 unsigned int idx_size;
1420
1421
2/2
✓ Branch 0 taken 998 times.
✓ Branch 1 taken 666 times.
3328 if (sps->num_long_term_ref_pics_sps > 0) {
1422
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
1996 ue(num_long_term_sps, 0, FFMIN(sps->num_long_term_ref_pics_sps,
1423 dpb_slots_remaining));
1424 1996 idx_size = av_log2(sps->num_long_term_ref_pics_sps - 1) + 1;
1425 1996 dpb_slots_remaining -= current->num_long_term_sps;
1426 } else {
1427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333 times.
1332 infer(num_long_term_sps, 0);
1428 1332 idx_size = 0;
1429 }
1430
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1664 times.
3328 ue(num_long_term_pics, 0, dpb_slots_remaining);
1431
1432 3328 for (i = 0; i < current->num_long_term_sps +
1433
2/2
✓ Branch 0 taken 2820 times.
✓ Branch 1 taken 1664 times.
8968 current->num_long_term_pics; i++) {
1434
2/2
✓ Branch 0 taken 368 times.
✓ Branch 1 taken 2452 times.
5640 if (i < current->num_long_term_sps) {
1435
1/2
✓ Branch 0 taken 368 times.
✗ Branch 1 not taken.
736 if (sps->num_long_term_ref_pics_sps > 1)
1436
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 368 times.
736 us(idx_size, lt_idx_sps[i],
1437 0, sps->num_long_term_ref_pics_sps - 1, 1, i);
1438
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 192 times.
736 if (sps->used_by_curr_pic_lt_sps_flag[current->lt_idx_sps[i]])
1439 352 ++num_pic_total_curr;
1440 } else {
1441
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2452 times.
4904 ubs(sps->log2_max_pic_order_cnt_lsb_minus4 + 4, poc_lsb_lt[i], 1, i);
1442
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2452 times.
4904 flags(used_by_curr_pic_lt_flag[i], 1, i);
1443
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 1696 times.
4904 if (current->used_by_curr_pic_lt_flag[i])
1444 1512 ++num_pic_total_curr;
1445 }
1446
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2820 times.
5640 flags(delta_poc_msb_present_flag[i], 1, i);
1447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2820 times.
5640 if (current->delta_poc_msb_present_flag[i])
1448 ues(delta_poc_msb_cycle_lt[i], 0, UINT32_MAX - 1, 1, i);
1449 else
1450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1410 times.
5640 infer(delta_poc_msb_cycle_lt[i], 0);
1451 }
1452 }
1453
1454
2/2
✓ Branch 0 taken 5206 times.
✓ Branch 1 taken 2646 times.
15704 if (sps->sps_temporal_mvp_enabled_flag)
1455
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5206 times.
10412 flag(slice_temporal_mvp_enabled_flag);
1456 else
1457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1323 times.
5292 infer(slice_temporal_mvp_enabled_flag, 0);
1458
1459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7852 times.
15704 if (pps->pps_curr_pic_ref_enabled_flag)
1460 ++num_pic_total_curr;
1461 }
1462
1463
2/2
✓ Branch 0 taken 4692 times.
✓ Branch 1 taken 3268 times.
15920 if (sps->sample_adaptive_offset_enabled_flag) {
1464
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4692 times.
9384 flag(slice_sao_luma_flag);
1465
2/4
✓ Branch 0 taken 4692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4692 times.
✗ Branch 3 not taken.
9384 if (!sps->separate_colour_plane_flag && sps->chroma_format_idc != 0)
1466
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4692 times.
9384 flag(slice_sao_chroma_flag);
1467 else
1468 infer(slice_sao_chroma_flag, 0);
1469 } else {
1470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1634 times.
6536 infer(slice_sao_luma_flag, 0);
1471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1634 times.
6536 infer(slice_sao_chroma_flag, 0);
1472 }
1473
1474
2/2
✓ Branch 0 taken 4592 times.
✓ Branch 1 taken 3368 times.
15920 if (current->slice_type == HEVC_SLICE_P ||
1475
2/2
✓ Branch 0 taken 4386 times.
✓ Branch 1 taken 206 times.
9184 current->slice_type == HEVC_SLICE_B) {
1476
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7754 times.
15508 flag(num_ref_idx_active_override_flag);
1477
2/2
✓ Branch 0 taken 3652 times.
✓ Branch 1 taken 4102 times.
15508 if (current->num_ref_idx_active_override_flag) {
1478
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3652 times.
7304 ue(num_ref_idx_l0_active_minus1, 0, 14);
1479
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 2740 times.
7304 if (current->slice_type == HEVC_SLICE_B)
1480
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 912 times.
1824 ue(num_ref_idx_l1_active_minus1, 0, 14);
1481 else
1482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1370 times.
5480 infer(num_ref_idx_l1_active_minus1, pps->num_ref_idx_l1_default_active_minus1);
1483 } else {
1484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2051 times.
8204 infer(num_ref_idx_l0_active_minus1, pps->num_ref_idx_l0_default_active_minus1);
1485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2051 times.
8204 infer(num_ref_idx_l1_active_minus1, pps->num_ref_idx_l1_default_active_minus1);
1486 }
1487
1488
4/4
✓ Branch 0 taken 1548 times.
✓ Branch 1 taken 6206 times.
✓ Branch 2 taken 1496 times.
✓ Branch 3 taken 52 times.
15508 if (pps->lists_modification_present_flag && num_pic_total_curr > 1)
1489
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1496 times.
2992 CHECK(FUNC(ref_pic_lists_modification)(ctx, rw, current,
1490 num_pic_total_curr));
1491
1492
2/2
✓ Branch 0 taken 4386 times.
✓ Branch 1 taken 3368 times.
15508 if (current->slice_type == HEVC_SLICE_B)
1493
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4386 times.
8772 flag(mvd_l1_zero_flag);
1494
2/2
✓ Branch 0 taken 4938 times.
✓ Branch 1 taken 2816 times.
15508 if (pps->cabac_init_present_flag)
1495
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4938 times.
9876 flag(cabac_init_flag);
1496 else
1497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1408 times.
5632 infer(cabac_init_flag, 0);
1498
2/2
✓ Branch 0 taken 5118 times.
✓ Branch 1 taken 2636 times.
15508 if (current->slice_temporal_mvp_enabled_flag) {
1499
2/2
✓ Branch 0 taken 4386 times.
✓ Branch 1 taken 732 times.
10236 if (current->slice_type == HEVC_SLICE_B)
1500
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4386 times.
8772 flag(collocated_from_l0_flag);
1501 else
1502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 366 times.
1464 infer(collocated_from_l0_flag, 1);
1503
2/2
✓ Branch 0 taken 2362 times.
✓ Branch 1 taken 2756 times.
10236 if (current->collocated_from_l0_flag) {
1504
2/2
✓ Branch 0 taken 2126 times.
✓ Branch 1 taken 236 times.
4724 if (current->num_ref_idx_l0_active_minus1 > 0)
1505
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2126 times.
4252 ue(collocated_ref_idx, 0, current->num_ref_idx_l0_active_minus1);
1506 else
1507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
472 infer(collocated_ref_idx, 0);
1508 } else {
1509
2/2
✓ Branch 0 taken 2574 times.
✓ Branch 1 taken 182 times.
5512 if (current->num_ref_idx_l1_active_minus1 > 0)
1510
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2574 times.
5148 ue(collocated_ref_idx, 0, current->num_ref_idx_l1_active_minus1);
1511 else
1512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91 times.
364 infer(collocated_ref_idx, 0);
1513 }
1514 }
1515
1516
3/4
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 7244 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 510 times.
15508 if ((pps->weighted_pred_flag && current->slice_type == HEVC_SLICE_P) ||
1517
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7244 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14488 (pps->weighted_bipred_flag && current->slice_type == HEVC_SLICE_B))
1518
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 510 times.
1020 CHECK(FUNC(pred_weight_table)(ctx, rw, current));
1519
1520
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7754 times.
15508 ue(five_minus_max_num_merge_cand, 0, 4);
1521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7754 times.
15508 if (sps->motion_vector_resolution_control_idc == 2)
1522 flag(use_integer_mv_flag);
1523 else
1524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3877 times.
15508 infer(use_integer_mv_flag, sps->motion_vector_resolution_control_idc);
1525 }
1526
1527
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7960 times.
15920 se(slice_qp_delta,
1528 - 6 * sps->bit_depth_luma_minus8 - (pps->init_qp_minus26 + 26),
1529 + 51 - (pps->init_qp_minus26 + 26));
1530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7960 times.
15920 if (pps->pps_slice_chroma_qp_offsets_present_flag) {
1531 se(slice_cb_qp_offset, -12, +12);
1532 se(slice_cr_qp_offset, -12, +12);
1533 } else {
1534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3980 times.
15920 infer(slice_cb_qp_offset, 0);
1535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3980 times.
15920 infer(slice_cr_qp_offset, 0);
1536 }
1537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7960 times.
15920 if (pps->pps_slice_act_qp_offsets_present_flag) {
1538 se(slice_act_y_qp_offset,
1539 -12 - (pps->pps_act_y_qp_offset_plus5 - 5),
1540 +12 - (pps->pps_act_y_qp_offset_plus5 - 5));
1541 se(slice_act_cb_qp_offset,
1542 -12 - (pps->pps_act_cb_qp_offset_plus5 - 5),
1543 +12 - (pps->pps_act_cb_qp_offset_plus5 - 5));
1544 se(slice_act_cr_qp_offset,
1545 -12 - (pps->pps_act_cr_qp_offset_plus3 - 3),
1546 +12 - (pps->pps_act_cr_qp_offset_plus3 - 3));
1547 } else {
1548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3980 times.
15920 infer(slice_act_y_qp_offset, 0);
1549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3980 times.
15920 infer(slice_act_cb_qp_offset, 0);
1550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3980 times.
15920 infer(slice_act_cr_qp_offset, 0);
1551 }
1552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7960 times.
15920 if (pps->chroma_qp_offset_list_enabled_flag)
1553 flag(cu_chroma_qp_offset_enabled_flag);
1554 else
1555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3980 times.
15920 infer(cu_chroma_qp_offset_enabled_flag, 0);
1556
1557
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 7886 times.
15920 if (pps->deblocking_filter_override_enabled_flag)
1558
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
148 flag(deblocking_filter_override_flag);
1559 else
1560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3943 times.
15772 infer(deblocking_filter_override_flag, 0);
1561
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7958 times.
15920 if (current->deblocking_filter_override_flag) {
1562
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
4 flag(slice_deblocking_filter_disabled_flag);
1563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
4 if (!current->slice_deblocking_filter_disabled_flag) {
1564 se(slice_beta_offset_div2, -6, +6);
1565 se(slice_tc_offset_div2, -6, +6);
1566 } else {
1567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
4 infer(slice_beta_offset_div2, pps->pps_beta_offset_div2);
1568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
4 infer(slice_tc_offset_div2, pps->pps_tc_offset_div2);
1569 }
1570 } else {
1571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3979 times.
15916 infer(slice_deblocking_filter_disabled_flag,
1572 pps->pps_deblocking_filter_disabled_flag);
1573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3979 times.
15916 infer(slice_beta_offset_div2, pps->pps_beta_offset_div2);
1574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3979 times.
15916 infer(slice_tc_offset_div2, pps->pps_tc_offset_div2);
1575 }
1576
2/2
✓ Branch 0 taken 6470 times.
✓ Branch 1 taken 1490 times.
15920 if (pps->pps_loop_filter_across_slices_enabled_flag &&
1577
3/4
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 1960 times.
✓ Branch 2 taken 4510 times.
✗ Branch 3 not taken.
12940 (current->slice_sao_luma_flag || current->slice_sao_chroma_flag ||
1578
2/2
✓ Branch 0 taken 4508 times.
✓ Branch 1 taken 2 times.
9020 !current->slice_deblocking_filter_disabled_flag))
1579
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6468 times.
12936 flag(slice_loop_filter_across_slices_enabled_flag);
1580 else
1581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 746 times.
2984 infer(slice_loop_filter_across_slices_enabled_flag,
1582 pps->pps_loop_filter_across_slices_enabled_flag);
1583 }
1584
1585
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 2736 times.
✓ Branch 2 taken 874 times.
✓ Branch 3 taken 8118 times.
23456 if (pps->tiles_enabled_flag || pps->entropy_coding_sync_enabled_flag) {
1586 unsigned int num_entry_point_offsets_limit;
1587
3/4
✓ Branch 0 taken 874 times.
✓ Branch 1 taken 2736 times.
✓ Branch 2 taken 874 times.
✗ Branch 3 not taken.
7220 if (!pps->tiles_enabled_flag && pps->entropy_coding_sync_enabled_flag)
1588 1748 num_entry_point_offsets_limit = pic_height_in_ctbs_y - 1;
1589
2/4
✓ Branch 0 taken 2736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2736 times.
✗ Branch 3 not taken.
5472 else if (pps->tiles_enabled_flag && !pps->entropy_coding_sync_enabled_flag)
1590 5472 num_entry_point_offsets_limit =
1591 5472 (pps->num_tile_columns_minus1 + 1) * (pps->num_tile_rows_minus1 + 1);
1592 else
1593 num_entry_point_offsets_limit =
1594 (pps->num_tile_columns_minus1 + 1) * pic_height_in_ctbs_y - 1;
1595
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3610 times.
7220 ue(num_entry_point_offsets, 0, num_entry_point_offsets_limit);
1596
1597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3610 times.
7220 if (current->num_entry_point_offsets > HEVC_MAX_ENTRY_POINT_OFFSETS) {
1598 av_log(ctx->log_ctx, AV_LOG_ERROR, "Too many entry points: "
1599 "%"PRIu16".\n", current->num_entry_point_offsets);
1600 return AVERROR_PATCHWELCOME;
1601 }
1602
1603
2/2
✓ Branch 0 taken 1538 times.
✓ Branch 1 taken 2072 times.
7220 if (current->num_entry_point_offsets > 0) {
1604
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1538 times.
3076 ue(offset_len_minus1, 0, 31);
1605
2/2
✓ Branch 0 taken 3112 times.
✓ Branch 1 taken 1538 times.
9300 for (i = 0; i < current->num_entry_point_offsets; i++)
1606
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3112 times.
6224 ubs(current->offset_len_minus1 + 1, entry_point_offset_minus1[i], 1, i);
1607 }
1608 }
1609
1610
2/2
✓ Branch 0 taken 874 times.
✓ Branch 1 taken 10854 times.
23456 if (pps->slice_segment_header_extension_present_flag) {
1611
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 874 times.
1748 ue(slice_segment_header_extension_length, 0, 256);
1612
2/2
✓ Branch 0 taken 6204 times.
✓ Branch 1 taken 874 times.
14156 for (i = 0; i < current->slice_segment_header_extension_length; i++)
1613
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6204 times.
12408 us(8, slice_segment_header_extension_data_byte[i], 0x00, 0xff, 1, i);
1614 }
1615
1616
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 11728 times.
23456 CHECK(FUNC(byte_alignment)(ctx, rw));
1617
1618 23456 return 0;
1619 }
1620
1621 30 static int FUNC(sei_buffering_period)
1622 (CodedBitstreamContext *ctx, RWContext *rw,
1623 H265RawSEIBufferingPeriod *current, SEIMessageState *sei)
1624 {
1625 30 CodedBitstreamH265Context *h265 = ctx->priv_data;
1626 const H265RawSPS *sps;
1627 const H265RawHRDParameters *hrd;
1628 int err, i, length;
1629
1630 #ifdef READ
1631 int start_pos, end_pos;
1632 10 start_pos = get_bits_count(rw);
1633 #endif
1634
1635 30 HEADER("Buffering Period");
1636
1637
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 ue(bp_seq_parameter_set_id, 0, HEVC_MAX_SPS_COUNT - 1);
1638
1639 30 sps = h265->sps[current->bp_seq_parameter_set_id];
1640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 if (!sps) {
1641 av_log(ctx->log_ctx, AV_LOG_ERROR, "SPS id %d not available.\n",
1642 current->bp_seq_parameter_set_id);
1643 return AVERROR_INVALIDDATA;
1644 }
1645 30 h265->active_sps = sps;
1646
1647
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 if (!sps->vui_parameters_present_flag ||
1648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 !sps->vui.vui_hrd_parameters_present_flag) {
1649 av_log(ctx->log_ctx, AV_LOG_ERROR, "Buffering period SEI requires "
1650 "HRD parameters to be present in SPS.\n");
1651 return AVERROR_INVALIDDATA;
1652 }
1653 30 hrd = &sps->vui.hrd_parameters;
1654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 if (!hrd->nal_hrd_parameters_present_flag &&
1655 !hrd->vcl_hrd_parameters_present_flag) {
1656 av_log(ctx->log_ctx, AV_LOG_ERROR, "Buffering period SEI requires "
1657 "NAL or VCL HRD parameters to be present.\n");
1658 return AVERROR_INVALIDDATA;
1659 }
1660
1661
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9 times.
30 if (!hrd->sub_pic_hrd_params_present_flag)
1662
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
12 flag(irap_cpb_params_present_flag);
1663 else
1664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
18 infer(irap_cpb_params_present_flag, 0);
1665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 if (current->irap_cpb_params_present_flag) {
1666 length = hrd->au_cpb_removal_delay_length_minus1 + 1;
1667 ub(length, cpb_delay_offset);
1668 length = hrd->dpb_output_delay_length_minus1 + 1;
1669 ub(length, dpb_delay_offset);
1670 } else {
1671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
30 infer(cpb_delay_offset, 0);
1672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
30 infer(dpb_delay_offset, 0);
1673 }
1674
1675
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 flag(concatenation_flag);
1676
1677 30 length = hrd->au_cpb_removal_delay_length_minus1 + 1;
1678
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 ub(length, au_cpb_removal_delay_delta_minus1);
1679
1680
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 if (hrd->nal_hrd_parameters_present_flag) {
1681
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 15 times.
60 for (i = 0; i <= hrd->cpb_cnt_minus1[0]; i++) {
1682 30 length = hrd->initial_cpb_removal_delay_length_minus1 + 1;
1683
1684
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 ubs(length, nal_initial_cpb_removal_delay[i], 1, i);
1685
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 ubs(length, nal_initial_cpb_removal_offset[i], 1, i);
1686
1687
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9 times.
30 if (hrd->sub_pic_hrd_params_present_flag ||
1688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
12 current->irap_cpb_params_present_flag) {
1689
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 ubs(length, nal_initial_alt_cpb_removal_delay[i], 1, i);
1690
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 ubs(length, nal_initial_alt_cpb_removal_offset[i], 1, i);
1691 }
1692 }
1693 }
1694
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 if (hrd->vcl_hrd_parameters_present_flag) {
1695
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 15 times.
60 for (i = 0; i <= hrd->cpb_cnt_minus1[0]; i++) {
1696 30 length = hrd->initial_cpb_removal_delay_length_minus1 + 1;
1697
1698
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 ubs(length, vcl_initial_cpb_removal_delay[i], 1, i);
1699
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 ubs(length, vcl_initial_cpb_removal_offset[i], 1, i);
1700
1701
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9 times.
30 if (hrd->sub_pic_hrd_params_present_flag ||
1702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
12 current->irap_cpb_params_present_flag) {
1703
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 ubs(length, vcl_initial_alt_cpb_removal_delay[i], 1, i);
1704
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 ubs(length, vcl_initial_alt_cpb_removal_offset[i], 1, i);
1705 }
1706 }
1707 }
1708
1709 #ifdef READ
1710 10 end_pos = get_bits_count(rw);
1711
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
10 if (cbs_h265_payload_extension_present(rw, sei->payload_size,
1712 end_pos - start_pos))
1713 flag(use_alt_cpb_params_flag);
1714 else
1715 10 infer(use_alt_cpb_params_flag, 0);
1716 #else
1717 // If unknown extension data exists, then use_alt_cpb_params_flag is
1718 // coded in the bitstream and must be written even if it's 0.
1719
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
20 if (current->use_alt_cpb_params_flag || sei->extension_present) {
1720 flag(use_alt_cpb_params_flag);
1721 // Ensure this bit is not the last in the payload by making the
1722 // more_data_in_payload() check evaluate to true, so it may not
1723 // be mistaken as something else by decoders.
1724 sei->extension_present = 1;
1725 }
1726 #endif
1727
1728 30 return 0;
1729 }
1730
1731 936 static int FUNC(sei_pic_timing)
1732 (CodedBitstreamContext *ctx, RWContext *rw,
1733 H265RawSEIPicTiming *current, SEIMessageState *sei)
1734 {
1735 936 CodedBitstreamH265Context *h265 = ctx->priv_data;
1736 const H265RawSPS *sps;
1737 const H265RawHRDParameters *hrd;
1738 int err, expected_source_scan_type, i, length;
1739
1740 936 HEADER("Picture Timing");
1741
1742 936 sps = h265->active_sps;
1743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
936 if (!sps) {
1744 av_log(ctx->log_ctx, AV_LOG_ERROR,
1745 "No active SPS for pic_timing.\n");
1746 return AVERROR_INVALIDDATA;
1747 }
1748
1749 936 expected_source_scan_type = 2 -
1750 936 2 * sps->profile_tier_level.general_interlaced_source_flag -
1751 936 sps->profile_tier_level.general_progressive_source_flag;
1752
1753
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 288 times.
936 if (sps->vui.frame_field_info_present_flag) {
1754
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
360 u(4, pic_struct, 0, 12);
1755
2/4
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 180 times.
360 u(2, source_scan_type,
1756 expected_source_scan_type >= 0 ? expected_source_scan_type : 0,
1757 expected_source_scan_type >= 0 ? expected_source_scan_type : 2);
1758
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
360 flag(duplicate_flag);
1759 } else {
1760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
576 infer(pic_struct, 0);
1761
2/6
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
576 infer(source_scan_type,
1762 expected_source_scan_type >= 0 ? expected_source_scan_type : 2);
1763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
576 infer(duplicate_flag, 0);
1764 }
1765
1766
1/2
✓ Branch 0 taken 468 times.
✗ Branch 1 not taken.
936 if (sps->vui_parameters_present_flag &&
1767
1/2
✓ Branch 0 taken 468 times.
✗ Branch 1 not taken.
936 sps->vui.vui_hrd_parameters_present_flag)
1768 936 hrd = &sps->vui.hrd_parameters;
1769 else
1770 hrd = NULL;
1771
2/4
✓ Branch 0 taken 468 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
936 if (hrd && (hrd->nal_hrd_parameters_present_flag ||
1772 hrd->vcl_hrd_parameters_present_flag)) {
1773 936 length = hrd->au_cpb_removal_delay_length_minus1 + 1;
1774
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 468 times.
936 ub(length, au_cpb_removal_delay_minus1);
1775
1776 936 length = hrd->dpb_output_delay_length_minus1 + 1;
1777
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 468 times.
936 ub(length, pic_dpb_output_delay);
1778
1779
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 180 times.
936 if (hrd->sub_pic_hrd_params_present_flag) {
1780 576 length = hrd->dpb_output_delay_du_length_minus1 + 1;
1781
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 288 times.
576 ub(length, pic_dpb_output_du_delay);
1782 }
1783
1784
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 180 times.
936 if (hrd->sub_pic_hrd_params_present_flag &&
1785
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
576 hrd->sub_pic_cpb_params_in_pic_timing_sei_flag) {
1786 // Each decoding unit must contain at least one slice segment.
1787
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 288 times.
576 ue(num_decoding_units_minus1, 0, HEVC_MAX_SLICE_SEGMENTS);
1788
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 288 times.
576 flag(du_common_cpb_removal_delay_flag);
1789
1790 576 length = hrd->du_cpb_removal_delay_increment_length_minus1 + 1;
1791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
576 if (current->du_common_cpb_removal_delay_flag)
1792 ub(length, du_common_cpb_removal_delay_increment_minus1);
1793
1794
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 288 times.
2880 for (i = 0; i <= current->num_decoding_units_minus1; i++) {
1795
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1152 times.
2304 ues(num_nalus_in_du_minus1[i],
1796 0, HEVC_MAX_SLICE_SEGMENTS, 1, i);
1797
1/2
✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
2304 if (!current->du_common_cpb_removal_delay_flag &&
1798
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 288 times.
2304 i < current->num_decoding_units_minus1)
1799
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
1728 ubs(length, du_cpb_removal_delay_increment_minus1[i], 1, i);
1800 }
1801 }
1802 }
1803
1804 936 return 0;
1805 }
1806
1807 static int FUNC(sei_pan_scan_rect)
1808 (CodedBitstreamContext *ctx, RWContext *rw,
1809 H265RawSEIPanScanRect *current, SEIMessageState *sei)
1810 {
1811 int err, i;
1812
1813 HEADER("Pan-Scan Rectangle");
1814
1815 ue(pan_scan_rect_id, 0, UINT32_MAX - 1);
1816 flag(pan_scan_rect_cancel_flag);
1817
1818 if (!current->pan_scan_rect_cancel_flag) {
1819 ue(pan_scan_cnt_minus1, 0, 2);
1820
1821 for (i = 0; i <= current->pan_scan_cnt_minus1; i++) {
1822 ses(pan_scan_rect_left_offset[i], INT32_MIN + 1, INT32_MAX, 1, i);
1823 ses(pan_scan_rect_right_offset[i], INT32_MIN + 1, INT32_MAX, 1, i);
1824 ses(pan_scan_rect_top_offset[i], INT32_MIN + 1, INT32_MAX, 1, i);
1825 ses(pan_scan_rect_bottom_offset[i], INT32_MIN + 1, INT32_MAX, 1, i);
1826 }
1827
1828 flag(pan_scan_rect_persistence_flag);
1829 }
1830
1831 return 0;
1832 }
1833
1834 30 static int FUNC(sei_recovery_point)
1835 (CodedBitstreamContext *ctx, RWContext *rw,
1836 H265RawSEIRecoveryPoint *current, SEIMessageState *sei)
1837 {
1838 int err;
1839
1840 30 HEADER("Recovery Point");
1841
1842
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 se(recovery_poc_cnt, -32768, 32767);
1843
1844
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 flag(exact_match_flag);
1845
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 flag(broken_link_flag);
1846
1847 30 return 0;
1848 }
1849
1850 static int FUNC(film_grain_characteristics)(CodedBitstreamContext *ctx, RWContext *rw,
1851 H265RawFilmGrainCharacteristics *current,
1852 SEIMessageState *state)
1853 {
1854 CodedBitstreamH265Context *h265 = ctx->priv_data;
1855 const H265RawSPS *sps = h265->active_sps;
1856 int err, c, i, j;
1857
1858 HEADER("Film Grain Characteristics");
1859
1860 flag(film_grain_characteristics_cancel_flag);
1861 if (!current->film_grain_characteristics_cancel_flag) {
1862 int filmGrainBitDepth[3];
1863
1864 u(2, film_grain_model_id, 0, 1);
1865 flag(separate_colour_description_present_flag);
1866 if (current->separate_colour_description_present_flag) {
1867 ub(3, film_grain_bit_depth_luma_minus8);
1868 ub(3, film_grain_bit_depth_chroma_minus8);
1869 flag(film_grain_full_range_flag);
1870 ub(8, film_grain_colour_primaries);
1871 ub(8, film_grain_transfer_characteristics);
1872 ub(8, film_grain_matrix_coeffs);
1873 } else {
1874 if (!sps) {
1875 av_log(ctx->log_ctx, AV_LOG_ERROR,
1876 "No active SPS for film_grain_characteristics.\n");
1877 return AVERROR_INVALIDDATA;
1878 }
1879 infer(film_grain_bit_depth_luma_minus8, sps->bit_depth_luma_minus8);
1880 infer(film_grain_bit_depth_chroma_minus8, sps->bit_depth_chroma_minus8);
1881 infer(film_grain_full_range_flag, sps->vui.video_full_range_flag);
1882 infer(film_grain_colour_primaries, sps->vui.colour_primaries);
1883 infer(film_grain_transfer_characteristics, sps->vui.transfer_characteristics);
1884 infer(film_grain_matrix_coeffs, sps->vui.matrix_coefficients);
1885 }
1886
1887 filmGrainBitDepth[0] = current->film_grain_bit_depth_luma_minus8 + 8;
1888 filmGrainBitDepth[1] =
1889 filmGrainBitDepth[2] = current->film_grain_bit_depth_chroma_minus8 + 8;
1890
1891 u(2, blending_mode_id, 0, 1);
1892 ub(4, log2_scale_factor);
1893 for (c = 0; c < 3; c++)
1894 flags(comp_model_present_flag[c], 1, c);
1895 for (c = 0; c < 3; c++) {
1896 if (current->comp_model_present_flag[c]) {
1897 ubs(8, num_intensity_intervals_minus1[c], 1, c);
1898 us(3, num_model_values_minus1[c], 0, 5, 1, c);
1899 for (i = 0; i <= current->num_intensity_intervals_minus1[c]; i++) {
1900 ubs(8, intensity_interval_lower_bound[c][i], 2, c, i);
1901 ubs(8, intensity_interval_upper_bound[c][i], 2, c, i);
1902 for (j = 0; j <= current->num_model_values_minus1[c]; j++)
1903 ses(comp_model_value[c][i][j], 0 - current->film_grain_model_id * (1 << (filmGrainBitDepth[c] - 1)),
1904 ((1 << filmGrainBitDepth[c]) - 1) - current->film_grain_model_id * (1 << (filmGrainBitDepth[c] - 1)),
1905 3, c, i, j);
1906 }
1907 }
1908 }
1909 flag(film_grain_characteristics_persistence_flag);
1910 }
1911
1912 return 0;
1913 }
1914
1915 static int FUNC(sei_display_orientation)
1916 (CodedBitstreamContext *ctx, RWContext *rw,
1917 H265RawSEIDisplayOrientation *current, SEIMessageState *sei)
1918 {
1919 int err;
1920
1921 HEADER("Display Orientation");
1922
1923 flag(display_orientation_cancel_flag);
1924 if (!current->display_orientation_cancel_flag) {
1925 flag(hor_flip);
1926 flag(ver_flip);
1927 ub(16, anticlockwise_rotation);
1928 flag(display_orientation_persistence_flag);
1929 }
1930
1931 return 0;
1932 }
1933
1934 18 static int FUNC(sei_active_parameter_sets)
1935 (CodedBitstreamContext *ctx, RWContext *rw,
1936 H265RawSEIActiveParameterSets *current, SEIMessageState *sei)
1937 {
1938 18 CodedBitstreamH265Context *h265 = ctx->priv_data;
1939 const H265RawVPS *vps;
1940 int err, i;
1941
1942 18 HEADER("Active Parameter Sets");
1943
1944
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 u(4, active_video_parameter_set_id, 0, HEVC_MAX_VPS_COUNT);
1945 18 vps = h265->vps[current->active_video_parameter_set_id];
1946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
18 if (!vps) {
1947 av_log(ctx->log_ctx, AV_LOG_ERROR, "VPS id %d not available for active "
1948 "parameter sets.\n", current->active_video_parameter_set_id);
1949 return AVERROR_INVALIDDATA;
1950 }
1951 18 h265->active_vps = vps;
1952
1953
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 flag(self_contained_cvs_flag);
1954
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 flag(no_parameter_set_update_flag);
1955
1956
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 ue(num_sps_ids_minus1, 0, HEVC_MAX_SPS_COUNT - 1);
1957
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
36 for (i = 0; i <= current->num_sps_ids_minus1; i++)
1958
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 ues(active_seq_parameter_set_id[i], 0, HEVC_MAX_SPS_COUNT - 1, 1, i);
1959
1960 18 for (i = vps->vps_base_layer_internal_flag;
1961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
18 i <= FFMIN(62, vps->vps_max_layers_minus1); i++) {
1962 ues(layer_sps_idx[i], 0, current->num_sps_ids_minus1, 1, i);
1963
1964 if (i == 0)
1965 h265->active_sps = h265->sps[current->active_seq_parameter_set_id[current->layer_sps_idx[0]]];
1966 }
1967
1968 18 return 0;
1969 }
1970
1971 8196 static int FUNC(sei_decoded_picture_hash)
1972 (CodedBitstreamContext *ctx, RWContext *rw,
1973 H265RawSEIDecodedPictureHash *current, SEIMessageState *sei)
1974 {
1975 8196 CodedBitstreamH265Context *h265 = ctx->priv_data;
1976 8196 const H265RawSPS *sps = h265->active_sps;
1977 int err, c, i;
1978
1979 8196 HEADER("Decoded Picture Hash");
1980
1981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4098 times.
8196 if (!sps) {
1982 av_log(ctx->log_ctx, AV_LOG_ERROR,
1983 "No active SPS for decoded picture hash.\n");
1984 return AVERROR_INVALIDDATA;
1985 }
1986
1987
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4098 times.
8196 u(8, hash_type, 0, 2);
1988
1989
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16392 times.
✓ Branch 2 taken 12294 times.
✓ Branch 3 taken 4098 times.
32784 for (c = 0; c < (sps->chroma_format_idc == 0 ? 1 : 3); c++) {
1990
2/2
✓ Branch 0 taken 11250 times.
✓ Branch 1 taken 1044 times.
24588 if (current->hash_type == 0) {
1991
2/2
✓ Branch 0 taken 180000 times.
✓ Branch 1 taken 11250 times.
382500 for (i = 0; i < 16; i++)
1992
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 180000 times.
360000 us(8, picture_md5[c][i], 0x00, 0xff, 2, c, i);
1993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1044 times.
2088 } else if (current->hash_type == 1) {
1994 us(16, picture_crc[c], 0x0000, 0xffff, 1, c);
1995
1/2
✓ Branch 0 taken 1044 times.
✗ Branch 1 not taken.
2088 } else if (current->hash_type == 2) {
1996
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1044 times.
2088 us(32, picture_checksum[c], 0x00000000, 0xffffffff, 1, c);
1997 }
1998 }
1999
2000 8196 return 0;
2001 }
2002
2003 static int FUNC(sei_time_code)
2004 (CodedBitstreamContext *ctx, RWContext *rw,
2005 H265RawSEITimeCode *current, SEIMessageState *sei)
2006 {
2007 int err, i;
2008
2009 HEADER("Time Code");
2010
2011 u(2, num_clock_ts, 1, 3);
2012
2013 for (i = 0; i < current->num_clock_ts; i++) {
2014 flags(clock_timestamp_flag[i], 1, i);
2015
2016 if (current->clock_timestamp_flag[i]) {
2017 flags(units_field_based_flag[i], 1, i);
2018 us(5, counting_type[i], 0, 6, 1, i);
2019 flags(full_timestamp_flag[i], 1, i);
2020 flags(discontinuity_flag[i], 1, i);
2021 flags(cnt_dropped_flag[i], 1, i);
2022
2023 ubs(9, n_frames[i], 1, i);
2024
2025 if (current->full_timestamp_flag[i]) {
2026 us(6, seconds_value[i], 0, 59, 1, i);
2027 us(6, minutes_value[i], 0, 59, 1, i);
2028 us(5, hours_value[i], 0, 23, 1, i);
2029 } else {
2030 flags(seconds_flag[i], 1, i);
2031 if (current->seconds_flag[i]) {
2032 us(6, seconds_value[i], 0, 59, 1, i);
2033 flags(minutes_flag[i], 1, i);
2034 if (current->minutes_flag[i]) {
2035 us(6, minutes_value[i], 0, 59, 1, i);
2036 flags(hours_flag[i], 1, i);
2037 if (current->hours_flag[i])
2038 us(5, hours_value[i], 0, 23, 1, i);
2039 }
2040 }
2041 }
2042
2043 ubs(5, time_offset_length[i], 1, i);
2044 if (current->time_offset_length[i] > 0)
2045 ibs(current->time_offset_length[i], time_offset_value[i], 1, i);
2046 else
2047 infer(time_offset_value[i], 0);
2048 }
2049 }
2050
2051 return 0;
2052 }
2053
2054 static int FUNC(sei_alpha_channel_info)
2055 (CodedBitstreamContext *ctx, RWContext *rw,
2056 H265RawSEIAlphaChannelInfo *current, SEIMessageState *sei)
2057 {
2058 int err, length;
2059
2060 HEADER("Alpha Channel Information");
2061
2062 flag(alpha_channel_cancel_flag);
2063 if (!current->alpha_channel_cancel_flag) {
2064 ub(3, alpha_channel_use_idc);
2065 ub(3, alpha_channel_bit_depth_minus8);
2066 length = current->alpha_channel_bit_depth_minus8 + 9;
2067 ub(length, alpha_transparent_value);
2068 ub(length, alpha_opaque_value);
2069 flag(alpha_channel_incr_flag);
2070 flag(alpha_channel_clip_flag);
2071 if (current->alpha_channel_clip_flag)
2072 flag(alpha_channel_clip_type_flag);
2073 } else {
2074 infer(alpha_channel_use_idc, 2);
2075 infer(alpha_channel_incr_flag, 0);
2076 infer(alpha_channel_clip_flag, 0);
2077 }
2078
2079 return 0;
2080 }
2081
2082 3070 static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw,
2083 H265RawSEI *current, int prefix)
2084 {
2085 int err;
2086
2087 3070 if (prefix)
2088 338 HEADER("Prefix Supplemental Enhancement Information");
2089 else
2090 2732 HEADER("Suffix Supplemental Enhancement Information");
2091
2092 3070 CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
2093 prefix ? HEVC_NAL_SEI_PREFIX
2094 : HEVC_NAL_SEI_SUFFIX));
2095
2096 3070 CHECK(FUNC_SEI(message_list)(ctx, rw, &current->message_list, prefix));
2097
2098 3070 CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
2099
2100 3070 return 0;
2101 }
2102