FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/cbs_h265_syntax_template.c
Date: 2026-09-26 20:14:34
Exec Total Coverage
Lines: 844 1387 60.9%
Functions: 56 98 57.1%
Branches: 894 2365 37.8%

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 9054 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 4527 times.
9054 fixed(1, rbsp_stop_one_bit, 1);
24
2/2
✓ Branch 1 taken 27855 times.
✓ Branch 2 taken 4527 times.
64764 while (byte_alignment(rw) != 0)
25
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 27855 times.
55710 fixed(1, rbsp_alignment_zero_bit, 0);
26
27 9054 return 0;
28 }
29
30 36230 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 18115 times.
36230 fixed(1, forbidden_zero_bit, 0);
37
38
2/2
✓ Branch 0 taken 4527 times.
✓ Branch 1 taken 13588 times.
36230 if (expected_nal_unit_type >= 0)
39
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4527 times.
9054 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 13588 times.
27176 ub(6, nal_unit_type);
43
44
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 18115 times.
36230 u(6, nuh_layer_id, 0, 62);
45
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 18115 times.
36230 u(3, nuh_temporal_id_plus1, 1, 7);
46
47 36230 return 0;
48 }
49
50 27176 static int FUNC(byte_alignment)(CodedBitstreamContext *ctx, RWContext *rw)
51 {
52 int err;
53
54
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 13588 times.
27176 fixed(1, alignment_bit_equal_to_one, 1);
55
2/2
✓ Branch 1 taken 54397 times.
✓ Branch 2 taken 13588 times.
135970 while (byte_alignment(rw) != 0)
56
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 54397 times.
108794 fixed(1, alignment_bit_equal_to_zero, 0);
57
58 27176 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; ff_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 540 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 270 times.
✗ Branch 1 not taken.
540 if (profile_present_flag) {
96
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
540 u(2, general_profile_space, 0, 0);
97
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
540 flag(general_tier_flag);
98
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
540 ub(5, general_profile_idc);
99
100
2/2
✓ Branch 0 taken 8640 times.
✓ Branch 1 taken 270 times.
17820 for (j = 0; j < 32; j++)
101
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8640 times.
17280 flags(general_profile_compatibility_flag[j], 1, j);
102
103
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
540 flag(general_progressive_source_flag);
104
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
540 flag(general_interlaced_source_flag);
105
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
540 flag(general_non_packed_constraint_flag);
106
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
540 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 270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 270 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 270 times.
✗ Branch 7 not taken.
540 if (profile_compatible(4) || profile_compatible(5) ||
111
4/8
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 270 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 270 times.
✗ Branch 7 not taken.
540 profile_compatible(6) || profile_compatible(7) ||
112
4/8
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 270 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 270 times.
✗ Branch 7 not taken.
540 profile_compatible(8) || profile_compatible(9) ||
113
4/8
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 270 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 270 times.
540 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
4/4
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 182 times.
✓ Branch 3 taken 56 times.
540 } else if (profile_compatible(2)) {
134
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 214 times.
428 fixed(7, general_reserved_zero_7bits, 0);
135
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 214 times.
428 flag(general_one_picture_only_constraint_flag);
136
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 214 times.
428 fixed(24, general_reserved_zero_35bits, 0);
137
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 214 times.
428 fixed(11, general_reserved_zero_35bits, 0);
138 } else {
139
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
112 fixed(24, general_reserved_zero_43bits, 0);
140
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
112 fixed(19, general_reserved_zero_43bits, 0);
141 }
142
143
4/8
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 238 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 32 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
540 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 270 times.
540 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 270 times.
540 ub(8, general_level_idc);
155
156
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 270 times.
732 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 222 times.
540 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 270 times.
732 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 540 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 124 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 62 times.
124 flag(aspect_ratio_info_present_flag);
328
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 28 times.
124 if (current->aspect_ratio_info_present_flag) {
329
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
68 ub(8, aspect_ratio_idc);
330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
68 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 16 times.
56 infer(aspect_ratio_idc, 0);
336 }
337
338
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
124 flag(overscan_info_present_flag);
339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
124 if (current->overscan_info_present_flag)
340 ✗ flag(overscan_appropriate_flag);
341
342
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
124 flag(video_signal_type_present_flag);
343
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 58 times.
124 if (current->video_signal_type_present_flag) {
344
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ub(3, video_format);
345
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 flag(video_full_range_flag);
346
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 flag(colour_description_present_flag);
347
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 if (current->colour_description_present_flag) {
348
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ub(8, colour_primaries);
349
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ub(8, transfer_characteristics);
350
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 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 29 times.
116 infer(video_format, 5);
358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
116 infer(video_full_range_flag, 0);
359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
116 infer(colour_primaries, 2);
360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
116 infer(transfer_characteristics, 2);
361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
116 infer(matrix_coefficients, 2);
362 }
363
364
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
124 flag(chroma_loc_info_present_flag);
365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
124 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 33 times.
124 infer(chroma_sample_loc_type_top_field, 0);
370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
124 infer(chroma_sample_loc_type_bottom_field, 0);
371 }
372
373
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
124 flag(neutral_chroma_indication_flag);
374
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
124 flag(field_seq_flag);
375
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
124 flag(frame_field_info_present_flag);
376
377
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
124 flag(default_display_window_flag);
378
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 34 times.
124 if (current->default_display_window_flag) {
379
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
56 ue(def_disp_win_left_offset, 0, 16384);
380
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
56 ue(def_disp_win_right_offset, 0, 16384);
381
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
56 ue(def_disp_win_top_offset, 0, 16384);
382
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
56 ue(def_disp_win_bottom_offset, 0, 16384);
383 }
384
385
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
124 flag(vui_timing_info_present_flag);
386
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 48 times.
124 if (current->vui_timing_info_present_flag) {
387
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
28 u(32, vui_num_units_in_tick, 1, UINT32_MAX);
388
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
28 u(32, vui_time_scale, 1, UINT32_MAX);
389
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
28 flag(vui_poc_proportional_to_timing_flag);
390
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 10 times.
28 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 14 times.
28 flag(vui_hrd_parameters_present_flag);
394
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6 times.
28 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 62 times.
124 flag(bitstream_restriction_flag);
401
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 38 times.
124 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 21 times.
76 infer(tiles_fixed_structure_flag, 0);
412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
76 infer(motion_vectors_over_pic_boundaries_flag, 1);
413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
76 infer(min_spatial_segmentation_idc, 0);
414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
76 infer(max_bytes_per_pic_denom, 2);
415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
76 infer(max_bits_per_min_cu_denom, 1);
416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
76 infer(log2_max_mv_length_horizontal, 15);
417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
76 infer(log2_max_mv_length_vertical, 15);
418 }
419
420 124 return 0;
421 }
422
423 264 static int FUNC(vps)(CodedBitstreamContext *ctx, RWContext *rw,
424 H265RawVPS *current)
425 {
426 int err, i, j;
427
428 264 HEADER("Video Parameter Set");
429
430
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
264 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 132 times.
264 ub(4, vps_video_parameter_set_id);
433
434
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
264 flag(vps_base_layer_internal_flag);
435
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
264 flag(vps_base_layer_available_flag);
436
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
264 u(6, vps_max_layers_minus1, 0, HEVC_MAX_LAYERS - 1);
437
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
264 u(3, vps_max_sub_layers_minus1, 0, HEVC_MAX_SUB_LAYERS - 1);
438
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
264 flag(vps_temporal_id_nesting_flag);
439
440
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 24 times.
264 if (current->vps_max_sub_layers_minus1 == 0 &&
441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
216 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 132 times.
264 fixed(16, vps_reserved_0xffff_16bits, 0xffff);
449
450
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
264 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 132 times.
264 flag(vps_sub_layer_ordering_info_present_flag);
454 264 for (i = (current->vps_sub_layer_ordering_info_present_flag ?
455
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 108 times.
264 0 : current->vps_max_sub_layers_minus1);
456
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 132 times.
544 i <= current->vps_max_sub_layers_minus1; i++) {
457
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
280 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 140 times.
280 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 140 times.
280 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 108 times.
264 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 132 times.
264 u(6, vps_max_layer_id, 0, HEVC_MAX_LAYERS - 1);
476
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
264 ue(vps_num_layer_sets_minus1, 0, HEVC_MAX_LAYER_SETS - 1);
477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
264 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 132 times.
✓ Branch 1 taken 132 times.
528 for (j = 0; j <= current->vps_max_layer_id; j++)
482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
264 infer(layer_id_included_flag[0][j], j == 0);
483
484
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
264 flag(vps_timing_info_present_flag);
485
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 128 times.
264 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 if (current->vps_num_hrd_parameters > 0)
493 ✗ allocate(current->hrd_parameters,
494 current->vps_num_hrd_parameters *
495 sizeof(*current->hrd_parameters));
496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
8 for (i = 0; i < current->vps_num_hrd_parameters; i++) {
497 ✗ ues(hrd_layer_set_idx[i],
498 current->vps_base_layer_internal_flag ? 0 : 1,
499 current->vps_num_layer_sets_minus1, 1, i);
500 ✗ if (i > 0)
501 ✗ flags(cprms_present_flag[i], 1, i);
502 else
503 ✗ infer(cprms_present_flag[0], 1);
504
505 ✗ CHECK(FUNC(hrd_parameters)(ctx, rw, &current->hrd_parameters[i],
506 current->cprms_present_flag[i],
507 current->vps_max_sub_layers_minus1));
508 }
509 }
510
511
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
264 flag(vps_extension_flag);
512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
264 if (current->vps_extension_flag)
513 ✗ CHECK(FUNC(extension_data)(ctx, rw, &current->extension_data));
514
515
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
264 CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
516
517 264 return 0;
518 }
519
520 9954 static int FUNC(st_ref_pic_set)(CodedBitstreamContext *ctx, RWContext *rw,
521 H265RawSTRefPicSet *current, int st_rps_idx,
522 const H265RawSPS *sps)
523 {
524 int err, i, j;
525
526
2/2
✓ Branch 0 taken 4793 times.
✓ Branch 1 taken 184 times.
9954 if (st_rps_idx != 0)
527
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4793 times.
9586 flag(inter_ref_pic_set_prediction_flag);
528 else
529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
368 infer(inter_ref_pic_set_prediction_flag, 0);
530
531
2/2
✓ Branch 0 taken 1368 times.
✓ Branch 1 taken 3609 times.
9954 if (current->inter_ref_pic_set_prediction_flag) {
532 unsigned int ref_rps_idx, num_delta_pocs, num_ref_pics;
533 const H265RawSTRefPicSet *ref;
534 int delta_rps, d_poc;
535 int ref_delta_poc_s0[HEVC_MAX_REFS], ref_delta_poc_s1[HEVC_MAX_REFS];
536 int delta_poc_s0[HEVC_MAX_REFS], delta_poc_s1[HEVC_MAX_REFS];
537 uint8_t used_by_curr_pic_s0[HEVC_MAX_REFS],
538 used_by_curr_pic_s1[HEVC_MAX_REFS];
539
540
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 940 times.
2736 if (st_rps_idx == sps->num_short_term_ref_pic_sets)
541
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 428 times.
856 ue(delta_idx_minus1, 0, st_rps_idx - 1);
542 else
543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
1880 infer(delta_idx_minus1, 0);
544
545 2736 ref_rps_idx = st_rps_idx - (current->delta_idx_minus1 + 1);
546 2736 ref = &sps->st_ref_pic_set[ref_rps_idx];
547 2736 num_delta_pocs = ref->num_negative_pics + ref->num_positive_pics;
548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
2736 av_assert0(num_delta_pocs < HEVC_MAX_DPB_SIZE);
549
550
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1368 times.
2736 flag(delta_rps_sign);
551
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1368 times.
2736 ue(abs_delta_rps_minus1, 0, INT16_MAX);
552 2736 delta_rps = (1 - 2 * current->delta_rps_sign) *
553 2736 (current->abs_delta_rps_minus1 + 1);
554
555 2736 num_ref_pics = 0;
556
2/2
✓ Branch 0 taken 6002 times.
✓ Branch 1 taken 1368 times.
14740 for (j = 0; j <= num_delta_pocs; j++) {
557
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6002 times.
12004 flags(used_by_curr_pic_flag[j], 1, j);
558
2/2
✓ Branch 0 taken 1367 times.
✓ Branch 1 taken 4635 times.
12004 if (!current->used_by_curr_pic_flag[j])
559
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1367 times.
2734 flags(use_delta_flag[j], 1, j);
560 else
561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2129 times.
9270 infer(use_delta_flag[j], 1);
562
2/2
✓ Branch 0 taken 4635 times.
✓ Branch 1 taken 1367 times.
12004 if (current->use_delta_flag[j])
563 9270 ++num_ref_pics;
564 }
565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1368 times.
2736 if (num_ref_pics >= HEVC_MAX_DPB_SIZE) {
566 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
567 "short-term ref pic set %d "
568 "contains too many pictures.\n", st_rps_idx);
569 ✗ return AVERROR_INVALIDDATA;
570 }
571
572 // Since the stored form of an RPS here is actually the delta-step
573 // form used when inter_ref_pic_set_prediction_flag is not set, we
574 // need to reconstruct that here in order to be able to refer to
575 // the RPS later (which is required for parsing, because we don't
576 // even know what syntax elements appear without it). Therefore,
577 // this code takes the delta-step form of the reference set, turns
578 // it into the delta-array form, applies the prediction process of
579 // 7.4.8, converts the result back to the delta-step form, and
580 // stores that as the current set for future use. Note that the
581 // inferences here mean that writers using prediction will need
582 // to fill in the delta-step values correctly as well - since the
583 // whole RPS prediction process is somewhat overly sophisticated,
584 // this hopefully forms a useful check for them to ensure their
585 // predicted form actually matches what was intended rather than
586 // an onerous additional requirement.
587
588 2736 d_poc = 0;
589
2/2
✓ Branch 0 taken 3040 times.
✓ Branch 1 taken 1368 times.
8816 for (i = 0; i < ref->num_negative_pics; i++) {
590 6080 d_poc -= ref->delta_poc_s0_minus1[i] + 1;
591 6080 ref_delta_poc_s0[i] = d_poc;
592 }
593 2736 d_poc = 0;
594
2/2
✓ Branch 0 taken 1594 times.
✓ Branch 1 taken 1368 times.
5924 for (i = 0; i < ref->num_positive_pics; i++) {
595 3188 d_poc += ref->delta_poc_s1_minus1[i] + 1;
596 3188 ref_delta_poc_s1[i] = d_poc;
597 }
598
599 2736 i = 0;
600
2/2
✓ Branch 0 taken 1594 times.
✓ Branch 1 taken 1368 times.
5924 for (j = ref->num_positive_pics - 1; j >= 0; j--) {
601 3188 d_poc = ref_delta_poc_s1[j] + delta_rps;
602
3/4
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 1188 times.
✓ Branch 2 taken 406 times.
✗ Branch 3 not taken.
3188 if (d_poc < 0 && current->use_delta_flag[ref->num_negative_pics + j]) {
603 812 delta_poc_s0[i] = d_poc;
604 812 used_by_curr_pic_s0[i++] =
605 812 current->used_by_curr_pic_flag[ref->num_negative_pics + j];
606 }
607 }
608
4/4
✓ Branch 0 taken 662 times.
✓ Branch 1 taken 706 times.
✓ Branch 2 taken 236 times.
✓ Branch 3 taken 426 times.
2736 if (delta_rps < 0 && current->use_delta_flag[num_delta_pocs]) {
609 472 delta_poc_s0[i] = delta_rps;
610 472 used_by_curr_pic_s0[i++] =
611 472 current->used_by_curr_pic_flag[num_delta_pocs];
612 }
613
2/2
✓ Branch 0 taken 3040 times.
✓ Branch 1 taken 1368 times.
8816 for (j = 0; j < ref->num_negative_pics; j++) {
614 6080 d_poc = ref_delta_poc_s0[j] + delta_rps;
615
3/4
✓ Branch 0 taken 3040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2224 times.
✓ Branch 3 taken 816 times.
6080 if (d_poc < 0 && current->use_delta_flag[j]) {
616 4448 delta_poc_s0[i] = d_poc;
617 4448 used_by_curr_pic_s0[i++] = current->used_by_curr_pic_flag[j];
618 }
619 }
620
621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626 times.
2736 infer(num_negative_pics, i);
622
2/2
✓ Branch 0 taken 2866 times.
✓ Branch 1 taken 1368 times.
8468 for (i = 0; i < current->num_negative_pics; i++) {
623
3/6
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 1314 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1328 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5732 infer(delta_poc_s0_minus1[i],
624 -(delta_poc_s0[i] - (i == 0 ? 0 : delta_poc_s0[i - 1])) - 1);
625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1328 times.
5732 infer(used_by_curr_pic_s0_flag[i], used_by_curr_pic_s0[i]);
626 }
627
628 2736 i = 0;
629
2/2
✓ Branch 0 taken 3040 times.
✓ Branch 1 taken 1368 times.
8816 for (j = ref->num_negative_pics - 1; j >= 0; j--) {
630 6080 d_poc = ref_delta_poc_s0[j] + delta_rps;
631
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3040 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6080 if (d_poc > 0 && current->use_delta_flag[j]) {
632 ✗ delta_poc_s1[i] = d_poc;
633 ✗ used_by_curr_pic_s1[i++] = current->used_by_curr_pic_flag[j];
634 }
635 }
636
4/4
✓ Branch 0 taken 706 times.
✓ Branch 1 taken 662 times.
✓ Branch 2 taken 683 times.
✓ Branch 3 taken 23 times.
2736 if (delta_rps > 0 && current->use_delta_flag[num_delta_pocs]) {
637 1366 delta_poc_s1[i] = delta_rps;
638 1366 used_by_curr_pic_s1[i++] =
639 1366 current->used_by_curr_pic_flag[num_delta_pocs];
640 }
641
2/2
✓ Branch 0 taken 1594 times.
✓ Branch 1 taken 1368 times.
5924 for (j = 0; j < ref->num_positive_pics; j++) {
642 3188 d_poc = ref_delta_poc_s1[j] + delta_rps;
643
4/4
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 406 times.
✓ Branch 2 taken 1086 times.
✓ Branch 3 taken 102 times.
3188 if (d_poc > 0 && current->use_delta_flag[ref->num_negative_pics + j]) {
644 2172 delta_poc_s1[i] = d_poc;
645 2172 used_by_curr_pic_s1[i++] =
646 2172 current->used_by_curr_pic_flag[ref->num_negative_pics + j];
647 }
648 }
649
650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626 times.
2736 infer(num_positive_pics, i);
651
2/2
✓ Branch 0 taken 1769 times.
✓ Branch 1 taken 1368 times.
6274 for (i = 0; i < current->num_positive_pics; i++) {
652
3/6
✓ Branch 0 taken 705 times.
✓ Branch 1 taken 1064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 801 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3538 infer(delta_poc_s1_minus1[i],
653 delta_poc_s1[i] - (i == 0 ? 0 : delta_poc_s1[i - 1]) - 1);
654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 801 times.
3538 infer(used_by_curr_pic_s1_flag[i], used_by_curr_pic_s1[i]);
655 }
656
657 } else {
658
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3609 times.
7218 ue(num_negative_pics, 0, 15);
659
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3609 times.
7218 ue(num_positive_pics, 0, 15 - current->num_negative_pics);
660
661
2/2
✓ Branch 0 taken 9904 times.
✓ Branch 1 taken 3609 times.
27026 for (i = 0; i < current->num_negative_pics; i++) {
662
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9904 times.
19808 ues(delta_poc_s0_minus1[i], 0, INT16_MAX, 1, i);
663
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9904 times.
19808 flags(used_by_curr_pic_s0_flag[i], 1, i);
664 }
665
666
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 3609 times.
8838 for (i = 0; i < current->num_positive_pics; i++) {
667
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 810 times.
1620 ues(delta_poc_s1_minus1[i], 0, INT16_MAX, 1, i);
668
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 810 times.
1620 flags(used_by_curr_pic_s1_flag[i], 1, i);
669 }
670 }
671
672 9954 return 0;
673 }
674
675 528 static int FUNC(scaling_list_data)(CodedBitstreamContext *ctx, RWContext *rw,
676 H265RawScalingList *current)
677 {
678 int sizeId, matrixId;
679 int err, n, i;
680
681
2/2
✓ Branch 0 taken 1056 times.
✓ Branch 1 taken 264 times.
2640 for (sizeId = 0; sizeId < 4; sizeId++) {
682
4/4
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 4752 times.
✓ Branch 2 taken 5280 times.
✓ Branch 3 taken 1056 times.
12672 for (matrixId = 0; matrixId < 6; matrixId += (sizeId == 3 ? 3 : 1)) {
683
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5280 times.
10560 flags(scaling_list_pred_mode_flag[sizeId][matrixId],
684 2, sizeId, matrixId);
685
2/2
✓ Branch 0 taken 2346 times.
✓ Branch 1 taken 2934 times.
10560 if (!current->scaling_list_pred_mode_flag[sizeId][matrixId]) {
686
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2334 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2346 times.
4692 ues(scaling_list_pred_matrix_id_delta[sizeId][matrixId],
687 0, sizeId == 3 ? matrixId / 3 : matrixId,
688 2, sizeId, matrixId);
689 } else {
690 5868 n = FFMIN(64, 1 << (4 + (sizeId << 1)));
691
2/2
✓ Branch 0 taken 1782 times.
✓ Branch 1 taken 1152 times.
5868 if (sizeId > 1) {
692
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1782 times.
3564 ses(scaling_list_dc_coef_minus8[sizeId - 2][matrixId], -7, +247,
693 2, sizeId - 2, matrixId);
694 }
695
2/2
✓ Branch 0 taken 158400 times.
✓ Branch 1 taken 2934 times.
322668 for (i = 0; i < n; i++) {
696
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 158400 times.
316800 ses(scaling_list_delta_coeff[sizeId][matrixId][i],
697 -128, +127, 3, sizeId, matrixId, i);
698 }
699 }
700 }
701 }
702
703 528 return 0;
704 }
705
706 ✗ static int FUNC(sps_range_extension)(CodedBitstreamContext *ctx, RWContext *rw,
707 H265RawSPS *current)
708 {
709 int err;
710
711 ✗ flag(transform_skip_rotation_enabled_flag);
712 ✗ flag(transform_skip_context_enabled_flag);
713 ✗ flag(implicit_rdpcm_enabled_flag);
714 ✗ flag(explicit_rdpcm_enabled_flag);
715 ✗ flag(extended_precision_processing_flag);
716 ✗ flag(intra_smoothing_disabled_flag);
717 ✗ flag(high_precision_offsets_enabled_flag);
718 ✗ flag(persistent_rice_adaptation_enabled_flag);
719 ✗ flag(cabac_bypass_alignment_enabled_flag);
720
721 ✗ return 0;
722 }
723
724 ✗ static int FUNC(sps_scc_extension)(CodedBitstreamContext *ctx, RWContext *rw,
725 H265RawSPS *current)
726 {
727 int err, comp, i;
728
729 ✗ flag(sps_curr_pic_ref_enabled_flag);
730
731 ✗ flag(palette_mode_enabled_flag);
732 ✗ if (current->palette_mode_enabled_flag) {
733 ✗ ue(palette_max_size, 0, 64);
734 ✗ ue(delta_palette_max_predictor_size, 0, 128);
735
736 ✗ flag(sps_palette_predictor_initializer_present_flag);
737 ✗ if (current->sps_palette_predictor_initializer_present_flag) {
738 ✗ ue(sps_num_palette_predictor_initializer_minus1, 0, 127);
739 ✗ for (comp = 0; comp < (current->chroma_format_idc ? 3 : 1); comp++) {
740 ✗ int bit_depth = comp == 0 ? current->bit_depth_luma_minus8 + 8
741 ✗ : current->bit_depth_chroma_minus8 + 8;
742 ✗ for (i = 0; i <= current->sps_num_palette_predictor_initializer_minus1; i++)
743 ✗ ubs(bit_depth, sps_palette_predictor_initializers[comp][i], 2, comp, i);
744 }
745 }
746 }
747
748 ✗ u(2, motion_vector_resolution_control_idc, 0, 2);
749 ✗ flag(intra_boundary_filtering_disable_flag);
750
751 ✗ return 0;
752 }
753
754 ✗ static int FUNC(sps_multilayer_extension)(CodedBitstreamContext *ctx, RWContext *rw,
755 H265RawSPS *current)
756 {
757 int err;
758
759 ✗ flag(inter_view_mv_vert_constraint_flag);
760
761 ✗ return 0;
762 }
763
764 152 static int FUNC(vui_parameters_default)(CodedBitstreamContext *ctx,
765 RWContext *rw, H265RawVUI *current,
766 H265RawSPS *sps)
767 {
768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(aspect_ratio_idc, 0);
769
770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(video_format, 5);
771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(video_full_range_flag, 0);
772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(colour_primaries, 2);
773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(transfer_characteristics, 2);
774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(matrix_coefficients, 2);
775
776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(chroma_sample_loc_type_top_field, 0);
777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(chroma_sample_loc_type_bottom_field, 0);
778
779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(tiles_fixed_structure_flag, 0);
780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(motion_vectors_over_pic_boundaries_flag, 1);
781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(min_spatial_segmentation_idc, 0);
782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(max_bytes_per_pic_denom, 2);
783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(max_bits_per_min_cu_denom, 1);
784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(log2_max_mv_length_horizontal, 15);
785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
152 infer(log2_max_mv_length_vertical, 15);
786
787 152 return 0;
788 }
789
790 276 static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw,
791 H265RawSPS *current)
792 {
793 276 CodedBitstreamH265Context *h265 = ctx->priv_data;
794 const H265RawVPS *vps;
795 int err, i;
796 unsigned int min_cb_log2_size_y, ctb_log2_size_y,
797 min_cb_size_y, min_tb_log2_size_y;
798 unsigned int multi_layer_ext_sps_flag;
799
800 276 HEADER("Sequence Parameter Set");
801
802
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header, HEVC_NAL_SPS));
803
804
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ub(4, sps_video_parameter_set_id);
805 276 h265->active_vps = vps = h265->vps[current->sps_video_parameter_set_id];
806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
276 if (!vps) {
807 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "VPS id %d not available.\n",
808 ✗ current->sps_video_parameter_set_id);
809 ✗ return AVERROR_INVALIDDATA;
810 }
811
812
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
276 if (current->nal_unit_header.nuh_layer_id == 0)
813
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 u(3, sps_max_sub_layers_minus1, 0, vps->vps_max_sub_layers_minus1);
814 else {
815 ✗ u(3, sps_ext_or_max_sub_layers_minus1, 0, HEVC_MAX_SUB_LAYERS);
816 ✗ infer(sps_max_sub_layers_minus1, current->sps_ext_or_max_sub_layers_minus1 == HEVC_MAX_SUB_LAYERS
817 ? vps->vps_max_sub_layers_minus1
818 : current->sps_ext_or_max_sub_layers_minus1);
819 }
820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
276 multi_layer_ext_sps_flag = current->nal_unit_header.nuh_layer_id &&
821 ✗ current->sps_ext_or_max_sub_layers_minus1 == HEVC_MAX_SUB_LAYERS;
822
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
276 if (!multi_layer_ext_sps_flag) {
823
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 flag(sps_temporal_id_nesting_flag);
824
825
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 24 times.
276 if (vps->vps_temporal_id_nesting_flag &&
826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
228 !current->sps_temporal_id_nesting_flag) {
827 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
828 "sps_temporal_id_nesting_flag must be 1 if "
829 "vps_temporal_id_nesting_flag is 1.\n");
830 ✗ return AVERROR_INVALIDDATA;
831 }
832
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 24 times.
276 if (current->sps_max_sub_layers_minus1 == 0 &&
833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
228 current->sps_temporal_id_nesting_flag != 1) {
834 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
835 "sps_temporal_id_nesting_flag must be 1 if "
836 "sps_max_sub_layers_minus1 is 0.\n");
837 ✗ return AVERROR_INVALIDDATA;
838 }
839
840
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 CHECK(FUNC(profile_tier_level)(ctx, rw, &current->profile_tier_level,
841 1, current->sps_max_sub_layers_minus1));
842 } else {
843 ✗ if (current->sps_max_sub_layers_minus1 > 0)
844 ✗ infer(sps_temporal_id_nesting_flag, vps->vps_temporal_id_nesting_flag);
845 else
846 ✗ infer(sps_temporal_id_nesting_flag, 1);
847 }
848
849
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(sps_seq_parameter_set_id, 0, 15);
850
851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
276 if (multi_layer_ext_sps_flag) {
852 ✗ flag(update_rep_format_flag);
853 ✗ if (current->update_rep_format_flag)
854 ✗ ub(8, sps_rep_format_idx);
855 } else {
856
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(chroma_format_idc, 0, 3);
857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
276 if (current->chroma_format_idc == 3)
858 ✗ flag(separate_colour_plane_flag);
859 else
860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
276 infer(separate_colour_plane_flag, 0);
861
862
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(pic_width_in_luma_samples, 1, HEVC_MAX_WIDTH);
863
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(pic_height_in_luma_samples, 1, HEVC_MAX_HEIGHT);
864
865
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 flag(conformance_window_flag);
866
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 30 times.
276 if (current->conformance_window_flag) {
867
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 108 times.
216 ue(conf_win_left_offset, 0, current->pic_width_in_luma_samples);
868
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 108 times.
216 ue(conf_win_right_offset, 0, current->pic_width_in_luma_samples);
869
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 108 times.
216 ue(conf_win_top_offset, 0, current->pic_height_in_luma_samples);
870
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 108 times.
216 ue(conf_win_bottom_offset, 0, current->pic_height_in_luma_samples);
871 } else {
872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
60 infer(conf_win_left_offset, 0);
873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
60 infer(conf_win_right_offset, 0);
874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
60 infer(conf_win_top_offset, 0);
875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
60 infer(conf_win_bottom_offset, 0);
876 }
877
878
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(bit_depth_luma_minus8, 0, 8);
879
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(bit_depth_chroma_minus8, 0, 8);
880 }
881
882
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(log2_max_pic_order_cnt_lsb_minus4, 0, 12);
883
884
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
276 if (!multi_layer_ext_sps_flag) {
885
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 flag(sps_sub_layer_ordering_info_present_flag);
886 276 for (i = (current->sps_sub_layer_ordering_info_present_flag ?
887
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 114 times.
276 0 : current->sps_max_sub_layers_minus1);
888
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 138 times.
568 i <= current->sps_max_sub_layers_minus1; i++) {
889
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
292 ues(sps_max_dec_pic_buffering_minus1[i],
890 0, HEVC_MAX_DPB_SIZE - 1, 1, i);
891
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
292 ues(sps_max_num_reorder_pics[i],
892 0, current->sps_max_dec_pic_buffering_minus1[i], 1, i);
893
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
292 ues(sps_max_latency_increase_plus1[i],
894 0, UINT32_MAX - 1, 1, i);
895 }
896
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 114 times.
276 if (!current->sps_sub_layer_ordering_info_present_flag) {
897
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 24 times.
128 for (i = 0; i < current->sps_max_sub_layers_minus1; i++) {
898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
80 infer(sps_max_dec_pic_buffering_minus1[i],
899 current->sps_max_dec_pic_buffering_minus1[current->sps_max_sub_layers_minus1]);
900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
80 infer(sps_max_num_reorder_pics[i],
901 current->sps_max_num_reorder_pics[current->sps_max_sub_layers_minus1]);
902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
80 infer(sps_max_latency_increase_plus1[i],
903 current->sps_max_latency_increase_plus1[current->sps_max_sub_layers_minus1]);
904 }
905 }
906 }
907
908
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(log2_min_luma_coding_block_size_minus3, 0, 3);
909 276 min_cb_log2_size_y = current->log2_min_luma_coding_block_size_minus3 + 3;
910
911
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(log2_diff_max_min_luma_coding_block_size, 0, 3);
912 276 ctb_log2_size_y = min_cb_log2_size_y +
913 276 current->log2_diff_max_min_luma_coding_block_size;
914
915 276 min_cb_size_y = 1 << min_cb_log2_size_y;
916
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
276 if (current->pic_width_in_luma_samples % min_cb_size_y ||
917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
276 current->pic_height_in_luma_samples % min_cb_size_y) {
918 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid dimensions: %ux%u not divisible "
919 ✗ "by MinCbSizeY = %u.\n", current->pic_width_in_luma_samples,
920 ✗ current->pic_height_in_luma_samples, min_cb_size_y);
921 ✗ return AVERROR_INVALIDDATA;
922 }
923
924
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(log2_min_luma_transform_block_size_minus2, 0, min_cb_log2_size_y - 3);
925 276 min_tb_log2_size_y = current->log2_min_luma_transform_block_size_minus2 + 2;
926
927
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(log2_diff_max_min_luma_transform_block_size,
928 0, FFMIN(ctb_log2_size_y, 5) - min_tb_log2_size_y);
929
930
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(max_transform_hierarchy_depth_inter,
931 0, ctb_log2_size_y - min_tb_log2_size_y);
932
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(max_transform_hierarchy_depth_intra,
933 0, ctb_log2_size_y - min_tb_log2_size_y);
934
935
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 flag(scaling_list_enabled_flag);
936
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 126 times.
276 if (current->scaling_list_enabled_flag) {
937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
24 if (multi_layer_ext_sps_flag)
938 ✗ flag(sps_infer_scaling_list_flag);
939 else
940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
24 infer(sps_infer_scaling_list_flag, 0);
941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
24 if (current->sps_infer_scaling_list_flag)
942 ✗ ub(6, sps_scaling_list_ref_layer_id);
943 else {
944
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
24 flag(sps_scaling_list_data_present_flag);
945
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 if (current->sps_scaling_list_data_present_flag)
946
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
24 CHECK(FUNC(scaling_list_data)(ctx, rw, &current->scaling_list));
947 }
948 } else {
949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
252 infer(sps_scaling_list_data_present_flag, 0);
950 }
951
952
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 flag(amp_enabled_flag);
953
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 flag(sample_adaptive_offset_enabled_flag);
954
955
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 flag(pcm_enabled_flag);
956
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 134 times.
276 if (current->pcm_enabled_flag) {
957
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 u(4, pcm_sample_bit_depth_luma_minus1,
958 0, current->bit_depth_luma_minus8 + 8 - 1);
959
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 u(4, pcm_sample_bit_depth_chroma_minus1,
960 0, current->bit_depth_chroma_minus8 + 8 - 1);
961
962
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ue(log2_min_pcm_luma_coding_block_size_minus3,
963 FFMIN(min_cb_log2_size_y, 5) - 3, FFMIN(ctb_log2_size_y, 5) - 3);
964
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 ue(log2_diff_max_min_pcm_luma_coding_block_size,
965 0, FFMIN(ctb_log2_size_y, 5) - (current->log2_min_pcm_luma_coding_block_size_minus3 + 3));
966
967
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 flag(pcm_loop_filter_disabled_flag);
968 }
969
970
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 ue(num_short_term_ref_pic_sets, 0, HEVC_MAX_SHORT_TERM_REF_PIC_SETS);
971
2/2
✓ Branch 0 taken 1180 times.
✓ Branch 1 taken 138 times.
2636 for (i = 0; i < current->num_short_term_ref_pic_sets; i++)
972
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1180 times.
2360 CHECK(FUNC(st_ref_pic_set)(ctx, rw, &current->st_ref_pic_set[i], i, current));
973
974
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 flag(long_term_ref_pics_present_flag);
975
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 110 times.
276 if (current->long_term_ref_pics_present_flag) {
976
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);
977
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++) {
978
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
64 ubs(current->log2_max_pic_order_cnt_lsb_minus4 + 4,
979 lt_ref_pic_poc_lsb_sps[i], 1, i);
980
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
64 flags(used_by_curr_pic_lt_sps_flag[i], 1, i);
981 }
982 }
983
984
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 flag(sps_temporal_mvp_enabled_flag);
985
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 flag(strong_intra_smoothing_enabled_flag);
986
987
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 flag(vui_parameters_present_flag);
988
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 76 times.
276 if (current->vui_parameters_present_flag)
989
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
124 CHECK(FUNC(vui_parameters)(ctx, rw, &current->vui, current));
990 else
991
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
152 CHECK(FUNC(vui_parameters_default)(ctx, rw, &current->vui, current));
992
993
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 flag(sps_extension_present_flag);
994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
276 if (current->sps_extension_present_flag) {
995 ✗ flag(sps_range_extension_flag);
996 ✗ flag(sps_multilayer_extension_flag);
997 ✗ flag(sps_3d_extension_flag);
998 ✗ flag(sps_scc_extension_flag);
999 ✗ ub(4, sps_extension_4bits);
1000 }
1001
1002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
276 if (current->sps_range_extension_flag)
1003 ✗ CHECK(FUNC(sps_range_extension)(ctx, rw, current));
1004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
276 if (current->sps_multilayer_extension_flag)
1005 ✗ CHECK(FUNC(sps_multilayer_extension)(ctx, rw, current));
1006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
276 if (current->sps_3d_extension_flag)
1007 ✗ return AVERROR_PATCHWELCOME;
1008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
276 if (current->sps_scc_extension_flag)
1009 ✗ CHECK(FUNC(sps_scc_extension)(ctx, rw, current));
1010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
276 if (current->sps_extension_4bits)
1011 ✗ CHECK(FUNC(extension_data)(ctx, rw, &current->extension_data));
1012
1013
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
276 CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
1014
1015 276 return 0;
1016 }
1017
1018 ✗ static int FUNC(pps_range_extension)(CodedBitstreamContext *ctx, RWContext *rw,
1019 H265RawPPS *current)
1020 {
1021 ✗ CodedBitstreamH265Context *h265 = ctx->priv_data;
1022 ✗ const H265RawSPS *sps = h265->active_sps;
1023 int err, i;
1024
1025 ✗ if (current->transform_skip_enabled_flag)
1026 ✗ ue(log2_max_transform_skip_block_size_minus2, 0, 3);
1027 ✗ flag(cross_component_prediction_enabled_flag);
1028
1029 ✗ flag(chroma_qp_offset_list_enabled_flag);
1030 ✗ if (current->chroma_qp_offset_list_enabled_flag) {
1031 ✗ ue(diff_cu_chroma_qp_offset_depth,
1032 0, sps->log2_diff_max_min_luma_coding_block_size);
1033 ✗ ue(chroma_qp_offset_list_len_minus1, 0, 5);
1034 ✗ for (i = 0; i <= current->chroma_qp_offset_list_len_minus1; i++) {
1035 ✗ ses(cb_qp_offset_list[i], -12, +12, 1, i);
1036 ✗ ses(cr_qp_offset_list[i], -12, +12, 1, i);
1037 }
1038 }
1039
1040 ✗ ue(log2_sao_offset_scale_luma, 0, FFMAX(0, sps->bit_depth_luma_minus8 - 2));
1041 ✗ ue(log2_sao_offset_scale_chroma, 0, FFMAX(0, sps->bit_depth_chroma_minus8 - 2));
1042
1043 ✗ return 0;
1044 }
1045
1046 ✗ static int FUNC(colour_mapping_octants)(CodedBitstreamContext *ctx, RWContext *rw,
1047 H265RawPPS *current, unsigned int inp_depth,
1048 unsigned int idx_y, unsigned int idx_cb,
1049 unsigned int idx_cr, unsigned int inp_length)
1050 {
1051 int part_num_y, cm_res_bits;
1052 int err;
1053
1054 ✗ part_num_y = 1 << current->cm_y_part_num_log2;
1055
1056 ✗ av_assert0(inp_depth <= 1);
1057 ✗ if (inp_depth < current->cm_octant_depth)
1058 ✗ flags(split_octant_flag[inp_depth], 1, inp_depth);
1059 else
1060 ✗ infer(split_octant_flag[inp_depth], 0);
1061
1062 ✗ if (current->split_octant_flag[inp_depth])
1063 ✗ for (int k = 0; k < 2; k++)
1064 ✗ for (int m = 0; m < 2; m++)
1065 ✗ for (int n = 0; n < 2; n++)
1066 ✗ CHECK(FUNC(colour_mapping_octants)(ctx, rw, current, inp_depth + 1,
1067 idx_y + part_num_y * k * inp_length / 2,
1068 idx_cb + m * inp_length / 2,
1069 idx_cr + n * inp_length / 2,
1070 inp_length / 2));
1071 else
1072 ✗ for (int i = 0; i < part_num_y; i++) {
1073 ✗ int idx_shift_y = idx_y + (i << (current->cm_octant_depth - inp_depth));
1074 ✗ for (int j = 0; j < 4; j++) {
1075 ✗ flags(coded_res_flag[idx_shift_y][idx_cb][idx_cr][j],
1076 4, idx_shift_y, idx_cb, idx_cr, j);
1077 ✗ if (current->coded_res_flag[idx_shift_y][idx_cb][idx_cr][j]) {
1078 ✗ for (int c = 0; c < 3; c++) {
1079 ✗ ues(res_coeff_q[idx_shift_y][idx_cb][idx_cr][j][c], 0, 3,
1080 5, idx_shift_y, idx_cb, idx_cr, j, c);
1081 ✗ cm_res_bits = FFMAX(0, 10 + (current->luma_bit_depth_cm_input_minus8 + 8) -
1082 (current->luma_bit_depth_cm_output_minus8 + 8) -
1083 current->cm_res_quant_bits - (current->cm_delta_flc_bits_minus1 + 1));
1084 ✗ if (cm_res_bits)
1085 ✗ ubs(cm_res_bits, res_coeff_r[idx_shift_y][idx_cb][idx_cr][j][c],
1086 5, idx_shift_y, idx_cb, idx_cr, j, c);
1087 else
1088 ✗ infer(res_coeff_r[idx_shift_y][idx_cb][idx_cr][j][c], 0);
1089 ✗ if (current->res_coeff_q[idx_shift_y][idx_cb][idx_cr][j][c] ||
1090 ✗ current->res_coeff_r[idx_shift_y][idx_cb][idx_cr][j][c])
1091 ✗ ub(1, res_coeff_s[idx_shift_y][idx_cb][idx_cr][j][c]);
1092 else
1093 ✗ infer(res_coeff_s[idx_shift_y][idx_cb][idx_cr][j][c], 0);
1094 }
1095 } else {
1096 ✗ for (int c = 0; c < 3; c++) {
1097 ✗ infer(res_coeff_q[idx_shift_y][idx_cb][idx_cr][j][c], 0);
1098 ✗ infer(res_coeff_r[idx_shift_y][idx_cb][idx_cr][j][c], 0);
1099 ✗ infer(res_coeff_s[idx_shift_y][idx_cb][idx_cr][j][c], 0);
1100 }
1101 }
1102 }
1103 }
1104
1105 ✗ return 0;
1106 }
1107
1108 ✗ static int FUNC(colour_mapping_table)(CodedBitstreamContext *ctx, RWContext *rw,
1109 H265RawPPS *current)
1110 {
1111 int err;
1112
1113 ✗ ue(num_cm_ref_layers_minus1, 0, 61);
1114 ✗ for (int i = 0; i <= current->num_cm_ref_layers_minus1; i++)
1115 ✗ ubs(6, cm_ref_layer_id[i], 1, i);
1116
1117 ✗ u(2, cm_octant_depth, 0, 1);
1118 ✗ u(2, cm_y_part_num_log2, 0, 3 - current->cm_octant_depth);
1119
1120 ✗ ue(luma_bit_depth_cm_input_minus8, 0, 8);
1121 ✗ ue(chroma_bit_depth_cm_input_minus8, 0, 8);
1122 ✗ ue(luma_bit_depth_cm_output_minus8, 0, 8);
1123 ✗ ue(chroma_bit_depth_cm_output_minus8, 0, 8);
1124
1125 ✗ ub(2, cm_res_quant_bits);
1126 ✗ ub(2, cm_delta_flc_bits_minus1);
1127
1128 ✗ if (current->cm_octant_depth == 1) {
1129 ✗ se(cm_adapt_threshold_u_delta, -32768, 32767);
1130 ✗ se(cm_adapt_threshold_v_delta, -32768, 32767);
1131 } else {
1132 ✗ infer(cm_adapt_threshold_u_delta, 0);
1133 ✗ infer(cm_adapt_threshold_v_delta, 0);
1134 }
1135
1136 ✗ CHECK(FUNC(colour_mapping_octants)(ctx, rw, current, 0, 0, 0, 0, 1 << current->cm_octant_depth));
1137
1138 ✗ return 0;
1139 }
1140
1141 ✗ static int FUNC(pps_multilayer_extension)(CodedBitstreamContext *ctx, RWContext *rw,
1142 H265RawPPS *current)
1143 {
1144 ✗ CodedBitstreamH265Context *h265 = ctx->priv_data;
1145 ✗ const H265RawVPS *vps = h265->active_vps;
1146 int offset;
1147 int err, i;
1148
1149 ✗ flag(poc_reset_info_present_flag);
1150 ✗ flag(pps_infer_scaling_list_flag);
1151 ✗ if (current->pps_infer_scaling_list_flag)
1152 ✗ ub(6, pps_scaling_list_ref_layer_id);
1153
1154 ✗ if (!vps) {
1155 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "VPS missing for PPS Multilayer Extension.\n");
1156 ✗ return AVERROR_INVALIDDATA;
1157 }
1158
1159 ✗ ue(num_ref_loc_offsets, 0, vps->vps_max_layers_minus1);
1160 ✗ for (i = 0; i < current->num_ref_loc_offsets; i++) {
1161 ✗ ubs(6, ref_loc_offset_layer_id[i], 1, i);
1162 ✗ offset = current->ref_loc_offset_layer_id[i];
1163 ✗ flags(scaled_ref_layer_offset_present_flag[i], 1, i);
1164 ✗ if (current->scaled_ref_layer_offset_present_flag[i]) {
1165 ✗ ses(scaled_ref_layer_left_offset[offset], -16384, 16383, 1, offset);
1166 ✗ ses(scaled_ref_layer_top_offset[offset], -16384, 16383, 1, offset);
1167 ✗ ses(scaled_ref_layer_right_offset[offset], -16384, 16383, 1, offset);
1168 ✗ ses(scaled_ref_layer_bottom_offset[offset], -16384, 16383, 1, offset);
1169 } else {
1170 ✗ infer(scaled_ref_layer_left_offset[offset], 0);
1171 ✗ infer(scaled_ref_layer_top_offset[offset], 0);
1172 ✗ infer(scaled_ref_layer_right_offset[offset], 0);
1173 ✗ infer(scaled_ref_layer_bottom_offset[offset], 0);
1174 }
1175 ✗ flags(ref_region_offset_present_flag[i], 1, i);
1176 ✗ if (current->ref_region_offset_present_flag[i]) {
1177 ✗ ses(ref_region_left_offset[offset], -16384, 16383, 1, offset);
1178 ✗ ses(ref_region_top_offset[offset], -16384, 16383, 1, offset);
1179 ✗ ses(ref_region_right_offset[offset], -16384, 16383, 1, offset);
1180 ✗ ses(ref_region_bottom_offset[offset], -16384, 16383, 1, offset);
1181 } else {
1182 ✗ infer(ref_region_left_offset[offset], 0);
1183 ✗ infer(ref_region_top_offset[offset], 0);
1184 ✗ infer(ref_region_right_offset[offset], 0);
1185 ✗ infer(ref_region_bottom_offset[offset], 0);
1186 }
1187 ✗ flags(resample_phase_set_present_flag[i], 1, i);
1188 ✗ if (current->resample_phase_set_present_flag[i]) {
1189 ✗ ues(phase_hor_luma[offset], 0, 31, 1, offset);
1190 ✗ ues(phase_ver_luma[offset], 0, 31, 1, offset);
1191 ✗ ues(phase_hor_chroma_plus8[offset], 0, 63, 1, offset);
1192 ✗ ues(phase_ver_chroma_plus8[offset], 0, 63, 1, offset);
1193 } else {
1194 ✗ infer(phase_hor_luma[offset], 0);
1195 ✗ infer(phase_ver_luma[offset], 0);
1196 ✗ infer(phase_hor_chroma_plus8[offset], 8);
1197 }
1198 }
1199
1200 ✗ flag(colour_mapping_enabled_flag);
1201 ✗ if (current->colour_mapping_enabled_flag)
1202 ✗ CHECK(FUNC(colour_mapping_table)(ctx, rw, current));
1203
1204 ✗ return 0;
1205 }
1206
1207 ✗ static int FUNC(pps_scc_extension)(CodedBitstreamContext *ctx, RWContext *rw,
1208 H265RawPPS *current)
1209 {
1210 int err, comp, i;
1211
1212 ✗ flag(pps_curr_pic_ref_enabled_flag);
1213
1214 ✗ flag(residual_adaptive_colour_transform_enabled_flag);
1215 ✗ if (current->residual_adaptive_colour_transform_enabled_flag) {
1216 ✗ flag(pps_slice_act_qp_offsets_present_flag);
1217 ✗ se(pps_act_y_qp_offset_plus5, -7, +17);
1218 ✗ se(pps_act_cb_qp_offset_plus5, -7, +17);
1219 ✗ se(pps_act_cr_qp_offset_plus3, -9, +15);
1220 } else {
1221 ✗ infer(pps_slice_act_qp_offsets_present_flag, 0);
1222 ✗ infer(pps_act_y_qp_offset_plus5, 0);
1223 ✗ infer(pps_act_cb_qp_offset_plus5, 0);
1224 ✗ infer(pps_act_cr_qp_offset_plus3, 0);
1225 }
1226
1227 ✗ flag(pps_palette_predictor_initializer_present_flag);
1228 ✗ if (current->pps_palette_predictor_initializer_present_flag) {
1229 ✗ ue(pps_num_palette_predictor_initializer, 0, 128);
1230 ✗ if (current->pps_num_palette_predictor_initializer > 0) {
1231 ✗ flag(monochrome_palette_flag);
1232 ✗ ue(luma_bit_depth_entry_minus8, 0, 8);
1233 ✗ if (!current->monochrome_palette_flag)
1234 ✗ ue(chroma_bit_depth_entry_minus8, 0, 8);
1235 ✗ for (comp = 0; comp < (current->monochrome_palette_flag ? 1 : 3); comp++) {
1236 ✗ int bit_depth = comp == 0 ? current->luma_bit_depth_entry_minus8 + 8
1237 ✗ : current->chroma_bit_depth_entry_minus8 + 8;
1238 ✗ for (i = 0; i < current->pps_num_palette_predictor_initializer; i++)
1239 ✗ ubs(bit_depth, pps_palette_predictor_initializers[comp][i], 2, comp, i);
1240 }
1241 }
1242 }
1243
1244 ✗ return 0;
1245 }
1246
1247 1428 static int FUNC(pps)(CodedBitstreamContext *ctx, RWContext *rw,
1248 H265RawPPS *current)
1249 {
1250 1428 CodedBitstreamH265Context *h265 = ctx->priv_data;
1251 const H265RawSPS *sps;
1252 int err, i;
1253
1254 1428 HEADER("Picture Parameter Set");
1255
1256
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header, HEVC_NAL_PPS));
1257
1258
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 ue(pps_pic_parameter_set_id, 0, 63);
1259
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 ue(pps_seq_parameter_set_id, 0, 15);
1260 1428 sps = h265->sps[current->pps_seq_parameter_set_id];
1261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714 times.
1428 if (!sps) {
1262 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "SPS id %d not available.\n",
1263 ✗ current->pps_seq_parameter_set_id);
1264 ✗ return AVERROR_INVALIDDATA;
1265 }
1266 1428 h265->active_sps = sps;
1267
1268
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(dependent_slice_segments_enabled_flag);
1269
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(output_flag_present_flag);
1270
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 ub(3, num_extra_slice_header_bits);
1271
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(sign_data_hiding_enabled_flag);
1272
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(cabac_init_present_flag);
1273
1274
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 ue(num_ref_idx_l0_default_active_minus1, 0, 14);
1275
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 ue(num_ref_idx_l1_default_active_minus1, 0, 14);
1276
1277
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 se(init_qp_minus26, -(26 + 6 * sps->bit_depth_luma_minus8), +25);
1278
1279
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(constrained_intra_pred_flag);
1280
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(transform_skip_enabled_flag);
1281
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(cu_qp_delta_enabled_flag);
1282
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 680 times.
1428 if (current->cu_qp_delta_enabled_flag)
1283
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
68 ue(diff_cu_qp_delta_depth,
1284 0, sps->log2_diff_max_min_luma_coding_block_size);
1285 else
1286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 273 times.
1360 infer(diff_cu_qp_delta_depth, 0);
1287
1288
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 se(pps_cb_qp_offset, -12, +12);
1289
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 se(pps_cr_qp_offset, -12, +12);
1290
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(pps_slice_chroma_qp_offsets_present_flag);
1291
1292
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(weighted_pred_flag);
1293
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(weighted_bipred_flag);
1294
1295
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(transquant_bypass_enabled_flag);
1296
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(tiles_enabled_flag);
1297
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(entropy_coding_sync_enabled_flag);
1298
1299
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 504 times.
1428 if (current->tiles_enabled_flag) {
1300
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
420 ue(num_tile_columns_minus1, 0, HEVC_MAX_TILE_COLUMNS);
1301
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
420 ue(num_tile_rows_minus1, 0, HEVC_MAX_TILE_ROWS);
1302
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
420 flag(uniform_spacing_flag);
1303
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 8 times.
420 if (!current->uniform_spacing_flag) {
1304
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 202 times.
2020 for (i = 0; i < current->num_tile_columns_minus1; i++)
1305
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);
1306
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 202 times.
2020 for (i = 0; i < current->num_tile_rows_minus1; i++)
1307
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);
1308 }
1309
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
420 flag(loop_filter_across_tiles_enabled_flag);
1310 } else {
1311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
1008 infer(num_tile_columns_minus1, 0);
1312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
1008 infer(num_tile_rows_minus1, 0);
1313 }
1314
1315
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(pps_loop_filter_across_slices_enabled_flag);
1316
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(deblocking_filter_control_present_flag);
1317
2/2
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 488 times.
1428 if (current->deblocking_filter_control_present_flag) {
1318
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 226 times.
452 flag(deblocking_filter_override_enabled_flag);
1319
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 226 times.
452 flag(pps_deblocking_filter_disabled_flag);
1320
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 4 times.
452 if (!current->pps_deblocking_filter_disabled_flag) {
1321
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 222 times.
444 se(pps_beta_offset_div2, -6, +6);
1322
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 222 times.
444 se(pps_tc_offset_div2, -6, +6);
1323 } else {
1324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
8 infer(pps_beta_offset_div2, 0);
1325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
8 infer(pps_tc_offset_div2, 0);
1326 }
1327 } else {
1328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
976 infer(deblocking_filter_override_enabled_flag, 0);
1329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
976 infer(pps_deblocking_filter_disabled_flag, 0);
1330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
976 infer(pps_beta_offset_div2, 0);
1331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
976 infer(pps_tc_offset_div2, 0);
1332 }
1333
1334
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(pps_scaling_list_data_present_flag);
1335
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 462 times.
1428 if (current->pps_scaling_list_data_present_flag)
1336
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 252 times.
504 CHECK(FUNC(scaling_list_data)(ctx, rw, &current->scaling_list));
1337
1338
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(lists_modification_present_flag);
1339
1340
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 ue(log2_parallel_merge_level_minus2,
1341 0, (sps->log2_min_luma_coding_block_size_minus3 + 3 +
1342 sps->log2_diff_max_min_luma_coding_block_size - 2));
1343
1344
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(slice_segment_header_extension_present_flag);
1345
1346
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 flag(pps_extension_present_flag);
1347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714 times.
1428 if (current->pps_extension_present_flag) {
1348 ✗ flag(pps_range_extension_flag);
1349 ✗ flag(pps_multilayer_extension_flag);
1350 ✗ flag(pps_3d_extension_flag);
1351 ✗ flag(pps_scc_extension_flag);
1352 ✗ ub(4, pps_extension_4bits);
1353 }
1354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714 times.
1428 if (current->pps_range_extension_flag)
1355 ✗ CHECK(FUNC(pps_range_extension)(ctx, rw, current));
1356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714 times.
1428 if (current->pps_multilayer_extension_flag)
1357 ✗ CHECK(FUNC(pps_multilayer_extension)(ctx, rw, current));
1358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714 times.
1428 if (current->pps_3d_extension_flag)
1359 ✗ return AVERROR_PATCHWELCOME;
1360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714 times.
1428 if (current->pps_scc_extension_flag)
1361 ✗ CHECK(FUNC(pps_scc_extension)(ctx, rw, current));
1362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 714 times.
1428 if (current->pps_extension_4bits)
1363 ✗ CHECK(FUNC(extension_data)(ctx, rw, &current->extension_data));
1364
1365
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 714 times.
1428 CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
1366
1367 1428 return 0;
1368 }
1369
1370 240 static int FUNC(aud)(CodedBitstreamContext *ctx, RWContext *rw,
1371 H265RawAUD *current)
1372 {
1373 int err;
1374
1375 240 HEADER("Access Unit Delimiter");
1376
1377
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));
1378
1379
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
240 u(3, pic_type, 0, 2);
1380
1381
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
240 CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
1382
1383 240 return 0;
1384 }
1385
1386 2992 static int FUNC(ref_pic_lists_modification)(CodedBitstreamContext *ctx, RWContext *rw,
1387 H265RawSliceHeader *current,
1388 unsigned int num_pic_total_curr)
1389 {
1390 unsigned int entry_size;
1391 int err, i;
1392
1393 2992 entry_size = av_log2(num_pic_total_curr - 1) + 1;
1394
1395
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1496 times.
2992 flag(ref_pic_list_modification_flag_l0);
1396
2/2
✓ Branch 0 taken 726 times.
✓ Branch 1 taken 770 times.
2992 if (current->ref_pic_list_modification_flag_l0) {
1397
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++)
1398
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);
1399 }
1400
1401
1/2
✓ Branch 0 taken 1496 times.
✗ Branch 1 not taken.
2992 if (current->slice_type == HEVC_SLICE_B) {
1402
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1496 times.
2992 flag(ref_pic_list_modification_flag_l1);
1403
2/2
✓ Branch 0 taken 426 times.
✓ Branch 1 taken 1070 times.
2992 if (current->ref_pic_list_modification_flag_l1) {
1404
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++)
1405
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);
1406 }
1407 }
1408
1409 2992 return 0;
1410 }
1411
1412 1028 static int FUNC(pred_weight_table)(CodedBitstreamContext *ctx, RWContext *rw,
1413 H265RawSliceHeader *current)
1414 {
1415 1028 CodedBitstreamH265Context *h265 = ctx->priv_data;
1416 1028 const H265RawSPS *sps = h265->active_sps;
1417 int err, i, j;
1418
1/2
✓ Branch 0 taken 514 times.
✗ Branch 1 not taken.
2056 int chroma = !sps->separate_colour_plane_flag &&
1419
1/2
✓ Branch 0 taken 514 times.
✗ Branch 1 not taken.
1028 sps->chroma_format_idc != 0;
1420
1421
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 514 times.
1028 ue(luma_log2_weight_denom, 0, 7);
1422
1/2
✓ Branch 0 taken 514 times.
✗ Branch 1 not taken.
1028 if (chroma)
1423
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 514 times.
1028 se(delta_chroma_log2_weight_denom, -7, 7);
1424 else
1425 ✗ infer(delta_chroma_log2_weight_denom, 0);
1426
1427
2/2
✓ Branch 0 taken 2032 times.
✓ Branch 1 taken 514 times.
5092 for (i = 0; i <= current->num_ref_idx_l0_active_minus1; i++) {
1428 if (1 /* is not same POC and same layer_id */)
1429
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2032 times.
4064 flags(luma_weight_l0_flag[i], 1, i);
1430 else
1431 infer(luma_weight_l0_flag[i], 0);
1432 }
1433
1/2
✓ Branch 0 taken 514 times.
✗ Branch 1 not taken.
1028 if (chroma) {
1434
2/2
✓ Branch 0 taken 2032 times.
✓ Branch 1 taken 514 times.
5092 for (i = 0; i <= current->num_ref_idx_l0_active_minus1; i++) {
1435 if (1 /* is not same POC and same layer_id */)
1436
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2032 times.
4064 flags(chroma_weight_l0_flag[i], 1, i);
1437 else
1438 infer(chroma_weight_l0_flag[i], 0);
1439 }
1440 }
1441
1442
2/2
✓ Branch 0 taken 2032 times.
✓ Branch 1 taken 514 times.
5092 for (i = 0; i <= current->num_ref_idx_l0_active_minus1; i++) {
1443
2/2
✓ Branch 0 taken 1540 times.
✓ Branch 1 taken 492 times.
4064 if (current->luma_weight_l0_flag[i]) {
1444
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1540 times.
3080 ses(delta_luma_weight_l0[i], -128, +127, 1, i);
1445
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1540 times.
3080 ses(luma_offset_l0[i],
1446 -(1 << (sps->bit_depth_luma_minus8 + 8 - 1)),
1447 ((1 << (sps->bit_depth_luma_minus8 + 8 - 1)) - 1), 1, i);
1448 } else {
1449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
984 infer(delta_luma_weight_l0[i], 0);
1450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
984 infer(luma_offset_l0[i], 0);
1451 }
1452
2/2
✓ Branch 0 taken 506 times.
✓ Branch 1 taken 1526 times.
4064 if (current->chroma_weight_l0_flag[i]) {
1453
2/2
✓ Branch 0 taken 1012 times.
✓ Branch 1 taken 506 times.
3036 for (j = 0; j < 2; j++) {
1454
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1012 times.
2024 ses(delta_chroma_weight_l0[i][j], -128, +127, 2, i, j);
1455
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1012 times.
2024 ses(chroma_offset_l0[i][j],
1456 -(4 << (sps->bit_depth_chroma_minus8 + 8 - 1)),
1457 ((4 << (sps->bit_depth_chroma_minus8 + 8 - 1)) - 1), 2, i, j);
1458 }
1459 } else {
1460
2/2
✓ Branch 0 taken 3052 times.
✓ Branch 1 taken 1526 times.
9156 for (j = 0; j < 2; j++) {
1461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1526 times.
6104 infer(delta_chroma_weight_l0[i][j], 0);
1462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1526 times.
6104 infer(chroma_offset_l0[i][j], 0);
1463 }
1464 }
1465 }
1466
1467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 514 times.
1028 if (current->slice_type == HEVC_SLICE_B) {
1468 ✗ for (i = 0; i <= current->num_ref_idx_l1_active_minus1; i++) {
1469 if (1 /* RefPicList1[i] is not CurrPic, nor is it in a different layer */)
1470 ✗ flags(luma_weight_l1_flag[i], 1, i);
1471 else
1472 infer(luma_weight_l1_flag[i], 0);
1473 }
1474 ✗ if (chroma) {
1475 ✗ for (i = 0; i <= current->num_ref_idx_l1_active_minus1; i++) {
1476 if (1 /* RefPicList1[i] is not CurrPic, nor is it in a different layer */)
1477 ✗ flags(chroma_weight_l1_flag[i], 1, i);
1478 else
1479 infer(chroma_weight_l1_flag[i], 0);
1480 }
1481 }
1482
1483 ✗ for (i = 0; i <= current->num_ref_idx_l1_active_minus1; i++) {
1484 ✗ if (current->luma_weight_l1_flag[i]) {
1485 ✗ ses(delta_luma_weight_l1[i], -128, +127, 1, i);
1486 ✗ ses(luma_offset_l1[i],
1487 -(1 << (sps->bit_depth_luma_minus8 + 8 - 1)),
1488 ((1 << (sps->bit_depth_luma_minus8 + 8 - 1)) - 1), 1, i);
1489 } else {
1490 ✗ infer(delta_luma_weight_l1[i], 0);
1491 ✗ infer(luma_offset_l1[i], 0);
1492 }
1493 ✗ if (current->chroma_weight_l1_flag[i]) {
1494 ✗ for (j = 0; j < 2; j++) {
1495 ✗ ses(delta_chroma_weight_l1[i][j], -128, +127, 2, i, j);
1496 ✗ ses(chroma_offset_l1[i][j],
1497 -(4 << (sps->bit_depth_chroma_minus8 + 8 - 1)),
1498 ((4 << (sps->bit_depth_chroma_minus8 + 8 - 1)) - 1), 2, i, j);
1499 }
1500 } else {
1501 ✗ for (j = 0; j < 2; j++) {
1502 ✗ infer(delta_chroma_weight_l1[i][j], 0);
1503 ✗ infer(chroma_offset_l1[i][j], 0);
1504 }
1505 }
1506 }
1507 }
1508
1509 1028 return 0;
1510 }
1511
1512 27176 static int FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw,
1513 H265RawSliceHeader *current)
1514 {
1515 27176 CodedBitstreamH265Context *h265 = ctx->priv_data;
1516 const H265RawSPS *sps;
1517 const H265RawPPS *pps;
1518 unsigned int pic_width_in_ctbs_y, pic_height_in_ctbs_y, pic_size_in_ctbs_y;
1519 27176 unsigned int num_pic_total_curr = 0;
1520 int err, i;
1521
1522 27176 HEADER("Slice Segment Header");
1523
1524
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 13588 times.
27176 CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header, -1));
1525
1526
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 13588 times.
27176 flag(first_slice_segment_in_pic_flag);
1527
1528
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 13303 times.
27176 if (current->nal_unit_header.nal_unit_type >= HEVC_NAL_BLA_W_LP &&
1529
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
570 current->nal_unit_header.nal_unit_type <= HEVC_NAL_RSV_IRAP_VCL23)
1530
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 285 times.
570 flag(no_output_of_prior_pics_flag);
1531
1532
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 13588 times.
27176 ue(slice_pic_parameter_set_id, 0, 63);
1533
1534 27176 pps = h265->pps[current->slice_pic_parameter_set_id];
1535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13588 times.
27176 if (!pps) {
1536 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "PPS id %d not available.\n",
1537 ✗ current->slice_pic_parameter_set_id);
1538 ✗ return AVERROR_INVALIDDATA;
1539 }
1540 27176 h265->active_pps = pps;
1541
1542 27176 sps = h265->sps[pps->pps_seq_parameter_set_id];
1543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13588 times.
27176 if (!sps) {
1544 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "SPS id %d not available.\n",
1545 ✗ pps->pps_seq_parameter_set_id);
1546 ✗ return AVERROR_INVALIDDATA;
1547 }
1548 27176 h265->active_sps = sps;
1549
1550 27176 cbs_h265_pic_size_in_ctbs(sps, &pic_width_in_ctbs_y, &pic_height_in_ctbs_y);
1551 27176 pic_size_in_ctbs_y = pic_width_in_ctbs_y * pic_height_in_ctbs_y;
1552
1553
2/2
✓ Branch 0 taken 8736 times.
✓ Branch 1 taken 4852 times.
27176 if (!current->first_slice_segment_in_pic_flag) {
1554 17472 unsigned int address_size = av_log2(pic_size_in_ctbs_y - 1) + 1;
1555
2/2
✓ Branch 0 taken 5354 times.
✓ Branch 1 taken 3382 times.
17472 if (pps->dependent_slice_segments_enabled_flag)
1556
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5354 times.
10708 flag(dependent_slice_segment_flag);
1557 else
1558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1691 times.
6764 infer(dependent_slice_segment_flag, 0);
1559
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8736 times.
17472 u(address_size, slice_segment_address, 0, pic_size_in_ctbs_y - 1);
1560 } else {
1561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2232 times.
9704 infer(dependent_slice_segment_flag, 0);
1562 }
1563
1564
2/2
✓ Branch 0 taken 9078 times.
✓ Branch 1 taken 4510 times.
27176 if (!current->dependent_slice_segment_flag) {
1565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9078 times.
18156 for (i = 0; i < pps->num_extra_slice_header_bits; i++)
1566 ✗ flags(slice_reserved_flag[i], 1, i);
1567
1568
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9078 times.
18156 ue(slice_type, 0, 2);
1569
1570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9078 times.
18156 if (pps->output_flag_present_flag)
1571 ✗ flag(pic_output_flag);
1572
1573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9078 times.
18156 if (sps->separate_colour_plane_flag)
1574 ✗ u(2, colour_plane_id, 0, 2);
1575
1576
2/2
✓ Branch 0 taken 8952 times.
✓ Branch 1 taken 126 times.
18156 if (current->nal_unit_header.nal_unit_type != HEVC_NAL_IDR_W_RADL &&
1577
2/2
✓ Branch 0 taken 8950 times.
✓ Branch 1 taken 2 times.
17904 current->nal_unit_header.nal_unit_type != HEVC_NAL_IDR_N_LP) {
1578 const H265RawSTRefPicSet *rps;
1579 int dpb_slots_remaining;
1580
1581
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8950 times.
17900 ub(sps->log2_max_pic_order_cnt_lsb_minus4 + 4, slice_pic_order_cnt_lsb);
1582
1583
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8950 times.
17900 flag(short_term_ref_pic_set_sps_flag);
1584
2/2
✓ Branch 0 taken 3797 times.
✓ Branch 1 taken 5153 times.
17900 if (!current->short_term_ref_pic_set_sps_flag) {
1585
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3797 times.
7594 CHECK(FUNC(st_ref_pic_set)(ctx, rw, &current->short_term_ref_pic_set,
1586 sps->num_short_term_ref_pic_sets, sps));
1587 7594 rps = &current->short_term_ref_pic_set;
1588
1/2
✓ Branch 0 taken 5153 times.
✗ Branch 1 not taken.
10306 } else if (sps->num_short_term_ref_pic_sets > 1) {
1589 10306 unsigned int idx_size = av_log2(sps->num_short_term_ref_pic_sets - 1) + 1;
1590
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5153 times.
10306 u(idx_size, short_term_ref_pic_set_idx,
1591 0, sps->num_short_term_ref_pic_sets - 1);
1592 10306 rps = &sps->st_ref_pic_set[current->short_term_ref_pic_set_idx];
1593 } else {
1594 ✗ infer(short_term_ref_pic_set_idx, 0);
1595 ✗ rps = &sps->st_ref_pic_set[0];
1596 }
1597
1598 17900 dpb_slots_remaining = HEVC_MAX_DPB_SIZE - 1 -
1599 17900 rps->num_negative_pics - rps->num_positive_pics;
1600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8950 times.
17900 if (pps->pps_curr_pic_ref_enabled_flag &&
1601 ✗ (sps->sample_adaptive_offset_enabled_flag ||
1602 ✗ !pps->pps_deblocking_filter_disabled_flag ||
1603 ✗ pps->deblocking_filter_override_enabled_flag)) {
1604 // This picture will occupy two DPB slots.
1605 ✗ if (dpb_slots_remaining == 0) {
1606 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
1607 "short-term ref pic set contains too many pictures "
1608 "to use with current picture reference enabled.\n");
1609 ✗ return AVERROR_INVALIDDATA;
1610 }
1611 ✗ --dpb_slots_remaining;
1612 }
1613
1614 17900 num_pic_total_curr = 0;
1615
2/2
✓ Branch 0 taken 23876 times.
✓ Branch 1 taken 8950 times.
65652 for (i = 0; i < rps->num_negative_pics; i++)
1616
2/2
✓ Branch 0 taken 22800 times.
✓ Branch 1 taken 1076 times.
47752 if (rps->used_by_curr_pic_s0_flag[i])
1617 45600 ++num_pic_total_curr;
1618
2/2
✓ Branch 0 taken 6952 times.
✓ Branch 1 taken 8950 times.
31804 for (i = 0; i < rps->num_positive_pics; i++)
1619
2/2
✓ Branch 0 taken 6662 times.
✓ Branch 1 taken 290 times.
13904 if (rps->used_by_curr_pic_s1_flag[i])
1620 13324 ++num_pic_total_curr;
1621
1622
2/2
✓ Branch 0 taken 1664 times.
✓ Branch 1 taken 7286 times.
17900 if (sps->long_term_ref_pics_present_flag) {
1623 unsigned int idx_size;
1624
1625
2/2
✓ Branch 0 taken 998 times.
✓ Branch 1 taken 666 times.
3328 if (sps->num_long_term_ref_pics_sps > 0) {
1626
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,
1627 dpb_slots_remaining));
1628 1996 idx_size = av_log2(sps->num_long_term_ref_pics_sps - 1) + 1;
1629 1996 dpb_slots_remaining -= current->num_long_term_sps;
1630 } else {
1631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333 times.
1332 infer(num_long_term_sps, 0);
1632 1332 idx_size = 0;
1633 }
1634
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1664 times.
3328 ue(num_long_term_pics, 0, dpb_slots_remaining);
1635
1636 3328 for (i = 0; i < current->num_long_term_sps +
1637
2/2
✓ Branch 0 taken 2820 times.
✓ Branch 1 taken 1664 times.
8968 current->num_long_term_pics; i++) {
1638
2/2
✓ Branch 0 taken 368 times.
✓ Branch 1 taken 2452 times.
5640 if (i < current->num_long_term_sps) {
1639
1/2
✓ Branch 0 taken 368 times.
✗ Branch 1 not taken.
736 if (sps->num_long_term_ref_pics_sps > 1)
1640
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 368 times.
736 us(idx_size, lt_idx_sps[i],
1641 0, sps->num_long_term_ref_pics_sps - 1, 1, i);
1642
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]])
1643 352 ++num_pic_total_curr;
1644 } else {
1645
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);
1646
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2452 times.
4904 flags(used_by_curr_pic_lt_flag[i], 1, i);
1647
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 1696 times.
4904 if (current->used_by_curr_pic_lt_flag[i])
1648 1512 ++num_pic_total_curr;
1649 }
1650
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2820 times.
5640 flags(delta_poc_msb_present_flag[i], 1, i);
1651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2820 times.
5640 if (current->delta_poc_msb_present_flag[i])
1652 ✗ ues(delta_poc_msb_cycle_lt[i], 0, UINT32_MAX - 1, 1, i);
1653 else
1654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1410 times.
5640 infer(delta_poc_msb_cycle_lt[i], 0);
1655 }
1656 }
1657
1658
2/2
✓ Branch 0 taken 6304 times.
✓ Branch 1 taken 2646 times.
17900 if (sps->sps_temporal_mvp_enabled_flag)
1659
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6304 times.
12608 flag(slice_temporal_mvp_enabled_flag);
1660 else
1661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1323 times.
5292 infer(slice_temporal_mvp_enabled_flag, 0);
1662
1663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8950 times.
17900 if (pps->pps_curr_pic_ref_enabled_flag)
1664 ✗ ++num_pic_total_curr;
1665 }
1666
1667
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 3398 times.
18156 if (sps->sample_adaptive_offset_enabled_flag) {
1668
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5680 times.
11360 flag(slice_sao_luma_flag);
1669
2/4
✓ Branch 0 taken 5680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5680 times.
✗ Branch 3 not taken.
11360 if (!sps->separate_colour_plane_flag && sps->chroma_format_idc != 0)
1670
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5680 times.
11360 flag(slice_sao_chroma_flag);
1671 else
1672 ✗ infer(slice_sao_chroma_flag, 0);
1673 } else {
1674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1634 times.
6796 infer(slice_sao_luma_flag, 0);
1675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1634 times.
6796 infer(slice_sao_chroma_flag, 0);
1676 }
1677
1678
2/2
✓ Branch 0 taken 5706 times.
✓ Branch 1 taken 3372 times.
18156 if (current->slice_type == HEVC_SLICE_P ||
1679
2/2
✓ Branch 0 taken 5473 times.
✓ Branch 1 taken 233 times.
11412 current->slice_type == HEVC_SLICE_B) {
1680
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8845 times.
17690 flag(num_ref_idx_active_override_flag);
1681
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 5132 times.
17690 if (current->num_ref_idx_active_override_flag) {
1682
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3713 times.
7426 ue(num_ref_idx_l0_active_minus1, 0, 14);
1683
2/2
✓ Branch 0 taken 973 times.
✓ Branch 1 taken 2740 times.
7426 if (current->slice_type == HEVC_SLICE_B)
1684
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 973 times.
1946 ue(num_ref_idx_l1_active_minus1, 0, 14);
1685 else
1686
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);
1687 } else {
1688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2184 times.
10264 infer(num_ref_idx_l0_active_minus1, pps->num_ref_idx_l0_default_active_minus1);
1689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2184 times.
10264 infer(num_ref_idx_l1_active_minus1, pps->num_ref_idx_l1_default_active_minus1);
1690 }
1691
1692
4/4
✓ Branch 0 taken 1548 times.
✓ Branch 1 taken 7297 times.
✓ Branch 2 taken 1496 times.
✓ Branch 3 taken 52 times.
17690 if (pps->lists_modification_present_flag && num_pic_total_curr > 1)
1693
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1496 times.
2992 CHECK(FUNC(ref_pic_lists_modification)(ctx, rw, current,
1694 num_pic_total_curr));
1695
1696
2/2
✓ Branch 0 taken 5473 times.
✓ Branch 1 taken 3372 times.
17690 if (current->slice_type == HEVC_SLICE_B)
1697
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5473 times.
10946 flag(mvd_l1_zero_flag);
1698
2/2
✓ Branch 0 taken 6025 times.
✓ Branch 1 taken 2820 times.
17690 if (pps->cabac_init_present_flag)
1699
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6025 times.
12050 flag(cabac_init_flag);
1700 else
1701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1410 times.
5640 infer(cabac_init_flag, 0);
1702
2/2
✓ Branch 0 taken 6209 times.
✓ Branch 1 taken 2636 times.
17690 if (current->slice_temporal_mvp_enabled_flag) {
1703
2/2
✓ Branch 0 taken 5473 times.
✓ Branch 1 taken 736 times.
12418 if (current->slice_type == HEVC_SLICE_B)
1704
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5473 times.
10946 flag(collocated_from_l0_flag);
1705 else
1706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
1472 infer(collocated_from_l0_flag, 1);
1707
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 3344 times.
12418 if (current->collocated_from_l0_flag) {
1708
2/2
✓ Branch 0 taken 2625 times.
✓ Branch 1 taken 240 times.
5730 if (current->num_ref_idx_l0_active_minus1 > 0)
1709
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2625 times.
5250 ue(collocated_ref_idx, 0, current->num_ref_idx_l0_active_minus1);
1710 else
1711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
480 infer(collocated_ref_idx, 0);
1712 } else {
1713
2/2
✓ Branch 0 taken 3142 times.
✓ Branch 1 taken 202 times.
6688 if (current->num_ref_idx_l1_active_minus1 > 0)
1714
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3142 times.
6284 ue(collocated_ref_idx, 0, current->num_ref_idx_l1_active_minus1);
1715 else
1716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
404 infer(collocated_ref_idx, 0);
1717 }
1718 }
1719
1720
3/4
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 8331 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 514 times.
17690 if ((pps->weighted_pred_flag && current->slice_type == HEVC_SLICE_P) ||
1721
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8331 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16662 (pps->weighted_bipred_flag && current->slice_type == HEVC_SLICE_B))
1722
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 514 times.
1028 CHECK(FUNC(pred_weight_table)(ctx, rw, current));
1723
1724
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8845 times.
17690 ue(five_minus_max_num_merge_cand, 0, 4);
1725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8845 times.
17690 if (sps->motion_vector_resolution_control_idc == 2)
1726 ✗ flag(use_integer_mv_flag);
1727 else
1728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4022 times.
17690 infer(use_integer_mv_flag, sps->motion_vector_resolution_control_idc);
1729 }
1730
1731
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9078 times.
18156 se(slice_qp_delta,
1732 - 6 * sps->bit_depth_luma_minus8 - (pps->init_qp_minus26 + 26),
1733 + 51 - (pps->init_qp_minus26 + 26));
1734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9078 times.
18156 if (pps->pps_slice_chroma_qp_offsets_present_flag) {
1735 ✗ se(slice_cb_qp_offset, -12, +12);
1736 ✗ se(slice_cr_qp_offset, -12, +12);
1737 } else {
1738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4134 times.
18156 infer(slice_cb_qp_offset, 0);
1739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4134 times.
18156 infer(slice_cr_qp_offset, 0);
1740 }
1741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9078 times.
18156 if (pps->pps_slice_act_qp_offsets_present_flag) {
1742 ✗ se(slice_act_y_qp_offset,
1743 -12 - (pps->pps_act_y_qp_offset_plus5 - 5),
1744 +12 - (pps->pps_act_y_qp_offset_plus5 - 5));
1745 ✗ se(slice_act_cb_qp_offset,
1746 -12 - (pps->pps_act_cb_qp_offset_plus5 - 5),
1747 +12 - (pps->pps_act_cb_qp_offset_plus5 - 5));
1748 ✗ se(slice_act_cr_qp_offset,
1749 -12 - (pps->pps_act_cr_qp_offset_plus3 - 3),
1750 +12 - (pps->pps_act_cr_qp_offset_plus3 - 3));
1751 } else {
1752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4134 times.
18156 infer(slice_act_y_qp_offset, 0);
1753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4134 times.
18156 infer(slice_act_cb_qp_offset, 0);
1754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4134 times.
18156 infer(slice_act_cr_qp_offset, 0);
1755 }
1756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9078 times.
18156 if (pps->chroma_qp_offset_list_enabled_flag)
1757 ✗ flag(cu_chroma_qp_offset_enabled_flag);
1758 else
1759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4134 times.
18156 infer(cu_chroma_qp_offset_enabled_flag, 0);
1760
1761
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 9004 times.
18156 if (pps->deblocking_filter_override_enabled_flag)
1762
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
148 flag(deblocking_filter_override_flag);
1763 else
1764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4097 times.
18008 infer(deblocking_filter_override_flag, 0);
1765
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9076 times.
18156 if (current->deblocking_filter_override_flag) {
1766
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
4 flag(slice_deblocking_filter_disabled_flag);
1767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
4 if (!current->slice_deblocking_filter_disabled_flag) {
1768 ✗ se(slice_beta_offset_div2, -6, +6);
1769 ✗ se(slice_tc_offset_div2, -6, +6);
1770 } else {
1771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
4 infer(slice_beta_offset_div2, pps->pps_beta_offset_div2);
1772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
4 infer(slice_tc_offset_div2, pps->pps_tc_offset_div2);
1773 }
1774 } else {
1775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4133 times.
18152 infer(slice_deblocking_filter_disabled_flag,
1776 pps->pps_deblocking_filter_disabled_flag);
1777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4133 times.
18152 infer(slice_beta_offset_div2, pps->pps_beta_offset_div2);
1778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4133 times.
18152 infer(slice_tc_offset_div2, pps->pps_tc_offset_div2);
1779 }
1780
2/2
✓ Branch 0 taken 7588 times.
✓ Branch 1 taken 1490 times.
18156 if (pps->pps_loop_filter_across_slices_enabled_flag &&
1781
3/4
✓ Branch 0 taken 5390 times.
✓ Branch 1 taken 2198 times.
✓ Branch 2 taken 5390 times.
✗ Branch 3 not taken.
15176 (current->slice_sao_luma_flag || current->slice_sao_chroma_flag ||
1782
2/2
✓ Branch 0 taken 5388 times.
✓ Branch 1 taken 2 times.
10780 !current->slice_deblocking_filter_disabled_flag))
1783
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7586 times.
15172 flag(slice_loop_filter_across_slices_enabled_flag);
1784 else
1785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 746 times.
2984 infer(slice_loop_filter_across_slices_enabled_flag,
1786 pps->pps_loop_filter_across_slices_enabled_flag);
1787 }
1788
1789
4/4
✓ Branch 0 taken 10852 times.
✓ Branch 1 taken 2736 times.
✓ Branch 2 taken 2365 times.
✓ Branch 3 taken 8487 times.
27176 if (pps->tiles_enabled_flag || pps->entropy_coding_sync_enabled_flag) {
1790 unsigned int num_entry_point_offsets_limit;
1791
3/4
✓ Branch 0 taken 2365 times.
✓ Branch 1 taken 2736 times.
✓ Branch 2 taken 2365 times.
✗ Branch 3 not taken.
10202 if (!pps->tiles_enabled_flag && pps->entropy_coding_sync_enabled_flag)
1792 4730 num_entry_point_offsets_limit = pic_height_in_ctbs_y - 1;
1793
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)
1794 5472 num_entry_point_offsets_limit =
1795 5472 (pps->num_tile_columns_minus1 + 1) * (pps->num_tile_rows_minus1 + 1);
1796 else
1797 ✗ num_entry_point_offsets_limit =
1798 ✗ (pps->num_tile_columns_minus1 + 1) * pic_height_in_ctbs_y - 1;
1799
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5101 times.
10202 ue(num_entry_point_offsets, 0, num_entry_point_offsets_limit);
1800
1801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5101 times.
10202 if (current->num_entry_point_offsets > HEVC_MAX_ENTRY_POINT_OFFSETS) {
1802 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "Too many entry points: "
1803 ✗ "%"PRIu16".\n", current->num_entry_point_offsets);
1804 ✗ return AVERROR_PATCHWELCOME;
1805 }
1806
1807
2/2
✓ Branch 0 taken 1703 times.
✓ Branch 1 taken 3398 times.
10202 if (current->num_entry_point_offsets > 0) {
1808
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1703 times.
3406 ue(offset_len_minus1, 0, 31);
1809
2/2
✓ Branch 0 taken 3481 times.
✓ Branch 1 taken 1703 times.
10368 for (i = 0; i < current->num_entry_point_offsets; i++)
1810
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3481 times.
6962 ubs(current->offset_len_minus1 + 1, entry_point_offset_minus1[i], 1, i);
1811 }
1812 }
1813
1814
2/2
✓ Branch 0 taken 2365 times.
✓ Branch 1 taken 11223 times.
27176 if (pps->slice_segment_header_extension_present_flag) {
1815
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2365 times.
4730 ue(slice_segment_header_extension_length, 0, 256);
1816
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 2365 times.
38400 for (i = 0; i < current->slice_segment_header_extension_length; i++)
1817
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 16835 times.
33670 us(8, slice_segment_header_extension_data_byte[i], 0x00, 0xff, 1, i);
1818 }
1819
1820
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 13588 times.
27176 CHECK(FUNC(byte_alignment)(ctx, rw));
1821
1822 27176 return 0;
1823 }
1824
1825 60 SEI_FUNC(sei_buffering_period, (CodedBitstreamContext *ctx, RWContext *rw,
1826 H265RawSEIBufferingPeriod *current,
1827 SEIMessageState *sei))
1828 {
1829 30 CodedBitstreamH265Context *h265 = ctx->priv_data;
1830 const H265RawSPS *sps;
1831 const H265RawHRDParameters *hrd;
1832 int err, i, length;
1833
1834 #ifdef READ
1835 int start_pos, end_pos;
1836 10 start_pos = get_bits_count(rw);
1837 #endif
1838
1839 30 HEADER("Buffering Period");
1840
1841
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 ue(bp_seq_parameter_set_id, 0, HEVC_MAX_SPS_COUNT - 1);
1842
1843 30 sps = h265->sps[current->bp_seq_parameter_set_id];
1844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 if (!sps) {
1845 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "SPS id %d not available.\n",
1846 ✗ current->bp_seq_parameter_set_id);
1847 ✗ return AVERROR_INVALIDDATA;
1848 }
1849 30 h265->active_sps = sps;
1850
1851
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 if (!sps->vui_parameters_present_flag ||
1852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 !sps->vui.vui_hrd_parameters_present_flag) {
1853 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "Buffering period SEI requires "
1854 "HRD parameters to be present in SPS.\n");
1855 ✗ return AVERROR_INVALIDDATA;
1856 }
1857 30 hrd = &sps->vui.hrd_parameters;
1858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 if (!hrd->nal_hrd_parameters_present_flag &&
1859 ✗ !hrd->vcl_hrd_parameters_present_flag) {
1860 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "Buffering period SEI requires "
1861 "NAL or VCL HRD parameters to be present.\n");
1862 ✗ return AVERROR_INVALIDDATA;
1863 }
1864
1865
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9 times.
30 if (!hrd->sub_pic_hrd_params_present_flag)
1866
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
12 flag(irap_cpb_params_present_flag);
1867 else
1868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
18 infer(irap_cpb_params_present_flag, 0);
1869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
30 if (current->irap_cpb_params_present_flag) {
1870 ✗ length = hrd->au_cpb_removal_delay_length_minus1 + 1;
1871 ✗ ub(length, cpb_delay_offset);
1872 ✗ length = hrd->dpb_output_delay_length_minus1 + 1;
1873 ✗ ub(length, dpb_delay_offset);
1874 } else {
1875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
30 infer(cpb_delay_offset, 0);
1876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
30 infer(dpb_delay_offset, 0);
1877 }
1878
1879
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 flag(concatenation_flag);
1880
1881 30 length = hrd->au_cpb_removal_delay_length_minus1 + 1;
1882
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 ub(length, au_cpb_removal_delay_delta_minus1);
1883
1884
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 if (hrd->nal_hrd_parameters_present_flag) {
1885
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 15 times.
60 for (i = 0; i <= hrd->cpb_cnt_minus1[0]; i++) {
1886 30 length = hrd->initial_cpb_removal_delay_length_minus1 + 1;
1887
1888
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 ubs(length, nal_initial_cpb_removal_delay[i], 1, i);
1889
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 ubs(length, nal_initial_cpb_removal_offset[i], 1, i);
1890
1891
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9 times.
30 if (hrd->sub_pic_hrd_params_present_flag ||
1892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
12 current->irap_cpb_params_present_flag) {
1893
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 ubs(length, nal_initial_alt_cpb_removal_delay[i], 1, i);
1894
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 ubs(length, nal_initial_alt_cpb_removal_offset[i], 1, i);
1895 }
1896 }
1897 }
1898
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 if (hrd->vcl_hrd_parameters_present_flag) {
1899
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 15 times.
60 for (i = 0; i <= hrd->cpb_cnt_minus1[0]; i++) {
1900 30 length = hrd->initial_cpb_removal_delay_length_minus1 + 1;
1901
1902
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 ubs(length, vcl_initial_cpb_removal_delay[i], 1, i);
1903
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 ubs(length, vcl_initial_cpb_removal_offset[i], 1, i);
1904
1905
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9 times.
30 if (hrd->sub_pic_hrd_params_present_flag ||
1906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
12 current->irap_cpb_params_present_flag) {
1907
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 ubs(length, vcl_initial_alt_cpb_removal_delay[i], 1, i);
1908
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 ubs(length, vcl_initial_alt_cpb_removal_offset[i], 1, i);
1909 }
1910 }
1911 }
1912
1913 #ifdef READ
1914 10 end_pos = get_bits_count(rw);
1915
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
10 if (ff_cbs_h2645_payload_extension_present(rw, sei->payload_size,
1916 end_pos - start_pos))
1917 ✗ flag(use_alt_cpb_params_flag);
1918 else
1919 10 infer(use_alt_cpb_params_flag, 0);
1920 #else
1921 // If unknown extension data exists, then use_alt_cpb_params_flag is
1922 // coded in the bitstream and must be written even if it's 0.
1923
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) {
1924 ✗ flag(use_alt_cpb_params_flag);
1925 // Ensure this bit is not the last in the payload by making the
1926 // more_data_in_payload() check evaluate to true, so it may not
1927 // be mistaken as something else by decoders.
1928 ✗ sei->extension_present = 1;
1929 }
1930 #endif
1931
1932 30 return 0;
1933 }
1934
1935 1872 SEI_FUNC(sei_pic_timing, (CodedBitstreamContext *ctx, RWContext *rw,
1936 H265RawSEIPicTiming *current, SEIMessageState *sei))
1937 {
1938 936 CodedBitstreamH265Context *h265 = ctx->priv_data;
1939 const H265RawSPS *sps;
1940 const H265RawHRDParameters *hrd;
1941 int err, expected_source_scan_type, i, length;
1942
1943 936 HEADER("Picture Timing");
1944
1945 936 sps = h265->active_sps;
1946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
936 if (!sps) {
1947 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR,
1948 "No active SPS for pic_timing.\n");
1949 ✗ return AVERROR_INVALIDDATA;
1950 }
1951
1952 936 expected_source_scan_type = 2 -
1953 936 2 * sps->profile_tier_level.general_interlaced_source_flag -
1954 936 sps->profile_tier_level.general_progressive_source_flag;
1955
1956
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 288 times.
936 if (sps->vui.frame_field_info_present_flag) {
1957
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
360 u(4, pic_struct, 0, 12);
1958
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,
1959 expected_source_scan_type >= 0 ? expected_source_scan_type : 0,
1960 expected_source_scan_type >= 0 ? expected_source_scan_type : 2);
1961
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 180 times.
360 flag(duplicate_flag);
1962 } else {
1963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
576 infer(pic_struct, 0);
1964
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,
1965 expected_source_scan_type >= 0 ? expected_source_scan_type : 2);
1966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
576 infer(duplicate_flag, 0);
1967 }
1968
1969
1/2
✓ Branch 0 taken 468 times.
✗ Branch 1 not taken.
936 if (sps->vui_parameters_present_flag &&
1970
1/2
✓ Branch 0 taken 468 times.
✗ Branch 1 not taken.
936 sps->vui.vui_hrd_parameters_present_flag)
1971 936 hrd = &sps->vui.hrd_parameters;
1972 else
1973 ✗ hrd = NULL;
1974
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 ||
1975 ✗ hrd->vcl_hrd_parameters_present_flag)) {
1976 936 length = hrd->au_cpb_removal_delay_length_minus1 + 1;
1977
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 468 times.
936 ub(length, au_cpb_removal_delay_minus1);
1978
1979 936 length = hrd->dpb_output_delay_length_minus1 + 1;
1980
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 468 times.
936 ub(length, pic_dpb_output_delay);
1981
1982
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 180 times.
936 if (hrd->sub_pic_hrd_params_present_flag) {
1983 576 length = hrd->dpb_output_delay_du_length_minus1 + 1;
1984
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 288 times.
576 ub(length, pic_dpb_output_du_delay);
1985 }
1986
1987
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 180 times.
936 if (hrd->sub_pic_hrd_params_present_flag &&
1988
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
576 hrd->sub_pic_cpb_params_in_pic_timing_sei_flag) {
1989 unsigned int pic_width_in_ctbs_y, pic_height_in_ctbs_y;
1990 576 cbs_h265_pic_size_in_ctbs(sps, &pic_width_in_ctbs_y, &pic_height_in_ctbs_y);
1991 // D.3.3 bounds this by PicSizeInCtbsY - 1. A decoding unit holds at
1992 // least one VCL NAL unit (3.47) and no level allows a picture more
1993 // than HEVC_MAX_SLICE_SEGMENTS slice segments (A.4.2), which is also
1994 // the size of the arrays indexed by it.
1995
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 288 times.
576 ue(num_decoding_units_minus1, 0,
1996 FFMIN(pic_width_in_ctbs_y * pic_height_in_ctbs_y, HEVC_MAX_SLICE_SEGMENTS) - 1);
1997
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 288 times.
576 flag(du_common_cpb_removal_delay_flag);
1998
1999 576 length = hrd->du_cpb_removal_delay_increment_length_minus1 + 1;
2000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
576 if (current->du_common_cpb_removal_delay_flag)
2001 ✗ ub(length, du_common_cpb_removal_delay_increment_minus1);
2002
2003
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 288 times.
2880 for (i = 0; i <= current->num_decoding_units_minus1; i++) {
2004
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1152 times.
2304 ues(num_nalus_in_du_minus1[i],
2005 0, HEVC_MAX_SLICE_SEGMENTS, 1, i);
2006
1/2
✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
2304 if (!current->du_common_cpb_removal_delay_flag &&
2007
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 288 times.
2304 i < current->num_decoding_units_minus1)
2008
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 864 times.
1728 ubs(length, du_cpb_removal_delay_increment_minus1[i], 1, i);
2009 }
2010 }
2011 }
2012
2013 936 return 0;
2014 }
2015
2016 ✗ SEI_FUNC(sei_pan_scan_rect, (CodedBitstreamContext *ctx, RWContext *rw,
2017 H265RawSEIPanScanRect *current,
2018 SEIMessageState *sei))
2019 {
2020 int err, i;
2021
2022 ✗ HEADER("Pan-Scan Rectangle");
2023
2024 ✗ ue(pan_scan_rect_id, 0, UINT32_MAX - 1);
2025 ✗ flag(pan_scan_rect_cancel_flag);
2026
2027 ✗ if (!current->pan_scan_rect_cancel_flag) {
2028 ✗ ue(pan_scan_cnt_minus1, 0, 2);
2029
2030 ✗ for (i = 0; i <= current->pan_scan_cnt_minus1; i++) {
2031 ✗ ses(pan_scan_rect_left_offset[i], INT32_MIN + 1, INT32_MAX, 1, i);
2032 ✗ ses(pan_scan_rect_right_offset[i], INT32_MIN + 1, INT32_MAX, 1, i);
2033 ✗ ses(pan_scan_rect_top_offset[i], INT32_MIN + 1, INT32_MAX, 1, i);
2034 ✗ ses(pan_scan_rect_bottom_offset[i], INT32_MIN + 1, INT32_MAX, 1, i);
2035 }
2036
2037 ✗ flag(pan_scan_rect_persistence_flag);
2038 }
2039
2040 ✗ return 0;
2041 }
2042
2043 60 SEI_FUNC(sei_recovery_point, (CodedBitstreamContext *ctx, RWContext *rw,
2044 H265RawSEIRecoveryPoint *current,
2045 SEIMessageState *sei))
2046 {
2047 int err;
2048
2049 30 HEADER("Recovery Point");
2050
2051
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 se(recovery_poc_cnt, -32768, 32767);
2052
2053
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 flag(exact_match_flag);
2054
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
30 flag(broken_link_flag);
2055
2056 30 return 0;
2057 }
2058
2059 ✗ SEI_FUNC(film_grain_characteristics, (CodedBitstreamContext *ctx, RWContext *rw,
2060 H265RawFilmGrainCharacteristics *current,
2061 SEIMessageState *state))
2062 {
2063 ✗ CodedBitstreamH265Context *h265 = ctx->priv_data;
2064 ✗ const H265RawSPS *sps = h265->active_sps;
2065 int err, c, i, j;
2066
2067 ✗ HEADER("Film Grain Characteristics");
2068
2069 ✗ flag(film_grain_characteristics_cancel_flag);
2070 ✗ if (!current->film_grain_characteristics_cancel_flag) {
2071 int filmGrainBitDepth[3];
2072
2073 ✗ u(2, film_grain_model_id, 0, 1);
2074 ✗ flag(separate_colour_description_present_flag);
2075 ✗ if (current->separate_colour_description_present_flag) {
2076 ✗ ub(3, film_grain_bit_depth_luma_minus8);
2077 ✗ ub(3, film_grain_bit_depth_chroma_minus8);
2078 ✗ flag(film_grain_full_range_flag);
2079 ✗ ub(8, film_grain_colour_primaries);
2080 ✗ ub(8, film_grain_transfer_characteristics);
2081 ✗ ub(8, film_grain_matrix_coeffs);
2082 } else {
2083 ✗ if (!sps) {
2084 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR,
2085 "No active SPS for film_grain_characteristics.\n");
2086 ✗ return AVERROR_INVALIDDATA;
2087 }
2088 ✗ infer(film_grain_bit_depth_luma_minus8, sps->bit_depth_luma_minus8);
2089 ✗ infer(film_grain_bit_depth_chroma_minus8, sps->bit_depth_chroma_minus8);
2090 ✗ infer(film_grain_full_range_flag, sps->vui.video_full_range_flag);
2091 ✗ infer(film_grain_colour_primaries, sps->vui.colour_primaries);
2092 ✗ infer(film_grain_transfer_characteristics, sps->vui.transfer_characteristics);
2093 ✗ infer(film_grain_matrix_coeffs, sps->vui.matrix_coefficients);
2094 }
2095
2096 ✗ filmGrainBitDepth[0] = current->film_grain_bit_depth_luma_minus8 + 8;
2097 ✗ filmGrainBitDepth[1] =
2098 ✗ filmGrainBitDepth[2] = current->film_grain_bit_depth_chroma_minus8 + 8;
2099
2100 ✗ u(2, blending_mode_id, 0, 1);
2101 ✗ ub(4, log2_scale_factor);
2102 ✗ for (c = 0; c < 3; c++)
2103 ✗ flags(comp_model_present_flag[c], 1, c);
2104 ✗ for (c = 0; c < 3; c++) {
2105 ✗ if (current->comp_model_present_flag[c]) {
2106 ✗ ubs(8, num_intensity_intervals_minus1[c], 1, c);
2107 ✗ us(3, num_model_values_minus1[c], 0, 5, 1, c);
2108 ✗ for (i = 0; i <= current->num_intensity_intervals_minus1[c]; i++) {
2109 ✗ ubs(8, intensity_interval_lower_bound[c][i], 2, c, i);
2110 ✗ ubs(8, intensity_interval_upper_bound[c][i], 2, c, i);
2111 ✗ for (j = 0; j <= current->num_model_values_minus1[c]; j++)
2112 ✗ ses(comp_model_value[c][i][j], 0 - current->film_grain_model_id * (1 << (filmGrainBitDepth[c] - 1)),
2113 ((1 << filmGrainBitDepth[c]) - 1) - current->film_grain_model_id * (1 << (filmGrainBitDepth[c] - 1)),
2114 3, c, i, j);
2115 }
2116 }
2117 }
2118 ✗ flag(film_grain_characteristics_persistence_flag);
2119 }
2120
2121 ✗ return 0;
2122 }
2123
2124 ✗ SEI_FUNC(sei_display_orientation, (CodedBitstreamContext *ctx, RWContext *rw,
2125 H265RawSEIDisplayOrientation *current,
2126 SEIMessageState *sei))
2127 {
2128 int err;
2129
2130 ✗ HEADER("Display Orientation");
2131
2132 ✗ flag(display_orientation_cancel_flag);
2133 ✗ if (!current->display_orientation_cancel_flag) {
2134 ✗ flag(hor_flip);
2135 ✗ flag(ver_flip);
2136 ✗ ub(16, anticlockwise_rotation);
2137 ✗ flag(display_orientation_persistence_flag);
2138 }
2139
2140 ✗ return 0;
2141 }
2142
2143 36 SEI_FUNC(sei_active_parameter_sets, (CodedBitstreamContext *ctx, RWContext *rw,
2144 H265RawSEIActiveParameterSets *current,
2145 SEIMessageState *sei))
2146 {
2147 18 CodedBitstreamH265Context *h265 = ctx->priv_data;
2148 const H265RawVPS *vps;
2149 int err, i;
2150
2151 18 HEADER("Active Parameter Sets");
2152
2153
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 u(4, active_video_parameter_set_id, 0, HEVC_MAX_VPS_COUNT);
2154 18 vps = h265->vps[current->active_video_parameter_set_id];
2155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
18 if (!vps) {
2156 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "VPS id %d not available for active "
2157 ✗ "parameter sets.\n", current->active_video_parameter_set_id);
2158 ✗ return AVERROR_INVALIDDATA;
2159 }
2160 18 h265->active_vps = vps;
2161
2162
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 flag(self_contained_cvs_flag);
2163
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 flag(no_parameter_set_update_flag);
2164
2165
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
18 ue(num_sps_ids_minus1, 0, HEVC_MAX_SPS_COUNT - 1);
2166
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
36 for (i = 0; i <= current->num_sps_ids_minus1; i++)
2167
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);
2168
2169 18 for (i = vps->vps_base_layer_internal_flag;
2170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
18 i <= FFMIN(62, vps->vps_max_layers_minus1); i++) {
2171 ✗ ues(layer_sps_idx[i], 0, current->num_sps_ids_minus1, 1, i);
2172
2173 ✗ if (i == 0)
2174 ✗ h265->active_sps = h265->sps[current->active_seq_parameter_set_id[current->layer_sps_idx[0]]];
2175 }
2176
2177 18 return 0;
2178 }
2179
2180 17896 SEI_FUNC(sei_decoded_picture_hash, (CodedBitstreamContext *ctx, RWContext *rw,
2181 H265RawSEIDecodedPictureHash *current,
2182 SEIMessageState *sei))
2183 {
2184 8948 CodedBitstreamH265Context *h265 = ctx->priv_data;
2185 8948 const H265RawSPS *sps = h265->active_sps;
2186 int err, c, i;
2187
2188 8948 HEADER("Decoded Picture Hash");
2189
2190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4474 times.
8948 if (!sps) {
2191 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR,
2192 "No active SPS for decoded picture hash.\n");
2193 ✗ return AVERROR_INVALIDDATA;
2194 }
2195
2196
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4474 times.
8948 u(8, hash_type, 0, 2);
2197
2198
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17896 times.
✓ Branch 2 taken 13422 times.
✓ Branch 3 taken 4474 times.
35792 for (c = 0; c < (sps->chroma_format_idc == 0 ? 1 : 3); c++) {
2199
2/2
✓ Branch 0 taken 12378 times.
✓ Branch 1 taken 1044 times.
26844 if (current->hash_type == 0) {
2200
2/2
✓ Branch 0 taken 198048 times.
✓ Branch 1 taken 12378 times.
420852 for (i = 0; i < 16; i++)
2201
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 198048 times.
396096 us(8, picture_md5[c][i], 0x00, 0xff, 2, c, i);
2202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1044 times.
2088 } else if (current->hash_type == 1) {
2203 ✗ us(16, picture_crc[c], 0x0000, 0xffff, 1, c);
2204
1/2
✓ Branch 0 taken 1044 times.
✗ Branch 1 not taken.
2088 } else if (current->hash_type == 2) {
2205
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1044 times.
2088 us(32, picture_checksum[c], 0x00000000, 0xffffffff, 1, c);
2206 }
2207 }
2208
2209 8948 return 0;
2210 }
2211
2212 ✗ SEI_FUNC(sei_time_code, (CodedBitstreamContext *ctx, RWContext *rw,
2213 H265RawSEITimeCode *current, SEIMessageState *sei))
2214 {
2215 int err, i;
2216
2217 ✗ HEADER("Time Code");
2218
2219 ✗ u(2, num_clock_ts, 1, 3);
2220
2221 ✗ for (i = 0; i < current->num_clock_ts; i++) {
2222 ✗ flags(clock_timestamp_flag[i], 1, i);
2223
2224 ✗ if (current->clock_timestamp_flag[i]) {
2225 ✗ flags(units_field_based_flag[i], 1, i);
2226 ✗ us(5, counting_type[i], 0, 6, 1, i);
2227 ✗ flags(full_timestamp_flag[i], 1, i);
2228 ✗ flags(discontinuity_flag[i], 1, i);
2229 ✗ flags(cnt_dropped_flag[i], 1, i);
2230
2231 ✗ ubs(9, n_frames[i], 1, i);
2232
2233 ✗ if (current->full_timestamp_flag[i]) {
2234 ✗ us(6, seconds_value[i], 0, 59, 1, i);
2235 ✗ us(6, minutes_value[i], 0, 59, 1, i);
2236 ✗ us(5, hours_value[i], 0, 23, 1, i);
2237 } else {
2238 ✗ flags(seconds_flag[i], 1, i);
2239 ✗ if (current->seconds_flag[i]) {
2240 ✗ us(6, seconds_value[i], 0, 59, 1, i);
2241 ✗ flags(minutes_flag[i], 1, i);
2242 ✗ if (current->minutes_flag[i]) {
2243 ✗ us(6, minutes_value[i], 0, 59, 1, i);
2244 ✗ flags(hours_flag[i], 1, i);
2245 ✗ if (current->hours_flag[i])
2246 ✗ us(5, hours_value[i], 0, 23, 1, i);
2247 }
2248 }
2249 }
2250
2251 ✗ ubs(5, time_offset_length[i], 1, i);
2252 ✗ if (current->time_offset_length[i] > 0)
2253 ✗ ibs(current->time_offset_length[i], time_offset_value[i], 1, i);
2254 else
2255 ✗ infer(time_offset_value[i], 0);
2256 }
2257 }
2258
2259 ✗ return 0;
2260 }
2261
2262 ✗ SEI_FUNC(sei_alpha_channel_info, (CodedBitstreamContext *ctx, RWContext *rw,
2263 H265RawSEIAlphaChannelInfo *current,
2264 SEIMessageState *sei))
2265 {
2266 int err, length;
2267
2268 ✗ HEADER("Alpha Channel Information");
2269
2270 ✗ flag(alpha_channel_cancel_flag);
2271 ✗ if (!current->alpha_channel_cancel_flag) {
2272 ✗ ub(3, alpha_channel_use_idc);
2273 ✗ ub(3, alpha_channel_bit_depth_minus8);
2274 ✗ length = current->alpha_channel_bit_depth_minus8 + 9;
2275 ✗ ub(length, alpha_transparent_value);
2276 ✗ ub(length, alpha_opaque_value);
2277 ✗ flag(alpha_channel_incr_flag);
2278 ✗ flag(alpha_channel_clip_flag);
2279 ✗ if (current->alpha_channel_clip_flag)
2280 ✗ flag(alpha_channel_clip_type_flag);
2281 } else {
2282 ✗ infer(alpha_channel_use_idc, 2);
2283 ✗ infer(alpha_channel_incr_flag, 0);
2284 ✗ infer(alpha_channel_clip_flag, 0);
2285 }
2286
2287 ✗ return 0;
2288 }
2289
2290 ✗ SEI_FUNC(sei_3d_reference_displays_info, (CodedBitstreamContext *ctx, RWContext *rw,
2291 H265RawSEI3DReferenceDisplaysInfo *current,
2292 SEIMessageState *sei))
2293 {
2294 int length;
2295 int err, i;
2296
2297 ✗ HEADER("Three Dimensional Reference Displays Information");
2298
2299 ✗ ue(prec_ref_display_width, 0, 31);
2300 ✗ flag(ref_viewing_distance_flag);
2301 ✗ if (current->ref_viewing_distance_flag)
2302 ✗ ue(prec_ref_viewing_dist, 0, 31);
2303 ✗ ue(num_ref_displays_minus1, 0, 31);
2304 ✗ for (i = 0; i <= current->num_ref_displays_minus1; i++) {
2305 ✗ ues(left_view_id[i], 0, MAX_UINT_BITS(15), 1, i);
2306 ✗ ues(right_view_id[i], 0, MAX_UINT_BITS(15), 1, i);
2307 ✗ us(6, exponent_ref_display_width[i], 0, 62, 1, i);
2308 ✗ if (!current->exponent_ref_display_width[i])
2309 ✗ length = FFMAX(0, (int)current->prec_ref_display_width - 30);
2310 else
2311 ✗ length = FFMAX(0, (int)current->exponent_ref_display_width[i] +
2312 (int)current->prec_ref_display_width - 31);
2313
2314 ✗ if (length > 32) {
2315 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "refDispWidthBits > 32 is not supported\n");
2316 ✗ return AVERROR_PATCHWELCOME;
2317 }
2318
2319 ✗ if (length)
2320 ✗ ubs(length, mantissa_ref_display_width[i], 1, i);
2321 else
2322 ✗ infer(mantissa_ref_display_width[i], 0);
2323 ✗ if (current->ref_viewing_distance_flag) {
2324 ✗ us(6, exponent_ref_viewing_distance[i], 0, 62, 1, i);
2325 ✗ if (!current->exponent_ref_viewing_distance[i])
2326 ✗ length = FFMAX(0, (int)current->prec_ref_viewing_dist - 30);
2327 else
2328 ✗ length = FFMAX(0, (int)current->exponent_ref_viewing_distance[i] +
2329 (int)current->prec_ref_viewing_dist - 31);
2330
2331 ✗ if (length > 32) {
2332 ✗ av_log(ctx->log_ctx, AV_LOG_ERROR, "refViewDistBits > 32 is not supported\n");
2333 ✗ return AVERROR_PATCHWELCOME;
2334 }
2335
2336 ✗ if (length)
2337 ✗ ubs(length, mantissa_ref_viewing_distance[i], 1, i);
2338 else
2339 ✗ infer(mantissa_ref_viewing_distance[i], 0);
2340 }
2341 ✗ flags(additional_shift_present_flag[i], 1, i);
2342 ✗ if (current->additional_shift_present_flag[i])
2343 ✗ us(10, num_sample_shift_plus512[i], 0, 1023, 1, i);
2344 }
2345 ✗ flag(three_dimensional_reference_displays_extension_flag);
2346
2347 ✗ return 0;
2348 }
2349
2350 6846 static int FUNC(sei)(CodedBitstreamContext *ctx, RWContext *rw,
2351 H265RawSEI *current, int prefix)
2352 {
2353 int err;
2354
2355
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 3081 times.
6846 if (prefix)
2356 684 HEADER("Prefix Supplemental Enhancement Information");
2357 else
2358 6162 HEADER("Suffix Supplemental Enhancement Information");
2359
2360
3/4
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 3081 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3423 times.
6846 CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
2361 prefix ? HEVC_NAL_SEI_PREFIX
2362 : HEVC_NAL_SEI_SUFFIX));
2363
2364
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3423 times.
6846 CHECK(FUNC_SEI(message_list)(ctx, rw, &current->message_list, prefix));
2365
2366
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3423 times.
6846 CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
2367
2368 6846 return 0;
2369 }
2370
2371
2372 ✗ static int FUNC(filler)(CodedBitstreamContext *ctx, RWContext *rw,
2373 H265RawFiller *current)
2374 {
2375 int err;
2376
2377 ✗ HEADER("Filler Data");
2378
2379 ✗ CHECK(FUNC(nal_unit_header)(ctx, rw, &current->nal_unit_header,
2380 HEVC_NAL_FD_NUT));
2381
2382 #ifdef READ
2383 ✗ while (show_bits(rw, 8) == 0xff) {
2384 ✗ fixed(8, ff_byte, 0xff);
2385 ✗ ++current->filler_size;
2386 }
2387 #else
2388 {
2389 uint32_t i;
2390 ✗ for (i = 0; i < current->filler_size; i++)
2391 ✗ fixed(8, ff_byte, 0xff);
2392 }
2393 #endif
2394
2395 ✗ CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
2396
2397 ✗ return 0;
2398 }
2399