26 fc(1, obu_forbidden_bit, 0, 0);
29 flag(obu_extension_flag);
30 flag(obu_has_size_field);
32 fc(1, obu_reserved_1bit, 0, 0);
34 if (current->obu_extension_flag) {
37 fc(3, extension_header_reserved_3bits, 0, 0);
49 fixed(1, trailing_one_bit, 1);
53 fixed(1, trailing_zero_bit, 0);
65 fixed(1, zero_bit, 0);
79 current->high_bitdepth) {
81 priv->
bit_depth = current->twelve_bit ? 12 : 10;
83 priv->
bit_depth = current->high_bitdepth ? 10 : 8;
87 infer(mono_chrome, 0);
90 priv->
num_planes = current->mono_chrome ? 1 : 3;
92 flag(color_description_present_flag);
93 if (current->color_description_present_flag) {
96 fb(8, matrix_coefficients);
103 if (current->mono_chrome) {
106 infer(subsampling_x, 1);
107 infer(subsampling_y, 1);
109 infer(separate_uv_delta_q, 0);
115 infer(subsampling_x, 0);
116 infer(subsampling_y, 0);
117 flag(separate_uv_delta_q);
123 infer(subsampling_x, 1);
124 infer(subsampling_y, 1);
126 infer(subsampling_x, 0);
127 infer(subsampling_y, 0);
130 fb(1, subsampling_x);
131 if (current->subsampling_x)
132 fb(1, subsampling_y);
134 infer(subsampling_y, 0);
136 infer(subsampling_x, 1);
137 infer(subsampling_y, 0);
140 if (current->subsampling_x && current->subsampling_y) {
145 flag(separate_uv_delta_q);
159 flag(equal_picture_interval);
160 if (current->equal_picture_interval)
171 fb(5, buffer_delay_length_minus_1);
172 fb(32, num_units_in_decoding_tick);
173 fb(5, buffer_removal_time_length_minus_1);
174 fb(5, frame_presentation_time_length_minus_1);
184 HEADER(
"Sequence Header");
189 flag(reduced_still_picture_header);
191 if (current->reduced_still_picture_header) {
192 infer(timing_info_present_flag, 0);
193 infer(decoder_model_info_present_flag, 0);
194 infer(initial_display_delay_present_flag, 0);
195 infer(operating_points_cnt_minus_1, 0);
196 infer(operating_point_idc[0], 0);
198 fb(5, seq_level_idx[0]);
200 infer(seq_tier[0], 0);
201 infer(decoder_model_present_for_this_op[0], 0);
202 infer(initial_display_delay_present_for_this_op[0], 0);
205 flag(timing_info_present_flag);
206 if (current->timing_info_present_flag) {
209 flag(decoder_model_info_present_flag);
210 if (current->decoder_model_info_present_flag) {
212 (
ctx, rw, ¤t->decoder_model_info));
215 infer(decoder_model_info_present_flag, 0);
218 flag(initial_display_delay_present_flag);
220 fb(5, operating_points_cnt_minus_1);
221 for (
i = 0;
i <= current->operating_points_cnt_minus_1;
i++) {
222 fbs(12, operating_point_idc[
i], 1,
i);
223 fbs(5, seq_level_idx[
i], 1,
i);
225 if (current->seq_level_idx[
i] > 7)
230 if (current->decoder_model_info_present_flag) {
231 flags(decoder_model_present_for_this_op[
i], 1,
i);
232 if (current->decoder_model_present_for_this_op[
i]) {
233 int n = current->decoder_model_info.buffer_delay_length_minus_1 + 1;
234 fbs(n, decoder_buffer_delay[
i], 1,
i);
235 fbs(n, encoder_buffer_delay[
i], 1,
i);
236 flags(low_delay_mode_flag[
i], 1,
i);
239 infer(decoder_model_present_for_this_op[
i], 0);
242 if (current->initial_display_delay_present_flag) {
243 flags(initial_display_delay_present_for_this_op[
i], 1,
i);
244 if (current->initial_display_delay_present_for_this_op[
i])
245 fbs(4, initial_display_delay_minus_1[
i], 1,
i);
250 fb(4, frame_width_bits_minus_1);
251 fb(4, frame_height_bits_minus_1);
253 fb(current->frame_width_bits_minus_1 + 1, max_frame_width_minus_1);
254 fb(current->frame_height_bits_minus_1 + 1, max_frame_height_minus_1);
256 if (current->reduced_still_picture_header)
257 infer(frame_id_numbers_present_flag, 0);
259 flag(frame_id_numbers_present_flag);
260 if (current->frame_id_numbers_present_flag) {
261 fb(4, delta_frame_id_length_minus_2);
262 fb(3, additional_frame_id_length_minus_1);
265 flag(use_128x128_superblock);
266 flag(enable_filter_intra);
267 flag(enable_intra_edge_filter);
269 if (current->reduced_still_picture_header) {
270 infer(enable_interintra_compound, 0);
271 infer(enable_masked_compound, 0);
272 infer(enable_warped_motion, 0);
273 infer(enable_dual_filter, 0);
274 infer(enable_order_hint, 0);
275 infer(enable_jnt_comp, 0);
276 infer(enable_ref_frame_mvs, 0);
278 infer(seq_force_screen_content_tools,
280 infer(seq_force_integer_mv,
283 flag(enable_interintra_compound);
284 flag(enable_masked_compound);
285 flag(enable_warped_motion);
286 flag(enable_dual_filter);
288 flag(enable_order_hint);
289 if (current->enable_order_hint) {
290 flag(enable_jnt_comp);
291 flag(enable_ref_frame_mvs);
293 infer(enable_jnt_comp, 0);
294 infer(enable_ref_frame_mvs, 0);
297 flag(seq_choose_screen_content_tools);
298 if (current->seq_choose_screen_content_tools)
299 infer(seq_force_screen_content_tools,
302 fb(1, seq_force_screen_content_tools);
303 if (current->seq_force_screen_content_tools > 0) {
304 flag(seq_choose_integer_mv);
305 if (current->seq_choose_integer_mv)
306 infer(seq_force_integer_mv,
309 fb(1, seq_force_integer_mv);
314 if (current->enable_order_hint)
315 fb(3, order_hint_bits_minus_1);
318 flag(enable_superres);
320 flag(enable_restoration);
323 current->seq_profile));
325 flag(film_grain_params_present);
334 HEADER(
"Temporal Delimiter");
352 int cur_frame_hint, latest_order_hint, earliest_order_hint,
ref;
356 ref_frame_idx[
i] = -1;
362 used_frame[current->last_frame_idx] = 1;
363 used_frame[current->golden_frame_idx] = 1;
367 shifted_order_hints[
i] = cur_frame_hint +
371 latest_order_hint = shifted_order_hints[current->last_frame_idx];
372 earliest_order_hint = shifted_order_hints[current->golden_frame_idx];
376 int hint = shifted_order_hints[
i];
377 if (!used_frame[
i] && hint >= cur_frame_hint &&
378 (ref < 0 || hint >= latest_order_hint)) {
380 latest_order_hint = hint;
390 int hint = shifted_order_hints[
i];
391 if (!used_frame[
i] && hint >= cur_frame_hint &&
392 (
ref < 0 || hint < earliest_order_hint)) {
394 earliest_order_hint = hint;
404 int hint = shifted_order_hints[
i];
405 if (!used_frame[
i] && hint >= cur_frame_hint &&
406 (
ref < 0 || hint < earliest_order_hint)) {
408 earliest_order_hint = hint;
417 int ref_frame = ref_frame_list[
i];
421 int hint = shifted_order_hints[j];
422 if (!used_frame[j] && hint < cur_frame_hint &&
423 (ref < 0 || hint >= latest_order_hint)) {
425 latest_order_hint = hint;
437 int hint = shifted_order_hints[
i];
438 if (
ref < 0 || hint < earliest_order_hint) {
440 earliest_order_hint = hint;
444 if (ref_frame_idx[
i] < 0)
445 ref_frame_idx[
i] =
ref;
446 infer(ref_frame_idx[
i], ref_frame_idx[
i]);
462 infer(use_superres, 0);
464 if (current->use_superres) {
485 if (current->frame_size_override_flag) {
489 priv->
frame_width = current->frame_width_minus_1 + 1;
507 flag(render_and_frame_size_different);
509 if (current->render_and_frame_size_different) {
510 fb(16, render_width_minus_1);
511 fb(16, render_height_minus_1);
531 if (current->found_ref[
i]) {
533 &priv->
ref[current->ref_frame_idx[
i]];
537 "Missing reference frame needed for frame size "
538 "(ref = %d, ref_frame_idx = %d).\n",
539 i, current->ref_frame_idx[
i]);
567 flag(is_filter_switchable);
568 if (current->is_filter_switchable)
582 int mi_cols, mi_rows, sb_cols, sb_rows, sb_shift, sb_size;
583 int max_tile_width_sb, max_tile_height_sb, max_tile_area_sb;
584 int min_log2_tile_cols, max_log2_tile_cols, max_log2_tile_rows;
585 int min_log2_tiles, min_log2_tile_rows;
592 : ((mi_cols + 15) >> 4);
594 : ((mi_rows + 15) >> 4);
597 sb_size = sb_shift + 2;
605 min_log2_tiles =
FFMAX(min_log2_tile_cols,
608 flag(uniform_tile_spacing_flag);
610 if (current->uniform_tile_spacing_flag) {
611 int tile_width_sb, tile_height_sb;
613 increment(tile_cols_log2, min_log2_tile_cols, max_log2_tile_cols);
615 tile_width_sb = (sb_cols + (1 << current->tile_cols_log2) - 1) >>
616 current->tile_cols_log2;
617 current->tile_cols = (sb_cols + tile_width_sb - 1) / tile_width_sb;
619 min_log2_tile_rows =
FFMAX(min_log2_tiles - current->tile_cols_log2, 0);
621 increment(tile_rows_log2, min_log2_tile_rows, max_log2_tile_rows);
623 tile_height_sb = (sb_rows + (1 << current->tile_rows_log2) - 1) >>
624 current->tile_rows_log2;
625 current->tile_rows = (sb_rows + tile_height_sb - 1) / tile_height_sb;
628 int widest_tile_sb, start_sb, size_sb, max_width, max_height;
634 max_width =
FFMIN(sb_cols - start_sb, max_tile_width_sb);
635 ns(max_width, width_in_sbs_minus_1[
i], 1,
i);
636 size_sb = current->width_in_sbs_minus_1[
i] + 1;
637 widest_tile_sb =
FFMAX(size_sb, widest_tile_sb);
641 current->tile_cols =
i;
643 if (min_log2_tiles > 0)
644 max_tile_area_sb = (sb_rows * sb_cols) >> (min_log2_tiles + 1);
646 max_tile_area_sb = sb_rows * sb_cols;
647 max_tile_height_sb =
FFMAX(max_tile_area_sb / widest_tile_sb, 1);
651 max_height =
FFMIN(sb_rows - start_sb, max_tile_height_sb);
652 ns(max_height, height_in_sbs_minus_1[
i], 1,
i);
653 size_sb = current->height_in_sbs_minus_1[
i] + 1;
657 current->tile_rows =
i;
660 if (current->tile_cols_log2 > 0 ||
661 current->tile_rows_log2 > 0) {
662 fb(current->tile_cols_log2 + current->tile_rows_log2,
663 context_update_tile_id);
664 fb(2, tile_size_bytes_minus1);
666 infer(context_update_tile_id, 0);
690 infer(diff_uv_delta, 0);
695 if (current->diff_uv_delta) {
699 infer(delta_q_v_dc, current->delta_q_u_dc);
700 infer(delta_q_v_ac, current->delta_q_u_ac);
703 infer(delta_q_u_dc, 0);
704 infer(delta_q_u_ac, 0);
705 infer(delta_q_v_dc, 0);
706 infer(delta_q_v_ac, 0);
710 if (current->using_qmatrix) {
716 infer(qm_v, current->qm_u);
729 flag(segmentation_enabled);
731 if (current->segmentation_enabled) {
733 infer(segmentation_update_map, 1);
734 infer(segmentation_temporal_update, 0);
735 infer(segmentation_update_data, 1);
737 flag(segmentation_update_map);
738 if (current->segmentation_update_map)
739 flag(segmentation_temporal_update);
741 infer(segmentation_temporal_update, 0);
742 flag(segmentation_update_data);
745 if (current->segmentation_update_data) {
748 flags(feature_enabled[
i][j], 2,
i, j);
750 if (current->feature_enabled[
i][j] &&
bits[j] > 0) {
752 sus(1 +
bits[j], feature_value[
i][j], 2,
i, j);
754 fbs(
bits[j], feature_value[
i][j], 2,
i, j);
756 infer(feature_value[
i][j], 0);
764 infer(feature_enabled[
i][j], 0);
765 infer(feature_value[
i][j], 0);
778 if (current->base_q_idx > 0)
779 flag(delta_q_present);
781 infer(delta_q_present, 0);
783 if (current->delta_q_present)
794 if (current->delta_q_present) {
795 if (!current->allow_intrabc)
796 flag(delta_lf_present);
798 infer(delta_lf_present, 0);
799 if (current->delta_lf_present) {
801 flag(delta_lf_multi);
803 infer(delta_lf_res, 0);
804 infer(delta_lf_multi, 0);
807 infer(delta_lf_present, 0);
808 infer(delta_lf_res, 0);
809 infer(delta_lf_multi, 0);
822 infer(loop_filter_level[0], 0);
823 infer(loop_filter_level[1], 0);
832 for (
i = 0;
i < 2;
i++)
833 infer(loop_filter_mode_deltas[
i], 0);
837 fb(6, loop_filter_level[0]);
838 fb(6, loop_filter_level[1]);
841 if (current->loop_filter_level[0] ||
842 current->loop_filter_level[1]) {
843 fb(6, loop_filter_level[2]);
844 fb(6, loop_filter_level[3]);
848 fb(3, loop_filter_sharpness);
850 flag(loop_filter_delta_enabled);
851 if (current->loop_filter_delta_enabled) {
852 flag(loop_filter_delta_update);
853 if (current->loop_filter_delta_update) {
855 flags(update_ref_delta[
i], 1,
i);
856 if (current->update_ref_delta[
i])
857 sus(1 + 6, loop_filter_ref_deltas[
i], 1,
i);
859 for (
i = 0;
i < 2;
i++) {
860 flags(update_mode_delta[
i], 1,
i);
861 if (current->update_mode_delta[
i])
862 sus(1 + 6, loop_filter_mode_deltas[
i], 1,
i);
879 infer(cdef_damping_minus_3, 0);
881 infer(cdef_y_pri_strength[0], 0);
882 infer(cdef_y_sec_strength[0], 0);
883 infer(cdef_uv_pri_strength[0], 0);
884 infer(cdef_uv_sec_strength[0], 0);
889 fb(2, cdef_damping_minus_3);
892 for (
i = 0;
i < (1 << current->cdef_bits);
i++) {
893 fbs(4, cdef_y_pri_strength[
i], 1,
i);
894 fbs(2, cdef_y_sec_strength[
i], 1,
i);
897 fbs(4, cdef_uv_pri_strength[
i], 1,
i);
898 fbs(2, cdef_uv_sec_strength[
i], 1,
i);
910 int uses_lr, uses_chroma_lr;
918 uses_lr = uses_chroma_lr = 0;
920 fbs(2, lr_type[
i], 1,
i);
922 if (current->lr_type[
i] != 0) {
939 infer(lr_uv_shift, 0);
967 infer(reference_select, 0);
969 flag(reference_select);
979 int skip_mode_allowed;
985 skip_mode_allowed = 0;
987 int forward_idx, backward_idx;
988 int forward_hint, backward_hint;
989 int ref_hint, dist,
i;
998 if (forward_idx < 0 ||
1000 forward_hint) > 0) {
1002 forward_hint = ref_hint;
1004 }
else if (dist > 0) {
1005 if (backward_idx < 0 ||
1007 backward_hint) < 0) {
1009 backward_hint = ref_hint;
1014 if (forward_idx < 0) {
1015 skip_mode_allowed = 0;
1016 }
else if (backward_idx >= 0) {
1017 skip_mode_allowed = 1;
1020 int second_forward_idx;
1021 int second_forward_hint;
1023 second_forward_idx = -1;
1027 forward_hint) < 0) {
1028 if (second_forward_idx < 0 ||
1030 second_forward_hint) > 0) {
1031 second_forward_idx =
i;
1032 second_forward_hint = ref_hint;
1037 if (second_forward_idx < 0) {
1038 skip_mode_allowed = 0;
1040 skip_mode_allowed = 1;
1046 if (skip_mode_allowed)
1047 flag(skip_mode_present);
1049 infer(skip_mode_present, 0);
1058 uint32_t abs_bits, prec_bits, num_syms;
1074 num_syms = 2 * (1 << abs_bits) + 1;
1095 if (current->is_global[
ref]) {
1097 if (current->is_rot_zoom[
ref]) {
1133 int num_pos_luma, num_pos_chroma;
1137 (!current->show_frame && !current->showable_frame))
1142 if (!current->apply_grain)
1150 infer(update_grain, 1);
1152 if (!current->update_grain) {
1153 fb(3, film_grain_params_ref_idx);
1157 fc(4, num_y_points, 0, 14);
1158 for (
i = 0;
i < current->num_y_points;
i++) {
1159 fcs(8, point_y_value[
i],
1160 i ? current->point_y_value[
i - 1] + 1 : 0,
1163 fbs(8, point_y_scaling[
i], 1,
i);
1167 infer(chroma_scaling_from_luma, 0);
1169 flag(chroma_scaling_from_luma);
1172 current->chroma_scaling_from_luma ||
1175 current->num_y_points == 0)) {
1176 infer(num_cb_points, 0);
1177 infer(num_cr_points, 0);
1179 fc(4, num_cb_points, 0, 10);
1180 for (
i = 0;
i < current->num_cb_points;
i++) {
1181 fcs(8, point_cb_value[
i],
1182 i ? current->point_cb_value[
i - 1] + 1 : 0,
1185 fbs(8, point_cb_scaling[
i], 1,
i);
1187 fc(4, num_cr_points, 0, 10);
1188 for (
i = 0;
i < current->num_cr_points;
i++) {
1189 fcs(8, point_cr_value[
i],
1190 i ? current->point_cr_value[
i - 1] + 1 : 0,
1193 fbs(8, point_cr_scaling[
i], 1,
i);
1197 fb(2, grain_scaling_minus_8);
1198 fb(2, ar_coeff_lag);
1199 num_pos_luma = 2 * current->ar_coeff_lag * (current->ar_coeff_lag + 1);
1200 if (current->num_y_points) {
1201 num_pos_chroma = num_pos_luma + 1;
1202 for (
i = 0;
i < num_pos_luma;
i++)
1203 fbs(8, ar_coeffs_y_plus_128[
i], 1,
i);
1205 num_pos_chroma = num_pos_luma;
1207 if (current->chroma_scaling_from_luma || current->num_cb_points) {
1208 for (
i = 0;
i < num_pos_chroma;
i++)
1209 fbs(8, ar_coeffs_cb_plus_128[
i], 1,
i);
1211 if (current->chroma_scaling_from_luma || current->num_cr_points) {
1212 for (
i = 0;
i < num_pos_chroma;
i++)
1213 fbs(8, ar_coeffs_cr_plus_128[
i], 1,
i);
1215 fb(2, ar_coeff_shift_minus_6);
1216 fb(2, grain_scale_shift);
1217 if (current->num_cb_points) {
1219 fb(8, cb_luma_mult);
1222 if (current->num_cr_points) {
1224 fb(8, cr_luma_mult);
1229 flag(clip_to_restricted_range);
1239 int id_len, diff_len, all_frames, frame_is_intra, order_hint_bits;
1244 "unable to decode frame header.\n");
1254 infer(show_existing_frame, 0);
1257 infer(showable_frame, 0);
1261 flag(show_existing_frame);
1263 if (current->show_existing_frame) {
1266 fb(3, frame_to_show_map_idx);
1267 ref = &priv->
ref[current->frame_to_show_map_idx];
1272 frame_presentation_time);
1276 fb(id_len, display_frame_id);
1280 infer(refresh_frame_flags, all_frames);
1283 infer(current_frame_id,
ref->frame_id);
1292 infer(refresh_frame_flags, 0);
1303 if (current->show_frame &&
1307 frame_presentation_time);
1309 if (current->show_frame)
1312 flag(showable_frame);
1315 (current->frame_type ==
AV1_FRAME_KEY && current->show_frame))
1316 infer(error_resilient_mode, 1);
1318 flag(error_resilient_mode);
1321 if (current->frame_type ==
AV1_FRAME_KEY && current->show_frame) {
1328 flag(disable_cdf_update);
1332 flag(allow_screen_content_tools);
1334 infer(allow_screen_content_tools,
1337 if (current->allow_screen_content_tools) {
1339 flag(force_integer_mv);
1343 infer(force_integer_mv, 0);
1347 fb(id_len, current_frame_id);
1351 if (current->current_frame_id > (1 << diff_len)) {
1352 if (priv->
ref[
i].
frame_id > current->current_frame_id ||
1357 if (priv->
ref[
i].
frame_id > current->current_frame_id &&
1359 current->current_frame_id -
1365 infer(current_frame_id, 0);
1369 infer(frame_size_override_flag, 1);
1371 infer(frame_size_override_flag, 0);
1373 flag(frame_size_override_flag);
1377 if (order_hint_bits > 0)
1378 fb(order_hint_bits, order_hint);
1380 infer(order_hint, 0);
1383 if (frame_is_intra || current->error_resilient_mode)
1386 fb(3, primary_ref_frame);
1389 flag(buffer_removal_time_present_flag);
1390 if (current->buffer_removal_time_present_flag) {
1394 int in_temporal_layer = (op_pt_idc >> priv->
temporal_id ) & 1;
1395 int in_spatial_layer = (op_pt_idc >> (priv->
spatial_id + 8)) & 1;
1397 (in_temporal_layer && in_spatial_layer)) {
1399 buffer_removal_time[
i], 1,
i);
1407 (current->frame_type ==
AV1_FRAME_KEY && current->show_frame))
1408 infer(refresh_frame_flags, all_frames);
1410 fb(8, refresh_frame_flags);
1412 if (!frame_is_intra || current->refresh_frame_flags != all_frames) {
1415 fbs(order_hint_bits, ref_order_hint[
i], 1,
i);
1427 if (current->allow_screen_content_tools &&
1429 flag(allow_intrabc);
1431 infer(allow_intrabc, 0);
1435 infer(frame_refs_short_signaling, 0);
1437 flag(frame_refs_short_signaling);
1438 if (current->frame_refs_short_signaling) {
1439 fb(3, last_frame_idx);
1440 fb(3, golden_frame_idx);
1446 if (!current->frame_refs_short_signaling)
1447 fbs(3, ref_frame_idx[
i], 1,
i);
1450 delta_frame_id_minus1[
i], 1,
i);
1454 if (current->frame_size_override_flag &&
1455 !current->error_resilient_mode) {
1462 if (current->force_integer_mv)
1463 infer(allow_high_precision_mv, 0);
1465 flag(allow_high_precision_mv);
1469 flag(is_motion_mode_switchable);
1471 if (current->error_resilient_mode ||
1473 infer(use_ref_frame_mvs, 0);
1475 flag(use_ref_frame_mvs);
1477 infer(allow_intrabc, 0);
1480 if (!frame_is_intra) {
1485 infer(disable_frame_end_update_cdf, 1);
1487 flag(disable_frame_end_update_cdf);
1497 if (current->use_ref_frame_mvs) {
1517 qindex = (current->base_q_idx +
1520 qindex = current->base_q_idx;
1522 qindex = av_clip_uintp2(qindex, 8);
1524 if (qindex || current->delta_q_y_dc ||
1525 current->delta_q_u_ac || current->delta_q_u_dc ||
1526 current->delta_q_v_ac || current->delta_q_v_dc) {
1545 if (frame_is_intra || current->error_resilient_mode ||
1547 infer(allow_warped_motion, 0);
1549 flag(allow_warped_motion);
1551 flag(reduced_tx_set);
1558 "upscaled %d render %dx%d subsample %dx%d "
1559 "bitdepth %d tiles %dx%d.\n", priv->
order_hint,
1568 if (current->refresh_frame_flags & (1 <<
i)) {
1571 .frame_id = current->current_frame_id,
1577 .frame_type = current->frame_type,
1594 int start_pos, fh_bits, fh_bytes, err;
1600 "frame header OBU.\n");
1607 HEADER(
"Redundant Frame Header");
1616 xf(
b, frame_header_copy[
i],
1622 HEADER(
"Redundant Frame Header (used as Frame Header)");
1634 if (current->show_existing_frame) {
1643 fh_start = (
uint8_t*)rw->buffer + start_pos / 8;
1653 fh_start = rw->buf + start_pos / 8;
1655 fh_bytes = (fh_bits + 7) / 8;
1659 if (rw_buffer_ref) {
1682 int num_tiles, tile_bits;
1689 flag(tile_start_and_end_present_flag);
1691 infer(tile_start_and_end_present_flag, 0);
1693 if (num_tiles == 1 || !current->tile_start_and_end_present_flag) {
1695 infer(tg_end, num_tiles - 1);
1699 fb(tile_bits, tg_start);
1700 fb(tile_bits, tg_end);
1706 if (current->tg_end == num_tiles - 1)
1735 fb(8, output_frame_width_in_tiles_minus_1);
1736 fb(8, output_frame_height_in_tiles_minus_1);
1738 fb(16, tile_count_minus_1);
1761 for (
i = 0;
i < 3;
i++) {
1762 fbs(16, primary_chromaticity_x[
i], 1,
i);
1763 fbs(16, primary_chromaticity_y[
i], 1,
i);
1766 fb(16, white_point_chromaticity_x);
1767 fb(16, white_point_chromaticity_y);
1772 fc(32, luminance_min, 0,
FFMIN(((uint64_t)current->luminance_max << 6) - 1,
1787 "unable to parse scalability metadata.\n");
1792 fb(2, spatial_layers_cnt_minus_1);
1793 flag(spatial_layer_dimensions_present_flag);
1794 flag(spatial_layer_description_present_flag);
1795 flag(temporal_group_description_present_flag);
1796 fc(3, scalability_structure_reserved_3bits, 0, 0);
1797 if (current->spatial_layer_dimensions_present_flag) {
1798 for (
i = 0;
i <= current->spatial_layers_cnt_minus_1;
i++) {
1799 fcs(16, spatial_layer_max_width[
i],
1801 fcs(16, spatial_layer_max_height[
i],
1805 if (current->spatial_layer_description_present_flag) {
1806 for (
i = 0;
i <= current->spatial_layers_cnt_minus_1;
i++)
1807 fbs(8, spatial_layer_ref_id[
i], 1,
i);
1809 if (current->temporal_group_description_present_flag) {
1810 fb(8, temporal_group_size);
1811 for (
i = 0;
i < current->temporal_group_size;
i++) {
1812 fbs(3, temporal_group_temporal_id[
i], 1,
i);
1813 flags(temporal_group_temporal_switching_up_point_flag[
i], 1,
i);
1814 flags(temporal_group_spatial_switching_up_point_flag[
i], 1,
i);
1815 fbs(3, temporal_group_ref_cnt[
i], 1,
i);
1816 for (j = 0; j < current->temporal_group_ref_cnt[
i]; j++) {
1817 fbs(8, temporal_group_ref_pic_diff[
i][j], 2,
i, j);
1830 fb(8, scalability_mode_idc);
1844 fb(8, itu_t_t35_country_code);
1845 if (current->itu_t_t35_country_code == 0xff)
1846 fb(8, itu_t_t35_country_code_extension_byte);
1854 if (!current->payload_ref)
1856 current->payload = current->payload_ref->data;
1859 for (
i = 0;
i < current->payload_size;
i++)
1860 xf(8, itu_t_t35_payload_bytes[
i], current->payload[
i],
1871 fb(5, counting_type);
1872 flag(full_timestamp_flag);
1873 flag(discontinuity_flag);
1874 flag(cnt_dropped_flag);
1877 if (current->full_timestamp_flag) {
1878 fc(6, seconds_value, 0, 59);
1879 fc(6, minutes_value, 0, 59);
1880 fc(5, hours_value, 0, 23);
1883 if (current->seconds_flag) {
1884 fc(6, seconds_value, 0, 59);
1886 if (current->minutes_flag) {
1887 fc(6, minutes_value, 0, 59);
1889 if (current->hours_flag)
1890 fc(5, hours_value, 0, 23);
1895 fb(5, time_offset_length);
1896 if (current->time_offset_length > 0)
1897 fb(current->time_offset_length, time_offset_value);
1899 infer(time_offset_length, 0);
1911 switch (current->metadata_type) {
1948 if (!current->payload_ref)
1950 current->payload = current->payload_ref->data;
1953 for (
i = 0;
i < current->payload_size;
i++)
1954 xf(8, obu_padding_byte[
i], current->payload[
i], 0x00, 0xff, 1,
i);