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
38 #include <epan/packet.h>
39 #include <epan/asn1.h>
40 #include <epan/strutil.h>
42 #include <epan/prefs.h>
45 /* Initialize the protocol and registered fields */
46 static int proto_h264 = -1;
47 static int hf_h264_type = -1;
48 static int hf_h264_nal_f_bit = -1;
49 static int hf_h264_nal_nri = -1;
50 static int hf_h264_start_bit = -1;
51 static int hf_h264_forbidden_bit = -1;
52 static int hf_h264_end_bit = -1;
53 static int hf_h264_profile = -1;
54 static int hf_h264_profile_idc = -1;
55 static int hf_h264_rbsp_stop_bit = -1;
56 static int hf_h264_rbsp_trailing_bits = -1;
57 static int hf_h264_constraint_set0_flag = -1;
58 static int hf_h264_constraint_set1_flag = -1;
59 static int hf_h264_constraint_set2_flag = -1;
60 static int hf_h264_constraint_set3_flag = -1;
61 static int hf_h264_reserved_zero_4bits = -1;
62 static int hf_h264_level_idc = -1;
63 static int hf_h264_nal_unit = -1;
64 static int hf_h264_forbidden_zero_bit = -1;
65 static int hf_h264_nal_ref_idc = -1;
66 static int hf_h264_nal_unit_type = -1;
67 static int hf_h264_seq_parameter_set_id = -1;
68 static int hf_h264_chroma_format_idc = -1;
69 static int hf_h264_residual_colour_transform_flag = -1;
70 static int hf_h264_bit_depth_luma_minus8 = -1;
71 static int hf_h264_bit_depth_chroma_minus8 = -1;
72 static int hf_h264_qpprime_y_zero_transform_bypass_flag = -1;
73 static int hf_h264_seq_scaling_matrix_present_flag = -1;
74 static int hf_h264_log2_max_frame_num_minus4 = -1;
75 static int hf_h264_pic_order_cnt_type = -1;
76 static int hf_h264_log2_max_pic_order_cnt_lsb_minus4 = -1;
77 static int hf_h264_delta_pic_order_always_zero_flag = -1;
78 static int hf_h264_offset_for_non_ref_pic = -1;
79 static int hf_h264_offset_for_top_to_bottom_field = -1;
80 static int hf_h264_num_ref_frames_in_pic_order_cnt_cycle = -1;
81 static int hf_h264_offset_for_ref_frame = -1;
82 static int hf_h264_num_ref_frames = -1;
83 static int hf_h264_gaps_in_frame_num_value_allowed_flag = -1;
84 static int hf_h264_pic_width_in_mbs_minus1 = -1;
85 static int hf_h264_pic_height_in_map_units_minus1 = -1;
86 static int hf_h264_frame_mbs_only_flag = -1;
87 static int hf_h264_mb_adaptive_frame_field_flag = -1;
88 static int hf_h264_direct_8x8_inference_flag = -1;
89 static int hf_h264_frame_cropping_flag = -1;
90 static int hf_h264_frame_crop_left_offset = -1;
91 static int hf_h264_frame_crop_right_offset = -1;
92 static int hf_h264_frame_crop_top_offset = -1;
93 static int hf_h264_frame_crop_bottom_offset = -1;
94 static int hf_h264_vui_parameters_present_flag = -1;
95 static int hf_h264_pic_parameter_set_id = -1;
96 static int hf_h264_entropy_coding_mode_flag = -1;
97 static int hf_h264_pic_order_present_flag = -1;
98 static int hf_h264_num_slice_groups_minus1 = -1;
99 static int hf_h264_slice_group_map_type = -1;
100 static int hf_h264_num_ref_idx_l0_active_minus1 = -1;
101 static int hf_h264_num_ref_idx_l1_active_minus1 = -1;
102 static int hf_h264_weighted_pred_flag = -1;
103 static int hf_h264_weighted_bipred_idc = -1;
104 static int hf_h264_pic_init_qp_minus26 = -1;
105 static int hf_h264_pic_init_qs_minus26 = -1;
106 static int hf_h264_chroma_qp_index_offset = -1;
107 static int hf_h264_deblocking_filter_control_present_flag = -1;
108 static int hf_h264_constrained_intra_pred_flag = -1;
109 static int hf_h264_redundant_pic_cnt_present_flag = -1;
110 static int hf_h264_transform_8x8_mode_flag = -1;
111 static int hf_h264_pic_scaling_matrix_present_flag = -1;
112 static int hf_h264_second_chroma_qp_index_offset = -1;
113 static int hf_h264_par_profile = -1;
114 static int hf_h264_par_profile_b = -1;
115 static int hf_h264_par_profile_m = -1;
116 static int hf_h264_par_profile_e = -1;
117 static int hf_h264_par_profile_h = -1;
118 static int hf_h264_par_profile_h10 = -1;
119 static int hf_h264_par_profile_h4_2_2 = -1;
120 static int hf_h264_par_profile_h4_4_4 = -1;
121 static int hf_h264_par_add_mode_sup = -1;
122 static int hf_h264_par_AdditionalModesSupported = -1;
123 static int hf_h264_par_add_mode_sup_rcdo = -1;
124 static int hf_h264_par_ProfileIOP = -1;
125 static int hf_h264_par_constraint_set0_flag = -1;
126 static int hf_h264_par_constraint_set1_flag = -1;
127 static int hf_h264_par_constraint_set2_flag = -1;
130 static int hf_h264_aspect_ratio_info_present_flag = -1;
131 static int hf_h264_aspect_ratio_idc = -1;
132 static int hf_h264_sar_width = -1;
133 static int hf_h264_sar_height = -1;
134 static int hf_h264_overscan_info_present_flag = -1;
135 static int hf_h264_overscan_appropriate_flag = -1;
136 static int hf_h264_video_signal_type_present_flag = -1;
137 static int hf_h264_video_format = -1;
138 static int hf_h264_video_full_range_flag = -1;
139 static int hf_h264_colour_description_present_flag = -1;
140 static int hf_h264_colour_primaries = -1;
141 static int hf_h264_transfer_characteristics = -1;
142 static int hf_h264_matrix_coefficients = -1;
143 static int hf_h264_chroma_loc_info_present_flag = -1;
144 static int hf_h264_chroma_sample_loc_type_top_field = -1;
145 static int hf_h264_chroma_sample_loc_type_bottom_field = -1;
146 static int hf_h264_timing_info_present_flag = -1;
147 static int hf_h264_num_units_in_tick = -1;
148 static int hf_h264_time_scale = -1;
149 static int hf_h264_fixed_frame_rate_flag = -1;
150 static int hf_h264_nal_hrd_parameters_present_flag = -1;
151 static int hf_h264_vcl_hrd_parameters_present_flag = -1;
152 static int hf_h264_low_delay_hrd_flag = -1;
153 static int hf_h264_pic_struct_present_flag = -1;
154 static int hf_h264_bitstream_restriction_flag = -1;
155 static int hf_h264_motion_vectors_over_pic_boundaries_flag = -1;
156 static int hf_h264_max_bytes_per_pic_denom = -1;
157 static int hf_h264_max_bits_per_mb_denom = -1;
158 static int hf_h264_log2_max_mv_length_horizontal = -1;
159 static int hf_h264_log2_max_mv_length_vertical = -1;
160 static int hf_h264_num_reorder_frames = -1;
161 static int hf_h264_max_dec_frame_buffering = -1;
162 static int hf_h264_cpb_cnt_minus1 = -1;
163 static int hf_h264_bit_rate_scale = -1;
164 static int hf_h264_cpb_size_scale = -1;
165 static int hf_h264_bit_rate_value_minus1 = -1;
166 static int hf_h264_cpb_size_value_minus1 = -1;
167 static int hf_h264_cbr_flag = -1;
168 static int hf_h264_initial_cpb_removal_delay_length_minus1 = -1;
169 static int hf_h264_cpb_removal_delay_length_minus1 = -1;
170 static int hf_h264_dpb_output_delay_length_minus11 = -1;
171 static int hf_h264_time_offset_length = -1;
173 static int hf_h264_first_mb_in_slice = -1;
174 static int hf_h264_slice_type = -1;
175 static int hf_h264_slice_id = -1;
176 static int hf_h264_payloadsize = -1;
177 static int hf_h264_payloadtype = -1;
178 static int hf_h264_frame_num = -1;
180 /* Initialize the subtree pointers */
181 static int ett_h264 = -1;
182 static int ett_h264_profile = -1;
183 static int ett_h264_nal = -1;
184 static int ett_h264_fua = -1;
185 static int ett_h264_stream = -1;
186 static int ett_h264_nal_unit = -1;
187 static int ett_h264_par_profile = -1;
188 static int ett_h264_par_AdditionalModesSupported = -1;
189 static int ett_h264_par_ProfileIOP = -1;
191 /* The dynamic payload type range which will be dissected as H.264 */
193 #define RTP_PT_DEFAULT_RANGE "0"
194 static range_t *temp_dynamic_payload_type_range = NULL;
196 static dissector_handle_t h264_handle;
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, start_offset;
381 guint32 codenum, mask, value, tmp;
387 header_field_info *hf_field = NULL;
389 start_offset = *start_bit_offset>>3;
392 hf_field = proto_registrar_get_nth(hf_index);
394 bit_offset = *start_bit_offset;
396 /* prepare the string */
399 for(bit=0;bit<((int)(bit_offset&0x07));bit++){
401 g_strlcat(str, " ", 256);
403 g_strlcat(str,".", 256);
407 leading_zero_bits = -1;
408 for( b = 0; !b; leading_zero_bits++ ){
410 g_strlcat(str, " ", 256);
413 g_strlcat(str, " ", 256);
415 b = tvb_get_bits8(tvb, bit_offset, 1);
417 g_strlcat(str, "1", 256);
419 g_strlcat(str, "0", 256);
425 if(leading_zero_bits==0){
427 *start_bit_offset = bit_offset;
430 g_strlcat(str, " ", 256);
432 g_strlcat(str,".", 256);
435 g_strlcat(str," = ", 256);
436 g_strlcat(str,hf_field->name, 256);
439 /* if the syntax element is coded as se(v),
440 * the value of the syntax element is derived by invoking the
441 * mapping process for signed Exp-Golomb codes as specified in
442 * subclause 9.1.1 with codeNum as the input.
444 if(hf_field->type==FT_INT32){
445 if (hf_field->strings) {
446 proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
449 val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
452 switch(hf_field->display){
454 proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
460 DISSECTOR_ASSERT_NOT_REACHED();
469 if(hf_field->type==FT_UINT32){
470 if (hf_field->strings) {
471 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
474 val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
477 switch(hf_field->display){
479 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
485 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
491 DISSECTOR_ASSERT_NOT_REACHED();
496 /* Only allow guint32 */
497 DISSECTOR_ASSERT_NOT_REACHED();
504 Syntax elements coded as ue(v), me(v), or se(v) are Exp-Golomb-coded. Syntax elements coded as te(v) are truncated
505 Exp-Golomb-coded. The parsing process for these syntax elements begins with reading the bits starting at the current
506 location in the bitstream up to and including the first non-zero bit, and counting the number of leading bits that are
507 equal to 0. This process is specified as follows:
508 leadingZeroBits = -1;
509 for( b = 0; !b; leadingZeroBits++ )
511 The variable codeNum is then assigned as follows:
512 codeNum = 2leadingZeroBits - 1 + read_bits( leadingZeroBits )
513 where the value returned from read_bits( leadingZeroBits ) is interpreted as a binary representation of an unsigned
514 integer with most significant bit written first.
517 codenum = codenum << leading_zero_bits;
519 if (leading_zero_bits > 32)
520 DISSECTOR_ASSERT_NOT_REACHED();
521 else if (leading_zero_bits > 16)
522 value = tvb_get_bits32(tvb, bit_offset,leading_zero_bits, ENC_BIG_ENDIAN);
523 else if (leading_zero_bits > 8)
524 value = tvb_get_bits16(tvb, bit_offset,leading_zero_bits, ENC_BIG_ENDIAN);
526 value = tvb_get_bits8(tvb, bit_offset,leading_zero_bits );
527 codenum = (codenum-1) + value;
528 bit_offset = bit_offset + leading_zero_bits;
530 /* read the bits for the int */
531 for(i=0;i<leading_zero_bits;i++){
533 g_strlcat(str, " ", 256);
536 g_strlcat(str, " ", 256);
541 g_strlcat(str, "1", 256);
543 g_strlcat(str, "0", 256);
549 g_strlcat(str, " ", 256);
551 g_strlcat(str,".", 256);
556 /* if the syntax element is coded as se(v),
557 * the value of the syntax element is derived by invoking the
558 * mapping process for signed Exp-Golomb codes as specified in
559 * subclause 9.1.1 with codeNum as the input.
563 se_value = (codenum + 1) >> 1;
564 if (!(se_value & 1)){
565 se_value = - se_value;
573 g_strlcat(str," = ", 256);
574 g_strlcat(str,hf_field->name, 256);
577 g_strlcat(str,"(se(v))", 256);
578 /* if the syntax element is coded as se(v),
579 * the value of the syntax element is derived by invoking the
580 * mapping process for signed Exp-Golomb codes as specified in
581 * subclause 9.1.1 with codeNum as the input.
587 if((hf_field->type==FT_UINT32)&&(descriptor==H264_UE_V)){
588 if (hf_field->strings) {
589 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
592 val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
595 switch(hf_field->display){
597 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
603 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
609 DISSECTOR_ASSERT_NOT_REACHED();
613 }else if((hf_field->type==FT_INT32)&&(descriptor==H264_SE_V)){
614 if (hf_field->strings) {
615 proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
618 val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
621 switch(hf_field->display){
623 proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
629 DISSECTOR_ASSERT_NOT_REACHED();
633 *start_bit_offset = bit_offset;
637 /* Only allow guint32 */
638 DISSECTOR_ASSERT_NOT_REACHED();
642 *start_bit_offset = bit_offset;
647 /* This function is adapted to parsing NAL units from SDP data where the
648 * base64 coding may add extra padding
652 more_rbsp_data(proto_tree *tree _U_, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
656 int remaining_length;
660 /* XXX might not be the best way of doing things but:
661 * Serch from the end of the tvb for the first '1' bit
662 * assuming that its's the RTBSP stop bit
665 /* Set offset to the byte we are treating */
666 offset = bit_offset>>3;
667 remaining_length = tvb_length_remaining(tvb,offset);
668 /* If there is more then 2 bytes left there *should* be more data */
669 if(remaining_length>2){
672 /* Start from last bit */
673 last_one_bit = (tvb_length(tvb) << 3);
677 b = tvb_get_bits8(tvb, last_one_bit, 1);
680 if( last_one_bit == bit_offset){
688 dissect_h264_rbsp_trailing_bits(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
690 gint remaining_bits=0;
692 proto_tree_add_bits_item(tree, hf_h264_rbsp_stop_bit, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
695 if((bit_offset&0x7)!=0){
696 remaining_bits = 8 - (bit_offset&0x7);
697 proto_tree_add_bits_item(tree, hf_h264_rbsp_trailing_bits, tvb, bit_offset, remaining_bits, ENC_BIG_ENDIAN);
700 return bit_offset+remaining_bits;
704 * 7.3.3 Slice header syntax
706 * XXX Just parse a few bytes
709 dissect_h264_slice_header(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
711 /* first_mb_in_slice 2 ue(v) */
712 dissect_h264_exp_golomb_code(tree, hf_h264_first_mb_in_slice, tvb, &bit_offset, H264_UE_V);
714 /* slice_type 2 ue(v) */
715 dissect_h264_exp_golomb_code(tree, hf_h264_slice_type, tvb, &bit_offset, H264_UE_V);
717 /* pic_parameter_set_id 2 ue(v) */
718 dissect_h264_exp_golomb_code(tree, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
720 /* frame_num 2 u(v) */
722 * represented by log2_max_frame_num_minus4 + 4 bits in
724 * proto_tree_add_bits_item(tree, hf_h264_frame_num, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
732 /* 7.3.2.1.1 Scaling list syntax
734 * scaling_list( scalingList, sizeOfScalingList, useDefaultScalingMatrixFlag )
738 dissect_h264_scaling_list(proto_tree *tree, tvbuff_t *tvb, gint bit_offset, int hf_index_scalinglist,
739 guint8 sizeOfScalingList, int hf_index_usedefaultscalingmatrixflag)
742 guint8 lastScale = 8;
743 guint8 nextScale = 8:
746 for( j = 0; j < sizeOfScalingList; j++ ) {
747 if( nextScale != 0 ) {
748 / delta_scale 0 | 1 se(v) /
749 delta_scale = dissect_h264_exp_golomb_code(tree, hf_h264_delta_scale, tvb, &bit_offset);
750 nextScale = ( lastScale + delta_scale + 256 ) % 256;
751 useDefaultScalingMatrixFlag = ( j == 0 && nextScale == 0 );
753 scalingList[ j ] = ( nextScale == 0 ) ? lastScale : nextScale
754 lastScale = scalingList[ j ]
758 /* E.1.2 HRD parameters syntax */
760 dissect_h264_hrd_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
762 guint8 cpb_cnt_minus1;
766 /* cpb_cnt_minus1 0 ue(v) */
767 cpb_cnt_minus1 = dissect_h264_exp_golomb_code(tree, hf_h264_cpb_cnt_minus1, tvb, &bit_offset, H264_UE_V);
769 /* bit_rate_scale 0 u(4) */
770 proto_tree_add_bits_item(tree, hf_h264_bit_rate_scale, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
771 bit_offset = bit_offset + 4;
773 /* cpb_size_scale 0 u(4) */
774 proto_tree_add_bits_item(tree, hf_h264_cpb_size_scale, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
775 bit_offset = bit_offset + 4;
776 /* for( SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++ ) { */
777 for( SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++ ) {
779 /* bit_rate_value_minus1[ SchedSelIdx ] 0 ue(v) */
780 dissect_h264_exp_golomb_code(tree, hf_h264_bit_rate_value_minus1, tvb, &bit_offset, H264_UE_V);
782 /* cpb_size_value_minus1[ SchedSelIdx ] 0 ue(v)*/
783 dissect_h264_exp_golomb_code(tree, hf_h264_cpb_size_value_minus1, tvb, &bit_offset, H264_UE_V);
785 /* cbr_flag[ SchedSelIdx ] 0 u(1) */
786 proto_tree_add_bits_item(tree, hf_h264_cbr_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
789 /* initial_cpb_removal_delay_length_minus1 0 u(5) */
790 proto_tree_add_bits_item(tree, hf_h264_initial_cpb_removal_delay_length_minus1, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
791 bit_offset = bit_offset + 5;
793 /* cpb_removal_delay_length_minus1 0 u(5) */
794 proto_tree_add_bits_item(tree, hf_h264_cpb_removal_delay_length_minus1, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
795 bit_offset = bit_offset + 5;
797 /* dpb_output_delay_length_minus1 0 u(5) */
798 proto_tree_add_bits_item(tree, hf_h264_dpb_output_delay_length_minus11, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
799 bit_offset = bit_offset + 5;
801 /* time_offset_length 0 u(5) */
802 proto_tree_add_bits_item(tree, hf_h264_time_offset_length, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
803 bit_offset = bit_offset + 5;
808 #define EXTENDED_SAR 255
810 /* E.1.1 VUI parameters syntax */
812 /* Table E-2 - Meaning of video_format */
813 static const value_string h264_video_format_vals[] = {
814 { 22, "reserved_sei_message)" },
820 { 5, "Unspecified video format" },
826 dissect_h264_vui_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint bit_offset)
829 guint8 aspect_ratio_info_present_flag, aspect_ratio_idc, overscan_info_present_flag;
830 guint8 video_signal_type_present_flag, colour_description_present_flag, chroma_loc_info_present_flag;
831 guint8 timing_info_present_flag, nal_hrd_parameters_present_flag, vcl_hrd_parameters_present_flag;
832 guint8 bitstream_restriction_flag;
834 /* vui_parameters( ) {
835 * aspect_ratio_info_present_flag 0 u(1)
837 aspect_ratio_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
838 proto_tree_add_bits_item(tree, hf_h264_aspect_ratio_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
841 if( aspect_ratio_info_present_flag ) {
842 /* aspect_ratio_idc 0 u(8) */
843 aspect_ratio_idc = tvb_get_bits8(tvb, bit_offset, 8);
844 proto_tree_add_bits_item(tree, hf_h264_aspect_ratio_idc, tvb, bit_offset, 8, ENC_BIG_ENDIAN);
845 bit_offset = bit_offset + 8;
847 if( aspect_ratio_idc == EXTENDED_SAR ) {
848 /* sar_width 0 u(16) */
849 proto_tree_add_bits_item(tree, hf_h264_sar_width, tvb, bit_offset, 16, ENC_BIG_ENDIAN);
850 bit_offset = bit_offset + 16;
852 /* sar_height 0 u(16) */
853 proto_tree_add_bits_item(tree, hf_h264_sar_height, tvb, bit_offset, 16, ENC_BIG_ENDIAN);
854 bit_offset = bit_offset + 16;
857 /* overscan_info_present_flag 0 u(1) */
858 overscan_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
859 proto_tree_add_bits_item(tree, hf_h264_overscan_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
862 if( overscan_info_present_flag ){
863 /* overscan_appropriate_flag 0 u(1) */
864 proto_tree_add_bits_item(tree, hf_h264_overscan_appropriate_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
868 /* video_signal_type_present_flag 0 u(1) */
869 video_signal_type_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
870 proto_tree_add_bits_item(tree, hf_h264_video_signal_type_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
873 if( video_signal_type_present_flag ) {
874 /* video_format 0 u(3) > */
875 proto_tree_add_bits_item(tree, hf_h264_video_format, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
876 bit_offset = bit_offset + 3;
878 /* video_full_range_flag 0 u(1)*/
879 proto_tree_add_bits_item(tree, hf_h264_video_full_range_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
882 /* colour_description_present_flag 0 u(1) */
883 colour_description_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
884 proto_tree_add_bits_item(tree, hf_h264_colour_description_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
887 if( colour_description_present_flag ) {
888 /* colour_primaries 0 u(8) */
889 proto_tree_add_bits_item(tree, hf_h264_colour_primaries, tvb, bit_offset, 8, ENC_BIG_ENDIAN);
890 bit_offset = bit_offset + 8;
892 /* transfer_characteristics 0 u(8) */
893 proto_tree_add_bits_item(tree, hf_h264_transfer_characteristics, tvb, bit_offset, 8, ENC_BIG_ENDIAN);
894 bit_offset = bit_offset + 8;
896 /* matrix_coefficients 0 u(8)*/
897 proto_tree_add_bits_item(tree, hf_h264_matrix_coefficients, tvb, bit_offset, 8, ENC_BIG_ENDIAN);
898 bit_offset = bit_offset + 8;
902 /* chroma_loc_info_present_flag 0 u(1) */
903 chroma_loc_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
904 proto_tree_add_bits_item(tree, hf_h264_chroma_loc_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
907 if( chroma_loc_info_present_flag ) {
908 /* chroma_sample_loc_type_top_field 0 ue(v) */
909 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_sample_loc_type_top_field, tvb, &bit_offset, H264_UE_V);
911 /* chroma_sample_loc_type_bottom_field 0 ue(v) */
912 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_sample_loc_type_bottom_field, tvb, &bit_offset, H264_UE_V);
915 /* timing_info_present_flag 0 u(1) */
916 timing_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
917 proto_tree_add_bits_item(tree, hf_h264_timing_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
920 if( timing_info_present_flag ) {
921 /* num_units_in_tick 0 u(32) */
922 proto_tree_add_bits_item(tree, hf_h264_num_units_in_tick, tvb, bit_offset, 32, ENC_BIG_ENDIAN);
923 bit_offset = bit_offset + 32;
925 /* time_scale 0 u(32) */
926 proto_tree_add_bits_item(tree, hf_h264_time_scale, tvb, bit_offset, 32, ENC_BIG_ENDIAN);
927 bit_offset = bit_offset + 32;
929 /* fixed_frame_rate_flag 0 u(1) */
930 proto_tree_add_bits_item(tree, hf_h264_fixed_frame_rate_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
933 /* nal_hrd_parameters_present_flag 0 u(1) */
934 nal_hrd_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
935 proto_tree_add_bits_item(tree, hf_h264_nal_hrd_parameters_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
938 if( nal_hrd_parameters_present_flag ){
939 /* hrd_parameters( ) */
940 bit_offset = dissect_h264_hrd_parameters(tree, tvb, pinfo, bit_offset);
943 /* vcl_hrd_parameters_present_flag 0 u(1) */
944 vcl_hrd_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
945 proto_tree_add_bits_item(tree, hf_h264_vcl_hrd_parameters_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
948 if( vcl_hrd_parameters_present_flag ){
949 /* hrd_parameters( ) */
950 bit_offset = dissect_h264_hrd_parameters(tree, tvb, pinfo, bit_offset);
952 if( nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag ){
953 /* low_delay_hrd_flag 0 u(1) */
954 proto_tree_add_bits_item(tree, hf_h264_low_delay_hrd_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
957 /* pic_struct_present_flag 0 u(1) */
958 proto_tree_add_bits_item(tree, hf_h264_pic_struct_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
961 /* bitstream_restriction_flag 0 u(1) */
962 bitstream_restriction_flag = tvb_get_bits8(tvb, bit_offset, 1);
963 proto_tree_add_bits_item(tree, hf_h264_bitstream_restriction_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
966 if( bitstream_restriction_flag ) {
967 /* motion_vectors_over_pic_boundaries_flag 0 u(1) */
968 proto_tree_add_bits_item(tree, hf_h264_motion_vectors_over_pic_boundaries_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
971 /* max_bytes_per_pic_denom 0 ue(v) */
972 dissect_h264_exp_golomb_code(tree, hf_h264_max_bytes_per_pic_denom, tvb, &bit_offset, H264_UE_V);
974 /* max_bits_per_mb_denom 0 ue(v) */
975 dissect_h264_exp_golomb_code(tree, hf_h264_max_bits_per_mb_denom, tvb, &bit_offset, H264_UE_V);
977 /* log2_max_mv_length_horizontal 0 ue(v) */
978 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_mv_length_horizontal, tvb, &bit_offset, H264_UE_V);
980 /* log2_max_mv_length_vertical 0 ue(v) */
981 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_mv_length_vertical, tvb, &bit_offset, H264_UE_V);
983 /* num_reorder_frames 0 ue(v) */
984 dissect_h264_exp_golomb_code(tree, hf_h264_num_reorder_frames, tvb, &bit_offset, H264_UE_V);
986 /* max_dec_frame_buffering 0 ue(v) */
987 dissect_h264_exp_golomb_code(tree, hf_h264_max_dec_frame_buffering, tvb, &bit_offset, H264_UE_V);
994 /* Used To dissect SDP parameter (H.264)profile */
996 dissect_h264_profile(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
998 proto_item *item, *level_item;
999 proto_tree *h264_profile_tree;
1001 guint8 constraint_set3_flag;
1004 item = proto_tree_add_item(tree, hf_h264_profile, tvb, offset, -1, ENC_NA);
1005 h264_profile_tree = proto_item_add_subtree(item, ett_h264_profile);
1007 proto_tree_add_item(h264_profile_tree, hf_h264_profile_idc, tvb, offset, 1, ENC_BIG_ENDIAN);
1010 constraint_set3_flag = (tvb_get_guint8(tvb,offset)&0x10)>>4;
1011 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set0_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1012 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set1_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1013 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set2_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1014 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set3_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1015 proto_tree_add_item(h264_profile_tree, hf_h264_reserved_zero_4bits, tvb, offset, 1, ENC_BIG_ENDIAN);
1018 /* A level to which the bitstream conforms shall be indicated by the syntax element level_idc as follows.
1019 * - If level_idc is equal to 11 and constraint_set3_flag is equal to 1, the indicated level is level 1b.
1020 * - Otherwise (level_idc is not equal to 11 or constraint_set3_flag is not equal to 1), level_idc shall
1021 * be set equal to a value of ten times the level number specified in Table A-1 and constraint_set3_flag
1022 * shall be set equal to 0.
1025 level_idc = tvb_get_guint8(tvb,offset);
1026 level_item = proto_tree_add_item(h264_profile_tree, hf_h264_level_idc, tvb, offset, 1, ENC_BIG_ENDIAN);
1027 if((level_idc==11)&&(constraint_set3_flag==1)){
1028 proto_item_append_text(level_item," [Level 1b (128kb/s)]");
1030 proto_item_append_text(level_item," [Level %.1f %s]",((double)level_idc/10),val_to_str(level_idc, h264_level_bitrate_values, "Unknown "));
1036 * 7.3.2.8 Slice layer without partitioning RBSP syntax
1037 * slice_layer_without_partitioning_rbsp( )
1041 dissect_h264_slice_layer_without_partitioning_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1045 bit_offset = offset <<3;
1047 /* slice_header( ) 2 */
1048 bit_offset = dissect_h264_slice_header(tree, tvb, pinfo, bit_offset);
1049 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1051 /* slice_data( ) * all categories of slice_data( ) syntax * 2 | 3 | 4 */
1052 /* rbsp_slice_trailing_bits( ) */
1057 * 7.3.2.9.1 Slice data partition A RBSP syntax
1058 * slice_data_partition_a_layer_rbsp( )
1061 dissect_h264_slice_data_partition_a_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1065 bit_offset = offset <<3;
1067 /* slice_header( ) 2 */
1068 bit_offset = dissect_h264_slice_header(tree, tvb, pinfo, bit_offset);
1070 /* slice_id All ue(v) */
1071 dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1072 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1074 /* slice_data( ) * only category 2 parts of slice_data( ) syntax * 2*/
1075 /* rbsp_slice_trailing_bits( )*/
1080 * 7.3.2.9.2 Slice data partition B RBSP syntax
1081 * slice_data_partition_b_layer_rbsp(
1084 dissect_h264_slice_data_partition_b_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1088 bit_offset = offset <<3;
1090 /* slice_id All ue(v) */
1091 dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1092 /* if( redundant_pic_cnt_present_flag ) */
1093 /* redundant_pic_cnt All ue(v) */
1094 /* slice_data( ) * only category 3 parts of slice_data( ) syntax * 3 */
1095 /* rbsp_slice_trailing_bits( ) 3 */
1096 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1101 * 7.3.2.9.3 Slice data partition C RBSP syntax
1102 * slice_data_partition_c_layer_rbsp( )
1105 dissect_h264_slice_data_partition_c_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1109 bit_offset = offset <<3;
1111 /* slice_id All ue(v) */
1112 dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1113 /* if( redundant_pic_cnt_present_flag ) */
1114 /* redundant_pic_cnt All ue(v) */
1115 /* slice_data( ) * only category 4 parts of slice_data( ) syntax * 4 */
1116 /* rbsp_slice_trailing_bits( ) 4 */
1117 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1120 /* D.1.6 User data unregistered SEI message syntax */
1123 h264_user_data_unregistered(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset, guint32 payloadSize)
1125 /* user_data_unregistered( payloadSize ) { C Descriptor */
1126 /* uuid_iso_iec_11578 5 u(128)
1127 * uuid_iso_iec_11578 shall have a value specified as a UUID
1128 * according to the procedures of ISO/IEC 11578:1996 Annex A.
1130 proto_tree_add_text(tree, tvb, bit_offset>>3, 16, "uuid_iso_iec_1157");
1132 /* for( i = 16; i < payloadSize; i++ )
1133 * user_data_payload_byte 5 b(8)
1135 proto_tree_add_text(tree, tvb, bit_offset>>3, payloadSize-16, "user_data_payload");
1136 bit_offset+=(payloadSize-16)<<3;
1140 /* D.1 SEI payload syntax */
1141 static const value_string h264_sei_payload_vals[] = {
1142 { 0, "buffering_period" },
1143 { 1, "pic_timing" },
1144 { 2, "pan_scan_rect" },
1145 { 3, "filler_payload" },
1146 { 4, "user_data_registered_itu_t_t35" },
1147 { 5, "user_data_unregistered" },
1148 { 6, "recovery_point" },
1149 { 7, "dec_ref_pic_marking_repetition" },
1151 { 9, "scene_inf)" },
1152 { 10, "sub_seq_info)" },
1153 { 11, "sub_seq_layer_characteristics" },
1154 { 12, "sub_seq_characteristics" },
1155 { 13, "full_frame_freeze_release" },
1156 { 14, "full_frame_freeze_release" },
1157 { 15, "full_frame_snapshot" },
1158 { 16, "progressive_refinement_segment_start" },
1159 { 17, "progressive_refinement_segment_end" },
1160 { 18, "motion_constrained_slice_group_set" },
1161 { 19, "film_grain_characteristics)" },
1162 { 20, "deblocking_filter_display_preference)" },
1163 { 21, "stereo_video_info)" },
1164 { 22, "reserved_sei_message)" },
1169 h264_sei_payload(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset, guint32 payloadType, guint32 payloadSize)
1171 /* sei_payload( payloadType, payloadSize ) { C Descriptor */
1172 if( payloadType == 0 ){
1173 /* buffering_period( payloadSize ) 5 */
1174 bit_offset = bit_offset +(payloadSize<<3);
1176 }else if( payloadType == 1 ){
1177 /* pic_timing( payloadSize ) 5 */
1178 }else if( payloadType == 2 ){
1179 /* pan_scan_rect( payloadSize ) 5 */
1180 }else if( payloadType == 3 ){
1181 /* filler_payload( payloadSize ) 5 */
1182 }else if( payloadType == 4 ){
1183 /* user_data_registered_itu_t_t35( payloadSize ) 5 */
1185 }else if( payloadType == 5 ){
1186 /* user_data_unregistered( payloadSize ) 5 */
1187 bit_offset = h264_user_data_unregistered( tree, tvb, pinfo, bit_offset, payloadSize);
1188 }else if( payloadType == 6 ){
1189 /* recovery_point( payloadSize ) 5 */
1190 bit_offset = bit_offset +(payloadSize<<3);
1191 }else if( payloadType == 7 ){
1192 /* dec_ref_pic_marking_repetition( payloadSize ) 5 */
1193 bit_offset = bit_offset +(payloadSize<<3);
1196 else if( payloadType == 8 )
1197 spare_pic( payloadSize ) 5
1198 else if( payloadType == 9 )
1199 scene_info( payloadSize ) 5
1200 else if( payloadType == 10 )
1201 sub_seq_info( payloadSize ) 5
1202 else if( payloadType == 11 )
1203 sub_seq_layer_characteristics( payloadSize ) 5
1204 else if( payloadType == 12 )
1205 sub_seq_characteristics( payloadSize ) 5
1206 else if( payloadType == 13 )
1207 full_frame_freeze( payloadSize ) 5
1208 else if( payloadType == 14 )
1209 full_frame_freeze_release( payloadSize ) 5
1210 else if( payloadType == 15 )
1211 full_frame_snapshot( payloadSize ) 5
1212 else if( payloadType == 16 )
1213 progressive_refinement_segment_start( payloadSize ) 5
1214 else if( payloadType == 17 )
1215 progressive_refinement_segment_end( payloadSize ) 5
1216 else if( payloadType == 18 )
1217 motion_constrained_slice_group_set( payloadSize ) 5
1218 else if( payloadType == 19 )
1219 film_grain_characteristics( payloadSize ) 5
1220 else if( payloadType == 20 )
1221 deblocking_filter_display_preference( payloadSize ) 5
1222 else if( payloadType == 21 )
1223 stereo_video_info( payloadSize ) 5
1225 reserved_sei_message( payloadSize ) 5
1228 if( !h264_byte_aligned(bit_offset)){
1229 /* bit_equal_to_one / * equal to 1 * / 5 f(1) */
1230 /* TODO:Display the filler and, error if not 1 ?? */
1232 while( !h264_byte_aligned(bit_offset)){
1233 /* bit_equal_to_zero / * equal to 0 * / 5 f(1) */
1234 /* TODO:Display the filler and, error if not 0 ?? */
1242 * 7.3.2.3.1 Supplemental enhancement information message syntax
1245 dissect_h264_sei_message(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint bit_offset)
1247 /* sei_message( ) { C Descriptor */
1248 guint32 payloadType = 0, payloadSize;
1249 gint start_bit_offset, length;
1251 start_bit_offset = bit_offset;
1253 /* while( next_bits( 8 ) == 0xFF ) { */
1254 while( tvb_get_bits8(tvb, bit_offset, 8) == 0xFF ) {
1255 /* ff_byte / * equal to 0xFF * / 5 f(8) */
1259 /* last_payload_type_byte 5 u(8) */
1260 payloadType += tvb_get_bits8(tvb, bit_offset, 8);
1262 length = (bit_offset - start_bit_offset)>>3;
1264 proto_tree_add_uint(tree, hf_h264_payloadtype, tvb, start_bit_offset>>3, length, payloadType);
1267 start_bit_offset = bit_offset;
1268 /* while( next_bits( 8 ) == 0xFF ) { */
1269 while( tvb_get_bits8(tvb, bit_offset, 8) == 0xFF ) {
1270 /* ff_byte / * equal to 0xFF * / 5 f(8) */
1274 /* last_payload_size_byte 5 u(8) */
1275 /* payloadSize += last_payload_size_byte */
1276 payloadSize += tvb_get_bits8(tvb, bit_offset, 8);
1278 length = (bit_offset - start_bit_offset)>>3;
1279 proto_tree_add_uint(tree, hf_h264_payloadsize, tvb, start_bit_offset>>3, length, payloadSize);
1281 /*sei_payload( payloadType, payloadSize ) 5 */
1282 bit_offset = h264_sei_payload( tree, tvb, pinfo, bit_offset, payloadType, payloadSize);
1286 * 7.3.2.3 Supplemental enhancement information RBSP syntax
1290 dissect_h264_sei_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1294 bit_offset = offset <<3;
1296 /* sei_message( ) 5*/
1297 bit_offset = dissect_h264_sei_message( tree, tvb, pinfo, bit_offset);
1299 /* while( more_rbsp_data( ) )
1300 * If there is more data in an RBSP before rbsp_trailing_bits( ),
1301 * the return value of more_rbsp_data( ) is equal to TRUE.
1303 /* rbsp_trailing_bits( ) 5 */
1304 bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1309 /* Ref 7.3.2.1 Sequence parameter set RBSP syntax */
1311 dissect_h264_seq_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1313 proto_item *level_item;
1315 guint8 constraint_set3_flag;
1319 guint8 profile_idc, chroma_format_idc, frame_mbs_only_flag, frame_cropping_flag;
1320 guint8 pic_order_cnt_type, vui_parameters_present_flag, num_ref_frames_in_pic_order_cnt_cycle;
1321 guint8 seq_scaling_matrix_present_flag; /* seq_scaling_list_present_flag */
1323 /* profile_idc 0 u(8) */
1324 profile_idc = tvb_get_guint8(tvb,offset);
1325 proto_tree_add_item(tree, hf_h264_profile_idc, tvb, offset, 1, ENC_BIG_ENDIAN);
1328 constraint_set3_flag = (tvb_get_guint8(tvb,offset)&0x10)>>4;
1329 /* constraint_set0_flag 0 u(1) */
1330 proto_tree_add_item(tree, hf_h264_constraint_set0_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1332 /* constraint_set1_flag 0 u(1) */
1333 proto_tree_add_item(tree, hf_h264_constraint_set1_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1335 /* constraint_set2_flag 0 u(1) */
1336 proto_tree_add_item(tree, hf_h264_constraint_set2_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1338 /* constraint_set3_flag 0 u(1) */
1339 proto_tree_add_item(tree, hf_h264_constraint_set3_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1341 /* reserved_zero_4bits equal to 0 0 u(4)*/
1342 proto_tree_add_item(tree, hf_h264_reserved_zero_4bits, tvb, offset, 1, ENC_BIG_ENDIAN);
1345 /* level_idc 0 u(8) */
1346 level_idc = tvb_get_guint8(tvb,offset);
1347 level_item = proto_tree_add_item(tree, hf_h264_level_idc, tvb, offset, 1, ENC_BIG_ENDIAN);
1348 if((level_idc==11)&&(constraint_set3_flag==1)){
1349 proto_item_append_text(level_item,"[Level 1b]");
1351 proto_item_append_text(level_item," [Level %.1f %s]",((double)level_idc/10),val_to_str(level_idc, h264_level_bitrate_values, "Unknown "));
1354 /* seq_parameter_set_id 0 ue(v)
1355 * ue(v): unsigned integer Exp-Golomb-coded syntax element with the left bit first.
1356 * The parsing process for this descriptor is specified in subclause 9.1.
1358 bit_offset = offset<<3;
1359 dissect_h264_exp_golomb_code(tree, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1362 if( profile_idc == 100 || profile_idc == 110 ||
1363 profile_idc == 122 || profile_idc == 144 ) {
1365 /* chroma_format_idc 0 ue(v) */
1366 chroma_format_idc = dissect_h264_exp_golomb_code(tree, hf_h264_chroma_format_idc, tvb, &bit_offset, H264_UE_V);
1367 if( chroma_format_idc == 3 ){
1368 /* residual_colour_transform_flag 0 u(1) */
1369 proto_tree_add_bits_item(tree, hf_h264_residual_colour_transform_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1373 /* bit_depth_luma_minus8 0 ue(v) */
1374 dissect_h264_exp_golomb_code(tree, hf_h264_bit_depth_luma_minus8, tvb, &bit_offset, H264_UE_V);
1376 /* bit_depth_chroma_minus8 0 ue(v) */
1377 dissect_h264_exp_golomb_code(tree, hf_h264_bit_depth_chroma_minus8, tvb, &bit_offset, H264_UE_V);
1379 /* qpprime_y_zero_transform_bypass_flag 0 u(1) */
1380 proto_tree_add_bits_item(tree, hf_h264_qpprime_y_zero_transform_bypass_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1383 /* seq_scaling_matrix_present_flag 0 u(1) */
1384 seq_scaling_matrix_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1385 proto_tree_add_bits_item(tree, hf_h264_seq_scaling_matrix_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1388 if( seq_scaling_matrix_present_flag ){
1390 for( i = 0; i < 8; i++ ) {
1391 / seq_scaling_list_present_flag[ i ] 0 u(1) /
1392 seq_scaling_list_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1394 if( seq_scaling_list_present_flag){
1396 scaling_list( ScalingList4x4[ i ], 16,UseDefaultScalingMatrix4x4Flag[ i ])0
1397 dissect_h264_scaling_list()
1399 scaling_list( ScalingList8x8[ i - 6 ], 64,UseDefaultScalingMatrix8x8Flag[ i - 6 ] )0
1403 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1409 /* log2_max_frame_num_minus4 0 ue(v) */
1410 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_frame_num_minus4, tvb, &bit_offset, H264_UE_V);
1412 /* pic_order_cnt_type 0 ue(v) */
1413 pic_order_cnt_type = dissect_h264_exp_golomb_code(tree,hf_h264_pic_order_cnt_type, tvb, &bit_offset, H264_UE_V);
1415 if(pic_order_cnt_type == 0){
1416 /* log2_max_pic_order_cnt_lsb_minus4 0 ue(v) */
1417 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_pic_order_cnt_lsb_minus4, tvb, &bit_offset, H264_UE_V);
1418 }else if(pic_order_cnt_type == 1) {
1419 /* delta_pic_order_always_zero_flag 0 u(1) */
1420 proto_tree_add_bits_item(tree, hf_h264_delta_pic_order_always_zero_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1423 /* offset_for_non_ref_pic 0 se(v) */
1424 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_non_ref_pic, tvb, &bit_offset, H264_SE_V);
1426 /* offset_for_top_to_bottom_field 0 se(v) */
1427 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_top_to_bottom_field, tvb, &bit_offset, H264_SE_V);
1429 /* num_ref_frames_in_pic_order_cnt_cycle 0 ue(v) */
1430 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);
1431 for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ ){
1432 /*offset_for_ref_frame[ i ] 0 se(v)*/
1433 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_ref_frame, tvb, &bit_offset, H264_SE_V);
1436 /* num_ref_frames 0 ue(v) */
1437 dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_frames, tvb, &bit_offset, H264_UE_V);
1439 /* gaps_in_frame_num_value_allowed_flag 0 u(1) */
1440 proto_tree_add_bits_item(tree, hf_h264_gaps_in_frame_num_value_allowed_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1443 /* pic_width_in_mbs_minus1 0 ue(v) */
1444 dissect_h264_exp_golomb_code(tree, hf_h264_pic_width_in_mbs_minus1, tvb, &bit_offset, H264_UE_V);
1446 /* pic_height_in_map_units_minus1 0 ue(v) */
1447 dissect_h264_exp_golomb_code(tree, hf_h264_pic_height_in_map_units_minus1, tvb, &bit_offset, H264_UE_V);
1449 /* frame_mbs_only_flag 0 u(1) */
1450 frame_mbs_only_flag = tvb_get_bits8(tvb, bit_offset, 1);
1451 proto_tree_add_bits_item(tree, hf_h264_frame_mbs_only_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1453 if( !frame_mbs_only_flag ){
1454 /* mb_adaptive_frame_field_flag 0 u(1) */
1455 proto_tree_add_bits_item(tree, hf_h264_mb_adaptive_frame_field_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1459 /* direct_8x8_inference_flag 0 u(1) */
1460 proto_tree_add_bits_item(tree, hf_h264_direct_8x8_inference_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1463 /* frame_cropping_flag 0 u(1) */
1464 frame_cropping_flag = tvb_get_bits8(tvb, bit_offset, 1);
1465 proto_tree_add_bits_item(tree, hf_h264_frame_cropping_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1468 if(frame_cropping_flag) {
1469 /* frame_crop_left_offset 0 ue(v) */
1470 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_left_offset, tvb, &bit_offset, H264_UE_V);
1471 dissect_h264_exp_golomb_code(tree,hf_h264_frame_crop_right_offset, tvb, &bit_offset, H264_UE_V);
1472 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_top_offset, tvb, &bit_offset, H264_UE_V);
1473 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_bottom_offset, tvb, &bit_offset, H264_UE_V);
1477 /* vui_parameters_present_flag 0 u(1) */
1478 vui_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1479 proto_tree_add_bits_item(tree, hf_h264_vui_parameters_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1481 if(vui_parameters_present_flag){
1482 bit_offset = dissect_h264_vui_parameters(tree, tvb, pinfo, bit_offset);
1485 /* rbsp_trailing_bits( ) 0 */
1486 bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1488 offset = bit_offset>>3;
1493 /* 7.3.2.2 Picture parameter set RBSP syntax */
1496 dissect_h264_pic_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1500 guint32 num_slice_groups_minus1, pic_scaling_matrix_present_flag;
1502 bit_offset = offset<<3;
1504 /* pic_parameter_set_id 1 ue(v) */
1505 dissect_h264_exp_golomb_code(tree, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1507 /* seq_parameter_set_id 1 ue(v) */
1508 dissect_h264_exp_golomb_code(tree, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1510 /* entropy_coding_mode_flag 1 u(1) */
1511 proto_tree_add_bits_item(tree, hf_h264_entropy_coding_mode_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1514 /* pic_order_present_flag 1 u(1)*/
1515 proto_tree_add_bits_item(tree, hf_h264_pic_order_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1518 /* num_slice_groups_minus1 1 ue(v)*/
1519 num_slice_groups_minus1 = dissect_h264_exp_golomb_code(tree, hf_h264_num_slice_groups_minus1, tvb, &bit_offset, H264_UE_V);
1520 if( num_slice_groups_minus1 > 0 ) {
1521 /* slice_group_map_type 1 ue(v)*/
1522 dissect_h264_exp_golomb_code(tree, hf_h264_slice_group_map_type, tvb, &bit_offset, H264_UE_V);
1523 /* slice_group_map_type = dissect_h264_exp_golomb_code(tree, hf_h264_slice_group_map_type, tvb, &bit_offset, H264_UE_V);*/
1524 /* if( slice_group_map_type == 0 )*/
1525 /* for( iGroup = 0; iGroup <= num_slice_groups_minus1; iGroup++ )*/
1526 /* run_length_minus1[ iGroup ] 1 ue(v)*/
1527 /* else if( slice_group_map_type == 2 )*/
1528 /* for( iGroup = 0; iGroup < num_slice_groups_minus1; iGroup++ ) {*/
1529 /* top_left[ iGroup ] 1 ue(v)*/
1530 /* bottom_right[ iGroup ] 1 ue(v)*/
1532 /* else if( slice_group_map_type == 3 ||*/
1533 /* slice_group_map_type == 4 ||*/
1534 /* slice_group_map_type == 5 ) {*/
1535 /* slice_group_change_direction_flag 1 u(1)*/
1536 /* slice_group_change_rate_minus1 1 ue(v)*/
1537 /* } else if( slice_group_map_type == 6 ) {*/
1538 /* pic_size_in_map_units_minus1 1 ue(v)*/
1539 /* for( i = 0; i <= pic_size_in_map_units_minus1; i++ )*/
1540 /* slice_group_id[ i ] 1 u(v)*/
1543 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1546 /* num_ref_idx_l0_active_minus1 1 ue(v)*/
1547 dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_idx_l0_active_minus1, tvb, &bit_offset, H264_UE_V);
1549 /* num_ref_idx_l1_active_minus1 1 ue(v)*/
1550 dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_idx_l1_active_minus1, tvb, &bit_offset, H264_UE_V);
1552 /* weighted_pred_flag 1 u(1)*/
1553 proto_tree_add_bits_item(tree, hf_h264_weighted_pred_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1556 /* weighted_bipred_idc 1 u(2)*/
1557 proto_tree_add_bits_item(tree, hf_h264_weighted_bipred_idc, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
1558 bit_offset= bit_offset+2;
1560 /* pic_init_qp_minus26 * relative to 26 * 1 se(v)*/
1561 dissect_h264_exp_golomb_code(tree, hf_h264_pic_init_qp_minus26, tvb, &bit_offset, H264_SE_V);
1563 /* pic_init_qs_minus26 * relative to 26 * 1 se(v)*/
1564 dissect_h264_exp_golomb_code(tree, hf_h264_pic_init_qs_minus26, tvb, &bit_offset, H264_SE_V);
1566 /* chroma_qp_index_offset 1 se(v)*/
1567 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
1569 /* deblocking_filter_control_present_flag 1 u(1)*/
1570 proto_tree_add_bits_item(tree, hf_h264_deblocking_filter_control_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1573 /* constrained_intra_pred_flag 1 u(1)*/
1574 proto_tree_add_bits_item(tree, hf_h264_constrained_intra_pred_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1577 /* redundant_pic_cnt_present_flag 1 u(1)*/
1578 proto_tree_add_bits_item(tree, hf_h264_redundant_pic_cnt_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1581 if( more_rbsp_data(tree, tvb, pinfo, bit_offset)){
1582 /* transform_8x8_mode_flag 1 u(1)*/
1583 proto_tree_add_bits_item(tree, hf_h264_transform_8x8_mode_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1586 /* pic_scaling_matrix_present_flag 1 u(1)*/
1587 pic_scaling_matrix_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1588 proto_tree_add_bits_item(tree, hf_h264_pic_scaling_matrix_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1591 if( pic_scaling_matrix_present_flag ){
1592 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1594 /* for( i = 0; i < 6 + 2* transform_8x8_mode_flag; i++ ) {*/
1595 /* pic_scaling_list_present_flag[ i ] 1 u(1)*/
1596 /* if( pic_scaling_list_present_flag[ i ] )*/
1598 /* scaling_list( ScalingList4x4[ i ], 16, UseDefaultScalingMatrix4x4Flag[ i ] )*/
1600 /* scaling_list( ScalingList8x8[ i - 6 ], 64, UseDefaultScalingMatrix8x8Flag[ i - 6 ] )*/
1604 /* second_chroma_qp_index_offset 1 se(v)*/
1605 dissect_h264_exp_golomb_code(tree, hf_h264_second_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
1607 bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1612 * 7.3.2.4 Access unit delimiter RBSP syntax
1613 * access_unit_delimiter_rbsp( )
1616 dissect_h264_access_unit_delimiter_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1618 /* primary_pic_type 6 u(3) */
1619 /* rbsp_trailing_bits( ) 6 */
1620 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1625 * 7.3.2.5 End of sequence RBSP syntax
1626 * end_of_seq_rbsp( ) {}
1629 dissect_h264_end_of_seq_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1631 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1636 * 7.3.2.6 End of stream RBSP syntax
1637 * end_of_stream_rbsp( ) {}
1640 dissect_h264_end_of_stream_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1642 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1647 * 7.3.2.7 Filler data RBSP syntax
1648 * filler_data_rbsp( )
1651 dissect_h264_filler_data_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1653 /* while( next_bits( 8 ) == 0xFF ) */
1654 /* ff_byte * equal to 0xFF * 9 f(8) */
1655 /* rbsp_trailing_bits( ) 9 */
1656 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1661 * 7.3.2.1.2 Sequence parameter set extension RBSP syntax
1662 * seq_parameter_set_extension_rbsp( )
1665 dissect_h264_seq_parameter_set_extension_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1667 /* seq_parameter_set_id 10 ue(v) */
1668 /* aux_format_idc 10 ue(v) */
1669 /* if( aux_format_idc != 0 ) { */
1670 /* bit_depth_aux_minus8 10 ue(v) */
1671 /* alpha_incr_flag 10 u(1) */
1672 /* alpha_opaque_value 10 u(v) */
1673 /* alpha_transparent_value 10 u(v) */
1675 /* additional_extension_flag 10 u(1) */
1676 /* rbsp_trailing_bits() 10 */
1677 proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1683 * Dissect NAL unit as recived in sprop-parameter-sets of SDP
1684 * or "DecoderConfiguration parameter in H.245
1687 dissect_h264_nal_unit(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1690 proto_tree *h264_nal_tree;
1692 guint8 nal_unit_type;
1694 item = proto_tree_add_item(tree, hf_h264_nal_unit, tvb, offset, -1, ENC_NA);
1695 h264_nal_tree = proto_item_add_subtree(item, ett_h264_nal_unit);
1698 /* In decoder configuration start code may be pressent
1699 * B.1.1 Byte stream NAL unit syntax
1701 dword = tvb_get_bits32(tvb, offset<<3, 32, ENC_BIG_ENDIAN);
1703 /* zero_byte + start_code_prefix_one_3bytes */
1705 }else if((dword >> 8)== 1){
1706 /* start_code_prefix_one_3bytes */
1709 /* Ref: 7.3.1 NAL unit syntax */
1710 nal_unit_type = tvb_get_guint8(tvb,offset) & 0x1f;
1712 /* forbidden_zero_bit All f(1) */
1713 proto_tree_add_item(h264_nal_tree, hf_h264_forbidden_zero_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1714 /* nal_ref_idc All u(2) */
1715 proto_tree_add_item(h264_nal_tree, hf_h264_nal_ref_idc, tvb, offset, 1, ENC_BIG_ENDIAN);
1716 /* nal_unit_type All u(5) */
1717 proto_tree_add_item(h264_nal_tree, hf_h264_nal_unit_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1720 switch(nal_unit_type){
1721 case 0: /* Unspecified */
1722 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Unspecified NAL unit type");
1724 case 1: /* Coded slice of a non-IDR picture */
1725 dissect_h264_slice_layer_without_partitioning_rbsp(h264_nal_tree, tvb, pinfo, offset);
1727 case 2: /* Coded slice data partition A */
1728 dissect_h264_slice_data_partition_a_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1730 case 3: /* Coded slice data partition B */
1731 dissect_h264_slice_data_partition_b_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1733 case 4: /* Coded slice data partition C */
1734 dissect_h264_slice_data_partition_c_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1736 case 5: /* Coded slice of an IDR picture */
1737 dissect_h264_slice_layer_without_partitioning_rbsp(h264_nal_tree, tvb, pinfo, offset);
1739 case 6: /* Supplemental enhancement information (SEI) */
1740 dissect_h264_sei_rbsp(h264_nal_tree, tvb, pinfo, offset);
1742 case H264_SEQ_PAR_SET: /* 7 Sequence parameter set*/
1743 offset = dissect_h264_seq_parameter_set_rbsp(h264_nal_tree, tvb, pinfo, offset);
1745 if(tvb_length_remaining(tvb,offset) > 0){
1746 /* In this case length = offset as we start from zero */
1747 proto_item_set_len(item, offset/*Length */);
1748 item = proto_tree_add_item(tree, hf_h264_nal_unit, tvb, offset, -1, ENC_NA);
1749 h264_nal_tree = proto_item_add_subtree(item, ett_h264_nal_unit);
1753 case H264_PIC_PAR_SET: /* 8 Picture parameter set */
1754 dissect_h264_pic_parameter_set_rbsp(h264_nal_tree, tvb, pinfo, offset);
1756 case 9: /* Access unit delimiter */
1757 dissect_h264_access_unit_delimiter_rbsp(h264_nal_tree, tvb, pinfo, offset);
1759 case 10: /* End of sequence */
1760 dissect_h264_end_of_seq_rbsp(h264_nal_tree, tvb, pinfo, offset);
1762 case 11: /* End of stream */
1763 dissect_h264_end_of_stream_rbsp(h264_nal_tree, tvb, pinfo, offset);
1765 case 12: /* Filler data */
1766 dissect_h264_filler_data_rbsp(h264_nal_tree, tvb, pinfo, offset);
1768 case 13: /* Sequence parameter set extension */
1769 dissect_h264_seq_parameter_set_extension_rbsp(h264_nal_tree, tvb, pinfo, offset);
1771 case 14: /* Reserved */
1772 case 15: /* Reserved */
1773 case 16: /* Reserved */
1774 case 17: /* Reserved */
1775 case 18: /* Reserved */
1776 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Reserved NAL unit type");
1778 case 19: /* Coded slice of an auxiliary coded picture without partitioning */
1779 dissect_h264_slice_layer_without_partitioning_rbsp(tree, tvb, pinfo, offset);
1782 dissect_h264_slice_layer_without_partitioning_rbsp(tree, tvb, pinfo, offset);
1785 /* 24..31 Unspecified */
1786 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Unspecified NAL unit type");
1791 /* Code to actually dissect the packets */
1793 dissect_h264(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1796 proto_item *item, *ti, *stream_item, *fua_item;
1797 proto_tree *h264_tree, *h264_nal_tree, *stream_tree, *fua_tree;
1801 /* Make entries in Protocol column and Info column on summary display */
1802 col_set_str(pinfo->cinfo, COL_PROTOCOL, "H264");
1805 item = proto_tree_add_item(tree, proto_h264, tvb, 0, -1, ENC_NA);
1806 h264_tree = proto_item_add_subtree(item, ett_h264);
1808 type = tvb_get_guint8(tvb,offset)&0x1f;
1809 /* if the type is 28, it would be draw another title */
1811 ti = proto_tree_add_text(h264_tree, tvb, offset, 1, "FU identifier");
1813 ti = proto_tree_add_text(h264_tree, tvb, offset, 1, "NAL unit header or first byte of the payload");
1814 h264_nal_tree = proto_item_add_subtree(ti, ett_h264_nal);
1816 /* +---------------+
1824 * forbidden_zero_bit. A value of 0 indicates that the NAL unit type
1825 * octet and payload should not contain bit errors or other syntax
1826 * violations. A value of 1 indicates that the NAL unit type octet
1827 * and payload may contain bit errors or other syntax violations.
1829 proto_tree_add_item(h264_nal_tree, hf_h264_nal_f_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1830 proto_tree_add_item(h264_nal_tree, hf_h264_nal_nri, tvb, offset, 1, ENC_BIG_ENDIAN);
1831 col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
1832 val_to_str(type, h264_type_values, "Unknown Type (%u)"));
1834 proto_tree_add_item(h264_nal_tree, hf_h264_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1837 fua_item = proto_tree_add_text(h264_tree, tvb, offset, 1, "FU Header");
1838 fua_tree = proto_item_add_subtree(fua_item, ett_h264_fua);
1839 proto_tree_add_item(fua_tree, hf_h264_start_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1840 proto_tree_add_item(fua_tree, hf_h264_end_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1841 proto_tree_add_item(fua_tree, hf_h264_forbidden_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1842 proto_tree_add_item(fua_tree, hf_h264_nal_unit_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1843 if ( (tvb_get_guint8(tvb,offset)&0x80) == 0x80 ){
1844 type = tvb_get_guint8(tvb,offset)&0x1f;
1850 stream_item =proto_tree_add_text(h264_tree, tvb, offset, -1, "H264 bitstream");
1851 stream_tree = proto_item_add_subtree(stream_item, ett_h264_stream);
1853 case 1: /* 1 Coded slice of a non-IDR picture */
1854 dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, tvb, pinfo, offset);
1856 case 3: /* Coded slice data partition B */
1857 dissect_h264_slice_data_partition_b_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1859 case 4: /* Coded slice data partition C */
1860 dissect_h264_slice_data_partition_c_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1862 case 5: /* Coded slice of an IDR picture */
1863 dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, tvb, pinfo, offset);
1865 case 6: /* Supplemental enhancement information (SEI) */
1866 dissect_h264_sei_rbsp(stream_tree, tvb, pinfo, offset);
1868 case H264_SEQ_PAR_SET: /* 7 Sequence parameter set*/
1869 dissect_h264_seq_parameter_set_rbsp(stream_tree, tvb, pinfo, offset);
1871 case H264_PIC_PAR_SET: /* 8 Picture parameter set */
1872 dissect_h264_pic_parameter_set_rbsp(stream_tree, tvb, pinfo, offset);
1874 case 19: /* Coded slice of an auxiliary coded picture without partitioning */
1875 dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, tvb, pinfo, offset);
1887 static const int *profile_fields[] = {
1888 &hf_h264_par_profile_b,
1889 &hf_h264_par_profile_m,
1890 &hf_h264_par_profile_e,
1891 &hf_h264_par_profile_h,
1892 &hf_h264_par_profile_h10,
1893 &hf_h264_par_profile_h4_2_2,
1894 &hf_h264_par_profile_h4_4_4,
1899 dissect_h264_par_profile(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1903 proto_tree_add_bitmask(tree, tvb, offset,
1904 hf_h264_par_profile, ett_h264_par_profile,
1905 profile_fields, ENC_BIG_ENDIAN);
1910 static const int *AdditionalModesSupported_fields[] = {
1911 &hf_h264_par_add_mode_sup_rcdo,
1915 dissect_h264_par_AdditionalModesSupported(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1919 proto_tree_add_bitmask(tree, tvb, offset,
1920 hf_h264_par_AdditionalModesSupported, ett_h264_par_AdditionalModesSupported,
1921 AdditionalModesSupported_fields, ENC_BIG_ENDIAN);
1927 static const int *ProfileIOP_fields[] = {
1928 &hf_h264_par_constraint_set0_flag,
1929 &hf_h264_par_constraint_set1_flag,
1930 &hf_h264_par_constraint_set2_flag,
1936 dissect_h264_ProfileIOP(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1940 proto_tree_add_bitmask(tree, tvb, offset,
1941 hf_h264_par_ProfileIOP, ett_h264_par_ProfileIOP,
1942 ProfileIOP_fields, ENC_BIG_ENDIAN);
1947 static const value_string h264_par_level_values[] = {
1968 dissect_h264_par_level(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_)
1972 const gchar *p = NULL;
1975 actx = get_asn1_ctx(pinfo->private_data);
1976 DISSECTOR_ASSERT(actx);
1978 lvl = tvb_get_ntohs(tvb, offset);
1979 p = match_strval(lvl, VALS(h264_par_level_values));
1981 proto_item_append_text(actx->created_item, " - Level %s", p);
1987 dissect_h264_par_DecoderConfigurationInformation(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_)
1991 actx = get_asn1_ctx(pinfo->private_data);
1992 DISSECTOR_ASSERT(actx);
1994 dissect_h264_nal_unit(tvb, pinfo, tree);
1996 return tvb_length(tvb);
1999 typedef struct _h264_capability_t {
2002 new_dissector_t content_pdu;
2003 } h264_capability_t;
2005 static h264_capability_t h264_capability_tab[] = {
2006 /* ITU-T H.241 (05/2006), 8.3 H.264 capabilities */
2007 { "GenericCapability/0.0.8.241.0.0.1", "ITU-T Rec. H.241 H.264 Video Capabilities", NULL },
2008 { "GenericCapability/0.0.8.241.0.0.1/collapsing/41", "Profile", dissect_h264_par_profile },
2009 { "GenericCapability/0.0.8.241.0.0.1/collapsing/42", "Level", dissect_h264_par_level },
2010 { "GenericCapability/0.0.8.241.0.0.1/collapsing/3" , "CustomMaxMBPS", NULL },
2011 { "GenericCapability/0.0.8.241.0.0.1/collapsing/4" , "CustomMaxFS", NULL },
2012 { "GenericCapability/0.0.8.241.0.0.1/collapsing/5" , "CustomMaxDPB", NULL },
2013 { "GenericCapability/0.0.8.241.0.0.1/collapsing/6" , "CustomMaxBRandCPB", NULL },
2014 { "GenericCapability/0.0.8.241.0.0.1/collapsing/7" , "MaxStaticMBPS", NULL },
2015 { "GenericCapability/0.0.8.241.0.0.1/collapsing/8" , "max-rcmd-nal-unit-size", NULL },
2016 { "GenericCapability/0.0.8.241.0.0.1/collapsing/9" , "max-nal-unit-size", NULL },
2017 { "GenericCapability/0.0.8.241.0.0.1/collapsing/10", "SampleAspectRatiosSupported", NULL },
2018 { "GenericCapability/0.0.8.241.0.0.1/collapsing/11", "AdditionalModesSupported", dissect_h264_par_AdditionalModesSupported },
2019 { "GenericCapability/0.0.8.241.0.0.1/collapsing/12", "AdditionalDisplayCapabilities", NULL },
2020 /* TS 26.111 H.264 */
2021 { "GenericCapability/0.0.8.241.0.0.1/nonCollapsing/43" , "DecoderConfigurationInformation", dissect_h264_par_DecoderConfigurationInformation },
2022 { "GenericCapability/0.0.8.241.0.0.1/collapsing/44" , "AcceptRedundantSlices", NULL },
2023 { "GenericCapability/0.0.8.241.0.0.1/collapsing/45" , "NalAlignedMode", NULL },
2024 { "GenericCapability/0.0.8.241.0.0.1/collapsing/46" , "ProfileIOP", dissect_h264_ProfileIOP },
2025 { NULL, NULL, NULL },
2028 static h264_capability_t *find_cap(const gchar *id) {
2029 h264_capability_t *ftr = NULL;
2030 h264_capability_t *f;
2032 for (f=h264_capability_tab; f->id; f++) {
2033 if (!strcmp(id, f->id)) { ftr = f; break; }
2039 dissect_h264_name(tvbuff_t *tvb _U_, packet_info *pinfo, proto_tree *tree)
2042 h264_capability_t *ftr = NULL;
2044 actx = get_asn1_ctx(pinfo->private_data);
2045 DISSECTOR_ASSERT(actx);
2047 ftr = find_cap(pinfo->match_string);
2049 proto_item_append_text(actx->created_item, " - %s", ftr->name);
2050 proto_item_append_text(proto_item_get_parent(proto_tree_get_parent(tree)), ": %s", ftr->name);
2052 proto_item_append_text(actx->created_item, " - unknown(%s)", pinfo->match_string);
2058 static void range_delete_h264_rtp_pt_callback(guint32 rtp_pt) {
2059 if (rtp_pt >= 96 && rtp_pt <= 127)
2060 dissector_delete_uint("rtp.pt", rtp_pt, h264_handle);
2063 static void range_add_h264_rtp_pt_callback(guint32 rtp_pt) {
2064 if (rtp_pt >= 96 && rtp_pt <= 127)
2065 dissector_add_uint("rtp.pt", rtp_pt, h264_handle);
2070 /* Register the protocol with Wireshark */
2071 /* If this dissector uses sub-dissector registration add a registration routine.
2072 This format is required because a script is used to find these routines and
2073 create the code that calls these routines.
2076 proto_reg_handoff_h264(void)
2079 static range_t *dynamic_payload_type_range = NULL;
2080 static gboolean h264_prefs_initialized = FALSE;
2082 if (!h264_prefs_initialized) {
2083 dissector_handle_t h264_name_handle;
2084 h264_capability_t *ftr;
2086 h264_handle = find_dissector("h264");
2087 dissector_add_string("rtp_dyn_payload_type","H264", h264_handle);
2089 h264_name_handle = create_dissector_handle(dissect_h264_name, proto_h264);
2090 for (ftr=h264_capability_tab; ftr->id; ftr++) {
2092 dissector_add_string("h245.gef.name", ftr->id, h264_name_handle);
2093 if (ftr->content_pdu)
2094 dissector_add_string("h245.gef.content", ftr->id, new_create_dissector_handle(ftr->content_pdu, proto_h264));
2096 h264_prefs_initialized = TRUE;
2098 range_foreach(dynamic_payload_type_range, range_delete_h264_rtp_pt_callback);
2099 g_free(dynamic_payload_type_range);
2102 dynamic_payload_type_range = range_copy(temp_dynamic_payload_type_range);
2103 range_foreach(dynamic_payload_type_range, range_add_h264_rtp_pt_callback);
2106 /* this format is required because a script is used to build the C function
2107 that calls all the protocol registration.
2111 proto_register_h264(void)
2114 module_t *h264_module;
2116 /* Setup list of header fields See Section 1.6.1 for details*/
2117 static hf_register_info hf[] = {
2118 { &hf_h264_nal_f_bit,
2119 { "F bit", "h264.f",
2120 FT_BOOLEAN, 8, TFS(&h264_f_bit_vals), 0x80,
2124 { "Nal_ref_idc (NRI)", "h264.nal_nri",
2125 FT_UINT8, BASE_DEC, NULL, 0x60,
2129 { "Type", "h264.nal_unit_hdr",
2130 FT_UINT8, BASE_DEC, VALS(h264_type_values), 0x1f,
2133 { &hf_h264_start_bit,
2134 { "Start bit", "h264.start.bit",
2135 FT_BOOLEAN, 8, TFS(&h264_start_bit_vals), 0x80,
2139 { "End bit", "h264.end.bit",
2140 FT_BOOLEAN, 8, TFS(&h264_end_bit_vals), 0x40,
2143 { &hf_h264_forbidden_bit,
2144 { "Forbidden bit", "h264.forbidden.bit",
2145 FT_UINT8, BASE_DEC, NULL, 0x20,
2149 { "Profile", "h264.profile",
2150 FT_BYTES, BASE_NONE, NULL, 0x0,
2153 { &hf_h264_profile_idc,
2154 { "Profile_idc", "h264.profile_idc",
2155 FT_UINT8, BASE_DEC, VALS(h264_profile_idc_values), 0xff,
2158 { &hf_h264_rbsp_stop_bit,
2159 { "rbsp_stop_bit", "h264.rbsp_stop_bit",
2160 FT_UINT8, BASE_DEC, NULL, 0x0,
2163 { &hf_h264_rbsp_trailing_bits,
2164 { "rbsp_trailing_bits", "h264.rbsp_trailing_bits",
2165 FT_UINT8, BASE_DEC, NULL, 0x0,
2168 { &hf_h264_constraint_set0_flag,
2169 { "Constraint_set0_flag", "h264.constraint_set0_flag",
2170 FT_UINT8, BASE_DEC, NULL, 0x80,
2173 { &hf_h264_constraint_set1_flag,
2174 { "Constraint_set1_flag", "h264.constraint_set1_flag",
2175 FT_UINT8, BASE_DEC, NULL, 0x40,
2178 { &hf_h264_constraint_set2_flag,
2179 { "Constraint_set2_flag", "h264.constraint_set2_flag",
2180 FT_UINT8, BASE_DEC, NULL, 0x20,
2183 { &hf_h264_constraint_set3_flag,
2184 { "Constraint_set3_flag", "h264.constraint_set3_flag",
2185 FT_UINT8, BASE_DEC, NULL, 0x10,
2188 { &hf_h264_reserved_zero_4bits,
2189 { "Reserved_zero_4bits", "h264.reserved_zero_4bits",
2190 FT_UINT8, BASE_DEC, NULL, 0x0f,
2193 { &hf_h264_level_idc,
2194 { "Level_id", "h264.level_id",
2195 FT_UINT8, BASE_DEC, NULL, 0xff,
2198 { &hf_h264_nal_unit,
2199 { "NAL unit", "h264.nal_unit",
2200 FT_BYTES, BASE_NONE, NULL, 0x0,
2203 { &hf_h264_forbidden_zero_bit,
2204 { "Forbidden_zero_bit", "h264.forbidden_zero_bit",
2205 FT_UINT8, BASE_DEC, NULL, 0x80,
2208 { &hf_h264_nal_ref_idc,
2209 { "Nal_ref_idc", "h264.nal_ref_idc",
2210 FT_UINT8, BASE_DEC, NULL, 0x60,
2213 {&hf_h264_nal_unit_type,
2214 { "Nal_unit_type", "h264.nal_unit_type",
2215 FT_UINT8, BASE_DEC, VALS(h264_nal_unit_type_vals), 0x1f,
2218 { &hf_h264_seq_parameter_set_id,
2219 { "seq_parameter_set_id", "h264.seq_parameter_set_id",
2220 FT_UINT32, BASE_DEC, NULL, 0x0,
2223 { &hf_h264_chroma_format_idc,
2224 { "chroma_format_id", "h264.chroma_format_id",
2225 FT_UINT32, BASE_DEC, NULL, 0x0,
2228 { &hf_h264_residual_colour_transform_flag,
2229 { "residual_colour_transform_flag", "h264.residual_colour_transform_flag",
2230 FT_UINT8, BASE_DEC, NULL, 0x0,
2233 { &hf_h264_bit_depth_luma_minus8,
2234 { "bit_depth_luma_minus8", "h264.bit_depth_luma_minus8",
2235 FT_UINT32, BASE_DEC, NULL, 0x0,
2238 { &hf_h264_bit_depth_chroma_minus8,
2239 { "bit_depth_chroma_minus8", "h264.bit_depth_chroma_minus8",
2240 FT_UINT32, BASE_DEC, NULL, 0x0,
2243 { &hf_h264_qpprime_y_zero_transform_bypass_flag,
2244 { "qpprime_y_zero_transform_bypass_flag", "h264.qpprime_y_zero_transform_bypass_flag",
2245 FT_UINT32, BASE_DEC, NULL, 0x0,
2248 { &hf_h264_seq_scaling_matrix_present_flag,
2249 { "seq_scaling_matrix_present_flag", "h264.seq_scaling_matrix_present_flag",
2250 FT_UINT32, BASE_DEC, NULL, 0x0,
2253 { &hf_h264_log2_max_frame_num_minus4,
2254 { "log2_max_frame_num_minus4", "h264.log2_max_frame_num_minus4",
2255 FT_UINT32, BASE_DEC, NULL, 0x0,
2258 { &hf_h264_pic_order_cnt_type,
2259 { "pic_order_cnt_type", "h264.pic_order_cnt_type",
2260 FT_UINT32, BASE_DEC, NULL, 0x0,
2263 { &hf_h264_log2_max_pic_order_cnt_lsb_minus4,
2264 { "log2_max_pic_order_cnt_lsb_minus4", "h264.log2_max_pic_order_cnt_lsb_minus4",
2265 FT_UINT32, BASE_DEC, NULL, 0x0,
2268 { &hf_h264_delta_pic_order_always_zero_flag,
2269 { "delta_pic_order_always_zero_flag", "h264.delta_pic_order_always_zero_flag",
2270 FT_UINT8, BASE_DEC, NULL, 0x0,
2273 { &hf_h264_offset_for_non_ref_pic,
2274 { "offset_for_non_ref_pic", "h264.offset_for_non_ref_pic",
2275 FT_INT32, BASE_DEC, NULL, 0x0,
2278 { &hf_h264_offset_for_top_to_bottom_field,
2279 { "offset_for_top_to_bottom_field", "h264.offset_for_top_to_bottom_field",
2280 FT_INT32, BASE_DEC, NULL, 0x0,
2283 { &hf_h264_num_ref_frames_in_pic_order_cnt_cycle,
2284 { "num_ref_frames_in_pic_order_cnt_cycle", "h264.num_ref_frames_in_pic_order_cnt_cycle",
2285 FT_UINT32, BASE_DEC, NULL, 0x0,
2288 { &hf_h264_offset_for_ref_frame,
2289 { "offset_for_ref_frame", "h264.offset_for_ref_frame",
2290 FT_INT32, BASE_DEC, NULL, 0x0,
2293 { &hf_h264_num_ref_frames,
2294 { "num_ref_frames", "h264.num_ref_frames",
2295 FT_UINT32, BASE_DEC, NULL, 0x0,
2298 { &hf_h264_gaps_in_frame_num_value_allowed_flag,
2299 { "gaps_in_frame_num_value_allowed_flag", "h264.gaps_in_frame_num_value_allowed_flag",
2300 FT_UINT8, BASE_DEC, NULL, 0x0,
2303 { &hf_h264_pic_width_in_mbs_minus1,
2304 { "pic_width_in_mbs_minus1", "h264.pic_width_in_mbs_minus1",
2305 FT_UINT32, BASE_DEC, NULL, 0x0,
2308 { &hf_h264_pic_height_in_map_units_minus1,
2309 { "pic_height_in_map_units_minus1", "h264.pic_height_in_map_units_minus1",
2310 FT_UINT32, BASE_DEC, NULL, 0x0,
2313 { &hf_h264_frame_mbs_only_flag,
2314 { "frame_mbs_only_flag", "h264.frame_mbs_only_flag",
2315 FT_UINT8, BASE_DEC, NULL, 0x0,
2318 { &hf_h264_mb_adaptive_frame_field_flag,
2319 { "mb_adaptive_frame_field_flag", "h264.mb_adaptive_frame_field_flag",
2320 FT_UINT8, BASE_DEC, NULL, 0x0,
2323 { &hf_h264_direct_8x8_inference_flag,
2324 { "direct_8x8_inference_flag", "h264.direct_8x8_inference_flag",
2325 FT_UINT8, BASE_DEC, NULL, 0x0,
2328 { &hf_h264_frame_cropping_flag,
2329 { "frame_cropping_flag", "h264.frame_cropping_flag",
2330 FT_UINT8, BASE_DEC, NULL, 0x0,
2333 { &hf_h264_frame_crop_left_offset,
2334 { "frame_crop_left_offset", "h264.frame_crop_left_offset",
2335 FT_UINT32, BASE_DEC, NULL, 0x0,
2338 { &hf_h264_frame_crop_right_offset,
2339 { "frame_crop_left_offset", "h264.frame_crop_right_offset",
2340 FT_UINT32, BASE_DEC, NULL, 0x0,
2343 { &hf_h264_frame_crop_top_offset,
2344 { "frame_crop_top_offset", "h264.frame_crop_top_offset",
2345 FT_UINT32, BASE_DEC, NULL, 0x0,
2348 { &hf_h264_frame_crop_bottom_offset,
2349 { "frame_crop_bottom_offset", "h264.frame_crop_bottom_offset",
2350 FT_UINT32, BASE_DEC, NULL, 0x0,
2353 { &hf_h264_vui_parameters_present_flag,
2354 { "vui_parameters_present_flag", "h264.vui_parameters_present_flag",
2355 FT_UINT8, BASE_DEC, NULL, 0x0,
2358 { &hf_h264_pic_parameter_set_id,
2359 { "pic_parameter_set_id", "h264.pic_parameter_set_id",
2360 FT_UINT32, BASE_DEC, NULL, 0x0,
2363 { &hf_h264_entropy_coding_mode_flag,
2364 { "entropy_coding_mode_flag", "h264.entropy_coding_mode_flag",
2365 FT_UINT8, BASE_DEC, NULL, 0x0,
2368 { &hf_h264_pic_order_present_flag,
2369 { "pic_order_present_flag", "h264.pic_order_present_flag",
2370 FT_UINT8, BASE_DEC, NULL, 0x0,
2373 { &hf_h264_num_slice_groups_minus1,
2374 { "num_slice_groups_minus1", "h264.num_slice_groups_minus1",
2375 FT_UINT32, BASE_DEC, NULL, 0x0,
2378 { &hf_h264_slice_group_map_type,
2379 { "slice_group_map_type", "h264.slice_group_map_type",
2380 FT_UINT32, BASE_DEC, VALS(h264_slice_group_map_type_vals), 0x0,
2383 { &hf_h264_num_ref_idx_l0_active_minus1,
2384 { "num_ref_idx_l0_active_minus1", "h264.num_ref_idx_l0_active_minus1",
2385 FT_UINT32, BASE_DEC, NULL, 0x0,
2388 { &hf_h264_num_ref_idx_l1_active_minus1,
2389 { "num_ref_idx_l1_active_minus1", "h264.num_ref_idx_l1_active_minus1",
2390 FT_UINT32, BASE_DEC, NULL, 0x0,
2393 { &hf_h264_weighted_pred_flag,
2394 { "weighted_pred_flag", "h264.weighted_pred_flag",
2395 FT_UINT8, BASE_DEC, NULL, 0x0,
2398 { &hf_h264_weighted_bipred_idc,
2399 { "weighted_bipred_idc", "h264.weighted_bipred_idc",
2400 FT_UINT8, BASE_DEC, NULL, 0x0,
2403 { &hf_h264_pic_init_qp_minus26,
2404 { "pic_init_qp_minus26", "h264.pic_init_qp_minus26",
2405 FT_INT32, BASE_DEC, NULL, 0x0,
2408 { &hf_h264_pic_init_qs_minus26,
2409 { "pic_init_qs_minus26", "h264.pic_init_qs_minus26",
2410 FT_INT32, BASE_DEC, NULL, 0x0,
2413 { &hf_h264_chroma_qp_index_offset,
2414 { "chroma_qp_index_offset", "h264.chroma_qp_index_offset",
2415 FT_INT32, BASE_DEC, NULL, 0x0,
2418 { &hf_h264_deblocking_filter_control_present_flag,
2419 { "deblocking_filter_control_present_flag", "h264.deblocking_filter_control_present_flag",
2420 FT_UINT8, BASE_DEC, NULL, 0x0,
2423 { &hf_h264_constrained_intra_pred_flag,
2424 { "constrained_intra_pred_flag", "h264.constrained_intra_pred_flag",
2425 FT_UINT8, BASE_DEC, NULL, 0x0,
2428 { &hf_h264_redundant_pic_cnt_present_flag,
2429 { "redundant_pic_cnt_present_flag", "h264.redundant_pic_cnt_present_flag",
2430 FT_UINT8, BASE_DEC, NULL, 0x0,
2433 { &hf_h264_transform_8x8_mode_flag,
2434 { "transform_8x8_mode_flag", "h264.transform_8x8_mode_flag",
2435 FT_UINT8, BASE_DEC, NULL, 0x0,
2438 { &hf_h264_pic_scaling_matrix_present_flag,
2439 { "pic_scaling_matrix_present_flag", "h264.pic_scaling_matrix_present_flag",
2440 FT_UINT8, BASE_DEC, NULL, 0x0,
2443 { &hf_h264_second_chroma_qp_index_offset,
2444 { "second_chroma_qp_index_offset", "h264.second_chroma_qp_index_offset",
2445 FT_INT32, BASE_DEC, NULL, 0x0,
2449 { &hf_h264_aspect_ratio_info_present_flag,
2450 { "aspect_ratio_info_present_flag", "h264.aspect_ratio_info_present_flag",
2451 FT_UINT8, BASE_DEC, NULL, 0x0,
2454 { &hf_h264_aspect_ratio_idc,
2455 { "aspect_ratio_idc", "h264.aspect_ratio_idc",
2456 FT_UINT8, BASE_DEC, NULL, 0x0,
2459 { &hf_h264_sar_width,
2460 { "sar_width", "h264.sar_width",
2461 FT_UINT16, BASE_DEC, NULL, 0x0,
2464 { &hf_h264_sar_height,
2465 { "sar_height", "h264.sar_height",
2466 FT_UINT16, BASE_DEC, NULL, 0x0,
2469 { &hf_h264_overscan_info_present_flag,
2470 { "overscan_info_present_flag", "h264.overscan_info_present_flag",
2471 FT_UINT8, BASE_DEC, NULL, 0x0,
2474 { &hf_h264_overscan_appropriate_flag,
2475 { "overscan_appropriate_flag", "h264.overscan_appropriate_flag",
2476 FT_UINT8, BASE_DEC, NULL, 0x0,
2479 { &hf_h264_video_signal_type_present_flag,
2480 { "video_signal_type_present_flag", "h264.video_signal_type_present_flag",
2481 FT_UINT8, BASE_DEC, NULL, 0x0,
2484 { &hf_h264_video_format,
2485 { "video_format", "h264.video_format",
2486 FT_UINT8, BASE_DEC, VALS(h264_video_format_vals), 0x0,
2489 { &hf_h264_video_full_range_flag,
2490 { "video_full_range_flag", "h264.video_full_range_flag",
2491 FT_UINT8, BASE_DEC, NULL, 0x0,
2494 { &hf_h264_colour_description_present_flag,
2495 { "colour_description_present_flag", "h264.colour_description_present_flag",
2496 FT_UINT8, BASE_DEC, NULL, 0x0,
2499 { &hf_h264_colour_primaries,
2500 { "colour_primaries", "h264.colour_primaries",
2501 FT_UINT8, BASE_DEC, NULL, 0x0,
2504 { &hf_h264_transfer_characteristics,
2505 { "transfer_characteristics", "h264.transfer_characteristics",
2506 FT_UINT8, BASE_DEC, NULL, 0x0,
2509 { &hf_h264_matrix_coefficients,
2510 { "matrix_coefficients", "h264.matrix_coefficients",
2511 FT_UINT8, BASE_DEC, NULL, 0x0,
2514 { &hf_h264_chroma_loc_info_present_flag,
2515 { "chroma_loc_info_present_flag", "h264.chroma_loc_info_present_flag",
2516 FT_UINT8, BASE_DEC, NULL, 0x0,
2519 { &hf_h264_chroma_sample_loc_type_top_field,
2520 { "chroma_sample_loc_type_top_field", "h264.chroma_sample_loc_type_top_field",
2521 FT_UINT32, BASE_DEC, NULL, 0x0,
2524 { &hf_h264_chroma_sample_loc_type_bottom_field,
2525 { "chroma_sample_loc_type_bottom_field", "h264.chroma_sample_loc_type_bottom_field",
2526 FT_UINT32, BASE_DEC, NULL, 0x0,
2529 { &hf_h264_timing_info_present_flag,
2530 { "timing_info_present_flag", "h264.timing_info_present_flag",
2531 FT_UINT8, BASE_DEC, NULL, 0x0,
2534 { &hf_h264_num_units_in_tick,
2535 { "num_units_in_tick", "h264.num_units_in_tick",
2536 FT_UINT32, BASE_DEC, NULL, 0x0,
2539 { &hf_h264_time_scale,
2540 { "time_scale", "h264.time_scale",
2541 FT_UINT32, BASE_DEC, NULL, 0x0,
2544 { &hf_h264_fixed_frame_rate_flag,
2545 { "fixed_frame_rate_flag", "h264.fixed_frame_rate_flag",
2546 FT_UINT8, BASE_DEC, NULL, 0x0,
2549 { &hf_h264_nal_hrd_parameters_present_flag,
2550 { "nal_hrd_parameters_present_flag", "h264.nal_hrd_parameters_present_flag",
2551 FT_UINT8, BASE_DEC, NULL, 0x0,
2554 { &hf_h264_vcl_hrd_parameters_present_flag,
2555 { "vcl_hrd_parameters_present_flag", "h264.vcl_hrd_parameters_present_flag",
2556 FT_UINT8, BASE_DEC, NULL, 0x0,
2559 { &hf_h264_low_delay_hrd_flag,
2560 { "low_delay_hrd_flag", "h264.low_delay_hrd_flag",
2561 FT_UINT8, BASE_DEC, NULL, 0x0,
2564 { &hf_h264_pic_struct_present_flag,
2565 { "pic_struct_present_flag", "h264.pic_struct_present_flag",
2566 FT_UINT8, BASE_DEC, NULL, 0x0,
2569 { &hf_h264_bitstream_restriction_flag,
2570 { "bitstream_restriction_flag", "h264.bitstream_restriction_flag",
2571 FT_UINT8, BASE_DEC, NULL, 0x0,
2574 { &hf_h264_motion_vectors_over_pic_boundaries_flag,
2575 { "motion_vectors_over_pic_boundaries_flag", "h264.motion_vectors_over_pic_boundaries_flag",
2576 FT_UINT32, BASE_DEC, NULL, 0x0,
2579 { &hf_h264_max_bytes_per_pic_denom,
2580 { "max_bytes_per_pic_denom", "h264.max_bytes_per_pic_denom",
2581 FT_UINT32, BASE_DEC, NULL, 0x0,
2584 { &hf_h264_max_bits_per_mb_denom,
2585 { "max_bits_per_mb_denom", "h264.max_bits_per_mb_denom",
2586 FT_UINT32, BASE_DEC, NULL, 0x0,
2589 { &hf_h264_log2_max_mv_length_horizontal,
2590 { "max_mv_length_horizontal", "h264.max_mv_length_horizontal",
2591 FT_UINT32, BASE_DEC, NULL, 0x0,
2594 { &hf_h264_log2_max_mv_length_vertical,
2595 { "log2_max_mv_length_vertical", "h264.log2_max_mv_length_vertical",
2596 FT_UINT32, BASE_DEC, NULL, 0x0,
2599 { &hf_h264_num_reorder_frames,
2600 { "num_reorder_frames", "h264.num_reorder_frames",
2601 FT_UINT32, BASE_DEC, NULL, 0x0,
2604 { &hf_h264_max_dec_frame_buffering,
2605 { "max_dec_frame_buffering", "h264.max_dec_frame_buffering",
2606 FT_UINT32, BASE_DEC, NULL, 0x0,
2609 { &hf_h264_cpb_cnt_minus1,
2610 { "cpb_cnt_minus1", "h264.cpb_cnt_minus1",
2611 FT_UINT32, BASE_DEC, NULL, 0x0,
2614 { &hf_h264_bit_rate_scale,
2615 { "bit_rate_scale", "h264.bit_rate_scale",
2616 FT_UINT8, BASE_DEC, NULL, 0x0,
2619 { &hf_h264_cpb_size_scale,
2620 { "cpb_size_scale", "h264.cpb_size_scale",
2621 FT_UINT8, BASE_DEC, NULL, 0x0,
2624 { &hf_h264_bit_rate_value_minus1,
2625 { "bit_rate_value_minus1", "h264.bit_rate_value_minus1",
2626 FT_UINT32, BASE_DEC, NULL, 0x0,
2629 { &hf_h264_cpb_size_value_minus1,
2630 { "cpb_size_value_minus1", "h264.cpb_size_value_minus1",
2631 FT_UINT32, BASE_DEC, NULL, 0x0,
2634 { &hf_h264_cbr_flag,
2635 { "cbr_flag", "h264.cbr_flag",
2636 FT_UINT8, BASE_DEC, NULL, 0x0,
2639 { &hf_h264_initial_cpb_removal_delay_length_minus1,
2640 { "initial_cpb_removal_delay_length_minus1", "h264.initial_cpb_removal_delay_length_minus1",
2641 FT_UINT8, BASE_DEC, NULL, 0x0,
2644 { &hf_h264_cpb_removal_delay_length_minus1,
2645 { "cpb_removal_delay_length_minus1", "h264.cpb_removal_delay_length_minus1",
2646 FT_UINT8, BASE_DEC, NULL, 0x0,
2649 { &hf_h264_dpb_output_delay_length_minus11,
2650 { "dpb_output_delay_length_minus11", "h264.dpb_output_delay_length_minus11",
2651 FT_UINT8, BASE_DEC, NULL, 0x0,
2654 { &hf_h264_time_offset_length,
2655 { "time_offset_length", "h264.time_offset_length",
2656 FT_UINT8, BASE_DEC, NULL, 0x0,
2659 { &hf_h264_first_mb_in_slice,
2660 { "first_mb_in_slice", "h264.first_mb_in_slice",
2661 FT_UINT32, BASE_DEC, NULL, 0x0,
2664 { &hf_h264_slice_type,
2665 { "slice_type", "h264.slice_type",
2666 FT_UINT32, BASE_DEC, VALS(h264_slice_type_vals), 0x0,
2669 { &hf_h264_slice_id,
2670 { "slice_id", "h264.slice_id",
2671 FT_UINT32, BASE_DEC, NULL, 0x0,
2674 { &hf_h264_payloadsize,
2675 { "PayloadSize", "h264.payloadsize",
2676 FT_UINT32, BASE_DEC, NULL, 0x0,
2679 { &hf_h264_payloadtype,
2680 { "payloadType", "h264.payloadtype",
2681 FT_UINT32, BASE_DEC, VALS(h264_sei_payload_vals), 0x0,
2684 { &hf_h264_frame_num,
2685 { "frame_num", "h264.frame_num",
2686 FT_UINT8, BASE_DEC, NULL, 0x0,
2689 { &hf_h264_par_profile,
2690 { "Profile", "h264.profile",
2691 FT_UINT8, BASE_HEX, NULL, 0x00,
2693 { &hf_h264_par_profile_b,
2694 { "Baseline Profile", "h264.profile.base",
2695 FT_BOOLEAN, 8, NULL, 0x40,
2697 { &hf_h264_par_profile_m,
2698 { "Main Profile", "h264.profile.main",
2699 FT_BOOLEAN, 8, NULL, 0x20,
2701 { &hf_h264_par_profile_e,
2702 { "Extended Profile.", "h264.profile.ext",
2703 FT_BOOLEAN, 8, NULL, 0x10,
2705 { &hf_h264_par_profile_h,
2706 { "High Profile", "h264.profile.high",
2707 FT_BOOLEAN, 8, NULL, 0x08,
2709 { &hf_h264_par_profile_h10,
2710 { "High 10 Profile", "h264.profile.high10",
2711 FT_BOOLEAN, 8, NULL, 0x04,
2713 { &hf_h264_par_profile_h4_2_2,
2714 { "High 4:2:2 Profile", "h264.profile.high4_2_2",
2715 FT_BOOLEAN, 8, NULL, 0x02,
2717 { &hf_h264_par_profile_h4_4_4,
2718 { "High 4:4:4 Profile", "h264.profile.high4_4_4",
2719 FT_BOOLEAN, 8, NULL, 0x01,
2721 { &hf_h264_par_AdditionalModesSupported,
2722 { "AdditionalModesSupported", "h264.AdditionalModesSupported",
2723 FT_UINT8, BASE_HEX, NULL, 0x00,
2725 { &hf_h264_par_add_mode_sup,
2726 { "Additional Modes Supported", "h264.add_mode_sup",
2727 FT_UINT8, BASE_HEX, NULL, 0x00,
2729 { &hf_h264_par_add_mode_sup_rcdo,
2730 { "Reduced Complexity Decoding Operation (RCDO) support", "h264.add_mode_sup.rcdo",
2731 FT_BOOLEAN, 8, NULL, 0x40,
2733 { &hf_h264_par_ProfileIOP,
2734 { "ProfileIOP", "h264.ProfileIOP",
2735 FT_UINT8, BASE_HEX, NULL, 0x00,
2737 { &hf_h264_par_constraint_set0_flag,
2738 { "constraint_set0_flag", "h264.par.constraint_set0_flag",
2739 FT_BOOLEAN, 8, NULL, 0x80,
2741 { &hf_h264_par_constraint_set1_flag,
2742 { "constraint_set1_flag", "h264.par.constraint_set1_flag",
2743 FT_BOOLEAN, 8, NULL, 0x40,
2745 { &hf_h264_par_constraint_set2_flag,
2746 { "constraint_set2_flag", "h264.par.constraint_set2_flag",
2747 FT_BOOLEAN, 8, NULL, 0x20,
2751 /* Setup protocol subtree array */
2752 static gint *ett[] = {
2759 &ett_h264_par_profile,
2760 &ett_h264_par_AdditionalModesSupported,
2761 &ett_h264_par_ProfileIOP,
2764 /* Register the protocol name and description */
2765 proto_h264 = proto_register_protocol("H.264","H264", "h264");
2767 /* Required function calls to register the header fields and subtrees used */
2768 proto_register_field_array(proto_h264, hf, array_length(hf));
2769 proto_register_subtree_array(ett, array_length(ett));
2770 /* Register a configuration option for port */
2773 h264_module = prefs_register_protocol(proto_h264, proto_reg_handoff_h264);
2776 prefs_register_range_preference(h264_module, "dynamic.payload.type",
2777 "H264 dynamic payload types",
2778 "Dynamic payload types which will be interpreted as H264"
2779 "; Values must be in the range 96 - 127",
2780 &temp_dynamic_payload_type_range, 127);
2782 register_dissector("h264", dissect_h264, proto_h264);