23 fixed(1, rbsp_stop_one_bit, 1);
25 fixed(1, rbsp_alignment_zero_bit, 0);
32 uint32_t valid_type_mask)
36 fixed(1, forbidden_zero_bit, 0);
40 if (!(1 << current->nal_unit_type & valid_type_mask)) {
42 current->nal_unit_type);
46 if (current->nal_unit_type == 14 ||
47 current->nal_unit_type == 20 ||
48 current->nal_unit_type == 21) {
49 if (current->nal_unit_type != 21)
50 flag(svc_extension_flag);
52 flag(avc_3d_extension_flag);
54 if (current->svc_extension_flag) {
58 }
else if (current->avc_3d_extension_flag) {
73 int size_of_scaling_list)
78 for (
i = 0;
i < size_of_scaling_list;
i++) {
79 ses(delta_scale[
i], -128, +127, 1,
i);
80 scale = (
scale + current->delta_scale[
i] + 256) % 256;
93 ue(cpb_cnt_minus1, 0, 31);
94 ub(4, bit_rate_scale);
95 ub(4, cpb_size_scale);
97 for (
i = 0;
i <= current->cpb_cnt_minus1;
i++) {
98 ues(bit_rate_value_minus1[
i], 0, UINT32_MAX - 1, 1,
i);
99 ues(cpb_size_value_minus1[
i], 0, UINT32_MAX - 1, 1,
i);
103 ub(5, initial_cpb_removal_delay_length_minus1);
104 ub(5, cpb_removal_delay_length_minus1);
105 ub(5, dpb_output_delay_length_minus1);
106 ub(5, time_offset_length);
116 flag(aspect_ratio_info_present_flag);
117 if (current->aspect_ratio_info_present_flag) {
118 ub(8, aspect_ratio_idc);
119 if (current->aspect_ratio_idc == 255) {
124 infer(aspect_ratio_idc, 0);
127 flag(overscan_info_present_flag);
128 if (current->overscan_info_present_flag)
129 flag(overscan_appropriate_flag);
131 flag(video_signal_type_present_flag);
132 if (current->video_signal_type_present_flag) {
134 flag(video_full_range_flag);
135 flag(colour_description_present_flag);
136 if (current->colour_description_present_flag) {
137 ub(8, colour_primaries);
139 ub(8, matrix_coefficients);
141 infer(colour_primaries, 2);
143 infer(matrix_coefficients, 2);
146 infer(video_format, 5);
147 infer(video_full_range_flag, 0);
148 infer(colour_primaries, 2);
150 infer(matrix_coefficients, 2);
153 flag(chroma_loc_info_present_flag);
154 if (current->chroma_loc_info_present_flag) {
155 ue(chroma_sample_loc_type_top_field, 0, 5);
156 ue(chroma_sample_loc_type_bottom_field, 0, 5);
158 infer(chroma_sample_loc_type_top_field, 0);
159 infer(chroma_sample_loc_type_bottom_field, 0);
162 flag(timing_info_present_flag);
163 if (current->timing_info_present_flag) {
164 u(32, num_units_in_tick, 1, UINT32_MAX);
165 u(32, time_scale, 1, UINT32_MAX);
166 flag(fixed_frame_rate_flag);
168 infer(fixed_frame_rate_flag, 0);
171 flag(nal_hrd_parameters_present_flag);
172 if (current->nal_hrd_parameters_present_flag)
175 flag(vcl_hrd_parameters_present_flag);
176 if (current->vcl_hrd_parameters_present_flag)
179 if (current->nal_hrd_parameters_present_flag ||
180 current->vcl_hrd_parameters_present_flag)
181 flag(low_delay_hrd_flag);
183 infer(low_delay_hrd_flag, 1 - current->fixed_frame_rate_flag);
185 flag(pic_struct_present_flag);
187 flag(bitstream_restriction_flag);
188 if (current->bitstream_restriction_flag) {
189 flag(motion_vectors_over_pic_boundaries_flag);
190 ue(max_bytes_per_pic_denom, 0, 16);
191 ue(max_bits_per_mb_denom, 0, 16);
194 ue(log2_max_mv_length_horizontal, 0, 16);
195 ue(log2_max_mv_length_vertical, 0, 16);
199 infer(motion_vectors_over_pic_boundaries_flag, 1);
200 infer(max_bytes_per_pic_denom, 2);
201 infer(max_bits_per_mb_denom, 1);
202 infer(log2_max_mv_length_horizontal, 15);
203 infer(log2_max_mv_length_vertical, 15);
205 if ((
sps->profile_idc == 44 ||
sps->profile_idc == 86 ||
206 sps->profile_idc == 100 ||
sps->profile_idc == 110 ||
207 sps->profile_idc == 122 ||
sps->profile_idc == 244) &&
208 sps->constraint_set3_flag) {
209 infer(max_num_reorder_frames, 0);
210 infer(max_dec_frame_buffering, 0);
224 infer(aspect_ratio_idc, 0);
226 infer(video_format, 5);
227 infer(video_full_range_flag, 0);
228 infer(colour_primaries, 2);
230 infer(matrix_coefficients, 2);
232 infer(chroma_sample_loc_type_top_field, 0);
233 infer(chroma_sample_loc_type_bottom_field, 0);
235 infer(fixed_frame_rate_flag, 0);
236 infer(low_delay_hrd_flag, 1);
238 infer(pic_struct_present_flag, 0);
240 infer(motion_vectors_over_pic_boundaries_flag, 1);
241 infer(max_bytes_per_pic_denom, 2);
242 infer(max_bits_per_mb_denom, 1);
243 infer(log2_max_mv_length_horizontal, 15);
244 infer(log2_max_mv_length_vertical, 15);
246 if ((
sps->profile_idc == 44 ||
sps->profile_idc == 86 ||
247 sps->profile_idc == 100 ||
sps->profile_idc == 110 ||
248 sps->profile_idc == 122 ||
sps->profile_idc == 244) &&
249 sps->constraint_set3_flag) {
250 infer(max_num_reorder_frames, 0);
251 infer(max_dec_frame_buffering, 0);
265 HEADER(
"Sequence Parameter Set");
272 flag(constraint_set0_flag);
273 flag(constraint_set1_flag);
274 flag(constraint_set2_flag);
275 flag(constraint_set3_flag);
276 flag(constraint_set4_flag);
277 flag(constraint_set5_flag);
279 u(2, reserved_zero_2bits, 0, 0);
283 ue(seq_parameter_set_id, 0, 31);
285 if (current->profile_idc == 100 || current->profile_idc == 110 ||
286 current->profile_idc == 122 || current->profile_idc == 244 ||
287 current->profile_idc == 44 || current->profile_idc == 83 ||
288 current->profile_idc == 86 || current->profile_idc == 118 ||
289 current->profile_idc == 128 || current->profile_idc == 138) {
290 ue(chroma_format_idc, 0, 3);
292 if (current->chroma_format_idc == 3)
293 flag(separate_colour_plane_flag);
295 infer(separate_colour_plane_flag, 0);
297 ue(bit_depth_luma_minus8, 0, 6);
298 ue(bit_depth_chroma_minus8, 0, 6);
300 flag(qpprime_y_zero_transform_bypass_flag);
302 flag(seq_scaling_matrix_present_flag);
303 if (current->seq_scaling_matrix_present_flag) {
304 for (
i = 0;
i < ((current->chroma_format_idc != 3) ? 8 : 12);
i++) {
305 flags(seq_scaling_list_present_flag[
i], 1,
i);
306 if (current->seq_scaling_list_present_flag[
i]) {
309 ¤t->scaling_list_4x4[
i],
313 ¤t->scaling_list_8x8[
i - 6],
319 infer(chroma_format_idc, current->profile_idc == 183 ? 0 : 1);
321 infer(separate_colour_plane_flag, 0);
322 infer(bit_depth_luma_minus8, 0);
323 infer(bit_depth_chroma_minus8, 0);
326 ue(log2_max_frame_num_minus4, 0, 12);
327 ue(pic_order_cnt_type, 0, 2);
329 if (current->pic_order_cnt_type == 0) {
330 ue(log2_max_pic_order_cnt_lsb_minus4, 0, 12);
331 }
else if (current->pic_order_cnt_type == 1) {
332 flag(delta_pic_order_always_zero_flag);
333 se(offset_for_non_ref_pic, INT32_MIN + 1, INT32_MAX);
334 se(offset_for_top_to_bottom_field, INT32_MIN + 1, INT32_MAX);
335 ue(num_ref_frames_in_pic_order_cnt_cycle, 0, 255);
337 for (
i = 0;
i < current->num_ref_frames_in_pic_order_cnt_cycle;
i++)
338 ses(offset_for_ref_frame[
i], INT32_MIN + 1, INT32_MAX, 1,
i);
342 flag(gaps_in_frame_num_allowed_flag);
347 flag(frame_mbs_only_flag);
348 if (!current->frame_mbs_only_flag)
349 flag(mb_adaptive_frame_field_flag);
351 flag(direct_8x8_inference_flag);
353 flag(frame_cropping_flag);
354 if (current->frame_cropping_flag) {
361 flag(vui_parameters_present_flag);
362 if (current->vui_parameters_present_flag)
377 HEADER(
"Sequence Parameter Set Extension");
382 ue(seq_parameter_set_id, 0, 31);
384 ue(aux_format_idc, 0, 3);
386 if (current->aux_format_idc != 0) {
389 ue(bit_depth_aux_minus8, 0, 4);
390 flag(alpha_incr_flag);
392 bits = current->bit_depth_aux_minus8 + 9;
393 ub(
bits, alpha_opaque_value);
394 ub(
bits, alpha_transparent_value);
397 flag(additional_extension_flag);
411 HEADER(
"Picture Parameter Set");
416 ue(pic_parameter_set_id, 0, 255);
417 ue(seq_parameter_set_id, 0, 31);
419 sps = h264->
sps[current->seq_parameter_set_id];
422 current->seq_parameter_set_id);
426 flag(entropy_coding_mode_flag);
427 flag(bottom_field_pic_order_in_frame_present_flag);
429 ue(num_slice_groups_minus1, 0, 7);
430 if (current->num_slice_groups_minus1 > 0) {
431 unsigned int pic_size;
434 pic_size = (
sps->pic_width_in_mbs_minus1 + 1) *
435 (
sps->pic_height_in_map_units_minus1 + 1);
437 ue(slice_group_map_type, 0, 6);
439 if (current->slice_group_map_type == 0) {
440 for (iGroup = 0; iGroup <= current->num_slice_groups_minus1; iGroup++)
441 ues(run_length_minus1[iGroup], 0, pic_size - 1, 1, iGroup);
443 }
else if (current->slice_group_map_type == 2) {
444 for (iGroup = 0; iGroup < current->num_slice_groups_minus1; iGroup++) {
445 ues(top_left[iGroup], 0, pic_size - 1, 1, iGroup);
446 ues(bottom_right[iGroup],
447 current->top_left[iGroup], pic_size - 1, 1, iGroup);
449 }
else if (current->slice_group_map_type == 3 ||
450 current->slice_group_map_type == 4 ||
451 current->slice_group_map_type == 5) {
452 flag(slice_group_change_direction_flag);
453 ue(slice_group_change_rate_minus1, 0, pic_size - 1);
454 }
else if (current->slice_group_map_type == 6) {
455 ue(pic_size_in_map_units_minus1, pic_size - 1, pic_size - 1);
458 current->pic_size_in_map_units_minus1 + 1);
459 for (
i = 0;
i <= current->pic_size_in_map_units_minus1;
i++)
460 us(
av_log2(2 * current->num_slice_groups_minus1 + 1),
461 slice_group_id[
i], 0, current->num_slice_groups_minus1, 1,
i);
465 ue(num_ref_idx_l0_default_active_minus1, 0, 31);
466 ue(num_ref_idx_l1_default_active_minus1, 0, 31);
468 flag(weighted_pred_flag);
469 u(2, weighted_bipred_idc, 0, 2);
471 se(pic_init_qp_minus26, -26 - 6 *
sps->bit_depth_luma_minus8, +25);
472 se(pic_init_qs_minus26, -26, +25);
473 se(chroma_qp_index_offset, -12, +12);
475 flag(deblocking_filter_control_present_flag);
476 flag(constrained_intra_pred_flag);
477 flag(redundant_pic_cnt_present_flag);
481 flag(transform_8x8_mode_flag);
483 flag(pic_scaling_matrix_present_flag);
484 if (current->pic_scaling_matrix_present_flag) {
485 for (
i = 0;
i < 6 + (((
sps->chroma_format_idc != 3) ? 2 : 6) *
486 current->transform_8x8_mode_flag);
i++) {
487 flags(pic_scaling_list_present_flag[
i], 1,
i);
488 if (current->pic_scaling_list_present_flag[
i]) {
491 ¤t->scaling_list_4x4[
i],
495 ¤t->scaling_list_8x8[
i - 6],
501 se(second_chroma_qp_index_offset, -12, +12);
503 infer(transform_8x8_mode_flag, 0);
504 infer(pic_scaling_matrix_present_flag, 0);
505 infer(second_chroma_qp_index_offset, current->chroma_qp_index_offset);
521 HEADER(
"Buffering Period");
523 ue(seq_parameter_set_id, 0, 31);
533 if (
sps->vui.nal_hrd_parameters_present_flag) {
534 for (
i = 0;
i <=
sps->vui.nal_hrd_parameters.cpb_cnt_minus1;
i++) {
535 length =
sps->vui.nal_hrd_parameters.initial_cpb_removal_delay_length_minus1 + 1;
536 xu(length, initial_cpb_removal_delay[SchedSelIdx],
539 xu(length, initial_cpb_removal_delay_offset[SchedSelIdx],
545 if (
sps->vui.vcl_hrd_parameters_present_flag) {
546 for (
i = 0;
i <=
sps->vui.vcl_hrd_parameters.cpb_cnt_minus1;
i++) {
547 length =
sps->vui.vcl_hrd_parameters.initial_cpb_removal_delay_length_minus1 + 1;
548 xu(length, initial_cpb_removal_delay[SchedSelIdx],
551 xu(length, initial_cpb_removal_delay_offset[SchedSelIdx],
564 uint8_t time_offset_length;
568 flag(nuit_field_based_flag);
569 u(5, counting_type, 0, 6);
570 flag(full_timestamp_flag);
571 flag(discontinuity_flag);
572 flag(cnt_dropped_flag);
574 if (current->full_timestamp_flag) {
575 u(6, seconds_value, 0, 59);
576 u(6, minutes_value, 0, 59);
577 u(5, hours_value, 0, 23);
580 if (current->seconds_flag) {
581 u(6, seconds_value, 0, 59);
583 if (current->minutes_flag) {
584 u(6, minutes_value, 0, 59);
586 if (current->hours_flag)
587 u(5, hours_value, 0, 23);
592 if (
sps->vui.nal_hrd_parameters_present_flag)
593 time_offset_length =
sps->vui.nal_hrd_parameters.time_offset_length;
594 else if (
sps->vui.vcl_hrd_parameters_present_flag)
595 time_offset_length =
sps->vui.vcl_hrd_parameters.time_offset_length;
597 time_offset_length = 24;
599 if (time_offset_length > 0)
600 ib(time_offset_length, time_offset);
602 infer(time_offset, 0);
635 "No active SPS for pic_timing.\n");
639 if (
sps->vui.nal_hrd_parameters_present_flag ||
640 sps->vui.vcl_hrd_parameters_present_flag) {
643 if (
sps->vui.nal_hrd_parameters_present_flag)
644 hrd = &
sps->vui.nal_hrd_parameters;
645 else if (
sps->vui.vcl_hrd_parameters_present_flag)
646 hrd = &
sps->vui.vcl_hrd_parameters;
649 "No HRD parameters for pic_timing.\n");
657 if (
sps->vui.pic_struct_present_flag) {
658 static const uint8_t num_clock_ts[9] = {
659 1, 1, 1, 2, 2, 3, 3, 2, 3
663 u(4, pic_struct, 0, 8);
668 flags(clock_timestamp_flag[
i], 1,
i);
684 HEADER(
"Pan-Scan Rectangle");
686 ue(pan_scan_rect_id, 0, UINT32_MAX - 1);
687 flag(pan_scan_rect_cancel_flag);
690 ue(pan_scan_cnt_minus1, 0, 2);
693 ses(pan_scan_rect_left_offset[
i], INT32_MIN + 1, INT32_MAX, 1,
i);
694 ses(pan_scan_rect_right_offset[
i], INT32_MIN + 1, INT32_MAX, 1,
i);
695 ses(pan_scan_rect_top_offset[
i], INT32_MIN + 1, INT32_MAX, 1,
i);
696 ses(pan_scan_rect_bottom_offset[
i], INT32_MIN + 1, INT32_MAX, 1,
i);
699 ue(pan_scan_rect_repetition_period, 0, 16384);
713 ue(recovery_frame_cnt, 0, 65535);
714 flag(exact_match_flag);
715 flag(broken_link_flag);
716 u(2, changing_slice_group_idc, 0, 2);
729 HEADER(
"Film Grain Characteristics");
749 flag(film_grain_characteristics_cancel_flag);
751 int filmGrainBitDepth[3];
753 u(2, film_grain_model_id, 0, 1);
754 flag(separate_colour_description_present_flag);
756 ub(3, film_grain_bit_depth_luma_minus8);
757 ub(3, film_grain_bit_depth_chroma_minus8);
758 flag(film_grain_full_range_flag);
759 ub(8, film_grain_colour_primaries);
760 ub(8, film_grain_transfer_characteristics);
761 ub(8, film_grain_matrix_coefficients);
765 "No active SPS for film_grain_characteristics.\n");
768 infer(film_grain_bit_depth_luma_minus8,
sps->bit_depth_luma_minus8);
769 infer(film_grain_bit_depth_chroma_minus8,
sps->bit_depth_chroma_minus8);
770 infer(film_grain_full_range_flag,
sps->vui.video_full_range_flag);
771 infer(film_grain_colour_primaries,
sps->vui.colour_primaries);
772 infer(film_grain_transfer_characteristics,
sps->vui.transfer_characteristics);
773 infer(film_grain_matrix_coefficients,
sps->vui.matrix_coefficients);
777 filmGrainBitDepth[1] =
780 u(2, blending_mode_id, 0, 1);
781 ub(4, log2_scale_factor);
782 for (
c = 0;
c < 3;
c++)
783 flags(comp_model_present_flag[
c], 1,
c);
784 for (
c = 0;
c < 3;
c++) {
786 ubs(8, num_intensity_intervals_minus1[
c], 1,
c);
787 us(3, num_model_values_minus1[
c], 0, 5, 1,
c);
789 ubs(8, intensity_interval_lower_bound[
c][
i], 2,
c,
i);
790 ubs(8, intensity_interval_upper_bound[
c][
i], 2,
c,
i);
793 ((1 << filmGrainBitDepth[
c]) - 1) - current->
film_grain_model_id * (1 << (filmGrainBitDepth[
c] - 1)),
798 ue(film_grain_characteristics_repetition_period, 0, 16384);
810 HEADER(
"Display Orientation");
812 flag(display_orientation_cancel_flag);
816 ub(16, anticlockwise_rotation);
817 ue(display_orientation_repetition_period, 0, 16384);
818 flag(display_orientation_extension_flag);
829 HEADER(
"Supplemental Enhancement Information");
846 HEADER(
"Access Unit Delimiter");
851 ub(3, primary_pic_type);
865 if (current->slice_type % 5 != 2 &&
866 current->slice_type % 5 != 4) {
867 flag(ref_pic_list_modification_flag_l0);
868 if (current->ref_pic_list_modification_flag_l0) {
870 xue(modification_of_pic_nums_idc,
871 current->rplm_l0[
i].modification_of_pic_nums_idc, 0, 3, 0);
873 mopn = current->rplm_l0[
i].modification_of_pic_nums_idc;
877 if (mopn == 0 || mopn == 1)
878 xue(abs_diff_pic_num_minus1,
879 current->rplm_l0[
i].abs_diff_pic_num_minus1,
880 0, (1 + current->field_pic_flag) *
881 (1 << (
sps->log2_max_frame_num_minus4 + 4)), 0);
883 xue(long_term_pic_num,
884 current->rplm_l0[
i].long_term_pic_num,
885 0,
sps->max_num_ref_frames - 1, 0);
890 if (current->slice_type % 5 == 1) {
891 flag(ref_pic_list_modification_flag_l1);
892 if (current->ref_pic_list_modification_flag_l1) {
894 xue(modification_of_pic_nums_idc,
895 current->rplm_l1[
i].modification_of_pic_nums_idc, 0, 3, 0);
897 mopn = current->rplm_l1[
i].modification_of_pic_nums_idc;
901 if (mopn == 0 || mopn == 1)
902 xue(abs_diff_pic_num_minus1,
903 current->rplm_l1[
i].abs_diff_pic_num_minus1,
904 0, (1 + current->field_pic_flag) *
905 (1 << (
sps->log2_max_frame_num_minus4 + 4)), 0);
907 xue(long_term_pic_num,
908 current->rplm_l1[
i].long_term_pic_num,
909 0,
sps->max_num_ref_frames - 1, 0);
925 ue(luma_log2_weight_denom, 0, 7);
927 chroma = !
sps->separate_colour_plane_flag &&
sps->chroma_format_idc != 0;
929 ue(chroma_log2_weight_denom, 0, 7);
931 for (
i = 0;
i <= current->num_ref_idx_l0_active_minus1;
i++) {
932 flags(luma_weight_l0_flag[
i], 1,
i);
933 if (current->luma_weight_l0_flag[
i]) {
934 ses(luma_weight_l0[
i], -128, +127, 1,
i);
935 ses(luma_offset_l0[
i], -128, +127, 1,
i);
938 flags(chroma_weight_l0_flag[
i], 1,
i);
939 if (current->chroma_weight_l0_flag[
i]) {
940 for (j = 0; j < 2; j++) {
941 ses(chroma_weight_l0[
i][j], -128, +127, 2,
i, j);
942 ses(chroma_offset_l0[
i][j], -128, +127, 2,
i, j);
948 if (current->slice_type % 5 == 1) {
949 for (
i = 0;
i <= current->num_ref_idx_l1_active_minus1;
i++) {
950 flags(luma_weight_l1_flag[
i], 1,
i);
951 if (current->luma_weight_l1_flag[
i]) {
952 ses(luma_weight_l1[
i], -128, +127, 1,
i);
953 ses(luma_offset_l1[
i], -128, +127, 1,
i);
956 flags(chroma_weight_l1_flag[
i], 1,
i);
957 if (current->chroma_weight_l1_flag[
i]) {
958 for (j = 0; j < 2; j++) {
959 ses(chroma_weight_l1[
i][j], -128, +127, 2,
i, j);
960 ses(chroma_offset_l1[
i][j], -128, +127, 2,
i, j);
979 flag(no_output_of_prior_pics_flag);
980 flag(long_term_reference_flag);
982 flag(adaptive_ref_pic_marking_mode_flag);
983 if (current->adaptive_ref_pic_marking_mode_flag) {
985 xue(memory_management_control_operation,
986 current->mmco[
i].memory_management_control_operation,
989 mmco = current->mmco[
i].memory_management_control_operation;
993 if (mmco == 1 || mmco == 3)
994 xue(difference_of_pic_nums_minus1,
995 current->mmco[
i].difference_of_pic_nums_minus1,
998 xue(long_term_pic_num,
999 current->mmco[
i].long_term_pic_num,
1000 0,
sps->max_num_ref_frames - 1, 0);
1001 if (mmco == 3 || mmco == 6)
1002 xue(long_term_frame_idx,
1003 current->mmco[
i].long_term_frame_idx,
1004 0,
sps->max_num_ref_frames - 1, 0);
1006 xue(max_long_term_frame_idx_plus1,
1007 current->mmco[
i].max_long_term_frame_idx_plus1,
1008 0,
sps->max_num_ref_frames, 0);
1012 "memory management control operations.\n");
1029 int slice_type_i, slice_type_p, slice_type_b;
1030 int slice_type_si, slice_type_sp;
1042 "is not decodable without the main picture "
1043 "in the same access unit.\n");
1052 ue(slice_type, 0, 9);
1054 slice_type_i = current->slice_type % 5 == 2;
1055 slice_type_p = current->slice_type % 5 == 0;
1056 slice_type_b = current->slice_type % 5 == 1;
1057 slice_type_si = current->slice_type % 5 == 4;
1058 slice_type_sp = current->slice_type % 5 == 3;
1060 if (idr_pic_flag && !(slice_type_i || slice_type_si)) {
1062 "for IDR picture.\n", current->slice_type);
1066 ue(pic_parameter_set_id, 0, 255);
1068 pps = h264->
pps[current->pic_parameter_set_id];
1071 current->pic_parameter_set_id);
1076 sps = h264->
sps[
pps->seq_parameter_set_id];
1079 pps->seq_parameter_set_id);
1084 if (
sps->separate_colour_plane_flag)
1085 u(2, colour_plane_id, 0, 2);
1087 ub(
sps->log2_max_frame_num_minus4 + 4, frame_num);
1089 if (!
sps->frame_mbs_only_flag) {
1090 flag(field_pic_flag);
1091 if (current->field_pic_flag)
1092 flag(bottom_field_flag);
1094 infer(bottom_field_flag, 0);
1096 infer(field_pic_flag, 0);
1097 infer(bottom_field_flag, 0);
1101 ue(idr_pic_id, 0, 65535);
1103 if (
sps->pic_order_cnt_type == 0) {
1104 ub(
sps->log2_max_pic_order_cnt_lsb_minus4 + 4, pic_order_cnt_lsb);
1105 if (
pps->bottom_field_pic_order_in_frame_present_flag &&
1106 !current->field_pic_flag)
1107 se(delta_pic_order_cnt_bottom, INT32_MIN + 1, INT32_MAX);
1109 }
else if (
sps->pic_order_cnt_type == 1) {
1110 if (!
sps->delta_pic_order_always_zero_flag) {
1111 se(delta_pic_order_cnt[0], INT32_MIN + 1, INT32_MAX);
1112 if (
pps->bottom_field_pic_order_in_frame_present_flag &&
1113 !current->field_pic_flag)
1114 se(delta_pic_order_cnt[1], INT32_MIN + 1, INT32_MAX);
1116 infer(delta_pic_order_cnt[1], 0);
1118 infer(delta_pic_order_cnt[0], 0);
1119 infer(delta_pic_order_cnt[1], 0);
1123 if (
pps->redundant_pic_cnt_present_flag)
1124 ue(redundant_pic_cnt, 0, 127);
1126 infer(redundant_pic_cnt, 0);
1129 && !current->redundant_pic_cnt)
1131 current->nal_unit_header.nal_unit_type;
1134 flag(direct_spatial_mv_pred_flag);
1136 if (slice_type_p || slice_type_sp || slice_type_b) {
1137 flag(num_ref_idx_active_override_flag);
1138 if (current->num_ref_idx_active_override_flag) {
1139 ue(num_ref_idx_l0_active_minus1, 0, 31);
1141 ue(num_ref_idx_l1_active_minus1, 0, 31);
1143 infer(num_ref_idx_l0_active_minus1,
1144 pps->num_ref_idx_l0_default_active_minus1);
1145 infer(num_ref_idx_l1_active_minus1,
1146 pps->num_ref_idx_l1_default_active_minus1);
1150 if (current->nal_unit_header.nal_unit_type == 20 ||
1151 current->nal_unit_header.nal_unit_type == 21) {
1158 if ((
pps->weighted_pred_flag && (slice_type_p || slice_type_sp)) ||
1159 (
pps->weighted_bipred_idc == 1 && slice_type_b)) {
1163 if (current->nal_unit_header.nal_ref_idc != 0) {
1167 if (
pps->entropy_coding_mode_flag &&
1168 !slice_type_i && !slice_type_si) {
1169 ue(cabac_init_idc, 0, 2);
1172 se(slice_qp_delta, - 51 - 6 *
sps->bit_depth_luma_minus8,
1173 + 51 + 6 *
sps->bit_depth_luma_minus8);
1174 if (slice_type_sp || slice_type_si) {
1176 flag(sp_for_switch_flag);
1177 se(slice_qs_delta, -51, +51);
1180 if (
pps->deblocking_filter_control_present_flag) {
1181 ue(disable_deblocking_filter_idc, 0, 2);
1182 if (current->disable_deblocking_filter_idc != 1) {
1183 se(slice_alpha_c0_offset_div2, -6, +6);
1184 se(slice_beta_offset_div2, -6, +6);
1186 infer(slice_alpha_c0_offset_div2, 0);
1187 infer(slice_beta_offset_div2, 0);
1190 infer(disable_deblocking_filter_idc, 0);
1191 infer(slice_alpha_c0_offset_div2, 0);
1192 infer(slice_beta_offset_div2, 0);
1195 if (
pps->num_slice_groups_minus1 > 0 &&
1196 pps->slice_group_map_type >= 3 &&
1197 pps->slice_group_map_type <= 5) {
1198 unsigned int pic_size,
max,
bits;
1200 pic_size = (
sps->pic_width_in_mbs_minus1 + 1) *
1201 (
sps->pic_height_in_map_units_minus1 + 1);
1202 max = (pic_size +
pps->slice_group_change_rate_minus1) /
1203 (
pps->slice_group_change_rate_minus1 + 1);
1206 u(
bits, slice_group_change_cycle, 0,
max);
1209 if (
pps->entropy_coding_mode_flag) {
1211 fixed(1, cabac_alignment_one_bit, 1);
1229 fixed(8, ff_byte, 0xff);
1230 ++current->filler_size;
1235 for (
i = 0;
i < current->filler_size;
i++)
1236 fixed(8, ff_byte, 0xff);
1248 HEADER(
"End of Sequence");