2 * Routines for H.264 dissection
3 * Copyright 2007 - 2009, Anders Broman <anders.broman[at]ericsson.com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 * http://www.ietf.org/rfc/rfc3984.txt?number=3984
27 * http://www.itu.int/rec/T-REC-H.264/en
39 #include <epan/packet.h>
40 #include <epan/proto.h>
41 #include <epan/asn1.h>
42 #include <epan/strutil.h>
44 #include <epan/prefs.h>
47 /* Initialize the protocol and registered fields */
48 static int proto_h264 = -1;
49 static int hf_h264_type = -1;
50 static int hf_h264_nal_f_bit = -1;
51 static int hf_h264_nal_nri = -1;
52 static int hf_h264_start_bit = -1;
53 static int hf_h264_forbidden_bit = -1;
54 static int hf_h264_end_bit = -1;
55 static int hf_h264_profile = -1;
56 static int hf_h264_profile_idc = -1;
57 static int hf_h264_rbsp_stop_bit = -1;
58 static int hf_h264_rbsp_trailing_bits = -1;
59 static int hf_h264_constraint_set0_flag = -1;
60 static int hf_h264_constraint_set1_flag = -1;
61 static int hf_h264_constraint_set2_flag = -1;
62 static int hf_h264_constraint_set3_flag = -1;
63 static int hf_h264_reserved_zero_4bits = -1;
64 static int hf_h264_level_idc = -1;
65 static int hf_h264_nal_unit = -1;
66 static int hf_h264_forbidden_zero_bit = -1;
67 static int hf_h264_nal_ref_idc = -1;
68 static int hf_h264_nal_unit_type = -1;
69 static int hf_h264_seq_parameter_set_id = -1;
70 static int hf_h264_chroma_format_idc = -1;
71 static int hf_h264_residual_colour_transform_flag = -1;
72 static int hf_h264_bit_depth_luma_minus8 = -1;
73 static int hf_h264_bit_depth_chroma_minus8 = -1;
74 static int hf_h264_qpprime_y_zero_transform_bypass_flag = -1;
75 static int hf_h264_seq_scaling_matrix_present_flag = -1;
76 static int hf_h264_log2_max_frame_num_minus4 = -1;
77 static int hf_h264_pic_order_cnt_type = -1;
78 static int hf_h264_log2_max_pic_order_cnt_lsb_minus4 = -1;
79 static int hf_h264_delta_pic_order_always_zero_flag = -1;
80 static int hf_h264_offset_for_non_ref_pic = -1;
81 static int hf_h264_offset_for_top_to_bottom_field = -1;
82 static int hf_h264_num_ref_frames_in_pic_order_cnt_cycle = -1;
83 static int hf_h264_offset_for_ref_frame = -1;
84 static int hf_h264_num_ref_frames = -1;
85 static int hf_h264_gaps_in_frame_num_value_allowed_flag = -1;
86 static int hf_h264_pic_width_in_mbs_minus1 = -1;
87 static int hf_h264_pic_height_in_map_units_minus1 = -1;
88 static int hf_h264_frame_mbs_only_flag = -1;
89 static int hf_h264_mb_adaptive_frame_field_flag = -1;
90 static int hf_h264_direct_8x8_inference_flag = -1;
91 static int hf_h264_frame_cropping_flag = -1;
92 static int hf_h264_frame_crop_left_offset = -1;
93 static int hf_h264_frame_crop_right_offset = -1;
94 static int hf_h264_frame_crop_top_offset = -1;
95 static int hf_h264_frame_crop_bottom_offset = -1;
96 static int hf_h264_vui_parameters_present_flag = -1;
97 static int hf_h264_pic_parameter_set_id = -1;
98 static int hf_h264_entropy_coding_mode_flag = -1;
99 static int hf_h264_pic_order_present_flag = -1;
100 static int hf_h264_num_slice_groups_minus1 = -1;
101 static int hf_h264_slice_group_map_type = -1;
102 static int hf_h264_num_ref_idx_l0_active_minus1 = -1;
103 static int hf_h264_num_ref_idx_l1_active_minus1 = -1;
104 static int hf_h264_weighted_pred_flag = -1;
105 static int hf_h264_weighted_bipred_idc = -1;
106 static int hf_h264_pic_init_qp_minus26 = -1;
107 static int hf_h264_pic_init_qs_minus26 = -1;
108 static int hf_h264_chroma_qp_index_offset = -1;
109 static int hf_h264_deblocking_filter_control_present_flag = -1;
110 static int hf_h264_constrained_intra_pred_flag = -1;
111 static int hf_h264_redundant_pic_cnt_present_flag = -1;
112 static int hf_h264_transform_8x8_mode_flag = -1;
113 static int hf_h264_pic_scaling_matrix_present_flag = -1;
114 static int hf_h264_second_chroma_qp_index_offset = -1;
115 static int hf_h264_par_profile = -1;
116 static int hf_h264_par_profile_b = -1;
117 static int hf_h264_par_profile_m = -1;
118 static int hf_h264_par_profile_e = -1;
119 static int hf_h264_par_profile_h = -1;
120 static int hf_h264_par_profile_h10 = -1;
121 static int hf_h264_par_profile_h4_2_2 = -1;
122 static int hf_h264_par_profile_h4_4_4 = -1;
123 static int hf_h264_par_add_mode_sup = -1;
124 static int hf_h264_par_AdditionalModesSupported = -1;
125 static int hf_h264_par_add_mode_sup_rcdo = -1;
126 static int hf_h264_par_ProfileIOP = -1;
127 static int hf_h264_par_constraint_set0_flag = -1;
128 static int hf_h264_par_constraint_set1_flag = -1;
129 static int hf_h264_par_constraint_set2_flag = -1;
132 static int hf_h264_aspect_ratio_info_present_flag = -1;
133 static int hf_h264_aspect_ratio_idc = -1;
134 static int hf_h264_sar_width = -1;
135 static int hf_h264_sar_height = -1;
136 static int hf_h264_overscan_info_present_flag = -1;
137 static int hf_h264_overscan_appropriate_flag = -1;
138 static int hf_h264_video_signal_type_present_flag = -1;
139 static int hf_h264_video_format = -1;
140 static int hf_h264_video_full_range_flag = -1;
141 static int hf_h264_colour_description_present_flag = -1;
142 static int hf_h264_colour_primaries = -1;
143 static int hf_h264_transfer_characteristics = -1;
144 static int hf_h264_matrix_coefficients = -1;
145 static int hf_h264_chroma_loc_info_present_flag = -1;
146 static int hf_h264_chroma_sample_loc_type_top_field = -1;
147 static int hf_h264_chroma_sample_loc_type_bottom_field = -1;
148 static int hf_h264_timing_info_present_flag = -1;
149 static int hf_h264_num_units_in_tick = -1;
150 static int hf_h264_time_scale = -1;
151 static int hf_h264_fixed_frame_rate_flag = -1;
152 static int hf_h264_nal_hrd_parameters_present_flag = -1;
153 static int hf_h264_vcl_hrd_parameters_present_flag = -1;
154 static int hf_h264_low_delay_hrd_flag = -1;
155 static int hf_h264_pic_struct_present_flag = -1;
156 static int hf_h264_bitstream_restriction_flag = -1;
157 static int hf_h264_motion_vectors_over_pic_boundaries_flag = -1;
158 static int hf_h264_max_bytes_per_pic_denom = -1;
159 static int hf_h264_max_bits_per_mb_denom = -1;
160 static int hf_h264_log2_max_mv_length_horizontal = -1;
161 static int hf_h264_log2_max_mv_length_vertical = -1;
162 static int hf_h264_num_reorder_frames = -1;
163 static int hf_h264_max_dec_frame_buffering = -1;
164 static int hf_h264_cpb_cnt_minus1 = -1;
165 static int hf_h264_bit_rate_scale = -1;
166 static int hf_h264_cpb_size_scale = -1;
167 static int hf_h264_bit_rate_value_minus1 = -1;
168 static int hf_h264_cpb_size_value_minus1 = -1;
169 static int hf_h264_cbr_flag = -1;
170 static int hf_h264_initial_cpb_removal_delay_length_minus1 = -1;
171 static int hf_h264_cpb_removal_delay_length_minus1 = -1;
172 static int hf_h264_dpb_output_delay_length_minus11 = -1;
173 static int hf_h264_time_offset_length = -1;
175 static int hf_h264_first_mb_in_slice = -1;
176 static int hf_h264_slice_type = -1;
177 static int hf_h264_slice_id = -1;
178 static int hf_h264_payloadsize = -1;
179 static int hf_h264_payloadtype = -1;
180 static int hf_h264_frame_num = -1;
182 /* Initialize the subtree pointers */
183 static int ett_h264 = -1;
184 static int ett_h264_profile = -1;
185 static int ett_h264_nal = -1;
186 static int ett_h264_fua = -1;
187 static int ett_h264_stream = -1;
188 static int ett_h264_nal_unit = -1;
189 static int ett_h264_par_profile = -1;
190 static int ett_h264_par_AdditionalModesSupported = -1;
191 static int ett_h264_par_ProfileIOP = -1;
193 /* The dynamic payload type which will be dissected as H.264 */
195 static guint temp_dynamic_payload_type = 0;
197 /* syntax tables in subclause 7.3 is equal to
198 * ue(v), me(v), se(v), or te(v).
205 } h264_golomb_descriptors;
208 static const true_false_string h264_f_bit_vals = {
209 "Bit errors or other syntax violations",
210 "No bit errors or other syntax violations"
212 static const true_false_string h264_start_bit_vals = {
213 "the first packet of FU-A picture",
214 "Not the first packet of FU-A picture"
216 static const true_false_string h264_end_bit_vals = {
217 "the last packet of FU-A picture",
218 "Not the last packet of FU-A picture"
220 static const true_false_string h264_forbidden_bit_vals = {
221 "Forbidden Bit of FU-A",
222 "Not Forbidden Bit of FU-A"
225 #define H264_SEQ_PAR_SET 7
226 #define H264_PIC_PAR_SET 8
228 static const value_string h264_type_values[] = {
230 { 1, "NAL unit - Coded slice of a non-IDR picture" }, /* Single NAL unit packet per H.264 */
231 { 2, "NAL unit - Coded slice data partition A" },
232 { 3, "NAL unit - Coded slice data partition B" },
233 { 4, "NAL unit - Coded slice data partition C" },
234 { 5, "NAL unit - Coded slice of an IDR picture" },
235 { 6, "NAL unit - Supplemental enhancement information (SEI)" },
236 { H264_SEQ_PAR_SET, "NAL unit - Sequence parameter set" }, /* 7 */
237 { H264_PIC_PAR_SET, "NAL unit - Picture parameter set" }, /* 8 */
238 { 9, "NAL unit - Access unit delimiter" },
239 { 10, "NAL unit - End of sequence" },
240 { 11, "NAL unit - End of stream" },
241 { 12, "NAL unit - Filler data" },
242 { 13, "NAL unit - Sequence parameter set extension" },
243 { 14, "NAL unit - Reserved" },
244 { 15, "NAL unit - Reserved" },
245 { 16, "NAL unit - Reserved" },
246 { 17, "NAL unit - Reserved" },
247 { 18, "NAL unit - Reserved" },
248 { 19, "NAL unit - Coded slice of an auxiliary coded picture without partitioning" },
249 { 20, "NAL unit - Reserved" },
250 { 21, "NAL unit - Reserved" },
251 { 22, "NAL unit - Reserved" },
252 { 23, "NAL unit - Reserved" },
253 { 24, "STAP-A" }, /* Single-time aggregation packet */
254 { 25, "STAP-B" }, /* Single-time aggregation packet */
255 { 26, "MTAP16" }, /* Multi-time aggregation packet */
256 { 27, "MTAP24" }, /* Multi-time aggregation packet */
257 { 28, "FU-A" }, /* Fragmentation unit */
258 { 29, "FU-B" }, /* Fragmentation unit */
265 static const value_string h264_profile_idc_values[] = {
266 { 66, "Baseline profile" },
267 { 77, "Main profile" },
268 { 88, "Extended profile" },
269 { 100, "High profile" },
270 { 110, "High 10 profile" },
271 { 122, "High 4:2:2 profile" },
272 { 144, "High 4:4:4 profile" },
276 static const value_string h264_level_bitrate_values[] = {
295 static const value_string h264_nal_unit_type_vals[] = {
296 { 0, "Unspecified" },
297 { 1, "Coded slice of a non-IDR picture" },
298 { 2, "Coded slice data partition A" },
299 { 3, "Coded slice data partition B" },
300 { 4, "Coded slice data partition C" },
301 { 5, "Coded slice of an IDR picture" },
302 { 6, "Supplemental enhancement information (SEI)" },
303 { 7, "Sequence parameter set" },
304 { 8, "Picture parameter set" },
305 { 9, "Access unit delimiter" },
306 { 10, "End of sequence" },
307 { 11, "End of stream" },
308 { 12, "Filler data" },
309 { 13, "Sequence parameter set extension" },
315 { 19, "Coded slice of an auxiliary coded picture without partitioning" },
320 { 24, "Unspecified" },
321 { 25, "Unspecified" },
322 { 26, "Unspecified" },
323 { 27, "Unspecified" },
325 { 29, "Unspecified" },
326 { 30, "Unspecified" },
327 { 31, "Unspecified" },
331 static const value_string h264_slice_group_map_type_vals[] = {
332 { 0, "Interleaved slice groups" },
333 { 1, "Dispersed slice group mapping" },
334 { 2, "One or more foreground slice groups and a leftover slice group" },
335 { 3, "Changing slice groups" },
336 { 4, "Changing slice groups" },
337 { 5, "Changing slice groups" },
338 { 6, "Explicit assignment of a slice group to each slice group map unit" },
342 /* Table 7-6 Name association to slice_type */
343 static const value_string h264_slice_type_vals[] = {
344 { 0, "P (P slice)" },
345 { 1, "B (B slice)" },
346 { 2, "I (I slice)" },
347 { 3, "SP (SP slice)" },
348 { 4, "SI (SI slice)" },
349 { 5, "P (P slice)" },
350 { 6, "B (B slice)" },
351 { 7, "I (I slice)" },
352 { 8, "SP (SP slice)" },
353 { 9, "SI (SI slice)" },
356 /* byte_aligned( ) is specified as follows.
357 * - If the current position in the bitstream is on a byte boundary, i.e.,
358 * the next bit in the bitstream is the first bit in a byte,
359 * the return value of byte_aligned( ) is equal to TRUE.
360 * - Otherwise, the return value of byte_aligned( ) is equal to FALSE.
363 h264_byte_aligned(int bit_offset)
370 /* Expect a tvb and a bit offset into the tvb
371 * returns the valu and bit_offset
373 #define cVALS(x) (const value_string*)(x)
376 dissect_h264_exp_golomb_code(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint *start_bit_offset, h264_golomb_descriptors descriptor)
377 /*(tvbuff_t *tvb, gint *start_bit_offset) */
379 gint leading_zero_bits, bit_offset, start_offset;
380 guint32 codenum, mask, value, tmp;
386 header_field_info *hf_field = NULL;
388 start_offset = *start_bit_offset>>3;
391 hf_field = proto_registrar_get_nth(hf_index);
393 bit_offset = *start_bit_offset;
395 /* prepare the string */
398 for(bit=0;bit<((int)(bit_offset&0x07));bit++){
400 g_strlcat(str, " ", 256);
402 g_strlcat(str,".", 256);
406 leading_zero_bits = -1;
407 for( b = 0; !b; leading_zero_bits++ ){
409 g_strlcat(str, " ", 256);
412 g_strlcat(str, " ", 256);
414 b = tvb_get_bits8(tvb, bit_offset, 1);
416 g_strlcat(str, "1", 256);
418 g_strlcat(str, "0", 256);
424 if(leading_zero_bits==0){
426 *start_bit_offset = bit_offset;
429 g_strlcat(str, " ", 256);
431 g_strlcat(str,".", 256);
434 g_strlcat(str," = ", 256);
435 g_strlcat(str,hf_field->name, 256);
438 /* if the syntax element is coded as se(v),
439 * the value of the syntax element is derived by invoking the
440 * mapping process for signed Exp-Golomb codes as specified in
441 * subclause 9.1.1 with codeNum as the input.
443 if(hf_field->type==FT_INT32){
444 if (hf_field->strings) {
445 proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
448 val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
451 switch(hf_field->display){
453 proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
459 DISSECTOR_ASSERT_NOT_REACHED();
468 if(hf_field->type==FT_UINT32){
469 if (hf_field->strings) {
470 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
473 val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
476 switch(hf_field->display){
478 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
484 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
490 DISSECTOR_ASSERT_NOT_REACHED();
495 /* Only allow guint32 */
496 DISSECTOR_ASSERT_NOT_REACHED();
503 Syntax elements coded as ue(v), me(v), or se(v) are Exp-Golomb-coded. Syntax elements coded as te(v) are truncated
504 Exp-Golomb-coded. The parsing process for these syntax elements begins with reading the bits starting at the current
505 location in the bitstream up to and including the first non-zero bit, and counting the number of leading bits that are
506 equal to 0. This process is specified as follows:
507 leadingZeroBits = -1;
508 for( b = 0; !b; leadingZeroBits++ )
510 The variable codeNum is then assigned as follows:
511 codeNum = 2leadingZeroBits - 1 + read_bits( leadingZeroBits )
512 where the value returned from read_bits( leadingZeroBits ) is interpreted as a binary representation of an unsigned
513 integer with most significant bit written first.
516 codenum = codenum << leading_zero_bits;
518 if (leading_zero_bits > 8)
519 value = tvb_get_bits16(tvb, bit_offset,leading_zero_bits, FALSE);
521 value = tvb_get_bits8(tvb, bit_offset,leading_zero_bits );
522 codenum = (codenum-1) + value;
523 bit_offset = bit_offset + leading_zero_bits;
525 /* read the bits for the int */
526 for(i=0;i<leading_zero_bits;i++){
528 g_strlcat(str, " ", 256);
531 g_strlcat(str, " ", 256);
536 g_strlcat(str, "1", 256);
538 g_strlcat(str, "0", 256);
544 g_strlcat(str, " ", 256);
546 g_strlcat(str,".", 256);
551 /* if the syntax element is coded as se(v),
552 * the value of the syntax element is derived by invoking the
553 * mapping process for signed Exp-Golomb codes as specified in
554 * subclause 9.1.1 with codeNum as the input.
558 se_value = (codenum + 1) >> 1;
559 if (!(se_value & 1)){
560 se_value = - se_value;
568 g_strlcat(str," = ", 256);
569 g_strlcat(str,hf_field->name, 256);
572 g_strlcat(str,"(se(v))", 256);
573 /* if the syntax element is coded as se(v),
574 * the value of the syntax element is derived by invoking the
575 * mapping process for signed Exp-Golomb codes as specified in
576 * subclause 9.1.1 with codeNum as the input.
582 if((hf_field->type==FT_UINT32)&&(descriptor==H264_UE_V)){
583 if (hf_field->strings) {
584 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
587 val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
590 switch(hf_field->display){
592 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
598 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
604 DISSECTOR_ASSERT_NOT_REACHED();
608 }else if((hf_field->type==FT_INT32)&&(descriptor==H264_SE_V)){
609 if (hf_field->strings) {
610 proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
613 val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
616 switch(hf_field->display){
618 proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
624 DISSECTOR_ASSERT_NOT_REACHED();
628 *start_bit_offset = bit_offset;
632 /* Only allow guint32 */
633 DISSECTOR_ASSERT_NOT_REACHED();
637 *start_bit_offset = bit_offset;
642 /* This funktion is adapted to parsing NAL units from SDP data where the
643 * base64 coding may add extra padding
647 more_rbsp_data(proto_tree *tree _U_, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
651 int remaining_length;
655 /* XXX might not be the best way of doing things but:
656 * Serch from the end of the tvb for the first '1' bit
657 * assuming that its's the RTBSP stop bit
660 /* Set offset to the byte we are treating */
661 offset = bit_offset>>3;
662 remaining_length = tvb_length_remaining(tvb,offset);
663 /* If there is more then 2 bytes left there *should* be more data */
664 if(remaining_length>2){
667 /* Start from last bit */
668 last_one_bit = (tvb_length(tvb) << 3);
672 b = tvb_get_bits8(tvb, last_one_bit, 1);
675 if( last_one_bit == bit_offset){
683 dissect_h264_rbsp_trailing_bits(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
685 gint remaining_bits=0;
687 proto_tree_add_bits_item(tree, hf_h264_rbsp_stop_bit, tvb, bit_offset, 1, FALSE);
690 if((bit_offset&0x7)!=0){
691 remaining_bits = 8 - (bit_offset&0x7);
692 proto_tree_add_bits_item(tree, hf_h264_rbsp_trailing_bits, tvb, bit_offset, remaining_bits, FALSE);
695 return bit_offset+remaining_bits;
699 * 7.3.3 Slice header syntax
701 * XXX Just parse a few bytes
704 dissect_h264_slice_header(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
706 /* first_mb_in_slice 2 ue(v) */
707 dissect_h264_exp_golomb_code(tree, hf_h264_first_mb_in_slice, tvb, &bit_offset, H264_UE_V);
709 /* slice_type 2 ue(v) */
710 dissect_h264_exp_golomb_code(tree, hf_h264_slice_type, tvb, &bit_offset, H264_UE_V);
712 /* pic_parameter_set_id 2 ue(v) */
713 dissect_h264_exp_golomb_code(tree, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
715 /* frame_num 2 u(v) */
717 * represented by log2_max_frame_num_minus4 + 4 bits in
719 * proto_tree_add_bits_item(tree, hf_h264_frame_num, tvb, bit_offset, 4, FALSE);
727 /* 7.3.2.1.1 Scaling list syntax
729 * scaling_list( scalingList, sizeOfScalingList, useDefaultScalingMatrixFlag )
733 dissect_h264_scaling_list(proto_tree *tree, tvbuff_t *tvb, gint bit_offset, int hf_index_scalinglist,
734 guint8 sizeOfScalingList, int hf_index_usedefaultscalingmatrixflag)
737 guint8 lastScale = 8;
738 guint8 nextScale = 8:
741 for( j = 0; j < sizeOfScalingList; j++ ) {
742 if( nextScale != 0 ) {
743 / delta_scale 0 | 1 se(v) /
744 delta_scale = dissect_h264_exp_golomb_code(tree, hf_h264_delta_scale, tvb, &bit_offset);
745 nextScale = ( lastScale + delta_scale + 256 ) % 256;
746 useDefaultScalingMatrixFlag = ( j == 0 && nextScale == 0 );
748 scalingList[ j ] = ( nextScale == 0 ) ? lastScale : nextScale
749 lastScale = scalingList[ j ]
753 /* E.1.2 HRD parameters syntax */
755 dissect_h264_hrd_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
757 guint8 cpb_cnt_minus1;
761 /* cpb_cnt_minus1 0 ue(v) */
762 cpb_cnt_minus1 = dissect_h264_exp_golomb_code(tree, hf_h264_cpb_cnt_minus1, tvb, &bit_offset, H264_UE_V);
764 /* bit_rate_scale 0 u(4) */
765 proto_tree_add_bits_item(tree, hf_h264_bit_rate_scale, tvb, bit_offset, 4, FALSE);
766 bit_offset = bit_offset + 4;
768 /* cpb_size_scale 0 u(4) */
769 proto_tree_add_bits_item(tree, hf_h264_cpb_size_scale, tvb, bit_offset, 4, FALSE);
770 bit_offset = bit_offset + 4;
771 /* for( SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++ ) { */
772 for( SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++ ) {
774 /* bit_rate_value_minus1[ SchedSelIdx ] 0 ue(v) */
775 dissect_h264_exp_golomb_code(tree, hf_h264_bit_rate_value_minus1, tvb, &bit_offset, H264_UE_V);
777 /* cpb_size_value_minus1[ SchedSelIdx ] 0 ue(v)*/
778 dissect_h264_exp_golomb_code(tree, hf_h264_cpb_size_value_minus1, tvb, &bit_offset, H264_UE_V);
780 /* cbr_flag[ SchedSelIdx ] 0 u(1) */
781 proto_tree_add_bits_item(tree, hf_h264_cbr_flag, tvb, bit_offset, 1, FALSE);
784 /* initial_cpb_removal_delay_length_minus1 0 u(5) */
785 proto_tree_add_bits_item(tree, hf_h264_initial_cpb_removal_delay_length_minus1, tvb, bit_offset, 5, FALSE);
786 bit_offset = bit_offset + 5;
788 /* cpb_removal_delay_length_minus1 0 u(5) */
789 proto_tree_add_bits_item(tree, hf_h264_cpb_removal_delay_length_minus1, tvb, bit_offset, 5, FALSE);
790 bit_offset = bit_offset + 5;
792 /* dpb_output_delay_length_minus1 0 u(5) */
793 proto_tree_add_bits_item(tree, hf_h264_dpb_output_delay_length_minus11, tvb, bit_offset, 5, FALSE);
794 bit_offset = bit_offset + 5;
796 /* time_offset_length 0 u(5) */
797 proto_tree_add_bits_item(tree, hf_h264_time_offset_length, tvb, bit_offset, 5, FALSE);
798 bit_offset = bit_offset + 5;
803 #define EXTENDED_SAR 255
805 /* E.1.1 VUI parameters syntax */
807 /* Table E-2 - Meaning of video_format */
808 static const value_string h264_video_format_vals[] = {
809 { 22, "reserved_sei_message)" },
815 { 5, "Unspecified video format" },
821 dissect_h264_vui_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint bit_offset)
824 guint8 aspect_ratio_info_present_flag, aspect_ratio_idc, overscan_info_present_flag;
825 guint8 video_signal_type_present_flag, colour_description_present_flag, chroma_loc_info_present_flag;
826 guint8 timing_info_present_flag, nal_hrd_parameters_present_flag, vcl_hrd_parameters_present_flag;
827 guint8 bitstream_restriction_flag;
829 /* vui_parameters( ) {
830 * aspect_ratio_info_present_flag 0 u(1)
832 aspect_ratio_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
833 proto_tree_add_bits_item(tree, hf_h264_aspect_ratio_info_present_flag, tvb, bit_offset, 1, FALSE);
836 if( aspect_ratio_info_present_flag ) {
837 /* aspect_ratio_idc 0 u(8) */
838 aspect_ratio_idc = tvb_get_bits8(tvb, bit_offset, 8);
839 proto_tree_add_bits_item(tree, hf_h264_aspect_ratio_idc, tvb, bit_offset, 8, FALSE);
840 bit_offset = bit_offset + 8;
842 if( aspect_ratio_idc == EXTENDED_SAR ) {
843 /* sar_width 0 u(16) */
844 proto_tree_add_bits_item(tree, hf_h264_sar_width, tvb, bit_offset, 16, FALSE);
845 bit_offset = bit_offset + 16;
847 /* sar_height 0 u(16) */
848 proto_tree_add_bits_item(tree, hf_h264_sar_height, tvb, bit_offset, 16, FALSE);
849 bit_offset = bit_offset + 16;
852 /* overscan_info_present_flag 0 u(1) */
853 overscan_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
854 proto_tree_add_bits_item(tree, hf_h264_overscan_info_present_flag, tvb, bit_offset, 1, FALSE);
857 if( overscan_info_present_flag ){
858 /* overscan_appropriate_flag 0 u(1) */
859 proto_tree_add_bits_item(tree, hf_h264_overscan_appropriate_flag, tvb, bit_offset, 1, FALSE);
863 /* video_signal_type_present_flag 0 u(1) */
864 video_signal_type_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
865 proto_tree_add_bits_item(tree, hf_h264_video_signal_type_present_flag, tvb, bit_offset, 1, FALSE);
868 if( video_signal_type_present_flag ) {
869 /* video_format 0 u(3) > */
870 proto_tree_add_bits_item(tree, hf_h264_video_format, tvb, bit_offset, 3, FALSE);
871 bit_offset = bit_offset + 3;
873 /* video_full_range_flag 0 u(1)*/
874 proto_tree_add_bits_item(tree, hf_h264_video_full_range_flag, tvb, bit_offset, 1, FALSE);
877 /* colour_description_present_flag 0 u(1) */
878 colour_description_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
879 proto_tree_add_bits_item(tree, hf_h264_colour_description_present_flag, tvb, bit_offset, 1, FALSE);
882 if( colour_description_present_flag ) {
883 /* colour_primaries 0 u(8) */
884 proto_tree_add_bits_item(tree, hf_h264_colour_primaries, tvb, bit_offset, 8, FALSE);
885 bit_offset = bit_offset + 8;
887 /* transfer_characteristics 0 u(8) */
888 proto_tree_add_bits_item(tree, hf_h264_transfer_characteristics, tvb, bit_offset, 8, FALSE);
889 bit_offset = bit_offset + 8;
891 /* matrix_coefficients 0 u(8)*/
892 proto_tree_add_bits_item(tree, hf_h264_matrix_coefficients, tvb, bit_offset, 8, FALSE);
893 bit_offset = bit_offset + 8;
897 /* chroma_loc_info_present_flag 0 u(1) */
898 chroma_loc_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
899 proto_tree_add_bits_item(tree, hf_h264_chroma_loc_info_present_flag, tvb, bit_offset, 1, FALSE);
902 if( chroma_loc_info_present_flag ) {
903 /* chroma_sample_loc_type_top_field 0 ue(v) */
904 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_sample_loc_type_top_field, tvb, &bit_offset, H264_UE_V);
906 /* chroma_sample_loc_type_bottom_field 0 ue(v) */
907 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_sample_loc_type_bottom_field, tvb, &bit_offset, H264_UE_V);
910 /* timing_info_present_flag 0 u(1) */
911 timing_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
912 proto_tree_add_bits_item(tree, hf_h264_timing_info_present_flag, tvb, bit_offset, 1, FALSE);
915 if( timing_info_present_flag ) {
916 /* num_units_in_tick 0 u(32) */
917 proto_tree_add_bits_item(tree, hf_h264_num_units_in_tick, tvb, bit_offset, 32, FALSE);
918 bit_offset = bit_offset + 32;
920 /* time_scale 0 u(32) */
921 proto_tree_add_bits_item(tree, hf_h264_time_scale, tvb, bit_offset, 32, FALSE);
922 bit_offset = bit_offset + 32;
924 /* fixed_frame_rate_flag 0 u(1) */
925 proto_tree_add_bits_item(tree, hf_h264_fixed_frame_rate_flag, tvb, bit_offset, 1, FALSE);
928 /* nal_hrd_parameters_present_flag 0 u(1) */
929 nal_hrd_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
930 proto_tree_add_bits_item(tree, hf_h264_nal_hrd_parameters_present_flag, tvb, bit_offset, 1, FALSE);
933 if( nal_hrd_parameters_present_flag ){
934 /* hrd_parameters( ) */
935 bit_offset = dissect_h264_hrd_parameters(tree, tvb, pinfo, bit_offset);
938 /* vcl_hrd_parameters_present_flag 0 u(1) */
939 vcl_hrd_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
940 proto_tree_add_bits_item(tree, hf_h264_vcl_hrd_parameters_present_flag, tvb, bit_offset, 1, FALSE);
943 if( vcl_hrd_parameters_present_flag ){
944 /* hrd_parameters( ) */
945 bit_offset = dissect_h264_hrd_parameters(tree, tvb, pinfo, bit_offset);
947 if( nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag ){
948 /* low_delay_hrd_flag 0 u(1) */
949 proto_tree_add_bits_item(tree, hf_h264_low_delay_hrd_flag, tvb, bit_offset, 1, FALSE);
952 /* pic_struct_present_flag 0 u(1) */
953 proto_tree_add_bits_item(tree, hf_h264_pic_struct_present_flag, tvb, bit_offset, 1, FALSE);
956 /* bitstream_restriction_flag 0 u(1) */
957 bitstream_restriction_flag = tvb_get_bits8(tvb, bit_offset, 1);
958 proto_tree_add_bits_item(tree, hf_h264_bitstream_restriction_flag, tvb, bit_offset, 1, FALSE);
961 if( bitstream_restriction_flag ) {
962 /* motion_vectors_over_pic_boundaries_flag 0 u(1) */
963 proto_tree_add_bits_item(tree, hf_h264_motion_vectors_over_pic_boundaries_flag, tvb, bit_offset, 1, FALSE);
966 /* max_bytes_per_pic_denom 0 ue(v) */
967 dissect_h264_exp_golomb_code(tree, hf_h264_max_bytes_per_pic_denom, tvb, &bit_offset, H264_UE_V);
969 /* max_bits_per_mb_denom 0 ue(v) */
970 dissect_h264_exp_golomb_code(tree, hf_h264_max_bits_per_mb_denom, tvb, &bit_offset, H264_UE_V);
972 /* log2_max_mv_length_horizontal 0 ue(v) */
973 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_mv_length_horizontal, tvb, &bit_offset, H264_UE_V);
975 /* log2_max_mv_length_vertical 0 ue(v) */
976 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_mv_length_vertical, tvb, &bit_offset, H264_UE_V);
978 /* num_reorder_frames 0 ue(v) */
979 dissect_h264_exp_golomb_code(tree, hf_h264_num_reorder_frames, tvb, &bit_offset, H264_UE_V);
981 /* max_dec_frame_buffering 0 ue(v) */
982 dissect_h264_exp_golomb_code(tree, hf_h264_max_dec_frame_buffering, tvb, &bit_offset, H264_UE_V);
989 /* Used To dissect SDP parameter (H.264)profile */
991 dissect_h264_profile(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
993 proto_item *item, *level_item;
994 proto_tree *h264_profile_tree;
996 guint8 constraint_set3_flag;
999 item = proto_tree_add_item(tree, hf_h264_profile, tvb, offset, -1, FALSE);
1000 h264_profile_tree = proto_item_add_subtree(item, ett_h264_profile);
1002 proto_tree_add_item(h264_profile_tree, hf_h264_profile_idc, tvb, offset, 1, FALSE);
1005 constraint_set3_flag = (tvb_get_guint8(tvb,offset)&0x10)>>4;
1006 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set0_flag, tvb, offset, 1, FALSE);
1007 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set1_flag, tvb, offset, 1, FALSE);
1008 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set2_flag, tvb, offset, 1, FALSE);
1009 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set3_flag, tvb, offset, 1, FALSE);
1010 proto_tree_add_item(h264_profile_tree, hf_h264_reserved_zero_4bits, tvb, offset, 1, FALSE);
1013 /* A level to which the bitstream conforms shall be indicated by the syntax element level_idc as follows.
1014 * - If level_idc is equal to 11 and constraint_set3_flag is equal to 1, the indicated level is level 1b.
1015 * - Otherwise (level_idc is not equal to 11 or constraint_set3_flag is not equal to 1), level_idc shall
1016 * be set equal to a value of ten times the level number specified in Table A-1 and constraint_set3_flag
1017 * shall be set equal to 0.
1020 level_idc = tvb_get_guint8(tvb,offset);
1021 level_item = proto_tree_add_item(h264_profile_tree, hf_h264_level_idc, tvb, offset, 1, FALSE);
1022 if((level_idc==11)&&(constraint_set3_flag==1)){
1023 proto_item_append_text(level_item," [Level 1b (128kb/s)]");
1025 proto_item_append_text(level_item," [Level %.1f %s]",((double)level_idc/10),val_to_str(level_idc, h264_level_bitrate_values, "Unknown "));
1031 * 7.3.2.8 Slice layer without partitioning RBSP syntax
1032 * slice_layer_without_partitioning_rbsp( )
1036 dissect_h264_slice_layer_without_partitioning_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1040 bit_offset = offset <<3;
1042 /* slice_header( ) 2 */
1043 bit_offset = dissect_h264_slice_header(tree, tvb, pinfo, bit_offset);
1044 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1046 /* slice_data( ) * all categories of slice_data( ) syntax * 2 | 3 | 4 */
1047 /* rbsp_slice_trailing_bits( ) */
1052 * 7.3.2.9.1 Slice data partition A RBSP syntax
1053 * slice_data_partition_a_layer_rbsp( )
1056 dissect_h264_slice_data_partition_a_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1060 bit_offset = offset <<3;
1062 /* slice_header( ) 2 */
1063 bit_offset = dissect_h264_slice_header(tree, tvb, pinfo, bit_offset);
1065 /* slice_id All ue(v) */
1066 dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1067 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1069 /* slice_data( ) * only category 2 parts of slice_data( ) syntax * 2*/
1070 /* rbsp_slice_trailing_bits( )*/
1075 * 7.3.2.9.2 Slice data partition B RBSP syntax
1076 * slice_data_partition_b_layer_rbsp(
1079 dissect_h264_slice_data_partition_b_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1083 bit_offset = offset <<3;
1085 /* slice_id All ue(v) */
1086 dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1087 /* if( redundant_pic_cnt_present_flag ) */
1088 /* redundant_pic_cnt All ue(v) */
1089 /* slice_data( ) * only category 3 parts of slice_data( ) syntax * 3 */
1090 /* rbsp_slice_trailing_bits( ) 3 */
1091 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1096 * 7.3.2.9.3 Slice data partition C RBSP syntax
1097 * slice_data_partition_c_layer_rbsp( )
1100 dissect_h264_slice_data_partition_c_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1104 bit_offset = offset <<3;
1106 /* slice_id All ue(v) */
1107 dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1108 /* if( redundant_pic_cnt_present_flag ) */
1109 /* redundant_pic_cnt All ue(v) */
1110 /* slice_data( ) * only category 4 parts of slice_data( ) syntax * 4 */
1111 /* rbsp_slice_trailing_bits( ) 4 */
1112 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1115 /* D.1.6 User data unregistered SEI message syntax */
1118 h264_user_data_unregistered(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset, guint32 payloadSize)
1120 /* user_data_unregistered( payloadSize ) { C Descriptor */
1121 /* uuid_iso_iec_11578 5 u(128)
1122 * uuid_iso_iec_11578 shall have a value specified as a UUID
1123 * according to the procedures of ISO/IEC 11578:1996 Annex A.
1125 proto_tree_add_text(tree, tvb, bit_offset>>3, 16, "uuid_iso_iec_1157");
1127 /* for( i = 16; i < payloadSize; i++ )
1128 * user_data_payload_byte 5 b(8)
1130 proto_tree_add_text(tree, tvb, bit_offset>>3, payloadSize-16, "user_data_payload");
1131 bit_offset+=(payloadSize-16)<<3;
1135 /* D.1 SEI payload syntax */
1136 static const value_string h264_sei_payload_vals[] = {
1137 { 0, "buffering_period" },
1138 { 1, "pic_timing" },
1139 { 2, "pan_scan_rect" },
1140 { 3, "filler_payload" },
1141 { 4, "user_data_registered_itu_t_t35" },
1142 { 5, "user_data_unregistered" },
1143 { 6, "recovery_point" },
1144 { 7, "dec_ref_pic_marking_repetition" },
1146 { 9, "scene_inf)" },
1147 { 10, "sub_seq_info)" },
1148 { 11, "sub_seq_layer_characteristics" },
1149 { 12, "sub_seq_characteristics" },
1150 { 13, "full_frame_freeze_release" },
1151 { 14, "full_frame_freeze_release" },
1152 { 15, "full_frame_snapshot" },
1153 { 16, "progressive_refinement_segment_start" },
1154 { 17, "progressive_refinement_segment_end" },
1155 { 18, "motion_constrained_slice_group_set" },
1156 { 19, "film_grain_characteristics)" },
1157 { 20, "deblocking_filter_display_preference)" },
1158 { 21, "stereo_video_info)" },
1159 { 22, "reserved_sei_message)" },
1164 h264_sei_payload(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset, guint32 payloadType, guint32 payloadSize)
1166 /* sei_payload( payloadType, payloadSize ) { C Descriptor */
1167 if( payloadType == 0 ){
1168 /* buffering_period( payloadSize ) 5 */
1169 bit_offset = bit_offset +(payloadSize<<3);
1171 }else if( payloadType == 1 ){
1172 /* pic_timing( payloadSize ) 5 */
1173 }else if( payloadType == 2 ){
1174 /* pan_scan_rect( payloadSize ) 5 */
1175 }else if( payloadType == 3 ){
1176 /* filler_payload( payloadSize ) 5 */
1177 }else if( payloadType == 4 ){
1178 /* user_data_registered_itu_t_t35( payloadSize ) 5 */
1180 }else if( payloadType == 5 ){
1181 /* user_data_unregistered( payloadSize ) 5 */
1182 bit_offset = h264_user_data_unregistered( tree, tvb, pinfo, bit_offset, payloadSize);
1183 }else if( payloadType == 6 ){
1184 /* recovery_point( payloadSize ) 5 */
1185 bit_offset = bit_offset +(payloadSize<<3);
1186 }else if( payloadType == 7 ){
1187 /* dec_ref_pic_marking_repetition( payloadSize ) 5 */
1188 bit_offset = bit_offset +(payloadSize<<3);
1191 else if( payloadType == 8 )
1192 spare_pic( payloadSize ) 5
1193 else if( payloadType == 9 )
1194 scene_info( payloadSize ) 5
1195 else if( payloadType == 10 )
1196 sub_seq_info( payloadSize ) 5
1197 else if( payloadType == 11 )
1198 sub_seq_layer_characteristics( payloadSize ) 5
1199 else if( payloadType == 12 )
1200 sub_seq_characteristics( payloadSize ) 5
1201 else if( payloadType == 13 )
1202 full_frame_freeze( payloadSize ) 5
1203 else if( payloadType == 14 )
1204 full_frame_freeze_release( payloadSize ) 5
1205 else if( payloadType == 15 )
1206 full_frame_snapshot( payloadSize ) 5
1207 else if( payloadType == 16 )
1208 progressive_refinement_segment_start( payloadSize ) 5
1209 else if( payloadType == 17 )
1210 progressive_refinement_segment_end( payloadSize ) 5
1211 else if( payloadType == 18 )
1212 motion_constrained_slice_group_set( payloadSize ) 5
1213 else if( payloadType == 19 )
1214 film_grain_characteristics( payloadSize ) 5
1215 else if( payloadType == 20 )
1216 deblocking_filter_display_preference( payloadSize ) 5
1217 else if( payloadType == 21 )
1218 stereo_video_info( payloadSize ) 5
1220 reserved_sei_message( payloadSize ) 5
1223 if( !h264_byte_aligned(bit_offset)){
1224 /* bit_equal_to_one / * equal to 1 * / 5 f(1) */
1225 /* TODO:Display the filler and, error if not 1 ?? */
1227 while( !h264_byte_aligned(bit_offset)){
1228 /* bit_equal_to_zero / * equal to 0 * / 5 f(1) */
1229 /* TODO:Display the filler and, error if not 0 ?? */
1237 * 7.3.2.3.1 Supplemental enhancement information message syntax
1240 dissect_h264_sei_message(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint bit_offset)
1242 /* sei_message( ) { C Descriptor */
1243 guint32 payloadType = 0, payloadSize;
1244 gint start_bit_offset, length;
1246 start_bit_offset = bit_offset;
1248 /* while( next_bits( 8 ) == 0xFF ) { */
1249 while( tvb_get_bits8(tvb, bit_offset, 8) == 0xFF ) {
1250 /* ff_byte / * equal to 0xFF * / 5 f(8) */
1254 /* last_payload_type_byte 5 u(8) */
1255 payloadType += tvb_get_bits8(tvb, bit_offset, 8);
1257 length = (bit_offset - start_bit_offset)>>3;
1259 proto_tree_add_uint(tree, hf_h264_payloadtype, tvb, start_bit_offset>>3, length, payloadType);
1262 start_bit_offset = bit_offset;
1263 /* while( next_bits( 8 ) == 0xFF ) { */
1264 while( tvb_get_bits8(tvb, bit_offset, 8) == 0xFF ) {
1265 /* ff_byte / * equal to 0xFF * / 5 f(8) */
1269 /* last_payload_size_byte 5 u(8) */
1270 /* payloadSize += last_payload_size_byte */
1271 payloadSize += tvb_get_bits8(tvb, bit_offset, 8);
1273 length = (bit_offset - start_bit_offset)>>3;
1274 proto_tree_add_uint(tree, hf_h264_payloadsize, tvb, start_bit_offset>>3, length, payloadSize);
1276 /*sei_payload( payloadType, payloadSize ) 5 */
1277 bit_offset = h264_sei_payload( tree, tvb, pinfo, bit_offset, payloadType, payloadSize);
1281 * 7.3.2.3 Supplemental enhancement information RBSP syntax
1285 dissect_h264_sei_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1289 bit_offset = offset <<3;
1291 /* sei_message( ) 5*/
1292 bit_offset = dissect_h264_sei_message( tree, tvb, pinfo, bit_offset);
1294 /* while( more_rbsp_data( ) )
1295 * If there is more data in an RBSP before rbsp_trailing_bits( ),
1296 * the return value of more_rbsp_data( ) is equal to TRUE.
1298 /* rbsp_trailing_bits( ) 5 */
1299 bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1303 /* Ref 7.3.2.1 Sequence parameter set RBSP syntax */
1305 dissect_h264_seq_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1307 proto_item *level_item;
1309 guint8 constraint_set3_flag;
1313 guint8 profile_idc, chroma_format_idc, frame_mbs_only_flag, frame_cropping_flag;
1314 guint8 pic_order_cnt_type, vui_parameters_present_flag, num_ref_frames_in_pic_order_cnt_cycle;
1315 guint8 seq_scaling_matrix_present_flag; /* seq_scaling_list_present_flag */
1317 /* profile_idc 0 u(8) */
1318 profile_idc = tvb_get_guint8(tvb,offset);
1319 proto_tree_add_item(tree, hf_h264_profile_idc, tvb, offset, 1, FALSE);
1322 constraint_set3_flag = (tvb_get_guint8(tvb,offset)&0x10)>>4;
1323 /* constraint_set0_flag 0 u(1) */
1324 proto_tree_add_item(tree, hf_h264_constraint_set0_flag, tvb, offset, 1, FALSE);
1326 /* constraint_set1_flag 0 u(1) */
1327 proto_tree_add_item(tree, hf_h264_constraint_set1_flag, tvb, offset, 1, FALSE);
1329 /* constraint_set2_flag 0 u(1) */
1330 proto_tree_add_item(tree, hf_h264_constraint_set2_flag, tvb, offset, 1, FALSE);
1332 /* constraint_set3_flag 0 u(1) */
1333 proto_tree_add_item(tree, hf_h264_constraint_set3_flag, tvb, offset, 1, FALSE);
1335 /* reserved_zero_4bits equal to 0 0 u(4)*/
1336 proto_tree_add_item(tree, hf_h264_reserved_zero_4bits, tvb, offset, 1, FALSE);
1339 /* level_idc 0 u(8) */
1340 level_idc = tvb_get_guint8(tvb,offset);
1341 level_item = proto_tree_add_item(tree, hf_h264_level_idc, tvb, offset, 1, FALSE);
1342 if((level_idc==11)&&(constraint_set3_flag==1)){
1343 proto_item_append_text(level_item,"[Level 1b]");
1345 proto_item_append_text(level_item," [Level %.1f %s]",((double)level_idc/10),val_to_str(level_idc, h264_level_bitrate_values, "Unknown "));
1348 /* seq_parameter_set_id 0 ue(v)
1349 * ue(v): unsigned integer Exp-Golomb-coded syntax element with the left bit first.
1350 * The parsing process for this descriptor is specified in subclause 9.1.
1352 bit_offset = offset<<3;
1353 dissect_h264_exp_golomb_code(tree, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1356 if( profile_idc == 100 || profile_idc == 110 ||
1357 profile_idc == 122 || profile_idc == 144 ) {
1359 /* chroma_format_idc 0 ue(v) */
1360 chroma_format_idc = dissect_h264_exp_golomb_code(tree, hf_h264_chroma_format_idc, tvb, &bit_offset, H264_UE_V);
1361 if( chroma_format_idc == 3 ){
1362 /* residual_colour_transform_flag 0 u(1) */
1363 proto_tree_add_bits_item(tree, hf_h264_residual_colour_transform_flag, tvb, bit_offset, 1, FALSE);
1367 /* bit_depth_luma_minus8 0 ue(v) */
1368 dissect_h264_exp_golomb_code(tree, hf_h264_bit_depth_luma_minus8, tvb, &bit_offset, H264_UE_V);
1370 /* bit_depth_chroma_minus8 0 ue(v) */
1371 dissect_h264_exp_golomb_code(tree, hf_h264_bit_depth_chroma_minus8, tvb, &bit_offset, H264_UE_V);
1373 /* qpprime_y_zero_transform_bypass_flag 0 u(1) */
1374 proto_tree_add_bits_item(tree, hf_h264_qpprime_y_zero_transform_bypass_flag, tvb, bit_offset, 1, FALSE);
1377 /* seq_scaling_matrix_present_flag 0 u(1) */
1378 seq_scaling_matrix_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1379 proto_tree_add_bits_item(tree, hf_h264_seq_scaling_matrix_present_flag, tvb, bit_offset, 1, FALSE);
1382 if( seq_scaling_matrix_present_flag ){
1384 for( i = 0; i < 8; i++ ) {
1385 / seq_scaling_list_present_flag[ i ] 0 u(1) /
1386 seq_scaling_list_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1388 if( seq_scaling_list_present_flag){
1390 scaling_list( ScalingList4x4[ i ], 16,UseDefaultScalingMatrix4x4Flag[ i ])0
1391 dissect_h264_scaling_list()
1393 scaling_list( ScalingList8x8[ i - 6 ], 64,UseDefaultScalingMatrix8x8Flag[ i - 6 ] )0
1397 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1403 /* log2_max_frame_num_minus4 0 ue(v) */
1404 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_frame_num_minus4, tvb, &bit_offset, H264_UE_V);
1406 /* pic_order_cnt_type 0 ue(v) */
1407 offset = bit_offset>>3;
1408 pic_order_cnt_type = dissect_h264_exp_golomb_code(tree,hf_h264_pic_order_cnt_type, tvb, &bit_offset, H264_UE_V);
1410 if(pic_order_cnt_type == 0){
1411 /* log2_max_pic_order_cnt_lsb_minus4 0 ue(v) */
1412 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_pic_order_cnt_lsb_minus4, tvb, &bit_offset, H264_UE_V);
1413 }else if(pic_order_cnt_type == 1) {
1414 /* delta_pic_order_always_zero_flag 0 u(1) */
1415 proto_tree_add_bits_item(tree, hf_h264_delta_pic_order_always_zero_flag, tvb, bit_offset, 1, FALSE);
1418 /* offset_for_non_ref_pic 0 se(v) */
1419 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_non_ref_pic, tvb, &bit_offset, H264_SE_V);
1421 /* offset_for_top_to_bottom_field 0 se(v) */
1422 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_top_to_bottom_field, tvb, &bit_offset, H264_SE_V);
1424 /* num_ref_frames_in_pic_order_cnt_cycle 0 ue(v) */
1425 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);
1426 for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ ){
1427 /*offset_for_ref_frame[ i ] 0 se(v)*/
1428 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_ref_frame, tvb, &bit_offset, H264_SE_V);
1431 /* num_ref_frames 0 ue(v) */
1432 dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_frames, tvb, &bit_offset, H264_UE_V);
1434 /* gaps_in_frame_num_value_allowed_flag 0 u(1) */
1435 proto_tree_add_bits_item(tree, hf_h264_gaps_in_frame_num_value_allowed_flag, tvb, bit_offset, 1, FALSE);
1438 /* pic_width_in_mbs_minus1 0 ue(v) */
1439 dissect_h264_exp_golomb_code(tree, hf_h264_pic_width_in_mbs_minus1, tvb, &bit_offset, H264_UE_V);
1441 /* pic_height_in_map_units_minus1 0 ue(v) */
1442 dissect_h264_exp_golomb_code(tree, hf_h264_pic_height_in_map_units_minus1, tvb, &bit_offset, H264_UE_V);
1444 /* frame_mbs_only_flag 0 u(1) */
1445 frame_mbs_only_flag = tvb_get_bits8(tvb, bit_offset, 1);
1446 proto_tree_add_bits_item(tree, hf_h264_frame_mbs_only_flag, tvb, bit_offset, 1, FALSE);
1448 if( !frame_mbs_only_flag ){
1449 /* mb_adaptive_frame_field_flag 0 u(1) */
1450 proto_tree_add_bits_item(tree, hf_h264_mb_adaptive_frame_field_flag, tvb, bit_offset, 1, FALSE);
1454 /* direct_8x8_inference_flag 0 u(1) */
1455 proto_tree_add_bits_item(tree, hf_h264_direct_8x8_inference_flag, tvb, bit_offset, 1, FALSE);
1458 /* frame_cropping_flag 0 u(1) */
1459 frame_cropping_flag = tvb_get_bits8(tvb, bit_offset, 1);
1460 proto_tree_add_bits_item(tree, hf_h264_frame_cropping_flag, tvb, bit_offset, 1, FALSE);
1463 if(frame_cropping_flag) {
1464 /* frame_crop_left_offset 0 ue(v) */
1465 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_left_offset, tvb, &bit_offset, H264_UE_V);
1466 dissect_h264_exp_golomb_code(tree,hf_h264_frame_crop_right_offset, tvb, &bit_offset, H264_UE_V);
1467 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_top_offset, tvb, &bit_offset, H264_UE_V);
1468 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_bottom_offset, tvb, &bit_offset, H264_UE_V);
1472 /* vui_parameters_present_flag 0 u(1) */
1473 vui_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1474 proto_tree_add_bits_item(tree, hf_h264_vui_parameters_present_flag, tvb, bit_offset, 1, FALSE);
1476 if(vui_parameters_present_flag){
1477 bit_offset = dissect_h264_vui_parameters(tree, tvb, pinfo, bit_offset);
1480 /* rbsp_trailing_bits( ) 0 */
1481 bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1483 offset = bit_offset>>3;
1488 /* 7.3.2.2 Picture parameter set RBSP syntax */
1491 dissect_h264_pic_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1495 guint32 num_slice_groups_minus1, slice_group_map_type, pic_scaling_matrix_present_flag;
1497 bit_offset = offset<<3;
1499 /* pic_parameter_set_id 1 ue(v) */
1500 dissect_h264_exp_golomb_code(tree, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1502 /* seq_parameter_set_id 1 ue(v) */
1503 dissect_h264_exp_golomb_code(tree, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1505 /* entropy_coding_mode_flag 1 u(1) */
1506 proto_tree_add_bits_item(tree, hf_h264_entropy_coding_mode_flag, tvb, bit_offset, 1, FALSE);
1509 /* pic_order_present_flag 1 u(1)*/
1510 proto_tree_add_bits_item(tree, hf_h264_pic_order_present_flag, tvb, bit_offset, 1, FALSE);
1513 /* num_slice_groups_minus1 1 ue(v)*/
1514 num_slice_groups_minus1 = dissect_h264_exp_golomb_code(tree, hf_h264_num_slice_groups_minus1, tvb, &bit_offset, H264_UE_V);
1515 if( num_slice_groups_minus1 > 0 ) {
1516 /* slice_group_map_type 1 ue(v)*/
1517 slice_group_map_type = dissect_h264_exp_golomb_code(tree, hf_h264_slice_group_map_type, tvb, &bit_offset, H264_UE_V);
1518 /* if( slice_group_map_type == 0 )*/
1519 /* for( iGroup = 0; iGroup <= num_slice_groups_minus1; iGroup++ )*/
1520 /* run_length_minus1[ iGroup ] 1 ue(v)*/
1521 /* else if( slice_group_map_type == 2 )*/
1522 /* for( iGroup = 0; iGroup < num_slice_groups_minus1; iGroup++ ) {*/
1523 /* top_left[ iGroup ] 1 ue(v)*/
1524 /* bottom_right[ iGroup ] 1 ue(v)*/
1526 /* else if( slice_group_map_type == 3 ||*/
1527 /* slice_group_map_type == 4 ||*/
1528 /* slice_group_map_type == 5 ) {*/
1529 /* slice_group_change_direction_flag 1 u(1)*/
1530 /* slice_group_change_rate_minus1 1 ue(v)*/
1531 /* } else if( slice_group_map_type == 6 ) {*/
1532 /* pic_size_in_map_units_minus1 1 ue(v)*/
1533 /* for( i = 0; i <= pic_size_in_map_units_minus1; i++ )*/
1534 /* slice_group_id[ i ] 1 u(v)*/
1537 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1540 /* num_ref_idx_l0_active_minus1 1 ue(v)*/
1541 dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_idx_l0_active_minus1, tvb, &bit_offset, H264_UE_V);
1543 /* num_ref_idx_l1_active_minus1 1 ue(v)*/
1544 dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_idx_l1_active_minus1, tvb, &bit_offset, H264_UE_V);
1546 /* weighted_pred_flag 1 u(1)*/
1547 proto_tree_add_bits_item(tree, hf_h264_weighted_pred_flag, tvb, bit_offset, 1, FALSE);
1550 /* weighted_bipred_idc 1 u(2)*/
1551 proto_tree_add_bits_item(tree, hf_h264_weighted_bipred_idc, tvb, bit_offset, 2, FALSE);
1552 bit_offset= bit_offset+2;
1554 /* pic_init_qp_minus26 * relative to 26 * 1 se(v)*/
1555 dissect_h264_exp_golomb_code(tree, hf_h264_pic_init_qp_minus26, tvb, &bit_offset, H264_SE_V);
1557 /* pic_init_qs_minus26 * relative to 26 * 1 se(v)*/
1558 dissect_h264_exp_golomb_code(tree, hf_h264_pic_init_qs_minus26, tvb, &bit_offset, H264_SE_V);
1560 /* chroma_qp_index_offset 1 se(v)*/
1561 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
1563 /* deblocking_filter_control_present_flag 1 u(1)*/
1564 proto_tree_add_bits_item(tree, hf_h264_deblocking_filter_control_present_flag, tvb, bit_offset, 1, FALSE);
1567 /* constrained_intra_pred_flag 1 u(1)*/
1568 proto_tree_add_bits_item(tree, hf_h264_constrained_intra_pred_flag, tvb, bit_offset, 1, FALSE);
1571 /* redundant_pic_cnt_present_flag 1 u(1)*/
1572 proto_tree_add_bits_item(tree, hf_h264_redundant_pic_cnt_present_flag, tvb, bit_offset, 1, FALSE);
1575 if( more_rbsp_data(tree, tvb, pinfo, bit_offset)){
1576 /* transform_8x8_mode_flag 1 u(1)*/
1577 proto_tree_add_bits_item(tree, hf_h264_transform_8x8_mode_flag, tvb, bit_offset, 1, FALSE);
1580 /* pic_scaling_matrix_present_flag 1 u(1)*/
1581 pic_scaling_matrix_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1582 proto_tree_add_bits_item(tree, hf_h264_pic_scaling_matrix_present_flag, tvb, bit_offset, 1, FALSE);
1585 if( pic_scaling_matrix_present_flag ){
1586 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1588 /* for( i = 0; i < 6 + 2* transform_8x8_mode_flag; i++ ) {*/
1589 /* pic_scaling_list_present_flag[ i ] 1 u(1)*/
1590 /* if( pic_scaling_list_present_flag[ i ] )*/
1592 /* scaling_list( ScalingList4x4[ i ], 16, UseDefaultScalingMatrix4x4Flag[ i ] )*/
1594 /* scaling_list( ScalingList8x8[ i - 6 ], 64, UseDefaultScalingMatrix8x8Flag[ i - 6 ] )*/
1598 /* second_chroma_qp_index_offset 1 se(v)*/
1599 dissect_h264_exp_golomb_code(tree, hf_h264_second_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
1601 bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1606 * 7.3.2.4 Access unit delimiter RBSP syntax
1607 * access_unit_delimiter_rbsp( )
1610 dissect_h264_access_unit_delimiter_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1612 /* primary_pic_type 6 u(3) */
1613 /* rbsp_trailing_bits( ) 6 */
1614 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1619 * 7.3.2.5 End of sequence RBSP syntax
1620 * end_of_seq_rbsp( ) {}
1623 dissect_h264_end_of_seq_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1625 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1630 * 7.3.2.6 End of stream RBSP syntax
1631 * end_of_stream_rbsp( ) {}
1634 dissect_h264_end_of_stream_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1636 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1641 * 7.3.2.7 Filler data RBSP syntax
1642 * filler_data_rbsp( )
1645 dissect_h264_filler_data_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1647 /* while( next_bits( 8 ) == 0xFF ) */
1648 /* ff_byte * equal to 0xFF * 9 f(8) */
1649 /* rbsp_trailing_bits( ) 9 */
1650 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1655 * 7.3.2.1.2 Sequence parameter set extension RBSP syntax
1656 * seq_parameter_set_extension_rbsp( )
1659 dissect_h264_seq_parameter_set_extension_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1661 /* seq_parameter_set_id 10 ue(v) */
1662 /* aux_format_idc 10 ue(v) */
1663 /* if( aux_format_idc != 0 ) { */
1664 /* bit_depth_aux_minus8 10 ue(v) */
1665 /* alpha_incr_flag 10 u(1) */
1666 /* alpha_opaque_value 10 u(v) */
1667 /* alpha_transparent_value 10 u(v) */
1669 /* additional_extension_flag 10 u(1) */
1670 /* rbsp_trailing_bits() 10 */
1671 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1677 * Dissect NAL unit as recived in sprop-parameter-sets of SDP
1678 * or "DecoderConfiguration parameter in H.245
1681 dissect_h264_nal_unit(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1684 proto_tree *h264_nal_tree;
1686 guint8 nal_unit_type;
1688 item = proto_tree_add_item(tree, hf_h264_nal_unit, tvb, offset, -1, FALSE);
1689 h264_nal_tree = proto_item_add_subtree(item, ett_h264_nal_unit);
1692 /* In decoder configuration start code may be pressent
1693 * B.1.1 Byte stream NAL unit syntax
1695 dword = tvb_get_bits32(tvb, offset<<3, 32, FALSE);
1697 /* zero_byte + start_code_prefix_one_3bytes */
1699 }else if((dword >> 8)== 1){
1700 /* start_code_prefix_one_3bytes */
1703 /* Ref: 7.3.1 NAL unit syntax */
1704 nal_unit_type = tvb_get_guint8(tvb,offset) & 0x1f;
1706 /* forbidden_zero_bit All f(1) */
1707 proto_tree_add_item(h264_nal_tree, hf_h264_forbidden_zero_bit, tvb, offset, 1, FALSE);
1708 /* nal_ref_idc All u(2) */
1709 proto_tree_add_item(h264_nal_tree, hf_h264_nal_ref_idc, tvb, offset, 1, FALSE);
1710 /* nal_unit_type All u(5) */
1711 proto_tree_add_item(h264_nal_tree, hf_h264_nal_unit_type, tvb, offset, 1, FALSE);
1714 switch(nal_unit_type){
1715 case 0: /* Unspecified */
1716 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Unspecified NAL unit type");
1718 case 1: /* Coded slice of a non-IDR picture */
1719 dissect_h264_slice_layer_without_partitioning_rbsp(h264_nal_tree, tvb, pinfo, offset);
1721 case 2: /* Coded slice data partition A */
1722 dissect_h264_slice_data_partition_a_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1724 case 3: /* Coded slice data partition B */
1725 dissect_h264_slice_data_partition_b_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1727 case 4: /* Coded slice data partition C */
1728 dissect_h264_slice_data_partition_c_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1730 case 5: /* Coded slice of an IDR picture */
1731 dissect_h264_slice_layer_without_partitioning_rbsp(h264_nal_tree, tvb, pinfo, offset);
1733 case 6: /* Supplemental enhancement information (SEI) */
1734 dissect_h264_sei_rbsp(h264_nal_tree, tvb, pinfo, offset);
1736 case H264_SEQ_PAR_SET: /* 7 Sequence parameter set*/
1737 offset = dissect_h264_seq_parameter_set_rbsp(h264_nal_tree, tvb, pinfo, offset);
1739 if(tvb_length_remaining(tvb,offset) > 0){
1740 /* In this case length = offset as we start from zero */
1741 proto_item_set_len(item, offset/*Length */);
1742 item = proto_tree_add_item(tree, hf_h264_nal_unit, tvb, offset, -1, FALSE);
1743 h264_nal_tree = proto_item_add_subtree(item, ett_h264_nal_unit);
1747 case H264_PIC_PAR_SET: /* 8 Picture parameter set */
1748 dissect_h264_pic_parameter_set_rbsp(h264_nal_tree, tvb, pinfo, offset);
1750 case 9: /* Access unit delimiter */
1751 dissect_h264_access_unit_delimiter_rbsp(h264_nal_tree, tvb, pinfo, offset);
1753 case 10: /* End of sequence */
1754 dissect_h264_end_of_seq_rbsp(h264_nal_tree, tvb, pinfo, offset);
1756 case 11: /* End of stream */
1757 dissect_h264_end_of_stream_rbsp(h264_nal_tree, tvb, pinfo, offset);
1759 case 12: /* Filler data */
1760 dissect_h264_filler_data_rbsp(h264_nal_tree, tvb, pinfo, offset);
1762 case 13: /* Sequence parameter set extension */
1763 dissect_h264_seq_parameter_set_extension_rbsp(h264_nal_tree, tvb, pinfo, offset);
1765 case 14: /* Reserved */
1766 case 15: /* Reserved */
1767 case 16: /* Reserved */
1768 case 17: /* Reserved */
1769 case 18: /* Reserved */
1770 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Reserved NAL unit type");
1772 case 19: /* Coded slice of an auxiliary coded picture without partitioning */
1773 dissect_h264_slice_layer_without_partitioning_rbsp(tree, tvb, pinfo, offset);
1776 dissect_h264_slice_layer_without_partitioning_rbsp(tree, tvb, pinfo, offset);
1779 /* 24..31 Unspecified */
1780 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Unspecified NAL unit type");
1785 /* Code to actually dissect the packets */
1787 dissect_h264(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1790 proto_item *item, *ti, *stream_item, *fua_item;
1791 proto_tree *h264_tree, *h264_nal_tree, *stream_tree, *fua_tree;
1795 /* Make entries in Protocol column and Info column on summary display */
1796 col_set_str(pinfo->cinfo, COL_PROTOCOL, "H264");
1799 item = proto_tree_add_item(tree, proto_h264, tvb, 0, -1, FALSE);
1800 h264_tree = proto_item_add_subtree(item, ett_h264);
1802 type = tvb_get_guint8(tvb,offset)&0x1f;
1803 /* if the type is 28, it would be draw another title */
1805 ti = proto_tree_add_text(h264_tree, tvb, offset, 1, "FU identifier");
1807 ti = proto_tree_add_text(h264_tree, tvb, offset, 1, "NAL unit header or first byte of the payload");
1808 h264_nal_tree = proto_item_add_subtree(ti, ett_h264_nal);
1810 /* +---------------+
1818 * forbidden_zero_bit. A value of 0 indicates that the NAL unit type
1819 * octet and payload should not contain bit errors or other syntax
1820 * violations. A value of 1 indicates that the NAL unit type octet
1821 * and payload may contain bit errors or other syntax violations.
1823 proto_tree_add_item(h264_nal_tree, hf_h264_nal_f_bit, tvb, offset, 1, FALSE);
1824 proto_tree_add_item(h264_nal_tree, hf_h264_nal_nri, tvb, offset, 1, FALSE);
1825 if (check_col(pinfo->cinfo, COL_INFO)){
1826 col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
1827 val_to_str(type, h264_type_values, "Unknown Type (%u)"));
1830 proto_tree_add_item(h264_nal_tree, hf_h264_type, tvb, offset, 1, FALSE);
1833 fua_item = proto_tree_add_text(h264_tree, tvb, offset, 1, "FU Header");
1834 fua_tree = proto_item_add_subtree(fua_item, ett_h264_fua);
1835 proto_tree_add_item(fua_tree, hf_h264_start_bit, tvb, offset, 1, FALSE);
1836 proto_tree_add_item(fua_tree, hf_h264_end_bit, tvb, offset, 1, FALSE);
1837 proto_tree_add_item(fua_tree, hf_h264_forbidden_bit, tvb, offset, 1, FALSE);
1838 proto_tree_add_item(fua_tree, hf_h264_nal_unit_type, tvb, offset, 1, FALSE);
1839 if ( (tvb_get_guint8(tvb,offset)&0x80) == 0x80 ){
1840 type = tvb_get_guint8(tvb,offset)&0x1f;
1846 stream_item =proto_tree_add_text(h264_tree, tvb, offset, -1, "H264 bitstream");
1847 stream_tree = proto_item_add_subtree(stream_item, ett_h264_stream);
1849 case 1: /* 1 Coded slice of a non-IDR picture */
1850 dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, tvb, pinfo, offset);
1852 case 3: /* Coded slice data partition B */
1853 dissect_h264_slice_data_partition_b_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1855 case 4: /* Coded slice data partition C */
1856 dissect_h264_slice_data_partition_c_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1858 case 5: /* Coded slice of an IDR picture */
1859 dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, tvb, pinfo, offset);
1861 case 6: /* Supplemental enhancement information (SEI) */
1862 dissect_h264_sei_rbsp(stream_tree, tvb, pinfo, offset);
1864 case H264_SEQ_PAR_SET: /* 7 Sequence parameter set*/
1865 dissect_h264_seq_parameter_set_rbsp(stream_tree, tvb, pinfo, offset);
1867 case H264_PIC_PAR_SET: /* 8 Picture parameter set */
1868 dissect_h264_pic_parameter_set_rbsp(stream_tree, tvb, pinfo, offset);
1870 case 19: /* Coded slice of an auxiliary coded picture without partitioning */
1871 dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, tvb, pinfo, offset);
1883 static const int *profile_fields[] = {
1884 &hf_h264_par_profile_b,
1885 &hf_h264_par_profile_m,
1886 &hf_h264_par_profile_e,
1887 &hf_h264_par_profile_h,
1888 &hf_h264_par_profile_h10,
1889 &hf_h264_par_profile_h4_2_2,
1890 &hf_h264_par_profile_h4_4_4,
1895 dissect_h264_par_profile(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1899 proto_tree_add_bitmask(tree, tvb, offset,
1900 hf_h264_par_profile, ett_h264_par_profile,
1901 profile_fields, FALSE);
1906 static const int *AdditionalModesSupported_fields[] = {
1907 &hf_h264_par_add_mode_sup_rcdo,
1911 dissect_h264_par_AdditionalModesSupported(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1915 proto_tree_add_bitmask(tree, tvb, offset,
1916 hf_h264_par_AdditionalModesSupported, ett_h264_par_AdditionalModesSupported,
1917 AdditionalModesSupported_fields, FALSE);
1923 static const int *ProfileIOP_fields[] = {
1924 &hf_h264_par_constraint_set0_flag,
1925 &hf_h264_par_constraint_set1_flag,
1926 &hf_h264_par_constraint_set2_flag,
1932 dissect_h264_ProfileIOP(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1936 proto_tree_add_bitmask(tree, tvb, offset,
1937 hf_h264_par_ProfileIOP, ett_h264_par_ProfileIOP,
1938 ProfileIOP_fields, FALSE);
1943 static const value_string h264_par_level_values[] = {
1964 dissect_h264_par_level(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_)
1968 const gchar *p = NULL;
1971 actx = get_asn1_ctx(pinfo->private_data);
1972 DISSECTOR_ASSERT(actx);
1974 lvl = tvb_get_ntohs(tvb, offset);
1975 p = match_strval(lvl, VALS(h264_par_level_values));
1977 proto_item_append_text(actx->created_item, " - Level %s", p);
1983 dissect_h264_par_DecoderConfigurationInformation(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_)
1987 actx = get_asn1_ctx(pinfo->private_data);
1988 DISSECTOR_ASSERT(actx);
1990 dissect_h264_nal_unit(tvb, pinfo, tree);
1992 return tvb_length(tvb);
1995 typedef struct _h264_capability_t {
1998 new_dissector_t content_pdu;
1999 } h264_capability_t;
2001 static h264_capability_t h264_capability_tab[] = {
2002 /* ITU-T H.241 (05/2006), 8.3 H.264 capabilities */
2003 { "GenericCapability/0.0.8.241.0.0.1", "ITU-T Rec. H.241 H.264 Video Capabilities", NULL },
2004 { "GenericCapability/0.0.8.241.0.0.1/collapsing/41", "Profile", dissect_h264_par_profile },
2005 { "GenericCapability/0.0.8.241.0.0.1/collapsing/42", "Level", dissect_h264_par_level },
2006 { "GenericCapability/0.0.8.241.0.0.1/collapsing/3" , "CustomMaxMBPS", NULL },
2007 { "GenericCapability/0.0.8.241.0.0.1/collapsing/4" , "CustomMaxFS", NULL },
2008 { "GenericCapability/0.0.8.241.0.0.1/collapsing/5" , "CustomMaxDPB", NULL },
2009 { "GenericCapability/0.0.8.241.0.0.1/collapsing/6" , "CustomMaxBRandCPB", NULL },
2010 { "GenericCapability/0.0.8.241.0.0.1/collapsing/7" , "MaxStaticMBPS", NULL },
2011 { "GenericCapability/0.0.8.241.0.0.1/collapsing/8" , "max-rcmd-nal-unit-size", NULL },
2012 { "GenericCapability/0.0.8.241.0.0.1/collapsing/9" , "max-nal-unit-size", NULL },
2013 { "GenericCapability/0.0.8.241.0.0.1/collapsing/10", "SampleAspectRatiosSupported", NULL },
2014 { "GenericCapability/0.0.8.241.0.0.1/collapsing/11", "AdditionalModesSupported", dissect_h264_par_AdditionalModesSupported },
2015 { "GenericCapability/0.0.8.241.0.0.1/collapsing/12", "AdditionalDisplayCapabilities", NULL },
2016 /* TS 26.111 H.264 */
2017 { "GenericCapability/0.0.8.241.0.0.1/nonCollapsing/43" , "DecoderConfigurationInformation", dissect_h264_par_DecoderConfigurationInformation },
2018 { "GenericCapability/0.0.8.241.0.0.1/collapsing/44" , "AcceptRedundantSlices", NULL },
2019 { "GenericCapability/0.0.8.241.0.0.1/collapsing/45" , "NalAlignedMode", NULL },
2020 { "GenericCapability/0.0.8.241.0.0.1/collapsing/46" , "ProfileIOP", dissect_h264_ProfileIOP },
2021 { NULL, NULL, NULL },
2024 static h264_capability_t *find_cap(const gchar *id) {
2025 h264_capability_t *ftr = NULL;
2026 h264_capability_t *f;
2028 for (f=h264_capability_tab; f->id; f++) {
2029 if (!strcmp(id, f->id)) { ftr = f; break; }
2035 dissect_h264_name(tvbuff_t *tvb _U_, packet_info *pinfo, proto_tree *tree)
2038 h264_capability_t *ftr = NULL;
2040 actx = get_asn1_ctx(pinfo->private_data);
2041 DISSECTOR_ASSERT(actx);
2043 ftr = find_cap(pinfo->match_string);
2045 proto_item_append_text(actx->created_item, " - %s", ftr->name);
2046 proto_item_append_text(proto_item_get_parent(proto_tree_get_parent(tree)), ": %s", ftr->name);
2048 proto_item_append_text(actx->created_item, " - unknown(%s)", pinfo->match_string);
2054 /* Register the protocol with Wireshark */
2055 /* If this dissector uses sub-dissector registration add a registration routine.
2056 This format is required because a script is used to find these routines and
2057 create the code that calls these routines.
2060 proto_reg_handoff_h264(void)
2062 static dissector_handle_t h264_handle;
2063 static guint dynamic_payload_type;
2064 static gboolean h264_prefs_initialized = FALSE;
2066 if (!h264_prefs_initialized) {
2067 dissector_handle_t h264_name_handle;
2068 h264_capability_t *ftr;
2070 h264_handle = find_dissector("h264");
2071 dissector_add_string("rtp_dyn_payload_type","H264", h264_handle);
2073 h264_name_handle = create_dissector_handle(dissect_h264_name, proto_h264);
2074 for (ftr=h264_capability_tab; ftr->id; ftr++) {
2076 dissector_add_string("h245.gef.name", ftr->id, h264_name_handle);
2077 if (ftr->content_pdu)
2078 dissector_add_string("h245.gef.content", ftr->id, new_create_dissector_handle(ftr->content_pdu, proto_h264));
2080 h264_prefs_initialized = TRUE;
2082 if ( dynamic_payload_type > 95 )
2083 dissector_delete("rtp.pt", dynamic_payload_type, h264_handle);
2086 dynamic_payload_type = temp_dynamic_payload_type;
2087 if ( dynamic_payload_type > 95 ){
2088 dissector_add("rtp.pt", dynamic_payload_type, h264_handle);
2092 /* this format is required because a script is used to build the C function
2093 that calls all the protocol registration.
2097 proto_register_h264(void)
2100 module_t *h264_module;
2102 /* Setup list of header fields See Section 1.6.1 for details*/
2103 static hf_register_info hf[] = {
2104 { &hf_h264_nal_f_bit,
2105 { "F bit", "h264.f",
2106 FT_BOOLEAN, 8, TFS(&h264_f_bit_vals), 0x80,
2110 { "Nal_ref_idc (NRI)", "h264.nal_nri",
2111 FT_UINT8, BASE_DEC, NULL, 0x60,
2115 { "Type", "h264.nal_unit_hdr",
2116 FT_UINT8, BASE_DEC, VALS(h264_type_values), 0x1f,
2119 { &hf_h264_start_bit,
2120 { "Start bit", "h264.start.bit",
2121 FT_BOOLEAN, 8, TFS(&h264_start_bit_vals), 0x80,
2125 { "End bit", "h264.end.bit",
2126 FT_BOOLEAN, 8, TFS(&h264_end_bit_vals), 0x40,
2129 { &hf_h264_forbidden_bit,
2130 { "Forbidden bit", "h264.forbidden.bit",
2131 FT_UINT8, BASE_DEC, NULL, 0x20,
2135 { "Profile", "h264.profile",
2136 FT_BYTES, BASE_NONE, NULL, 0x0,
2139 { &hf_h264_profile_idc,
2140 { "Profile_idc", "h264.profile_idc",
2141 FT_UINT8, BASE_DEC, VALS(h264_profile_idc_values), 0xff,
2144 { &hf_h264_rbsp_stop_bit,
2145 { "rbsp_stop_bit", "h264.rbsp_stop_bit",
2146 FT_UINT8, BASE_DEC, NULL, 0x0,
2149 { &hf_h264_rbsp_trailing_bits,
2150 { "rbsp_trailing_bits", "h264.rbsp_trailing_bits",
2151 FT_UINT8, BASE_DEC, NULL, 0x0,
2154 { &hf_h264_constraint_set0_flag,
2155 { "Constraint_set0_flag", "h264.constraint_set0_flag",
2156 FT_UINT8, BASE_DEC, NULL, 0x80,
2159 { &hf_h264_constraint_set1_flag,
2160 { "Constraint_set1_flag", "h264.constraint_set1_flag",
2161 FT_UINT8, BASE_DEC, NULL, 0x40,
2164 { &hf_h264_constraint_set2_flag,
2165 { "Constraint_set2_flag", "h264.constraint_set2_flag",
2166 FT_UINT8, BASE_DEC, NULL, 0x20,
2169 { &hf_h264_constraint_set3_flag,
2170 { "Constraint_set3_flag", "h264.constraint_set3_flag",
2171 FT_UINT8, BASE_DEC, NULL, 0x10,
2174 { &hf_h264_reserved_zero_4bits,
2175 { "Reserved_zero_4bits", "h264.reserved_zero_4bits",
2176 FT_UINT8, BASE_DEC, NULL, 0x0f,
2179 { &hf_h264_level_idc,
2180 { "Level_id", "h264.level_id",
2181 FT_UINT8, BASE_DEC, NULL, 0xff,
2184 { &hf_h264_nal_unit,
2185 { "NAL unit", "h264.nal_unit",
2186 FT_BYTES, BASE_NONE, NULL, 0x0,
2189 { &hf_h264_forbidden_zero_bit,
2190 { "Forbidden_zero_bit", "h264.forbidden_zero_bit",
2191 FT_UINT8, BASE_DEC, NULL, 0x80,
2194 { &hf_h264_nal_ref_idc,
2195 { "Nal_ref_idc", "h264.nal_ref_idc",
2196 FT_UINT8, BASE_DEC, NULL, 0x60,
2199 {&hf_h264_nal_unit_type,
2200 { "Nal_unit_type", "h264.nal_unit_type",
2201 FT_UINT8, BASE_DEC, VALS(h264_nal_unit_type_vals), 0x1f,
2204 { &hf_h264_seq_parameter_set_id,
2205 { "seq_parameter_set_id", "h264.seq_parameter_set_id",
2206 FT_UINT32, BASE_DEC, NULL, 0x0,
2209 { &hf_h264_chroma_format_idc,
2210 { "chroma_format_id", "h264.chroma_format_id",
2211 FT_UINT32, BASE_DEC, NULL, 0x0,
2214 { &hf_h264_residual_colour_transform_flag,
2215 { "residual_colour_transform_flag", "h264.residual_colour_transform_flag",
2216 FT_UINT8, BASE_DEC, NULL, 0x0,
2219 { &hf_h264_bit_depth_luma_minus8,
2220 { "bit_depth_luma_minus8", "h264.bit_depth_luma_minus8",
2221 FT_UINT32, BASE_DEC, NULL, 0x0,
2224 { &hf_h264_bit_depth_chroma_minus8,
2225 { "bit_depth_chroma_minus8", "h264.bit_depth_chroma_minus8",
2226 FT_UINT32, BASE_DEC, NULL, 0x0,
2229 { &hf_h264_qpprime_y_zero_transform_bypass_flag,
2230 { "qpprime_y_zero_transform_bypass_flag", "h264.qpprime_y_zero_transform_bypass_flag",
2231 FT_UINT32, BASE_DEC, NULL, 0x0,
2234 { &hf_h264_seq_scaling_matrix_present_flag,
2235 { "seq_scaling_matrix_present_flag", "h264.seq_scaling_matrix_present_flag",
2236 FT_UINT32, BASE_DEC, NULL, 0x0,
2239 { &hf_h264_log2_max_frame_num_minus4,
2240 { "log2_max_frame_num_minus4", "h264.log2_max_frame_num_minus4",
2241 FT_UINT32, BASE_DEC, NULL, 0x0,
2244 { &hf_h264_pic_order_cnt_type,
2245 { "pic_order_cnt_type", "h264.pic_order_cnt_type",
2246 FT_UINT32, BASE_DEC, NULL, 0x0,
2249 { &hf_h264_log2_max_pic_order_cnt_lsb_minus4,
2250 { "log2_max_pic_order_cnt_lsb_minus4", "h264.log2_max_pic_order_cnt_lsb_minus4",
2251 FT_UINT32, BASE_DEC, NULL, 0x0,
2254 { &hf_h264_delta_pic_order_always_zero_flag,
2255 { "delta_pic_order_always_zero_flag", "h264.delta_pic_order_always_zero_flag",
2256 FT_UINT8, BASE_DEC, NULL, 0x0,
2259 { &hf_h264_offset_for_non_ref_pic,
2260 { "offset_for_non_ref_pic", "h264.offset_for_non_ref_pic",
2261 FT_INT32, BASE_DEC, NULL, 0x0,
2264 { &hf_h264_offset_for_top_to_bottom_field,
2265 { "offset_for_top_to_bottom_field", "h264.offset_for_top_to_bottom_field",
2266 FT_INT32, BASE_DEC, NULL, 0x0,
2269 { &hf_h264_num_ref_frames_in_pic_order_cnt_cycle,
2270 { "num_ref_frames_in_pic_order_cnt_cycle", "h264.num_ref_frames_in_pic_order_cnt_cycle",
2271 FT_UINT32, BASE_DEC, NULL, 0x0,
2274 { &hf_h264_offset_for_ref_frame,
2275 { "offset_for_ref_frame", "h264.offset_for_ref_frame",
2276 FT_INT32, BASE_DEC, NULL, 0x0,
2279 { &hf_h264_num_ref_frames,
2280 { "num_ref_frames", "h264.num_ref_frames",
2281 FT_UINT32, BASE_DEC, NULL, 0x0,
2284 { &hf_h264_gaps_in_frame_num_value_allowed_flag,
2285 { "gaps_in_frame_num_value_allowed_flag", "h264.gaps_in_frame_num_value_allowed_flag",
2286 FT_UINT8, BASE_DEC, NULL, 0x0,
2289 { &hf_h264_pic_width_in_mbs_minus1,
2290 { "pic_width_in_mbs_minus1", "h264.pic_width_in_mbs_minus1",
2291 FT_UINT32, BASE_DEC, NULL, 0x0,
2294 { &hf_h264_pic_height_in_map_units_minus1,
2295 { "pic_height_in_map_units_minus1", "h264.pic_height_in_map_units_minus1",
2296 FT_UINT32, BASE_DEC, NULL, 0x0,
2299 { &hf_h264_frame_mbs_only_flag,
2300 { "frame_mbs_only_flag", "h264.frame_mbs_only_flag",
2301 FT_UINT8, BASE_DEC, NULL, 0x0,
2304 { &hf_h264_mb_adaptive_frame_field_flag,
2305 { "mb_adaptive_frame_field_flag", "h264.mb_adaptive_frame_field_flag",
2306 FT_UINT8, BASE_DEC, NULL, 0x0,
2309 { &hf_h264_direct_8x8_inference_flag,
2310 { "direct_8x8_inference_flag", "h264.direct_8x8_inference_flag",
2311 FT_UINT8, BASE_DEC, NULL, 0x0,
2314 { &hf_h264_frame_cropping_flag,
2315 { "frame_cropping_flag", "h264.frame_cropping_flag",
2316 FT_UINT8, BASE_DEC, NULL, 0x0,
2319 { &hf_h264_frame_crop_left_offset,
2320 { "frame_crop_left_offset", "h264.frame_crop_left_offset",
2321 FT_UINT32, BASE_DEC, NULL, 0x0,
2324 { &hf_h264_frame_crop_right_offset,
2325 { "frame_crop_left_offset", "h264.frame_crop_right_offset",
2326 FT_UINT32, BASE_DEC, NULL, 0x0,
2329 { &hf_h264_frame_crop_top_offset,
2330 { "frame_crop_top_offset", "h264.frame_crop_top_offset",
2331 FT_UINT32, BASE_DEC, NULL, 0x0,
2334 { &hf_h264_frame_crop_bottom_offset,
2335 { "frame_crop_bottom_offset", "h264.frame_crop_bottom_offset",
2336 FT_UINT32, BASE_DEC, NULL, 0x0,
2339 { &hf_h264_vui_parameters_present_flag,
2340 { "vui_parameters_present_flag", "h264.vui_parameters_present_flag",
2341 FT_UINT8, BASE_DEC, NULL, 0x0,
2344 { &hf_h264_pic_parameter_set_id,
2345 { "pic_parameter_set_id", "h264.pic_parameter_set_id",
2346 FT_UINT32, BASE_DEC, NULL, 0x0,
2349 { &hf_h264_entropy_coding_mode_flag,
2350 { "entropy_coding_mode_flag", "h264.entropy_coding_mode_flag",
2351 FT_UINT8, BASE_DEC, NULL, 0x0,
2354 { &hf_h264_pic_order_present_flag,
2355 { "pic_order_present_flag", "h264.pic_order_present_flag",
2356 FT_UINT8, BASE_DEC, NULL, 0x0,
2359 { &hf_h264_num_slice_groups_minus1,
2360 { "num_slice_groups_minus1", "h264.num_slice_groups_minus1",
2361 FT_UINT32, BASE_DEC, NULL, 0x0,
2364 { &hf_h264_slice_group_map_type,
2365 { "slice_group_map_type", "h264.slice_group_map_type",
2366 FT_UINT32, BASE_DEC, VALS(h264_slice_group_map_type_vals), 0x0,
2369 { &hf_h264_num_ref_idx_l0_active_minus1,
2370 { "num_ref_idx_l0_active_minus1", "h264.num_ref_idx_l0_active_minus1",
2371 FT_UINT32, BASE_DEC, NULL, 0x0,
2374 { &hf_h264_num_ref_idx_l1_active_minus1,
2375 { "num_ref_idx_l1_active_minus1", "h264.num_ref_idx_l1_active_minus1",
2376 FT_UINT32, BASE_DEC, NULL, 0x0,
2379 { &hf_h264_weighted_pred_flag,
2380 { "weighted_pred_flag", "h264.weighted_pred_flag",
2381 FT_UINT8, BASE_DEC, NULL, 0x0,
2384 { &hf_h264_weighted_bipred_idc,
2385 { "weighted_bipred_idc", "h264.weighted_bipred_idc",
2386 FT_UINT8, BASE_DEC, NULL, 0x0,
2389 { &hf_h264_pic_init_qp_minus26,
2390 { "pic_init_qp_minus26", "h264.pic_init_qp_minus26",
2391 FT_INT32, BASE_DEC, NULL, 0x0,
2394 { &hf_h264_pic_init_qs_minus26,
2395 { "pic_init_qs_minus26", "h264.pic_init_qs_minus26",
2396 FT_INT32, BASE_DEC, NULL, 0x0,
2399 { &hf_h264_chroma_qp_index_offset,
2400 { "chroma_qp_index_offset", "h264.chroma_qp_index_offset",
2401 FT_INT32, BASE_DEC, NULL, 0x0,
2404 { &hf_h264_deblocking_filter_control_present_flag,
2405 { "deblocking_filter_control_present_flag", "h264.deblocking_filter_control_present_flag",
2406 FT_UINT8, BASE_DEC, NULL, 0x0,
2409 { &hf_h264_constrained_intra_pred_flag,
2410 { "constrained_intra_pred_flag", "h264.constrained_intra_pred_flag",
2411 FT_UINT8, BASE_DEC, NULL, 0x0,
2414 { &hf_h264_redundant_pic_cnt_present_flag,
2415 { "redundant_pic_cnt_present_flag", "h264.redundant_pic_cnt_present_flag",
2416 FT_UINT8, BASE_DEC, NULL, 0x0,
2419 { &hf_h264_transform_8x8_mode_flag,
2420 { "transform_8x8_mode_flag", "h264.transform_8x8_mode_flag",
2421 FT_UINT8, BASE_DEC, NULL, 0x0,
2424 { &hf_h264_pic_scaling_matrix_present_flag,
2425 { "pic_scaling_matrix_present_flag", "h264.pic_scaling_matrix_present_flag",
2426 FT_UINT8, BASE_DEC, NULL, 0x0,
2429 { &hf_h264_second_chroma_qp_index_offset,
2430 { "second_chroma_qp_index_offset", "h264.second_chroma_qp_index_offset",
2431 FT_INT32, BASE_DEC, NULL, 0x0,
2435 { &hf_h264_aspect_ratio_info_present_flag,
2436 { "aspect_ratio_info_present_flag", "h264.aspect_ratio_info_present_flag",
2437 FT_UINT8, BASE_DEC, NULL, 0x0,
2440 { &hf_h264_aspect_ratio_idc,
2441 { "aspect_ratio_idc", "h264.aspect_ratio_idc",
2442 FT_UINT8, BASE_DEC, NULL, 0x0,
2445 { &hf_h264_sar_width,
2446 { "sar_width", "h264.sar_width",
2447 FT_UINT16, BASE_DEC, NULL, 0x0,
2450 { &hf_h264_sar_height,
2451 { "sar_height", "h264.sar_height",
2452 FT_UINT16, BASE_DEC, NULL, 0x0,
2455 { &hf_h264_overscan_info_present_flag,
2456 { "overscan_info_present_flag", "h264.overscan_info_present_flag",
2457 FT_UINT8, BASE_DEC, NULL, 0x0,
2460 { &hf_h264_overscan_appropriate_flag,
2461 { "overscan_appropriate_flag", "h264.overscan_appropriate_flag",
2462 FT_UINT8, BASE_DEC, NULL, 0x0,
2465 { &hf_h264_video_signal_type_present_flag,
2466 { "video_signal_type_present_flag", "h264.video_signal_type_present_flag",
2467 FT_UINT8, BASE_DEC, NULL, 0x0,
2470 { &hf_h264_video_format,
2471 { "video_format", "h264.video_format",
2472 FT_UINT8, BASE_DEC, VALS(h264_video_format_vals), 0x0,
2475 { &hf_h264_video_full_range_flag,
2476 { "video_full_range_flag", "h264.video_full_range_flag",
2477 FT_UINT8, BASE_DEC, NULL, 0x0,
2480 { &hf_h264_colour_description_present_flag,
2481 { "colour_description_present_flag", "h264.colour_description_present_flag",
2482 FT_UINT8, BASE_DEC, NULL, 0x0,
2485 { &hf_h264_colour_primaries,
2486 { "colour_primaries", "h264.colour_primaries",
2487 FT_UINT8, BASE_DEC, NULL, 0x0,
2490 { &hf_h264_transfer_characteristics,
2491 { "transfer_characteristics", "h264.transfer_characteristics",
2492 FT_UINT8, BASE_DEC, NULL, 0x0,
2495 { &hf_h264_matrix_coefficients,
2496 { "matrix_coefficients", "h264.matrix_coefficients",
2497 FT_UINT8, BASE_DEC, NULL, 0x0,
2500 { &hf_h264_chroma_loc_info_present_flag,
2501 { "chroma_loc_info_present_flag", "h264.chroma_loc_info_present_flag",
2502 FT_UINT8, BASE_DEC, NULL, 0x0,
2505 { &hf_h264_chroma_sample_loc_type_top_field,
2506 { "chroma_sample_loc_type_top_field", "h264.chroma_sample_loc_type_top_field",
2507 FT_UINT32, BASE_DEC, NULL, 0x0,
2510 { &hf_h264_chroma_sample_loc_type_bottom_field,
2511 { "chroma_sample_loc_type_bottom_field", "h264.chroma_sample_loc_type_bottom_field",
2512 FT_UINT32, BASE_DEC, NULL, 0x0,
2515 { &hf_h264_timing_info_present_flag,
2516 { "timing_info_present_flag", "h264.timing_info_present_flag",
2517 FT_UINT8, BASE_DEC, NULL, 0x0,
2520 { &hf_h264_num_units_in_tick,
2521 { "num_units_in_tick", "h264.num_units_in_tick",
2522 FT_UINT32, BASE_DEC, NULL, 0x0,
2525 { &hf_h264_time_scale,
2526 { "time_scale", "h264.time_scale",
2527 FT_UINT32, BASE_DEC, NULL, 0x0,
2530 { &hf_h264_fixed_frame_rate_flag,
2531 { "fixed_frame_rate_flag", "h264.fixed_frame_rate_flag",
2532 FT_UINT8, BASE_DEC, NULL, 0x0,
2535 { &hf_h264_nal_hrd_parameters_present_flag,
2536 { "nal_hrd_parameters_present_flag", "h264.nal_hrd_parameters_present_flag",
2537 FT_UINT8, BASE_DEC, NULL, 0x0,
2540 { &hf_h264_vcl_hrd_parameters_present_flag,
2541 { "vcl_hrd_parameters_present_flag", "h264.vcl_hrd_parameters_present_flag",
2542 FT_UINT8, BASE_DEC, NULL, 0x0,
2545 { &hf_h264_low_delay_hrd_flag,
2546 { "low_delay_hrd_flag", "h264.low_delay_hrd_flag",
2547 FT_UINT8, BASE_DEC, NULL, 0x0,
2550 { &hf_h264_pic_struct_present_flag,
2551 { "pic_struct_present_flag", "h264.pic_struct_present_flag",
2552 FT_UINT8, BASE_DEC, NULL, 0x0,
2555 { &hf_h264_bitstream_restriction_flag,
2556 { "bitstream_restriction_flag", "h264.bitstream_restriction_flag",
2557 FT_UINT8, BASE_DEC, NULL, 0x0,
2560 { &hf_h264_motion_vectors_over_pic_boundaries_flag,
2561 { "motion_vectors_over_pic_boundaries_flag", "h264.motion_vectors_over_pic_boundaries_flag",
2562 FT_UINT32, BASE_DEC, NULL, 0x0,
2565 { &hf_h264_max_bytes_per_pic_denom,
2566 { "max_bytes_per_pic_denom", "h264.max_bytes_per_pic_denom",
2567 FT_UINT32, BASE_DEC, NULL, 0x0,
2570 { &hf_h264_max_bits_per_mb_denom,
2571 { "max_bits_per_mb_denom", "h264.max_bits_per_mb_denom",
2572 FT_UINT32, BASE_DEC, NULL, 0x0,
2575 { &hf_h264_log2_max_mv_length_horizontal,
2576 { "max_mv_length_horizontal", "h264.max_mv_length_horizontal",
2577 FT_UINT32, BASE_DEC, NULL, 0x0,
2580 { &hf_h264_log2_max_mv_length_vertical,
2581 { "log2_max_mv_length_vertical", "h264.log2_max_mv_length_vertical",
2582 FT_UINT32, BASE_DEC, NULL, 0x0,
2585 { &hf_h264_num_reorder_frames,
2586 { "num_reorder_frames", "h264.num_reorder_frames",
2587 FT_UINT32, BASE_DEC, NULL, 0x0,
2590 { &hf_h264_max_dec_frame_buffering,
2591 { "max_dec_frame_buffering", "h264.max_dec_frame_buffering",
2592 FT_UINT32, BASE_DEC, NULL, 0x0,
2595 { &hf_h264_cpb_cnt_minus1,
2596 { "cpb_cnt_minus1", "h264.cpb_cnt_minus1",
2597 FT_UINT32, BASE_DEC, NULL, 0x0,
2600 { &hf_h264_bit_rate_scale,
2601 { "bit_rate_scale", "h264.bit_rate_scale",
2602 FT_UINT8, BASE_DEC, NULL, 0x0,
2605 { &hf_h264_cpb_size_scale,
2606 { "cpb_size_scale", "h264.cpb_size_scale",
2607 FT_UINT8, BASE_DEC, NULL, 0x0,
2610 { &hf_h264_bit_rate_value_minus1,
2611 { "bit_rate_value_minus1", "h264.bit_rate_value_minus1",
2612 FT_UINT32, BASE_DEC, NULL, 0x0,
2615 { &hf_h264_cpb_size_value_minus1,
2616 { "cpb_size_value_minus1", "h264.cpb_size_value_minus1",
2617 FT_UINT32, BASE_DEC, NULL, 0x0,
2620 { &hf_h264_cbr_flag,
2621 { "cbr_flag", "h264.cbr_flag",
2622 FT_UINT8, BASE_DEC, NULL, 0x0,
2625 { &hf_h264_initial_cpb_removal_delay_length_minus1,
2626 { "initial_cpb_removal_delay_length_minus1", "h264.initial_cpb_removal_delay_length_minus1",
2627 FT_UINT8, BASE_DEC, NULL, 0x0,
2630 { &hf_h264_cpb_removal_delay_length_minus1,
2631 { "cpb_removal_delay_length_minus1", "h264.cpb_removal_delay_length_minus1",
2632 FT_UINT8, BASE_DEC, NULL, 0x0,
2635 { &hf_h264_dpb_output_delay_length_minus11,
2636 { "dpb_output_delay_length_minus11", "h264.dpb_output_delay_length_minus11",
2637 FT_UINT8, BASE_DEC, NULL, 0x0,
2640 { &hf_h264_time_offset_length,
2641 { "time_offset_length", "h264.time_offset_length",
2642 FT_UINT8, BASE_DEC, NULL, 0x0,
2645 { &hf_h264_first_mb_in_slice,
2646 { "first_mb_in_slice", "h264.first_mb_in_slice",
2647 FT_UINT32, BASE_DEC, NULL, 0x0,
2650 { &hf_h264_slice_type,
2651 { "slice_type", "h264.slice_type",
2652 FT_UINT32, BASE_DEC, VALS(h264_slice_type_vals), 0x0,
2655 { &hf_h264_slice_id,
2656 { "slice_id", "h264.slice_id",
2657 FT_UINT32, BASE_DEC, NULL, 0x0,
2660 { &hf_h264_payloadsize,
2661 { "PayloadSize", "h264.payloadsize",
2662 FT_UINT32, BASE_DEC, NULL, 0x0,
2665 { &hf_h264_payloadtype,
2666 { "payloadType", "h264.payloadtype",
2667 FT_UINT32, BASE_DEC, VALS(h264_sei_payload_vals), 0x0,
2670 { &hf_h264_frame_num,
2671 { "frame_num", "h264.frame_num",
2672 FT_UINT8, BASE_DEC, NULL, 0x0,
2675 { &hf_h264_par_profile,
2676 { "Profile", "h264.profile",
2677 FT_UINT8, BASE_HEX, NULL, 0x00,
2679 { &hf_h264_par_profile_b,
2680 { "Baseline Profile", "h264.profile.base",
2681 FT_BOOLEAN, 8, NULL, 0x40,
2683 { &hf_h264_par_profile_m,
2684 { "Main Profile", "h264.profile.main",
2685 FT_BOOLEAN, 8, NULL, 0x20,
2687 { &hf_h264_par_profile_e,
2688 { "Extended Profile.", "h264.profile.ext",
2689 FT_BOOLEAN, 8, NULL, 0x10,
2691 { &hf_h264_par_profile_h,
2692 { "High Profile", "h264.profile.high",
2693 FT_BOOLEAN, 8, NULL, 0x08,
2695 { &hf_h264_par_profile_h10,
2696 { "High 10 Profile", "h264.profile.high10",
2697 FT_BOOLEAN, 8, NULL, 0x04,
2699 { &hf_h264_par_profile_h4_2_2,
2700 { "High 4:2:2 Profile", "h264.profile.high4_2_2",
2701 FT_BOOLEAN, 8, NULL, 0x02,
2703 { &hf_h264_par_profile_h4_4_4,
2704 { "High 4:4:4 Profile", "h264.profile.high4_4_4",
2705 FT_BOOLEAN, 8, NULL, 0x01,
2707 { &hf_h264_par_AdditionalModesSupported,
2708 { "AdditionalModesSupported", "h264.AdditionalModesSupported",
2709 FT_UINT8, BASE_HEX, NULL, 0x00,
2711 { &hf_h264_par_add_mode_sup,
2712 { "Additional Modes Supported", "h264.add_mode_sup",
2713 FT_UINT8, BASE_HEX, NULL, 0x00,
2715 { &hf_h264_par_add_mode_sup_rcdo,
2716 { "Reduced Complexity Decoding Operation (RCDO) support", "h264.add_mode_sup.rcdo",
2717 FT_BOOLEAN, 8, NULL, 0x40,
2719 { &hf_h264_par_ProfileIOP,
2720 { "ProfileIOP", "h264.ProfileIOP",
2721 FT_UINT8, BASE_HEX, NULL, 0x00,
2723 { &hf_h264_par_constraint_set0_flag,
2724 { "constraint_set0_flag", "h264.par.constraint_set0_flag",
2725 FT_BOOLEAN, 8, NULL, 0x80,
2727 { &hf_h264_par_constraint_set1_flag,
2728 { "constraint_set1_flag", "h264.par.constraint_set1_flag",
2729 FT_BOOLEAN, 8, NULL, 0x40,
2731 { &hf_h264_par_constraint_set2_flag,
2732 { "constraint_set2_flag", "h264.par.constraint_set2_flag",
2733 FT_BOOLEAN, 8, NULL, 0x20,
2737 /* Setup protocol subtree array */
2738 static gint *ett[] = {
2745 &ett_h264_par_profile,
2746 &ett_h264_par_AdditionalModesSupported,
2747 &ett_h264_par_ProfileIOP,
2750 /* Register the protocol name and description */
2751 proto_h264 = proto_register_protocol("H.264","H264", "h264");
2753 /* Required function calls to register the header fields and subtrees used */
2754 proto_register_field_array(proto_h264, hf, array_length(hf));
2755 proto_register_subtree_array(ett, array_length(ett));
2756 /* Register a configuration option for port */
2759 h264_module = prefs_register_protocol(proto_h264, proto_reg_handoff_h264);
2761 prefs_register_uint_preference(h264_module, "dynamic.payload.type",
2762 "H264 dynamic payload type",
2763 "The dynamic payload type which will be interpreted as H264"
2764 "; The value must be greater than 95",
2766 &temp_dynamic_payload_type);
2769 register_dissector("h264", dissect_h264, proto_h264);