Correct a typo.
[obnox/wireshark/wip.git] / epan / dissectors / packet-h264.c
1 /* packet-h264.c
2  * Routines for H.264 dissection
3  * Copyright 2007, Anders Broman <anders.broman[at]ericsson.com>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  * 
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.
15  * 
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.
20  * 
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.
24  *
25  * References:
26  * http://www.ietf.org/rfc/rfc3984.txt?number=3984
27  * http://www.itu.int/rec/T-REC-H.264/en
28  */
29
30 #ifdef HAVE_CONFIG_H
31 # include "config.h"
32 #endif
33
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
37
38 #include <glib.h>
39
40 #include <epan/packet.h>
41 #include <epan/proto.h>
42 #include <epan/asn1.h>
43
44 #include "prefs.h"
45
46
47 /* Initialize the protocol and registered fields */
48 static int proto_h264                                                           = -1;
49 static int hf_h264_type                                                         = -1;
50 static int hf_h264_nal_f_bit                                            = -1;
51 static int hf_h264_nal_nri                                                      = -1;
52 static int hf_h264_profile                                                      = -1;
53 static int hf_h264_profile_idc                                          = -1;
54 static int hf_h264_rbsp_stop_bit                                        = -1;
55 static int hf_h264_rbsp_trailing_bits                           = -1;
56 static int hf_h264_constraint_set0_flag                         = -1;
57 static int hf_h264_constraint_set1_flag                         = -1;
58 static int hf_h264_constraint_set2_flag                         = -1;
59 static int hf_h264_constraint_set3_flag                         = -1;
60 static int hf_h264_reserved_zero_4bits                          = -1;
61 static int hf_h264_level_idc                                            = -1;
62 static int hf_h264_nal_unit                                                     = -1;
63 static int hf_h264_forbidden_zero_bit                           = -1;
64 static int hf_h264_nal_ref_idc                                          = -1;
65 static int hf_h264_nal_unit_type                                        = -1;
66 static int hf_h264_seq_parameter_set_id                         = -1;
67 static int hf_h264_chroma_format_idc                            = -1;
68 static int hf_h264_residual_colour_transform_flag       = -1;
69 static int hf_h264_bit_depth_luma_minus8                        = -1;
70 static int hf_h264_bit_depth_chroma_minus8                      = -1;
71 static int hf_h264_qpprime_y_zero_transform_bypass_flag = -1;
72 static int hf_h264_seq_scaling_matrix_present_flag      = -1;
73 static int hf_h264_log2_max_frame_num_minus4            = -1;
74 static int hf_h264_pic_order_cnt_type                           = -1;
75 static int hf_h264_log2_max_pic_order_cnt_lsb_minus4 = -1;
76 static int hf_h264_delta_pic_order_always_zero_flag = -1;
77 static int hf_h264_offset_for_non_ref_pic                       = -1;
78 static int hf_h264_offset_for_top_to_bottom_field       = -1;
79 static int hf_264_num_ref_frames_in_pic_order_cnt_cycle = -1;
80 static int hf_h264_offset_for_ref_frame                         = -1;
81 static int hf_h264_num_ref_frames                                       = -1;
82 static int hf_h264_gaps_in_frame_num_value_allowed_flag = -1;
83 static int hf_h264_pic_width_in_mbs_minus1                      = -1;
84 static int hf_h264_pic_height_in_map_units_minus1       = -1;
85 static int hf_h264_frame_mbs_only_flag                          = -1;
86 static int hf_h264_mb_adaptive_frame_field_flag         = -1;
87 static int hf_h264_direct_8x8_inference_flag            = -1;
88 static int hf_h264_frame_cropping_flag                          = -1;
89 static int hf_h264_frame_crop_left_offset                       = -1;
90 static int hf_h264_frame_crop_right_offset                      = -1;
91 static int hf_h264_frame_crop_top_offset                        = -1;
92 static int hf_h264_frame_crop_bottom_offset                     = -1;
93 static int hf_h264_vui_parameters_present_flag          = -1;
94 static int hf_h264_pic_parameter_set_id                         = -1;
95 static int hf_h264_entropy_coding_mode_flag                     = -1;
96 static int hf_h264_pic_order_present_flag                       = -1;
97 static int hf_h264_num_slice_groups_minus1                      = -1;
98 static int hf_h264_slice_group_map_type                         = -1;
99 static int hf_h264_num_ref_idx_l0_active_minus1         = -1;
100 static int hf_h264_num_ref_idx_l1_active_minus1         = -1;
101 static int hf_h264_weighted_pred_flag                           = -1;
102 static int hf_h264_weighted_bipred_idc                          = -1;
103 static int hf_h264_pic_init_qp_minus26                          = -1;
104 static int hf_h264_pic_init_qs_minus26                          = -1;
105 static int hf_h264_chroma_qp_index_offset                       = -1;
106 static int hf_h264_deblocking_filter_control_present_flag = -1;
107 static int hf_h264_constrained_intra_pred_flag          = -1;
108 static int hf_h264_redundant_pic_cnt_present_flag       = -1;
109 static int hf_h264_transform_8x8_mode_flag                      = -1;
110 static int hf_h264_pic_scaling_matrix_present_flag      = -1;
111 static int hf_h264_second_chroma_qp_index_offset        = -1;
112 static int hf_h264_par_profile                                          = -1;
113 static int hf_h264_par_profile_b                                        = -1;
114 static int hf_h264_par_profile_m                                        = -1;
115 static int hf_h264_par_profile_e                                        = -1;
116 static int hf_h264_par_profile_h                                        = -1;
117 static int hf_h264_par_profile_h10                                      = -1;
118 static int hf_h264_par_profile_h4_2_2                           = -1;
119 static int hf_h264_par_profile_h4_4_4                           = -1;
120 static int hf_h264_par_add_mode_sup                                     = -1;
121 static int hf_h264_par_AdditionalModesSupported         = -1;
122 static int hf_h264_par_add_mode_sup_rcdo                        = -1;
123 static int hf_h264_par_ProfileIOP                                       = -1;
124 static int hf_h264_par_constraint_set0_flag                     = -1;
125 static int hf_h264_par_constraint_set1_flag                     = -1;
126 static int hf_h264_par_constraint_set2_flag                     = -1;
127
128 /* VUI parameters */
129 static int hf_h264_aspect_ratio_info_present_flag       = -1;
130 static int hf_h264_aspect_ratio_idc                                     = -1;
131 static int hf_h264_sar_width                                            = -1;
132 static int hf_h264_sar_height                                           = -1;
133 static int hf_h264_overscan_info_present_flag           = -1;
134 static int hf_h264_overscan_appropriate_flag            = -1;
135 static int hf_h264_video_signal_type_present_flag       = -1;
136 static int hf_h264_video_format                                         = -1;
137 static int hf_h264_video_full_range_flag                        = -1;
138 static int hf_h264_colour_description_present_flag      = -1;
139 static int hf_h264_colour_primaries                                     = -1;
140 static int hf_h264_transfer_characteristics                     = -1;
141 static int hf_h264_matrix_coefficients                          = -1;
142 static int hf_h264_chroma_loc_info_present_flag         = -1;
143 static int hf_h264_chroma_sample_loc_type_top_field = -1;
144 static int hf_h264_chroma_sample_loc_type_bottom_field = -1;
145 static int hf_h264_timing_info_present_flag                     = -1;
146 static int hf_h264_num_units_in_tick                            = -1;
147 static int hf_h264_time_scale                                           = -1;
148 static int hf_h264_fixed_frame_rate_flag                        = -1;
149 static int hf_h264_nal_hrd_parameters_present_flag      = -1;
150 static int hf_h264_vcl_hrd_parameters_present_flag      = -1;
151 static int hf_h264_low_delay_hrd_flag                           = -1;
152 static int hf_h264_pic_struct_present_flag                      = -1;
153 static int hf_h264_bitstream_restriction_flag           = -1;
154 static int hf_h264_motion_vectors_over_pic_boundaries_flag = -1;
155 static int hf_h264_max_bytes_per_pic_denom                      = -1;
156 static int hf_h264_max_bits_per_mb_denom                        = -1;
157 static int hf_h264_log2_max_mv_length_horizontal        = -1;
158 static int hf_h264_log2_max_mv_length_vertical          = -1;
159 static int hf_h264_num_reorder_frames                           = -1;
160 static int hf_h264_max_dec_frame_buffering                      = -1;
161 static int hf_h264_cpb_cnt_minus1                                       = -1;
162 static int hf_h264_bit_rate_scale                                       = -1;
163 static int hf_h264_cpb_size_scale                                       = -1;
164 static int hf_h264_bit_rate_value_minus1                        = -1;
165 static int hf_h264_cpb_size_value_minus1                        = -1;
166 static int hf_h264_cbr_flag                                                     = -1;
167 static int hf_h264_initial_cpb_removal_delay_length_minus1 = -1;
168 static int hf_h264_cpb_removal_delay_length_minus1      = -1;
169 static int hf_h264_dpb_output_delay_length_minus11      = -1;
170 static int hf_h264_time_offset_length                           = -1;
171
172 static int hf_h264_first_mb_in_slice                            = -1;
173 static int hf_h264_slice_type                                           = -1;
174 static int hf_h264_slice_id                                                     = -1;
175 static int hf_h264_frame_num                                            = -1;
176
177 /* Initialize the subtree pointers */
178 static int ett_h264 = -1;
179 static int ett_h264_profile = -1;
180 static int ett_h264_nal = -1;
181 static int ett_h264_stream = -1;
182 static int ett_h264_nal_unit = -1;
183 static int ett_h264_par_profile = -1;
184 static int ett_h264_par_AdditionalModesSupported = -1;
185 static int ett_h264_par_ProfileIOP                               = -1;
186
187 /* The dynamic payload type which will be dissected as H.264 */
188
189 static guint dynamic_payload_type = 0;
190 static guint temp_dynamic_payload_type = 0;
191
192 /* syntax tables in subclause 7.3 is equal to
193  * ue(v), me(v), se(v), or te(v).
194  */
195 typedef enum {
196     H264_UE_V = 0,
197     H264_ME_V = 1,
198     H264_SE_V = 2,
199     H264_TE_V = 3
200 } h264_golomb_descriptors;
201
202
203 static const true_false_string h264_f_bit_vals = {
204   "Bit errors or other syntax violations",
205   "No bit errors or other syntax violations"
206 };
207
208 #define H264_SEQ_PAR_SET                7
209 #define H264_PIC_PAR_SET                8
210
211 static const value_string h264_type_values[] = {
212         { 0,    "Undefined" }, 
213         { 1,    "NAL unit - Coded slice of a non-IDR picture" },        /* Single NAL unit packet per H.264 */
214         { 2,    "NAL unit - Coded slice data partition A" },
215         { 3,    "NAL unit - Coded slice data partition B" },
216         { 4,    "NAL unit - Coded slice data partition C" },
217         { 5,    "NAL unit - Coded slice of an IDR picture" },
218         { 6,    "NAL unit - Supplemental enhancement information (SEI)" },
219         { H264_SEQ_PAR_SET,     "NAL unit - Sequence parameter set" },                          /* 7 */
220         { H264_PIC_PAR_SET,     "NAL unit - Picture parameter set" },                           /* 8 */
221         { 9,    "NAL unit - Access unit delimiter" },
222         { 10,   "NAL unit - End of sequence" },
223         { 11,   "NAL unit - End of stream" },   
224         { 12,   "NAL unit - Filler data" },
225         { 13,   "NAL unit - Sequence parameter set extension" },
226         { 14,   "NAL unit - Reserved" },
227         { 15,   "NAL unit - Reserved" },
228         { 16,   "NAL unit - Reserved" },
229         { 17,   "NAL unit - Reserved" },
230         { 18,   "NAL unit - Reserved" },
231         { 19,   "NAL unit - Coded slice of an auxiliary coded picture without partitioning" },
232         { 20,   "NAL unit - Reserved" },
233         { 21,   "NAL unit - Reserved" },        
234         { 22,   "NAL unit - Reserved" },
235         { 23,   "NAL unit - Reserved" },
236         { 24,   "STAP-A" },             /* Single-time aggregation packet */
237         { 25,   "STAP-B" },             /* Single-time aggregation packet */
238         { 26,   "MTAP16" },             /* Multi-time aggregation packet */
239         { 27,   "MTAP24" },             /* Multi-time aggregation packet */ 
240         { 28,   "FU-A" },               /* Fragmentation unit */
241         { 29,   "FU-B" },               /* Fragmentation unit */
242         { 30,   "undefined" }, 
243         { 31,   "undefined" }, 
244         { 0,    NULL }
245 };
246
247
248 static const value_string h264_profile_idc_values[] = {
249         { 66,   "Baseline profile" },
250         { 77,   "Main profile" },
251         { 88,   "Extended profile" },
252         { 100,  "High profile" },
253         { 110,  "High 10 profile" },
254         { 122,  "High 4:2:2 profile" },
255         { 144,  "High 4:4:4 profile" },
256         { 0,    NULL }
257 };
258
259 static const value_string h264_nal_unit_type_vals[] = {
260         { 0,    "Unspecified" },
261         { 1,    "Coded slice of a non-IDR picture" },
262         { 2,    "Coded slice data partition A" },
263         { 3,    "Coded slice data partition B" },
264         { 4,    "Coded slice data partition C" },
265         { 5,    "Coded slice of an IDR picture" },
266         { 6,    "Supplemental enhancement information (SEI)" },
267         { 7,    "Sequence parameter set" },
268         { 8,    "Picture parameter set" },
269         { 9,    "Access unit delimiter" },
270         { 10,   "End of sequence" },
271         { 11,   "End of stream" },
272         { 12,   "Filler data" },
273         { 13,   "Sequence parameter set extension" },
274         { 14,   "Reserved" },
275         { 15,   "Reserved" },
276         { 16,   "Reserved" },
277         { 17,   "Reserved" },
278         { 18,   "Reserved" },
279         { 19,   "Coded slice of an auxiliary coded picture without partitioning" },
280         { 20,   "Reserved" },
281         { 21,   "Reserved" },
282         { 22,   "Reserved" },
283         { 23,   "Reserved" },
284         { 24,   "Unspecified" },
285         { 25,   "Unspecified" },
286         { 26,   "Unspecified" },
287         { 27,   "Unspecified" },
288         { 28,   "Unspecified" },
289         { 29,   "Unspecified" },
290         { 30,   "Unspecified" },
291         { 31,   "Unspecified" },
292         { 0,    NULL }
293 };
294
295 static const value_string h264_slice_group_map_type_vals[] = {
296         { 0,    "Interleaved slice groups" },
297         { 1,    "Dispersed slice group mapping" },
298         { 2,    "One or more foreground slice groups and a leftover slice group" },
299         { 3,    "Changing slice groups" },
300         { 4,    "Changing slice groups" },
301         { 5,    "Changing slice groups" },
302         { 6,    "Explicit assignment of a slice group to each slice group map unit" },
303         { 0,    NULL }
304 };
305
306 /* Table 7-6 Name association to slice_type */
307 static const value_string h264_slice_type_vals[] = {
308         { 0,    "P (P slice)" },
309         { 1,    "B (B slice)" },
310         { 2,    "I (I slice)" },
311         { 3,    "SP (SP slice)" },
312         { 4,    "SI (SI slice)" },
313         { 5,    "P (P slice)" },
314         { 6,    "B (B slice)" },
315         { 7 ,   "I (I slice)" },
316         { 8,    "SP (SP slice)" },
317         { 9,    "SI (SI slice)" },
318         { 0,    NULL }
319 };
320
321 /* Expect a tvb and a bit offset into the tvb
322  * returns the valu and bit_offset
323  */
324 #define cVALS(x) (const value_string*)(x)
325
326 guint32
327 dissect_h264_exp_golomb_code(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint *start_bit_offset, h264_golomb_descriptors descriptor)
328 /*(tvbuff_t *tvb, gint *start_bit_offset) */
329 {
330         gint            leading_zero_bits, bit_offset;
331         guint32         codenum, mask, value, tmp;
332         gint32          se_value=0;             
333         gint            b;
334         char *str;
335         int bit;
336         int i;
337         header_field_info *hf_field = NULL;
338
339         if(hf_index > -1)
340                 hf_field = proto_registrar_get_nth(hf_index);
341
342         bit_offset = *start_bit_offset;
343
344         /* prepare the string */
345         str=ep_alloc(256);
346         str[0]='\0';
347         for(bit=0;bit<((int)(bit_offset&0x07));bit++){
348                 if(bit&&(!(bit%4))){
349                         strcat(str, " ");
350                 }
351                 strcat(str,".");
352         }
353
354
355         leading_zero_bits = -1;
356         for( b = 0; !b; leading_zero_bits++ ){
357                 if(bit&&(!(bit%4))){
358                         strcat(str, " ");
359                 }
360                 if(bit&&(!(bit%8))){
361                         strcat(str, " ");
362                 }
363                 b = tvb_get_bits8(tvb, bit_offset, 1);
364                 if(b != 0){
365                         strcat(str, "1");
366                 } else {
367                         strcat(str, "0");
368                 }
369                 bit++;
370                 bit_offset++;
371         }
372
373         if(leading_zero_bits==0){
374                 codenum = 0;
375                 *start_bit_offset = bit_offset;
376                 for(;bit%8;bit++){
377                         if(bit&&(!(bit%4))){
378                                 strcat(str, " ");
379                         }
380                 strcat(str,".");
381                 }
382                 if(hf_field){
383                         strcat(str," = ");
384                         strcat(str,hf_field->name);
385                         switch (descriptor){
386                         case H264_SE_V:
387                                 /* if the syntax element is coded as se(v), 
388                                  * the value of the syntax element is derived by invoking the
389                                  * mapping process for signed Exp-Golomb codes as specified in 
390                                  * subclause 9.1.1 with codeNum as the input.
391                                  */
392                                 if(hf_field->type==FT_INT32){
393                                         if (hf_field->strings) {
394                                                 proto_tree_add_int_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
395                                                           "%s: %s (%d)",
396                                                           str,
397                                                           val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
398                                                           codenum);
399                                         }else{
400                                                 switch(hf_field->display){
401                                                         case BASE_DEC:
402                                                                 proto_tree_add_int_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
403                                                                  "%s: %d",
404                                                                           str,
405                                                                           codenum);
406                                                                 break;
407                                                         default:
408                                                                 DISSECTOR_ASSERT_NOT_REACHED();
409                                                                 break;
410                                                 }
411                                         }
412                                 }
413                                 return codenum;
414                                 break;
415                         default:
416                                 break;
417                         }
418                         if(hf_field->type==FT_UINT32){
419                                 if (hf_field->strings) {
420                                         proto_tree_add_uint_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
421                                                   "%s: %s (%u)",
422                                                   str,
423                                                   val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
424                                                   codenum);
425                                 }else{
426                                         switch(hf_field->display){
427                                                 case BASE_DEC:
428                                                         proto_tree_add_uint_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
429                                                          "%s: %u",
430                                                                   str,
431                                                                   codenum);
432                                                         break;
433                                                 case BASE_HEX:
434                                                         proto_tree_add_uint_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
435                                                      "%s: 0x%x",
436                                                                   str,
437                                                                   codenum);
438                                                         break;
439                                                 default:
440                                                         DISSECTOR_ASSERT_NOT_REACHED();
441                                                         break;
442                                         }
443                                 }
444                         }else{
445                                 /* Only allow guint32 */
446                                 DISSECTOR_ASSERT_NOT_REACHED();
447                         }
448                 }
449                 return codenum;
450         }
451
452         /*
453         Syntax elements coded as ue(v), me(v), or se(v) are Exp-Golomb-coded. Syntax elements coded as te(v) are truncated
454         Exp-Golomb-coded. The parsing process for these syntax elements begins with reading the bits starting at the current
455         location in the bitstream up to and including the first non-zero bit, and counting the number of leading bits that are
456         equal to 0. This process is specified as follows:
457         leadingZeroBits = -1;
458         for( b = 0; !b; leadingZeroBits++ )
459         b = read_bits( 1 )
460         The variable codeNum is then assigned as follows:
461         codeNum = 2leadingZeroBits - 1 + read_bits( leadingZeroBits )
462         where the value returned from read_bits( leadingZeroBits ) is interpreted as a binary representation of an unsigned
463         integer with most significant bit written first.
464         */
465         codenum = 1;
466         codenum = codenum << leading_zero_bits;
467         mask = codenum>>1;
468         value = tvb_get_bits8(tvb, bit_offset,leading_zero_bits );
469         codenum = (codenum-1) + value; 
470         bit_offset = bit_offset + leading_zero_bits;
471
472         /* read the bits for the int */
473         for(i=0;i<leading_zero_bits;i++){
474                 if(bit&&(!(bit%4))){
475                         strcat(str, " ");
476                 }
477                 if(bit&&(!(bit%8))){
478                         strcat(str, " ");
479                 }
480                 bit++;
481                 tmp = value & mask;
482                 if(tmp != 0){
483                         strcat(str, "1");
484                 } else {
485                         strcat(str, "0");
486                 }
487                 mask = mask>>1;
488         }
489         for(;bit%8;bit++){
490                 if(bit&&(!(bit%4))){
491                         strcat(str, " ");
492                 }
493                 strcat(str,".");
494         }
495
496         switch (descriptor){
497         case H264_SE_V:
498                 /* if the syntax element is coded as se(v), 
499                  * the value of the syntax element is derived by invoking the
500                  * mapping process for signed Exp-Golomb codes as specified in 
501                  * subclause 9.1.1 with codeNum as the input.
502                  *              k+1 
503                  * (-1)    Ceil( k÷2 )
504                  */
505                 se_value = (codenum + 1) >> 1;
506                 if (!(se_value & 1)){
507                         se_value =  - se_value;
508                 }
509                 break;
510         default:
511                 break;
512         }
513
514         if(hf_field){
515                 strcat(str," = ");
516                 strcat(str,hf_field->name);
517                 switch (descriptor){
518                 case H264_SE_V:
519                         strcat(str,"(se(v))");
520                         /* if the syntax element is coded as se(v), 
521                          * the value of the syntax element is derived by invoking the
522                          * mapping process for signed Exp-Golomb codes as specified in 
523                          * subclause 9.1.1 with codeNum as the input.
524                          */
525                         break;
526                 default:
527                 break;
528                 }
529                 if((hf_field->type==FT_UINT32)&&(descriptor==H264_UE_V)){
530                         if (hf_field->strings) {
531                                 proto_tree_add_uint_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
532                                                   "%s: %s (%u)",
533                                                   str,
534                                                   val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
535                                                   codenum);
536                         }else{
537                                 switch(hf_field->display){
538                                         case BASE_DEC:
539                                                 proto_tree_add_uint_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
540                                                  "%s: %u",
541                                                           str,
542                                                           codenum);
543                                                 break;
544                                         case BASE_HEX:
545                                                 proto_tree_add_uint_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
546                                              "%s: 0x%x",
547                                                           str,
548                                                           codenum);
549                                                 break;
550                                         default:
551                                                 DISSECTOR_ASSERT_NOT_REACHED();
552                                                 break;
553                                 }
554                         }
555                 }else if((hf_field->type==FT_INT32)&&(descriptor==H264_SE_V)){
556                         if (hf_field->strings) {
557                                 proto_tree_add_int_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
558                                                   "%s: %s (%d)",
559                                                   str,
560                                                   val_to_str(codenum, cVALS(hf_field->strings), "Unknown "),
561                                                   se_value);
562                         }else{
563                                 switch(hf_field->display){
564                                         case BASE_DEC:
565                                                 proto_tree_add_int_format(tree, hf_index, tvb, bit_offset>>3, 1, codenum,
566                                                  "%s: %d",
567                                                           str,
568                                                           se_value);
569                                                 break;
570                                         default:
571                                                 DISSECTOR_ASSERT_NOT_REACHED();
572                                                 break;
573                                 }
574                         }
575                         *start_bit_offset = bit_offset;
576                         return se_value;
577
578                 }else{
579                         /* Only allow guint32 */
580                         DISSECTOR_ASSERT_NOT_REACHED();
581                 }
582         }
583
584         *start_bit_offset = bit_offset;
585         return codenum;
586
587 }
588
589 /* This funktion is adapted to parsing NAL units from SDP data where the
590  * base64 coding may add extra padding
591  */
592
593 static gboolean
594 more_rbsp_data(proto_tree *tree _U_, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
595 {
596
597         int offset;
598         int remaining_length;
599         int last_one_bit;
600         guint8 b = 0;
601
602         /* XXX might not be the best way of doing things but:
603          * Serch from the end of the tvb for the first '1' bit
604          * assuming that its's the RTBSP stop bit
605          */
606
607         /* Set offset to the byte we are treating */
608         offset = bit_offset>>3;
609         remaining_length = tvb_length_remaining(tvb,offset);
610         /* If there is more then 2 bytes left there *should* be more data */
611         if(remaining_length>2){
612                 return TRUE;
613         }
614         /* Start from last bit */
615         last_one_bit = (tvb_length(tvb) << 3);
616
617         for( b = 0; !b; ){
618                 last_one_bit--;
619                 b = tvb_get_bits8(tvb, last_one_bit, 1);
620         }
621
622         if( last_one_bit == bit_offset){
623                 return FALSE;
624         }
625
626         return TRUE;
627 }
628
629 static int
630 dissect_h264_rbsp_trailing_bits(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
631 {
632         gint remaining_bits;
633
634         proto_tree_add_bits_item(tree, hf_h264_rbsp_stop_bit, tvb, bit_offset, 1, FALSE);
635         bit_offset++;
636
637         remaining_bits = 8 - (bit_offset&0x7);
638
639         proto_tree_add_bits_item(tree, hf_h264_rbsp_trailing_bits, tvb, bit_offset, remaining_bits, FALSE);
640
641         return bit_offset+remaining_bits;
642
643 }
644
645 /*
646  * 7.3.3 Slice header syntax
647  * slice_header( )
648  * XXX Just parse a few bytes
649  */
650 static int
651 dissect_h264_slice_header(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
652 {
653         /* first_mb_in_slice 2 ue(v) */
654         dissect_h264_exp_golomb_code(tree, hf_h264_first_mb_in_slice, tvb, &bit_offset, H264_UE_V);
655
656         /* slice_type 2 ue(v) */
657         dissect_h264_exp_golomb_code(tree, hf_h264_slice_type, tvb, &bit_offset, H264_UE_V);
658         
659         /* pic_parameter_set_id 2 ue(v) */
660         dissect_h264_exp_golomb_code(tree, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
661         
662         /* frame_num 2 u(v) */
663         /* XXXX Is frame_num allways 4 bits in the bit stream? */
664         proto_tree_add_bits_item(tree, hf_h264_frame_num, tvb, bit_offset, 4, FALSE);
665
666         return bit_offset;
667 }
668
669
670 /* 7.3.2.1.1 Scaling list syntax 
671  * 
672  * scaling_list( scalingList, sizeOfScalingList, useDefaultScalingMatrixFlag )
673  */
674 /*
675 static int
676 dissect_h264_scaling_list(proto_tree *tree, tvbuff_t *tvb, gint bit_offset, int hf_index_scalinglist,
677                                                   guint8 sizeOfScalingList, int hf_index_usedefaultscalingmatrixflag)
678 {
679
680         guint8 lastScale = 8;
681         guint8 nextScale = 8:
682         guint8 delta_scale;
683
684         for( j = 0; j < sizeOfScalingList; j++ ) {
685           if( nextScale != 0 ) {
686                   / delta_scale 0 | 1 se(v) /
687                   delta_scale = dissect_h264_exp_golomb_code(tree, hf_h264_delta_scale, tvb, &bit_offset);
688                   nextScale = ( lastScale + delta_scale + 256 ) % 256;
689                   useDefaultScalingMatrixFlag = ( j == 0 && nextScale == 0 );
690         }
691         scalingList[ j ] = ( nextScale == 0 ) ? lastScale : nextScale
692         lastScale = scalingList[ j ]
693         }
694 }
695 */
696 /* E.1.2 HRD parameters syntax */
697 static int
698 dissect_h264_hrd_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
699 {
700         guint8 cpb_cnt_minus1;
701         int SchedSelIdx;
702
703
704         /* cpb_cnt_minus1 0 ue(v) */
705         cpb_cnt_minus1 = dissect_h264_exp_golomb_code(tree, hf_h264_cpb_cnt_minus1, tvb, &bit_offset, H264_UE_V);
706
707         /* bit_rate_scale 0 u(4) */
708         proto_tree_add_bits_item(tree, hf_h264_bit_rate_scale, tvb, bit_offset, 4, FALSE);
709         bit_offset = bit_offset + 4;
710
711         /* cpb_size_scale 0 u(4) */
712         proto_tree_add_bits_item(tree, hf_h264_cpb_size_scale, tvb, bit_offset, 4, FALSE);
713         bit_offset = bit_offset + 4;
714         /* for( SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++ ) { */
715         for( SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++ ) {
716
717                 /* bit_rate_value_minus1[ SchedSelIdx ] 0 ue(v) */
718                 dissect_h264_exp_golomb_code(tree, hf_h264_bit_rate_value_minus1, tvb, &bit_offset, H264_UE_V);
719
720                 /* cpb_size_value_minus1[ SchedSelIdx ] 0 ue(v)*/
721                 dissect_h264_exp_golomb_code(tree, hf_h264_cpb_size_value_minus1, tvb, &bit_offset, H264_UE_V);
722
723                 /* cbr_flag[ SchedSelIdx ] 0 u(1) */
724                 proto_tree_add_bits_item(tree, hf_h264_cbr_flag, tvb, bit_offset, 1, FALSE);
725                 bit_offset++;
726         }
727         /* initial_cpb_removal_delay_length_minus1 0 u(5) */
728         proto_tree_add_bits_item(tree, hf_h264_initial_cpb_removal_delay_length_minus1, tvb, bit_offset, 1, FALSE);
729         bit_offset = bit_offset + 5;
730
731         /* cpb_removal_delay_length_minus1 0 u(5) */
732         proto_tree_add_bits_item(tree, hf_h264_cpb_removal_delay_length_minus1, tvb, bit_offset, 1, FALSE);
733         bit_offset = bit_offset + 5;
734
735         /* dpb_output_delay_length_minus1 0 u(5) */
736         proto_tree_add_bits_item(tree, hf_h264_dpb_output_delay_length_minus11, tvb, bit_offset, 1, FALSE);
737         bit_offset = bit_offset + 5;
738
739         /* time_offset_length 0 u(5) */
740         proto_tree_add_bits_item(tree, hf_h264_time_offset_length, tvb, bit_offset, 1, FALSE);
741         bit_offset = bit_offset + 5;
742
743         return bit_offset;
744 }
745
746 #define EXTENDED_SAR 255
747
748 /* E.1.1 VUI parameters syntax */
749 static int
750 dissect_h264_vui_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint bit_offset)
751 {
752
753         guint8 aspect_ratio_info_present_flag, aspect_ratio_idc, overscan_info_present_flag;
754         guint8 video_signal_type_present_flag, colour_description_present_flag, chroma_loc_info_present_flag;
755         guint8 timing_info_present_flag, nal_hrd_parameters_present_flag, vcl_hrd_parameters_present_flag;
756         guint8 bitstream_restriction_flag;
757
758         /* vui_parameters( ) {
759          * aspect_ratio_info_present_flag 0 u(1)
760          */
761         aspect_ratio_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
762         proto_tree_add_bits_item(tree, hf_h264_aspect_ratio_info_present_flag, tvb, bit_offset, 1, FALSE);
763         bit_offset++;
764
765         if( aspect_ratio_info_present_flag ) {
766                 /* aspect_ratio_idc 0 u(8) */
767                 aspect_ratio_idc = tvb_get_bits8(tvb, bit_offset, 8);
768                 proto_tree_add_bits_item(tree, hf_h264_aspect_ratio_idc, tvb, bit_offset, 8, FALSE);
769                 bit_offset = bit_offset + 8;
770
771                 if( aspect_ratio_idc == EXTENDED_SAR ) {
772                         /* sar_width 0 u(16) */
773                         proto_tree_add_bits_item(tree, hf_h264_sar_width, tvb, bit_offset, 16, FALSE);
774                         bit_offset = bit_offset + 16;
775                 
776                         /* sar_height 0 u(16) */
777                         proto_tree_add_bits_item(tree, hf_h264_sar_height, tvb, bit_offset, 16, FALSE);
778                         bit_offset = bit_offset + 16;
779                 }
780         }
781         /* overscan_info_present_flag 0 u(1) */
782         overscan_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
783         proto_tree_add_bits_item(tree, hf_h264_overscan_info_present_flag, tvb, bit_offset, 1, FALSE);
784         bit_offset++;
785         
786         if( overscan_info_present_flag ){
787                 /* overscan_appropriate_flag 0 u(1) */
788                 proto_tree_add_bits_item(tree, hf_h264_overscan_appropriate_flag, tvb, bit_offset, 1, FALSE);
789                 bit_offset++;
790         }
791         
792         /* video_signal_type_present_flag 0 u(1) */
793         video_signal_type_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
794         proto_tree_add_bits_item(tree, hf_h264_video_signal_type_present_flag, tvb, bit_offset, 1, FALSE);
795         bit_offset++;
796         
797         if( video_signal_type_present_flag ) {
798                 /* video_format 0 u(3) > */
799                 proto_tree_add_bits_item(tree, hf_h264_video_format, tvb, bit_offset, 3, FALSE);
800                 bit_offset = bit_offset + 3;
801         
802                 /* video_full_range_flag 0 u(1)*/
803                 proto_tree_add_bits_item(tree, hf_h264_video_full_range_flag, tvb, bit_offset, 1, FALSE);
804                 bit_offset++;
805                 
806                 /* colour_description_present_flag 0 u(1) */
807                 colour_description_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
808                 proto_tree_add_bits_item(tree, hf_h264_colour_description_present_flag, tvb, bit_offset, 1, FALSE);
809                 bit_offset++;
810                 
811                 if( colour_description_present_flag ) {
812                         /* colour_primaries 0 u(8) */
813                         proto_tree_add_bits_item(tree, hf_h264_colour_primaries, tvb, bit_offset, 8, FALSE);
814                         bit_offset = bit_offset + 8;
815
816                         /* transfer_characteristics 0 u(8) */
817                         proto_tree_add_bits_item(tree, hf_h264_transfer_characteristics, tvb, bit_offset, 8, FALSE);
818                         bit_offset = bit_offset + 8;
819
820                         /* matrix_coefficients 0 u(8)*/
821                         proto_tree_add_bits_item(tree, hf_h264_matrix_coefficients, tvb, bit_offset, 8, FALSE);
822                         bit_offset = bit_offset + 8;
823                 }
824         }
825
826         /* chroma_loc_info_present_flag 0 u(1) */
827         chroma_loc_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
828         proto_tree_add_bits_item(tree, hf_h264_chroma_loc_info_present_flag, tvb, bit_offset, 1, FALSE);
829         bit_offset++;
830
831         if( chroma_loc_info_present_flag ) {
832                 /* chroma_sample_loc_type_top_field 0 ue(v) */
833                 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_sample_loc_type_top_field, tvb, &bit_offset, H264_UE_V);
834
835                 /* chroma_sample_loc_type_bottom_field 0 ue(v) */
836                 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_sample_loc_type_bottom_field, tvb, &bit_offset, H264_UE_V);
837         }
838
839         /* timing_info_present_flag 0 u(1) */
840         timing_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
841         proto_tree_add_bits_item(tree, hf_h264_timing_info_present_flag, tvb, bit_offset, 1, FALSE);
842         bit_offset++;
843
844         if( timing_info_present_flag ) {
845                 /* num_units_in_tick 0 u(32) */
846                 proto_tree_add_bits_item(tree, hf_h264_num_units_in_tick, tvb, bit_offset, 32, FALSE);
847                 bit_offset = bit_offset + 32;
848
849                 /* time_scale 0 u(32) */
850                 proto_tree_add_bits_item(tree, hf_h264_time_scale, tvb, bit_offset, 32, FALSE);
851                 bit_offset = bit_offset + 32;
852                 
853                 /* fixed_frame_rate_flag 0 u(1) */
854                 proto_tree_add_bits_item(tree, hf_h264_fixed_frame_rate_flag, tvb, bit_offset, 1, FALSE);
855                 bit_offset++;
856         }
857         /* nal_hrd_parameters_present_flag 0 u(1) */
858         nal_hrd_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
859         proto_tree_add_bits_item(tree, hf_h264_nal_hrd_parameters_present_flag, tvb, bit_offset, 1, FALSE);
860         bit_offset++;
861
862         if( nal_hrd_parameters_present_flag ){
863                 /* hrd_parameters( ) */
864                 bit_offset = dissect_h264_hrd_parameters(tree, tvb, pinfo, bit_offset);
865         }
866
867         /* vcl_hrd_parameters_present_flag 0 u(1) */
868         vcl_hrd_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
869         proto_tree_add_bits_item(tree, hf_h264_vcl_hrd_parameters_present_flag, tvb, bit_offset, 1, FALSE);
870         bit_offset++;
871
872         if( vcl_hrd_parameters_present_flag ){
873                 /* hrd_parameters( ) */
874                 bit_offset = dissect_h264_hrd_parameters(tree, tvb, pinfo, bit_offset);
875         }
876         if( nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag ){
877                 /* low_delay_hrd_flag 0 u(1) */
878                 proto_tree_add_bits_item(tree, hf_h264_low_delay_hrd_flag, tvb, bit_offset, 1, FALSE);
879                 bit_offset++;
880         }
881         /* pic_struct_present_flag 0 u(1) */
882         proto_tree_add_bits_item(tree, hf_h264_pic_struct_present_flag, tvb, bit_offset, 1, FALSE);
883         bit_offset++;
884
885         /* bitstream_restriction_flag 0 u(1) */
886         bitstream_restriction_flag = tvb_get_bits8(tvb, bit_offset, 1);
887         proto_tree_add_bits_item(tree, hf_h264_bitstream_restriction_flag, tvb, bit_offset, 1, FALSE);
888         bit_offset++;
889
890         if( bitstream_restriction_flag ) {
891                 /* motion_vectors_over_pic_boundaries_flag 0 u(1) */
892                 proto_tree_add_bits_item(tree, hf_h264_motion_vectors_over_pic_boundaries_flag, tvb, bit_offset, 1, FALSE);
893                 bit_offset++;
894
895                 /* max_bytes_per_pic_denom 0 ue(v) */
896                 dissect_h264_exp_golomb_code(tree, hf_h264_max_bytes_per_pic_denom, tvb, &bit_offset, H264_UE_V);
897                 
898                 /* max_bits_per_mb_denom 0 ue(v) */
899                 dissect_h264_exp_golomb_code(tree, hf_h264_max_bits_per_mb_denom, tvb, &bit_offset, H264_UE_V);
900                 
901                 /* log2_max_mv_length_horizontal 0 ue(v) */
902                 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_mv_length_horizontal, tvb, &bit_offset, H264_UE_V);
903                 
904                 /* log2_max_mv_length_vertical 0 ue(v) */
905                 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_mv_length_vertical, tvb, &bit_offset, H264_UE_V);
906                 
907                 /* num_reorder_frames 0 ue(v) */
908                 dissect_h264_exp_golomb_code(tree, hf_h264_num_reorder_frames, tvb, &bit_offset, H264_UE_V);
909                 
910                 /* max_dec_frame_buffering 0 ue(v) */
911                 dissect_h264_exp_golomb_code(tree, hf_h264_max_dec_frame_buffering, tvb, &bit_offset, H264_UE_V);
912         }
913
914         return bit_offset;
915 }
916
917
918 /* Used To dissect SDP parameter (H.264)profile */
919 void
920 dissect_h264_profile(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
921 {
922         proto_item *item, *level_item;
923         proto_tree *h264_profile_tree;
924         gint    offset = 0;
925         guint8  constraint_set3_flag;
926         guint32 level_idc;
927
928         item = proto_tree_add_item(tree, hf_h264_profile, tvb, offset, -1, FALSE);
929         h264_profile_tree = proto_item_add_subtree(item, ett_h264_profile);
930
931         proto_tree_add_item(h264_profile_tree, hf_h264_profile_idc, tvb, offset, 1, FALSE);
932         offset++;
933         
934         constraint_set3_flag = (tvb_get_guint8(tvb,offset)&0x10)>>4;
935         proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set0_flag, tvb, offset, 1, FALSE);
936         proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set1_flag, tvb, offset, 1, FALSE);
937         proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set2_flag, tvb, offset, 1, FALSE);
938         proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set3_flag, tvb, offset, 1, FALSE);
939         proto_tree_add_item(h264_profile_tree, hf_h264_reserved_zero_4bits, tvb, offset, 1, FALSE);
940         offset++;
941
942         /* A level to which the bitstream conforms shall be indicated by the syntax element level_idc as follows.
943          *      - If level_idc is equal to 11 and constraint_set3_flag is equal to 1, the indicated level is level 1b.
944          *      - Otherwise (level_idc is not equal to 11 or constraint_set3_flag is not equal to 1), level_idc shall
945          *    be set equal to a value of ten times the level number specified in Table A-1 and constraint_set3_flag
946          *    shall be set equal to 0.
947          */
948
949         level_idc = tvb_get_guint8(tvb,offset);
950         level_item = proto_tree_add_item(h264_profile_tree, hf_h264_level_idc, tvb, offset, 1, FALSE);
951         if((level_idc==11)&&(constraint_set3_flag==1)){
952                 proto_item_append_text(level_item," [Level 1b]");
953         }else{
954                 proto_item_append_text(level_item," [Level %.1f]",((double)level_idc/10));
955         }
956
957 }
958
959 /*
960  * 7.3.2.8 Slice layer without partitioning RBSP syntax
961  * slice_layer_without_partitioning_rbsp( )
962  */
963
964 static void
965 dissect_h264_slice_layer_without_partitioning_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
966 {
967         gint bit_offset;
968
969         bit_offset = offset <<3;
970
971         /* slice_header( ) 2 */
972         bit_offset = dissect_h264_slice_header(tree, tvb, pinfo, bit_offset);
973         proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
974         return; 
975         /* slice_data( ) * all categories of slice_data( ) syntax * 2 | 3 | 4 */
976         /* rbsp_slice_trailing_bits( ) */
977
978 }
979
980 /*
981  * 7.3.2.9.1 Slice data partition A RBSP syntax
982  * slice_data_partition_a_layer_rbsp( )
983  */
984 static void
985 dissect_h264_slice_data_partition_a_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
986 {
987         gint bit_offset;
988
989         bit_offset = offset <<3;
990
991         /* slice_header( ) 2 */
992         bit_offset = dissect_h264_slice_header(tree, tvb, pinfo, bit_offset);
993
994         /* slice_id All ue(v) */
995         dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
996         proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
997         return; 
998         /* slice_data( ) * only category 2 parts of slice_data( ) syntax * 2*/
999         /* rbsp_slice_trailing_bits( )*/
1000
1001 }
1002
1003 /* 
1004  * 7.3.2.9.2 Slice data partition B RBSP syntax
1005  * slice_data_partition_b_layer_rbsp(
1006  */
1007 static void
1008 dissect_h264_slice_data_partition_b_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1009 {
1010         gint bit_offset;
1011
1012         bit_offset = offset <<3;
1013
1014         /* slice_id All ue(v) */
1015         dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1016         /* if( redundant_pic_cnt_present_flag ) */
1017         /* redundant_pic_cnt All ue(v) */
1018         /* slice_data( ) * only category 3 parts of slice_data( ) syntax * 3 */
1019         /* rbsp_slice_trailing_bits( ) 3 */
1020         proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1021
1022 }
1023
1024 /*
1025  * 7.3.2.9.3 Slice data partition C RBSP syntax
1026  * slice_data_partition_c_layer_rbsp( )
1027  */
1028 static void
1029 dissect_h264_slice_data_partition_c_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1030 {
1031         gint bit_offset;
1032
1033         bit_offset = offset <<3;
1034
1035         /* slice_id All ue(v) */
1036         dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1037         /* if( redundant_pic_cnt_present_flag ) */
1038         /* redundant_pic_cnt All ue(v) */
1039         /* slice_data( ) * only category 4 parts of slice_data( ) syntax * 4 */
1040         /* rbsp_slice_trailing_bits( ) 4 */
1041         proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1042
1043 }
1044 /*
1045  * 7.3.2.3 Supplemental enhancement information RBSP syntax
1046  * sei_rbsp( )
1047  */
1048 static void
1049 dissect_h264_sei_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1050 {
1051         /* do */
1052         /* sei_message( ) 5*/
1053         /* while( more_rbsp_data( ) )*/
1054         /* rbsp_trailing_bits( ) 5 */
1055         proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1056
1057 }
1058
1059 /* Ref 7.3.2.1 Sequence parameter set RBSP syntax */
1060 static void
1061 dissect_h264_seq_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1062 {
1063         proto_item *level_item;
1064         gint bit_offset;
1065         guint8  constraint_set3_flag;
1066         guint32 level_idc;
1067
1068         gint i; 
1069         guint8 profile_idc, chroma_format_idc, frame_mbs_only_flag, frame_cropping_flag;
1070         guint8 pic_order_cnt_type, vui_parameters_present_flag, num_ref_frames_in_pic_order_cnt_cycle;
1071         guint8 seq_scaling_matrix_present_flag; /* seq_scaling_list_present_flag */
1072
1073         /* profile_idc 0 u(8) */
1074         profile_idc = tvb_get_guint8(tvb,offset);
1075         proto_tree_add_item(tree, hf_h264_profile_idc, tvb, offset, 1, FALSE);
1076         offset++;
1077         
1078         constraint_set3_flag = (tvb_get_guint8(tvb,offset)&0x10)>>4;
1079         /* constraint_set0_flag 0 u(1) */
1080         proto_tree_add_item(tree, hf_h264_constraint_set0_flag, tvb, offset, 1, FALSE);
1081         
1082         /* constraint_set1_flag 0 u(1) */
1083         proto_tree_add_item(tree, hf_h264_constraint_set1_flag, tvb, offset, 1, FALSE);
1084         
1085         /* constraint_set2_flag 0 u(1) */
1086         proto_tree_add_item(tree, hf_h264_constraint_set2_flag, tvb, offset, 1, FALSE);
1087         
1088         /* constraint_set3_flag 0 u(1) */
1089         proto_tree_add_item(tree, hf_h264_constraint_set3_flag, tvb, offset, 1, FALSE);
1090         
1091         /* reserved_zero_4bits  equal to 0  0 u(4)*/
1092         proto_tree_add_item(tree, hf_h264_reserved_zero_4bits, tvb, offset, 1, FALSE);
1093         offset++;
1094         
1095         /* level_idc 0 u(8) */
1096         level_idc = tvb_get_guint8(tvb,offset);
1097         level_item = proto_tree_add_item(tree, hf_h264_level_idc, tvb, offset, 1, FALSE);
1098         if((level_idc==11)&&(constraint_set3_flag==1)){
1099                 proto_item_append_text(level_item,"[Level 1b]");
1100         }else{
1101                 proto_item_append_text(level_item,"[Level %.1f]",((double)level_idc/10));
1102         }
1103         offset++;
1104         /* seq_parameter_set_id 0 ue(v) 
1105          * ue(v): unsigned integer Exp-Golomb-coded syntax element with the left bit first.
1106          * The parsing process for this descriptor is specified in subclause 9.1.
1107          */
1108         bit_offset = offset<<3;
1109         dissect_h264_exp_golomb_code(tree, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1110
1111
1112         if( profile_idc == 100 || profile_idc == 110 ||
1113                 profile_idc == 122 || profile_idc == 144 ) {
1114
1115                 /* chroma_format_idc 0 ue(v) */
1116                 chroma_format_idc = dissect_h264_exp_golomb_code(tree, hf_h264_chroma_format_idc, tvb, &bit_offset, H264_UE_V);
1117                 if( chroma_format_idc == 3 ){
1118                         /* residual_colour_transform_flag 0 u(1) */
1119                         proto_tree_add_bits_item(tree, hf_h264_residual_colour_transform_flag, tvb, bit_offset, 1, FALSE);
1120                         bit_offset++;
1121                 }
1122
1123                 /* bit_depth_luma_minus8 0 ue(v) */
1124                 dissect_h264_exp_golomb_code(tree, hf_h264_bit_depth_luma_minus8, tvb, &bit_offset, H264_UE_V);
1125
1126                 /* bit_depth_chroma_minus8 0 ue(v) */
1127                 dissect_h264_exp_golomb_code(tree, hf_h264_bit_depth_chroma_minus8, tvb, &bit_offset, H264_UE_V);
1128
1129                 /* qpprime_y_zero_transform_bypass_flag 0 u(1) */
1130                 proto_tree_add_bits_item(tree, hf_h264_qpprime_y_zero_transform_bypass_flag, tvb, bit_offset, 1, FALSE);
1131                 bit_offset++;
1132
1133                 /* seq_scaling_matrix_present_flag 0 u(1) */
1134                 seq_scaling_matrix_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1135                 proto_tree_add_bits_item(tree, hf_h264_seq_scaling_matrix_present_flag, tvb, bit_offset, 1, FALSE);
1136                 bit_offset++;
1137                 
1138                 if( seq_scaling_matrix_present_flag ){
1139                         /*
1140                         for( i = 0; i < 8; i++ ) {
1141                                 / seq_scaling_list_present_flag[ i ] 0 u(1) /
1142                                 seq_scaling_list_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1143                                 bit_offset++;
1144                                 if( seq_scaling_list_present_flag){
1145                                         if( i < 6 )
1146                                                 scaling_list( ScalingList4x4[ i ], 16,UseDefaultScalingMatrix4x4Flag[ i ])0
1147                                                 dissect_h264_scaling_list()
1148                                         else
1149                                                 scaling_list( ScalingList8x8[ i - 6 ], 64,UseDefaultScalingMatrix8x8Flag[ i - 6 ] )0
1150                                 }
1151                         }
1152                         */
1153                         proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1154                         return;
1155                 }
1156
1157         }
1158
1159         /* log2_max_frame_num_minus4 0 ue(v) */
1160         dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_frame_num_minus4, tvb, &bit_offset, H264_UE_V);
1161
1162         /* pic_order_cnt_type 0 ue(v) */
1163         offset = bit_offset>>3;
1164         pic_order_cnt_type = dissect_h264_exp_golomb_code(tree,hf_h264_pic_order_cnt_type, tvb, &bit_offset, H264_UE_V);
1165
1166         if(pic_order_cnt_type == 0){
1167                 /* log2_max_pic_order_cnt_lsb_minus4 0 ue(v) */
1168                 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_pic_order_cnt_lsb_minus4, tvb, &bit_offset, H264_UE_V);
1169         }else if(pic_order_cnt_type == 1) {
1170                 /* delta_pic_order_always_zero_flag 0 u(1) */
1171                 proto_tree_add_bits_item(tree, hf_h264_delta_pic_order_always_zero_flag, tvb, bit_offset, 1, FALSE);
1172                 bit_offset++;
1173
1174                 /* offset_for_non_ref_pic 0 se(v) */
1175                 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_non_ref_pic, tvb, &bit_offset, H264_SE_V);
1176                 
1177                 /* offset_for_top_to_bottom_field 0 se(v) */
1178                 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_top_to_bottom_field, tvb, &bit_offset, H264_SE_V);
1179                 
1180                 /* num_ref_frames_in_pic_order_cnt_cycle 0 ue(v) */
1181                 num_ref_frames_in_pic_order_cnt_cycle = dissect_h264_exp_golomb_code(tree, hf_264_num_ref_frames_in_pic_order_cnt_cycle, tvb, &bit_offset, H264_UE_V);
1182                 for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ ){
1183                         /*offset_for_ref_frame[ i ] 0 se(v)*/
1184                         dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_ref_frame, tvb, &bit_offset, H264_SE_V);
1185                 }
1186         } 
1187         /* num_ref_frames 0 ue(v) */
1188         dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_frames, tvb, &bit_offset, H264_UE_V);
1189
1190         /*      gaps_in_frame_num_value_allowed_flag 0 u(1) */
1191         proto_tree_add_bits_item(tree, hf_h264_gaps_in_frame_num_value_allowed_flag, tvb, bit_offset, 1, FALSE);
1192         bit_offset++;
1193         
1194         /*      pic_width_in_mbs_minus1 0 ue(v) */
1195         dissect_h264_exp_golomb_code(tree, hf_h264_pic_width_in_mbs_minus1, tvb, &bit_offset, H264_UE_V);
1196         
1197         /* pic_height_in_map_units_minus1 0 ue(v) */
1198         dissect_h264_exp_golomb_code(tree, hf_h264_pic_height_in_map_units_minus1, tvb, &bit_offset, H264_UE_V);
1199
1200         /* frame_mbs_only_flag 0 u(1) */
1201         frame_mbs_only_flag = tvb_get_bits8(tvb, bit_offset, 1);
1202         proto_tree_add_bits_item(tree, hf_h264_frame_mbs_only_flag, tvb, bit_offset, 1, FALSE);
1203         bit_offset++;
1204         if( !frame_mbs_only_flag ){
1205                 /* mb_adaptive_frame_field_flag 0 u(1) */
1206                 proto_tree_add_bits_item(tree, hf_h264_mb_adaptive_frame_field_flag, tvb, bit_offset, 1, FALSE);
1207                 bit_offset++;
1208         }
1209         
1210         /* direct_8x8_inference_flag 0 u(1) */
1211         proto_tree_add_bits_item(tree, hf_h264_direct_8x8_inference_flag, tvb, bit_offset, 1, FALSE);
1212         bit_offset++;
1213         
1214         /* frame_cropping_flag 0 u(1) */
1215         frame_cropping_flag = tvb_get_bits8(tvb, bit_offset, 1);
1216         proto_tree_add_bits_item(tree, hf_h264_frame_cropping_flag, tvb, bit_offset, 1, FALSE);
1217         bit_offset++;
1218
1219         if(frame_cropping_flag) {
1220                 /* frame_crop_left_offset 0 ue(v) */
1221                 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_left_offset, tvb, &bit_offset, H264_UE_V);
1222                 dissect_h264_exp_golomb_code(tree,hf_h264_frame_crop_right_offset, tvb, &bit_offset, H264_UE_V);
1223                 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_top_offset, tvb, &bit_offset, H264_UE_V);
1224                 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_bottom_offset, tvb, &bit_offset, H264_UE_V);
1225
1226         }
1227
1228         /*      vui_parameters_present_flag 0 u(1) */
1229         vui_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1230         proto_tree_add_bits_item(tree, hf_h264_vui_parameters_present_flag, tvb, bit_offset, 1, FALSE);
1231         bit_offset++;
1232         if(vui_parameters_present_flag){
1233                 bit_offset = dissect_h264_vui_parameters(tree, tvb, pinfo, bit_offset);
1234         }
1235         
1236         /*      rbsp_trailing_bits( ) 0 */
1237         bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset); 
1238
1239 }
1240
1241 /* 7.3.2.2 Picture parameter set RBSP syntax */
1242
1243 static void
1244 dissect_h264_pic_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1245 {
1246
1247         gint bit_offset;
1248         guint32 num_slice_groups_minus1, slice_group_map_type, pic_scaling_matrix_present_flag;
1249
1250         bit_offset = offset<<3;
1251
1252         /* pic_parameter_set_id 1 ue(v) */
1253         dissect_h264_exp_golomb_code(tree, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1254
1255         /* seq_parameter_set_id 1 ue(v) */
1256         dissect_h264_exp_golomb_code(tree, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1257
1258         /* entropy_coding_mode_flag 1 u(1) */
1259         proto_tree_add_bits_item(tree, hf_h264_entropy_coding_mode_flag, tvb, bit_offset, 1, FALSE);
1260         bit_offset++;
1261
1262         /* pic_order_present_flag 1 u(1)*/
1263         proto_tree_add_bits_item(tree, hf_h264_pic_order_present_flag, tvb, bit_offset, 1, FALSE);
1264         bit_offset++;
1265
1266         /* num_slice_groups_minus1 1 ue(v)*/
1267         num_slice_groups_minus1 = dissect_h264_exp_golomb_code(tree, hf_h264_num_slice_groups_minus1, tvb, &bit_offset, H264_UE_V);
1268         if( num_slice_groups_minus1 > 0 ) {
1269                 /* slice_group_map_type 1 ue(v)*/
1270                 slice_group_map_type = dissect_h264_exp_golomb_code(tree, hf_h264_slice_group_map_type, tvb, &bit_offset, H264_UE_V);
1271         /* if( slice_group_map_type = = 0 )*/
1272         /* for( iGroup = 0; iGroup <= num_slice_groups_minus1; iGroup++ )*/
1273         /* run_length_minus1[ iGroup ] 1 ue(v)*/
1274         /* else if( slice_group_map_type == 2 )*/
1275         /* for( iGroup = 0; iGroup < num_slice_groups_minus1; iGroup++ ) {*/
1276         /* top_left[ iGroup ] 1 ue(v)*/
1277         /* bottom_right[ iGroup ] 1 ue(v)*/
1278         /* }*/
1279         /* else if( slice_group_map_type == 3 ||*/
1280         /* slice_group_map_type == 4 ||*/
1281         /* slice_group_map_type == 5 ) {*/
1282         /* slice_group_change_direction_flag 1 u(1)*/
1283         /* slice_group_change_rate_minus1 1 ue(v)*/
1284         /* } else if( slice_group_map_type == 6 ) {*/
1285         /* pic_size_in_map_units_minus1 1 ue(v)*/
1286         /* for( i = 0; i <= pic_size_in_map_units_minus1; i++ )*/
1287         /* slice_group_id[ i ] 1 u(v)*/
1288         /* }*/
1289         /* }*/
1290                 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1291                 return;
1292         }
1293         /* num_ref_idx_l0_active_minus1 1 ue(v)*/
1294         dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_idx_l0_active_minus1, tvb, &bit_offset, H264_UE_V);
1295         
1296         /* num_ref_idx_l1_active_minus1 1 ue(v)*/
1297         dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_idx_l1_active_minus1, tvb, &bit_offset, H264_UE_V);
1298         
1299         /* weighted_pred_flag 1 u(1)*/
1300         proto_tree_add_bits_item(tree, hf_h264_weighted_pred_flag, tvb, bit_offset, 1, FALSE);
1301         bit_offset++;
1302         
1303         /* weighted_bipred_idc 1 u(2)*/
1304         proto_tree_add_bits_item(tree, hf_h264_weighted_bipred_idc, tvb, bit_offset, 2, FALSE);
1305         bit_offset= bit_offset+2;
1306
1307         /* pic_init_qp_minus26  * relative to 26 * 1 se(v)*/
1308         dissect_h264_exp_golomb_code(tree, hf_h264_pic_init_qp_minus26, tvb, &bit_offset, H264_SE_V);
1309
1310         /* pic_init_qs_minus26  * relative to 26 *  1 se(v)*/
1311         dissect_h264_exp_golomb_code(tree, hf_h264_pic_init_qs_minus26, tvb, &bit_offset, H264_SE_V);
1312
1313         /* chroma_qp_index_offset 1 se(v)*/
1314         dissect_h264_exp_golomb_code(tree, hf_h264_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
1315
1316         /* deblocking_filter_control_present_flag 1 u(1)*/
1317         proto_tree_add_bits_item(tree, hf_h264_deblocking_filter_control_present_flag, tvb, bit_offset, 1, FALSE);
1318         bit_offset++;
1319
1320         /* constrained_intra_pred_flag 1 u(1)*/
1321         proto_tree_add_bits_item(tree, hf_h264_constrained_intra_pred_flag, tvb, bit_offset, 1, FALSE);
1322         bit_offset++;
1323
1324         /* redundant_pic_cnt_present_flag 1 u(1)*/
1325         proto_tree_add_bits_item(tree, hf_h264_redundant_pic_cnt_present_flag, tvb, bit_offset, 1, FALSE);
1326         bit_offset++;
1327
1328         if( more_rbsp_data(tree, tvb, pinfo, bit_offset)){
1329                 /* transform_8x8_mode_flag 1 u(1)*/
1330                 proto_tree_add_bits_item(tree, hf_h264_transform_8x8_mode_flag, tvb, bit_offset, 1, FALSE);
1331                 bit_offset++;
1332
1333                 /* pic_scaling_matrix_present_flag 1 u(1)*/
1334                 pic_scaling_matrix_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1335                 proto_tree_add_bits_item(tree, hf_h264_pic_scaling_matrix_present_flag, tvb, bit_offset, 1, FALSE);
1336                 bit_offset++;
1337
1338                 if( pic_scaling_matrix_present_flag ){
1339                         proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1340                         return;
1341                         /* for( i = 0; i < 6 + 2* transform_8x8_mode_flag; i++ ) {*/
1342                                 /* pic_scaling_list_present_flag[ i ] 1 u(1)*/
1343                                 /* if( pic_scaling_list_present_flag[ i ] )*/
1344                                 /* if( i < 6 )*/
1345                                         /* scaling_list( ScalingList4x4[ i ], 16, UseDefaultScalingMatrix4x4Flag[ i ] )*/
1346                                 /* else*/
1347                                         /* scaling_list( ScalingList8x8[ i - 6 ], 64, UseDefaultScalingMatrix8x8Flag[ i - 6 ] )*/
1348                         /* }*/
1349                         proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "[Not decoded yet]");
1350                         }
1351
1352                 /* second_chroma_qp_index_offset 1 se(v)*/
1353                 dissect_h264_exp_golomb_code(tree, hf_h264_second_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
1354         }
1355         bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1356
1357 }
1358
1359 /*
1360  * 7.3.2.4 Access unit delimiter RBSP syntax
1361  * access_unit_delimiter_rbsp( )
1362  */
1363 static void
1364 dissect_h264_access_unit_delimiter_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1365 {
1366         /* primary_pic_type 6 u(3) */
1367         /* rbsp_trailing_bits( ) 6 */
1368         proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1369
1370 }
1371
1372 /*
1373  * 7.3.2.5 End of sequence RBSP syntax
1374  * end_of_seq_rbsp( ) {}
1375  */
1376 static void
1377 dissect_h264_end_of_seq_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1378 {
1379         proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1380
1381 }
1382
1383 /*
1384  * 7.3.2.6 End of stream RBSP syntax
1385  * end_of_stream_rbsp( ) {}
1386  */
1387 static void
1388 dissect_h264_end_of_stream_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1389 {
1390         proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1391
1392 }
1393
1394 /*
1395  * 7.3.2.7 Filler data RBSP syntax
1396  * filler_data_rbsp( )
1397  */
1398 static void
1399 dissect_h264_filler_data_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1400 {
1401         /* while( next_bits( 8 ) = = 0xFF ) */
1402         /* ff_byte * equal to 0xFF * 9 f(8) */
1403         /* rbsp_trailing_bits( ) 9 */
1404         proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1405
1406 }
1407
1408 /*
1409  * 7.3.2.1.2 Sequence parameter set extension RBSP syntax
1410  * seq_parameter_set_extension_rbsp( )
1411  */
1412 static void
1413 dissect_h264_seq_parameter_set_extension_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1414 {
1415         /* seq_parameter_set_id 10 ue(v) */
1416         /* aux_format_idc 10 ue(v) */
1417         /* if( aux_format_idc != 0 ) { */
1418         /* bit_depth_aux_minus8 10 ue(v) */
1419         /* alpha_incr_flag 10 u(1) */
1420         /* alpha_opaque_value 10 u(v) */
1421         /* alpha_transparent_value 10 u(v) */
1422         /* } */
1423         /* additional_extension_flag 10 u(1) */
1424         /* rbsp_trailing_bits() 10 */
1425         proto_tree_add_text(tree, tvb, offset, -1, "[Not decoded yet]");
1426
1427 }
1428
1429
1430 /* Dissect NAL unit as recived in sprop-parameter-sets of SDP */
1431 void
1432 dissect_h264_nal_unit(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1433 {
1434         proto_item *item;
1435         proto_tree *h264_nal_tree;
1436         gint    offset = 0;
1437         guint8 nal_unit_type;
1438         item = proto_tree_add_item(tree, hf_h264_nal_unit, tvb, offset, -1, FALSE);
1439         h264_nal_tree = proto_item_add_subtree(item, ett_h264_nal_unit);
1440
1441         /* Ref: 7.3.1 NAL unit syntax */
1442         nal_unit_type = tvb_get_guint8(tvb,offset) & 0x1f;
1443
1444         /* forbidden_zero_bit All f(1) */
1445         proto_tree_add_item(h264_nal_tree, hf_h264_forbidden_zero_bit, tvb, offset, 1, FALSE);
1446         /* nal_ref_idc All u(2) */
1447         proto_tree_add_item(h264_nal_tree, hf_h264_nal_ref_idc, tvb, offset, 1, FALSE);
1448         /* nal_unit_type All u(5) */
1449         proto_tree_add_item(h264_nal_tree, hf_h264_nal_unit_type, tvb, offset, 1, FALSE);
1450         offset++;
1451
1452         switch(nal_unit_type){
1453         case 0: /* Unspecified */
1454                 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Unspecified NAL unit type");
1455                 break;
1456         case 1: /* Coded slice of a non-IDR picture */ 
1457                 dissect_h264_slice_layer_without_partitioning_rbsp(h264_nal_tree, tvb, pinfo, offset);
1458                 break;
1459         case 2: /* Coded slice data partition A */
1460                 dissect_h264_slice_data_partition_a_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1461                 break;
1462         case 3: /* Coded slice data partition B */
1463                 dissect_h264_slice_data_partition_b_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1464                 break;
1465         case 4: /* Coded slice data partition C */
1466                 dissect_h264_slice_data_partition_c_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1467                 break;
1468         case 5: /* Coded slice of an IDR picture */
1469                 dissect_h264_slice_layer_without_partitioning_rbsp(h264_nal_tree, tvb, pinfo, offset);
1470                 break;
1471         case 6: /* Supplemental enhancement information (SEI) */
1472                 dissect_h264_sei_rbsp(h264_nal_tree, tvb, pinfo, offset);
1473                 break;
1474         case H264_SEQ_PAR_SET:  /* 7 Sequence parameter set*/
1475                 dissect_h264_seq_parameter_set_rbsp(h264_nal_tree, tvb, pinfo, offset);
1476                 break;
1477         case H264_PIC_PAR_SET:  /* 8 Picture parameter set */
1478                 dissect_h264_pic_parameter_set_rbsp(h264_nal_tree, tvb, pinfo, offset);
1479                 break;
1480         case 9: /* Access unit delimiter */
1481                 dissect_h264_access_unit_delimiter_rbsp(h264_nal_tree, tvb, pinfo, offset);
1482                 break;
1483         case 10:        /* End of sequence */
1484                 dissect_h264_end_of_seq_rbsp(h264_nal_tree, tvb, pinfo, offset);
1485                 break;
1486         case 11:        /* End of stream */
1487                 dissect_h264_end_of_stream_rbsp(h264_nal_tree, tvb, pinfo, offset);
1488                 break;
1489         case 12:        /* Filler data */
1490                 dissect_h264_filler_data_rbsp(h264_nal_tree, tvb, pinfo, offset);
1491                 break;
1492         case 13:        /* Sequence parameter set extension */
1493                 dissect_h264_seq_parameter_set_extension_rbsp(h264_nal_tree, tvb, pinfo, offset);
1494                 break;
1495         case 14:        /* Reserved */
1496         case 15:        /* Reserved */
1497         case 16:        /* Reserved */
1498         case 17:        /* Reserved */
1499         case 18:        /* Reserved */
1500                 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Reserved NAL unit type");
1501                 break;
1502         case 19:        /* Coded slice of an auxiliary coded picture without partitioning */
1503                 dissect_h264_slice_layer_without_partitioning_rbsp(tree, tvb, pinfo, offset);
1504                 break;
1505         default:
1506                 /* 24..31 Unspecified */
1507                 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Unspecified NAL unit type");
1508                 break;
1509         }
1510
1511 }
1512 /* Code to actually dissect the packets */
1513 static void
1514 dissect_h264(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1515 {
1516         int offset = 0;
1517         proto_item *item, *ti, *stream_item;
1518         proto_tree *h264_tree, *h264_nal_tree, *stream_tree;
1519         guint8 type;
1520
1521
1522 /* Make entries in Protocol column and Info column on summary display */
1523         if (check_col(pinfo->cinfo, COL_PROTOCOL)) 
1524                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "H264");
1525         if (tree) {
1526
1527                 item = proto_tree_add_item(tree, proto_h264, tvb, 0, -1, FALSE);
1528                 h264_tree = proto_item_add_subtree(item, ett_h264);
1529
1530                 ti = proto_tree_add_text(h264_tree, tvb, offset, 1, "NAL unit header or first byte of the payload");
1531                 h264_nal_tree = proto_item_add_subtree(ti, ett_h264_nal);
1532                 /* +---------------+
1533                  * |0|1|2|3|4|5|6|7|
1534                  * +-+-+-+-+-+-+-+-+
1535                  * |F|NRI|  Type   |
1536                  * +---------------+
1537                  */
1538
1539                 /* F: 1 bit
1540                  * forbidden_zero_bit.  A value of 0 indicates that the NAL unit type
1541                  * octet and payload should not contain bit errors or other syntax
1542                  * violations.  A value of 1 indicates that the NAL unit type octet
1543                  * and payload may contain bit errors or other syntax violations.
1544                  */
1545                 proto_tree_add_item(h264_nal_tree, hf_h264_nal_f_bit, tvb, offset, 1, FALSE);
1546                 proto_tree_add_item(h264_nal_tree, hf_h264_nal_nri, tvb, offset, 1, FALSE);
1547                 type = tvb_get_guint8(tvb,offset)&0x1f;
1548                 if (check_col(pinfo->cinfo, COL_INFO)){
1549                         col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
1550                                 val_to_str(type, h264_type_values, "Unknown Type (%u)"));
1551                 }
1552
1553                 proto_tree_add_item(h264_nal_tree, hf_h264_type, tvb, offset, 1, FALSE);
1554                 offset++;
1555                 stream_item =proto_tree_add_text(h264_tree, tvb, offset, -1, "H264 bitstream");
1556                 stream_tree = proto_item_add_subtree(stream_item, ett_h264_stream);
1557                 switch(type){
1558                 case 1:                         /* 1 Coded slice of a non-IDR picture */ 
1559                         dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, tvb, pinfo, offset);
1560                         break;
1561                 case 3: /* Coded slice data partition B */
1562                         dissect_h264_slice_data_partition_b_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1563                         break;
1564                 case 4: /* Coded slice data partition C */
1565                         dissect_h264_slice_data_partition_c_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
1566                         break;
1567                 case 5: /* Coded slice of an IDR picture */
1568                         dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, tvb, pinfo, offset);
1569                         break;
1570                 case H264_SEQ_PAR_SET:  /* 7 Sequence parameter set*/
1571                         dissect_h264_seq_parameter_set_rbsp(stream_tree, tvb, pinfo, offset);
1572                         break;
1573                 case H264_PIC_PAR_SET:  /* 8 Picture parameter set */
1574                         dissect_h264_pic_parameter_set_rbsp(stream_tree, tvb, pinfo, offset);
1575                         break;
1576                 case 19:        /* Coded slice of an auxiliary coded picture without partitioning */
1577                         dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, tvb, pinfo, offset);
1578                         break;
1579                 default:
1580                         break;
1581                 }
1582         }/* if tree */
1583
1584 }
1585
1586
1587 /* Capability */
1588
1589 static const int *profile_fields[] = {
1590   &hf_h264_par_profile_b,
1591   &hf_h264_par_profile_m,
1592   &hf_h264_par_profile_e,
1593   &hf_h264_par_profile_h,
1594   &hf_h264_par_profile_h10,
1595   &hf_h264_par_profile_h4_2_2,
1596   &hf_h264_par_profile_h4_4_4,
1597   NULL
1598 };
1599
1600 static int
1601 dissect_h264_par_profile(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1602 {
1603   int offset = 0;
1604
1605   proto_tree_add_bitmask(tree, tvb, offset, 
1606                          hf_h264_par_profile, ett_h264_par_profile,
1607                          profile_fields, FALSE);
1608   offset += 1;
1609   return offset;
1610 }
1611
1612 static const int *AdditionalModesSupported_fields[] = {
1613   &hf_h264_par_add_mode_sup_rcdo,
1614   NULL
1615 };
1616 static int
1617 dissect_h264_par_AdditionalModesSupported(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1618 {
1619   int offset = 0;
1620
1621   proto_tree_add_bitmask(tree, tvb, offset, 
1622                          hf_h264_par_AdditionalModesSupported, ett_h264_par_AdditionalModesSupported,
1623                          AdditionalModesSupported_fields, FALSE);
1624   offset += 1;
1625   return offset;
1626 }
1627
1628
1629 static const int *ProfileIOP_fields[] = {
1630   &hf_h264_par_constraint_set0_flag,
1631   &hf_h264_par_constraint_set1_flag,
1632   &hf_h264_par_constraint_set2_flag,
1633   NULL
1634 };
1635
1636
1637 static int
1638 dissect_h264_ProfileIOP(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1639 {
1640   int offset = 0;
1641
1642   proto_tree_add_bitmask(tree, tvb, offset, 
1643                          hf_h264_par_ProfileIOP, ett_h264_par_ProfileIOP,
1644                          ProfileIOP_fields, FALSE);
1645   offset += 1;
1646   return offset;
1647 }
1648
1649 static const value_string h264_par_level_values[] = {
1650   { 15,         "1" },
1651   { 19,         "1b" },
1652   { 22,         "1.1" },
1653   { 29,         "1.2" },
1654   { 36,         "1.3" },
1655   { 43,         "2" },
1656   { 50,         "2.1" },
1657   { 57,         "2.2" },
1658   { 64,         "3" },
1659   { 71,         "3.1" },
1660   { 78,         "3.2" },
1661   { 85,         "4" },
1662   { 92,         "4.1" },
1663   { 99,         "4.2" },
1664   { 106,        "5" },
1665   { 113 ,       "5.1" },
1666   { 0,  NULL }
1667 };
1668
1669 static int
1670 dissect_h264_par_level(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_)
1671 {
1672   int offset = 0;
1673   guint16 lvl;
1674   const gchar *p = NULL;
1675   asn1_ctx_t *actx;
1676
1677   actx = get_asn1_ctx(pinfo->private_data);
1678   DISSECTOR_ASSERT(actx);
1679
1680   lvl = tvb_get_ntohs(tvb, offset);
1681   p = match_strval(lvl, VALS(h264_par_level_values));
1682   if (p) {
1683     proto_item_append_text(actx->created_item, " - Level %s", p);
1684   }
1685   offset += 2;
1686   return offset;
1687 }
1688
1689 typedef struct _h264_capability_t {
1690   const gchar *id;
1691   const gchar *name;
1692   new_dissector_t content_pdu;
1693 } h264_capability_t;
1694
1695 static h264_capability_t h264_capability_tab[] = {
1696   /* ITU-T H.241 (05/2006), 8.3 H.264 capabilities */
1697   { "GenericCapability/0.0.8.241.0.0.1", "ITU-T Rec. H.241 H.264 Video Capabilities", NULL },
1698   { "GenericCapability/0.0.8.241.0.0.1/collapsing/41", "Profile", dissect_h264_par_profile },
1699   { "GenericCapability/0.0.8.241.0.0.1/collapsing/42", "Level", dissect_h264_par_level },
1700   { "GenericCapability/0.0.8.241.0.0.1/collapsing/3" , "CustomMaxMBPS", NULL },
1701   { "GenericCapability/0.0.8.241.0.0.1/collapsing/4" , "CustomMaxFS", NULL },
1702   { "GenericCapability/0.0.8.241.0.0.1/collapsing/5" , "CustomMaxDPB", NULL },
1703   { "GenericCapability/0.0.8.241.0.0.1/collapsing/6" , "CustomMaxBRandCPB", NULL },
1704   { "GenericCapability/0.0.8.241.0.0.1/collapsing/7" , "MaxStaticMBPS", NULL },
1705   { "GenericCapability/0.0.8.241.0.0.1/collapsing/8" , "max-rcmd-nal-unit-size", NULL },
1706   { "GenericCapability/0.0.8.241.0.0.1/collapsing/9" , "max-nal-unit-size", NULL },
1707   { "GenericCapability/0.0.8.241.0.0.1/collapsing/10", "SampleAspectRatiosSupported", NULL },
1708   { "GenericCapability/0.0.8.241.0.0.1/collapsing/11", "AdditionalModesSupported", dissect_h264_par_AdditionalModesSupported },
1709   { "GenericCapability/0.0.8.241.0.0.1/collapsing/12", "AdditionalDisplayCapabilities", NULL },
1710   /* TS 26.111  H.264 */
1711   { "GenericCapability/0.0.8.241.0.0.1/collapsing/43" , "DecoderConfigurationInformation", NULL },
1712   { "GenericCapability/0.0.8.241.0.0.1/collapsing/44" , "AcceptRedundantSlices", NULL },
1713   { "GenericCapability/0.0.8.241.0.0.1/collapsing/45" , "NalAlignedMode", NULL },
1714   { "GenericCapability/0.0.8.241.0.0.1/collapsing/46" , "ProfileIOP", dissect_h264_ProfileIOP },
1715   { NULL, NULL, NULL },
1716 };                                 
1717
1718 static h264_capability_t *find_cap(const gchar *id) {
1719   h264_capability_t *ftr = NULL;
1720   h264_capability_t *f;
1721
1722   for (f=h264_capability_tab; f->id; f++) {
1723     if (!strcmp(id, f->id)) { ftr = f; break; }
1724   }
1725   return ftr;
1726 }
1727
1728 static void
1729 dissect_h264_name(tvbuff_t *tvb _U_, packet_info *pinfo, proto_tree *tree) 
1730 {
1731   asn1_ctx_t *actx;
1732   h264_capability_t *ftr = NULL;
1733
1734   actx = get_asn1_ctx(pinfo->private_data);
1735   DISSECTOR_ASSERT(actx);
1736   if (tree) {
1737     ftr = find_cap(pinfo->match_string);
1738     if (ftr) {
1739       proto_item_append_text(actx->created_item, " - %s", ftr->name);
1740       proto_item_append_text(proto_item_get_parent(proto_tree_get_parent(tree)), ": %s", ftr->name);
1741     } else {
1742       proto_item_append_text(actx->created_item, " - unknown(%s)", pinfo->match_string);
1743     }
1744   }
1745 }
1746
1747
1748 /* Register the protocol with Wireshark */
1749 /* If this dissector uses sub-dissector registration add a registration routine.
1750    This format is required because a script is used to find these routines and
1751    create the code that calls these routines.
1752 */
1753 void
1754 proto_reg_handoff_h264(void)
1755 {
1756         dissector_handle_t h264_handle;
1757         dissector_handle_t h264_name_handle;
1758         h264_capability_t *ftr;
1759
1760         static int h264_prefs_initialized = FALSE;
1761         
1762         h264_handle = create_dissector_handle(dissect_h264, proto_h264);
1763
1764         if (!h264_prefs_initialized) {
1765                 h264_prefs_initialized = TRUE;
1766           }
1767         else {
1768                         if ( dynamic_payload_type > 95 )
1769                                 dissector_delete("rtp.pt", dynamic_payload_type, h264_handle);
1770         }
1771         dynamic_payload_type = temp_dynamic_payload_type;
1772
1773         if ( dynamic_payload_type > 95 ){
1774                 dissector_add("rtp.pt", dynamic_payload_type, h264_handle);
1775         }
1776         dissector_add_string("rtp_dyn_payload_type","H264", h264_handle);
1777
1778   h264_name_handle = create_dissector_handle(dissect_h264_name, proto_h264);
1779   for (ftr=h264_capability_tab; ftr->id; ftr++) {
1780     if (ftr->name) 
1781       dissector_add_string("h245.gef.name", ftr->id, h264_name_handle);
1782     if (ftr->content_pdu)
1783       dissector_add_string("h245.gef.content", ftr->id, new_create_dissector_handle(ftr->content_pdu, proto_h264));
1784   }
1785
1786 }
1787
1788 /* this format is require because a script is used to build the C function
1789    that calls all the protocol registration.
1790 */
1791
1792 void
1793 proto_register_h264(void)
1794 {                 
1795
1796         module_t *h264_module;
1797
1798 /* Setup list of header fields  See Section 1.6.1 for details*/
1799         static hf_register_info hf[] = {
1800                 { &hf_h264_nal_f_bit,
1801                         { "F bit",           "h264.f",
1802                         FT_BOOLEAN, 8, TFS(&h264_f_bit_vals), 0x80,          
1803                         "F bit", HFILL }
1804                 },
1805                 { &hf_h264_nal_nri,
1806                         { "Nal_ref_idc (NRI)",           "h264.nal_nri",
1807                         FT_UINT8, BASE_DEC, NULL, 0x60,          
1808                         "NRI", HFILL }
1809                 },
1810                 { &hf_h264_type,
1811                         { "Type",           "h264.nal_unit_hdr",
1812                         FT_UINT8, BASE_DEC, VALS(h264_type_values), 0x1f,          
1813                         "Type", HFILL }
1814                 },
1815                 { &hf_h264_profile,
1816                         { "Profile",           "h264.profile",
1817                         FT_BYTES, BASE_NONE, NULL, 0x0,          
1818                         "Profile", HFILL }
1819                 },
1820                 { &hf_h264_profile_idc,
1821                         { "Profile_idc",           "h264.profile_idc",
1822                         FT_UINT8, BASE_DEC, VALS(h264_profile_idc_values), 0xff,          
1823                         "Profile_idc", HFILL }
1824                 },
1825                 { &hf_h264_rbsp_stop_bit,
1826                         { "rbsp_stop_bit",           "h264.rbsp_stop_bit",
1827                         FT_UINT8, BASE_DEC, NULL, 0x0,          
1828                         "rbsp_stop_bit", HFILL }
1829                 },
1830                 { &hf_h264_rbsp_trailing_bits,
1831                         { "rbsp_trailing_bits",           "h264.rbsp_trailing_bits",
1832                         FT_UINT8, BASE_DEC, NULL, 0x0,          
1833                         "rbsp_trailing_bits", HFILL }
1834                 },
1835                 { &hf_h264_constraint_set0_flag,
1836                         { "Constraint_set0_flag",           "h264.constraint_set0_flag",
1837                         FT_UINT8, BASE_DEC, NULL, 0x80,          
1838                         "Constraint_set0_flag", HFILL }
1839                 },
1840                 { &hf_h264_constraint_set1_flag,
1841                         { "Constraint_set1_flag",           "h264.constraint_set1_flag",
1842                         FT_UINT8, BASE_DEC, NULL, 0x40,          
1843                         "Constraint_set1_flag", HFILL }
1844                 },
1845                 { &hf_h264_constraint_set2_flag,
1846                         { "Constraint_set2_flag",           "h264.constraint_set2_flag",
1847                         FT_UINT8, BASE_DEC, NULL, 0x20,          
1848                         "NRI", HFILL }
1849                 },
1850                 { &hf_h264_constraint_set3_flag,
1851                         { "Constraint_set3_flag",           "h264.constraint_set3_flag",
1852                         FT_UINT8, BASE_DEC, NULL, 0x10,          
1853                         "Constraint_set3_flag", HFILL }
1854                 },
1855                 { &hf_h264_reserved_zero_4bits,
1856                         { "Reserved_zero_4bits",           "h264.reserved_zero_4bits",
1857                         FT_UINT8, BASE_DEC, NULL, 0x0f,          
1858                         "Reserved_zero_4bits", HFILL }
1859                 },
1860                 { &hf_h264_level_idc,
1861                         { "Level_id",           "h264.level_id",
1862                         FT_UINT8, BASE_DEC, NULL, 0xff,          
1863                         "Level_id", HFILL }
1864                 },
1865                 { &hf_h264_nal_unit,
1866                         { "NAL unit",           "h264.nal_unit",
1867                         FT_BYTES, BASE_NONE, NULL, 0x0,          
1868                         "NAL unit", HFILL }
1869                 },
1870                 { &hf_h264_forbidden_zero_bit,
1871                         { "Forbidden_zero_bit",           "h264.forbidden_zero_bit",
1872                         FT_UINT8, BASE_DEC, NULL, 0x80,          
1873                         "forbidden_zero_bit", HFILL }
1874                 },
1875                 { &hf_h264_nal_ref_idc,
1876                         { "Nal_ref_idc",           "h264.nal_ref_idc",
1877                         FT_UINT8, BASE_DEC, NULL, 0x60,          
1878                         "nal_ref_idc", HFILL }
1879                 },
1880                 {&hf_h264_nal_unit_type,
1881                         { "Nal_unit_type",           "h264.nal_unit_type",
1882                         FT_UINT8, BASE_DEC, VALS(h264_nal_unit_type_vals), 0x1f,          
1883                         "nal_unit_type", HFILL }
1884                 },
1885                 { &hf_h264_seq_parameter_set_id,
1886                         { "seq_parameter_set_id",           "h264.seq_parameter_set_id",
1887                         FT_UINT32, BASE_DEC, NULL, 0x0,          
1888                         "seq_parameter_set_id", HFILL }
1889                 },
1890                 { &hf_h264_chroma_format_idc,
1891                         { "chroma_format_id",           "h264.chroma_format_id",
1892                         FT_UINT32, BASE_DEC, NULL, 0x0,          
1893                         "chroma_format_id", HFILL }
1894                 },
1895                 { &hf_h264_residual_colour_transform_flag,
1896                         { "residual_colour_transform_flag",           "h264.residual_colour_transform_flag",
1897                         FT_UINT8, BASE_DEC, NULL, 0x0,          
1898                         "residual_colour_transform_flag", HFILL }
1899                 },
1900                 { &hf_h264_bit_depth_luma_minus8,
1901                         { "bit_depth_luma_minus8",           "h264.bit_depth_luma_minus8",
1902                         FT_UINT32, BASE_DEC, NULL, 0x0,          
1903                         "bit_depth_luma_minus8", HFILL }
1904                 },
1905                 { &hf_h264_bit_depth_chroma_minus8,
1906                         { "bit_depth_chroma_minus8",           "h264.bit_depth_chroma_minus8",
1907                         FT_UINT32, BASE_DEC, NULL, 0x0,          
1908                         "bit_depth_chroma_minus8", HFILL }
1909                 },
1910                 { &hf_h264_qpprime_y_zero_transform_bypass_flag,
1911                         { "qpprime_y_zero_transform_bypass_flag",           "h264.qpprime_y_zero_transform_bypass_flag",
1912                         FT_UINT32, BASE_DEC, NULL, 0x0,          
1913                         "qpprime_y_zero_transform_bypass_flag", HFILL }
1914                 },
1915                 { &hf_h264_seq_scaling_matrix_present_flag,
1916                         { "seq_scaling_matrix_present_flag",           "h264.seq_scaling_matrix_present_flag",
1917                         FT_UINT32, BASE_DEC, NULL, 0x0,          
1918                         "seq_scaling_matrix_present_flag", HFILL }
1919                 },
1920                 { &hf_h264_log2_max_frame_num_minus4,
1921                         { "log2_max_frame_num_minus4",           "h264.log2_max_frame_num_minus4",
1922                         FT_UINT32, BASE_DEC, NULL, 0x0,          
1923                         "log2_max_frame_num_minus4", HFILL }
1924                 },
1925                 { &hf_h264_pic_order_cnt_type,
1926                         { "pic_order_cnt_type",           "h264.pic_order_cnt_type",
1927                         FT_UINT32, BASE_DEC, NULL, 0x0,          
1928                         "pic_order_cnt_type", HFILL }
1929                 },
1930                 { &hf_h264_log2_max_pic_order_cnt_lsb_minus4,
1931                         { "log2_max_pic_order_cnt_lsb_minus4",           "h264.log2_max_pic_order_cnt_lsb_minus4",
1932                         FT_UINT32, BASE_DEC, NULL, 0x0,          
1933                         "log2_max_pic_order_cnt_lsb_minus4", HFILL }
1934                 },
1935                 { &hf_h264_delta_pic_order_always_zero_flag,
1936                         { "delta_pic_order_always_zero_flag",           "h264.delta_pic_order_always_zero_flag",
1937                         FT_UINT8, BASE_DEC, NULL, 0x0,          
1938                         "delta_pic_order_always_zero_flag", HFILL }
1939                 },
1940                 { &hf_h264_offset_for_non_ref_pic,
1941                         { "offset_for_non_ref_pic",           "h264.offset_for_non_ref_pic",
1942                         FT_INT32, BASE_DEC, NULL, 0x0,          
1943                         "offset_for_non_ref_pic", HFILL }
1944                 },
1945                 { &hf_h264_offset_for_top_to_bottom_field,
1946                         { "offset_for_top_to_bottom_field",           "h264.offset_for_top_to_bottom_field",
1947                         FT_INT32, BASE_DEC, NULL, 0x0,          
1948                         "offset_for_top_to_bottom_field", HFILL }
1949                 },
1950                 { &hf_264_num_ref_frames_in_pic_order_cnt_cycle,
1951                         { "num_ref_frames_in_pic_order_cnt_cycle",           "h264.num_ref_frames_in_pic_order_cnt_cycle",
1952                         FT_UINT32, BASE_DEC, NULL, 0x0,          
1953                         "num_ref_frames_in_pic_order_cnt_cycle", HFILL }
1954                 },
1955                 { &hf_h264_offset_for_ref_frame,
1956                         { "offset_for_ref_frame",           "h264.offset_for_ref_frame",
1957                         FT_INT32, BASE_DEC, NULL, 0x0,          
1958                         "offset_for_ref_frame", HFILL }
1959                 },
1960                 { &hf_h264_num_ref_frames,
1961                         { "num_ref_frames",           "h264.num_ref_frames",
1962                         FT_UINT32, BASE_DEC, NULL, 0x0,          
1963                         "num_ref_frames", HFILL }
1964                 },
1965                 { &hf_h264_gaps_in_frame_num_value_allowed_flag,
1966                         { "gaps_in_frame_num_value_allowed_flag",           "h264.gaps_in_frame_num_value_allowed_flag",
1967                         FT_UINT8, BASE_DEC, NULL, 0x0,          
1968                         "gaps_in_frame_num_value_allowed_flag", HFILL }
1969                 },
1970                 { &hf_h264_pic_width_in_mbs_minus1,
1971                         { "pic_width_in_mbs_minus1",           "h264.pic_width_in_mbs_minus1",
1972                         FT_UINT32, BASE_DEC, NULL, 0x0,          
1973                         "pic_width_in_mbs_minus1", HFILL }
1974                 },
1975                 { &hf_h264_pic_height_in_map_units_minus1,
1976                         { "pic_height_in_map_units_minus1",           "h264.pic_height_in_map_units_minus1",
1977                         FT_UINT32, BASE_DEC, NULL, 0x0,          
1978                         "pic_height_in_map_units_minus1", HFILL }
1979                 },
1980                 { &hf_h264_frame_mbs_only_flag,
1981                         { "frame_mbs_only_flag",           "h264.frame_mbs_only_flag",
1982                         FT_UINT8, BASE_DEC, NULL, 0x0,          
1983                         "frame_mbs_only_flag", HFILL }
1984                 },
1985                 { &hf_h264_mb_adaptive_frame_field_flag,
1986                         { "mb_adaptive_frame_field_flag",           "h264.mb_adaptive_frame_field_flag",
1987                         FT_UINT8, BASE_DEC, NULL, 0x0,          
1988                         "mb_adaptive_frame_field_flag", HFILL }
1989                 },
1990                 { &hf_h264_direct_8x8_inference_flag,
1991                         { "direct_8x8_inference_flag",           "h264.direct_8x8_inference_flag",
1992                         FT_UINT8, BASE_DEC, NULL, 0x0,          
1993                         "direct_8x8_inference_flag", HFILL }
1994                 },
1995                 { &hf_h264_frame_cropping_flag,
1996                         { "frame_cropping_flag",           "h264.frame_cropping_flag",
1997                         FT_UINT8, BASE_DEC, NULL, 0x0,          
1998                         "frame_cropping_flag", HFILL }
1999                 },
2000                 { &hf_h264_frame_crop_left_offset,
2001                         { "frame_crop_left_offset",           "h264.frame_crop_left_offset",
2002                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2003                         "frame_crop_left_offset", HFILL }
2004                 },
2005                 { &hf_h264_frame_crop_right_offset,
2006                         { "frame_crop_left_offset",           "h264.frame_crop_right_offset",
2007                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2008                         "frame_crop_right_offset", HFILL }
2009                 },
2010                 { &hf_h264_frame_crop_top_offset,
2011                         { "frame_crop_top_offset",           "h264.frame_crop_top_offset",
2012                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2013                         "frame_crop_top_offset", HFILL }
2014                 },
2015                 { &hf_h264_frame_crop_bottom_offset,
2016                         { "frame_crop_bottom_offset",           "h264.frame_crop_bottom_offset",
2017                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2018                         "frame_crop_bottom_offset", HFILL }
2019                 },
2020                 { &hf_h264_vui_parameters_present_flag,
2021                         { "vui_parameters_present_flag",           "h264.vui_parameters_present_flag",
2022                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2023                         "vui_parameters_present_flag", HFILL }
2024                 },
2025                 { &hf_h264_pic_parameter_set_id,
2026                         { "pic_parameter_set_id",           "h264.pic_parameter_set_id",
2027                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2028                         "pic_parameter_set_id", HFILL }
2029                 },
2030                 { &hf_h264_entropy_coding_mode_flag,
2031                         { "entropy_coding_mode_flag",           "h264.entropy_coding_mode_flag",
2032                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2033                         "entropy_coding_mode_flag", HFILL }
2034                 },
2035                 { &hf_h264_pic_order_present_flag,
2036                         { "pic_order_present_flag",           "h264.pic_order_present_flag",
2037                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2038                         "pic_order_present_flag", HFILL }
2039                 },
2040                 { &hf_h264_num_slice_groups_minus1,
2041                         { "num_slice_groups_minus1",           "h264.num_slice_groups_minus1",
2042                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2043                         "num_slice_groups_minus1", HFILL }
2044                 },
2045                 { &hf_h264_slice_group_map_type,
2046                         { "slice_group_map_type",           "h264.slice_group_map_type",
2047                         FT_UINT32, BASE_DEC, VALS(h264_slice_group_map_type_vals), 0x0,          
2048                         "slice_group_map_type", HFILL }
2049                 },
2050                 { &hf_h264_num_ref_idx_l0_active_minus1,
2051                         { "num_ref_idx_l0_active_minus1",           "h264.num_ref_idx_l0_active_minus1",
2052                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2053                         "num_ref_idx_l0_active_minus1", HFILL }
2054                 },
2055                 { &hf_h264_num_ref_idx_l1_active_minus1,
2056                         { "num_ref_idx_l1_active_minus1",           "h264.num_ref_idx_l1_active_minus1",
2057                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2058                         "num_ref_idx_l1_active_minus1", HFILL }
2059                 },
2060                 { &hf_h264_weighted_pred_flag,
2061                         { "weighted_pred_flag",           "h264.weighted_pred_flag",
2062                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2063                         "weighted_pred_flag", HFILL }
2064                 },
2065                 { &hf_h264_weighted_bipred_idc,
2066                         { "weighted_bipred_idc",           "h264.weighted_bipred_idc",
2067                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2068                         "weighted_bipred_idc", HFILL }
2069                 },
2070                 { &hf_h264_pic_init_qp_minus26,
2071                         { "pic_init_qp_minus26",           "h264.pic_init_qp_minus26",
2072                         FT_INT32, BASE_DEC, NULL, 0x0,          
2073                         "pic_init_qp_minus26", HFILL }
2074                 },
2075                 { &hf_h264_pic_init_qs_minus26,
2076                         { "pic_init_qs_minus26",           "h264.pic_init_qs_minus26",
2077                         FT_INT32, BASE_DEC, NULL, 0x0,          
2078                         "pic_init_qs_minus26", HFILL }
2079                 },
2080                 { &hf_h264_chroma_qp_index_offset,
2081                         { "chroma_qp_index_offset",           "h264.chroma_qp_index_offset",
2082                         FT_INT32, BASE_DEC, NULL, 0x0,          
2083                         "chroma_qp_index_offset", HFILL }
2084                 },
2085                 { &hf_h264_deblocking_filter_control_present_flag,
2086                         { "deblocking_filter_control_present_flag",           "h264.deblocking_filter_control_present_flag",
2087                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2088                         "deblocking_filter_control_present_flag", HFILL }
2089                 },
2090                 { &hf_h264_constrained_intra_pred_flag,
2091                         { "constrained_intra_pred_flag",           "h264.constrained_intra_pred_flag",
2092                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2093                         "constrained_intra_pred_flag", HFILL }
2094                 },
2095                 { &hf_h264_redundant_pic_cnt_present_flag,
2096                         { "redundant_pic_cnt_present_flag",           "h264.redundant_pic_cnt_present_flag",
2097                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2098                         "redundant_pic_cnt_present_flag", HFILL }
2099                 },
2100                 { &hf_h264_transform_8x8_mode_flag,
2101                         { "transform_8x8_mode_flag",           "h264.transform_8x8_mode_flag",
2102                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2103                         "transform_8x8_mode_flag", HFILL }
2104                 },
2105                 { &hf_h264_pic_scaling_matrix_present_flag,
2106                         { "pic_scaling_matrix_present_flag",           "h264.pic_scaling_matrix_present_flag",
2107                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2108                         "pic_scaling_matrix_present_flag", HFILL }
2109                 },
2110                 { &hf_h264_second_chroma_qp_index_offset,
2111                         { "second_chroma_qp_index_offset",           "h264.second_chroma_qp_index_offset",
2112                         FT_INT32, BASE_DEC, NULL, 0x0,          
2113                         "second_chroma_qp_index_offset", HFILL }
2114                 },
2115
2116                 { &hf_h264_aspect_ratio_info_present_flag,
2117                         { "aspect_ratio_info_present_flag",           "h264.aspect_ratio_info_present_flag",
2118                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2119                         "aspect_ratio_info_present_flag", HFILL }
2120                 },
2121                 { &hf_h264_aspect_ratio_idc,
2122                         { "aspect_ratio_idc",           "h264.aspect_ratio_idc",
2123                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2124                         "aspect_ratio_idc", HFILL }
2125                 },
2126                 { &hf_h264_sar_width,
2127                         { "sar_width",           "h264.sar_width",
2128                         FT_UINT16, BASE_DEC, NULL, 0x0,          
2129                         "sar_width", HFILL }
2130                 },
2131                 { &hf_h264_sar_height,
2132                         { "sar_height",           "h264.sar_height",
2133                         FT_UINT16, BASE_DEC, NULL, 0x0,          
2134                         "sar_height", HFILL }
2135                 },
2136                 { &hf_h264_overscan_info_present_flag,
2137                         { "overscan_info_present_flag",           "h264.overscan_info_present_flag",
2138                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2139                         "overscan_info_present_flag", HFILL }
2140                 },
2141                 { &hf_h264_overscan_appropriate_flag,
2142                         { "overscan_appropriate_flag",           "h264.overscan_appropriate_flag",
2143                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2144                         "overscan_appropriate_flag", HFILL }
2145                 },
2146                 { &hf_h264_video_signal_type_present_flag,
2147                         { "video_signal_type_present_flag",           "h264.video_signal_type_present_flag",
2148                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2149                         "video_signal_type_present_flag", HFILL }
2150                 },
2151                 { &hf_h264_video_format,
2152                         { "video_format",           "h264.video_format",
2153                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2154                         "video_format", HFILL }
2155                 },
2156                 { &hf_h264_video_full_range_flag,
2157                         { "video_full_range_flag",           "h264.video_full_range_flag",
2158                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2159                         "video_full_range_flag", HFILL }
2160                 },
2161                 { &hf_h264_colour_description_present_flag,
2162                         { "colour_description_present_flag",           "h264.colour_description_present_flag",
2163                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2164                         "colour_description_present_flag", HFILL }
2165                 },
2166                 { &hf_h264_colour_primaries,
2167                         { "colour_primaries",           "h264.colour_primaries",
2168                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2169                         "colour_primaries", HFILL }
2170                 },
2171                 { &hf_h264_transfer_characteristics,
2172                         { "transfer_characteristics",           "h264.transfer_characteristics",
2173                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2174                         "transfer_characteristics", HFILL }
2175                 },
2176                 { &hf_h264_matrix_coefficients,
2177                         { "matrix_coefficients",           "h264.matrix_coefficients",
2178                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2179                         "matrix_coefficients", HFILL }
2180                 },
2181                 { &hf_h264_chroma_loc_info_present_flag,
2182                         { "chroma_loc_info_present_flag",           "h264.chroma_loc_info_present_flag",
2183                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2184                         "chroma_loc_info_present_flag", HFILL }
2185                 },
2186                 { &hf_h264_chroma_sample_loc_type_top_field,
2187                         { "chroma_sample_loc_type_top_field",           "h264.chroma_sample_loc_type_top_field",
2188                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2189                         "chroma_sample_loc_type_top_field", HFILL }
2190                 },
2191                 { &hf_h264_chroma_sample_loc_type_bottom_field,
2192                         { "chroma_sample_loc_type_bottom_field",           "h264.chroma_sample_loc_type_bottom_field",
2193                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2194                         "chroma_sample_loc_type_bottom_field", HFILL }
2195                 },
2196                 { &hf_h264_timing_info_present_flag,
2197                         { "timing_info_present_flag",           "h264.timing_info_present_flag",
2198                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2199                         "timing_info_present_flag", HFILL }
2200                 },
2201                 { &hf_h264_num_units_in_tick,
2202                         { "num_units_in_tick",           "h264.num_units_in_tick",
2203                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2204                         "num_units_in_tick", HFILL }
2205                 },
2206                 { &hf_h264_time_scale,
2207                         { "time_scale",           "h264.time_scale",
2208                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2209                         "time_scale", HFILL }
2210                 },
2211                 { &hf_h264_fixed_frame_rate_flag,
2212                         { "fixed_frame_rate_flag",           "h264.fixed_frame_rate_flag",
2213                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2214                         "fixed_frame_rate_flag", HFILL }
2215                 },
2216                 { &hf_h264_nal_hrd_parameters_present_flag,
2217                         { "nal_hrd_parameters_present_flag",           "h264.nal_hrd_parameters_present_flag",
2218                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2219                         "nal_hrd_parameters_present_flag", HFILL }
2220                 },
2221                 { &hf_h264_vcl_hrd_parameters_present_flag,
2222                         { "vcl_hrd_parameters_present_flag",           "h264.vcl_hrd_parameters_present_flag",
2223                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2224                         "vcl_hrd_parameters_present_flag", HFILL }
2225                 },
2226                 { &hf_h264_low_delay_hrd_flag,
2227                         { "low_delay_hrd_flag",           "h264.low_delay_hrd_flag",
2228                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2229                         "low_delay_hrd_flag", HFILL }
2230                 },
2231                 { &hf_h264_pic_struct_present_flag,
2232                         { "pic_struct_present_flag",           "h264.pic_struct_present_flag",
2233                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2234                         "pic_struct_present_flag", HFILL }
2235                 },
2236                 { &hf_h264_bitstream_restriction_flag,
2237                         { "bitstream_restriction_flag",           "h264.bitstream_restriction_flag",
2238                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2239                         "bitstream_restriction_flag", HFILL }
2240                 },
2241                 { &hf_h264_motion_vectors_over_pic_boundaries_flag,
2242                         { "motion_vectors_over_pic_boundaries_flag",           "h264.motion_vectors_over_pic_boundaries_flag",
2243                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2244                         "motion_vectors_over_pic_boundaries_flag", HFILL }
2245                 },
2246                 { &hf_h264_max_bytes_per_pic_denom,
2247                         { "max_bytes_per_pic_denom",           "h264.max_bytes_per_pic_denom",
2248                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2249                         "max_bytes_per_pic_denom", HFILL }
2250                 },
2251                 { &hf_h264_max_bits_per_mb_denom,
2252                         { "max_bits_per_mb_denom",           "h264.max_bits_per_mb_denom",
2253                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2254                         "max_bits_per_mb_denom", HFILL }
2255                 },
2256                 { &hf_h264_log2_max_mv_length_horizontal,
2257                         { "max_mv_length_horizontal",           "h264.max_mv_length_horizontal",
2258                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2259                         "max_mv_length_horizontal", HFILL }
2260                 },
2261                 { &hf_h264_log2_max_mv_length_vertical,
2262                         { "log2_max_mv_length_vertical",           "h264.log2_max_mv_length_vertical",
2263                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2264                         "log2_max_mv_length_vertical", HFILL }
2265                 },
2266                 { &hf_h264_num_reorder_frames,
2267                         { "num_reorder_frames",           "h264.num_reorder_frames",
2268                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2269                         "num_reorder_frames", HFILL }
2270                 },
2271                 { &hf_h264_max_dec_frame_buffering,
2272                         { "max_dec_frame_buffering",           "h264.max_dec_frame_buffering",
2273                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2274                         "max_dec_frame_buffering", HFILL }
2275                 },
2276                 { &hf_h264_cpb_cnt_minus1,
2277                         { "cpb_cnt_minus1",           "h264.cpb_cnt_minus1",
2278                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2279                         "cpb_cnt_minus1", HFILL }
2280                 },
2281                 { &hf_h264_bit_rate_scale,
2282                         { "bit_rate_scale",           "h264.bit_rate_scale",
2283                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2284                         "bit_rate_scale", HFILL }
2285                 },
2286                 { &hf_h264_cpb_size_scale,
2287                         { "cpb_size_scale",           "h264.cpb_size_scale",
2288                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2289                         "cpb_size_scale", HFILL }
2290                 },
2291                 { &hf_h264_bit_rate_value_minus1,
2292                         { "bit_rate_value_minus1",           "h264.bit_rate_value_minus1",
2293                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2294                         "bit_rate_value_minus1", HFILL }
2295                 },
2296                 { &hf_h264_cpb_size_value_minus1,
2297                         { "cpb_size_value_minus1",           "h264.cpb_size_value_minus1",
2298                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2299                         "cpb_size_value_minus1", HFILL }
2300                 },
2301                 { &hf_h264_cbr_flag,
2302                         { "cbr_flag",           "h264.cbr_flag",
2303                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2304                         "cbr_flag", HFILL }
2305                 },
2306                 { &hf_h264_initial_cpb_removal_delay_length_minus1,
2307                         { "initial_cpb_removal_delay_length_minus1",           "h264.initial_cpb_removal_delay_length_minus1",
2308                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2309                         "initial_cpb_removal_delay_length_minus1", HFILL }
2310                 },
2311                 { &hf_h264_cpb_removal_delay_length_minus1,
2312                         { "cpb_removal_delay_length_minus1",           "h264.cpb_removal_delay_length_minus1",
2313                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2314                         "cpb_removal_delay_length_minus1", HFILL }
2315                 },
2316                 { &hf_h264_dpb_output_delay_length_minus11,
2317                         { "dpb_output_delay_length_minus11",           "h264.dpb_output_delay_length_minus11",
2318                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2319                         "dpb_output_delay_length_minus11", HFILL }
2320                 },
2321                 { &hf_h264_time_offset_length,
2322                         { "time_offset_length",           "h264.time_offset_length",
2323                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2324                         "time_offset_length", HFILL }
2325                 },
2326                 { &hf_h264_first_mb_in_slice,
2327                         { "first_mb_in_slice",           "h264.first_mb_in_slice",
2328                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2329                         "first_mb_in_slice", HFILL }
2330                 },
2331                 { &hf_h264_slice_type,
2332                         { "slice_type",           "h264.slice_type",
2333                         FT_UINT32, BASE_DEC, VALS(h264_slice_type_vals), 0x0,          
2334                         "slice_type", HFILL }
2335                 },
2336                 { &hf_h264_slice_id,
2337                         { "slice_id",           "h264.slice_id",
2338                         FT_UINT32, BASE_DEC, NULL, 0x0,          
2339                         "slice_id", HFILL }
2340                 },
2341                 { &hf_h264_frame_num,
2342                         { "frame_num",           "h264.frame_num",
2343                         FT_UINT8, BASE_DEC, NULL, 0x0,          
2344                         "frame_num", HFILL }
2345                 },
2346
2347     { &hf_h264_par_profile,
2348       { "Profile", "h264.profile",
2349         FT_UINT8, BASE_HEX, NULL, 0x00,
2350         NULL, HFILL}},
2351     { &hf_h264_par_profile_b,
2352       { "Baseline Profile", "h264.profile.base",
2353         FT_BOOLEAN, 8, NULL, 0x40,
2354         NULL, HFILL}},
2355     { &hf_h264_par_profile_m,
2356       { "Main Profile", "h264.profile.main",
2357         FT_BOOLEAN, 8, NULL, 0x20,
2358         NULL, HFILL}},
2359     { &hf_h264_par_profile_e,
2360       { "Extended Profile.", "h264.profile.ext",
2361         FT_BOOLEAN, 8, NULL, 0x10,
2362         NULL, HFILL}},
2363     { &hf_h264_par_profile_h,
2364       { "High Profile", "h264.profile.high",
2365         FT_BOOLEAN, 8, NULL, 0x08,
2366         NULL, HFILL}},
2367     { &hf_h264_par_profile_h10,
2368       { "High 10 Profile", "h264.profile.high10",
2369         FT_BOOLEAN, 8, NULL, 0x04,
2370         NULL, HFILL}},
2371     { &hf_h264_par_profile_h4_2_2,
2372       { "High 4:2:2 Profile", "h264.profile.high4_2_2",
2373         FT_BOOLEAN, 8, NULL, 0x02,
2374         NULL, HFILL}},
2375     { &hf_h264_par_profile_h4_4_4,
2376       { "High 4:4:4 Profile", "h264.profile.high4_4_4",
2377         FT_BOOLEAN, 8, NULL, 0x01,
2378         NULL, HFILL}},
2379         { &hf_h264_par_AdditionalModesSupported,
2380       { "AdditionalModesSupported", "h264.AdditionalModesSupported",
2381         FT_UINT8, BASE_HEX, NULL, 0x00,
2382         NULL, HFILL}},
2383         { &hf_h264_par_add_mode_sup,
2384       { "Additional Modes Supported", "h264.add_mode_sup",
2385         FT_UINT8, BASE_HEX, NULL, 0x00,
2386         NULL, HFILL}},
2387         { &hf_h264_par_add_mode_sup_rcdo,
2388       { "Reduced Complexity Decoding Operation (RCDO) support", "h264.add_mode_sup.rcdo",
2389         FT_BOOLEAN, 8, NULL, 0x40,
2390         NULL, HFILL}},
2391         { &hf_h264_par_ProfileIOP,
2392       { "ProfileIOP", "h264.ProfileIOP",
2393         FT_UINT8, BASE_HEX, NULL, 0x00,
2394         NULL, HFILL}},
2395         { &hf_h264_par_constraint_set0_flag,
2396       { "constraint_set0_flag", "h264.par.constraint_set0_flag",
2397         FT_BOOLEAN, 8, NULL, 0x80,
2398         NULL, HFILL}},
2399         { &hf_h264_par_constraint_set1_flag,
2400       { "constraint_set1_flag", "h264.par.constraint_set1_flag",
2401         FT_BOOLEAN, 8, NULL, 0x40,
2402         NULL, HFILL}},
2403         { &hf_h264_par_constraint_set2_flag,
2404       { "constraint_set2_flag", "h264.par.constraint_set2_flag",
2405         FT_BOOLEAN, 8, NULL, 0x20,
2406         NULL, HFILL}},
2407         };
2408
2409 /* Setup protocol subtree array */
2410         static gint *ett[] = {
2411                 &ett_h264,
2412                 &ett_h264_profile,
2413                 &ett_h264_nal,
2414                 &ett_h264_stream,
2415                 &ett_h264_nal_unit,
2416                 &ett_h264_par_profile,
2417                 &ett_h264_par_AdditionalModesSupported,
2418                 &ett_h264_par_ProfileIOP,
2419         };
2420
2421 /* Register the protocol name and description */
2422         proto_h264 = proto_register_protocol("H.264","H264", "h264");
2423
2424 /* Required function calls to register the header fields and subtrees used */
2425         proto_register_field_array(proto_h264, hf, array_length(hf));
2426         proto_register_subtree_array(ett, array_length(ett));
2427         /* Register a configuration option for port */
2428
2429         
2430         h264_module = prefs_register_protocol(proto_h264, proto_reg_handoff_h264);
2431
2432         prefs_register_uint_preference(h264_module, "dynamic.payload.type",
2433                                                                    "H264 dynamic payload type",
2434                                                                    "The dynamic payload type which will be interpreted as H264",
2435                                                                    10,
2436                                                                    &temp_dynamic_payload_type);
2437
2438         
2439         register_dissector("h264", dissect_h264, proto_h264);
2440 }
2441
2442