23 fixed(1, rbsp_stop_one_bit, 1);
25 fixed(1, rbsp_alignment_zero_bit, 0);
32 uint32_t valid_type_mask)
36 u(1, forbidden_zero_bit, 0, 0);
37 u(2, nal_ref_idc, 0, 3);
38 u(5, nal_unit_type, 0, 31);
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 u(4, bit_rate_scale, 0, 15);
95 u(4, cpb_size_scale, 0, 15);
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);
100 flags(cbr_flag[i], 1, i);
103 u(5, initial_cpb_removal_delay_length_minus1, 0, 31);
104 u(5, cpb_removal_delay_length_minus1, 0, 31);
105 u(5, dpb_output_delay_length_minus1, 0, 31);
106 u(5, time_offset_length, 0, 31);
116 flag(aspect_ratio_info_present_flag);
117 if (current->aspect_ratio_info_present_flag) {
118 u(8, aspect_ratio_idc, 0, 255);
119 if (current->aspect_ratio_idc == 255) {
120 u(16, sar_width, 0, 65535);
121 u(16, sar_height, 0, 65535);
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) {
133 u(3, video_format, 0, 7);
134 flag(video_full_range_flag);
135 flag(colour_description_present_flag);
136 if (current->colour_description_present_flag) {
137 u(8, colour_primaries, 0, 255);
139 u(8, matrix_coefficients, 0, 255);
142 infer(video_format, 5);
143 infer(video_full_range_flag, 0);
144 infer(colour_primaries, 2);
146 infer(matrix_coefficients, 2);
149 flag(chroma_loc_info_present_flag);
150 if (current->chroma_loc_info_present_flag) {
151 ue(chroma_sample_loc_type_top_field, 0, 5);
152 ue(chroma_sample_loc_type_bottom_field, 0, 5);
154 infer(chroma_sample_loc_type_top_field, 0);
155 infer(chroma_sample_loc_type_bottom_field, 0);
158 flag(timing_info_present_flag);
159 if (current->timing_info_present_flag) {
160 u(32, num_units_in_tick, 1, UINT32_MAX);
161 u(32, time_scale, 1, UINT32_MAX);
162 flag(fixed_frame_rate_flag);
164 infer(fixed_frame_rate_flag, 0);
167 flag(nal_hrd_parameters_present_flag);
168 if (current->nal_hrd_parameters_present_flag)
171 flag(vcl_hrd_parameters_present_flag);
172 if (current->vcl_hrd_parameters_present_flag)
175 if (current->nal_hrd_parameters_present_flag ||
176 current->vcl_hrd_parameters_present_flag)
177 flag(low_delay_hrd_flag);
179 infer(low_delay_hrd_flag, 1 - current->fixed_frame_rate_flag);
181 flag(pic_struct_present_flag);
183 flag(bitstream_restriction_flag);
184 if (current->bitstream_restriction_flag) {
185 flag(motion_vectors_over_pic_boundaries_flag);
186 ue(max_bytes_per_pic_denom, 0, 16);
187 ue(max_bits_per_mb_denom, 0, 16);
190 ue(log2_max_mv_length_horizontal, 0, 16);
191 ue(log2_max_mv_length_vertical, 0, 16);
195 infer(motion_vectors_over_pic_boundaries_flag, 1);
196 infer(max_bytes_per_pic_denom, 2);
197 infer(max_bits_per_mb_denom, 1);
198 infer(log2_max_mv_length_horizontal, 15);
199 infer(log2_max_mv_length_vertical, 15);
201 if ((
sps->profile_idc == 44 ||
sps->profile_idc == 86 ||
202 sps->profile_idc == 100 ||
sps->profile_idc == 110 ||
203 sps->profile_idc == 122 ||
sps->profile_idc == 244) &&
204 sps->constraint_set3_flag) {
205 infer(max_num_reorder_frames, 0);
206 infer(max_dec_frame_buffering, 0);
220 infer(aspect_ratio_idc, 0);
222 infer(video_format, 5);
223 infer(video_full_range_flag, 0);
224 infer(colour_primaries, 2);
226 infer(matrix_coefficients, 2);
228 infer(chroma_sample_loc_type_top_field, 0);
229 infer(chroma_sample_loc_type_bottom_field, 0);
231 infer(fixed_frame_rate_flag, 0);
232 infer(low_delay_hrd_flag, 1);
234 infer(pic_struct_present_flag, 0);
236 infer(motion_vectors_over_pic_boundaries_flag, 1);
237 infer(max_bytes_per_pic_denom, 2);
238 infer(max_bits_per_mb_denom, 1);
239 infer(log2_max_mv_length_horizontal, 15);
240 infer(log2_max_mv_length_vertical, 15);
242 if ((
sps->profile_idc == 44 ||
sps->profile_idc == 86 ||
243 sps->profile_idc == 100 ||
sps->profile_idc == 110 ||
244 sps->profile_idc == 122 ||
sps->profile_idc == 244) &&
245 sps->constraint_set3_flag) {
246 infer(max_num_reorder_frames, 0);
247 infer(max_dec_frame_buffering, 0);
261 HEADER(
"Sequence Parameter Set");
268 flag(constraint_set0_flag);
269 flag(constraint_set1_flag);
270 flag(constraint_set2_flag);
271 flag(constraint_set3_flag);
272 flag(constraint_set4_flag);
273 flag(constraint_set5_flag);
275 u(2, reserved_zero_2bits, 0, 0);
279 ue(seq_parameter_set_id, 0, 31);
281 if (current->profile_idc == 100 || current->profile_idc == 110 ||
282 current->profile_idc == 122 || current->profile_idc == 244 ||
283 current->profile_idc == 44 || current->profile_idc == 83 ||
284 current->profile_idc == 86 || current->profile_idc == 118 ||
285 current->profile_idc == 128 || current->profile_idc == 138) {
286 ue(chroma_format_idc, 0, 3);
288 if (current->chroma_format_idc == 3)
289 flag(separate_colour_plane_flag);
291 infer(separate_colour_plane_flag, 0);
293 ue(bit_depth_luma_minus8, 0, 6);
294 ue(bit_depth_chroma_minus8, 0, 6);
296 flag(qpprime_y_zero_transform_bypass_flag);
298 flag(seq_scaling_matrix_present_flag);
299 if (current->seq_scaling_matrix_present_flag) {
300 for (i = 0; i < ((current->chroma_format_idc != 3) ? 8 : 12); i++) {
301 flags(seq_scaling_list_present_flag[i], 1, i);
302 if (current->seq_scaling_list_present_flag[i]) {
305 ¤t->scaling_list_4x4[i],
309 ¤t->scaling_list_8x8[i - 6],
315 infer(chroma_format_idc, current->profile_idc == 183 ? 0 : 1);
317 infer(separate_colour_plane_flag, 0);
318 infer(bit_depth_luma_minus8, 0);
319 infer(bit_depth_chroma_minus8, 0);
322 ue(log2_max_frame_num_minus4, 0, 12);
323 ue(pic_order_cnt_type, 0, 2);
325 if (current->pic_order_cnt_type == 0) {
326 ue(log2_max_pic_order_cnt_lsb_minus4, 0, 12);
327 }
else if (current->pic_order_cnt_type == 1) {
328 flag(delta_pic_order_always_zero_flag);
329 se(offset_for_non_ref_pic, INT32_MIN + 1, INT32_MAX);
330 se(offset_for_top_to_bottom_field, INT32_MIN + 1, INT32_MAX);
331 ue(num_ref_frames_in_pic_order_cnt_cycle, 0, 255);
333 for (i = 0; i < current->num_ref_frames_in_pic_order_cnt_cycle; i++)
334 ses(offset_for_ref_frame[i], INT32_MIN + 1, INT32_MAX, 1, i);
338 flag(gaps_in_frame_num_allowed_flag);
343 flag(frame_mbs_only_flag);
344 if (!current->frame_mbs_only_flag)
345 flag(mb_adaptive_frame_field_flag);
347 flag(direct_8x8_inference_flag);
349 flag(frame_cropping_flag);
350 if (current->frame_cropping_flag) {
357 flag(vui_parameters_present_flag);
358 if (current->vui_parameters_present_flag)
373 HEADER(
"Sequence Parameter Set Extension");
378 ue(seq_parameter_set_id, 0, 31);
380 ue(aux_format_idc, 0, 3);
382 if (current->aux_format_idc != 0) {
385 ue(bit_depth_aux_minus8, 0, 4);
386 flag(alpha_incr_flag);
388 bits = current->bit_depth_aux_minus8 + 9;
393 flag(additional_extension_flag);
407 HEADER(
"Picture Parameter Set");
412 ue(pic_parameter_set_id, 0, 255);
413 ue(seq_parameter_set_id, 0, 31);
415 sps = h264->
sps[current->seq_parameter_set_id];
418 current->seq_parameter_set_id);
422 flag(entropy_coding_mode_flag);
423 flag(bottom_field_pic_order_in_frame_present_flag);
425 ue(num_slice_groups_minus1, 0, 7);
426 if (current->num_slice_groups_minus1 > 0) {
427 unsigned int pic_size;
433 ue(slice_group_map_type, 0, 6);
435 if (current->slice_group_map_type == 0) {
436 for (iGroup = 0; iGroup <= current->num_slice_groups_minus1; iGroup++)
437 ues(run_length_minus1[iGroup], 0, pic_size - 1, 1, iGroup);
439 }
else if (current->slice_group_map_type == 2) {
440 for (iGroup = 0; iGroup < current->num_slice_groups_minus1; iGroup++) {
441 ues(top_left[iGroup], 0, pic_size - 1, 1, iGroup);
442 ues(bottom_right[iGroup],
443 current->top_left[iGroup], pic_size - 1, 1, iGroup);
445 }
else if (current->slice_group_map_type == 3 ||
446 current->slice_group_map_type == 4 ||
447 current->slice_group_map_type == 5) {
448 flag(slice_group_change_direction_flag);
449 ue(slice_group_change_rate_minus1, 0, pic_size - 1);
450 }
else if (current->slice_group_map_type == 6) {
451 ue(pic_size_in_map_units_minus1, pic_size - 1, pic_size - 1);
454 current->pic_size_in_map_units_minus1 + 1);
455 for (i = 0; i <= current->pic_size_in_map_units_minus1; i++)
456 us(
av_log2(2 * current->num_slice_groups_minus1 + 1),
457 slice_group_id[i], 0, current->num_slice_groups_minus1, 1, i);
461 ue(num_ref_idx_l0_default_active_minus1, 0, 31);
462 ue(num_ref_idx_l1_default_active_minus1, 0, 31);
464 flag(weighted_pred_flag);
465 u(2, weighted_bipred_idc, 0, 2);
468 se(pic_init_qs_minus26, -26, +25);
469 se(chroma_qp_index_offset, -12, +12);
471 flag(deblocking_filter_control_present_flag);
472 flag(constrained_intra_pred_flag);
473 flag(redundant_pic_cnt_present_flag);
477 flag(transform_8x8_mode_flag);
479 flag(pic_scaling_matrix_present_flag);
480 if (current->pic_scaling_matrix_present_flag) {
482 current->transform_8x8_mode_flag); i++) {
483 flags(pic_scaling_list_present_flag[i], 1, i);
484 if (current->pic_scaling_list_present_flag[i]) {
487 ¤t->scaling_list_4x4[i],
491 ¤t->scaling_list_8x8[i - 6],
497 se(second_chroma_qp_index_offset, -12, +12);
499 infer(transform_8x8_mode_flag, 0);
500 infer(pic_scaling_matrix_present_flag, 0);
501 infer(second_chroma_qp_index_offset, current->chroma_qp_index_offset);
516 HEADER(
"Buffering Period");
518 ue(seq_parameter_set_id, 0, 31);
520 sps = h264->
sps[current->seq_parameter_set_id];
523 current->seq_parameter_set_id);
531 xu(length, initial_cpb_removal_delay[SchedSelIdx],
532 current->nal.initial_cpb_removal_delay[i],
534 xu(length, initial_cpb_removal_delay_offset[SchedSelIdx],
535 current->nal.initial_cpb_removal_delay_offset[i],
543 xu(length, initial_cpb_removal_delay[SchedSelIdx],
544 current->vcl.initial_cpb_removal_delay[i],
546 xu(length, initial_cpb_removal_delay_offset[SchedSelIdx],
547 current->vcl.initial_cpb_removal_delay_offset[i],
563 flag(nuit_field_based_flag);
564 u(5, counting_type, 0, 6);
565 flag(full_timestamp_flag);
566 flag(discontinuity_flag);
567 flag(cnt_dropped_flag);
568 u(8, n_frames, 0, 255);
569 if (current->full_timestamp_flag) {
570 u(6, seconds_value, 0, 59);
571 u(6, minutes_value, 0, 59);
572 u(5, hours_value, 0, 23);
575 if (current->seconds_flag) {
576 u(6, seconds_value, 0, 59);
578 if (current->minutes_flag) {
579 u(6, minutes_value, 0, 59);
581 if (current->hours_flag)
582 u(5, hours_value, 0, 23);
587 if (
sps->vui.nal_hrd_parameters_present_flag)
588 time_offset_length =
sps->vui.nal_hrd_parameters.time_offset_length;
589 else if (
sps->vui.vcl_hrd_parameters_present_flag)
590 time_offset_length =
sps->vui.vcl_hrd_parameters.time_offset_length;
592 time_offset_length = 24;
594 if (time_offset_length > 0)
595 u(time_offset_length, time_offset,
598 infer(time_offset, 0);
631 "No active SPS for pic_timing.\n");
645 "No HRD parameters for pic_timing.\n");
656 static const int num_clock_ts[9] = {
657 1, 1, 1, 2, 2, 3, 3, 2, 3
661 u(4, pic_struct, 0, 8);
662 if (current->pic_struct > 8)
665 for (i = 0; i < num_clock_ts[current->pic_struct]; i++) {
666 flags(clock_timestamp_flag[i], 1, i);
667 if (current->clock_timestamp_flag[i])
669 ¤t->timestamp[i], sps));
681 HEADER(
"Pan-Scan Rectangle");
683 ue(pan_scan_rect_id, 0, UINT32_MAX - 1);
684 flag(pan_scan_rect_cancel_flag);
686 if (!current->pan_scan_rect_cancel_flag) {
687 ue(pan_scan_cnt_minus1, 0, 2);
689 for (i = 0; i <= current->pan_scan_cnt_minus1; i++) {
690 ses(pan_scan_rect_left_offset[i], INT32_MIN + 1, INT32_MAX, 1, i);
691 ses(pan_scan_rect_right_offset[i], INT32_MIN + 1, INT32_MAX, 1, i);
692 ses(pan_scan_rect_top_offset[i], INT32_MIN + 1, INT32_MAX, 1, i);
693 ses(pan_scan_rect_bottom_offset[i], INT32_MIN + 1, INT32_MAX, 1, i);
696 ue(pan_scan_rect_repetition_period, 0, 16384);
704 uint32_t *payload_size)
708 HEADER(
"User Data Registered ITU-T T.35");
710 u(8, itu_t_t35_country_code, 0x00, 0xff);
711 if (current->itu_t_t35_country_code != 0xff)
714 u(8, itu_t_t35_country_code_extension_byte, 0x00, 0xff);
719 if (*payload_size < i) {
721 "Invalid SEI user data registered payload.\n");
724 current->data_length = *payload_size - i;
726 *payload_size = i + current->data_length;
729 allocate(current->data, current->data_length);
730 for (j = 0; j < current->data_length; j++)
731 xu(8, itu_t_t35_payload_byte[i], current->data[j], 0x00, 0xff, 1, i + j);
738 uint32_t *payload_size)
742 HEADER(
"User Data Unregistered");
745 if (*payload_size < 16) {
747 "Invalid SEI user data unregistered payload.\n");
750 current->data_length = *payload_size - 16;
752 *payload_size = 16 + current->data_length;
755 for (i = 0; i < 16; i++)
756 us(8, uuid_iso_iec_11578[i], 0x00, 0xff, 1, i);
758 allocate(current->data, current->data_length);
760 for (i = 0; i < current->data_length; i++)
761 xu(8, user_data_payload_byte[i], current->data[i], 0x00, 0xff, 1, i);
773 ue(recovery_frame_cnt, 0, 65535);
774 flag(exact_match_flag);
775 flag(broken_link_flag);
776 u(2, changing_slice_group_idc, 0, 2);
786 HEADER(
"Display Orientation");
788 flag(display_orientation_cancel_flag);
789 if (!current->display_orientation_cancel_flag) {
792 u(16, anticlockwise_rotation, 0, 65535);
793 ue(display_orientation_repetition_period, 0, 16384);
794 flag(display_orientation_extension_flag);
805 HEADER(
"Mastering Display Colour Volume");
807 for (c = 0; c < 3; c++) {
808 us(16, display_primaries_x[c], 0, 50000, 1, c);
809 us(16, display_primaries_y[c], 0, 50000, 1, c);
812 u(16, white_point_x, 0, 50000);
813 u(16, white_point_y, 0, 50000);
816 u(32, min_display_mastering_luminance, 0, current->max_display_mastering_luminance - 1);
825 int start_position, end_position;
833 switch (current->payload_type) {
836 (
ctx, rw, ¤t->payload.buffering_period));
840 (
ctx, rw, ¤t->payload.pic_timing));
844 (
ctx, rw, ¤t->payload.pan_scan_rect));
848 for (i = 0; i < current->payload_size; i++)
849 fixed(8, ff_byte, 0xff);
854 (
ctx, rw, ¤t->payload.user_data_registered, ¤t->payload_size));
858 (
ctx, rw, ¤t->payload.user_data_unregistered, ¤t->payload_size));
862 (
ctx, rw, ¤t->payload.recovery_point));
866 (
ctx, rw, ¤t->payload.display_orientation));
870 (
ctx, rw, ¤t->payload.mastering_display_colour_volume));
875 current->payload.other.data_length = current->payload_size;
877 allocate(current->payload.other.data, current->payload.other.data_length);
878 for (i = 0; i < current->payload.other.data_length; i++)
879 xu(8, payload_byte[i], current->payload.other.data[i], 0, 255, 1, i);
884 fixed(1, bit_equal_to_one, 1);
886 fixed(1, bit_equal_to_zero, 0);
891 if (end_position < start_position + 8 * current->payload_size) {
893 "header %"PRIu32
" bits, actually %d bits.\n",
894 8 * current->payload_size,
895 end_position - start_position);
900 current->payload_size = (end_position - start_position) / 8;
911 HEADER(
"Supplemental Enhancement Information");
918 uint32_t payload_type = 0;
919 uint32_t payload_size = 0;
923 fixed(8, ff_byte, 0xff);
926 xu(8, last_payload_type_byte, tmp, 0, 254, 0);
930 fixed(8, ff_byte, 0xff);
933 xu(8, last_payload_size_byte, tmp, 0, 254, 0);
936 current->payload[k].payload_type = payload_type;
937 current->payload[k].payload_size = payload_size;
944 if (k >= H264_MAX_SEI_PAYLOADS) {
946 "SEI message: found %d.\n", k);
949 current->payload_count = k + 1;
951 for (k = 0; k < current->payload_count; k++) {
960 need_size = !current->payload[k].payload_size;
961 for (i = 0; i < 1 + need_size; i++) {
964 tmp = current->payload[k].payload_type;
966 fixed(8, ff_byte, 0xff);
969 xu(8, last_payload_type_byte, tmp, 0, 254, 0);
971 tmp = current->payload[k].payload_size;
973 fixed(8, ff_byte, 0xff);
976 xu(8, last_payload_size_byte, tmp, 0, 254, 0);
993 HEADER(
"Access Unit Delimiter");
998 u(3, primary_pic_type, 0, 7);
1012 if (current->slice_type % 5 != 2 &&
1013 current->slice_type % 5 != 4) {
1014 flag(ref_pic_list_modification_flag_l0);
1015 if (current->ref_pic_list_modification_flag_l0) {
1017 xue(modification_of_pic_nums_idc,
1018 current->rplm_l0[i].modification_of_pic_nums_idc, 0, 3, 0);
1020 mopn = current->rplm_l0[i].modification_of_pic_nums_idc;
1024 if (mopn == 0 || mopn == 1)
1025 xue(abs_diff_pic_num_minus1,
1026 current->rplm_l0[i].abs_diff_pic_num_minus1,
1027 0, (1 + current->field_pic_flag) *
1030 xue(long_term_pic_num,
1031 current->rplm_l0[i].long_term_pic_num,
1037 if (current->slice_type % 5 == 1) {
1038 flag(ref_pic_list_modification_flag_l1);
1039 if (current->ref_pic_list_modification_flag_l1) {
1041 xue(modification_of_pic_nums_idc,
1042 current->rplm_l1[i].modification_of_pic_nums_idc, 0, 3, 0);
1044 mopn = current->rplm_l1[i].modification_of_pic_nums_idc;
1048 if (mopn == 0 || mopn == 1)
1049 xue(abs_diff_pic_num_minus1,
1050 current->rplm_l1[i].abs_diff_pic_num_minus1,
1051 0, (1 + current->field_pic_flag) *
1054 xue(long_term_pic_num,
1055 current->rplm_l1[i].long_term_pic_num,
1072 ue(luma_log2_weight_denom, 0, 7);
1076 ue(chroma_log2_weight_denom, 0, 7);
1078 for (i = 0; i <= current->num_ref_idx_l0_active_minus1; i++) {
1079 flags(luma_weight_l0_flag[i], 1, i);
1080 if (current->luma_weight_l0_flag[i]) {
1081 ses(luma_weight_l0[i], -128, +127, 1, i);
1082 ses(luma_offset_l0[i], -128, +127, 1, i);
1085 flags(chroma_weight_l0_flag[i], 1, i);
1086 if (current->chroma_weight_l0_flag[i]) {
1087 for (j = 0; j < 2; j++) {
1088 ses(chroma_weight_l0[i][j], -128, +127, 2, i, j);
1089 ses(chroma_offset_l0[i][j], -128, +127, 2, i, j);
1095 if (current->slice_type % 5 == 1) {
1096 for (i = 0; i <= current->num_ref_idx_l1_active_minus1; i++) {
1097 flags(luma_weight_l1_flag[i], 1, i);
1098 if (current->luma_weight_l1_flag[i]) {
1099 ses(luma_weight_l1[i], -128, +127, 1, i);
1100 ses(luma_offset_l1[i], -128, +127, 1, i);
1103 flags(chroma_weight_l1_flag[i], 1, i);
1104 if (current->chroma_weight_l1_flag[i]) {
1105 for (j = 0; j < 2; j++) {
1106 ses(chroma_weight_l1[i][j], -128, +127, 2, i, j);
1107 ses(chroma_offset_l1[i][j], -128, +127, 2, i, j);
1126 flag(no_output_of_prior_pics_flag);
1127 flag(long_term_reference_flag);
1129 flag(adaptive_ref_pic_marking_mode_flag);
1130 if (current->adaptive_ref_pic_marking_mode_flag) {
1132 xue(memory_management_control_operation,
1133 current->mmco[i].memory_management_control_operation,
1136 mmco = current->mmco[i].memory_management_control_operation;
1140 if (mmco == 1 || mmco == 3)
1141 xue(difference_of_pic_nums_minus1,
1142 current->mmco[i].difference_of_pic_nums_minus1,
1145 xue(long_term_pic_num,
1146 current->mmco[i].long_term_pic_num,
1148 if (mmco == 3 || mmco == 6)
1149 xue(long_term_frame_idx,
1150 current->mmco[i].long_term_frame_idx,
1153 xue(max_long_term_frame_idx_plus1,
1154 current->mmco[i].max_long_term_frame_idx_plus1,
1157 if (i == H264_MAX_MMCO_COUNT) {
1159 "memory management control operations.\n");
1176 int slice_type_i, slice_type_p, slice_type_b;
1177 int slice_type_si, slice_type_sp;
1189 "is not decodable without the main picture "
1190 "in the same access unit.\n");
1195 current->nal_unit_header.nal_unit_type;
1200 ue(slice_type, 0, 9);
1202 slice_type_i = current->slice_type % 5 == 2;
1203 slice_type_p = current->slice_type % 5 == 0;
1204 slice_type_b = current->slice_type % 5 == 1;
1205 slice_type_si = current->slice_type % 5 == 4;
1206 slice_type_sp = current->slice_type % 5 == 3;
1208 if (idr_pic_flag && !(slice_type_i || slice_type_si)) {
1210 "for IDR picture.\n", current->slice_type);
1214 ue(pic_parameter_set_id, 0, 255);
1216 pps = h264->
pps[current->pic_parameter_set_id];
1219 current->pic_parameter_set_id);
1233 u(2, colour_plane_id, 0, 2);
1239 flag(field_pic_flag);
1240 if (current->field_pic_flag)
1241 flag(bottom_field_flag);
1243 infer(bottom_field_flag, 0);
1245 infer(field_pic_flag, 0);
1246 infer(bottom_field_flag, 0);
1250 ue(idr_pic_id, 0, 65535);
1256 !current->field_pic_flag)
1257 se(delta_pic_order_cnt_bottom, INT32_MIN + 1, INT32_MAX);
1261 se(delta_pic_order_cnt[0], INT32_MIN + 1, INT32_MAX);
1263 !current->field_pic_flag)
1264 se(delta_pic_order_cnt[1], INT32_MIN + 1, INT32_MAX);
1266 infer(delta_pic_order_cnt[1], 0);
1268 infer(delta_pic_order_cnt[0], 0);
1269 infer(delta_pic_order_cnt[1], 0);
1274 ue(redundant_pic_cnt, 0, 127);
1277 flag(direct_spatial_mv_pred_flag);
1279 if (slice_type_p || slice_type_sp || slice_type_b) {
1280 flag(num_ref_idx_active_override_flag);
1281 if (current->num_ref_idx_active_override_flag) {
1282 ue(num_ref_idx_l0_active_minus1, 0, 31);
1284 ue(num_ref_idx_l1_active_minus1, 0, 31);
1286 infer(num_ref_idx_l0_active_minus1,
1288 infer(num_ref_idx_l1_active_minus1,
1293 if (current->nal_unit_header.nal_unit_type == 20 ||
1294 current->nal_unit_header.nal_unit_type == 21) {
1306 if (current->nal_unit_header.nal_ref_idc != 0) {
1311 !slice_type_i && !slice_type_si) {
1312 ue(cabac_init_idc, 0, 2);
1317 if (slice_type_sp || slice_type_si) {
1319 flag(sp_for_switch_flag);
1320 se(slice_qs_delta, -51, +51);
1324 ue(disable_deblocking_filter_idc, 0, 2);
1325 if (current->disable_deblocking_filter_idc != 1) {
1326 se(slice_alpha_c0_offset_div2, -6, +6);
1327 se(slice_beta_offset_div2, -6, +6);
1329 infer(slice_alpha_c0_offset_div2, 0);
1330 infer(slice_beta_offset_div2, 0);
1333 infer(disable_deblocking_filter_idc, 0);
1334 infer(slice_alpha_c0_offset_div2, 0);
1335 infer(slice_beta_offset_div2, 0);
1341 unsigned int pic_size, max, bits;
1349 u(bits, slice_group_change_cycle, 0, max);
1354 fixed(1, cabac_alignment_one_bit, 1);
1372 fixed(8, ff_byte, 0xff);
1373 ++current->filler_size;
1378 for (i = 0; i < current->filler_size; i++)
1379 fixed(8, ff_byte, 0xff);
1391 HEADER(
"End of Sequence");
#define allocate(name, size)
static int FUNC() sei_mastering_display_colour_volume(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIMasteringDisplayColourVolume *current)
uint8_t deblocking_filter_control_present_flag
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int FUNC() dec_ref_pic_marking(CodedBitstreamContext *ctx, RWContext *rw, H264RawSliceHeader *current, int idr_pic_flag)
#define se(name, range_min, range_max)
static int FUNC() sei_pic_timestamp(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIPicTimestamp *current, const H264RawSPS *sps)
uint8_t dpb_output_delay_length_minus1
#define fixed(width, name, value)
uint8_t initial_cpb_removal_delay_length_minus1
H264RawPPS * pps[H264_MAX_PPS_COUNT]
uint8_t log2_max_frame_num_minus4
#define us(width, name, range_min, range_max, subs,...)
static int FUNC() sps_extension(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPSExtension *current)
#define xue(name, var, range_min, range_max, subs,...)
static int FUNC() sei_display_orientation(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIDisplayOrientation *current)
static int FUNC() scaling_list(CodedBitstreamContext *ctx, RWContext *rw, H264RawScalingList *current, int size_of_scaling_list)
uint8_t weighted_pred_flag
H264RawHRD nal_hrd_parameters
static int FUNC() sei_payload(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIPayload *current)
uint16_t pic_width_in_mbs_minus1
#define byte_alignment(rw)
#define MAX_UINT_BITS(length)
static int FUNC() vui_parameters_default(CodedBitstreamContext *ctx, RWContext *rw, H264RawVUI *current, H264RawSPS *sps)
#define u(width, name, range_min, range_max)
static int FUNC() pred_weight_table(CodedBitstreamContext *ctx, RWContext *rw, H264RawSliceHeader *current)
CHECK(-1) CHECK(-2)}}}}CHECK(1) CHECK(2)}}}}}if(diff0+diff1 > 0) temp-
#define ses(name, range_min, range_max, subs,...)
static int get_bits_count(const GetBitContext *s)
H264RawSPS * sps[H264_MAX_SPS_COUNT]
static int FUNC() slice_header(CodedBitstreamContext *ctx, RWContext *rw, H264RawSliceHeader *current)
uint8_t nal_hrd_parameters_present_flag
uint8_t bit_depth_luma_minus8
uint8_t slice_group_map_type
buffering period (H.264, D.1.1)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t max_num_ref_frames
uint8_t weighted_bipred_idc
static int FUNC() sei_pan_scan_rect(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIPanScanRect *current)
#define ue(name, range_min, range_max)
static int FUNC() rbsp_trailing_bits(CodedBitstreamContext *ctx, RWContext *rw)
uint8_t num_ref_idx_l1_default_active_minus1
uint8_t frame_mbs_only_flag
static int put_bits_count(PutBitContext *s)
uint8_t seq_parameter_set_id
static int FUNC() sei_recovery_point(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIRecoveryPoint *current)
static const struct TransferCharacteristics transfer_characteristics[AVCOL_TRC_NB]
static int FUNC() ref_pic_list_modification(CodedBitstreamContext *ctx, RWContext *rw, H264RawSliceHeader *current)
uint8_t separate_colour_plane_flag
uint8_t last_slice_nal_unit_type
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
#define more_rbsp_data(var)
uint8_t chroma_format_idc
static int FUNC() hrd_parameters(CodedBitstreamContext *ctx, RWContext *rw, H264RawHRD *current)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int FUNC() vui_parameters(CodedBitstreamContext *ctx, RWContext *rw, H264RawVUI *current, H264RawSPS *sps)
static int FUNC() nal_unit_header(CodedBitstreamContext *ctx, RWContext *rw, H264RawNALUnitHeader *current, uint32_t valid_type_mask)
uint8_t num_slice_groups_minus1
uint8_t bottom_field_pic_order_in_frame_present_flag
uint8_t entropy_coding_mode_flag
#define xu(width, name, var, range_min, range_max, subs,...)
static int FUNC() aud(CodedBitstreamContext *ctx, RWContext *rw, H264RawAUD *current)
uint8_t pic_order_cnt_type
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
Context structure for coded bitstream operations.
uint8_t num_ref_idx_l0_default_active_minus1
static int FUNC() end_of_sequence(CodedBitstreamContext *ctx, RWContext *rw, H264RawNALUnitHeader *current)
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
recovery point (frame # to decoder sync)
static int cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
registered user data as specified by Rec. ITU-T T.35
#define flags(name, subs,...)
static int FUNC() filler(CodedBitstreamContext *ctx, RWContext *rw, H264RawFiller *current)
static int FUNC() sei_user_data_registered(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIUserDataRegistered *current, uint32_t *payload_size)
static int FUNC() end_of_stream(CodedBitstreamContext *ctx, RWContext *rw, H264RawNALUnitHeader *current)
uint8_t redundant_pic_cnt_present_flag
uint8_t pic_struct_present_flag
uint8_t cpb_removal_delay_length_minus1
static int FUNC() sei_user_data_unregistered(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIUserDataUnregistered *current, uint32_t *payload_size)
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
static int FUNC() sei_buffering_period(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIBufferingPeriod *current)
static int FUNC() sei_pic_timing(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEIPicTiming *current)
uint8_t log2_max_pic_order_cnt_lsb_minus4
void * priv_data
Format private data.
uint8_t delta_pic_order_always_zero_flag
mastering display properties
const H264RawPPS * active_pps
uint16_t pic_height_in_map_units_minus1
#define infer(name, value)
#define ues(name, range_min, range_max, subs,...)
uint8_t vcl_hrd_parameters_present_flag
H264RawHRD vcl_hrd_parameters
const H264RawSPS * active_sps
uint16_t slice_group_change_rate_minus1