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
40 #include <epan/packet.h>
41 #include <epan/proto.h>
42 #include <epan/asn1.h>
43 #include <epan/strutil.h>
48 /* Initialize the protocol and registered fields */
49 static int proto_h264 = -1;
50 static int hf_h264_type = -1;
51 static int hf_h264_nal_f_bit = -1;
52 static int hf_h264_nal_nri = -1;
53 static int hf_h264_start_bit = -1;
54 static int hf_h264_forbidden_bit = -1;
55 static int hf_h264_end_bit = -1;
56 static int hf_h264_profile = -1;
57 static int hf_h264_profile_idc = -1;
58 static int hf_h264_rbsp_stop_bit = -1;
59 static int hf_h264_rbsp_trailing_bits = -1;
60 static int hf_h264_constraint_set0_flag = -1;
61 static int hf_h264_constraint_set1_flag = -1;
62 static int hf_h264_constraint_set2_flag = -1;
63 static int hf_h264_constraint_set3_flag = -1;
64 static int hf_h264_reserved_zero_4bits = -1;
65 static int hf_h264_level_idc = -1;
66 static int hf_h264_nal_unit = -1;
67 static int hf_h264_forbidden_zero_bit = -1;
68 static int hf_h264_nal_ref_idc = -1;
69 static int hf_h264_nal_unit_type = -1;
70 static int hf_h264_seq_parameter_set_id = -1;
71 static int hf_h264_chroma_format_idc = -1;
72 static int hf_h264_residual_colour_transform_flag = -1;
73 static int hf_h264_bit_depth_luma_minus8 = -1;
74 static int hf_h264_bit_depth_chroma_minus8 = -1;
75 static int hf_h264_qpprime_y_zero_transform_bypass_flag = -1;
76 static int hf_h264_seq_scaling_matrix_present_flag = -1;
77 static int hf_h264_log2_max_frame_num_minus4 = -1;
78 static int hf_h264_pic_order_cnt_type = -1;
79 static int hf_h264_log2_max_pic_order_cnt_lsb_minus4 = -1;
80 static int hf_h264_delta_pic_order_always_zero_flag = -1;
81 static int hf_h264_offset_for_non_ref_pic = -1;
82 static int hf_h264_offset_for_top_to_bottom_field = -1;
83 static int hf_h264_num_ref_frames_in_pic_order_cnt_cycle = -1;
84 static int hf_h264_offset_for_ref_frame = -1;
85 static int hf_h264_num_ref_frames = -1;
86 static int hf_h264_gaps_in_frame_num_value_allowed_flag = -1;
87 static int hf_h264_pic_width_in_mbs_minus1 = -1;
88 static int hf_h264_pic_height_in_map_units_minus1 = -1;
89 static int hf_h264_frame_mbs_only_flag = -1;
90 static int hf_h264_mb_adaptive_frame_field_flag = -1;
91 static int hf_h264_direct_8x8_inference_flag = -1;
92 static int hf_h264_frame_cropping_flag = -1;
93 static int hf_h264_frame_crop_left_offset = -1;
94 static int hf_h264_frame_crop_right_offset = -1;
95 static int hf_h264_frame_crop_top_offset = -1;
96 static int hf_h264_frame_crop_bottom_offset = -1;
97 static int hf_h264_vui_parameters_present_flag = -1;
98 static int hf_h264_pic_parameter_set_id = -1;
99 static int hf_h264_entropy_coding_mode_flag = -1;
100 static int hf_h264_pic_order_present_flag = -1;
101 static int hf_h264_num_slice_groups_minus1 = -1;
102 static int hf_h264_slice_group_map_type = -1;
103 static int hf_h264_num_ref_idx_l0_active_minus1 = -1;
104 static int hf_h264_num_ref_idx_l1_active_minus1 = -1;
105 static int hf_h264_weighted_pred_flag = -1;
106 static int hf_h264_weighted_bipred_idc = -1;
107 static int hf_h264_pic_init_qp_minus26 = -1;
108 static int hf_h264_pic_init_qs_minus26 = -1;
109 static int hf_h264_chroma_qp_index_offset = -1;
110 static int hf_h264_deblocking_filter_control_present_flag = -1;
111 static int hf_h264_constrained_intra_pred_flag = -1;
112 static int hf_h264_redundant_pic_cnt_present_flag = -1;
113 static int hf_h264_transform_8x8_mode_flag = -1;
114 static int hf_h264_pic_scaling_matrix_present_flag = -1;
115 static int hf_h264_second_chroma_qp_index_offset = -1;
116 static int hf_h264_par_profile = -1;
117 static int hf_h264_par_profile_b = -1;
118 static int hf_h264_par_profile_m = -1;
119 static int hf_h264_par_profile_e = -1;
120 static int hf_h264_par_profile_h = -1;
121 static int hf_h264_par_profile_h10 = -1;
122 static int hf_h264_par_profile_h4_2_2 = -1;
123 static int hf_h264_par_profile_h4_4_4 = -1;
124 static int hf_h264_par_add_mode_sup = -1;
125 static int hf_h264_par_AdditionalModesSupported = -1;
126 static int hf_h264_par_add_mode_sup_rcdo = -1;
127 static int hf_h264_par_ProfileIOP = -1;
128 static int hf_h264_par_constraint_set0_flag = -1;
129 static int hf_h264_par_constraint_set1_flag = -1;
130 static int hf_h264_par_constraint_set2_flag = -1;
133 static int hf_h264_aspect_ratio_info_present_flag = -1;
134 static int hf_h264_aspect_ratio_idc = -1;
135 static int hf_h264_sar_width = -1;
136 static int hf_h264_sar_height = -1;
137 static int hf_h264_overscan_info_present_flag = -1;
138 static int hf_h264_overscan_appropriate_flag = -1;
139 static int hf_h264_video_signal_type_present_flag = -1;
140 static int hf_h264_video_format = -1;
141 static int hf_h264_video_full_range_flag = -1;
142 static int hf_h264_colour_description_present_flag = -1;
143 static int hf_h264_colour_primaries = -1;
144 static int hf_h264_transfer_characteristics = -1;
145 static int hf_h264_matrix_coefficients = -1;
146 static int hf_h264_chroma_loc_info_present_flag = -1;
147 static int hf_h264_chroma_sample_loc_type_top_field = -1;
148 static int hf_h264_chroma_sample_loc_type_bottom_field = -1;
149 static int hf_h264_timing_info_present_flag = -1;
150 static int hf_h264_num_units_in_tick = -1;
151 static int hf_h264_time_scale = -1;
152 static int hf_h264_fixed_frame_rate_flag = -1;
153 static int hf_h264_nal_hrd_parameters_present_flag = -1;
154 static int hf_h264_vcl_hrd_parameters_present_flag = -1;
155 static int hf_h264_low_delay_hrd_flag = -1;
156 static int hf_h264_pic_struct_present_flag = -1;
157 static int hf_h264_bitstream_restriction_flag = -1;
158 static int hf_h264_motion_vectors_over_pic_boundaries_flag = -1;
159 static int hf_h264_max_bytes_per_pic_denom = -1;
160 static int hf_h264_max_bits_per_mb_denom = -1;
161 static int hf_h264_log2_max_mv_length_horizontal = -1;
162 static int hf_h264_log2_max_mv_length_vertical = -1;
163 static int hf_h264_num_reorder_frames = -1;
164 static int hf_h264_max_dec_frame_buffering = -1;
165 static int hf_h264_cpb_cnt_minus1 = -1;
166 static int hf_h264_bit_rate_scale = -1;
167 static int hf_h264_cpb_size_scale = -1;
168 static int hf_h264_bit_rate_value_minus1 = -1;
169 static int hf_h264_cpb_size_value_minus1 = -1;
170 static int hf_h264_cbr_flag = -1;
171 static int hf_h264_initial_cpb_removal_delay_length_minus1 = -1;
172 static int hf_h264_cpb_removal_delay_length_minus1 = -1;
173 static int hf_h264_dpb_output_delay_length_minus11 = -1;
174 static int hf_h264_time_offset_length = -1;
176 static int hf_h264_first_mb_in_slice = -1;
177 static int hf_h264_slice_type = -1;
178 static int hf_h264_slice_id = -1;
179 static int hf_h264_payloadsize = -1;
180 static int hf_h264_payloadtype = -1;
181 static int hf_h264_frame_num = -1;
183 /* Initialize the subtree pointers */
184 static int ett_h264 = -1;
185 static int ett_h264_profile = -1;
186 static int ett_h264_nal = -1;
187 static int ett_h264_fua = -1;
188 static int ett_h264_stream = -1;
189 static int ett_h264_nal_unit = -1;
190 static int ett_h264_par_profile = -1;
191 static int ett_h264_par_AdditionalModesSupported = -1;
192 static int ett_h264_par_ProfileIOP = -1;
194 /* The dynamic payload type which will be dissected as H.264 */
196 static guint temp_dynamic_payload_type = 0;
198 /* syntax tables in subclause 7.3 is equal to
199 * ue(v), me(v), se(v), or te(v).
206 } h264_golomb_descriptors;
209 static const true_false_string h264_f_bit_vals = {
210 "Bit errors or other syntax violations",
211 "No bit errors or other syntax violations"
213 static const true_false_string h264_start_bit_vals = {
214 "the first packet of FU-A picture",
215 "Not the first packet of FU-A picture"
217 static const true_false_string h264_end_bit_vals = {
218 "the last packet of FU-A picture",
219 "Not the last packet of FU-A picture"
221 static const true_false_string h264_forbidden_bit_vals = {
222 "Forbidden Bit of FU-A",
223 "Not Forbidden Bit of FU-A"
226 #define H264_SEQ_PAR_SET 7
227 #define H264_PIC_PAR_SET 8
229 static const value_string h264_type_values[] = {
231 { 1, "NAL unit - Coded slice of a non-IDR picture" }, /* Single NAL unit packet per H.264 */
232 { 2, "NAL unit - Coded slice data partition A" },
233 { 3, "NAL unit - Coded slice data partition B" },
234 { 4, "NAL unit - Coded slice data partition C" },
235 { 5, "NAL unit - Coded slice of an IDR picture" },
236 { 6, "NAL unit - Supplemental enhancement information (SEI)" },
237 { H264_SEQ_PAR_SET, "NAL unit - Sequence parameter set" }, /* 7 */
238 { H264_PIC_PAR_SET, "NAL unit - Picture parameter set" }, /* 8 */
239 { 9, "NAL unit - Access unit delimiter" },
240 { 10, "NAL unit - End of sequence" },
241 { 11, "NAL unit - End of stream" },
242 { 12, "NAL unit - Filler data" },
243 { 13, "NAL unit - Sequence parameter set extension" },
244 { 14, "NAL unit - Reserved" },
245 { 15, "NAL unit - Reserved" },
246 { 16, "NAL unit - Reserved" },
247 { 17, "NAL unit - Reserved" },
248 { 18, "NAL unit - Reserved" },
249 { 19, "NAL unit - Coded slice of an auxiliary coded picture without partitioning" },
250 { 20, "NAL unit - Reserved" },
251 { 21, "NAL unit - Reserved" },
252 { 22, "NAL unit - Reserved" },
253 { 23, "NAL unit - Reserved" },
254 { 24, "STAP-A" }, /* Single-time aggregation packet */
255 { 25, "STAP-B" }, /* Single-time aggregation packet */
256 { 26, "MTAP16" }, /* Multi-time aggregation packet */
257 { 27, "MTAP24" }, /* Multi-time aggregation packet */
258 { 28, "FU-A" }, /* Fragmentation unit */
259 { 29, "FU-B" }, /* Fragmentation unit */
266 static const value_string h264_profile_idc_values[] = {
267 { 66, "Baseline profile" },
268 { 77, "Main profile" },
269 { 88, "Extended profile" },
270 { 100, "High profile" },
271 { 110, "High 10 profile" },
272 { 122, "High 4:2:2 profile" },
273 { 144, "High 4:4:4 profile" },
277 static const value_string h264_level_bitrate_values[] = {
296 static const value_string h264_nal_unit_type_vals[] = {
297 { 0, "Unspecified" },
298 { 1, "Coded slice of a non-IDR picture" },
299 { 2, "Coded slice data partition A" },
300 { 3, "Coded slice data partition B" },
301 { 4, "Coded slice data partition C" },
302 { 5, "Coded slice of an IDR picture" },
303 { 6, "Supplemental enhancement information (SEI)" },
304 { 7, "Sequence parameter set" },
305 { 8, "Picture parameter set" },
306 { 9, "Access unit delimiter" },
307 { 10, "End of sequence" },
308 { 11, "End of stream" },
309 { 12, "Filler data" },
310 { 13, "Sequence parameter set extension" },
316 { 19, "Coded slice of an auxiliary coded picture without partitioning" },
321 { 24, "Unspecified" },
322 { 25, "Unspecified" },
323 { 26, "Unspecified" },
324 { 27, "Unspecified" },
326 { 29, "Unspecified" },
327 { 30, "Unspecified" },
328 { 31, "Unspecified" },
332 static const value_string h264_slice_group_map_type_vals[] = {
333 { 0, "Interleaved slice groups" },
334 { 1, "Dispersed slice group mapping" },
335 { 2, "One or more foreground slice groups and a leftover slice group" },
336 { 3, "Changing slice groups" },
337 { 4, "Changing slice groups" },
338 { 5, "Changing slice groups" },
339 { 6, "Explicit assignment of a slice group to each slice group map unit" },
343 /* Table 7-6 Name association to slice_type */
344 static const value_string h264_slice_type_vals[] = {
345 { 0, "P (P slice)" },
346 { 1, "B (B slice)" },
347 { 2, "I (I slice)" },
348 { 3, "SP (SP slice)" },
349 { 4, "SI (SI slice)" },
350 { 5, "P (P slice)" },
351 { 6, "B (B slice)" },
352 { 7, "I (I slice)" },
353 { 8, "SP (SP slice)" },
354 { 9, "SI (SI slice)" },
357 /* byte_aligned( ) is specified as follows.
358 * - If the current position in the bitstream is on a byte boundary, i.e.,
359 * the next bit in the bitstream is the first bit in a byte,
360 * the return value of byte_aligned( ) is equal to TRUE.
361 * - Otherwise, the return value of byte_aligned( ) is equal to FALSE.
364 h264_byte_aligned(int bit_offset)
371 /* Expect a tvb and a bit offset into the tvb
372 * returns the valu and bit_offset
374 #define cVALS(x) (const value_string*)(x)
377 dissect_h264_exp_golomb_code(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint *start_bit_offset, h264_golomb_descriptors descriptor)
378 /*(tvbuff_t *tvb, gint *start_bit_offset) */
380 gint leading_zero_bits, bit_offset;
381 guint32 codenum, mask, value, tmp;
387 header_field_info *hf_field = NULL;
390 hf_field = proto_registrar_get_nth(hf_index);
392 bit_offset = *start_bit_offset;
394 /* prepare the string */
397 for(bit=0;bit<((int)(bit_offset&0x07));bit++){
399 g_strlcat(str, " ", 256);
401 g_strlcat(str,".", 256);
405 leading_zero_bits = -1;
406 for( b = 0; !b; leading_zero_bits++ ){
408 g_strlcat(str, " ", 256);
411 g_strlcat(str, " ", 256);
413 b = tvb_get_bits8(tvb, bit_offset, 1);
415 g_strlcat(str, "1", 256);
417 g_strlcat(str, "0", 256);
423 if(leading_zero_bits==0){
425 *start_bit_offset = bit_offset;
428 g_strlcat(str, " ", 256);
430 g_strlcat(str,".", 256);
433 g_strlcat(str," = ", 256);
434 g_strlcat(str,hf_field->name, 256);
437 /* if the syntax element is coded as se(v),
438 * the value of the syntax element is derived by invoking the
439 * mapping process for signed Exp-Golomb codes as specified in
440 * subclause 9.1.1 with codeNum as the input.
442 if(hf_field->type==FT_INT32){
443 if (hf_field->strings) {
444 proto_tree_add_int_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
447 val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
450 switch(hf_field->display){
452 proto_tree_add_int_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
458 DISSECTOR_ASSERT_NOT_REACHED();
467 if(hf_field->type==FT_UINT32){
468 if (hf_field->strings) {
469 proto_tree_add_uint_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
472 val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
475 switch(hf_field->display){
477 proto_tree_add_uint_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
483 proto_tree_add_uint_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
489 DISSECTOR_ASSERT_NOT_REACHED();
494 /* Only allow guint32 */
495 DISSECTOR_ASSERT_NOT_REACHED();
502 Syntax elements coded as ue(v), me(v), or se(v) are Exp-Golomb-coded. Syntax elements coded as te(v) are truncated
503 Exp-Golomb-coded. The parsing process for these syntax elements begins with reading the bits starting at the current
504 location in the bitstream up to and including the first non-zero bit, and counting the number of leading bits that are
505 equal to 0. This process is specified as follows:
506 leadingZeroBits = -1;
507 for( b = 0; !b; leadingZeroBits++ )
509 The variable codeNum is then assigned as follows:
510 codeNum = 2leadingZeroBits - 1 + read_bits( leadingZeroBits )
511 where the value returned from read_bits( leadingZeroBits ) is interpreted as a binary representation of an unsigned
512 integer with most significant bit written first.
515 codenum = codenum << leading_zero_bits;
517 if (leading_zero_bits > 8)
518 value = tvb_get_bits16(tvb, bit_offset,leading_zero_bits, FALSE);
520 value = tvb_get_bits8(tvb, bit_offset,leading_zero_bits );
521 codenum = (codenum-1) + value;
522 bit_offset = bit_offset + leading_zero_bits;
524 /* read the bits for the int */
525 for(i=0;i<leading_zero_bits;i++){
527 g_strlcat(str, " ", 256);
530 g_strlcat(str, " ", 256);
535 g_strlcat(str, "1", 256);
537 g_strlcat(str, "0", 256);
543 g_strlcat(str, " ", 256);
545 g_strlcat(str,".", 256);
550 /* if the syntax element is coded as se(v),
551 * the value of the syntax element is derived by invoking the
552 * mapping process for signed Exp-Golomb codes as specified in
553 * subclause 9.1.1 with codeNum as the input.
557 se_value = (codenum + 1) >> 1;
558 if (!(se_value & 1)){
559 se_value = - se_value;
567 g_strlcat(str," = ", 256);
568 g_strlcat(str,hf_field->name, 256);
571 g_strlcat(str,"(se(v))", 256);
572 /* if the syntax element is coded as se(v),
573 * the value of the syntax element is derived by invoking the
574 * mapping process for signed Exp-Golomb codes as specified in
575 * subclause 9.1.1 with codeNum as the input.
581 if((hf_field->type==FT_UINT32)&&(descriptor==H264_UE_V)){
582 if (hf_field->strings) {
583 proto_tree_add_uint_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
586 val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
589 switch(hf_field->display){
591 proto_tree_add_uint_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
597 proto_tree_add_uint_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
603 DISSECTOR_ASSERT_NOT_REACHED();
607 }else if((hf_field->type==FT_INT32)&&(descriptor==H264_SE_V)){
608 if (hf_field->strings) {
609 proto_tree_add_int_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
612 val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
615 switch(hf_field->display){
617 proto_tree_add_int_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
623 DISSECTOR_ASSERT_NOT_REACHED();
627 *start_bit_offset = bit_offset;
631 /* Only allow guint32 */
632 DISSECTOR_ASSERT_NOT_REACHED();
636 *start_bit_offset = bit_offset;
641 /* This funktion is adapted to parsing NAL units from SDP data where the
642 * base64 coding may add extra padding
646 more_rbsp_data(proto_tree *tree _U_, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
650 int remaining_length;
654 /* XXX might not be the best way of doing things but:
655 * Serch from the end of the tvb for the first '1' bit
656 * assuming that its's the RTBSP stop bit
659 /* Set offset to the byte we are treating */
660 offset = bit_offset>>3;
661 remaining_length = tvb_length_remaining(tvb,offset);
662 /* If there is more then 2 bytes left there *should* be more data */
663 if(remaining_length>2){
666 /* Start from last bit */
667 last_one_bit = (tvb_length(tvb) << 3);
671 b = tvb_get_bits8(tvb, last_one_bit, 1);
674 if( last_one_bit == bit_offset){
682 dissect_h264_rbsp_trailing_bits(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
684 gint remaining_bits=0;
686 proto_tree_add_bits_item(tree, hf_h264_rbsp_stop_bit, tvb, bit_offset, 1, FALSE);
689 if((bit_offset&0x7)!=0){
690 remaining_bits = 8 - (bit_offset&0x7);
691 proto_tree_add_bits_item(tree, hf_h264_rbsp_trailing_bits, tvb, bit_offset, remaining_bits, FALSE);
694 return bit_offset+remaining_bits;
698 * 7.3.3 Slice header syntax
700 * XXX Just parse a few bytes
703 dissect_h264_slice_header(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
705 /* first_mb_in_slice 2 ue(v) */
706 dissect_h264_exp_golomb_code(tree, hf_h264_first_mb_in_slice, tvb, &bit_offset, H264_UE_V);
708 /* slice_type 2 ue(v) */
709 dissect_h264_exp_golomb_code(tree, hf_h264_slice_type, tvb, &bit_offset, H264_UE_V);
711 /* pic_parameter_set_id 2 ue(v) */
712 dissect_h264_exp_golomb_code(tree, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
714 /* frame_num 2 u(v) */
716 * represented by log2_max_frame_num_minus4 + 4 bits in
718 * proto_tree_add_bits_item(tree, hf_h264_frame_num, tvb, bit_offset, 4, FALSE);
726 /* 7.3.2.1.1 Scaling list syntax
728 * scaling_list( scalingList, sizeOfScalingList, useDefaultScalingMatrixFlag )
732 dissect_h264_scaling_list(proto_tree *tree, tvbuff_t *tvb, gint bit_offset, int hf_index_scalinglist,
733 guint8 sizeOfScalingList, int hf_index_usedefaultscalingmatrixflag)
736 guint8 lastScale = 8;
737 guint8 nextScale = 8:
740 for( j = 0; j < sizeOfScalingList; j++ ) {
741 if( nextScale != 0 ) {
742 / delta_scale 0 | 1 se(v) /
743 delta_scale = dissect_h264_exp_golomb_code(tree, hf_h264_delta_scale, tvb, &bit_offset);
744 nextScale = ( lastScale + delta_scale + 256 ) % 256;
745 useDefaultScalingMatrixFlag = ( j == 0 && nextScale == 0 );
747 scalingList[ j ] = ( nextScale == 0 ) ? lastScale : nextScale
748 lastScale = scalingList[ j ]
752 /* E.1.2 HRD parameters syntax */
754 dissect_h264_hrd_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
756 guint8 cpb_cnt_minus1;
760 /* cpb_cnt_minus1 0 ue(v) */
761 cpb_cnt_minus1 = dissect_h264_exp_golomb_code(tree, hf_h264_cpb_cnt_minus1, tvb, &bit_offset, H264_UE_V);
763 /* bit_rate_scale 0 u(4) */
764 proto_tree_add_bits_item(tree, hf_h264_bit_rate_scale, tvb, bit_offset, 4, FALSE);
765 bit_offset = bit_offset + 4;
767 /* cpb_size_scale 0 u(4) */
768 proto_tree_add_bits_item(tree, hf_h264_cpb_size_scale, tvb, bit_offset, 4, FALSE);
769 bit_offset = bit_offset + 4;
770 /* for( SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++ ) { */
771 for( SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++ ) {
773 /* bit_rate_value_minus1[ SchedSelIdx ] 0 ue(v) */
774 dissect_h264_exp_golomb_code(tree, hf_h264_bit_rate_value_minus1, tvb, &bit_offset, H264_UE_V);
776 /* cpb_size_value_minus1[ SchedSelIdx ] 0 ue(v)*/
777 dissect_h264_exp_golomb_code(tree, hf_h264_cpb_size_value_minus1, tvb, &bit_offset, H264_UE_V);
779 /* cbr_flag[ SchedSelIdx ] 0 u(1) */
780 proto_tree_add_bits_item(tree, hf_h264_cbr_flag, tvb, bit_offset, 1, FALSE);
783 /* initial_cpb_removal_delay_length_minus1 0 u(5) */
784 proto_tree_add_bits_item(tree, hf_h264_initial_cpb_removal_delay_length_minus1, tvb, bit_offset, 5, FALSE);
785 bit_offset = bit_offset + 5;
787 /* cpb_removal_delay_length_minus1 0 u(5) */
788 proto_tree_add_bits_item(tree, hf_h264_cpb_removal_delay_length_minus1, tvb, bit_offset, 5, FALSE);
789 bit_offset = bit_offset + 5;
791 /* dpb_output_delay_length_minus1 0 u(5) */
792 proto_tree_add_bits_item(tree, hf_h264_dpb_output_delay_length_minus11, tvb, bit_offset, 5, FALSE);
793 bit_offset = bit_offset + 5;
795 /* time_offset_length 0 u(5) */
796 proto_tree_add_bits_item(tree, hf_h264_time_offset_length, tvb, bit_offset, 5, FALSE);
797 bit_offset = bit_offset + 5;
802 #define EXTENDED_SAR 255
804 /* E.1.1 VUI parameters syntax */
806 dissect_h264_vui_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint bit_offset)
809 guint8 aspect_ratio_info_present_flag, aspect_ratio_idc, overscan_info_present_flag;
810 guint8 video_signal_type_present_flag, colour_description_present_flag, chroma_loc_info_present_flag;
811 guint8 timing_info_present_flag, nal_hrd_parameters_present_flag, vcl_hrd_parameters_present_flag;
812 guint8 bitstream_restriction_flag;
814 /* vui_parameters( ) {
815 * aspect_ratio_info_present_flag 0 u(1)
817 aspect_ratio_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
818 proto_tree_add_bits_item(tree, hf_h264_aspect_ratio_info_present_flag, tvb, bit_offset, 1, FALSE);
821 if( aspect_ratio_info_present_flag ) {
822 /* aspect_ratio_idc 0 u(8) */
823 aspect_ratio_idc = tvb_get_bits8(tvb, bit_offset, 8);
824 proto_tree_add_bits_item(tree, hf_h264_aspect_ratio_idc, tvb, bit_offset, 8, FALSE);
825 bit_offset = bit_offset + 8;
827 if( aspect_ratio_idc == EXTENDED_SAR ) {
828 /* sar_width 0 u(16) */
829 proto_tree_add_bits_item(tree, hf_h264_sar_width, tvb, bit_offset, 16, FALSE);
830 bit_offset = bit_offset + 16;
832 /* sar_height 0 u(16) */
833 proto_tree_add_bits_item(tree, hf_h264_sar_height, tvb, bit_offset, 16, FALSE);
834 bit_offset = bit_offset + 16;
837 /* overscan_info_present_flag 0 u(1) */
838 overscan_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
839 proto_tree_add_bits_item(tree, hf_h264_overscan_info_present_flag, tvb, bit_offset, 1, FALSE);
842 if( overscan_info_present_flag ){
843 /* overscan_appropriate_flag 0 u(1) */
844 proto_tree_add_bits_item(tree, hf_h264_overscan_appropriate_flag, tvb, bit_offset, 1, FALSE);
848 /* video_signal_type_present_flag 0 u(1) */
849 video_signal_type_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
850 proto_tree_add_bits_item(tree, hf_h264_video_signal_type_present_flag, tvb, bit_offset, 1, FALSE);
853 if( video_signal_type_present_flag ) {
854 /* video_format 0 u(3) > */
855 proto_tree_add_bits_item(tree, hf_h264_video_format, tvb, bit_offset, 3, FALSE);
856 bit_offset = bit_offset + 3;
858 /* video_full_range_flag 0 u(1)*/
859 proto_tree_add_bits_item(tree, hf_h264_video_full_range_flag, tvb, bit_offset, 1, FALSE);
862 /* colour_description_present_flag 0 u(1) */
863 colour_description_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
864 proto_tree_add_bits_item(tree, hf_h264_colour_description_present_flag, tvb, bit_offset, 1, FALSE);
867 if( colour_description_present_flag ) {
868 /* colour_primaries 0 u(8) */
869 proto_tree_add_bits_item(tree, hf_h264_colour_primaries, tvb, bit_offset, 8, FALSE);
870 bit_offset = bit_offset + 8;
872 /* transfer_characteristics 0 u(8) */
873 proto_tree_add_bits_item(tree, hf_h264_transfer_characteristics, tvb, bit_offset, 8, FALSE);
874 bit_offset = bit_offset + 8;
876 /* matrix_coefficients 0 u(8)*/
877 proto_tree_add_bits_item(tree, hf_h264_matrix_coefficients, tvb, bit_offset, 8, FALSE);
878 bit_offset = bit_offset + 8;
882 /* chroma_loc_info_present_flag 0 u(1) */
883 chroma_loc_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
884 proto_tree_add_bits_item(tree, hf_h264_chroma_loc_info_present_flag, tvb, bit_offset, 1, FALSE);
887 if( chroma_loc_info_present_flag ) {
888 /* chroma_sample_loc_type_top_field 0 ue(v) */
889 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_sample_loc_type_top_field, tvb, &bit_offset, H264_UE_V);
891 /* chroma_sample_loc_type_bottom_field 0 ue(v) */
892 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_sample_loc_type_bottom_field, tvb, &bit_offset, H264_UE_V);
895 /* timing_info_present_flag 0 u(1) */
896 timing_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
897 proto_tree_add_bits_item(tree, hf_h264_timing_info_present_flag, tvb, bit_offset, 1, FALSE);
900 if( timing_info_present_flag ) {
901 /* num_units_in_tick 0 u(32) */
902 proto_tree_add_bits_item(tree, hf_h264_num_units_in_tick, tvb, bit_offset, 32, FALSE);
903 bit_offset = bit_offset + 32;
905 /* time_scale 0 u(32) */
906 proto_tree_add_bits_item(tree, hf_h264_time_scale, tvb, bit_offset, 32, FALSE);
907 bit_offset = bit_offset + 32;
909 /* fixed_frame_rate_flag 0 u(1) */
910 proto_tree_add_bits_item(tree, hf_h264_fixed_frame_rate_flag, tvb, bit_offset, 1, FALSE);
913 /* nal_hrd_parameters_present_flag 0 u(1) */
914 nal_hrd_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
915 proto_tree_add_bits_item(tree, hf_h264_nal_hrd_parameters_present_flag, tvb, bit_offset, 1, FALSE);
918 if( nal_hrd_parameters_present_flag ){
919 /* hrd_parameters( ) */
920 bit_offset = dissect_h264_hrd_parameters(tree, tvb, pinfo, bit_offset);
923 /* vcl_hrd_parameters_present_flag 0 u(1) */
924 vcl_hrd_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
925 proto_tree_add_bits_item(tree, hf_h264_vcl_hrd_parameters_present_flag, tvb, bit_offset, 1, FALSE);
928 if( vcl_hrd_parameters_present_flag ){
929 /* hrd_parameters( ) */
930 bit_offset = dissect_h264_hrd_parameters(tree, tvb, pinfo, bit_offset);
932 if( nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag ){
933 /* low_delay_hrd_flag 0 u(1) */
934 proto_tree_add_bits_item(tree, hf_h264_low_delay_hrd_flag, tvb, bit_offset, 1, FALSE);
937 /* pic_struct_present_flag 0 u(1) */
938 proto_tree_add_bits_item(tree, hf_h264_pic_struct_present_flag, tvb, bit_offset, 1, FALSE);
941 /* bitstream_restriction_flag 0 u(1) */
942 bitstream_restriction_flag = tvb_get_bits8(tvb, bit_offset, 1);
943 proto_tree_add_bits_item(tree, hf_h264_bitstream_restriction_flag, tvb, bit_offset, 1, FALSE);
946 if( bitstream_restriction_flag ) {
947 /* motion_vectors_over_pic_boundaries_flag 0 u(1) */
948 proto_tree_add_bits_item(tree, hf_h264_motion_vectors_over_pic_boundaries_flag, tvb, bit_offset, 1, FALSE);
951 /* max_bytes_per_pic_denom 0 ue(v) */
952 dissect_h264_exp_golomb_code(tree, hf_h264_max_bytes_per_pic_denom, tvb, &bit_offset, H264_UE_V);
954 /* max_bits_per_mb_denom 0 ue(v) */
955 dissect_h264_exp_golomb_code(tree, hf_h264_max_bits_per_mb_denom, tvb, &bit_offset, H264_UE_V);
957 /* log2_max_mv_length_horizontal 0 ue(v) */
958 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_mv_length_horizontal, tvb, &bit_offset, H264_UE_V);
960 /* log2_max_mv_length_vertical 0 ue(v) */
961 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_mv_length_vertical, tvb, &bit_offset, H264_UE_V);
963 /* num_reorder_frames 0 ue(v) */
964 dissect_h264_exp_golomb_code(tree, hf_h264_num_reorder_frames, tvb, &bit_offset, H264_UE_V);
966 /* max_dec_frame_buffering 0 ue(v) */
967 dissect_h264_exp_golomb_code(tree, hf_h264_max_dec_frame_buffering, tvb, &bit_offset, H264_UE_V);
974 /* Used To dissect SDP parameter (H.264)profile */
976 dissect_h264_profile(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
978 proto_item *item, *level_item;
979 proto_tree *h264_profile_tree;
981 guint8 constraint_set3_flag;
984 item = proto_tree_add_item(tree, hf_h264_profile, tvb, offset, -1, FALSE);
985 h264_profile_tree = proto_item_add_subtree(item, ett_h264_profile);
987 proto_tree_add_item(h264_profile_tree, hf_h264_profile_idc, tvb, offset, 1, FALSE);
990 constraint_set3_flag = (tvb_get_guint8(tvb,offset)&0x10)>>4;
991 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set0_flag, tvb, offset, 1, FALSE);
992 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set1_flag, tvb, offset, 1, FALSE);
993 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set2_flag, tvb, offset, 1, FALSE);
994 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set3_flag, tvb, offset, 1, FALSE);
995 proto_tree_add_item(h264_profile_tree, hf_h264_reserved_zero_4bits, tvb, offset, 1, FALSE);
998 /* A level to which the bitstream conforms shall be indicated by the syntax element level_idc as follows.
999 * - If level_idc is equal to 11 and constraint_set3_flag is equal to 1, the indicated level is level 1b.
1000 * - Otherwise (level_idc is not equal to 11 or constraint_set3_flag is not equal to 1), level_idc shall
1001 * be set equal to a value of ten times the level number specified in Table A-1 and constraint_set3_flag
1002 * shall be set equal to 0.
1005 level_idc = tvb_get_guint8(tvb,offset);
1006 level_item = proto_tree_add_item(h264_profile_tree, hf_h264_level_idc, tvb, offset, 1, FALSE);
1007 if((level_idc==11)&&(constraint_set3_flag==1)){
1008 proto_item_append_text(level_item," [Level 1b (128kb/s)]");
1010 proto_item_append_text(level_item," [Level %.1f %s]",((double)level_idc/10),val_to_str(level_idc, h264_level_bitrate_values, "Unknown "));
1016 * 7.3.2.8 Slice layer without partitioning RBSP syntax
1017 * slice_layer_without_partitioning_rbsp( )
1021 dissect_h264_slice_layer_without_partitioning_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1025 bit_offset = offset <<3;
1027 /* slice_header( ) 2 */
1028 bit_offset = dissect_h264_slice_header(tree, tvb, pinfo, bit_offset);
1029 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1031 /* slice_data( ) * all categories of slice_data( ) syntax * 2 | 3 | 4 */
1032 /* rbsp_slice_trailing_bits( ) */
1037 * 7.3.2.9.1 Slice data partition A RBSP syntax
1038 * slice_data_partition_a_layer_rbsp( )
1041 dissect_h264_slice_data_partition_a_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1045 bit_offset = offset <<3;
1047 /* slice_header( ) 2 */
1048 bit_offset = dissect_h264_slice_header(tree, tvb, pinfo, bit_offset);
1050 /* slice_id All ue(v) */
1051 dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1052 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1054 /* slice_data( ) * only category 2 parts of slice_data( ) syntax * 2*/
1055 /* rbsp_slice_trailing_bits( )*/
1060 * 7.3.2.9.2 Slice data partition B RBSP syntax
1061 * slice_data_partition_b_layer_rbsp(
1064 dissect_h264_slice_data_partition_b_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1068 bit_offset = offset <<3;
1070 /* slice_id All ue(v) */
1071 dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1072 /* if( redundant_pic_cnt_present_flag ) */
1073 /* redundant_pic_cnt All ue(v) */
1074 /* slice_data( ) * only category 3 parts of slice_data( ) syntax * 3 */
1075 /* rbsp_slice_trailing_bits( ) 3 */
1076 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1081 * 7.3.2.9.3 Slice data partition C RBSP syntax
1082 * slice_data_partition_c_layer_rbsp( )
1085 dissect_h264_slice_data_partition_c_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1089 bit_offset = offset <<3;
1091 /* slice_id All ue(v) */
1092 dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1093 /* if( redundant_pic_cnt_present_flag ) */
1094 /* redundant_pic_cnt All ue(v) */
1095 /* slice_data( ) * only category 4 parts of slice_data( ) syntax * 4 */
1096 /* rbsp_slice_trailing_bits( ) 4 */
1097 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1100 /* D.1.6 User data unregistered SEI message syntax */
1103 h264_user_data_unregistered(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset, guint32 payloadSize)
1105 /* user_data_unregistered( payloadSize ) { C Descriptor */
1106 /* uuid_iso_iec_11578 5 u(128)
1107 * uuid_iso_iec_11578 shall have a value specified as a UUID
1108 * according to the procedures of ISO/IEC 11578:1996 Annex A.
1110 proto_tree_add_text(tree, tvb, bit_offset>>3, 16, "uuid_iso_iec_1157");
1112 /* for( i = 16; i < payloadSize; i++ )
1113 * user_data_payload_byte 5 b(8)
1115 proto_tree_add_text(tree, tvb, bit_offset>>3, payloadSize-16, "user_data_payload");
1116 bit_offset+=(payloadSize-16)<<3;
1120 /* D.1 SEI payload syntax */
1121 static const value_string h264_sei_payload_vals[] = {
1122 { 0, "buffering_period" },
1123 { 1, "pic_timing" },
1124 { 2, "pan_scan_rect" },
1125 { 3, "filler_payload" },
1126 { 4, "user_data_registered_itu_t_t35" },
1127 { 5, "user_data_unregistered" },
1128 { 6, "recovery_point" },
1129 { 7, "dec_ref_pic_marking_repetition" },
1131 { 9, "scene_inf)" },
1132 { 10, "sub_seq_info)" },
1133 { 11, "sub_seq_layer_characteristics" },
1134 { 12, "sub_seq_characteristics" },
1135 { 13, "full_frame_freeze_release" },
1136 { 14, "full_frame_freeze_release" },
1137 { 15, "full_frame_snapshot" },
1138 { 16, "progressive_refinement_segment_start" },
1139 { 17, "progressive_refinement_segment_end" },
1140 { 18, "motion_constrained_slice_group_set" },
1141 { 19, "film_grain_characteristics)" },
1142 { 20, "deblocking_filter_display_preference)" },
1143 { 21, "stereo_video_info)" },
1144 { 22, "reserved_sei_message)" },
1149 h264_sei_payload(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset, guint32 payloadType, guint32 payloadSize)
1151 /* sei_payload( payloadType, payloadSize ) { C Descriptor */
1152 if( payloadType == 0 ){
1153 /* buffering_period( payloadSize ) 5 */
1154 bit_offset = bit_offset +(payloadSize<<3);
1156 }else if( payloadType == 1 ){
1157 /* pic_timing( payloadSize ) 5 */
1158 }else if( payloadType == 2 ){
1159 /* pan_scan_rect( payloadSize ) 5 */
1160 }else if( payloadType == 3 ){
1161 /* filler_payload( payloadSize ) 5 */
1162 }else if( payloadType == 4 ){
1163 /* user_data_registered_itu_t_t35( payloadSize ) 5 */
1165 }else if( payloadType == 5 ){
1166 /* user_data_unregistered( payloadSize ) 5 */
1167 bit_offset = h264_user_data_unregistered( tree, tvb, pinfo, bit_offset, payloadSize);
1168 }else if( payloadType == 6 ){
1169 /* recovery_point( payloadSize ) 5 */
1170 bit_offset = bit_offset +(payloadSize<<3);
1171 }else if( payloadType == 7 ){
1172 /* dec_ref_pic_marking_repetition( payloadSize ) 5 */
1173 bit_offset = bit_offset +(payloadSize<<3);
1176 else if( payloadType == 8 )
1177 spare_pic( payloadSize ) 5
1178 else if( payloadType == 9 )
1179 scene_info( payloadSize ) 5
1180 else if( payloadType == 10 )
1181 sub_seq_info( payloadSize ) 5
1182 else if( payloadType == 11 )
1183 sub_seq_layer_characteristics( payloadSize ) 5
1184 else if( payloadType == 12 )
1185 sub_seq_characteristics( payloadSize ) 5
1186 else if( payloadType == 13 )
1187 full_frame_freeze( payloadSize ) 5
1188 else if( payloadType == 14 )
1189 full_frame_freeze_release( payloadSize ) 5
1190 else if( payloadType == 15 )
1191 full_frame_snapshot( payloadSize ) 5
1192 else if( payloadType == 16 )
1193 progressive_refinement_segment_start( payloadSize ) 5
1194 else if( payloadType == 17 )
1195 progressive_refinement_segment_end( payloadSize ) 5
1196 else if( payloadType == 18 )
1197 motion_constrained_slice_group_set( payloadSize ) 5
1198 else if( payloadType == 19 )
1199 film_grain_characteristics( payloadSize ) 5
1200 else if( payloadType == 20 )
1201 deblocking_filter_display_preference( payloadSize ) 5
1202 else if( payloadType == 21 )
1203 stereo_video_info( payloadSize ) 5
1205 reserved_sei_message( payloadSize ) 5
1208 if( !h264_byte_aligned(bit_offset)){
1209 /* bit_equal_to_one / * equal to 1 * / 5 f(1) */
1210 /* TODO:Display the filler and, error if not 1 ?? */
1212 while( !h264_byte_aligned(bit_offset)){
1213 /* bit_equal_to_zero / * equal to 0 * / 5 f(1) */
1214 /* TODO:Display the filler and, error if not 0 ?? */
1222 * 7.3.2.3.1 Supplemental enhancement information message syntax
1225 dissect_h264_sei_message(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint bit_offset)
1227 /* sei_message( ) { C Descriptor */
1228 guint32 payloadType = 0, payloadSize;
1229 gint start_bit_offset, length;
1231 start_bit_offset = bit_offset;
1233 /* while( next_bits( 8 ) == 0xFF ) { */
1234 while( tvb_get_bits8(tvb, bit_offset, 8) == 0xFF ) {
1235 /* ff_byte / * equal to 0xFF * / 5 f(8) */
1239 /* last_payload_type_byte 5 u(8) */
1240 payloadType += tvb_get_bits8(tvb, bit_offset, 8);
1242 length = (bit_offset - start_bit_offset)>>3;
1244 proto_tree_add_uint(tree, hf_h264_payloadtype, tvb, start_bit_offset>>3, length, payloadType);
1247 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_size_byte 5 u(8) */
1255 /* payloadSize += last_payload_size_byte */
1256 payloadSize += tvb_get_bits8(tvb, bit_offset, 8);
1258 length = (bit_offset - start_bit_offset)>>3;
1259 proto_tree_add_uint(tree, hf_h264_payloadsize, tvb, start_bit_offset>>3, length, payloadSize);
1261 /*sei_payload( payloadType, payloadSize ) 5 */
1262 bit_offset = h264_sei_payload( tree, tvb, pinfo, bit_offset, payloadType, payloadSize);
1266 * 7.3.2.3 Supplemental enhancement information RBSP syntax
1270 dissect_h264_sei_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1274 bit_offset = offset <<3;
1276 /* sei_message( ) 5*/
1277 bit_offset = dissect_h264_sei_message( tree, tvb, pinfo, bit_offset);
1279 /* while( more_rbsp_data( ) )
1280 * If there is more data in an RBSP before rbsp_trailing_bits( ),
1281 * the return value of more_rbsp_data( ) is equal to TRUE.
1283 /* rbsp_trailing_bits( ) 5 */
1284 bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1288 /* Ref 7.3.2.1 Sequence parameter set RBSP syntax */
1290 dissect_h264_seq_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1292 proto_item *level_item;
1294 guint8 constraint_set3_flag;
1298 guint8 profile_idc, chroma_format_idc, frame_mbs_only_flag, frame_cropping_flag;
1299 guint8 pic_order_cnt_type, vui_parameters_present_flag, num_ref_frames_in_pic_order_cnt_cycle;
1300 guint8 seq_scaling_matrix_present_flag; /* seq_scaling_list_present_flag */
1302 /* profile_idc 0 u(8) */
1303 profile_idc = tvb_get_guint8(tvb,offset);
1304 proto_tree_add_item(tree, hf_h264_profile_idc, tvb, offset, 1, FALSE);
1307 constraint_set3_flag = (tvb_get_guint8(tvb,offset)&0x10)>>4;
1308 /* constraint_set0_flag 0 u(1) */
1309 proto_tree_add_item(tree, hf_h264_constraint_set0_flag, tvb, offset, 1, FALSE);
1311 /* constraint_set1_flag 0 u(1) */
1312 proto_tree_add_item(tree, hf_h264_constraint_set1_flag, tvb, offset, 1, FALSE);
1314 /* constraint_set2_flag 0 u(1) */
1315 proto_tree_add_item(tree, hf_h264_constraint_set2_flag, tvb, offset, 1, FALSE);
1317 /* constraint_set3_flag 0 u(1) */
1318 proto_tree_add_item(tree, hf_h264_constraint_set3_flag, tvb, offset, 1, FALSE);
1320 /* reserved_zero_4bits equal to 0 0 u(4)*/
1321 proto_tree_add_item(tree, hf_h264_reserved_zero_4bits, tvb, offset, 1, FALSE);
1324 /* level_idc 0 u(8) */
1325 level_idc = tvb_get_guint8(tvb,offset);
1326 level_item = proto_tree_add_item(tree, hf_h264_level_idc, tvb, offset, 1, FALSE);
1327 if((level_idc==11)&&(constraint_set3_flag==1)){
1328 proto_item_append_text(level_item,"[Level 1b]");
1330 proto_item_append_text(level_item," [Level %.1f %s]",((double)level_idc/10),val_to_str(level_idc, h264_level_bitrate_values, "Unknown "));
1333 /* seq_parameter_set_id 0 ue(v)
1334 * ue(v): unsigned integer Exp-Golomb-coded syntax element with the left bit first.
1335 * The parsing process for this descriptor is specified in subclause 9.1.
1337 bit_offset = offset<<3;
1338 dissect_h264_exp_golomb_code(tree, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1341 if( profile_idc == 100 || profile_idc == 110 ||
1342 profile_idc == 122 || profile_idc == 144 ) {
1344 /* chroma_format_idc 0 ue(v) */
1345 chroma_format_idc = dissect_h264_exp_golomb_code(tree, hf_h264_chroma_format_idc, tvb, &bit_offset, H264_UE_V);
1346 if( chroma_format_idc == 3 ){
1347 /* residual_colour_transform_flag 0 u(1) */
1348 proto_tree_add_bits_item(tree, hf_h264_residual_colour_transform_flag, tvb, bit_offset, 1, FALSE);
1352 /* bit_depth_luma_minus8 0 ue(v) */
1353 dissect_h264_exp_golomb_code(tree, hf_h264_bit_depth_luma_minus8, tvb, &bit_offset, H264_UE_V);
1355 /* bit_depth_chroma_minus8 0 ue(v) */
1356 dissect_h264_exp_golomb_code(tree, hf_h264_bit_depth_chroma_minus8, tvb, &bit_offset, H264_UE_V);
1358 /* qpprime_y_zero_transform_bypass_flag 0 u(1) */
1359 proto_tree_add_bits_item(tree, hf_h264_qpprime_y_zero_transform_bypass_flag, tvb, bit_offset, 1, FALSE);
1362 /* seq_scaling_matrix_present_flag 0 u(1) */
1363 seq_scaling_matrix_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1364 proto_tree_add_bits_item(tree, hf_h264_seq_scaling_matrix_present_flag, tvb, bit_offset, 1, FALSE);
1367 if( seq_scaling_matrix_present_flag ){
1369 for( i = 0; i < 8; i++ ) {
1370 / seq_scaling_list_present_flag[ i ] 0 u(1) /
1371 seq_scaling_list_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1373 if( seq_scaling_list_present_flag){
1375 scaling_list( ScalingList4x4[ i ], 16,UseDefaultScalingMatrix4x4Flag[ i ])0
1376 dissect_h264_scaling_list()
1378 scaling_list( ScalingList8x8[ i - 6 ], 64,UseDefaultScalingMatrix8x8Flag[ i - 6 ] )0
1382 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1388 /* log2_max_frame_num_minus4 0 ue(v) */
1389 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_frame_num_minus4, tvb, &bit_offset, H264_UE_V);
1391 /* pic_order_cnt_type 0 ue(v) */
1392 offset = bit_offset>>3;
1393 pic_order_cnt_type = dissect_h264_exp_golomb_code(tree,hf_h264_pic_order_cnt_type, tvb, &bit_offset, H264_UE_V);
1395 if(pic_order_cnt_type == 0){
1396 /* log2_max_pic_order_cnt_lsb_minus4 0 ue(v) */
1397 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_pic_order_cnt_lsb_minus4, tvb, &bit_offset, H264_UE_V);
1398 }else if(pic_order_cnt_type == 1) {
1399 /* delta_pic_order_always_zero_flag 0 u(1) */
1400 proto_tree_add_bits_item(tree, hf_h264_delta_pic_order_always_zero_flag, tvb, bit_offset, 1, FALSE);
1403 /* offset_for_non_ref_pic 0 se(v) */
1404 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_non_ref_pic, tvb, &bit_offset, H264_SE_V);
1406 /* offset_for_top_to_bottom_field 0 se(v) */
1407 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_top_to_bottom_field, tvb, &bit_offset, H264_SE_V);
1409 /* num_ref_frames_in_pic_order_cnt_cycle 0 ue(v) */
1410 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);
1411 for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ ){
1412 /*offset_for_ref_frame[ i ] 0 se(v)*/
1413 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_ref_frame, tvb, &bit_offset, H264_SE_V);
1416 /* num_ref_frames 0 ue(v) */
1417 dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_frames, tvb, &bit_offset, H264_UE_V);
1419 /* gaps_in_frame_num_value_allowed_flag 0 u(1) */
1420 proto_tree_add_bits_item(tree, hf_h264_gaps_in_frame_num_value_allowed_flag, tvb, bit_offset, 1, FALSE);
1423 /* pic_width_in_mbs_minus1 0 ue(v) */
1424 dissect_h264_exp_golomb_code(tree, hf_h264_pic_width_in_mbs_minus1, tvb, &bit_offset, H264_UE_V);
1426 /* pic_height_in_map_units_minus1 0 ue(v) */
1427 dissect_h264_exp_golomb_code(tree, hf_h264_pic_height_in_map_units_minus1, tvb, &bit_offset, H264_UE_V);
1429 /* frame_mbs_only_flag 0 u(1) */
1430 frame_mbs_only_flag = tvb_get_bits8(tvb, bit_offset, 1);
1431 proto_tree_add_bits_item(tree, hf_h264_frame_mbs_only_flag, tvb, bit_offset, 1, FALSE);
1433 if( !frame_mbs_only_flag ){
1434 /* mb_adaptive_frame_field_flag 0 u(1) */
1435 proto_tree_add_bits_item(tree, hf_h264_mb_adaptive_frame_field_flag, tvb, bit_offset, 1, FALSE);
1439 /* direct_8x8_inference_flag 0 u(1) */
1440 proto_tree_add_bits_item(tree, hf_h264_direct_8x8_inference_flag, tvb, bit_offset, 1, FALSE);
1443 /* frame_cropping_flag 0 u(1) */
1444 frame_cropping_flag = tvb_get_bits8(tvb, bit_offset, 1);
1445 proto_tree_add_bits_item(tree, hf_h264_frame_cropping_flag, tvb, bit_offset, 1, FALSE);
1448 if(frame_cropping_flag) {
1449 /* frame_crop_left_offset 0 ue(v) */
1450 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_left_offset, tvb, &bit_offset, H264_UE_V);
1451 dissect_h264_exp_golomb_code(tree,hf_h264_frame_crop_right_offset, tvb, &bit_offset, H264_UE_V);
1452 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_top_offset, tvb, &bit_offset, H264_UE_V);
1453 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_bottom_offset, tvb, &bit_offset, H264_UE_V);
1457 /* vui_parameters_present_flag 0 u(1) */
1458 vui_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1459 proto_tree_add_bits_item(tree, hf_h264_vui_parameters_present_flag, tvb, bit_offset, 1, FALSE);
1461 if(vui_parameters_present_flag){
1462 bit_offset = dissect_h264_vui_parameters(tree, tvb, pinfo, bit_offset);
1465 /* rbsp_trailing_bits( ) 0 */
1466 bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1468 offset = bit_offset>>3;
1473 /* 7.3.2.2 Picture parameter set RBSP syntax */
1476 dissect_h264_pic_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1480 guint32 num_slice_groups_minus1, slice_group_map_type, pic_scaling_matrix_present_flag;
1482 bit_offset = offset<<3;
1484 /* pic_parameter_set_id 1 ue(v) */
1485 dissect_h264_exp_golomb_code(tree, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1487 /* seq_parameter_set_id 1 ue(v) */
1488 dissect_h264_exp_golomb_code(tree, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1490 /* entropy_coding_mode_flag 1 u(1) */
1491 proto_tree_add_bits_item(tree, hf_h264_entropy_coding_mode_flag, tvb, bit_offset, 1, FALSE);
1494 /* pic_order_present_flag 1 u(1)*/
1495 proto_tree_add_bits_item(tree, hf_h264_pic_order_present_flag, tvb, bit_offset, 1, FALSE);
1498 /* num_slice_groups_minus1 1 ue(v)*/
1499 num_slice_groups_minus1 = dissect_h264_exp_golomb_code(tree, hf_h264_num_slice_groups_minus1, tvb, &bit_offset, H264_UE_V);
1500 if( num_slice_groups_minus1 > 0 ) {
1501 /* slice_group_map_type 1 ue(v)*/
1502 slice_group_map_type = dissect_h264_exp_golomb_code(tree, hf_h264_slice_group_map_type, tvb, &bit_offset, H264_UE_V);
1503 /* if( slice_group_map_type == 0 )*/
1504 /* for( iGroup = 0; iGroup <= num_slice_groups_minus1; iGroup++ )*/
1505 /* run_length_minus1[ iGroup ] 1 ue(v)*/
1506 /* else if( slice_group_map_type == 2 )*/
1507 /* for( iGroup = 0; iGroup < num_slice_groups_minus1; iGroup++ ) {*/
1508 /* top_left[ iGroup ] 1 ue(v)*/
1509 /* bottom_right[ iGroup ] 1 ue(v)*/
1511 /* else if( slice_group_map_type == 3 ||*/
1512 /* slice_group_map_type == 4 ||*/
1513 /* slice_group_map_type == 5 ) {*/
1514 /* slice_group_change_direction_flag 1 u(1)*/
1515 /* slice_group_change_rate_minus1 1 ue(v)*/
1516 /* } else if( slice_group_map_type == 6 ) {*/
1517 /* pic_size_in_map_units_minus1 1 ue(v)*/
1518 /* for( i = 0; i <= pic_size_in_map_units_minus1; i++ )*/
1519 /* slice_group_id[ i ] 1 u(v)*/
1522 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1525 /* num_ref_idx_l0_active_minus1 1 ue(v)*/
1526 dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_idx_l0_active_minus1, tvb, &bit_offset, H264_UE_V);
1528 /* num_ref_idx_l1_active_minus1 1 ue(v)*/
1529 dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_idx_l1_active_minus1, tvb, &bit_offset, H264_UE_V);
1531 /* weighted_pred_flag 1 u(1)*/
1532 proto_tree_add_bits_item(tree, hf_h264_weighted_pred_flag, tvb, bit_offset, 1, FALSE);
1535 /* weighted_bipred_idc 1 u(2)*/
1536 proto_tree_add_bits_item(tree, hf_h264_weighted_bipred_idc, tvb, bit_offset, 2, FALSE);
1537 bit_offset= bit_offset+2;
1539 /* pic_init_qp_minus26 * relative to 26 * 1 se(v)*/
1540 dissect_h264_exp_golomb_code(tree, hf_h264_pic_init_qp_minus26, tvb, &bit_offset, H264_SE_V);
1542 /* pic_init_qs_minus26 * relative to 26 * 1 se(v)*/
1543 dissect_h264_exp_golomb_code(tree, hf_h264_pic_init_qs_minus26, tvb, &bit_offset, H264_SE_V);
1545 /* chroma_qp_index_offset 1 se(v)*/
1546 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
1548 /* deblocking_filter_control_present_flag 1 u(1)*/
1549 proto_tree_add_bits_item(tree, hf_h264_deblocking_filter_control_present_flag, tvb, bit_offset, 1, FALSE);
1552 /* constrained_intra_pred_flag 1 u(1)*/
1553 proto_tree_add_bits_item(tree, hf_h264_constrained_intra_pred_flag, tvb, bit_offset, 1, FALSE);
1556 /* redundant_pic_cnt_present_flag 1 u(1)*/
1557 proto_tree_add_bits_item(tree, hf_h264_redundant_pic_cnt_present_flag, tvb, bit_offset, 1, FALSE);
1560 if( more_rbsp_data(tree, tvb, pinfo, bit_offset)){
1561 /* transform_8x8_mode_flag 1 u(1)*/
1562 proto_tree_add_bits_item(tree, hf_h264_transform_8x8_mode_flag, tvb, bit_offset, 1, FALSE);
1565 /* pic_scaling_matrix_present_flag 1 u(1)*/
1566 pic_scaling_matrix_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1567 proto_tree_add_bits_item(tree, hf_h264_pic_scaling_matrix_present_flag, tvb, bit_offset, 1, FALSE);
1570 if( pic_scaling_matrix_present_flag ){
1571 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1573 /* for( i = 0; i < 6 + 2* transform_8x8_mode_flag; i++ ) {*/
1574 /* pic_scaling_list_present_flag[ i ] 1 u(1)*/
1575 /* if( pic_scaling_list_present_flag[ i ] )*/
1577 /* scaling_list( ScalingList4x4[ i ], 16, UseDefaultScalingMatrix4x4Flag[ i ] )*/
1579 /* scaling_list( ScalingList8x8[ i - 6 ], 64, UseDefaultScalingMatrix8x8Flag[ i - 6 ] )*/
1583 /* second_chroma_qp_index_offset 1 se(v)*/
1584 dissect_h264_exp_golomb_code(tree, hf_h264_second_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
1586 bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1591 * 7.3.2.4 Access unit delimiter RBSP syntax
1592 * access_unit_delimiter_rbsp( )
1595 dissect_h264_access_unit_delimiter_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1597 /* primary_pic_type 6 u(3) */
1598 /* rbsp_trailing_bits( ) 6 */
1599 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1604 * 7.3.2.5 End of sequence RBSP syntax
1605 * end_of_seq_rbsp( ) {}
1608 dissect_h264_end_of_seq_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1610 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1615 * 7.3.2.6 End of stream RBSP syntax
1616 * end_of_stream_rbsp( ) {}
1619 dissect_h264_end_of_stream_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1621 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1626 * 7.3.2.7 Filler data RBSP syntax
1627 * filler_data_rbsp( )
1630 dissect_h264_filler_data_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1632 /* while( next_bits( 8 ) == 0xFF ) */
1633 /* ff_byte * equal to 0xFF * 9 f(8) */
1634 /* rbsp_trailing_bits( ) 9 */
1635 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1640 * 7.3.2.1.2 Sequence parameter set extension RBSP syntax
1641 * seq_parameter_set_extension_rbsp( )
1644 dissect_h264_seq_parameter_set_extension_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1646 /* seq_parameter_set_id 10 ue(v) */
1647 /* aux_format_idc 10 ue(v) */
1648 /* if( aux_format_idc != 0 ) { */
1649 /* bit_depth_aux_minus8 10 ue(v) */
1650 /* alpha_incr_flag 10 u(1) */
1651 /* alpha_opaque_value 10 u(v) */
1652 /* alpha_transparent_value 10 u(v) */
1654 /* additional_extension_flag 10 u(1) */
1655 /* rbsp_trailing_bits() 10 */
1656 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1662 * Dissect NAL unit as recived in sprop-parameter-sets of SDP
1663 * or "DecoderConfiguration parameter in H.245
1666 dissect_h264_nal_unit(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1669 proto_tree *h264_nal_tree;
1671 guint8 nal_unit_type;
1673 item = proto_tree_add_item(tree, hf_h264_nal_unit, tvb, offset, -1, FALSE);
1674 h264_nal_tree = proto_item_add_subtree(item, ett_h264_nal_unit);
1677 /* In decoder configuration start code may be pressent
1678 * B.1.1 Byte stream NAL unit syntax
1680 dword = tvb_get_bits32(tvb, offset<<3, 32, FALSE);
1682 /* zero_byte + start_code_prefix_one_3bytes */
1684 }else if((dword >> 8)== 1){
1685 /* start_code_prefix_one_3bytes */
1688 /* Ref: 7.3.1 NAL unit syntax */
1689 nal_unit_type = tvb_get_guint8(tvb,offset) & 0x1f;
1691 /* forbidden_zero_bit All f(1) */
1692 proto_tree_add_item(h264_nal_tree, hf_h264_forbidden_zero_bit, tvb, offset, 1, FALSE);
1693 /* nal_ref_idc All u(2) */
1694 proto_tree_add_item(h264_nal_tree, hf_h264_nal_ref_idc, tvb, offset, 1, FALSE);
1695 /* nal_unit_type All u(5) */
1696 proto_tree_add_item(h264_nal_tree, hf_h264_nal_unit_type, tvb, offset, 1, FALSE);
1699 switch(nal_unit_type){
1700 case 0: /* Unspecified */
1701 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Unspecified NAL unit type");
1703 case 1: /* Coded slice of a non-IDR picture */
1704 dissect_h264_slice_layer_without_partitioning_rbsp(h264_nal_tree, tvb, pinfo, offset);
1706 case 2: /* Coded slice data partition A */
1707 dissect_h264_slice_data_partition_a_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1709 case 3: /* Coded slice data partition B */
1710 dissect_h264_slice_data_partition_b_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1712 case 4: /* Coded slice data partition C */
1713 dissect_h264_slice_data_partition_c_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1715 case 5: /* Coded slice of an IDR picture */
1716 dissect_h264_slice_layer_without_partitioning_rbsp(h264_nal_tree, tvb, pinfo, offset);
1718 case 6: /* Supplemental enhancement information (SEI) */
1719 dissect_h264_sei_rbsp(h264_nal_tree, tvb, pinfo, offset);
1721 case H264_SEQ_PAR_SET: /* 7 Sequence parameter set*/
1722 offset = dissect_h264_seq_parameter_set_rbsp(h264_nal_tree, tvb, pinfo, offset);
1724 if(tvb_length_remaining(tvb,offset) > 0){
1725 /* In this case length = offset as we start from zero */
1726 proto_item_set_len(item, offset/*Length */);
1727 item = proto_tree_add_item(tree, hf_h264_nal_unit, tvb, offset, -1, FALSE);
1728 h264_nal_tree = proto_item_add_subtree(item, ett_h264_nal_unit);
1732 case H264_PIC_PAR_SET: /* 8 Picture parameter set */
1733 dissect_h264_pic_parameter_set_rbsp(h264_nal_tree, tvb, pinfo, offset);
1735 case 9: /* Access unit delimiter */
1736 dissect_h264_access_unit_delimiter_rbsp(h264_nal_tree, tvb, pinfo, offset);
1738 case 10: /* End of sequence */
1739 dissect_h264_end_of_seq_rbsp(h264_nal_tree, tvb, pinfo, offset);
1741 case 11: /* End of stream */
1742 dissect_h264_end_of_stream_rbsp(h264_nal_tree, tvb, pinfo, offset);
1744 case 12: /* Filler data */
1745 dissect_h264_filler_data_rbsp(h264_nal_tree, tvb, pinfo, offset);
1747 case 13: /* Sequence parameter set extension */
1748 dissect_h264_seq_parameter_set_extension_rbsp(h264_nal_tree, tvb, pinfo, offset);
1750 case 14: /* Reserved */
1751 case 15: /* Reserved */
1752 case 16: /* Reserved */
1753 case 17: /* Reserved */
1754 case 18: /* Reserved */
1755 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Reserved NAL unit type");
1757 case 19: /* Coded slice of an auxiliary coded picture without partitioning */
1758 dissect_h264_slice_layer_without_partitioning_rbsp(tree, tvb, pinfo, offset);
1761 dissect_h264_slice_layer_without_partitioning_rbsp(tree, tvb, pinfo, offset);
1764 /* 24..31 Unspecified */
1765 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Unspecified NAL unit type");
1770 /* Code to actually dissect the packets */
1772 dissect_h264(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1775 proto_item *item, *ti, *stream_item, *fua_item;
1776 proto_tree *h264_tree, *h264_nal_tree, *stream_tree, *fua_tree;
1780 /* Make entries in Protocol column and Info column on summary display */
1781 col_set_str(pinfo->cinfo, COL_PROTOCOL, "H264");
1784 item = proto_tree_add_item(tree, proto_h264, tvb, 0, -1, FALSE);
1785 h264_tree = proto_item_add_subtree(item, ett_h264);
1787 type = tvb_get_guint8(tvb,offset)&0x1f;
1788 /* if the type is 28, it would be draw another title */
1790 ti = proto_tree_add_text(h264_tree, tvb, offset, 1, "FU identifier");
1792 ti = proto_tree_add_text(h264_tree, tvb, offset, 1, "NAL unit header or first byte of the payload");
1793 h264_nal_tree = proto_item_add_subtree(ti, ett_h264_nal);
1795 /* +---------------+
1803 * forbidden_zero_bit. A value of 0 indicates that the NAL unit type
1804 * octet and payload should not contain bit errors or other syntax
1805 * violations. A value of 1 indicates that the NAL unit type octet
1806 * and payload may contain bit errors or other syntax violations.
1808 proto_tree_add_item(h264_nal_tree, hf_h264_nal_f_bit, tvb, offset, 1, FALSE);
1809 proto_tree_add_item(h264_nal_tree, hf_h264_nal_nri, tvb, offset, 1, FALSE);
1810 if (check_col(pinfo->cinfo, COL_INFO)){
1811 col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
1812 val_to_str(type, h264_type_values, "Unknown Type (%u)"));
1815 proto_tree_add_item(h264_nal_tree, hf_h264_type, tvb, offset, 1, FALSE);
1818 fua_item = proto_tree_add_text(h264_tree, tvb, offset, 1, "FU Header");
1819 fua_tree = proto_item_add_subtree(fua_item, ett_h264_fua);
1820 proto_tree_add_item(fua_tree, hf_h264_start_bit, tvb, offset, 1, FALSE);
1821 proto_tree_add_item(fua_tree, hf_h264_end_bit, tvb, offset, 1, FALSE);
1822 proto_tree_add_item(fua_tree, hf_h264_forbidden_bit, tvb, offset, 1, FALSE);
1823 proto_tree_add_item(fua_tree, hf_h264_nal_unit_type, tvb, offset, 1, FALSE);
1824 if ( (tvb_get_guint8(tvb,offset)&0x80) == 0x80 ){
1825 type = tvb_get_guint8(tvb,offset)&0x1f;
1831 stream_item =proto_tree_add_text(h264_tree, tvb, offset, -1, "H264 bitstream");
1832 stream_tree = proto_item_add_subtree(stream_item, ett_h264_stream);
1834 case 1: /* 1 Coded slice of a non-IDR picture */
1835 dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, tvb, pinfo, offset);
1837 case 3: /* Coded slice data partition B */
1838 dissect_h264_slice_data_partition_b_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1840 case 4: /* Coded slice data partition C */
1841 dissect_h264_slice_data_partition_c_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1843 case 5: /* Coded slice of an IDR picture */
1844 dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, tvb, pinfo, offset);
1846 case 6: /* Supplemental enhancement information (SEI) */
1847 dissect_h264_sei_rbsp(stream_tree, tvb, pinfo, offset);
1849 case H264_SEQ_PAR_SET: /* 7 Sequence parameter set*/
1850 dissect_h264_seq_parameter_set_rbsp(stream_tree, tvb, pinfo, offset);
1852 case H264_PIC_PAR_SET: /* 8 Picture parameter set */
1853 dissect_h264_pic_parameter_set_rbsp(stream_tree, tvb, pinfo, offset);
1855 case 19: /* Coded slice of an auxiliary coded picture without partitioning */
1856 dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, tvb, pinfo, offset);
1868 static const int *profile_fields[] = {
1869 &hf_h264_par_profile_b,
1870 &hf_h264_par_profile_m,
1871 &hf_h264_par_profile_e,
1872 &hf_h264_par_profile_h,
1873 &hf_h264_par_profile_h10,
1874 &hf_h264_par_profile_h4_2_2,
1875 &hf_h264_par_profile_h4_4_4,
1880 dissect_h264_par_profile(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1884 proto_tree_add_bitmask(tree, tvb, offset,
1885 hf_h264_par_profile, ett_h264_par_profile,
1886 profile_fields, FALSE);
1891 static const int *AdditionalModesSupported_fields[] = {
1892 &hf_h264_par_add_mode_sup_rcdo,
1896 dissect_h264_par_AdditionalModesSupported(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1900 proto_tree_add_bitmask(tree, tvb, offset,
1901 hf_h264_par_AdditionalModesSupported, ett_h264_par_AdditionalModesSupported,
1902 AdditionalModesSupported_fields, FALSE);
1908 static const int *ProfileIOP_fields[] = {
1909 &hf_h264_par_constraint_set0_flag,
1910 &hf_h264_par_constraint_set1_flag,
1911 &hf_h264_par_constraint_set2_flag,
1917 dissect_h264_ProfileIOP(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1921 proto_tree_add_bitmask(tree, tvb, offset,
1922 hf_h264_par_ProfileIOP, ett_h264_par_ProfileIOP,
1923 ProfileIOP_fields, FALSE);
1928 static const value_string h264_par_level_values[] = {
1949 dissect_h264_par_level(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_)
1953 const gchar *p = NULL;
1956 actx = get_asn1_ctx(pinfo->private_data);
1957 DISSECTOR_ASSERT(actx);
1959 lvl = tvb_get_ntohs(tvb, offset);
1960 p = match_strval(lvl, VALS(h264_par_level_values));
1962 proto_item_append_text(actx->created_item, " - Level %s", p);
1968 dissect_h264_par_DecoderConfigurationInformation(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_)
1972 actx = get_asn1_ctx(pinfo->private_data);
1973 DISSECTOR_ASSERT(actx);
1975 dissect_h264_nal_unit(tvb, pinfo, tree);
1977 return tvb_length(tvb);
1980 typedef struct _h264_capability_t {
1983 new_dissector_t content_pdu;
1984 } h264_capability_t;
1986 static h264_capability_t h264_capability_tab[] = {
1987 /* ITU-T H.241 (05/2006), 8.3 H.264 capabilities */
1988 { "GenericCapability/0.0.8.241.0.0.1", "ITU-T Rec. H.241 H.264 Video Capabilities", NULL },
1989 { "GenericCapability/0.0.8.241.0.0.1/collapsing/41", "Profile", dissect_h264_par_profile },
1990 { "GenericCapability/0.0.8.241.0.0.1/collapsing/42", "Level", dissect_h264_par_level },
1991 { "GenericCapability/0.0.8.241.0.0.1/collapsing/3" , "CustomMaxMBPS", NULL },
1992 { "GenericCapability/0.0.8.241.0.0.1/collapsing/4" , "CustomMaxFS", NULL },
1993 { "GenericCapability/0.0.8.241.0.0.1/collapsing/5" , "CustomMaxDPB", NULL },
1994 { "GenericCapability/0.0.8.241.0.0.1/collapsing/6" , "CustomMaxBRandCPB", NULL },
1995 { "GenericCapability/0.0.8.241.0.0.1/collapsing/7" , "MaxStaticMBPS", NULL },
1996 { "GenericCapability/0.0.8.241.0.0.1/collapsing/8" , "max-rcmd-nal-unit-size", NULL },
1997 { "GenericCapability/0.0.8.241.0.0.1/collapsing/9" , "max-nal-unit-size", NULL },
1998 { "GenericCapability/0.0.8.241.0.0.1/collapsing/10", "SampleAspectRatiosSupported", NULL },
1999 { "GenericCapability/0.0.8.241.0.0.1/collapsing/11", "AdditionalModesSupported", dissect_h264_par_AdditionalModesSupported },
2000 { "GenericCapability/0.0.8.241.0.0.1/collapsing/12", "AdditionalDisplayCapabilities", NULL },
2001 /* TS 26.111 H.264 */
2002 { "GenericCapability/0.0.8.241.0.0.1/nonCollapsing/43" , "DecoderConfigurationInformation", dissect_h264_par_DecoderConfigurationInformation },
2003 { "GenericCapability/0.0.8.241.0.0.1/collapsing/44" , "AcceptRedundantSlices", NULL },
2004 { "GenericCapability/0.0.8.241.0.0.1/collapsing/45" , "NalAlignedMode", NULL },
2005 { "GenericCapability/0.0.8.241.0.0.1/collapsing/46" , "ProfileIOP", dissect_h264_ProfileIOP },
2006 { NULL, NULL, NULL },
2009 static h264_capability_t *find_cap(const gchar *id) {
2010 h264_capability_t *ftr = NULL;
2011 h264_capability_t *f;
2013 for (f=h264_capability_tab; f->id; f++) {
2014 if (!strcmp(id, f->id)) { ftr = f; break; }
2020 dissect_h264_name(tvbuff_t *tvb _U_, packet_info *pinfo, proto_tree *tree)
2023 h264_capability_t *ftr = NULL;
2025 actx = get_asn1_ctx(pinfo->private_data);
2026 DISSECTOR_ASSERT(actx);
2028 ftr = find_cap(pinfo->match_string);
2030 proto_item_append_text(actx->created_item, " - %s", ftr->name);
2031 proto_item_append_text(proto_item_get_parent(proto_tree_get_parent(tree)), ": %s", ftr->name);
2033 proto_item_append_text(actx->created_item, " - unknown(%s)", pinfo->match_string);
2039 /* Register the protocol with Wireshark */
2040 /* If this dissector uses sub-dissector registration add a registration routine.
2041 This format is required because a script is used to find these routines and
2042 create the code that calls these routines.
2045 proto_reg_handoff_h264(void)
2047 static dissector_handle_t h264_handle;
2048 static guint dynamic_payload_type;
2049 static gboolean h264_prefs_initialized = FALSE;
2051 if (!h264_prefs_initialized) {
2052 dissector_handle_t h264_name_handle;
2053 h264_capability_t *ftr;
2055 h264_handle = find_dissector("h264");
2056 dissector_add_string("rtp_dyn_payload_type","H264", h264_handle);
2058 h264_name_handle = create_dissector_handle(dissect_h264_name, proto_h264);
2059 for (ftr=h264_capability_tab; ftr->id; ftr++) {
2061 dissector_add_string("h245.gef.name", ftr->id, h264_name_handle);
2062 if (ftr->content_pdu)
2063 dissector_add_string("h245.gef.content", ftr->id, new_create_dissector_handle(ftr->content_pdu, proto_h264));
2065 h264_prefs_initialized = TRUE;
2067 if ( dynamic_payload_type > 95 )
2068 dissector_delete("rtp.pt", dynamic_payload_type, h264_handle);
2071 dynamic_payload_type = temp_dynamic_payload_type;
2072 if ( dynamic_payload_type > 95 ){
2073 dissector_add("rtp.pt", dynamic_payload_type, h264_handle);
2077 /* this format is required because a script is used to build the C function
2078 that calls all the protocol registration.
2082 proto_register_h264(void)
2085 module_t *h264_module;
2087 /* Setup list of header fields See Section 1.6.1 for details*/
2088 static hf_register_info hf[] = {
2089 { &hf_h264_nal_f_bit,
2090 { "F bit", "h264.f",
2091 FT_BOOLEAN, 8, TFS(&h264_f_bit_vals), 0x80,
2095 { "Nal_ref_idc (NRI)", "h264.nal_nri",
2096 FT_UINT8, BASE_DEC, NULL, 0x60,
2100 { "Type", "h264.nal_unit_hdr",
2101 FT_UINT8, BASE_DEC, VALS(h264_type_values), 0x1f,
2104 { &hf_h264_start_bit,
2105 { "Start bit", "h264.start.bit",
2106 FT_BOOLEAN, 8, TFS(&h264_start_bit_vals), 0x80,
2110 { "End bit", "h264.end.bit",
2111 FT_BOOLEAN, 8, TFS(&h264_end_bit_vals), 0x40,
2114 { &hf_h264_forbidden_bit,
2115 { "Forbidden bit", "h264.forbidden.bit",
2116 FT_UINT8, BASE_DEC, NULL, 0x20,
2120 { "Profile", "h264.profile",
2121 FT_BYTES, BASE_NONE, NULL, 0x0,
2124 { &hf_h264_profile_idc,
2125 { "Profile_idc", "h264.profile_idc",
2126 FT_UINT8, BASE_DEC, VALS(h264_profile_idc_values), 0xff,
2129 { &hf_h264_rbsp_stop_bit,
2130 { "rbsp_stop_bit", "h264.rbsp_stop_bit",
2131 FT_UINT8, BASE_DEC, NULL, 0x0,
2134 { &hf_h264_rbsp_trailing_bits,
2135 { "rbsp_trailing_bits", "h264.rbsp_trailing_bits",
2136 FT_UINT8, BASE_DEC, NULL, 0x0,
2139 { &hf_h264_constraint_set0_flag,
2140 { "Constraint_set0_flag", "h264.constraint_set0_flag",
2141 FT_UINT8, BASE_DEC, NULL, 0x80,
2144 { &hf_h264_constraint_set1_flag,
2145 { "Constraint_set1_flag", "h264.constraint_set1_flag",
2146 FT_UINT8, BASE_DEC, NULL, 0x40,
2149 { &hf_h264_constraint_set2_flag,
2150 { "Constraint_set2_flag", "h264.constraint_set2_flag",
2151 FT_UINT8, BASE_DEC, NULL, 0x20,
2154 { &hf_h264_constraint_set3_flag,
2155 { "Constraint_set3_flag", "h264.constraint_set3_flag",
2156 FT_UINT8, BASE_DEC, NULL, 0x10,
2159 { &hf_h264_reserved_zero_4bits,
2160 { "Reserved_zero_4bits", "h264.reserved_zero_4bits",
2161 FT_UINT8, BASE_DEC, NULL, 0x0f,
2164 { &hf_h264_level_idc,
2165 { "Level_id", "h264.level_id",
2166 FT_UINT8, BASE_DEC, NULL, 0xff,
2169 { &hf_h264_nal_unit,
2170 { "NAL unit", "h264.nal_unit",
2171 FT_BYTES, BASE_NONE, NULL, 0x0,
2174 { &hf_h264_forbidden_zero_bit,
2175 { "Forbidden_zero_bit", "h264.forbidden_zero_bit",
2176 FT_UINT8, BASE_DEC, NULL, 0x80,
2179 { &hf_h264_nal_ref_idc,
2180 { "Nal_ref_idc", "h264.nal_ref_idc",
2181 FT_UINT8, BASE_DEC, NULL, 0x60,
2184 {&hf_h264_nal_unit_type,
2185 { "Nal_unit_type", "h264.nal_unit_type",
2186 FT_UINT8, BASE_DEC, VALS(h264_nal_unit_type_vals), 0x1f,
2189 { &hf_h264_seq_parameter_set_id,
2190 { "seq_parameter_set_id", "h264.seq_parameter_set_id",
2191 FT_UINT32, BASE_DEC, NULL, 0x0,
2194 { &hf_h264_chroma_format_idc,
2195 { "chroma_format_id", "h264.chroma_format_id",
2196 FT_UINT32, BASE_DEC, NULL, 0x0,
2199 { &hf_h264_residual_colour_transform_flag,
2200 { "residual_colour_transform_flag", "h264.residual_colour_transform_flag",
2201 FT_UINT8, BASE_DEC, NULL, 0x0,
2204 { &hf_h264_bit_depth_luma_minus8,
2205 { "bit_depth_luma_minus8", "h264.bit_depth_luma_minus8",
2206 FT_UINT32, BASE_DEC, NULL, 0x0,
2209 { &hf_h264_bit_depth_chroma_minus8,
2210 { "bit_depth_chroma_minus8", "h264.bit_depth_chroma_minus8",
2211 FT_UINT32, BASE_DEC, NULL, 0x0,
2214 { &hf_h264_qpprime_y_zero_transform_bypass_flag,
2215 { "qpprime_y_zero_transform_bypass_flag", "h264.qpprime_y_zero_transform_bypass_flag",
2216 FT_UINT32, BASE_DEC, NULL, 0x0,
2219 { &hf_h264_seq_scaling_matrix_present_flag,
2220 { "seq_scaling_matrix_present_flag", "h264.seq_scaling_matrix_present_flag",
2221 FT_UINT32, BASE_DEC, NULL, 0x0,
2224 { &hf_h264_log2_max_frame_num_minus4,
2225 { "log2_max_frame_num_minus4", "h264.log2_max_frame_num_minus4",
2226 FT_UINT32, BASE_DEC, NULL, 0x0,
2229 { &hf_h264_pic_order_cnt_type,
2230 { "pic_order_cnt_type", "h264.pic_order_cnt_type",
2231 FT_UINT32, BASE_DEC, NULL, 0x0,
2234 { &hf_h264_log2_max_pic_order_cnt_lsb_minus4,
2235 { "log2_max_pic_order_cnt_lsb_minus4", "h264.log2_max_pic_order_cnt_lsb_minus4",
2236 FT_UINT32, BASE_DEC, NULL, 0x0,
2239 { &hf_h264_delta_pic_order_always_zero_flag,
2240 { "delta_pic_order_always_zero_flag", "h264.delta_pic_order_always_zero_flag",
2241 FT_UINT8, BASE_DEC, NULL, 0x0,
2244 { &hf_h264_offset_for_non_ref_pic,
2245 { "offset_for_non_ref_pic", "h264.offset_for_non_ref_pic",
2246 FT_INT32, BASE_DEC, NULL, 0x0,
2249 { &hf_h264_offset_for_top_to_bottom_field,
2250 { "offset_for_top_to_bottom_field", "h264.offset_for_top_to_bottom_field",
2251 FT_INT32, BASE_DEC, NULL, 0x0,
2254 { &hf_h264_num_ref_frames_in_pic_order_cnt_cycle,
2255 { "num_ref_frames_in_pic_order_cnt_cycle", "h264.num_ref_frames_in_pic_order_cnt_cycle",
2256 FT_UINT32, BASE_DEC, NULL, 0x0,
2259 { &hf_h264_offset_for_ref_frame,
2260 { "offset_for_ref_frame", "h264.offset_for_ref_frame",
2261 FT_INT32, BASE_DEC, NULL, 0x0,
2264 { &hf_h264_num_ref_frames,
2265 { "num_ref_frames", "h264.num_ref_frames",
2266 FT_UINT32, BASE_DEC, NULL, 0x0,
2269 { &hf_h264_gaps_in_frame_num_value_allowed_flag,
2270 { "gaps_in_frame_num_value_allowed_flag", "h264.gaps_in_frame_num_value_allowed_flag",
2271 FT_UINT8, BASE_DEC, NULL, 0x0,
2274 { &hf_h264_pic_width_in_mbs_minus1,
2275 { "pic_width_in_mbs_minus1", "h264.pic_width_in_mbs_minus1",
2276 FT_UINT32, BASE_DEC, NULL, 0x0,
2279 { &hf_h264_pic_height_in_map_units_minus1,
2280 { "pic_height_in_map_units_minus1", "h264.pic_height_in_map_units_minus1",
2281 FT_UINT32, BASE_DEC, NULL, 0x0,
2284 { &hf_h264_frame_mbs_only_flag,
2285 { "frame_mbs_only_flag", "h264.frame_mbs_only_flag",
2286 FT_UINT8, BASE_DEC, NULL, 0x0,
2289 { &hf_h264_mb_adaptive_frame_field_flag,
2290 { "mb_adaptive_frame_field_flag", "h264.mb_adaptive_frame_field_flag",
2291 FT_UINT8, BASE_DEC, NULL, 0x0,
2294 { &hf_h264_direct_8x8_inference_flag,
2295 { "direct_8x8_inference_flag", "h264.direct_8x8_inference_flag",
2296 FT_UINT8, BASE_DEC, NULL, 0x0,
2299 { &hf_h264_frame_cropping_flag,
2300 { "frame_cropping_flag", "h264.frame_cropping_flag",
2301 FT_UINT8, BASE_DEC, NULL, 0x0,
2304 { &hf_h264_frame_crop_left_offset,
2305 { "frame_crop_left_offset", "h264.frame_crop_left_offset",
2306 FT_UINT32, BASE_DEC, NULL, 0x0,
2309 { &hf_h264_frame_crop_right_offset,
2310 { "frame_crop_left_offset", "h264.frame_crop_right_offset",
2311 FT_UINT32, BASE_DEC, NULL, 0x0,
2314 { &hf_h264_frame_crop_top_offset,
2315 { "frame_crop_top_offset", "h264.frame_crop_top_offset",
2316 FT_UINT32, BASE_DEC, NULL, 0x0,
2319 { &hf_h264_frame_crop_bottom_offset,
2320 { "frame_crop_bottom_offset", "h264.frame_crop_bottom_offset",
2321 FT_UINT32, BASE_DEC, NULL, 0x0,
2324 { &hf_h264_vui_parameters_present_flag,
2325 { "vui_parameters_present_flag", "h264.vui_parameters_present_flag",
2326 FT_UINT8, BASE_DEC, NULL, 0x0,
2329 { &hf_h264_pic_parameter_set_id,
2330 { "pic_parameter_set_id", "h264.pic_parameter_set_id",
2331 FT_UINT32, BASE_DEC, NULL, 0x0,
2334 { &hf_h264_entropy_coding_mode_flag,
2335 { "entropy_coding_mode_flag", "h264.entropy_coding_mode_flag",
2336 FT_UINT8, BASE_DEC, NULL, 0x0,
2339 { &hf_h264_pic_order_present_flag,
2340 { "pic_order_present_flag", "h264.pic_order_present_flag",
2341 FT_UINT8, BASE_DEC, NULL, 0x0,
2344 { &hf_h264_num_slice_groups_minus1,
2345 { "num_slice_groups_minus1", "h264.num_slice_groups_minus1",
2346 FT_UINT32, BASE_DEC, NULL, 0x0,
2349 { &hf_h264_slice_group_map_type,
2350 { "slice_group_map_type", "h264.slice_group_map_type",
2351 FT_UINT32, BASE_DEC, VALS(h264_slice_group_map_type_vals), 0x0,
2354 { &hf_h264_num_ref_idx_l0_active_minus1,
2355 { "num_ref_idx_l0_active_minus1", "h264.num_ref_idx_l0_active_minus1",
2356 FT_UINT32, BASE_DEC, NULL, 0x0,
2359 { &hf_h264_num_ref_idx_l1_active_minus1,
2360 { "num_ref_idx_l1_active_minus1", "h264.num_ref_idx_l1_active_minus1",
2361 FT_UINT32, BASE_DEC, NULL, 0x0,
2364 { &hf_h264_weighted_pred_flag,
2365 { "weighted_pred_flag", "h264.weighted_pred_flag",
2366 FT_UINT8, BASE_DEC, NULL, 0x0,
2369 { &hf_h264_weighted_bipred_idc,
2370 { "weighted_bipred_idc", "h264.weighted_bipred_idc",
2371 FT_UINT8, BASE_DEC, NULL, 0x0,
2374 { &hf_h264_pic_init_qp_minus26,
2375 { "pic_init_qp_minus26", "h264.pic_init_qp_minus26",
2376 FT_INT32, BASE_DEC, NULL, 0x0,
2379 { &hf_h264_pic_init_qs_minus26,
2380 { "pic_init_qs_minus26", "h264.pic_init_qs_minus26",
2381 FT_INT32, BASE_DEC, NULL, 0x0,
2384 { &hf_h264_chroma_qp_index_offset,
2385 { "chroma_qp_index_offset", "h264.chroma_qp_index_offset",
2386 FT_INT32, BASE_DEC, NULL, 0x0,
2389 { &hf_h264_deblocking_filter_control_present_flag,
2390 { "deblocking_filter_control_present_flag", "h264.deblocking_filter_control_present_flag",
2391 FT_UINT8, BASE_DEC, NULL, 0x0,
2394 { &hf_h264_constrained_intra_pred_flag,
2395 { "constrained_intra_pred_flag", "h264.constrained_intra_pred_flag",
2396 FT_UINT8, BASE_DEC, NULL, 0x0,
2399 { &hf_h264_redundant_pic_cnt_present_flag,
2400 { "redundant_pic_cnt_present_flag", "h264.redundant_pic_cnt_present_flag",
2401 FT_UINT8, BASE_DEC, NULL, 0x0,
2404 { &hf_h264_transform_8x8_mode_flag,
2405 { "transform_8x8_mode_flag", "h264.transform_8x8_mode_flag",
2406 FT_UINT8, BASE_DEC, NULL, 0x0,
2409 { &hf_h264_pic_scaling_matrix_present_flag,
2410 { "pic_scaling_matrix_present_flag", "h264.pic_scaling_matrix_present_flag",
2411 FT_UINT8, BASE_DEC, NULL, 0x0,
2414 { &hf_h264_second_chroma_qp_index_offset,
2415 { "second_chroma_qp_index_offset", "h264.second_chroma_qp_index_offset",
2416 FT_INT32, BASE_DEC, NULL, 0x0,
2420 { &hf_h264_aspect_ratio_info_present_flag,
2421 { "aspect_ratio_info_present_flag", "h264.aspect_ratio_info_present_flag",
2422 FT_UINT8, BASE_DEC, NULL, 0x0,
2425 { &hf_h264_aspect_ratio_idc,
2426 { "aspect_ratio_idc", "h264.aspect_ratio_idc",
2427 FT_UINT8, BASE_DEC, NULL, 0x0,
2430 { &hf_h264_sar_width,
2431 { "sar_width", "h264.sar_width",
2432 FT_UINT16, BASE_DEC, NULL, 0x0,
2435 { &hf_h264_sar_height,
2436 { "sar_height", "h264.sar_height",
2437 FT_UINT16, BASE_DEC, NULL, 0x0,
2440 { &hf_h264_overscan_info_present_flag,
2441 { "overscan_info_present_flag", "h264.overscan_info_present_flag",
2442 FT_UINT8, BASE_DEC, NULL, 0x0,
2445 { &hf_h264_overscan_appropriate_flag,
2446 { "overscan_appropriate_flag", "h264.overscan_appropriate_flag",
2447 FT_UINT8, BASE_DEC, NULL, 0x0,
2450 { &hf_h264_video_signal_type_present_flag,
2451 { "video_signal_type_present_flag", "h264.video_signal_type_present_flag",
2452 FT_UINT8, BASE_DEC, NULL, 0x0,
2455 { &hf_h264_video_format,
2456 { "video_format", "h264.video_format",
2457 FT_UINT8, BASE_DEC, NULL, 0x0,
2460 { &hf_h264_video_full_range_flag,
2461 { "video_full_range_flag", "h264.video_full_range_flag",
2462 FT_UINT8, BASE_DEC, NULL, 0x0,
2465 { &hf_h264_colour_description_present_flag,
2466 { "colour_description_present_flag", "h264.colour_description_present_flag",
2467 FT_UINT8, BASE_DEC, NULL, 0x0,
2470 { &hf_h264_colour_primaries,
2471 { "colour_primaries", "h264.colour_primaries",
2472 FT_UINT8, BASE_DEC, NULL, 0x0,
2475 { &hf_h264_transfer_characteristics,
2476 { "transfer_characteristics", "h264.transfer_characteristics",
2477 FT_UINT8, BASE_DEC, NULL, 0x0,
2480 { &hf_h264_matrix_coefficients,
2481 { "matrix_coefficients", "h264.matrix_coefficients",
2482 FT_UINT8, BASE_DEC, NULL, 0x0,
2485 { &hf_h264_chroma_loc_info_present_flag,
2486 { "chroma_loc_info_present_flag", "h264.chroma_loc_info_present_flag",
2487 FT_UINT8, BASE_DEC, NULL, 0x0,
2490 { &hf_h264_chroma_sample_loc_type_top_field,
2491 { "chroma_sample_loc_type_top_field", "h264.chroma_sample_loc_type_top_field",
2492 FT_UINT32, BASE_DEC, NULL, 0x0,
2495 { &hf_h264_chroma_sample_loc_type_bottom_field,
2496 { "chroma_sample_loc_type_bottom_field", "h264.chroma_sample_loc_type_bottom_field",
2497 FT_UINT32, BASE_DEC, NULL, 0x0,
2500 { &hf_h264_timing_info_present_flag,
2501 { "timing_info_present_flag", "h264.timing_info_present_flag",
2502 FT_UINT8, BASE_DEC, NULL, 0x0,
2505 { &hf_h264_num_units_in_tick,
2506 { "num_units_in_tick", "h264.num_units_in_tick",
2507 FT_UINT32, BASE_DEC, NULL, 0x0,
2510 { &hf_h264_time_scale,
2511 { "time_scale", "h264.time_scale",
2512 FT_UINT32, BASE_DEC, NULL, 0x0,
2515 { &hf_h264_fixed_frame_rate_flag,
2516 { "fixed_frame_rate_flag", "h264.fixed_frame_rate_flag",
2517 FT_UINT8, BASE_DEC, NULL, 0x0,
2520 { &hf_h264_nal_hrd_parameters_present_flag,
2521 { "nal_hrd_parameters_present_flag", "h264.nal_hrd_parameters_present_flag",
2522 FT_UINT8, BASE_DEC, NULL, 0x0,
2525 { &hf_h264_vcl_hrd_parameters_present_flag,
2526 { "vcl_hrd_parameters_present_flag", "h264.vcl_hrd_parameters_present_flag",
2527 FT_UINT8, BASE_DEC, NULL, 0x0,
2530 { &hf_h264_low_delay_hrd_flag,
2531 { "low_delay_hrd_flag", "h264.low_delay_hrd_flag",
2532 FT_UINT8, BASE_DEC, NULL, 0x0,
2535 { &hf_h264_pic_struct_present_flag,
2536 { "pic_struct_present_flag", "h264.pic_struct_present_flag",
2537 FT_UINT8, BASE_DEC, NULL, 0x0,
2540 { &hf_h264_bitstream_restriction_flag,
2541 { "bitstream_restriction_flag", "h264.bitstream_restriction_flag",
2542 FT_UINT8, BASE_DEC, NULL, 0x0,
2545 { &hf_h264_motion_vectors_over_pic_boundaries_flag,
2546 { "motion_vectors_over_pic_boundaries_flag", "h264.motion_vectors_over_pic_boundaries_flag",
2547 FT_UINT32, BASE_DEC, NULL, 0x0,
2550 { &hf_h264_max_bytes_per_pic_denom,
2551 { "max_bytes_per_pic_denom", "h264.max_bytes_per_pic_denom",
2552 FT_UINT32, BASE_DEC, NULL, 0x0,
2555 { &hf_h264_max_bits_per_mb_denom,
2556 { "max_bits_per_mb_denom", "h264.max_bits_per_mb_denom",
2557 FT_UINT32, BASE_DEC, NULL, 0x0,
2560 { &hf_h264_log2_max_mv_length_horizontal,
2561 { "max_mv_length_horizontal", "h264.max_mv_length_horizontal",
2562 FT_UINT32, BASE_DEC, NULL, 0x0,
2565 { &hf_h264_log2_max_mv_length_vertical,
2566 { "log2_max_mv_length_vertical", "h264.log2_max_mv_length_vertical",
2567 FT_UINT32, BASE_DEC, NULL, 0x0,
2570 { &hf_h264_num_reorder_frames,
2571 { "num_reorder_frames", "h264.num_reorder_frames",
2572 FT_UINT32, BASE_DEC, NULL, 0x0,
2575 { &hf_h264_max_dec_frame_buffering,
2576 { "max_dec_frame_buffering", "h264.max_dec_frame_buffering",
2577 FT_UINT32, BASE_DEC, NULL, 0x0,
2580 { &hf_h264_cpb_cnt_minus1,
2581 { "cpb_cnt_minus1", "h264.cpb_cnt_minus1",
2582 FT_UINT32, BASE_DEC, NULL, 0x0,
2585 { &hf_h264_bit_rate_scale,
2586 { "bit_rate_scale", "h264.bit_rate_scale",
2587 FT_UINT8, BASE_DEC, NULL, 0x0,
2590 { &hf_h264_cpb_size_scale,
2591 { "cpb_size_scale", "h264.cpb_size_scale",
2592 FT_UINT8, BASE_DEC, NULL, 0x0,
2595 { &hf_h264_bit_rate_value_minus1,
2596 { "bit_rate_value_minus1", "h264.bit_rate_value_minus1",
2597 FT_UINT32, BASE_DEC, NULL, 0x0,
2600 { &hf_h264_cpb_size_value_minus1,
2601 { "cpb_size_value_minus1", "h264.cpb_size_value_minus1",
2602 FT_UINT32, BASE_DEC, NULL, 0x0,
2605 { &hf_h264_cbr_flag,
2606 { "cbr_flag", "h264.cbr_flag",
2607 FT_UINT8, BASE_DEC, NULL, 0x0,
2610 { &hf_h264_initial_cpb_removal_delay_length_minus1,
2611 { "initial_cpb_removal_delay_length_minus1", "h264.initial_cpb_removal_delay_length_minus1",
2612 FT_UINT8, BASE_DEC, NULL, 0x0,
2615 { &hf_h264_cpb_removal_delay_length_minus1,
2616 { "cpb_removal_delay_length_minus1", "h264.cpb_removal_delay_length_minus1",
2617 FT_UINT8, BASE_DEC, NULL, 0x0,
2620 { &hf_h264_dpb_output_delay_length_minus11,
2621 { "dpb_output_delay_length_minus11", "h264.dpb_output_delay_length_minus11",
2622 FT_UINT8, BASE_DEC, NULL, 0x0,
2625 { &hf_h264_time_offset_length,
2626 { "time_offset_length", "h264.time_offset_length",
2627 FT_UINT8, BASE_DEC, NULL, 0x0,
2630 { &hf_h264_first_mb_in_slice,
2631 { "first_mb_in_slice", "h264.first_mb_in_slice",
2632 FT_UINT32, BASE_DEC, NULL, 0x0,
2635 { &hf_h264_slice_type,
2636 { "slice_type", "h264.slice_type",
2637 FT_UINT32, BASE_DEC, VALS(h264_slice_type_vals), 0x0,
2640 { &hf_h264_slice_id,
2641 { "slice_id", "h264.slice_id",
2642 FT_UINT32, BASE_DEC, NULL, 0x0,
2645 { &hf_h264_payloadsize,
2646 { "PayloadSize", "h264.payloadsize",
2647 FT_UINT32, BASE_DEC, NULL, 0x0,
2650 { &hf_h264_payloadtype,
2651 { "payloadType", "h264.payloadtype",
2652 FT_UINT32, BASE_DEC, VALS(h264_sei_payload_vals), 0x0,
2655 { &hf_h264_frame_num,
2656 { "frame_num", "h264.frame_num",
2657 FT_UINT8, BASE_DEC, NULL, 0x0,
2660 { &hf_h264_par_profile,
2661 { "Profile", "h264.profile",
2662 FT_UINT8, BASE_HEX, NULL, 0x00,
2664 { &hf_h264_par_profile_b,
2665 { "Baseline Profile", "h264.profile.base",
2666 FT_BOOLEAN, 8, NULL, 0x40,
2668 { &hf_h264_par_profile_m,
2669 { "Main Profile", "h264.profile.main",
2670 FT_BOOLEAN, 8, NULL, 0x20,
2672 { &hf_h264_par_profile_e,
2673 { "Extended Profile.", "h264.profile.ext",
2674 FT_BOOLEAN, 8, NULL, 0x10,
2676 { &hf_h264_par_profile_h,
2677 { "High Profile", "h264.profile.high",
2678 FT_BOOLEAN, 8, NULL, 0x08,
2680 { &hf_h264_par_profile_h10,
2681 { "High 10 Profile", "h264.profile.high10",
2682 FT_BOOLEAN, 8, NULL, 0x04,
2684 { &hf_h264_par_profile_h4_2_2,
2685 { "High 4:2:2 Profile", "h264.profile.high4_2_2",
2686 FT_BOOLEAN, 8, NULL, 0x02,
2688 { &hf_h264_par_profile_h4_4_4,
2689 { "High 4:4:4 Profile", "h264.profile.high4_4_4",
2690 FT_BOOLEAN, 8, NULL, 0x01,
2692 { &hf_h264_par_AdditionalModesSupported,
2693 { "AdditionalModesSupported", "h264.AdditionalModesSupported",
2694 FT_UINT8, BASE_HEX, NULL, 0x00,
2696 { &hf_h264_par_add_mode_sup,
2697 { "Additional Modes Supported", "h264.add_mode_sup",
2698 FT_UINT8, BASE_HEX, NULL, 0x00,
2700 { &hf_h264_par_add_mode_sup_rcdo,
2701 { "Reduced Complexity Decoding Operation (RCDO) support", "h264.add_mode_sup.rcdo",
2702 FT_BOOLEAN, 8, NULL, 0x40,
2704 { &hf_h264_par_ProfileIOP,
2705 { "ProfileIOP", "h264.ProfileIOP",
2706 FT_UINT8, BASE_HEX, NULL, 0x00,
2708 { &hf_h264_par_constraint_set0_flag,
2709 { "constraint_set0_flag", "h264.par.constraint_set0_flag",
2710 FT_BOOLEAN, 8, NULL, 0x80,
2712 { &hf_h264_par_constraint_set1_flag,
2713 { "constraint_set1_flag", "h264.par.constraint_set1_flag",
2714 FT_BOOLEAN, 8, NULL, 0x40,
2716 { &hf_h264_par_constraint_set2_flag,
2717 { "constraint_set2_flag", "h264.par.constraint_set2_flag",
2718 FT_BOOLEAN, 8, NULL, 0x20,
2722 /* Setup protocol subtree array */
2723 static gint *ett[] = {
2730 &ett_h264_par_profile,
2731 &ett_h264_par_AdditionalModesSupported,
2732 &ett_h264_par_ProfileIOP,
2735 /* Register the protocol name and description */
2736 proto_h264 = proto_register_protocol("H.264","H264", "h264");
2738 /* Required function calls to register the header fields and subtrees used */
2739 proto_register_field_array(proto_h264, hf, array_length(hf));
2740 proto_register_subtree_array(ett, array_length(ett));
2741 /* Register a configuration option for port */
2744 h264_module = prefs_register_protocol(proto_h264, proto_reg_handoff_h264);
2746 prefs_register_uint_preference(h264_module, "dynamic.payload.type",
2747 "H264 dynamic payload type",
2748 "The dynamic payload type which will be interpreted as H264"
2749 "; The value must be greater than 95",
2751 &temp_dynamic_payload_type);
2754 register_dissector("h264", dissect_h264, proto_h264);