aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-h264.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/packet-h264.c')
-rw-r--r--epan/dissectors/packet-h264.c722
1 files changed, 398 insertions, 324 deletions
diff --git a/epan/dissectors/packet-h264.c b/epan/dissectors/packet-h264.c
index 8476570e63..9516c2cdc5 100644
--- a/epan/dissectors/packet-h264.c
+++ b/epan/dissectors/packet-h264.c
@@ -29,234 +29,231 @@ void proto_register_h264(void);
void proto_reg_handoff_h264(void);
/* Initialize the protocol and registered fields */
-static int proto_h264 = -1;
-static int hf_h264_type = -1;
-static int hf_h264_nal_f_bit = -1;
-static int hf_h264_nal_nri = -1;
-static int hf_h264_start_bit = -1;
-static int hf_h264_forbidden_bit = -1;
-static int hf_h264_end_bit = -1;
-static int hf_h264_profile = -1;
-static int hf_h264_profile_idc = -1;
-static int hf_h264_rbsp_stop_bit = -1;
-static int hf_h264_rbsp_trailing_bits = -1;
-static int hf_h264_constraint_set0_flag = -1;
-static int hf_h264_constraint_set1_flag = -1;
-static int hf_h264_constraint_set2_flag = -1;
-static int hf_h264_constraint_set3_flag = -1;
-static int hf_h264_constraint_set4_flag = -1;
-static int hf_h264_constraint_set5_flag = -1;
-static int hf_h264_reserved_zero_2bits = -1;
-static int hf_h264_level_idc = -1;
-static int hf_h264_nal_unit = -1;
-static int hf_h264_forbidden_zero_bit = -1;
-static int hf_h264_nal_ref_idc = -1;
-static int hf_h264_nal_unit_type = -1;
-static int hf_h264_seq_parameter_set_id = -1;
-static int hf_h264_chroma_format_idc = -1;
-static int hf_h264_residual_colour_transform_flag = -1;
-static int hf_h264_bit_depth_luma_minus8 = -1;
-static int hf_h264_bit_depth_chroma_minus8 = -1;
-static int hf_h264_qpprime_y_zero_transform_bypass_flag = -1;
-static int hf_h264_seq_scaling_matrix_present_flag = -1;
-static int hf_h264_seq_scaling_list_present_flag = -1;
-static int hf_h264_delta_scale = -1;
-static int hf_h264_log2_max_frame_num_minus4 = -1;
-static int hf_h264_pic_order_cnt_type = -1;
-static int hf_h264_log2_max_pic_order_cnt_lsb_minus4 = -1;
-static int hf_h264_delta_pic_order_always_zero_flag = -1;
-static int hf_h264_offset_for_non_ref_pic = -1;
-static int hf_h264_offset_for_top_to_bottom_field = -1;
-static int hf_h264_num_ref_frames_in_pic_order_cnt_cycle = -1;
-static int hf_h264_offset_for_ref_frame = -1;
-static int hf_h264_num_ref_frames = -1;
-static int hf_h264_gaps_in_frame_num_value_allowed_flag = -1;
-static int hf_h264_pic_width_in_mbs_minus1 = -1;
-static int hf_h264_pic_height_in_map_units_minus1 = -1;
-static int hf_h264_frame_mbs_only_flag = -1;
-static int hf_h264_mb_adaptive_frame_field_flag = -1;
-static int hf_h264_direct_8x8_inference_flag = -1;
-static int hf_h264_frame_cropping_flag = -1;
-static int hf_h264_frame_crop_left_offset = -1;
-static int hf_h264_frame_crop_right_offset = -1;
-static int hf_h264_frame_crop_top_offset = -1;
-static int hf_h264_frame_crop_bottom_offset = -1;
-static int hf_h264_vui_parameters_present_flag = -1;
-static int hf_h264_pic_parameter_set_id = -1;
-static int hf_h264_entropy_coding_mode_flag = -1;
-static int hf_h264_pic_order_present_flag = -1;
-static int hf_h264_num_slice_groups_minus1 = -1;
-static int hf_h264_slice_group_map_type = -1;
-static int hf_h264_num_ref_idx_l0_active_minus1 = -1;
-static int hf_h264_num_ref_idx_l1_active_minus1 = -1;
-static int hf_h264_weighted_pred_flag = -1;
-static int hf_h264_weighted_bipred_idc = -1;
-static int hf_h264_pic_init_qp_minus26 = -1;
-static int hf_h264_pic_init_qs_minus26 = -1;
-static int hf_h264_chroma_qp_index_offset = -1;
-static int hf_h264_deblocking_filter_control_present_flag = -1;
-static int hf_h264_constrained_intra_pred_flag = -1;
-static int hf_h264_redundant_pic_cnt_present_flag = -1;
-static int hf_h264_transform_8x8_mode_flag = -1;
-static int hf_h264_pic_scaling_matrix_present_flag = -1;
-static int hf_h264_second_chroma_qp_index_offset = -1;
-static int hf_h264_par_profile = -1;
-static int hf_h264_par_profile_b = -1;
-static int hf_h264_par_profile_m = -1;
-static int hf_h264_par_profile_e = -1;
-static int hf_h264_par_profile_h = -1;
-static int hf_h264_par_profile_h10 = -1;
-static int hf_h264_par_profile_h4_2_2 = -1;
-static int hf_h264_par_profile_h4_4_4 = -1;
-/* static int hf_h264_par_add_mode_sup = -1; */
-static int hf_h264_par_AdditionalModesSupported = -1;
-static int hf_h264_par_add_mode_sup_rcdo = -1;
-static int hf_h264_par_ProfileIOP = -1;
-static int hf_h264_par_constraint_set0_flag = -1;
-static int hf_h264_par_constraint_set1_flag = -1;
-static int hf_h264_par_constraint_set2_flag = -1;
+static int proto_h264;
+static int hf_h264_type;
+static int hf_h264_nal_f_bit;
+static int hf_h264_nal_nri;
+static int hf_h264_start_bit;
+static int hf_h264_forbidden_bit;
+static int hf_h264_end_bit;
+static int hf_h264_profile;
+static int hf_h264_profile_idc;
+static int hf_h264_rbsp_stop_bit;
+static int hf_h264_rbsp_trailing_bits;
+static int hf_h264_constraint_set0_flag;
+static int hf_h264_constraint_set1_flag;
+static int hf_h264_constraint_set2_flag;
+static int hf_h264_constraint_set3_flag;
+static int hf_h264_constraint_set4_flag;
+static int hf_h264_constraint_set5_flag;
+static int hf_h264_reserved_zero_2bits;
+static int hf_h264_level_idc;
+static int hf_h264_nal_unit;
+static int hf_h264_forbidden_zero_bit;
+static int hf_h264_nal_ref_idc;
+static int hf_h264_nal_unit_type;
+static int hf_h264_seq_parameter_set_id;
+static int hf_h264_chroma_format_idc;
+static int hf_h264_residual_colour_transform_flag;
+static int hf_h264_bit_depth_luma_minus8;
+static int hf_h264_bit_depth_chroma_minus8;
+static int hf_h264_qpprime_y_zero_transform_bypass_flag;
+static int hf_h264_seq_scaling_matrix_present_flag;
+static int hf_h264_seq_scaling_list_present_flag;
+static int hf_h264_delta_scale;
+static int hf_h264_log2_max_frame_num_minus4;
+static int hf_h264_pic_order_cnt_type;
+static int hf_h264_log2_max_pic_order_cnt_lsb_minus4;
+static int hf_h264_delta_pic_order_always_zero_flag;
+static int hf_h264_offset_for_non_ref_pic;
+static int hf_h264_offset_for_top_to_bottom_field;
+static int hf_h264_num_ref_frames_in_pic_order_cnt_cycle;
+static int hf_h264_offset_for_ref_frame;
+static int hf_h264_num_ref_frames;
+static int hf_h264_gaps_in_frame_num_value_allowed_flag;
+static int hf_h264_pic_width_in_mbs_minus1;
+static int hf_h264_pic_height_in_map_units_minus1;
+static int hf_h264_frame_mbs_only_flag;
+static int hf_h264_mb_adaptive_frame_field_flag;
+static int hf_h264_direct_8x8_inference_flag;
+static int hf_h264_frame_cropping_flag;
+static int hf_h264_frame_crop_left_offset;
+static int hf_h264_frame_crop_right_offset;
+static int hf_h264_frame_crop_top_offset;
+static int hf_h264_frame_crop_bottom_offset;
+static int hf_h264_vui_parameters_present_flag;
+static int hf_h264_pic_parameter_set_id;
+static int hf_h264_entropy_coding_mode_flag;
+static int hf_h264_pic_order_present_flag;
+static int hf_h264_num_slice_groups_minus1;
+static int hf_h264_slice_group_map_type;
+static int hf_h264_num_ref_idx_l0_active_minus1;
+static int hf_h264_num_ref_idx_l1_active_minus1;
+static int hf_h264_weighted_pred_flag;
+static int hf_h264_weighted_bipred_idc;
+static int hf_h264_pic_init_qp_minus26;
+static int hf_h264_pic_init_qs_minus26;
+static int hf_h264_chroma_qp_index_offset;
+static int hf_h264_deblocking_filter_control_present_flag;
+static int hf_h264_constrained_intra_pred_flag;
+static int hf_h264_redundant_pic_cnt_present_flag;
+static int hf_h264_transform_8x8_mode_flag;
+static int hf_h264_pic_scaling_matrix_present_flag;
+static int hf_h264_second_chroma_qp_index_offset;
+static int hf_h264_primary_pic_type;
+static int hf_h264_par_profile;
+static int hf_h264_par_profile_b;
+static int hf_h264_par_profile_m;
+static int hf_h264_par_profile_e;
+static int hf_h264_par_profile_h;
+static int hf_h264_par_profile_h10;
+static int hf_h264_par_profile_h4_2_2;
+static int hf_h264_par_profile_h4_4_4;
+/* static int hf_h264_par_add_mode_sup; */
+static int hf_h264_par_AdditionalModesSupported;
+static int hf_h264_par_add_mode_sup_rcdo;
+static int hf_h264_par_ProfileIOP;
+static int hf_h264_par_constraint_set0_flag;
+static int hf_h264_par_constraint_set1_flag;
+static int hf_h264_par_constraint_set2_flag;
/* Packetization Values */
-static int hf_h264_nalu_size = -1;
-static int hf_h264_don = -1;
-static int hf_h264_dond = -1;
-static int hf_h264_ts_offset16 = -1;
-static int hf_h264_ts_offset24 = -1;
+static int hf_h264_nalu_size;
+static int hf_h264_don;
+static int hf_h264_dond;
+static int hf_h264_ts_offset16;
+static int hf_h264_ts_offset24;
/* Extension Header */
-static int hf_h264_nal_extension_subtype = -1;
-static int hf_h264_nal_extension_j = -1;
-static int hf_h264_nal_extension_k = -1;
-static int hf_h264_nal_extension_l = -1;
+static int hf_h264_nal_extension_subtype;
+static int hf_h264_nal_extension_j;
+static int hf_h264_nal_extension_k;
+static int hf_h264_nal_extension_l;
/* SEI Decoding Information */
-static int hf_h264_sei_uuid = -1;
+static int hf_h264_sei_uuid;
/* Microsoft Layout SEI */
-static int hf_h264_sei_ms_lpb = -1;
-static int hf_h264_sei_ms_layout_p = -1;
-static int hf_h264_sei_ms_layout_ldsize = -1;
-static int hf_h264_sei_ms_layer_desc_coded_width = -1;
-static int hf_h264_sei_ms_layer_desc_coded_height = -1;
-static int hf_h264_sei_ms_layer_desc_display_width = -1;
-static int hf_h264_sei_ms_layer_desc_display_height = -1;
-static int hf_h264_sei_ms_layer_desc_bitrate = -1;
-static int hf_h264_sei_ms_layer_desc_frame_rate = -1;
-static int hf_h264_sei_ms_layer_desc_layer_type = -1;
-static int hf_h264_sei_ms_layer_desc_prid = -1;
-static int hf_h264_sei_ms_layer_desc_cb = -1;
+static int hf_h264_sei_ms_lpb;
+static int hf_h264_sei_ms_layout_p;
+static int hf_h264_sei_ms_layout_ldsize;
+static int hf_h264_sei_ms_layer_desc_coded_width;
+static int hf_h264_sei_ms_layer_desc_coded_height;
+static int hf_h264_sei_ms_layer_desc_display_width;
+static int hf_h264_sei_ms_layer_desc_display_height;
+static int hf_h264_sei_ms_layer_desc_bitrate;
+static int hf_h264_sei_ms_layer_desc_frame_rate;
+static int hf_h264_sei_ms_layer_desc_layer_type;
+static int hf_h264_sei_ms_layer_desc_prid;
+static int hf_h264_sei_ms_layer_desc_cb;
/* Microsoft Bitstream SEI */
-static int hf_h264_sei_ms_bitstream_ref_frame_cnt = -1;
-static int hf_h264_sei_ms_bitstream_num_nalus = -1;
-static int hf_h264_sei_iso_sec_info = -1;
+static int hf_h264_sei_ms_bitstream_ref_frame_cnt;
+static int hf_h264_sei_ms_bitstream_num_nalus;
+static int hf_h264_sei_iso_sec_info;
/* Microsoft Crop SEI */
-static int hf_h264_sei_ms_crop_num_data = -1;
-static int hf_h264_sei_ms_crop_info_type = -1;
-static int hf_h264_sei_ms_crop_confidence_level = -1;
-static int hf_h264_sei_ms_crop_frame_left_offset = -1;
-static int hf_h264_sei_ms_crop_frame_right_offset = -1;
-static int hf_h264_sei_ms_crop_frame_top_offset = -1;
-static int hf_h264_sei_ms_crop_frame_bottom_offset = -1;
+static int hf_h264_sei_ms_crop_num_data;
+static int hf_h264_sei_ms_crop_info_type;
+static int hf_h264_sei_ms_crop_confidence_level;
+static int hf_h264_sei_ms_crop_frame_left_offset;
+static int hf_h264_sei_ms_crop_frame_right_offset;
+static int hf_h264_sei_ms_crop_frame_top_offset;
+static int hf_h264_sei_ms_crop_frame_bottom_offset;
/* SVC NAL Header Extension Values Annex G.7.3.1.1 */
-static int hf_h264_nal_hdr_ext_svc = -1;
-static int hf_h264_nal_hdr_ext_i = -1;
-static int hf_h264_nal_hdr_ext_prid = -1;
-static int hf_h264_nal_hdr_ext_n = -1;
-static int hf_h264_nal_hdr_ext_did = -1;
-static int hf_h264_nal_hdr_ext_qid = -1;
-static int hf_h264_nal_hdr_ext_tid = -1;
-static int hf_h264_nal_hdr_ext_u = -1;
-static int hf_h264_nal_hdr_ext_d = -1;
-static int hf_h264_nal_hdr_ext_o = -1;
-static int hf_h264_nal_hdr_ext_rr = -1;
+static int hf_h264_nal_hdr_ext_svc;
+static int hf_h264_nal_hdr_ext_i;
+static int hf_h264_nal_hdr_ext_prid;
+static int hf_h264_nal_hdr_ext_n;
+static int hf_h264_nal_hdr_ext_did;
+static int hf_h264_nal_hdr_ext_qid;
+static int hf_h264_nal_hdr_ext_tid;
+static int hf_h264_nal_hdr_ext_u;
+static int hf_h264_nal_hdr_ext_d;
+static int hf_h264_nal_hdr_ext_o;
+static int hf_h264_nal_hdr_ext_rr;
/* PACSI Values */
-static int hf_h264_pacsi_x = -1;
-static int hf_h264_pacsi_y = -1;
-static int hf_h264_pacsi_t = -1;
-static int hf_h264_pacsi_a = -1;
-static int hf_h264_pacsi_p = -1;
-static int hf_h264_pacsi_c = -1;
-static int hf_h264_pacsi_s = -1;
-static int hf_h264_pacsi_e = -1;
-static int hf_h264_pacsi_tl0picidx = -1;
-static int hf_h264_pacsi_idrpicid = -1;
-static int hf_h264_pacsi_donc = -1;
+static int hf_h264_pacsi_x;
+static int hf_h264_pacsi_y;
+static int hf_h264_pacsi_t;
+static int hf_h264_pacsi_a;
+static int hf_h264_pacsi_p;
+static int hf_h264_pacsi_c;
+static int hf_h264_pacsi_s;
+static int hf_h264_pacsi_e;
+static int hf_h264_pacsi_tl0picidx;
+static int hf_h264_pacsi_idrpicid;
+static int hf_h264_pacsi_donc;
/* VUI parameters */
-static int hf_h264_aspect_ratio_info_present_flag = -1;
-static int hf_h264_aspect_ratio_idc = -1;
-static int hf_h264_sar_width = -1;
-static int hf_h264_sar_height = -1;
-static int hf_h264_overscan_info_present_flag = -1;
-static int hf_h264_overscan_appropriate_flag = -1;
-static int hf_h264_video_signal_type_present_flag = -1;
-static int hf_h264_video_format = -1;
-static int hf_h264_video_full_range_flag = -1;
-static int hf_h264_colour_description_present_flag = -1;
-static int hf_h264_colour_primaries = -1;
-static int hf_h264_transfer_characteristics = -1;
-static int hf_h264_matrix_coefficients = -1;
-static int hf_h264_chroma_loc_info_present_flag = -1;
-static int hf_h264_chroma_sample_loc_type_top_field = -1;
-static int hf_h264_chroma_sample_loc_type_bottom_field = -1;
-static int hf_h264_timing_info_present_flag = -1;
-static int hf_h264_num_units_in_tick = -1;
-static int hf_h264_time_scale = -1;
-static int hf_h264_fixed_frame_rate_flag = -1;
-static int hf_h264_nal_hrd_parameters_present_flag = -1;
-static int hf_h264_vcl_hrd_parameters_present_flag = -1;
-static int hf_h264_low_delay_hrd_flag = -1;
-static int hf_h264_pic_struct_present_flag = -1;
-static int hf_h264_bitstream_restriction_flag = -1;
-static int hf_h264_motion_vectors_over_pic_boundaries_flag = -1;
-static int hf_h264_max_bytes_per_pic_denom = -1;
-static int hf_h264_max_bits_per_mb_denom = -1;
-static int hf_h264_log2_max_mv_length_horizontal = -1;
-static int hf_h264_log2_max_mv_length_vertical = -1;
-static int hf_h264_num_reorder_frames = -1;
-static int hf_h264_max_dec_frame_buffering = -1;
-static int hf_h264_cpb_cnt_minus1 = -1;
-static int hf_h264_bit_rate_scale = -1;
-static int hf_h264_cpb_size_scale = -1;
-static int hf_h264_bit_rate_value_minus1 = -1;
-static int hf_h264_cpb_size_value_minus1 = -1;
-static int hf_h264_cbr_flag = -1;
-static int hf_h264_initial_cpb_removal_delay_length_minus1 = -1;
-static int hf_h264_cpb_removal_delay_length_minus1 = -1;
-static int hf_h264_dpb_output_delay_length_minus11 = -1;
-static int hf_h264_time_offset_length = -1;
-
-static int hf_h264_first_mb_in_slice = -1;
-static int hf_h264_slice_type = -1;
-static int hf_h264_slice_id = -1;
-static int hf_h264_payloadsize = -1;
-static int hf_h264_payloadtype = -1;
-/* static int hf_h264_frame_num = -1; */
+static int hf_h264_aspect_ratio_info_present_flag;
+static int hf_h264_aspect_ratio_idc;
+static int hf_h264_sar_width;
+static int hf_h264_sar_height;
+static int hf_h264_overscan_info_present_flag;
+static int hf_h264_overscan_appropriate_flag;
+static int hf_h264_video_signal_type_present_flag;
+static int hf_h264_video_format;
+static int hf_h264_video_full_range_flag;
+static int hf_h264_colour_description_present_flag;
+static int hf_h264_colour_primaries;
+static int hf_h264_transfer_characteristics;
+static int hf_h264_matrix_coefficients;
+static int hf_h264_chroma_loc_info_present_flag;
+static int hf_h264_chroma_sample_loc_type_top_field;
+static int hf_h264_chroma_sample_loc_type_bottom_field;
+static int hf_h264_timing_info_present_flag;
+static int hf_h264_num_units_in_tick;
+static int hf_h264_time_scale;
+static int hf_h264_fixed_frame_rate_flag;
+static int hf_h264_nal_hrd_parameters_present_flag;
+static int hf_h264_vcl_hrd_parameters_present_flag;
+static int hf_h264_low_delay_hrd_flag;
+static int hf_h264_pic_struct_present_flag;
+static int hf_h264_bitstream_restriction_flag;
+static int hf_h264_motion_vectors_over_pic_boundaries_flag;
+static int hf_h264_max_bytes_per_pic_denom;
+static int hf_h264_max_bits_per_mb_denom;
+static int hf_h264_log2_max_mv_length_horizontal;
+static int hf_h264_log2_max_mv_length_vertical;
+static int hf_h264_num_reorder_frames;
+static int hf_h264_max_dec_frame_buffering;
+static int hf_h264_cpb_cnt_minus1;
+static int hf_h264_bit_rate_scale;
+static int hf_h264_cpb_size_scale;
+static int hf_h264_bit_rate_value_minus1;
+static int hf_h264_cpb_size_value_minus1;
+static int hf_h264_cbr_flag;
+static int hf_h264_initial_cpb_removal_delay_length_minus1;
+static int hf_h264_cpb_removal_delay_length_minus1;
+static int hf_h264_dpb_output_delay_length_minus11;
+static int hf_h264_time_offset_length;
+
+static int hf_h264_first_mb_in_slice;
+static int hf_h264_slice_type;
+static int hf_h264_slice_id;
+static int hf_h264_payloadsize;
+static int hf_h264_payloadtype;
+/* static int hf_h264_frame_num; */
/* Initialize the subtree pointers */
-static int ett_h264 = -1;
-static int ett_h264_profile = -1;
-static int ett_h264_nal = -1;
-static int ett_h264_fua = -1;
-static int ett_h264_stream = -1;
-static int ett_h264_nal_unit = -1;
-static int ett_h264_par_profile = -1;
-static int ett_h264_par_AdditionalModesSupported = -1;
-static int ett_h264_par_ProfileIOP = -1;
-static int ett_h264_ms_layer_description = -1;
-static int ett_h264_ms_crop_data = -1;
-static int ett_h264_ni_mtap = -1;
-
-static expert_field ei_h264_undecoded = EI_INIT;
-static expert_field ei_h264_ms_layout_wrong_length = EI_INIT;
-static expert_field ei_h264_oversized_exp_golomb_code = EI_INIT;
-static expert_field ei_h264_bad_nal_length = EI_INIT;
-static expert_field ei_h264_nal_unit_type_reserved = EI_INIT;
-static expert_field ei_h264_nal_unit_type_unspecified = EI_INIT;
+static int ett_h264;
+static int ett_h264_profile;
+static int ett_h264_nal;
+static int ett_h264_fua;
+static int ett_h264_stream;
+static int ett_h264_nal_unit;
+static int ett_h264_par_profile;
+static int ett_h264_par_AdditionalModesSupported;
+static int ett_h264_par_ProfileIOP;
+static int ett_h264_ms_layer_description;
+static int ett_h264_ms_crop_data;
+static int ett_h264_ni_mtap;
+
+static expert_field ei_h264_undecoded;
+static expert_field ei_h264_ms_layout_wrong_length;
+static expert_field ei_h264_oversized_exp_golomb_code;
+static expert_field ei_h264_bad_nal_length;
+static expert_field ei_h264_nal_unit_type_reserved;
+static expert_field ei_h264_nal_unit_type_unspecified;
static dissector_handle_t h264_name_handle;
-/* The dynamic payload type range which will be dissected as H.264 */
-
-static range_t *temp_dynamic_payload_type_range = NULL;
-
static dissector_handle_t h264_handle;
/* syntax tables in subclause 7.3 is equal to
@@ -473,6 +470,19 @@ static const value_string h264_slice_group_map_type_vals[] = {
{ 0, NULL }
};
+/* Table 7-5 Meaning of primary_pic_type */
+static const value_string h264_primary_pic_type_vals[] = {
+ { 0, "2, 7" },
+ { 1, "0, 2, 5, 7" },
+ { 2, "0, 1, 2, 5, 6, 7" },
+ { 3, "4, 9" },
+ { 4, "3, 4, 8, 9" },
+ { 5, "2, 4, 7, 9" },
+ { 6, "0, 2, 3, 4, 5, 7, 8, 9" },
+ { 7, "0, 1, 2, 3, 4, 5, 6, 7, 8, 9" },
+ { 0, NULL }
+};
+
/* Table 7-6 Name association to slice_type */
static const value_string h264_slice_type_vals[] = {
{ 0, "P (P slice)" },
@@ -534,7 +544,7 @@ h264_byte_aligned(int bit_offset)
#define cVALS(x) (const value_string*)(x)
static guint32
-dissect_h264_exp_golomb_code(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint *start_bit_offset, h264_golomb_descriptors descriptor)
+dissect_h264_exp_golomb_code(proto_tree *tree, packet_info *pinfo, int hf_index, tvbuff_t *tvb, gint *start_bit_offset, h264_golomb_descriptors descriptor)
/*(tvbuff_t *tvb, gint *start_bit_offset) */
{
proto_item *ti;
@@ -551,7 +561,7 @@ dissect_h264_exp_golomb_code(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint
start_offset = *start_bit_offset>>3;
- if (hf_index > -1)
+ if (hf_index > 0)
hf_field = proto_registrar_get_nth(hf_index);
switch (descriptor) {
@@ -567,7 +577,7 @@ dissect_h264_exp_golomb_code(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint
bit_offset = *start_bit_offset;
/* prepare the string */
- str = (char *)wmem_alloc(wmem_packet_scope(), 256);
+ str = (char *)wmem_alloc(pinfo->pool, 256);
str[0] = '\0';
for (bit=0; bit<((int)(bit_offset&0x07)); bit++) {
if (bit && (!(bit%4))) {
@@ -692,8 +702,8 @@ dissect_h264_exp_golomb_code(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint
overflow = TRUE;
codenum = G_MAXUINT32;
if (descriptor == H264_SE_V) {
- value = tvb_get_bits32(tvb, bit_offset + leading_zero_bits / 32, leading_zero_bits % 32, ENC_BIG_ENDIAN);
- if (value % 1) {
+ value = tvb_get_bits32(tvb, bit_offset + 32*(leading_zero_bits / 32), leading_zero_bits % 32, ENC_BIG_ENDIAN);
+ if (value % 2) {
se_value = G_MININT32;
} else {
se_value = G_MAXINT32;
@@ -709,7 +719,7 @@ dissect_h264_exp_golomb_code(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint
if (value != 1) {
overflow = TRUE;
}
- if (value % 1) {
+ if (value % 2) {
se_value = G_MININT32;
} else {
se_value = G_MAXINT32;
@@ -755,11 +765,11 @@ dissect_h264_exp_golomb_code(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint
*start_bit_offset = bit_offset;
/* We will probably get a BoundsError later in the packet. */
if (descriptor == H264_SE_V) {
- ti = proto_tree_add_int_format_value(tree, hf_index, tvb, start_offset, (bit_offset >> 3) - start_offset + 1, codenum, "Invalid value (%d leading zero bits), clamped to %" G_GINT32_MODIFIER "d", leading_zero_bits, se_value);
+ ti = proto_tree_add_int_format_value(tree, hf_index, tvb, start_offset, (bit_offset >> 3) - start_offset + 1, codenum, "Invalid value (%d leading zero bits), clamped to %" PRId32, leading_zero_bits, se_value);
expert_add_info(NULL, ti, &ei_h264_oversized_exp_golomb_code);
return se_value;
} else {
- ti = proto_tree_add_uint_format_value(tree, hf_index, tvb, start_offset, (bit_offset >> 3) - start_offset + 1, codenum, "Invalid value (%d leading zero bits), clamped to %" G_GINT32_MODIFIER "u", leading_zero_bits, codenum);
+ ti = proto_tree_add_uint_format_value(tree, hf_index, tvb, start_offset, (bit_offset >> 3) - start_offset + 1, codenum, "Invalid value (%d leading zero bits), clamped to %" PRIu32, leading_zero_bits, codenum);
expert_add_info(NULL, ti, &ei_h264_oversized_exp_golomb_code);
return codenum;
}
@@ -931,16 +941,16 @@ dissect_h264_rbsp_trailing_bits(proto_tree *tree, tvbuff_t *tvb, packet_info *pi
* XXX Just parse a few bytes
*/
static int
-dissect_h264_slice_header(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
+dissect_h264_slice_header(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint bit_offset)
{
/* first_mb_in_slice 2 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_first_mb_in_slice, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_first_mb_in_slice, tvb, &bit_offset, H264_UE_V);
/* slice_type 2 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_slice_type, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_slice_type, tvb, &bit_offset, H264_UE_V);
/* pic_parameter_set_id 2 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
/* frame_num 2 u(v) */
/*
@@ -957,7 +967,7 @@ dissect_h264_slice_header(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U
* scaling_list( scalingList, sizeOfScalingList, useDefaultScalingMatrixFlag )
*/
static int
-dissect_h264_scaling_list(proto_tree *tree, tvbuff_t *tvb, gint bit_offset, int* hf_index_scalinglist,
+dissect_h264_scaling_list(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, gint bit_offset, int* hf_index_scalinglist,
guint8 sizeOfScalingList)
{
guint8 j;
@@ -968,7 +978,7 @@ dissect_h264_scaling_list(proto_tree *tree, tvbuff_t *tvb, gint bit_offset, int*
for (j = 0; j < sizeOfScalingList; j++) {
if (nextScale != 0) {
/* delta_scale 0 | 1 se(v) */
- delta_scale = dissect_h264_exp_golomb_code(tree, hf_h264_delta_scale, tvb, &bit_offset, H264_SE_V);
+ delta_scale = dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_delta_scale, tvb, &bit_offset, H264_SE_V);
nextScale = ( lastScale + delta_scale + 256 ) % 256;
/* hf_index_usedefaultscalingmatrixflag = ( j == 0 && nextScale == 0 ); */
}
@@ -981,14 +991,14 @@ dissect_h264_scaling_list(proto_tree *tree, tvbuff_t *tvb, gint bit_offset, int*
/* E.1.2 HRD parameters syntax */
static int
-dissect_h264_hrd_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
+dissect_h264_hrd_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint bit_offset)
{
guint8 cpb_cnt_minus1;
int SchedSelIdx;
/* cpb_cnt_minus1 0 ue(v) */
- cpb_cnt_minus1 = dissect_h264_exp_golomb_code(tree, hf_h264_cpb_cnt_minus1, tvb, &bit_offset, H264_UE_V);
+ cpb_cnt_minus1 = dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_cpb_cnt_minus1, tvb, &bit_offset, H264_UE_V);
/* bit_rate_scale 0 u(4) */
proto_tree_add_bits_item(tree, hf_h264_bit_rate_scale, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
@@ -1001,10 +1011,10 @@ dissect_h264_hrd_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo
for (SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++) {
/* bit_rate_value_minus1[ SchedSelIdx ] 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_bit_rate_value_minus1, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_bit_rate_value_minus1, tvb, &bit_offset, H264_UE_V);
/* cpb_size_value_minus1[ SchedSelIdx ] 0 ue(v)*/
- dissect_h264_exp_golomb_code(tree, hf_h264_cpb_size_value_minus1, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_cpb_size_value_minus1, tvb, &bit_offset, H264_UE_V);
/* cbr_flag[ SchedSelIdx ] 0 u(1) */
proto_tree_add_bits_item(tree, hf_h264_cbr_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
@@ -1131,10 +1141,10 @@ dissect_h264_vui_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo,
if (chroma_loc_info_present_flag) {
/* chroma_sample_loc_type_top_field 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_chroma_sample_loc_type_top_field, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_chroma_sample_loc_type_top_field, tvb, &bit_offset, H264_UE_V);
/* chroma_sample_loc_type_bottom_field 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_chroma_sample_loc_type_bottom_field, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_chroma_sample_loc_type_bottom_field, tvb, &bit_offset, H264_UE_V);
}
/* timing_info_present_flag 0 u(1) */
@@ -1194,22 +1204,22 @@ dissect_h264_vui_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo,
bit_offset++;
/* max_bytes_per_pic_denom 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_max_bytes_per_pic_denom, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_max_bytes_per_pic_denom, tvb, &bit_offset, H264_UE_V);
/* max_bits_per_mb_denom 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_max_bits_per_mb_denom, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_max_bits_per_mb_denom, tvb, &bit_offset, H264_UE_V);
/* log2_max_mv_length_horizontal 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_mv_length_horizontal, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_log2_max_mv_length_horizontal, tvb, &bit_offset, H264_UE_V);
/* log2_max_mv_length_vertical 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_mv_length_vertical, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_log2_max_mv_length_vertical, tvb, &bit_offset, H264_UE_V);
/* num_reorder_frames 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_num_reorder_frames, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_num_reorder_frames, tvb, &bit_offset, H264_UE_V);
/* max_dec_frame_buffering 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_max_dec_frame_buffering, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_max_dec_frame_buffering, tvb, &bit_offset, H264_UE_V);
}
return bit_offset;
@@ -1332,7 +1342,7 @@ dissect_h264_slice_layer_without_partitioning_rbsp(proto_tree *tree, tvbuff_t *t
* slice_data_partition_a_layer_rbsp( )
*/
static void
-dissect_h264_slice_data_partition_a_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
+dissect_h264_slice_data_partition_a_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
{
gint bit_offset;
@@ -1342,7 +1352,7 @@ dissect_h264_slice_data_partition_a_layer_rbsp(proto_tree *tree, tvbuff_t *tvb,
bit_offset = dissect_h264_slice_header(tree, tvb, pinfo, bit_offset);
/* slice_id All ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, bit_offset>>3, -1);
return;
/* slice_data( ) * only category 2 parts of slice_data( ) syntax * 2*/
@@ -1354,14 +1364,14 @@ dissect_h264_slice_data_partition_a_layer_rbsp(proto_tree *tree, tvbuff_t *tvb,
* slice_data_partition_b_layer_rbsp(
*/
static void
-dissect_h264_slice_data_partition_b_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
+dissect_h264_slice_data_partition_b_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
{
gint bit_offset;
bit_offset = offset <<3;
/* slice_id All ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
/* if (redundant_pic_cnt_present_flag) */
/* redundant_pic_cnt All ue(v) */
/* slice_data( ) * only category 3 parts of slice_data( ) syntax * 3 */
@@ -1375,14 +1385,14 @@ dissect_h264_slice_data_partition_b_layer_rbsp(proto_tree *tree, tvbuff_t *tvb,
* slice_data_partition_c_layer_rbsp( )
*/
static void
-dissect_h264_slice_data_partition_c_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
+dissect_h264_slice_data_partition_c_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
{
gint bit_offset;
bit_offset = offset <<3;
/* slice_id All ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
/* if (redundant_pic_cnt_present_flag) */
/* redundant_pic_cnt All ue(v) */
/* slice_data( ) * only category 4 parts of slice_data( ) syntax * 4 */
@@ -1758,7 +1768,7 @@ dissect_h264_seq_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info
* The parsing process for this descriptor is specified in subclause 9.1.
*/
bit_offset = offset<<3;
- dissect_h264_exp_golomb_code(tree, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
if ((profile_idc == 100) || (profile_idc == 110) ||
@@ -1769,7 +1779,7 @@ dissect_h264_seq_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info
{
/* chroma_format_idc 0 ue(v) */
- chroma_format_idc = dissect_h264_exp_golomb_code(tree, hf_h264_chroma_format_idc, tvb, &bit_offset, H264_UE_V);
+ chroma_format_idc = dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_chroma_format_idc, tvb, &bit_offset, H264_UE_V);
if (chroma_format_idc == 3) {
/* residual_colour_transform_flag 0 u(1) */
proto_tree_add_bits_item(tree, hf_h264_residual_colour_transform_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
@@ -1777,10 +1787,10 @@ dissect_h264_seq_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info
}
/* bit_depth_luma_minus8 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_bit_depth_luma_minus8, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_bit_depth_luma_minus8, tvb, &bit_offset, H264_UE_V);
/* bit_depth_chroma_minus8 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_bit_depth_chroma_minus8, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_bit_depth_chroma_minus8, tvb, &bit_offset, H264_UE_V);
/* qpprime_y_zero_transform_bypass_flag 0 u(1) */
proto_tree_add_bits_item(tree, hf_h264_qpprime_y_zero_transform_bypass_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
@@ -1799,9 +1809,9 @@ dissect_h264_seq_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info
bit_offset++;
if (seq_scaling_list_present_flag) {
if (i < 6)
- bit_offset = dissect_h264_scaling_list(tree, tvb, bit_offset, ScalingList4x4[ i ], 16);
+ bit_offset = dissect_h264_scaling_list(tree, pinfo, tvb, bit_offset, ScalingList4x4[ i ], 16);
else
- bit_offset = dissect_h264_scaling_list(tree, tvb, bit_offset, ScalingList8x8[ i - 6 ], 64);
+ bit_offset = dissect_h264_scaling_list(tree, pinfo, tvb, bit_offset, ScalingList8x8[ i - 6 ], 64);
}
}
}
@@ -1809,44 +1819,44 @@ dissect_h264_seq_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info
}
/* log2_max_frame_num_minus4 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_frame_num_minus4, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_log2_max_frame_num_minus4, tvb, &bit_offset, H264_UE_V);
/* pic_order_cnt_type 0 ue(v) */
- pic_order_cnt_type = dissect_h264_exp_golomb_code(tree, hf_h264_pic_order_cnt_type, tvb, &bit_offset, H264_UE_V);
+ pic_order_cnt_type = dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_pic_order_cnt_type, tvb, &bit_offset, H264_UE_V);
if (pic_order_cnt_type == 0) {
/* log2_max_pic_order_cnt_lsb_minus4 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_pic_order_cnt_lsb_minus4, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_log2_max_pic_order_cnt_lsb_minus4, tvb, &bit_offset, H264_UE_V);
} else if (pic_order_cnt_type == 1) {
/* delta_pic_order_always_zero_flag 0 u(1) */
proto_tree_add_bits_item(tree, hf_h264_delta_pic_order_always_zero_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
bit_offset++;
/* offset_for_non_ref_pic 0 se(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_non_ref_pic, tvb, &bit_offset, H264_SE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_offset_for_non_ref_pic, tvb, &bit_offset, H264_SE_V);
/* offset_for_top_to_bottom_field 0 se(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_top_to_bottom_field, tvb, &bit_offset, H264_SE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_offset_for_top_to_bottom_field, tvb, &bit_offset, H264_SE_V);
/* num_ref_frames_in_pic_order_cnt_cycle 0 ue(v) */
- num_ref_frames_in_pic_order_cnt_cycle = dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_frames_in_pic_order_cnt_cycle, tvb, &bit_offset, H264_UE_V);
+ num_ref_frames_in_pic_order_cnt_cycle = dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_num_ref_frames_in_pic_order_cnt_cycle, tvb, &bit_offset, H264_UE_V);
for (i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
/*offset_for_ref_frame[ i ] 0 se(v)*/
- dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_ref_frame, tvb, &bit_offset, H264_SE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_offset_for_ref_frame, tvb, &bit_offset, H264_SE_V);
}
}
/* num_ref_frames 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_frames, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_num_ref_frames, tvb, &bit_offset, H264_UE_V);
/* gaps_in_frame_num_value_allowed_flag 0 u(1) */
proto_tree_add_bits_item(tree, hf_h264_gaps_in_frame_num_value_allowed_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
bit_offset++;
/* pic_width_in_mbs_minus1 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_pic_width_in_mbs_minus1, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_pic_width_in_mbs_minus1, tvb, &bit_offset, H264_UE_V);
/* pic_height_in_map_units_minus1 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_pic_height_in_map_units_minus1, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_pic_height_in_map_units_minus1, tvb, &bit_offset, H264_UE_V);
/* frame_mbs_only_flag 0 u(1) */
frame_mbs_only_flag = tvb_get_bits8(tvb, bit_offset, 1);
@@ -1869,10 +1879,10 @@ dissect_h264_seq_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info
if (frame_cropping_flag) {
/* frame_crop_left_offset 0 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_left_offset, tvb, &bit_offset, H264_UE_V);
- dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_right_offset, tvb, &bit_offset, H264_UE_V);
- dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_top_offset, tvb, &bit_offset, H264_UE_V);
- dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_bottom_offset, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_frame_crop_left_offset, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_frame_crop_right_offset, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_frame_crop_top_offset, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_frame_crop_bottom_offset, tvb, &bit_offset, H264_UE_V);
}
@@ -1904,10 +1914,10 @@ dissect_h264_pic_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info
bit_offset = offset<<3;
/* pic_parameter_set_id 1 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
/* seq_parameter_set_id 1 ue(v) */
- dissect_h264_exp_golomb_code(tree, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
/* entropy_coding_mode_flag 1 u(1) */
proto_tree_add_bits_item(tree, hf_h264_entropy_coding_mode_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
@@ -1918,11 +1928,11 @@ dissect_h264_pic_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info
bit_offset++;
/* num_slice_groups_minus1 1 ue(v)*/
- num_slice_groups_minus1 = dissect_h264_exp_golomb_code(tree, hf_h264_num_slice_groups_minus1, tvb, &bit_offset, H264_UE_V);
+ num_slice_groups_minus1 = dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_num_slice_groups_minus1, tvb, &bit_offset, H264_UE_V);
if (num_slice_groups_minus1 > 0) {
/* slice_group_map_type 1 ue(v)*/
- dissect_h264_exp_golomb_code(tree, hf_h264_slice_group_map_type, tvb, &bit_offset, H264_UE_V);
- /* slice_group_map_type = dissect_h264_exp_golomb_code(tree, hf_h264_slice_group_map_type, tvb, &bit_offset, H264_UE_V);*/
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_slice_group_map_type, tvb, &bit_offset, H264_UE_V);
+ /* slice_group_map_type = dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_slice_group_map_type, tvb, &bit_offset, H264_UE_V);*/
/* if (slice_group_map_type == 0)*/
/* for (iGroup = 0; iGroup <= num_slice_groups_minus1; iGroup++)*/
/* run_length_minus1[ iGroup ] 1 ue(v)*/
@@ -1946,10 +1956,10 @@ dissect_h264_pic_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info
return;
}
/* num_ref_idx_l0_active_minus1 1 ue(v)*/
- dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_idx_l0_active_minus1, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_num_ref_idx_l0_active_minus1, tvb, &bit_offset, H264_UE_V);
/* num_ref_idx_l1_active_minus1 1 ue(v)*/
- dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_idx_l1_active_minus1, tvb, &bit_offset, H264_UE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_num_ref_idx_l1_active_minus1, tvb, &bit_offset, H264_UE_V);
/* weighted_pred_flag 1 u(1)*/
proto_tree_add_bits_item(tree, hf_h264_weighted_pred_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
@@ -1960,13 +1970,13 @@ dissect_h264_pic_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info
bit_offset= bit_offset+2;
/* pic_init_qp_minus26 * relative to 26 * 1 se(v)*/
- dissect_h264_exp_golomb_code(tree, hf_h264_pic_init_qp_minus26, tvb, &bit_offset, H264_SE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_pic_init_qp_minus26, tvb, &bit_offset, H264_SE_V);
/* pic_init_qs_minus26 * relative to 26 * 1 se(v)*/
- dissect_h264_exp_golomb_code(tree, hf_h264_pic_init_qs_minus26, tvb, &bit_offset, H264_SE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_pic_init_qs_minus26, tvb, &bit_offset, H264_SE_V);
/* chroma_qp_index_offset 1 se(v)*/
- dissect_h264_exp_golomb_code(tree, hf_h264_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
/* deblocking_filter_control_present_flag 1 u(1)*/
proto_tree_add_bits_item(tree, hf_h264_deblocking_filter_control_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
@@ -2004,7 +2014,7 @@ dissect_h264_pic_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info
}
/* second_chroma_qp_index_offset 1 se(v)*/
- dissect_h264_exp_golomb_code(tree, hf_h264_second_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
+ dissect_h264_exp_golomb_code(tree, pinfo, hf_h264_second_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
}
dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
}
@@ -2016,9 +2026,13 @@ dissect_h264_pic_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info
static void
dissect_h264_access_unit_delimiter_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
{
+ gint bit_offset = offset << 3;
/* primary_pic_type 6 u(3) */
+ proto_tree_add_bits_item(tree, hf_h264_primary_pic_type, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
+ bit_offset += 3;
+
/* rbsp_trailing_bits( ) 6 */
- proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, offset, -1);
+ dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
}
/*
@@ -2372,13 +2386,15 @@ startover:
/* In decoder configuration start code may be pressent
* B.1.1 Byte stream NAL unit syntax
*/
- dword = tvb_get_bits32(tvb, offset<<3, 32, ENC_BIG_ENDIAN);
- if (dword == 1) {
- /* zero_byte + start_code_prefix_one_3bytes */
- offset+=4;
- } else if ((dword >> 8) == 1) {
- /* start_code_prefix_one_3bytes */
- offset+= 3;
+ if (tvb_reported_length_remaining(tvb, offset<<3) >= 4) {
+ dword = tvb_get_bits32(tvb, offset<<3, 32, ENC_BIG_ENDIAN);
+ if (dword == 1) {
+ /* zero_byte + start_code_prefix_one_3bytes */
+ offset+=4;
+ } else if ((dword >> 8) == 1) {
+ /* start_code_prefix_one_3bytes */
+ offset+= 3;
+ }
}
/* Ref: 7.3.1 NAL unit syntax */
nal_unit_type = tvb_get_guint8(tvb, offset) & 0x1f;
@@ -2460,6 +2476,73 @@ startover:
}
}
+/* Annex B "Byte stream format" */
+static int
+dissect_h264_bytestream(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
+{
+ proto_tree *h264_tree;
+ proto_item *item;
+
+ tvbuff_t *next_tvb, *rbsp_tvb;
+ gint offset = 0, end_offset;
+ guint32 dword;
+
+ /* Look for the first start word. Assume byte aligned. */
+ while (1) {
+ if (tvb_reported_length(tvb) < 4) {
+ return 0;
+ }
+ dword = tvb_get_guint32(tvb, offset, ENC_BIG_ENDIAN);
+ if ((dword >> 8) == 1 || dword == 1) {
+ break;
+ } else if (dword != 0) {
+ return 0;
+ }
+ offset += 2;
+ }
+
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "H.264");
+ item = proto_tree_add_item(tree, proto_h264, tvb, 0, -1, ENC_NA);
+ h264_tree = proto_item_add_subtree(item, ett_h264);
+
+ while (tvb_reported_length_remaining(tvb, offset)) {
+ dword = tvb_get_guint32(tvb, offset, ENC_BIG_ENDIAN);
+ if ((dword >> 8) != 1) {
+ /* zero_byte */
+ offset++;
+ }
+ /* start_code_prefix_one_3bytes */
+ offset += 3;
+ gint nal_length = tvb_reported_length_remaining(tvb, offset);
+ /* Search for either \0\0\1 or \0\0\0\1:
+ * Find \0\0 and then check if \0\1 is in the next offset or
+ * the one after that. (Note none of this throws exceptions.)
+ */
+ end_offset = tvb_find_guint16(tvb, offset, -1, 0);
+ while (end_offset != -1) {
+ if (tvb_find_guint16(tvb, end_offset + 1, 3, 1) != -1) {
+ nal_length = end_offset - offset;
+ break;
+ }
+ end_offset = tvb_find_guint16(tvb, end_offset + 1, -1, 0);
+ }
+
+ /* If end_offset is -1, we got to the end; assume this is the end
+ * of the NAL. To handle a bytestream that fragments NALs across
+ * lower level packets (does any implementation do this?), we would
+ * need to use epan/stream.h
+ */
+
+ /* Unescape NAL unit */
+ next_tvb = tvb_new_subset_length(tvb, offset, nal_length);
+ rbsp_tvb = dissect_h265_unescap_nal_unit(next_tvb, pinfo, 0);
+
+ dissect_h264_nal_unit(rbsp_tvb, pinfo, h264_tree);
+ offset += nal_length;
+ }
+ return tvb_reported_length(tvb);
+}
+
/* Code to actually dissect the packets */
static int
dissect_h264(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
@@ -2472,7 +2555,7 @@ dissect_h264(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
/* Make entries in Protocol column and Info column on summary display */
- col_set_str(pinfo->cinfo, COL_PROTOCOL, "H264");
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "H.264");
type = tvb_get_guint8(tvb, offset)&0x1f;
@@ -2537,10 +2620,10 @@ dissect_h264(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
break;
case 3: /* Coded slice data partition B */
- dissect_h264_slice_data_partition_b_layer_rbsp(h264_nal_tree, rbsp_tvb, pinfo, 0);
+ dissect_h264_slice_data_partition_b_layer_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
break;
case 4: /* Coded slice data partition C */
- dissect_h264_slice_data_partition_c_layer_rbsp(h264_nal_tree, rbsp_tvb, pinfo, 0);
+ dissect_h264_slice_data_partition_c_layer_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
break;
case 5: /* Coded slice of an IDR picture */
dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
@@ -2814,7 +2897,7 @@ proto_register_h264(void)
},
{ &hf_h264_profile_idc,
{ "Profile_idc", "h264.profile_idc",
- FT_UINT8, BASE_DEC, VALS(h264_profile_idc_values), 0xff,
+ FT_UINT8, BASE_DEC, VALS(h264_profile_idc_values), 0x0,
NULL, HFILL }
},
{ &hf_h264_rbsp_stop_bit,
@@ -2864,7 +2947,7 @@ proto_register_h264(void)
},
{ &hf_h264_level_idc,
{ "Level_id", "h264.level_id",
- FT_UINT8, BASE_DEC, NULL, 0xff,
+ FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_h264_nal_unit,
@@ -3128,6 +3211,12 @@ proto_register_h264(void)
NULL, HFILL }
},
+ { &hf_h264_primary_pic_type,
+ { "primary_pic_type", "h264.primary_pic_type",
+ FT_INT8, BASE_DEC, VALS(h264_primary_pic_type_vals), 0x0,
+ "slice_type values that may be present in the primary coded picture", HFILL }
+ },
+
{ &hf_h264_aspect_ratio_info_present_flag,
{ "aspect_ratio_info_present_flag", "h264.aspect_ratio_info_present_flag",
FT_UINT8, BASE_DEC, NULL, 0x0,
@@ -3502,22 +3591,22 @@ proto_register_h264(void)
},
{ &hf_h264_sei_ms_layer_desc_coded_width,
{ "Coded Width", "h264.sei.ms.layout.desc.coded_width",
- FT_UINT8, BASE_DEC, NULL, 0x0,
+ FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_h264_sei_ms_layer_desc_coded_height,
{ "Coded Height", "h264.sei.ms.layout.desc.coded_height",
- FT_UINT8, BASE_DEC, NULL, 0x0,
+ FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_h264_sei_ms_layer_desc_display_width,
{ "Display Width", "h264.sei.ms.layout.desc.display_width",
- FT_UINT8, BASE_DEC, NULL, 0x0,
+ FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_h264_sei_ms_layer_desc_display_height,
{ "Display Height", "h264.sei.ms.layout.desc.display_height",
- FT_UINT8, BASE_DEC, NULL, 0x0,
+ FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }
},
{ &hf_h264_sei_ms_layer_desc_bitrate,
@@ -3697,7 +3786,7 @@ proto_register_h264(void)
},
{ &hf_h264_pacsi_tl0picidx,
{ "TL0PICIDX", "h264.pacsi.tl0picidx",
- FT_UINT8, BASE_DEC, NULL, 0xFF,
+ FT_UINT8, BASE_DEC, NULL, 0xff,
NULL, HFILL }
},
{ &hf_h264_pacsi_idrpicid,
@@ -3749,16 +3838,12 @@ proto_register_h264(void)
/* Register a configuration option for port */
- h264_module = prefs_register_protocol(proto_h264, proto_reg_handoff_h264);
+ h264_module = prefs_register_protocol(proto_h264, NULL);
-
- prefs_register_range_preference(h264_module, "dynamic.payload.type",
- "H.264 dynamic payload types",
- "Dynamic payload types which will be interpreted as H.264"
- "; values must be in the range 1 - 127",
- &temp_dynamic_payload_type_range, 127);
+ prefs_register_obsolete_preference(h264_module, "dynamic.payload.type");
h264_handle = register_dissector("h264", dissect_h264, proto_h264);
+ register_dissector_with_description("h264_bytestream", "H.264 Annex B Byte stream format", dissect_h264_bytestream, proto_h264);
}
@@ -3766,32 +3851,21 @@ proto_register_h264(void)
void
proto_reg_handoff_h264(void)
{
- static range_t *dynamic_payload_type_range = NULL;
- static gboolean h264_prefs_initialized = FALSE;
-
- if (!h264_prefs_initialized) {
- h264_capability_t *ftr;
-
- dissector_add_string("rtp_dyn_payload_type","H264", h264_handle);
- dissector_add_string("rtp_dyn_payload_type","H264-SVC", h264_handle);
- dissector_add_string("rtp_dyn_payload_type","X-H264UC", h264_handle);
-
- h264_name_handle = create_dissector_handle(dissect_h264_name, proto_h264);
- for (ftr=h264_capability_tab; ftr->id; ftr++) {
- if (ftr->name)
- dissector_add_string("h245.gef.name", ftr->id, h264_name_handle);
- if (ftr->content_pdu)
- dissector_add_string("h245.gef.content", ftr->id, create_dissector_handle(ftr->content_pdu, proto_h264));
- }
- h264_prefs_initialized = TRUE;
- } else {
- dissector_delete_uint_range("rtp.pt", dynamic_payload_type_range, h264_handle);
- wmem_free(wmem_epan_scope(), dynamic_payload_type_range);
+ h264_capability_t *ftr;
+
+ dissector_add_string("rtp_dyn_payload_type","H264", h264_handle);
+ dissector_add_string("rtp_dyn_payload_type","H264-SVC", h264_handle);
+ dissector_add_string("rtp_dyn_payload_type","X-H264UC", h264_handle);
+
+ h264_name_handle = create_dissector_handle(dissect_h264_name, proto_h264);
+ for (ftr=h264_capability_tab; ftr->id; ftr++) {
+ if (ftr->name)
+ dissector_add_string("h245.gef.name", ftr->id, h264_name_handle);
+ if (ftr->content_pdu)
+ dissector_add_string("h245.gef.content", ftr->id, create_dissector_handle(ftr->content_pdu, proto_h264));
}
- dynamic_payload_type_range = range_copy(wmem_epan_scope(), temp_dynamic_payload_type_range);
- range_remove_value(wmem_epan_scope(), &dynamic_payload_type_range, 0);
- dissector_add_uint_range("rtp.pt", dynamic_payload_type_range, h264_handle);
+ dissector_add_uint_range_with_preference("rtp.pt", "", h264_handle);
}