2 * Routines for H.264 dissection
3 * Copyright 2007 - 2009, Anders Broman <anders.broman[at]ericsson.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * http://www.ietf.org/rfc/rfc3984.txt?number=3984 Obsolete
25 * http://www.ietf.org/rfc/rfc6184.txt?number=6184
26 * http://www.ietf.org/rfc/rfc6190.txt?number=6190
27 * http://www.itu.int/rec/T-REC-H.264/en
28 * MS-H264PF http://msdn.microsoft.com/en-us/library/hh659565.aspx
37 #include <epan/packet.h>
38 #include <epan/asn1.h>
39 #include <epan/strutil.h>
40 #include <epan/expert.h>
41 #include <epan/prefs.h>
42 #include <epan/wmem/wmem.h>
44 #include "packet-h264.h"
46 void proto_register_h264(void);
47 void proto_reg_handoff_h264(void);
49 /* Initialize the protocol and registered fields */
50 static int proto_h264 = -1;
51 static int hf_h264_type = -1;
52 static int hf_h264_nal_f_bit = -1;
53 static int hf_h264_nal_nri = -1;
54 static int hf_h264_start_bit = -1;
55 static int hf_h264_forbidden_bit = -1;
56 static int hf_h264_end_bit = -1;
57 static int hf_h264_profile = -1;
58 static int hf_h264_profile_idc = -1;
59 static int hf_h264_rbsp_stop_bit = -1;
60 static int hf_h264_rbsp_trailing_bits = -1;
61 static int hf_h264_constraint_set0_flag = -1;
62 static int hf_h264_constraint_set1_flag = -1;
63 static int hf_h264_constraint_set2_flag = -1;
64 static int hf_h264_constraint_set3_flag = -1;
65 static int hf_h264_constraint_set4_flag = -1;
66 static int hf_h264_constraint_set5_flag = -1;
67 static int hf_h264_reserved_zero_2bits = -1;
68 static int hf_h264_level_idc = -1;
69 static int hf_h264_nal_unit = -1;
70 static int hf_h264_forbidden_zero_bit = -1;
71 static int hf_h264_nal_ref_idc = -1;
72 static int hf_h264_nal_unit_type = -1;
73 static int hf_h264_seq_parameter_set_id = -1;
74 static int hf_h264_chroma_format_idc = -1;
75 static int hf_h264_residual_colour_transform_flag = -1;
76 static int hf_h264_bit_depth_luma_minus8 = -1;
77 static int hf_h264_bit_depth_chroma_minus8 = -1;
78 static int hf_h264_qpprime_y_zero_transform_bypass_flag = -1;
79 static int hf_h264_seq_scaling_matrix_present_flag = -1;
80 static int hf_h264_log2_max_frame_num_minus4 = -1;
81 static int hf_h264_pic_order_cnt_type = -1;
82 static int hf_h264_log2_max_pic_order_cnt_lsb_minus4 = -1;
83 static int hf_h264_delta_pic_order_always_zero_flag = -1;
84 static int hf_h264_offset_for_non_ref_pic = -1;
85 static int hf_h264_offset_for_top_to_bottom_field = -1;
86 static int hf_h264_num_ref_frames_in_pic_order_cnt_cycle = -1;
87 static int hf_h264_offset_for_ref_frame = -1;
88 static int hf_h264_num_ref_frames = -1;
89 static int hf_h264_gaps_in_frame_num_value_allowed_flag = -1;
90 static int hf_h264_pic_width_in_mbs_minus1 = -1;
91 static int hf_h264_pic_height_in_map_units_minus1 = -1;
92 static int hf_h264_frame_mbs_only_flag = -1;
93 static int hf_h264_mb_adaptive_frame_field_flag = -1;
94 static int hf_h264_direct_8x8_inference_flag = -1;
95 static int hf_h264_frame_cropping_flag = -1;
96 static int hf_h264_frame_crop_left_offset = -1;
97 static int hf_h264_frame_crop_right_offset = -1;
98 static int hf_h264_frame_crop_top_offset = -1;
99 static int hf_h264_frame_crop_bottom_offset = -1;
100 static int hf_h264_vui_parameters_present_flag = -1;
101 static int hf_h264_pic_parameter_set_id = -1;
102 static int hf_h264_entropy_coding_mode_flag = -1;
103 static int hf_h264_pic_order_present_flag = -1;
104 static int hf_h264_num_slice_groups_minus1 = -1;
105 static int hf_h264_slice_group_map_type = -1;
106 static int hf_h264_num_ref_idx_l0_active_minus1 = -1;
107 static int hf_h264_num_ref_idx_l1_active_minus1 = -1;
108 static int hf_h264_weighted_pred_flag = -1;
109 static int hf_h264_weighted_bipred_idc = -1;
110 static int hf_h264_pic_init_qp_minus26 = -1;
111 static int hf_h264_pic_init_qs_minus26 = -1;
112 static int hf_h264_chroma_qp_index_offset = -1;
113 static int hf_h264_deblocking_filter_control_present_flag = -1;
114 static int hf_h264_constrained_intra_pred_flag = -1;
115 static int hf_h264_redundant_pic_cnt_present_flag = -1;
116 static int hf_h264_transform_8x8_mode_flag = -1;
117 static int hf_h264_pic_scaling_matrix_present_flag = -1;
118 static int hf_h264_second_chroma_qp_index_offset = -1;
119 static int hf_h264_par_profile = -1;
120 static int hf_h264_par_profile_b = -1;
121 static int hf_h264_par_profile_m = -1;
122 static int hf_h264_par_profile_e = -1;
123 static int hf_h264_par_profile_h = -1;
124 static int hf_h264_par_profile_h10 = -1;
125 static int hf_h264_par_profile_h4_2_2 = -1;
126 static int hf_h264_par_profile_h4_4_4 = -1;
127 /* static int hf_h264_par_add_mode_sup = -1; */
128 static int hf_h264_par_AdditionalModesSupported = -1;
129 static int hf_h264_par_add_mode_sup_rcdo = -1;
130 static int hf_h264_par_ProfileIOP = -1;
131 static int hf_h264_par_constraint_set0_flag = -1;
132 static int hf_h264_par_constraint_set1_flag = -1;
133 static int hf_h264_par_constraint_set2_flag = -1;
134 /* Packetization Values */
135 static int hf_h264_nalu_size = -1;
136 static int hf_h264_don = -1;
137 static int hf_h264_dond = -1;
138 static int hf_h264_ts_offset16 = -1;
139 static int hf_h264_ts_offset24 = -1;
140 /* Extension Header */
141 static int hf_h264_nal_extension_subtype = -1;
142 static int hf_h264_nal_extension_j = -1;
143 static int hf_h264_nal_extension_k = -1;
144 static int hf_h264_nal_extension_l = -1;
146 /* SEI Decoding Information */
147 static int hf_h264_sei_uuid = -1;
148 /* Microsoft Layout SEI */
149 static int hf_h264_sei_ms_lpb = -1;
150 static int hf_h264_sei_ms_layout_p = -1;
151 static int hf_h264_sei_ms_layout_ldsize = -1;
152 static int hf_h264_sei_ms_layer_desc_coded_width = -1;
153 static int hf_h264_sei_ms_layer_desc_coded_height = -1;
154 static int hf_h264_sei_ms_layer_desc_display_width = -1;
155 static int hf_h264_sei_ms_layer_desc_display_height = -1;
156 static int hf_h264_sei_ms_layer_desc_bitrate = -1;
157 static int hf_h264_sei_ms_layer_desc_frame_rate = -1;
158 static int hf_h264_sei_ms_layer_desc_layer_type = -1;
159 static int hf_h264_sei_ms_layer_desc_prid = -1;
160 static int hf_h264_sei_ms_layer_desc_cb = -1;
161 /* Microsoft Bitstream SEI */
162 static int hf_h264_sei_ms_bitstream_ref_frame_cnt = -1;
163 static int hf_h264_sei_ms_bitstream_num_nalus = -1;
164 /* Microsoft Crop SEI */
165 static int hf_h264_sei_ms_crop_num_data = -1;
166 static int hf_h264_sei_ms_crop_info_type = -1;
167 static int hf_h264_sei_ms_crop_confidence_level = -1;
168 static int hf_h264_sei_ms_crop_frame_left_offset = -1;
169 static int hf_h264_sei_ms_crop_frame_right_offset = -1;
170 static int hf_h264_sei_ms_crop_frame_top_offset = -1;
171 static int hf_h264_sei_ms_crop_frame_bottom_offset = -1;
172 /* SVC NAL Header Extension Values Annex G.7.3.1.1 */
173 static int hf_h264_nal_hdr_ext_svc = -1;
174 static int hf_h264_nal_hdr_ext_i = -1;
175 static int hf_h264_nal_hdr_ext_prid = -1;
176 static int hf_h264_nal_hdr_ext_n = -1;
177 static int hf_h264_nal_hdr_ext_did = -1;
178 static int hf_h264_nal_hdr_ext_qid = -1;
179 static int hf_h264_nal_hdr_ext_tid = -1;
180 static int hf_h264_nal_hdr_ext_u = -1;
181 static int hf_h264_nal_hdr_ext_d = -1;
182 static int hf_h264_nal_hdr_ext_o = -1;
183 static int hf_h264_nal_hdr_ext_rr = -1;
185 static int hf_h264_pacsi_x = -1;
186 static int hf_h264_pacsi_y = -1;
187 static int hf_h264_pacsi_t = -1;
188 static int hf_h264_pacsi_a = -1;
189 static int hf_h264_pacsi_p = -1;
190 static int hf_h264_pacsi_c = -1;
191 static int hf_h264_pacsi_s = -1;
192 static int hf_h264_pacsi_e = -1;
193 static int hf_h264_pacsi_tl0picidx = -1;
194 static int hf_h264_pacsi_idrpicid = -1;
195 static int hf_h264_pacsi_donc = -1;
198 static int hf_h264_aspect_ratio_info_present_flag = -1;
199 static int hf_h264_aspect_ratio_idc = -1;
200 static int hf_h264_sar_width = -1;
201 static int hf_h264_sar_height = -1;
202 static int hf_h264_overscan_info_present_flag = -1;
203 static int hf_h264_overscan_appropriate_flag = -1;
204 static int hf_h264_video_signal_type_present_flag = -1;
205 static int hf_h264_video_format = -1;
206 static int hf_h264_video_full_range_flag = -1;
207 static int hf_h264_colour_description_present_flag = -1;
208 static int hf_h264_colour_primaries = -1;
209 static int hf_h264_transfer_characteristics = -1;
210 static int hf_h264_matrix_coefficients = -1;
211 static int hf_h264_chroma_loc_info_present_flag = -1;
212 static int hf_h264_chroma_sample_loc_type_top_field = -1;
213 static int hf_h264_chroma_sample_loc_type_bottom_field = -1;
214 static int hf_h264_timing_info_present_flag = -1;
215 static int hf_h264_num_units_in_tick = -1;
216 static int hf_h264_time_scale = -1;
217 static int hf_h264_fixed_frame_rate_flag = -1;
218 static int hf_h264_nal_hrd_parameters_present_flag = -1;
219 static int hf_h264_vcl_hrd_parameters_present_flag = -1;
220 static int hf_h264_low_delay_hrd_flag = -1;
221 static int hf_h264_pic_struct_present_flag = -1;
222 static int hf_h264_bitstream_restriction_flag = -1;
223 static int hf_h264_motion_vectors_over_pic_boundaries_flag = -1;
224 static int hf_h264_max_bytes_per_pic_denom = -1;
225 static int hf_h264_max_bits_per_mb_denom = -1;
226 static int hf_h264_log2_max_mv_length_horizontal = -1;
227 static int hf_h264_log2_max_mv_length_vertical = -1;
228 static int hf_h264_num_reorder_frames = -1;
229 static int hf_h264_max_dec_frame_buffering = -1;
230 static int hf_h264_cpb_cnt_minus1 = -1;
231 static int hf_h264_bit_rate_scale = -1;
232 static int hf_h264_cpb_size_scale = -1;
233 static int hf_h264_bit_rate_value_minus1 = -1;
234 static int hf_h264_cpb_size_value_minus1 = -1;
235 static int hf_h264_cbr_flag = -1;
236 static int hf_h264_initial_cpb_removal_delay_length_minus1 = -1;
237 static int hf_h264_cpb_removal_delay_length_minus1 = -1;
238 static int hf_h264_dpb_output_delay_length_minus11 = -1;
239 static int hf_h264_time_offset_length = -1;
241 static int hf_h264_first_mb_in_slice = -1;
242 static int hf_h264_slice_type = -1;
243 static int hf_h264_slice_id = -1;
244 static int hf_h264_payloadsize = -1;
245 static int hf_h264_payloadtype = -1;
246 /* static int hf_h264_frame_num = -1; */
248 /* Initialize the subtree pointers */
249 static int ett_h264 = -1;
250 static int ett_h264_profile = -1;
251 static int ett_h264_nal = -1;
252 static int ett_h264_fua = -1;
253 static int ett_h264_stream = -1;
254 static int ett_h264_nal_unit = -1;
255 static int ett_h264_par_profile = -1;
256 static int ett_h264_par_AdditionalModesSupported = -1;
257 static int ett_h264_par_ProfileIOP = -1;
258 static int ett_h264_ms_layer_description = -1;
259 static int ett_h264_ms_crop_data = -1;
261 static expert_field ei_h264_undecoded = EI_INIT;
262 static expert_field ei_h264_ms_layout_wrong_length = EI_INIT;
263 static expert_field ei_h264_bad_nal_length = EI_INIT;
265 /* The dynamic payload type range which will be dissected as H.264 */
267 #define RTP_PT_DEFAULT_RANGE "0"
268 static range_t *temp_dynamic_payload_type_range = NULL;
270 static dissector_handle_t h264_handle;
272 /* syntax tables in subclause 7.3 is equal to
273 * ue(v), me(v), se(v), or te(v).
280 } h264_golomb_descriptors;
283 static const true_false_string h264_f_bit_vals = {
284 "Bit errors or other syntax violations",
285 "No bit errors or other syntax violations"
288 static const true_false_string h264_start_bit_vals = {
289 "the first packet of FU-A picture",
290 "Not the first packet of FU-A picture"
293 static const true_false_string h264_end_bit_vals = {
294 "the last packet of FU-A picture",
295 "Not the last packet of FU-A picture"
299 static const true_false_string h264_forbidden_bit_vals = {
300 "Forbidden Bit of FU-A",
301 "Not Forbidden Bit of FU-A"
305 #define H264_SEQ_PAR_SET 7
306 #define H264_PIC_PAR_SET 8
307 #define H264_PREFIX 14
308 #define H264_STAP_A 24
309 #define H264_STAP_B 25
310 #define H264_MTAP16 26
311 #define H264_MTAP24 27
312 #define H264_PACSI 30
313 #define H264_EXTENSION 31
316 static const value_string h264_type_values[] = {
318 { 1, "NAL unit - Coded slice of a non-IDR picture" }, /* Single NAL unit packet per H.264 */
319 { 2, "NAL unit - Coded slice data partition A" },
320 { 3, "NAL unit - Coded slice data partition B" },
321 { 4, "NAL unit - Coded slice data partition C" },
322 { 5, "NAL unit - Coded slice of an IDR picture" },
323 { 6, "NAL unit - Supplemental enhancement information (SEI)" },
324 { H264_SEQ_PAR_SET, "NAL unit - Sequence parameter set" }, /* 7 */
325 { H264_PIC_PAR_SET, "NAL unit - Picture parameter set" }, /* 8 */
326 { 9, "NAL unit - Access unit delimiter" },
327 { 10, "NAL unit - End of sequence" },
328 { 11, "NAL unit - End of stream" },
329 { 12, "NAL unit - Filler data" },
330 { 13, "NAL unit - Sequence parameter set extension" },
331 { H264_PREFIX, "NAL unit - Prefix" },
332 { 15, "NAL unit - Subset sequence parameter set" },
333 { 16, "NAL unit - Reserved" },
334 { 17, "NAL unit - Reserved" },
335 { 18, "NAL unit - Reserved" },
336 { 19, "NAL unit - Coded slice of an auxiliary coded picture without partitioning" },
337 { 20, "NAL unit - Coded slice extension" },
338 { 21, "NAL unit - Coded slice extension for depth view components" },
339 { 22, "NAL unit - Reserved" },
340 { 23, "NAL unit - Reserved" },
341 { 24, "Single-time aggregation packet A (STAP-A)" },
342 { 25, "Single-time aggregation packet B (STAP-B)" },
343 { 26, "Multi-time aggregation packet 16 (MTAP16)" },
344 { 27, "Multi-time aggregation packet 24 (MTAP24)" },
345 { 28, "Fragmentation unit A (FU-A)" },
346 { 29, "Fragmentation unit B (FU-B)" },
347 { 30, "NAL unit - Payload Content Scalability Information (PACSI)" },
348 { 31, "NAL unit - Extended NAL Header" },
352 static const value_string h264_type_summary_values[] = {
354 { 1, "non-IDR-Slice" }, /* Single NAL unit packet per H.264 */
360 { H264_SEQ_PAR_SET, "SPS" }, /* 7 */
361 { H264_PIC_PAR_SET, "PPS" }, /* 8 */
362 { 9, "Access-Delimiter" },
363 { 10, "End-of-Seq" },
364 { 11, "End-of-Stream" },
367 { H264_PREFIX, "Prefix" },
374 { 21, "Slice-Ext-Depth" },
388 /* Extension Subtype Strings RFC 6190 4.3 */
389 static const value_string h264_subtype_values[] = {
391 { 1, "NAL Unit - Empty" },
392 { 2, "Non-interleaved Multi-Time Aggregation Packet (NI-MTAP)" },
395 static const value_string h264_subtype_summary_values[] = {
403 static const value_string h264_profile_idc_values[] = {
404 { 66, "Baseline profile" },
405 { 77, "Main profile" },
406 { 83, "Scalable Baseline" },
407 { 86, "Scalable High" },
408 { 88, "Extended profile" },
409 { 100, "High profile" },
410 { 110, "High 10 profile" },
411 { 118, "Multi-view High" },
412 { 122, "High 4:2:2 profile" },
413 { 128, "Stereo High" },
414 { 144, "High 4:4:4 profile" },
418 /* Table A-1 - Level limits */
419 static const value_string h264_level_bitrate_values[] = {
439 static const value_string h264_nal_unit_type_vals[] = {
440 { 0, "Unspecified" },
441 { 1, "Coded slice of a non-IDR picture" },
442 { 2, "Coded slice data partition A" },
443 { 3, "Coded slice data partition B" },
444 { 4, "Coded slice data partition C" },
445 { 5, "Coded slice of an IDR picture" },
446 { 6, "Supplemental enhancement information (SEI)" },
447 { 7, "Sequence parameter set" },
448 { 8, "Picture parameter set" },
449 { 9, "Access unit delimiter" },
450 { 10, "End of sequence" },
451 { 11, "End of stream" },
452 { 12, "Filler data" },
453 { 13, "Sequence parameter set extension" },
455 { 15, "Subset sequence parameter set" },
459 { 19, "Coded slice of an auxiliary coded picture without partitioning" },
460 { 20, "Coded slice extension" },
461 { 21, "Coded slice extension for depth view components" },
464 { 24, "Unspecified" },
465 { 25, "Unspecified" },
466 { 26, "Unspecified" },
467 { 27, "Unspecified" },
469 { 29, "Unspecified" },
470 { 30, "Unspecified" },
471 { 31, "Unspecified" },
475 static const value_string h264_slice_group_map_type_vals[] = {
476 { 0, "Interleaved slice groups" },
477 { 1, "Dispersed slice group mapping" },
478 { 2, "One or more foreground slice groups and a leftover slice group" },
479 { 3, "Changing slice groups" },
480 { 4, "Changing slice groups" },
481 { 5, "Changing slice groups" },
482 { 6, "Explicit assignment of a slice group to each slice group map unit" },
486 /* Table 7-6 Name association to slice_type */
487 static const value_string h264_slice_type_vals[] = {
488 { 0, "P (P slice)" },
489 { 1, "B (B slice)" },
490 { 2, "I (I slice)" },
491 { 3, "SP (SP slice)" },
492 { 4, "SI (SI slice)" },
493 { 5, "P (P slice)" },
494 { 6, "B (B slice)" },
495 { 7, "I (I slice)" },
496 { 8, "SP (SP slice)" },
497 { 9, "SI (SI slice)" },
501 /* Microsoft Frame per second index */
502 static const value_string h264_sei_ms_frame_values[] = {
513 /* Microsoft UUIDs from MS-H264-PF */
515 #define MS_CROPPING 1
516 #define MS_BITSTREAM 2
517 static const e_guid_t ms_guids[3] = {
518 { 0x139FB1A9, 0x446A, 0x4DEC, {0x8C, 0xBF, 0x65, 0xB1, 0xE1, 0x2D, 0x2C, 0xFD}}, /* Stream Layout */
519 { 0xBB7FC1A0, 0x6986, 0x4052, {0x90, 0xF0, 0x09, 0x29, 0x21, 0x75, 0x39, 0xCF}}, /* Cropping Information*/
520 { 0x05FBC6B9, 0x5A80, 0x40E5, {0xA2, 0x2A, 0xAB, 0x40, 0x20, 0x26, 0x7E, 0x26}} /* Bitstream Information */
524 dissect_h264(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
526 /* byte_aligned( ) is specified as follows.
527 * - If the current position in the bitstream is on a byte boundary, i.e.,
528 * the next bit in the bitstream is the first bit in a byte,
529 * the return value of byte_aligned( ) is equal to TRUE.
530 * - Otherwise, the return value of byte_aligned( ) is equal to FALSE.
533 h264_byte_aligned(int bit_offset)
541 /* Expect a tvb and a bit offset into the tvb
542 * returns the value and bit_offset
544 #define cVALS(x) (const value_string*)(x)
547 dissect_h264_exp_golomb_code(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint *start_bit_offset, h264_golomb_descriptors descriptor)
548 /*(tvbuff_t *tvb, gint *start_bit_offset) */
550 gint leading_zero_bits, bit_offset, start_offset;
551 guint32 codenum, mask, value, tmp;
557 header_field_info *hf_field = NULL;
559 start_offset = *start_bit_offset>>3;
562 hf_field = proto_registrar_get_nth(hf_index);
564 bit_offset = *start_bit_offset;
566 /* prepare the string */
567 str = (char *)wmem_alloc(wmem_packet_scope(), 256);
569 for (bit=0; bit<((int)(bit_offset&0x07)); bit++) {
570 if (bit && (!(bit%4))) {
571 g_strlcat(str, " ", 256);
573 g_strlcat(str,".", 256);
577 leading_zero_bits = -1;
578 for (b = 0; !b; leading_zero_bits++) {
579 if (bit && (!(bit%4))) {
580 g_strlcat(str, " ", 256);
582 if (bit && (!(bit%8))) {
583 g_strlcat(str, " ", 256);
585 b = tvb_get_bits8(tvb, bit_offset, 1);
587 g_strlcat(str, "1", 256);
589 g_strlcat(str, "0", 256);
595 if (leading_zero_bits == 0) {
597 *start_bit_offset = bit_offset;
598 for (; bit%8; bit++) {
599 if (bit && (!(bit%4))) {
600 g_strlcat(str, " ", 256);
602 g_strlcat(str,".", 256);
605 g_strlcat(str," = ", 256);
606 g_strlcat(str, hf_field->name, 256);
607 switch (descriptor) {
609 /* if the syntax element is coded as se(v),
610 * the value of the syntax element is derived by invoking the
611 * mapping process for signed Exp-Golomb codes as specified in
612 * subclause 9.1.1 with codeNum as the input.
614 if (hf_field->type == FT_INT32) {
615 if (hf_field->strings) {
616 proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
619 val_to_str_const(codenum, cVALS(hf_field->strings), "Unknown "),
622 switch (hf_field->display) {
624 proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
630 DISSECTOR_ASSERT_NOT_REACHED();
639 if (hf_field->type == FT_UINT32) {
640 if (hf_field->strings) {
641 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
644 val_to_str_const(codenum, cVALS(hf_field->strings), "Unknown "),
647 switch (hf_field->display) {
649 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
655 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
661 DISSECTOR_ASSERT_NOT_REACHED();
666 /* Only allow guint32 */
667 DISSECTOR_ASSERT_NOT_REACHED();
674 Syntax elements coded as ue(v), me(v), or se(v) are Exp-Golomb-coded. Syntax elements coded as te(v) are truncated
675 Exp-Golomb-coded. The parsing process for these syntax elements begins with reading the bits starting at the current
676 location in the bitstream up to and including the first non-zero bit, and counting the number of leading bits that are
677 equal to 0. This process is specified as follows:
678 leadingZeroBits = -1;
679 for (b = 0; !b; leadingZeroBits++)
681 The variable codeNum is then assigned as follows:
682 codeNum = 2leadingZeroBits - 1 + read_bits( leadingZeroBits )
683 where the value returned from read_bits( leadingZeroBits ) is interpreted as a binary representation of an unsigned
684 integer with most significant bit written first.
687 codenum = codenum << leading_zero_bits;
689 if (leading_zero_bits > 32)
690 DISSECTOR_ASSERT_NOT_REACHED();
691 else if (leading_zero_bits > 16)
692 value = tvb_get_bits32(tvb, bit_offset, leading_zero_bits, ENC_BIG_ENDIAN);
693 else if (leading_zero_bits > 8)
694 value = tvb_get_bits16(tvb, bit_offset, leading_zero_bits, ENC_BIG_ENDIAN);
696 value = tvb_get_bits8(tvb, bit_offset, leading_zero_bits);
697 codenum = (codenum-1) + value;
698 bit_offset = bit_offset + leading_zero_bits;
700 /* read the bits for the int */
701 for (i=0; i<leading_zero_bits; i++) {
702 if (bit && (!(bit%4))) {
703 g_strlcat(str, " ", 256);
705 if (bit && (!(bit%8))) {
706 g_strlcat(str, " ", 256);
711 g_strlcat(str, "1", 256);
713 g_strlcat(str, "0", 256);
717 for ( ; bit%8; bit++) {
718 if (bit && (!(bit%4))) {
719 g_strlcat(str, " ", 256);
721 g_strlcat(str,".", 256);
724 switch (descriptor) {
726 /* if the syntax element is coded as se(v),
727 * the value of the syntax element is derived by invoking the
728 * mapping process for signed Exp-Golomb codes as specified in
729 * subclause 9.1.1 with codeNum as the input.
733 se_value = (codenum + 1) >> 1;
734 if (!(se_value & 1)) {
735 se_value = - se_value;
743 g_strlcat(str," = ", 256);
744 g_strlcat(str, hf_field->name, 256);
745 switch (descriptor) {
747 g_strlcat(str,"(se(v))", 256);
748 /* if the syntax element is coded as se(v),
749 * the value of the syntax element is derived by invoking the
750 * mapping process for signed Exp-Golomb codes as specified in
751 * subclause 9.1.1 with codeNum as the input.
757 if ((hf_field->type == FT_UINT32) && (descriptor == H264_UE_V)) {
758 if (hf_field->strings) {
759 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
762 val_to_str_const(codenum, cVALS(hf_field->strings), "Unknown "),
765 switch (hf_field->display) {
767 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
773 proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
779 DISSECTOR_ASSERT_NOT_REACHED();
783 } else if ((hf_field->type == FT_INT32) && (descriptor == H264_SE_V)) {
784 if (hf_field->strings) {
785 proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
788 val_to_str_const(codenum, cVALS(hf_field->strings), "Unknown "),
791 switch (hf_field->display) {
793 proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
799 DISSECTOR_ASSERT_NOT_REACHED();
803 *start_bit_offset = bit_offset;
807 /* Only allow guint32 */
808 DISSECTOR_ASSERT_NOT_REACHED();
812 *start_bit_offset = bit_offset;
816 /* This function is adapted to parsing NAL units from SDP data where the
817 * base64 coding may add extra padding
821 more_rbsp_data(proto_tree *tree _U_, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
824 int remaining_length;
828 /* XXX might not be the best way of doing things but:
829 * Serch from the end of the tvb for the first '1' bit
830 * assuming that it's the RTBSP stop bit
833 /* Set offset to the byte we are treating */
834 offset = bit_offset>>3;
835 remaining_length = tvb_length_remaining(tvb, offset);
836 /* If there is more then 2 bytes left there *should* be more data */
837 if (remaining_length>2) {
840 /* Start from last bit */
841 last_one_bit = (tvb_length(tvb) << 3);
845 b = tvb_get_bits8(tvb, last_one_bit, 1);
848 if (last_one_bit == bit_offset) {
856 dissect_h264_rbsp_trailing_bits(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
858 gint remaining_bits=0;
860 proto_tree_add_bits_item(tree, hf_h264_rbsp_stop_bit, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
863 if ((bit_offset&0x7) != 0) {
864 remaining_bits = 8 - (bit_offset&0x7);
865 proto_tree_add_bits_item(tree, hf_h264_rbsp_trailing_bits, tvb, bit_offset, remaining_bits, ENC_BIG_ENDIAN);
868 return bit_offset+remaining_bits;
872 * 7.3.3 Slice header syntax
874 * XXX Just parse a few bytes
877 dissect_h264_slice_header(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
879 /* first_mb_in_slice 2 ue(v) */
880 dissect_h264_exp_golomb_code(tree, hf_h264_first_mb_in_slice, tvb, &bit_offset, H264_UE_V);
882 /* slice_type 2 ue(v) */
883 dissect_h264_exp_golomb_code(tree, hf_h264_slice_type, tvb, &bit_offset, H264_UE_V);
885 /* pic_parameter_set_id 2 ue(v) */
886 dissect_h264_exp_golomb_code(tree, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
888 /* frame_num 2 u(v) */
890 * represented by log2_max_frame_num_minus4 + 4 bits in
892 * proto_tree_add_bits_item(tree, hf_h264_frame_num, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
898 /* 7.3.2.1.1 Scaling list syntax
900 * scaling_list( scalingList, sizeOfScalingList, useDefaultScalingMatrixFlag )
904 dissect_h264_scaling_list(proto_tree *tree, tvbuff_t *tvb, gint bit_offset, int hf_index_scalinglist,
905 guint8 sizeOfScalingList, int hf_index_usedefaultscalingmatrixflag)
908 guint8 lastScale = 8;
909 guint8 nextScale = 8:
912 for (j = 0; j < sizeOfScalingList; j++) {
913 if (nextScale != 0) {
914 / delta_scale 0 | 1 se(v) /
915 delta_scale = dissect_h264_exp_golomb_code(tree, hf_h264_delta_scale, tvb, &bit_offset);
916 nextScale = ( lastScale + delta_scale + 256 ) % 256;
917 useDefaultScalingMatrixFlag = ( j == 0 && nextScale == 0 );
919 scalingList[ j ] = ( nextScale == 0 ) ? lastScale : nextScale
920 lastScale = scalingList[ j ]
924 /* E.1.2 HRD parameters syntax */
926 dissect_h264_hrd_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
928 guint8 cpb_cnt_minus1;
932 /* cpb_cnt_minus1 0 ue(v) */
933 cpb_cnt_minus1 = dissect_h264_exp_golomb_code(tree, hf_h264_cpb_cnt_minus1, tvb, &bit_offset, H264_UE_V);
935 /* bit_rate_scale 0 u(4) */
936 proto_tree_add_bits_item(tree, hf_h264_bit_rate_scale, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
937 bit_offset = bit_offset + 4;
939 /* cpb_size_scale 0 u(4) */
940 proto_tree_add_bits_item(tree, hf_h264_cpb_size_scale, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
941 bit_offset = bit_offset + 4;
942 /* for (SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++) { */
943 for (SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++) {
945 /* bit_rate_value_minus1[ SchedSelIdx ] 0 ue(v) */
946 dissect_h264_exp_golomb_code(tree, hf_h264_bit_rate_value_minus1, tvb, &bit_offset, H264_UE_V);
948 /* cpb_size_value_minus1[ SchedSelIdx ] 0 ue(v)*/
949 dissect_h264_exp_golomb_code(tree, hf_h264_cpb_size_value_minus1, tvb, &bit_offset, H264_UE_V);
951 /* cbr_flag[ SchedSelIdx ] 0 u(1) */
952 proto_tree_add_bits_item(tree, hf_h264_cbr_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
955 /* initial_cpb_removal_delay_length_minus1 0 u(5) */
956 proto_tree_add_bits_item(tree, hf_h264_initial_cpb_removal_delay_length_minus1, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
957 bit_offset = bit_offset + 5;
959 /* cpb_removal_delay_length_minus1 0 u(5) */
960 proto_tree_add_bits_item(tree, hf_h264_cpb_removal_delay_length_minus1, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
961 bit_offset = bit_offset + 5;
963 /* dpb_output_delay_length_minus1 0 u(5) */
964 proto_tree_add_bits_item(tree, hf_h264_dpb_output_delay_length_minus11, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
965 bit_offset = bit_offset + 5;
967 /* time_offset_length 0 u(5) */
968 proto_tree_add_bits_item(tree, hf_h264_time_offset_length, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
969 bit_offset = bit_offset + 5;
974 #define EXTENDED_SAR 255
976 /* E.1.1 VUI parameters syntax */
978 /* Table E-2 - Meaning of video_format */
979 static const value_string h264_video_format_vals[] = {
980 { 22, "reserved_sei_message)" },
986 { 5, "Unspecified video format" },
993 dissect_h264_vui_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint bit_offset)
996 guint8 aspect_ratio_info_present_flag, aspect_ratio_idc, overscan_info_present_flag;
997 guint8 video_signal_type_present_flag, colour_description_present_flag, chroma_loc_info_present_flag;
998 guint8 timing_info_present_flag, nal_hrd_parameters_present_flag, vcl_hrd_parameters_present_flag;
999 guint8 bitstream_restriction_flag;
1001 /* vui_parameters( ) {
1002 * aspect_ratio_info_present_flag 0 u(1)
1004 aspect_ratio_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1005 proto_tree_add_bits_item(tree, hf_h264_aspect_ratio_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1008 if (aspect_ratio_info_present_flag) {
1009 /* aspect_ratio_idc 0 u(8) */
1010 aspect_ratio_idc = tvb_get_bits8(tvb, bit_offset, 8);
1011 proto_tree_add_bits_item(tree, hf_h264_aspect_ratio_idc, tvb, bit_offset, 8, ENC_BIG_ENDIAN);
1012 bit_offset = bit_offset + 8;
1014 if (aspect_ratio_idc == EXTENDED_SAR) {
1015 /* sar_width 0 u(16) */
1016 proto_tree_add_bits_item(tree, hf_h264_sar_width, tvb, bit_offset, 16, ENC_BIG_ENDIAN);
1017 bit_offset = bit_offset + 16;
1019 /* sar_height 0 u(16) */
1020 proto_tree_add_bits_item(tree, hf_h264_sar_height, tvb, bit_offset, 16, ENC_BIG_ENDIAN);
1021 bit_offset = bit_offset + 16;
1024 /* overscan_info_present_flag 0 u(1) */
1025 overscan_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1026 proto_tree_add_bits_item(tree, hf_h264_overscan_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1029 if (overscan_info_present_flag) {
1030 /* overscan_appropriate_flag 0 u(1) */
1031 proto_tree_add_bits_item(tree, hf_h264_overscan_appropriate_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1035 /* video_signal_type_present_flag 0 u(1) */
1036 video_signal_type_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1037 proto_tree_add_bits_item(tree, hf_h264_video_signal_type_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1040 if (video_signal_type_present_flag) {
1041 /* video_format 0 u(3) > */
1042 proto_tree_add_bits_item(tree, hf_h264_video_format, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
1043 bit_offset = bit_offset + 3;
1045 /* video_full_range_flag 0 u(1)*/
1046 proto_tree_add_bits_item(tree, hf_h264_video_full_range_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1049 /* colour_description_present_flag 0 u(1) */
1050 colour_description_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1051 proto_tree_add_bits_item(tree, hf_h264_colour_description_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1054 if (colour_description_present_flag) {
1055 /* colour_primaries 0 u(8) */
1056 proto_tree_add_bits_item(tree, hf_h264_colour_primaries, tvb, bit_offset, 8, ENC_BIG_ENDIAN);
1057 bit_offset = bit_offset + 8;
1059 /* transfer_characteristics 0 u(8) */
1060 proto_tree_add_bits_item(tree, hf_h264_transfer_characteristics, tvb, bit_offset, 8, ENC_BIG_ENDIAN);
1061 bit_offset = bit_offset + 8;
1063 /* matrix_coefficients 0 u(8)*/
1064 proto_tree_add_bits_item(tree, hf_h264_matrix_coefficients, tvb, bit_offset, 8, ENC_BIG_ENDIAN);
1065 bit_offset = bit_offset + 8;
1069 /* chroma_loc_info_present_flag 0 u(1) */
1070 chroma_loc_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1071 proto_tree_add_bits_item(tree, hf_h264_chroma_loc_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1074 if (chroma_loc_info_present_flag) {
1075 /* chroma_sample_loc_type_top_field 0 ue(v) */
1076 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_sample_loc_type_top_field, tvb, &bit_offset, H264_UE_V);
1078 /* chroma_sample_loc_type_bottom_field 0 ue(v) */
1079 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_sample_loc_type_bottom_field, tvb, &bit_offset, H264_UE_V);
1082 /* timing_info_present_flag 0 u(1) */
1083 timing_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1084 proto_tree_add_bits_item(tree, hf_h264_timing_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1087 if (timing_info_present_flag) {
1088 /* num_units_in_tick 0 u(32) */
1089 proto_tree_add_bits_item(tree, hf_h264_num_units_in_tick, tvb, bit_offset, 32, ENC_BIG_ENDIAN);
1090 bit_offset = bit_offset + 32;
1092 /* time_scale 0 u(32) */
1093 proto_tree_add_bits_item(tree, hf_h264_time_scale, tvb, bit_offset, 32, ENC_BIG_ENDIAN);
1094 bit_offset = bit_offset + 32;
1096 /* fixed_frame_rate_flag 0 u(1) */
1097 proto_tree_add_bits_item(tree, hf_h264_fixed_frame_rate_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1100 /* nal_hrd_parameters_present_flag 0 u(1) */
1101 nal_hrd_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1102 proto_tree_add_bits_item(tree, hf_h264_nal_hrd_parameters_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1105 if (nal_hrd_parameters_present_flag) {
1106 /* hrd_parameters( ) */
1107 bit_offset = dissect_h264_hrd_parameters(tree, tvb, pinfo, bit_offset);
1110 /* vcl_hrd_parameters_present_flag 0 u(1) */
1111 vcl_hrd_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1112 proto_tree_add_bits_item(tree, hf_h264_vcl_hrd_parameters_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1115 if (vcl_hrd_parameters_present_flag) {
1116 /* hrd_parameters( ) */
1117 bit_offset = dissect_h264_hrd_parameters(tree, tvb, pinfo, bit_offset);
1119 if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag) {
1120 /* low_delay_hrd_flag 0 u(1) */
1121 proto_tree_add_bits_item(tree, hf_h264_low_delay_hrd_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1124 /* pic_struct_present_flag 0 u(1) */
1125 proto_tree_add_bits_item(tree, hf_h264_pic_struct_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1128 /* bitstream_restriction_flag 0 u(1) */
1129 bitstream_restriction_flag = tvb_get_bits8(tvb, bit_offset, 1);
1130 proto_tree_add_bits_item(tree, hf_h264_bitstream_restriction_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1133 if (bitstream_restriction_flag) {
1134 /* motion_vectors_over_pic_boundaries_flag 0 u(1) */
1135 proto_tree_add_bits_item(tree, hf_h264_motion_vectors_over_pic_boundaries_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1138 /* max_bytes_per_pic_denom 0 ue(v) */
1139 dissect_h264_exp_golomb_code(tree, hf_h264_max_bytes_per_pic_denom, tvb, &bit_offset, H264_UE_V);
1141 /* max_bits_per_mb_denom 0 ue(v) */
1142 dissect_h264_exp_golomb_code(tree, hf_h264_max_bits_per_mb_denom, tvb, &bit_offset, H264_UE_V);
1144 /* log2_max_mv_length_horizontal 0 ue(v) */
1145 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_mv_length_horizontal, tvb, &bit_offset, H264_UE_V);
1147 /* log2_max_mv_length_vertical 0 ue(v) */
1148 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_mv_length_vertical, tvb, &bit_offset, H264_UE_V);
1150 /* num_reorder_frames 0 ue(v) */
1151 dissect_h264_exp_golomb_code(tree, hf_h264_num_reorder_frames, tvb, &bit_offset, H264_UE_V);
1153 /* max_dec_frame_buffering 0 ue(v) */
1154 dissect_h264_exp_golomb_code(tree, hf_h264_max_dec_frame_buffering, tvb, &bit_offset, H264_UE_V);
1160 /* Used To dissect SDP parameter (H.264)profile */
1162 dissect_h264_profile(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
1164 proto_item *item, *level_item;
1165 proto_tree *h264_profile_tree;
1167 guint8 constraint_set3_flag;
1170 item = proto_tree_add_item(tree, hf_h264_profile, tvb, offset, -1, ENC_NA);
1171 h264_profile_tree = proto_item_add_subtree(item, ett_h264_profile);
1173 proto_tree_add_item(h264_profile_tree, hf_h264_profile_idc, tvb, offset, 1, ENC_BIG_ENDIAN);
1176 constraint_set3_flag = (tvb_get_guint8(tvb, offset)&0x10)>>4;
1177 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set0_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1178 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set1_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1179 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set2_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1180 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set3_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1181 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set4_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1182 proto_tree_add_item(h264_profile_tree, hf_h264_constraint_set5_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1183 proto_tree_add_item(h264_profile_tree, hf_h264_reserved_zero_2bits, tvb, offset, 1, ENC_BIG_ENDIAN);
1186 /* A level to which the bitstream conforms shall be indicated by the syntax element level_idc as follows.
1187 * - If level_idc is equal to 11 and constraint_set3_flag is equal to 1, the indicated level is level 1b.
1188 * - Otherwise (level_idc is not equal to 11 or constraint_set3_flag is not equal to 1), level_idc shall
1189 * be set equal to a value of ten times the level number specified in Table A-1 and constraint_set3_flag
1190 * shall be set equal to 0.
1193 level_idc = tvb_get_guint8(tvb, offset);
1194 level_item = proto_tree_add_item(h264_profile_tree, hf_h264_level_idc, tvb, offset, 1, ENC_BIG_ENDIAN);
1195 if ((level_idc == 11) && (constraint_set3_flag == 1)) {
1196 proto_item_append_text(level_item," [Level 1b (128kb/s)]");
1198 proto_item_append_text(level_item," [Level %.1f %s]", ((double)level_idc/10), val_to_str_const(level_idc, h264_level_bitrate_values, "Unknown "));
1203 * 7.3.1 NAL unit syntax
1204 * Un escape the NAL tvb
1207 * nal_unit( NumBytesInNALunit ) { C Descriptor
1208 * forbidden_zero_bit All f(1)
1209 * nal_ref_idc All u(2)
1210 * nal_unit_type All u(5)
1211 * NumBytesInRBSP = 0
1212 * for (i = 1; i < NumBytesInNALunit; i++) {
1213 * if (i + 2 < NumBytesInNALunit && next_bits( 24 ) = = 0x000003 ) {
1214 * rbsp_byte[ NumBytesInRBSP++ ] All b(8)
1215 * rbsp_byte[ NumBytesInRBSP++ ] All b(8)
1217 * emulation_prevention_three_byte / * equal to 0x03 * / All f(8)
1219 * rbsp_byte[ NumBytesInRBSP++ ] All b(8)
1225 dissect_h265_unescap_nal_unit(tvbuff_t *tvb, packet_info *pinfo, int offset)
1228 int length = tvb_length_remaining(tvb, offset);
1229 int NumBytesInRBSP = 0;
1233 buff = (gchar *)wmem_alloc(pinfo->pool, length);
1234 for (i = 0; i < length; i++) {
1235 if ((i + 2 < length) && (tvb_get_ntoh24(tvb, offset) == 0x000003)) {
1236 buff[NumBytesInRBSP++] = tvb_get_guint8(tvb, offset);
1237 buff[NumBytesInRBSP++] = tvb_get_guint8(tvb, offset+1);
1241 buff[ NumBytesInRBSP++] = tvb_get_guint8(tvb, offset);
1246 tvb_rbsp = tvb_new_child_real_data(tvb, buff, NumBytesInRBSP, NumBytesInRBSP);
1247 add_new_data_source(pinfo, tvb_rbsp, "Unescaped RSP Data");
1253 * 7.3.2.8 Slice layer without partitioning RBSP syntax
1254 * slice_layer_without_partitioning_rbsp( )
1258 dissect_h264_slice_layer_without_partitioning_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1262 bit_offset = offset <<3;
1264 /* slice_header( ) 2 */
1265 bit_offset = dissect_h264_slice_header(tree, tvb, pinfo, bit_offset);
1266 proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, bit_offset>>3, -1);
1268 /* slice_data( ) * all categories of slice_data( ) syntax * 2 | 3 | 4 */
1269 /* rbsp_slice_trailing_bits( ) */
1273 * 7.3.2.9.1 Slice data partition A RBSP syntax
1274 * slice_data_partition_a_layer_rbsp( )
1277 dissect_h264_slice_data_partition_a_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1281 bit_offset = offset <<3;
1283 /* slice_header( ) 2 */
1284 bit_offset = dissect_h264_slice_header(tree, tvb, pinfo, bit_offset);
1286 /* slice_id All ue(v) */
1287 dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1288 proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, bit_offset>>3, -1);
1290 /* slice_data( ) * only category 2 parts of slice_data( ) syntax * 2*/
1291 /* rbsp_slice_trailing_bits( )*/
1295 * 7.3.2.9.2 Slice data partition B RBSP syntax
1296 * slice_data_partition_b_layer_rbsp(
1299 dissect_h264_slice_data_partition_b_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1303 bit_offset = offset <<3;
1305 /* slice_id All ue(v) */
1306 dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1307 /* if (redundant_pic_cnt_present_flag) */
1308 /* redundant_pic_cnt All ue(v) */
1309 /* slice_data( ) * only category 3 parts of slice_data( ) syntax * 3 */
1310 /* rbsp_slice_trailing_bits( ) 3 */
1311 proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, bit_offset>>3, -1);
1316 * 7.3.2.9.3 Slice data partition C RBSP syntax
1317 * slice_data_partition_c_layer_rbsp( )
1320 dissect_h264_slice_data_partition_c_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1324 bit_offset = offset <<3;
1326 /* slice_id All ue(v) */
1327 dissect_h264_exp_golomb_code(tree, hf_h264_slice_id, tvb, &bit_offset, H264_UE_V);
1328 /* if (redundant_pic_cnt_present_flag) */
1329 /* redundant_pic_cnt All ue(v) */
1330 /* slice_data( ) * only category 4 parts of slice_data( ) syntax * 4 */
1331 /* rbsp_slice_trailing_bits( ) 4 */
1332 proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, bit_offset>>3, -1);
1335 /* D.1.6 User data unregistered SEI message syntax */
1338 h264_user_data_unregistered(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset, guint32 payloadSize)
1345 gint offset = bit_offset >> 3;
1347 proto_item *uuid_item;
1348 proto_tree *h264_ms_layer_desc_tree;
1349 proto_tree *h264_ms_crop_data_tree;
1353 /* user_data_unregistered( payloadSize ) { C Descriptor */
1354 /* uuid_iso_iec_11578 5 u(128)
1355 * uuid_iso_iec_11578 shall have a value specified as a UUID
1356 * according to the procedures of ISO/IEC 11578:1996 Annex A.
1359 uuid_item = proto_tree_add_item (tree, hf_h264_sei_uuid, tvb, offset, 16, ENC_BIG_ENDIAN);
1360 /* Extract the ISO/IEC value for comparison */
1361 tvb_get_ntohguid(tvb, offset, &guid);
1364 /* Microsoft MS-H264PF Specification */
1365 if ( memcmp(&guid, &(ms_guids[MS_LAYOUT]), sizeof(e_guid_t)) == 0)
1367 col_append_fstr(pinfo->cinfo, COL_INFO, ":MS_Layout");
1368 proto_item_append_text(uuid_item," - Microsoft Stream Layout SEI Message");
1369 /* Loop through the layer presence bytes 0-7 */
1370 for (i = 0; i < 8 ; i++)
1372 item = proto_tree_add_item (tree, hf_h264_sei_ms_lpb, tvb, offset, 1, ENC_BIG_ENDIAN);
1373 proto_item_append_text (item, " PRID %2d - %2d", (i+1)*8-1, i*8);
1376 p_flag = tvb_get_guint8 (tvb, offset);
1377 proto_tree_add_item (tree, hf_h264_sei_ms_layout_p, tvb, offset, 1, ENC_BIG_ENDIAN);
1381 ld_size = tvb_get_guint8 (tvb, offset);
1382 proto_tree_add_item (tree, hf_h264_sei_ms_layout_ldsize, tvb, offset, 1, ENC_BIG_ENDIAN);
1384 /* MS Errata - Microsoft seems to be setting the LD size to 16 but then including 2 layer descriptions which should be 32
1385 * To compensate for that, keep decoding layers as long as there are 16 or more bytes left in the SEI message.
1387 if (tvb_reported_length_remaining (tvb, offset) != ld_size)
1389 item = proto_tree_add_expert(tree, pinfo, &ei_h264_ms_layout_wrong_length, tvb, offset-1, 1);
1390 proto_item_append_text(item," Size of %d, remaining size %d",
1392 tvb_reported_length_remaining (tvb, offset));
1394 while (tvb_reported_length_remaining (tvb, offset) >= 16)
1396 h264_ms_layer_desc_tree = proto_tree_add_subtree_format(tree, tvb, offset, 16, ett_h264_ms_layer_description, NULL, "MS Layer Description #%d", ++desc);
1398 proto_tree_add_item (h264_ms_layer_desc_tree, hf_h264_sei_ms_layer_desc_coded_width, tvb, offset, 2, ENC_BIG_ENDIAN);
1399 proto_tree_add_item (h264_ms_layer_desc_tree, hf_h264_sei_ms_layer_desc_coded_height, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
1400 proto_tree_add_item (h264_ms_layer_desc_tree, hf_h264_sei_ms_layer_desc_display_width, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
1401 proto_tree_add_item (h264_ms_layer_desc_tree, hf_h264_sei_ms_layer_desc_display_height, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
1402 proto_tree_add_item (h264_ms_layer_desc_tree, hf_h264_sei_ms_layer_desc_bitrate, tvb, offset + 8, 4, ENC_BIG_ENDIAN);
1403 proto_tree_add_item (h264_ms_layer_desc_tree, hf_h264_sei_ms_layer_desc_frame_rate, tvb, offset + 12, 1, ENC_BIG_ENDIAN);
1404 proto_tree_add_item (h264_ms_layer_desc_tree, hf_h264_sei_ms_layer_desc_layer_type, tvb, offset + 12, 1, ENC_BIG_ENDIAN);
1405 proto_tree_add_item (h264_ms_layer_desc_tree, hf_h264_sei_ms_layer_desc_prid, tvb, offset + 13, 1, ENC_BIG_ENDIAN);
1406 proto_tree_add_item (h264_ms_layer_desc_tree, hf_h264_sei_ms_layer_desc_cb, tvb, offset + 13, 1, ENC_BIG_ENDIAN);
1411 else if ( memcmp(&guid, &(ms_guids[MS_CROPPING]), sizeof(e_guid_t)) == 0)
1413 col_append_fstr(pinfo->cinfo, COL_INFO, ":MS_Cropping");
1414 proto_item_append_text(uuid_item," - Microsoft Cropping Info SEI Message");
1415 num_crops = tvb_get_guint8 (tvb, offset);
1416 proto_tree_add_item (tree, hf_h264_sei_ms_crop_num_data, tvb, offset, 1, ENC_BIG_ENDIAN);
1418 proto_tree_add_item (tree, hf_h264_sei_ms_crop_info_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1420 while (num_crops != 0)
1422 h264_ms_crop_data_tree = proto_tree_add_subtree_format(tree, tvb, offset, 9, ett_h264_ms_crop_data, NULL, "Crop Data #%d", ++desc);
1423 proto_tree_add_item (h264_ms_crop_data_tree, hf_h264_sei_ms_crop_confidence_level, tvb, offset, 1, ENC_BIG_ENDIAN);
1424 proto_tree_add_item (h264_ms_crop_data_tree, hf_h264_sei_ms_crop_frame_left_offset, tvb, offset+1, 2, ENC_BIG_ENDIAN);
1425 proto_tree_add_item (h264_ms_crop_data_tree, hf_h264_sei_ms_crop_frame_right_offset, tvb, offset+3, 2, ENC_BIG_ENDIAN);
1426 proto_tree_add_item (h264_ms_crop_data_tree, hf_h264_sei_ms_crop_frame_top_offset, tvb, offset+5, 2, ENC_BIG_ENDIAN);
1427 proto_tree_add_item (h264_ms_crop_data_tree, hf_h264_sei_ms_crop_frame_bottom_offset, tvb, offset+7, 2, ENC_BIG_ENDIAN);
1432 else if ( memcmp(&guid, &(ms_guids[MS_BITSTREAM]), sizeof(e_guid_t)) == 0)
1434 col_append_fstr(pinfo->cinfo, COL_INFO, ":MS_Bitstream");
1435 proto_item_append_text(uuid_item," - Microsoft Bitstream Info SEI Message");
1436 proto_tree_add_item (tree, hf_h264_sei_ms_bitstream_ref_frame_cnt, tvb, offset, 1, ENC_BIG_ENDIAN);
1438 proto_tree_add_item (tree, hf_h264_sei_ms_bitstream_num_nalus, tvb, offset, 1, ENC_BIG_ENDIAN);
1443 proto_tree_add_text(tree, tvb, offset, 16, "Unparsed iso_iec information");
1444 /* for (i = 16; i < payloadSize; i++)
1445 * user_data_payload_byte 5 b(8)
1447 if (payloadSize > 16)
1449 proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, offset, payloadSize-16);
1450 offset+=(payloadSize-16);
1457 /* D.1 SEI payload syntax */
1458 static const value_string h264_sei_payload_vals[] = {
1459 { 0, "buffering_period" },
1460 { 1, "pic_timing" },
1461 { 2, "pan_scan_rect" },
1462 { 3, "filler_payload" },
1463 { 4, "user_data_registered_itu_t_t35" },
1464 { 5, "user_data_unregistered" },
1465 { 6, "recovery_point" },
1466 { 7, "dec_ref_pic_marking_repetition" },
1468 { 9, "scene_inf)" },
1469 { 10, "sub_seq_info)" },
1470 { 11, "sub_seq_layer_characteristics" },
1471 { 12, "sub_seq_characteristics" },
1472 { 13, "full_frame_freeze_release" },
1473 { 14, "full_frame_freeze_release" },
1474 { 15, "full_frame_snapshot" },
1475 { 16, "progressive_refinement_segment_start" },
1476 { 17, "progressive_refinement_segment_end" },
1477 { 18, "motion_constrained_slice_group_set" },
1478 { 19, "film_grain_characteristics)" },
1479 { 20, "deblocking_filter_display_preference)" },
1480 { 21, "stereo_video_info)" },
1481 { 22, "post_filter_hint" },
1482 { 23, "tone_mapping_info" },
1483 /* Annex G Values */
1484 { 24, "scalability_info" },
1485 { 25, "sub_pic_scalable_layer" },
1486 { 26, "non_required_layer_rep" },
1487 { 27, "priority_layer_info" },
1488 { 28, "layers_not_present" },
1489 { 29, "layer_dependency_change" },
1490 { 30, "scalable_nesting" },
1491 { 31, "base_layer_temporal_hrd" },
1492 { 32, "quality_layer_integrity_check" },
1493 { 33, "redundant_pic_property" },
1494 { 34, "tl0_dep_rep_index" },
1495 { 35, "tl_switching_point" },
1496 /* Annex H 37 to 46 - Not Decoded*/
1497 /* Annex I 47 to 53 - Not Decoded*/
1502 h264_sei_payload(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset, guint32 payloadType, guint32 payloadSize)
1504 /* sei_payload( payloadType, payloadSize ) { C Descriptor */
1505 if (payloadType == 0) {
1506 /* buffering_period( payloadSize ) 5 */
1507 bit_offset = bit_offset +(payloadSize<<3);
1509 } else if (payloadType == 1) {
1510 /* pic_timing( payloadSize ) 5 */
1511 } else if (payloadType == 2) {
1512 /* pan_scan_rect( payloadSize ) 5 */
1513 } else if (payloadType == 3) {
1514 /* filler_payload( payloadSize ) 5 */
1515 } else if (payloadType == 4) {
1516 /* user_data_registered_itu_t_t35( payloadSize ) 5 */
1518 } else if (payloadType == 5) {
1519 /* user_data_unregistered( payloadSize ) 5 */
1520 bit_offset = h264_user_data_unregistered( tree, tvb, pinfo, bit_offset, payloadSize);
1521 } else if (payloadType == 6) {
1522 /* recovery_point( payloadSize ) 5 */
1523 bit_offset = bit_offset +(payloadSize<<3);
1524 } else if (payloadType == 7) {
1525 /* dec_ref_pic_marking_repetition( payloadSize ) 5 */
1526 bit_offset = bit_offset +(payloadSize<<3);
1529 else if (payloadType == 8)
1530 spare_pic( payloadSize ) 5
1531 else if (payloadType == 9)
1532 scene_info( payloadSize ) 5
1533 else if (payloadType == 10)
1534 sub_seq_info( payloadSize ) 5
1535 else if (payloadType == 11)
1536 sub_seq_layer_characteristics( payloadSize ) 5
1537 else if (payloadType == 12)
1538 sub_seq_characteristics( payloadSize ) 5
1539 else if (payloadType == 13)
1540 full_frame_freeze( payloadSize ) 5
1541 else if (payloadType == 14)
1542 full_frame_freeze_release( payloadSize ) 5
1543 else if (payloadType == 15)
1544 full_frame_snapshot( payloadSize ) 5
1545 else if (payloadType == 16)
1546 progressive_refinement_segment_start( payloadSize ) 5
1547 else if (payloadType == 17)
1548 progressive_refinement_segment_end( payloadSize ) 5
1549 else if (payloadType == 18)
1550 motion_constrained_slice_group_set( payloadSize ) 5
1551 else if (payloadType == 19)
1552 film_grain_characteristics( payloadSize ) 5
1553 else if (payloadType == 20)
1554 deblocking_filter_display_preference( payloadSize ) 5
1555 else if (payloadType == 21)
1556 stereo_video_info( payloadSize ) 5
1558 reserved_sei_message( payloadSize ) 5
1561 if (!h264_byte_aligned(bit_offset)) {
1562 /* bit_equal_to_one / * equal to 1 * / 5 f(1) */
1563 /* TODO:Display the filler and, error if not 1 ?? */
1565 while (!h264_byte_aligned(bit_offset)) {
1566 /* bit_equal_to_zero / * equal to 0 * / 5 f(1) */
1567 /* TODO:Display the filler and, error if not 0 ?? */
1575 * 7.3.2.3.1 Supplemental enhancement information message syntax
1578 dissect_h264_sei_message(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint bit_offset)
1580 /* sei_message( ) { C Descriptor */
1581 guint32 payloadType = 0, payloadSize;
1582 gint start_bit_offset, length;
1584 start_bit_offset = bit_offset;
1586 /* while (next_bits( 8 ) == 0xFF) { */
1587 while (tvb_get_bits8(tvb, bit_offset, 8) == 0xFF) {
1588 /* ff_byte / * equal to 0xFF * / 5 f(8) */
1592 /* last_payload_type_byte 5 u(8) */
1593 payloadType += tvb_get_bits8(tvb, bit_offset, 8);
1595 length = (bit_offset - start_bit_offset)>>3;
1597 proto_tree_add_uint(tree, hf_h264_payloadtype, tvb, start_bit_offset>>3, length, payloadType);
1600 start_bit_offset = bit_offset;
1601 /* while (next_bits( 8 ) == 0xFF) { */
1602 while (tvb_get_bits8(tvb, bit_offset, 8) == 0xFF) {
1603 /* ff_byte / * equal to 0xFF * / 5 f(8) */
1607 /* last_payload_size_byte 5 u(8) */
1608 /* payloadSize += last_payload_size_byte */
1609 payloadSize += tvb_get_bits8(tvb, bit_offset, 8);
1611 length = (bit_offset - start_bit_offset)>>3;
1612 proto_tree_add_uint(tree, hf_h264_payloadsize, tvb, start_bit_offset>>3, length, payloadSize);
1614 /*sei_payload( payloadType, payloadSize ) 5 */
1615 bit_offset = h264_sei_payload( tree, tvb, pinfo, bit_offset, payloadType, payloadSize);
1620 * 7.3.2.3 Supplemental enhancement information RBSP syntax
1624 dissect_h264_sei_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1628 bit_offset = offset <<3;
1630 /* sei_message( ) 5*/
1631 bit_offset = dissect_h264_sei_message( tree, tvb, pinfo, bit_offset);
1633 /* while (more_rbsp_data( ))
1634 * If there is more data in an RBSP before rbsp_trailing_bits( ),
1635 * the return value of more_rbsp_data( ) is equal to TRUE.
1637 /* rbsp_trailing_bits( ) 5 */
1638 if (tvb_reported_length_remaining (tvb, bit_offset >> 3) != 0 || (bit_offset & 0x7) != 0)
1640 bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1646 /* Ref 7.3.2.1 Sequence parameter set RBSP syntax */
1648 dissect_h264_seq_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1650 proto_item *level_item;
1652 guint8 constraint_set3_flag;
1656 guint8 profile_idc, chroma_format_idc, frame_mbs_only_flag, frame_cropping_flag;
1657 guint8 pic_order_cnt_type, vui_parameters_present_flag, num_ref_frames_in_pic_order_cnt_cycle;
1658 guint8 seq_scaling_matrix_present_flag; /* seq_scaling_list_present_flag */
1660 /* profile_idc 0 u(8) */
1661 profile_idc = tvb_get_guint8(tvb, offset);
1662 proto_tree_add_item(tree, hf_h264_profile_idc, tvb, offset, 1, ENC_BIG_ENDIAN);
1665 constraint_set3_flag = (tvb_get_guint8(tvb, offset)&0x10)>>4;
1666 /* constraint_set0_flag 0 u(1) */
1667 proto_tree_add_item(tree, hf_h264_constraint_set0_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1669 /* constraint_set1_flag 0 u(1) */
1670 proto_tree_add_item(tree, hf_h264_constraint_set1_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1672 /* constraint_set2_flag 0 u(1) */
1673 proto_tree_add_item(tree, hf_h264_constraint_set2_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1675 /* constraint_set3_flag 0 u(1) */
1676 proto_tree_add_item(tree, hf_h264_constraint_set3_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1678 /* constraint_set4_flag 0 u(1) */
1679 proto_tree_add_item(tree, hf_h264_constraint_set4_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1681 /* constraint_set5_flag 0 u(1) */
1682 proto_tree_add_item(tree, hf_h264_constraint_set5_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1684 /* reserved_zero_4bits equal to 0 0 u(4)*/
1685 proto_tree_add_item(tree, hf_h264_reserved_zero_2bits, tvb, offset, 1, ENC_BIG_ENDIAN);
1688 /* level_idc 0 u(8) */
1689 level_idc = tvb_get_guint8(tvb, offset);
1690 level_item = proto_tree_add_item(tree, hf_h264_level_idc, tvb, offset, 1, ENC_BIG_ENDIAN);
1691 if ((level_idc == 11) && (constraint_set3_flag == 1)) {
1692 proto_item_append_text(level_item,"[Level 1b]");
1694 proto_item_append_text(level_item," [Level %.1f %s]", ((double)level_idc/10), val_to_str_const(level_idc, h264_level_bitrate_values, "Unknown "));
1697 /* seq_parameter_set_id 0 ue(v)
1698 * ue(v): unsigned integer Exp-Golomb-coded syntax element with the left bit first.
1699 * The parsing process for this descriptor is specified in subclause 9.1.
1701 bit_offset = offset<<3;
1702 dissect_h264_exp_golomb_code(tree, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1705 if ((profile_idc == 100) || (profile_idc == 110) ||
1706 (profile_idc == 122) || (profile_idc == 144) ||
1707 (profile_idc == 44) || (profile_idc == 83) ||
1708 (profile_idc == 86) || (profile_idc == 118) ||
1709 (profile_idc == 128) || (profile_idc == 138))
1712 /* chroma_format_idc 0 ue(v) */
1713 chroma_format_idc = dissect_h264_exp_golomb_code(tree, hf_h264_chroma_format_idc, tvb, &bit_offset, H264_UE_V);
1714 if (chroma_format_idc == 3) {
1715 /* residual_colour_transform_flag 0 u(1) */
1716 proto_tree_add_bits_item(tree, hf_h264_residual_colour_transform_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1720 /* bit_depth_luma_minus8 0 ue(v) */
1721 dissect_h264_exp_golomb_code(tree, hf_h264_bit_depth_luma_minus8, tvb, &bit_offset, H264_UE_V);
1723 /* bit_depth_chroma_minus8 0 ue(v) */
1724 dissect_h264_exp_golomb_code(tree, hf_h264_bit_depth_chroma_minus8, tvb, &bit_offset, H264_UE_V);
1726 /* qpprime_y_zero_transform_bypass_flag 0 u(1) */
1727 proto_tree_add_bits_item(tree, hf_h264_qpprime_y_zero_transform_bypass_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1730 /* seq_scaling_matrix_present_flag 0 u(1) */
1731 seq_scaling_matrix_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1732 proto_tree_add_bits_item(tree, hf_h264_seq_scaling_matrix_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1735 if (seq_scaling_matrix_present_flag) {
1737 for (i = 0; i < 8; i++) {
1738 / seq_scaling_list_present_flag[ i ] 0 u(1) /
1739 seq_scaling_list_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1741 if (seq_scaling_list_present_flag) {
1743 scaling_list( ScalingList4x4[ i ], 16, UseDefaultScalingMatrix4x4Flag[ i ])0
1744 dissect_h264_scaling_list()
1746 scaling_list( ScalingList8x8[ i - 6 ], 64, UseDefaultScalingMatrix8x8Flag[ i - 6 ] )0
1750 proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, bit_offset>>3, -1);
1756 /* log2_max_frame_num_minus4 0 ue(v) */
1757 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_frame_num_minus4, tvb, &bit_offset, H264_UE_V);
1759 /* pic_order_cnt_type 0 ue(v) */
1760 pic_order_cnt_type = dissect_h264_exp_golomb_code(tree, hf_h264_pic_order_cnt_type, tvb, &bit_offset, H264_UE_V);
1762 if (pic_order_cnt_type == 0) {
1763 /* log2_max_pic_order_cnt_lsb_minus4 0 ue(v) */
1764 dissect_h264_exp_golomb_code(tree, hf_h264_log2_max_pic_order_cnt_lsb_minus4, tvb, &bit_offset, H264_UE_V);
1765 } else if (pic_order_cnt_type == 1) {
1766 /* delta_pic_order_always_zero_flag 0 u(1) */
1767 proto_tree_add_bits_item(tree, hf_h264_delta_pic_order_always_zero_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1770 /* offset_for_non_ref_pic 0 se(v) */
1771 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_non_ref_pic, tvb, &bit_offset, H264_SE_V);
1773 /* offset_for_top_to_bottom_field 0 se(v) */
1774 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_top_to_bottom_field, tvb, &bit_offset, H264_SE_V);
1776 /* num_ref_frames_in_pic_order_cnt_cycle 0 ue(v) */
1777 num_ref_frames_in_pic_order_cnt_cycle = dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_frames_in_pic_order_cnt_cycle, tvb, &bit_offset, H264_UE_V);
1778 for (i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
1779 /*offset_for_ref_frame[ i ] 0 se(v)*/
1780 dissect_h264_exp_golomb_code(tree, hf_h264_offset_for_ref_frame, tvb, &bit_offset, H264_SE_V);
1783 /* num_ref_frames 0 ue(v) */
1784 dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_frames, tvb, &bit_offset, H264_UE_V);
1786 /* gaps_in_frame_num_value_allowed_flag 0 u(1) */
1787 proto_tree_add_bits_item(tree, hf_h264_gaps_in_frame_num_value_allowed_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1790 /* pic_width_in_mbs_minus1 0 ue(v) */
1791 dissect_h264_exp_golomb_code(tree, hf_h264_pic_width_in_mbs_minus1, tvb, &bit_offset, H264_UE_V);
1793 /* pic_height_in_map_units_minus1 0 ue(v) */
1794 dissect_h264_exp_golomb_code(tree, hf_h264_pic_height_in_map_units_minus1, tvb, &bit_offset, H264_UE_V);
1796 /* frame_mbs_only_flag 0 u(1) */
1797 frame_mbs_only_flag = tvb_get_bits8(tvb, bit_offset, 1);
1798 proto_tree_add_bits_item(tree, hf_h264_frame_mbs_only_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1800 if (!frame_mbs_only_flag) {
1801 /* mb_adaptive_frame_field_flag 0 u(1) */
1802 proto_tree_add_bits_item(tree, hf_h264_mb_adaptive_frame_field_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1806 /* direct_8x8_inference_flag 0 u(1) */
1807 proto_tree_add_bits_item(tree, hf_h264_direct_8x8_inference_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1810 /* frame_cropping_flag 0 u(1) */
1811 frame_cropping_flag = tvb_get_bits8(tvb, bit_offset, 1);
1812 proto_tree_add_bits_item(tree, hf_h264_frame_cropping_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1815 if (frame_cropping_flag) {
1816 /* frame_crop_left_offset 0 ue(v) */
1817 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_left_offset, tvb, &bit_offset, H264_UE_V);
1818 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_right_offset, tvb, &bit_offset, H264_UE_V);
1819 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_top_offset, tvb, &bit_offset, H264_UE_V);
1820 dissect_h264_exp_golomb_code(tree, hf_h264_frame_crop_bottom_offset, tvb, &bit_offset, H264_UE_V);
1824 /* vui_parameters_present_flag 0 u(1) */
1825 vui_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1826 proto_tree_add_bits_item(tree, hf_h264_vui_parameters_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1828 if (vui_parameters_present_flag) {
1829 bit_offset = dissect_h264_vui_parameters(tree, tvb, pinfo, bit_offset);
1832 /* rbsp_trailing_bits( ) 0 */
1833 bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1835 offset = bit_offset>>3;
1837 /* TODO - Add dissector of SPS SVC extension from Annex G*/
1841 /* 7.3.2.2 Picture parameter set RBSP syntax */
1844 dissect_h264_pic_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1847 guint32 num_slice_groups_minus1, pic_scaling_matrix_present_flag;
1849 bit_offset = offset<<3;
1851 /* pic_parameter_set_id 1 ue(v) */
1852 dissect_h264_exp_golomb_code(tree, hf_h264_pic_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1854 /* seq_parameter_set_id 1 ue(v) */
1855 dissect_h264_exp_golomb_code(tree, hf_h264_seq_parameter_set_id, tvb, &bit_offset, H264_UE_V);
1857 /* entropy_coding_mode_flag 1 u(1) */
1858 proto_tree_add_bits_item(tree, hf_h264_entropy_coding_mode_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1861 /* pic_order_present_flag 1 u(1)*/
1862 proto_tree_add_bits_item(tree, hf_h264_pic_order_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1865 /* num_slice_groups_minus1 1 ue(v)*/
1866 num_slice_groups_minus1 = dissect_h264_exp_golomb_code(tree, hf_h264_num_slice_groups_minus1, tvb, &bit_offset, H264_UE_V);
1867 if (num_slice_groups_minus1 > 0) {
1868 /* slice_group_map_type 1 ue(v)*/
1869 dissect_h264_exp_golomb_code(tree, hf_h264_slice_group_map_type, tvb, &bit_offset, H264_UE_V);
1870 /* slice_group_map_type = dissect_h264_exp_golomb_code(tree, hf_h264_slice_group_map_type, tvb, &bit_offset, H264_UE_V);*/
1871 /* if (slice_group_map_type == 0)*/
1872 /* for (iGroup = 0; iGroup <= num_slice_groups_minus1; iGroup++)*/
1873 /* run_length_minus1[ iGroup ] 1 ue(v)*/
1874 /* else if (slice_group_map_type == 2)*/
1875 /* for (iGroup = 0; iGroup < num_slice_groups_minus1; iGroup++) {*/
1876 /* top_left[ iGroup ] 1 ue(v)*/
1877 /* bottom_right[ iGroup ] 1 ue(v)*/
1879 /* else if (slice_group_map_type == 3 ||*/
1880 /* slice_group_map_type == 4 ||*/
1881 /* slice_group_map_type == 5 ) {*/
1882 /* slice_group_change_direction_flag 1 u(1)*/
1883 /* slice_group_change_rate_minus1 1 ue(v)*/
1884 /* } else if (slice_group_map_type == 6) {*/
1885 /* pic_size_in_map_units_minus1 1 ue(v)*/
1886 /* for (i = 0; i <= pic_size_in_map_units_minus1; i++)*/
1887 /* slice_group_id[ i ] 1 u(v)*/
1890 proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, bit_offset>>3, -1);
1893 /* num_ref_idx_l0_active_minus1 1 ue(v)*/
1894 dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_idx_l0_active_minus1, tvb, &bit_offset, H264_UE_V);
1896 /* num_ref_idx_l1_active_minus1 1 ue(v)*/
1897 dissect_h264_exp_golomb_code(tree, hf_h264_num_ref_idx_l1_active_minus1, tvb, &bit_offset, H264_UE_V);
1899 /* weighted_pred_flag 1 u(1)*/
1900 proto_tree_add_bits_item(tree, hf_h264_weighted_pred_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1903 /* weighted_bipred_idc 1 u(2)*/
1904 proto_tree_add_bits_item(tree, hf_h264_weighted_bipred_idc, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
1905 bit_offset= bit_offset+2;
1907 /* pic_init_qp_minus26 * relative to 26 * 1 se(v)*/
1908 dissect_h264_exp_golomb_code(tree, hf_h264_pic_init_qp_minus26, tvb, &bit_offset, H264_SE_V);
1910 /* pic_init_qs_minus26 * relative to 26 * 1 se(v)*/
1911 dissect_h264_exp_golomb_code(tree, hf_h264_pic_init_qs_minus26, tvb, &bit_offset, H264_SE_V);
1913 /* chroma_qp_index_offset 1 se(v)*/
1914 dissect_h264_exp_golomb_code(tree, hf_h264_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
1916 /* deblocking_filter_control_present_flag 1 u(1)*/
1917 proto_tree_add_bits_item(tree, hf_h264_deblocking_filter_control_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1920 /* constrained_intra_pred_flag 1 u(1)*/
1921 proto_tree_add_bits_item(tree, hf_h264_constrained_intra_pred_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1924 /* redundant_pic_cnt_present_flag 1 u(1)*/
1925 proto_tree_add_bits_item(tree, hf_h264_redundant_pic_cnt_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1928 if (more_rbsp_data(tree, tvb, pinfo, bit_offset)) {
1929 /* transform_8x8_mode_flag 1 u(1)*/
1930 proto_tree_add_bits_item(tree, hf_h264_transform_8x8_mode_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1933 /* pic_scaling_matrix_present_flag 1 u(1)*/
1934 pic_scaling_matrix_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1935 proto_tree_add_bits_item(tree, hf_h264_pic_scaling_matrix_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1938 if (pic_scaling_matrix_present_flag) {
1939 proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, bit_offset>>3, -1);
1941 /* for (i = 0; i < 6 + 2* transform_8x8_mode_flag; i++) {*/
1942 /* pic_scaling_list_present_flag[ i ] 1 u(1)*/
1943 /* if (pic_scaling_list_present_flag[ i ])*/
1945 /* scaling_list( ScalingList4x4[ i ], 16, UseDefaultScalingMatrix4x4Flag[ i ] )*/
1947 /* scaling_list( ScalingList8x8[ i - 6 ], 64, UseDefaultScalingMatrix8x8Flag[ i - 6 ] )*/
1951 /* second_chroma_qp_index_offset 1 se(v)*/
1952 dissect_h264_exp_golomb_code(tree, hf_h264_second_chroma_qp_index_offset, tvb, &bit_offset, H264_SE_V);
1954 bit_offset = dissect_h264_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1958 * 7.3.2.4 Access unit delimiter RBSP syntax
1959 * access_unit_delimiter_rbsp( )
1962 dissect_h264_access_unit_delimiter_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1964 /* primary_pic_type 6 u(3) */
1965 /* rbsp_trailing_bits( ) 6 */
1966 proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, offset, -1);
1970 * 7.3.2.5 End of sequence RBSP syntax
1971 * end_of_seq_rbsp( ) {}
1974 dissect_h264_end_of_seq_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1976 proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, offset, -1);
1980 * 7.3.2.6 End of stream RBSP syntax
1981 * end_of_stream_rbsp( ) {}
1984 dissect_h264_end_of_stream_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1986 proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, offset, -1);
1990 * 7.3.2.7 Filler data RBSP syntax
1991 * filler_data_rbsp( )
1994 dissect_h264_filler_data_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
1996 /* while (next_bits( 8 ) == 0xFF) */
1997 /* ff_byte * equal to 0xFF * 9 f(8) */
1998 /* rbsp_trailing_bits( ) 9 */
1999 proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, offset, -1);
2003 * 7.3.2.1.2 Sequence parameter set extension RBSP syntax
2004 * seq_parameter_set_extension_rbsp( )
2007 dissect_h264_seq_parameter_set_extension_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
2009 /* seq_parameter_set_id 10 ue(v) */
2010 /* aux_format_idc 10 ue(v) */
2011 /* if (aux_format_idc != 0 ) { */
2012 /* bit_depth_aux_minus8 10 ue(v) */
2013 /* alpha_incr_flag 10 u(1) */
2014 /* alpha_opaque_value 10 u(v) */
2015 /* alpha_transparent_value 10 u(v) */
2017 /* additional_extension_flag 10 u(1) */
2018 /* rbsp_trailing_bits() 10 */
2019 proto_tree_add_expert(tree, pinfo, &ei_h264_undecoded, tvb, offset, -1);
2022 /* RFC 6190 Section: 1.1.3 - NAL Unit Header Extension - H.264 Annex G*/
2024 dissect_h264_svc_nal_header_extension(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
2026 proto_tree_add_item(tree, hf_h264_nal_hdr_ext_svc, tvb, offset, 1, ENC_BIG_ENDIAN);
2027 proto_tree_add_item(tree, hf_h264_nal_hdr_ext_i, tvb, offset, 1, ENC_BIG_ENDIAN);
2028 proto_tree_add_item(tree, hf_h264_nal_hdr_ext_prid, tvb, offset, 1, ENC_BIG_ENDIAN);
2030 proto_tree_add_item(tree, hf_h264_nal_hdr_ext_n, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
2031 proto_tree_add_item(tree, hf_h264_nal_hdr_ext_did, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
2032 proto_tree_add_item(tree, hf_h264_nal_hdr_ext_qid, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
2034 proto_tree_add_item(tree, hf_h264_nal_hdr_ext_tid, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
2035 proto_tree_add_item(tree, hf_h264_nal_hdr_ext_u, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
2036 proto_tree_add_item(tree, hf_h264_nal_hdr_ext_d, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
2037 proto_tree_add_item(tree, hf_h264_nal_hdr_ext_o, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
2038 proto_tree_add_item(tree, hf_h264_nal_hdr_ext_rr, tvb, offset + 2, 1, ENC_BIG_ENDIAN);
2042 /* H.264 Annex G Prefix NAL Unit */
2044 static int dissect_h264_prefix(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
2046 guint8 svc_extension_flag;
2048 svc_extension_flag = tvb_get_bits8(tvb, offset << 3, 1);
2049 if (svc_extension_flag)
2051 /* Annex G NAL Unit Header SVC Extension */
2052 dissect_h264_svc_nal_header_extension (tree, tvb, pinfo, offset);
2056 /* Annex H NAL Unit Header MVC Extension */
2063 /* RFC 6190 Section: 4.9 - Payload Content Scalability Information (PACSI) */
2065 dissect_h264_pacsi(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
2068 guint16 nal_unit_size;
2070 gboolean error = FALSE;
2071 gboolean contains_sei = FALSE;
2073 offset = dissect_h264_svc_nal_header_extension(tree, tvb, pinfo, offset);
2075 pacsi_flags = tvb_get_guint8(tvb, offset);
2076 proto_tree_add_item(tree, hf_h264_pacsi_x, tvb, offset, 1, ENC_BIG_ENDIAN);
2077 proto_tree_add_item(tree, hf_h264_pacsi_y, tvb, offset, 1, ENC_BIG_ENDIAN);
2078 proto_tree_add_item(tree, hf_h264_pacsi_t, tvb, offset, 1, ENC_BIG_ENDIAN);
2079 proto_tree_add_item(tree, hf_h264_pacsi_a, tvb, offset, 1, ENC_BIG_ENDIAN);
2080 proto_tree_add_item(tree, hf_h264_pacsi_p, tvb, offset, 1, ENC_BIG_ENDIAN);
2081 proto_tree_add_item(tree, hf_h264_pacsi_c, tvb, offset, 1, ENC_BIG_ENDIAN);
2082 proto_tree_add_item(tree, hf_h264_pacsi_s, tvb, offset, 1, ENC_BIG_ENDIAN);
2083 proto_tree_add_item(tree, hf_h264_pacsi_e, tvb, offset, 1, ENC_BIG_ENDIAN);
2086 if (pacsi_flags & 0x40)
2088 proto_tree_add_item(tree, hf_h264_pacsi_tl0picidx, tvb, offset, 1, ENC_BIG_ENDIAN);
2090 proto_tree_add_item(tree, hf_h264_pacsi_idrpicid, tvb, offset, 2, ENC_BIG_ENDIAN);
2093 if (pacsi_flags & 0x20)
2095 proto_tree_add_item(tree, hf_h264_pacsi_donc, tvb, offset, 2, ENC_BIG_ENDIAN);
2098 if (tvb_reported_length_remaining(tvb, offset) > 0)
2100 contains_sei = TRUE;
2101 col_append_fstr(pinfo->cinfo, COL_INFO, "(");
2104 /* Decode the SEI units that are in the packet. */
2105 while (tvb_reported_length_remaining(tvb, offset) > 0 && !error)
2107 nal_unit_size = tvb_get_ntohs(tvb, offset);
2108 proto_tree_add_item(tree, hf_h264_nalu_size, tvb, offset, 2, ENC_NA);
2111 if (nal_unit_size == 0 || nal_unit_size > tvb_reported_length_remaining(tvb, offset))
2113 proto_tree_add_expert(tree, pinfo, &ei_h264_bad_nal_length, tvb, offset-2, 2);
2118 /* Make a new subset of the existing buffer for the NAL unit */
2119 nalu_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb,offset), nal_unit_size);
2120 /* Decode the NAL unit */
2121 dissect_h264(nalu_tvb, pinfo, tree);
2122 offset += nal_unit_size;
2125 if (contains_sei == TRUE)
2127 col_append_fstr(pinfo->cinfo, COL_INFO, ")");
2132 * RFC 3984 Section 5.7.1 - Single-Time Aggregation Packet (STAP)
2135 dissect_h264_stap(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset, gint8 nal_type)
2137 guint16 nal_unit_size;
2141 /* If it is a STAP-B then the Decoder Order Number if present before the NAL Units */
2142 if (nal_type == H264_STAP_B)
2144 proto_tree_add_item(tree, hf_h264_don, tvb, offset, 2, ENC_NA);
2148 while (tvb_reported_length_remaining(tvb, offset) > 0)
2150 /* Get the size of the NAL unit and display */
2151 proto_tree_add_item(tree, hf_h264_nalu_size, tvb, offset, 2, ENC_NA);
2152 nal_unit_size = tvb_get_ntohs(tvb, offset);
2155 /* Do a sanity check on the unit size versus what is left in the packet. */
2156 if (nal_unit_size == 0 || tvb_reported_length_remaining(tvb, offset) < nal_unit_size)
2158 /* Throw an exception if the size is wrong and don't try to decode the rest of the packet. */
2159 col_append_fstr(pinfo->cinfo, COL_INFO, " [Bad NAL Length]");
2160 item = proto_tree_add_expert (tree, pinfo, &ei_h264_bad_nal_length, tvb, offset-2, 2);
2161 proto_item_append_text(item, " Size of %d, Remaining %d",
2162 nal_unit_size, tvb_reported_length_remaining(tvb, offset));
2163 offset += tvb_reported_length_remaining(tvb, offset);
2167 /* Make a new subset of the existing buffer for the NAL unit */
2168 nalu_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset), nal_unit_size);
2169 /* Decode the NAL unit */
2170 dissect_h264(nalu_tvb, pinfo, tree);
2171 offset += nal_unit_size;
2177 * RFC 3984 Section 5.7.2 Multi-Time Aggregation Packet (MTAP)
2180 dissect_h264_mtap(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset, gint8 nal_type)
2183 guint16 nal_unit_size;
2187 /* Get the DON base value for type MTAP16 & MTAP24 */
2188 proto_tree_add_item(tree, hf_h264_don, tvb, offset, 2, ENC_NA);
2191 while (tvb_reported_length_remaining(tvb, offset) > 0)
2193 proto_tree_add_item(tree, hf_h264_nalu_size, tvb, offset, 2, ENC_NA);
2194 nal_unit_size = tvb_get_ntohs(tvb, offset);
2195 size_offset = offset;
2197 proto_tree_add_item(tree, hf_h264_dond, tvb, offset, 1, ENC_NA);
2200 if (nal_type == H264_MTAP16)
2202 /* Get the 16 bit DOND value */
2203 proto_tree_add_item(tree, hf_h264_ts_offset16, tvb, offset, 2, ENC_NA);
2208 /* Get the 24 bit DOND value */
2209 proto_tree_add_item(tree, hf_h264_ts_offset24, tvb, offset, 2, ENC_NA);
2213 if (nal_unit_size == 0 || tvb_reported_length_remaining(tvb, offset) < nal_unit_size)
2215 /* Throw an exception if the size is wrong and don't try to decode the rest of the packet. */
2216 col_append_fstr(pinfo->cinfo, COL_INFO, " [Bad NAL Length]");
2217 item = proto_tree_add_expert (tree, pinfo, &ei_h264_bad_nal_length, tvb, size_offset, 2);
2218 proto_item_append_text(item, " Size of %d, Remaining %d",
2219 nal_unit_size, tvb_reported_length_remaining(tvb, offset));
2220 offset += tvb_reported_length_remaining(tvb, offset);
2224 /* Make a new subset of the existing buffer for the NAL unit */
2225 nalu_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset), nal_unit_size);
2226 /* Decode the NAL unit */
2227 dissect_h264(nalu_tvb, pinfo, tree);
2228 offset += nal_unit_size;
2234 * Dissect NAL Header extension and NI-MTAP Subtype defined in RFC 6190
2237 dissect_h264_nalu_extension (proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset)
2240 guint16 nal_unit_size;
2244 guint8 bit_offset = offset << 3;
2248 subtype = tvb_get_bits8(tvb, bit_offset, 5);
2249 j_flag = tvb_get_bits8(tvb, bit_offset+5, 1);
2251 /* NAL Header Extension Decoding */
2252 proto_tree_add_item(tree, hf_h264_nal_extension_subtype, tvb, offset, 1, ENC_NA);
2253 proto_tree_add_item(tree, hf_h264_nal_extension_j, tvb, offset, 1, ENC_NA);
2254 proto_tree_add_item(tree, hf_h264_nal_extension_k, tvb, offset, 1, ENC_NA);
2255 proto_tree_add_item(tree, hf_h264_nal_extension_l, tvb, offset, 1, ENC_NA);
2256 col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
2257 val_to_str(subtype, h264_subtype_summary_values, "Unknown Subtype (%u)"));
2262 /* Multi-Time Aggregation Packet (NI-MTAP) - RFC 6190 Section 4.7.1 */
2263 while (tvb_reported_length_remaining(tvb, offset) > 0)
2265 proto_tree_add_text(tree, tvb, offset, 1, "NI-MTAP Unit %d", unit++);
2266 proto_tree_add_item(tree, hf_h264_nalu_size, tvb, offset, 2, ENC_NA);
2267 nal_unit_size = tvb_get_ntohs(tvb, offset);
2268 size_offset = offset;
2270 proto_tree_add_item(tree, hf_h264_ts_offset16, tvb, offset, 2, ENC_NA);
2272 /* If J flag is set then DON is present in packet */
2275 proto_tree_add_item(tree, hf_h264_don, tvb, offset, 2, ENC_NA);
2278 if (nal_unit_size == 0 || tvb_reported_length_remaining(tvb, offset) < nal_unit_size)
2280 /* Throw an exception if the size is wrong and don't try to decode the rest of the packet. */
2281 col_append_fstr(pinfo->cinfo, COL_INFO, " [Bad NAL Length]");
2282 item = proto_tree_add_expert (tree, pinfo, &ei_h264_bad_nal_length, tvb, size_offset, 2);
2283 proto_item_append_text(item, " Size of %d, Remaining %d",
2284 nal_unit_size, tvb_reported_length_remaining(tvb, offset));
2285 offset += tvb_reported_length_remaining(tvb, offset);
2289 /* Make a new subset of the existing buffer for the NAL unit */
2290 nalu_tvb = tvb_new_subset(tvb, offset, tvb_captured_length_remaining(tvb, offset), nal_unit_size);
2291 /* Decode the NAL unit */
2292 dissect_h264(nalu_tvb, pinfo, tree);
2293 offset += nal_unit_size;
2300 * Dissect NAL unit as received in sprop-parameter-sets of SDP
2301 * or "DecoderConfiguration parameter in H.245
2304 dissect_h264_nal_unit(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
2307 proto_tree *h264_nal_tree;
2309 guint8 nal_unit_type;
2312 item = proto_tree_add_item(tree, hf_h264_nal_unit, tvb, offset, -1, ENC_NA);
2313 h264_nal_tree = proto_item_add_subtree(item, ett_h264_nal_unit);
2316 /* In decoder configuration start code may be pressent
2317 * B.1.1 Byte stream NAL unit syntax
2319 dword = tvb_get_bits32(tvb, offset<<3, 32, ENC_BIG_ENDIAN);
2321 /* zero_byte + start_code_prefix_one_3bytes */
2323 } else if ((dword >> 8) == 1) {
2324 /* start_code_prefix_one_3bytes */
2327 /* Ref: 7.3.1 NAL unit syntax */
2328 nal_unit_type = tvb_get_guint8(tvb, offset) & 0x1f;
2330 /* forbidden_zero_bit All f(1) */
2331 proto_tree_add_item(h264_nal_tree, hf_h264_forbidden_zero_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
2332 /* nal_ref_idc All u(2) */
2333 proto_tree_add_item(h264_nal_tree, hf_h264_nal_ref_idc, tvb, offset, 1, ENC_BIG_ENDIAN);
2334 /* nal_unit_type All u(5) */
2335 proto_tree_add_item(h264_nal_tree, hf_h264_nal_unit_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2338 switch (nal_unit_type) {
2339 case 1: /* Coded slice of a non-IDR picture */
2340 dissect_h264_slice_layer_without_partitioning_rbsp(h264_nal_tree, tvb, pinfo, offset);
2342 case 2: /* Coded slice data partition A */
2343 dissect_h264_slice_data_partition_a_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
2345 case 3: /* Coded slice data partition B */
2346 dissect_h264_slice_data_partition_b_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
2348 case 4: /* Coded slice data partition C */
2349 dissect_h264_slice_data_partition_c_layer_rbsp(h264_nal_tree, tvb, pinfo, offset);
2351 case 5: /* Coded slice of an IDR picture */
2352 dissect_h264_slice_layer_without_partitioning_rbsp(h264_nal_tree, tvb, pinfo, offset);
2354 case 6: /* Supplemental enhancement information (SEI) */
2355 dissect_h264_sei_rbsp(h264_nal_tree, tvb, pinfo, offset);
2357 case H264_SEQ_PAR_SET: /* 7 Sequence parameter set*/
2358 offset = dissect_h264_seq_parameter_set_rbsp(h264_nal_tree, tvb, pinfo, offset);
2360 if ((offset != -1) && (tvb_length_remaining(tvb, offset) > 0)) {
2361 /* In this case length = offset as we start from zero */
2362 proto_item_set_len(item, offset/*Length */);
2363 item = proto_tree_add_item(tree, hf_h264_nal_unit, tvb, offset, -1, ENC_NA);
2364 h264_nal_tree = proto_item_add_subtree(item, ett_h264_nal_unit);
2368 case H264_PIC_PAR_SET: /* 8 Picture parameter set */
2369 dissect_h264_pic_parameter_set_rbsp(h264_nal_tree, tvb, pinfo, offset);
2371 case 9: /* Access unit delimiter */
2372 dissect_h264_access_unit_delimiter_rbsp(h264_nal_tree, tvb, pinfo, offset);
2374 case 10: /* End of sequence */
2375 dissect_h264_end_of_seq_rbsp(h264_nal_tree, tvb, pinfo, offset);
2377 case 11: /* End of stream */
2378 dissect_h264_end_of_stream_rbsp(h264_nal_tree, tvb, pinfo, offset);
2380 case 12: /* Filler data */
2381 dissect_h264_filler_data_rbsp(h264_nal_tree, tvb, pinfo, offset);
2383 case 13: /* Sequence parameter set extension */
2384 dissect_h264_seq_parameter_set_extension_rbsp(h264_nal_tree, tvb, pinfo, offset);
2386 case 14: /* Reserved */
2387 case 15: /* Reserved */
2388 case 16: /* Reserved */
2389 case 17: /* Reserved */
2390 case 18: /* Reserved */
2391 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Reserved NAL unit type");
2393 case 19: /* Coded slice of an auxiliary coded picture without partitioning */
2394 dissect_h264_slice_layer_without_partitioning_rbsp(tree, tvb, pinfo, offset);
2397 dissect_h264_slice_layer_without_partitioning_rbsp(tree, tvb, pinfo, offset);
2399 case 0: /* Unspecified */
2401 /* 24..31 Unspecified */
2402 proto_tree_add_text(h264_nal_tree, tvb, offset, -1, "Unspecified NAL unit type");
2407 /* Code to actually dissect the packets */
2409 dissect_h264(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2413 proto_tree *h264_tree, *h264_nal_tree, *stream_tree, *fua_tree;
2418 /* Make entries in Protocol column and Info column on summary display */
2419 col_set_str(pinfo->cinfo, COL_PROTOCOL, "H264");
2421 type = tvb_get_guint8(tvb, offset)&0x1f;
2423 col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
2424 val_to_str(type, h264_type_summary_values, "Unknown Type (%u)"));
2427 item = proto_tree_add_item(tree, proto_h264, tvb, 0, -1, ENC_NA);
2428 h264_tree = proto_item_add_subtree(item, ett_h264);
2430 /* if the type is 28, it would be draw another title */
2432 h264_nal_tree = proto_tree_add_subtree(h264_tree, tvb, offset, 1, ett_h264_nal, NULL, "FU identifier");
2434 h264_nal_tree = proto_tree_add_subtree(h264_tree, tvb, offset, 1, ett_h264_nal, NULL, "NAL unit header or first byte of the payload");
2436 /* +---------------+
2444 * forbidden_zero_bit. A value of 0 indicates that the NAL unit type
2445 * octet and payload should not contain bit errors or other syntax
2446 * violations. A value of 1 indicates that the NAL unit type octet
2447 * and payload may contain bit errors or other syntax violations.
2449 proto_tree_add_item(h264_nal_tree, hf_h264_nal_f_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
2450 proto_tree_add_item(h264_nal_tree, hf_h264_nal_nri, tvb, offset, 1, ENC_BIG_ENDIAN);
2452 proto_tree_add_item(h264_nal_tree, hf_h264_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2455 fua_tree = proto_tree_add_subtree(h264_tree, tvb, offset, 1, ett_h264_fua, NULL, "FU Header");
2456 proto_tree_add_item(fua_tree, hf_h264_start_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
2457 proto_tree_add_item(fua_tree, hf_h264_end_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
2458 proto_tree_add_item(fua_tree, hf_h264_forbidden_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
2459 proto_tree_add_item(fua_tree, hf_h264_nal_unit_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2460 if ((tvb_get_guint8(tvb, offset)&0x80) == 0x80) {
2461 type = tvb_get_guint8(tvb, offset)&0x1f;
2462 col_append_fstr(pinfo->cinfo, COL_INFO, " Start:%s",
2463 val_to_str(type, h264_type_summary_values, "Unknown Type (%u)"));
2468 if ((tvb_get_guint8(tvb, offset)&0x40) == 0x40) {
2469 col_append_fstr(pinfo->cinfo, COL_INFO, " End");
2475 /* Unescape NAL unit */
2476 rbsp_tvb = dissect_h265_unescap_nal_unit(tvb, pinfo, offset);
2478 stream_tree = proto_tree_add_subtree(h264_tree, tvb, offset, -1, ett_h264_stream, NULL, "H264 NAL Unit Payload");
2480 case 1: /* 1 Coded slice of a non-IDR picture */
2481 dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
2483 case 3: /* Coded slice data partition B */
2484 dissect_h264_slice_data_partition_b_layer_rbsp(h264_nal_tree, rbsp_tvb, pinfo, 0);
2486 case 4: /* Coded slice data partition C */
2487 dissect_h264_slice_data_partition_c_layer_rbsp(h264_nal_tree, rbsp_tvb, pinfo, 0);
2489 case 5: /* Coded slice of an IDR picture */
2490 dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
2492 case 6: /* Supplemental enhancement information (SEI) */
2493 dissect_h264_sei_rbsp(stream_tree, tvb, pinfo, offset);
2495 case H264_SEQ_PAR_SET: /* 7 Sequence parameter set*/
2496 dissect_h264_seq_parameter_set_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
2498 case H264_PIC_PAR_SET: /* 8 Picture parameter set */
2499 dissect_h264_pic_parameter_set_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
2502 dissect_h264_prefix(stream_tree, rbsp_tvb, pinfo, 0);
2504 case 19: /* Coded slice of an auxiliary coded picture without partitioning */
2505 dissect_h264_slice_layer_without_partitioning_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
2507 case H264_STAP_A: /* STAP-A */
2508 case H264_STAP_B: /* STAP-B */
2509 dissect_h264_stap(stream_tree, tvb, pinfo, offset, type);
2511 case H264_MTAP16: /* MSTAP16 */
2512 case H264_MTAP24: /* MSTAP24 */
2513 dissect_h264_mtap(stream_tree, tvb, pinfo, offset, type);
2515 case H264_PACSI: /* PACSI */
2516 dissect_h264_pacsi(stream_tree, tvb, pinfo, offset);
2518 case H264_EXTENSION: /* Extension Header */
2519 dissect_h264_nalu_extension(stream_tree, rbsp_tvb, pinfo, 0);
2530 static const int *profile_fields[] = {
2531 &hf_h264_par_profile_b,
2532 &hf_h264_par_profile_m,
2533 &hf_h264_par_profile_e,
2534 &hf_h264_par_profile_h,
2535 &hf_h264_par_profile_h10,
2536 &hf_h264_par_profile_h4_2_2,
2537 &hf_h264_par_profile_h4_4_4,
2542 dissect_h264_par_profile(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
2546 proto_tree_add_bitmask(tree, tvb, offset,
2547 hf_h264_par_profile, ett_h264_par_profile,
2548 profile_fields, ENC_BIG_ENDIAN);
2553 static const int *AdditionalModesSupported_fields[] = {
2554 &hf_h264_par_add_mode_sup_rcdo,
2559 dissect_h264_par_AdditionalModesSupported(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
2563 proto_tree_add_bitmask(tree, tvb, offset,
2564 hf_h264_par_AdditionalModesSupported, ett_h264_par_AdditionalModesSupported,
2565 AdditionalModesSupported_fields, ENC_BIG_ENDIAN);
2571 static const int *ProfileIOP_fields[] = {
2572 &hf_h264_par_constraint_set0_flag,
2573 &hf_h264_par_constraint_set1_flag,
2574 &hf_h264_par_constraint_set2_flag,
2580 dissect_h264_ProfileIOP(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
2584 proto_tree_add_bitmask(tree, tvb, offset,
2585 hf_h264_par_ProfileIOP, ett_h264_par_ProfileIOP,
2586 ProfileIOP_fields, ENC_BIG_ENDIAN);
2591 static const value_string h264_par_level_values[] = {
2612 dissect_h264_par_level(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, void *data)
2619 /* Reject the packet if data is NULL */
2622 actx = get_asn1_ctx(data);
2623 DISSECTOR_ASSERT(actx);
2625 lvl = tvb_get_ntohs(tvb, offset);
2626 p = try_val_to_str(lvl, VALS(h264_par_level_values));
2628 proto_item_append_text(actx->created_item, " - Level %s", p);
2635 dissect_h264_par_DecoderConfigurationInformation(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
2639 /* Reject the packet if data is NULL */
2642 actx = get_asn1_ctx(data);
2643 DISSECTOR_ASSERT(actx);
2645 dissect_h264_nal_unit(tvb, pinfo, tree);
2647 return tvb_length(tvb);
2650 typedef struct _h264_capability_t {
2653 new_dissector_t content_pdu;
2654 } h264_capability_t;
2656 static h264_capability_t h264_capability_tab[] = {
2657 /* ITU-T H.241 (05/2006), 8.3 H.264 capabilities */
2658 { "GenericCapability/0.0.8.241.0.0.1", "ITU-T Rec. H.241 H.264 Video Capabilities", NULL },
2659 { "GenericCapability/0.0.8.241.0.0.1/collapsing/41", "Profile", dissect_h264_par_profile },
2660 { "GenericCapability/0.0.8.241.0.0.1/collapsing/42", "Level", dissect_h264_par_level },
2661 { "GenericCapability/0.0.8.241.0.0.1/collapsing/3" , "CustomMaxMBPS", NULL },
2662 { "GenericCapability/0.0.8.241.0.0.1/collapsing/4" , "CustomMaxFS", NULL },
2663 { "GenericCapability/0.0.8.241.0.0.1/collapsing/5" , "CustomMaxDPB", NULL },
2664 { "GenericCapability/0.0.8.241.0.0.1/collapsing/6" , "CustomMaxBRandCPB", NULL },
2665 { "GenericCapability/0.0.8.241.0.0.1/collapsing/7" , "MaxStaticMBPS", NULL },
2666 { "GenericCapability/0.0.8.241.0.0.1/collapsing/8" , "max-rcmd-nal-unit-size", NULL },
2667 { "GenericCapability/0.0.8.241.0.0.1/collapsing/9" , "max-nal-unit-size", NULL },
2668 { "GenericCapability/0.0.8.241.0.0.1/collapsing/10", "SampleAspectRatiosSupported", NULL },
2669 { "GenericCapability/0.0.8.241.0.0.1/collapsing/11", "AdditionalModesSupported", dissect_h264_par_AdditionalModesSupported },
2670 { "GenericCapability/0.0.8.241.0.0.1/collapsing/12", "AdditionalDisplayCapabilities", NULL },
2671 /* TS 26.111 H.264 */
2672 { "GenericCapability/0.0.8.241.0.0.1/nonCollapsing/43" , "DecoderConfigurationInformation", dissect_h264_par_DecoderConfigurationInformation },
2673 { "GenericCapability/0.0.8.241.0.0.1/collapsing/44" , "AcceptRedundantSlices", NULL },
2674 { "GenericCapability/0.0.8.241.0.0.1/collapsing/45" , "NalAlignedMode", NULL },
2675 { "GenericCapability/0.0.8.241.0.0.1/collapsing/46" , "ProfileIOP", dissect_h264_ProfileIOP },
2676 { NULL, NULL, NULL },
2679 static h264_capability_t *find_cap(const gchar *id) {
2680 h264_capability_t *ftr = NULL;
2681 h264_capability_t *f;
2683 for (f=h264_capability_tab; f->id; f++) {
2684 if (!strcmp(id, f->id)) { ftr = f; break; }
2690 dissect_h264_name(tvbuff_t *tvb _U_, packet_info *pinfo, proto_tree *tree, void* data)
2694 /* Reject the packet if data is NULL */
2697 actx = get_asn1_ctx(data);
2698 DISSECTOR_ASSERT(actx);
2701 h264_capability_t *ftr;
2702 ftr = find_cap(pinfo->match_string);
2704 proto_item_append_text(actx->created_item, " - %s", ftr->name);
2705 proto_item_append_text(proto_item_get_parent(proto_tree_get_parent(tree)), ": %s", ftr->name);
2707 proto_item_append_text(actx->created_item, " - unknown(%s)", pinfo->match_string);
2711 return tvb_length(tvb);
2715 static void range_delete_h264_rtp_pt_callback(guint32 rtp_pt) {
2716 if (rtp_pt >= 96 && rtp_pt <= 127)
2717 dissector_delete_uint("rtp.pt", rtp_pt, h264_handle);
2720 static void range_add_h264_rtp_pt_callback(guint32 rtp_pt) {
2721 if (rtp_pt >= 96 && rtp_pt <= 127)
2722 dissector_add_uint("rtp.pt", rtp_pt, h264_handle);
2726 proto_register_h264(void)
2728 module_t *h264_module;
2729 expert_module_t* expert_h264;
2731 /* Setup list of header fields See Section 1.6.1 for details*/
2732 static hf_register_info hf[] = {
2733 { &hf_h264_nal_f_bit,
2734 { "F bit", "h264.f",
2735 FT_BOOLEAN, 8, TFS(&h264_f_bit_vals), 0x80,
2739 { "Nal_ref_idc (NRI)", "h264.nal_nri",
2740 FT_UINT8, BASE_DEC, NULL, 0x60,
2744 { "Type", "h264.nal_unit_hdr",
2745 FT_UINT8, BASE_DEC, VALS(h264_type_values), 0x1f,
2748 { &hf_h264_start_bit,
2749 { "Start bit", "h264.start.bit",
2750 FT_BOOLEAN, 8, TFS(&h264_start_bit_vals), 0x80,
2754 { "End bit", "h264.end.bit",
2755 FT_BOOLEAN, 8, TFS(&h264_end_bit_vals), 0x40,
2758 { &hf_h264_forbidden_bit,
2759 { "Forbidden bit", "h264.forbidden.bit",
2760 FT_UINT8, BASE_DEC, NULL, 0x20,
2764 { "Profile", "h264.profile",
2765 FT_BYTES, BASE_NONE, NULL, 0x0,
2768 { &hf_h264_profile_idc,
2769 { "Profile_idc", "h264.profile_idc",
2770 FT_UINT8, BASE_DEC, VALS(h264_profile_idc_values), 0xff,
2773 { &hf_h264_rbsp_stop_bit,
2774 { "rbsp_stop_bit", "h264.rbsp_stop_bit",
2775 FT_UINT8, BASE_DEC, NULL, 0x0,
2778 { &hf_h264_rbsp_trailing_bits,
2779 { "rbsp_trailing_bits", "h264.rbsp_trailing_bits",
2780 FT_UINT8, BASE_DEC, NULL, 0x0,
2783 { &hf_h264_constraint_set0_flag,
2784 { "Constraint_set0_flag", "h264.constraint_set0_flag",
2785 FT_UINT8, BASE_DEC, NULL, 0x80,
2788 { &hf_h264_constraint_set1_flag,
2789 { "Constraint_set1_flag", "h264.constraint_set1_flag",
2790 FT_UINT8, BASE_DEC, NULL, 0x40,
2793 { &hf_h264_constraint_set2_flag,
2794 { "Constraint_set2_flag", "h264.constraint_set2_flag",
2795 FT_UINT8, BASE_DEC, NULL, 0x20,
2798 { &hf_h264_constraint_set3_flag,
2799 { "Constraint_set3_flag", "h264.constraint_set3_flag",
2800 FT_UINT8, BASE_DEC, NULL, 0x10,
2803 { &hf_h264_constraint_set4_flag,
2804 { "Constraint_set4_flag", "h264.constraint_set4_flag",
2805 FT_UINT8, BASE_DEC, NULL, 0x08,
2808 { &hf_h264_constraint_set5_flag,
2809 { "Constraint_set5_flag", "h264.constraint_set5_flag",
2810 FT_UINT8, BASE_DEC, NULL, 0x04,
2813 { &hf_h264_reserved_zero_2bits,
2814 { "Reserved_zero_2bits", "h264.reserved_zero_2bits",
2815 FT_UINT8, BASE_DEC, NULL, 0x03,
2818 { &hf_h264_level_idc,
2819 { "Level_id", "h264.level_id",
2820 FT_UINT8, BASE_DEC, NULL, 0xff,
2823 { &hf_h264_nal_unit,
2824 { "NAL unit", "h264.nal_unit",
2825 FT_BYTES, BASE_NONE, NULL, 0x0,
2828 { &hf_h264_forbidden_zero_bit,
2829 { "Forbidden_zero_bit", "h264.forbidden_zero_bit",
2830 FT_UINT8, BASE_DEC, NULL, 0x80,
2833 { &hf_h264_nal_ref_idc,
2834 { "Nal_ref_idc", "h264.nal_ref_idc",
2835 FT_UINT8, BASE_DEC, NULL, 0x60,
2838 {&hf_h264_nal_unit_type,
2839 { "Nal_unit_type", "h264.nal_unit_type",
2840 FT_UINT8, BASE_DEC, VALS(h264_nal_unit_type_vals), 0x1f,
2843 { &hf_h264_seq_parameter_set_id,
2844 { "seq_parameter_set_id", "h264.seq_parameter_set_id",
2845 FT_UINT32, BASE_DEC, NULL, 0x0,
2848 { &hf_h264_chroma_format_idc,
2849 { "chroma_format_id", "h264.chroma_format_id",
2850 FT_UINT32, BASE_DEC, NULL, 0x0,
2853 { &hf_h264_residual_colour_transform_flag,
2854 { "residual_colour_transform_flag", "h264.residual_colour_transform_flag",
2855 FT_UINT8, BASE_DEC, NULL, 0x0,
2858 { &hf_h264_bit_depth_luma_minus8,
2859 { "bit_depth_luma_minus8", "h264.bit_depth_luma_minus8",
2860 FT_UINT32, BASE_DEC, NULL, 0x0,
2863 { &hf_h264_bit_depth_chroma_minus8,
2864 { "bit_depth_chroma_minus8", "h264.bit_depth_chroma_minus8",
2865 FT_UINT32, BASE_DEC, NULL, 0x0,
2868 { &hf_h264_qpprime_y_zero_transform_bypass_flag,
2869 { "qpprime_y_zero_transform_bypass_flag", "h264.qpprime_y_zero_transform_bypass_flag",
2870 FT_UINT32, BASE_DEC, NULL, 0x0,
2873 { &hf_h264_seq_scaling_matrix_present_flag,
2874 { "seq_scaling_matrix_present_flag", "h264.seq_scaling_matrix_present_flag",
2875 FT_UINT32, BASE_DEC, NULL, 0x0,
2878 { &hf_h264_log2_max_frame_num_minus4,
2879 { "log2_max_frame_num_minus4", "h264.log2_max_frame_num_minus4",
2880 FT_UINT32, BASE_DEC, NULL, 0x0,
2883 { &hf_h264_pic_order_cnt_type,
2884 { "pic_order_cnt_type", "h264.pic_order_cnt_type",
2885 FT_UINT32, BASE_DEC, NULL, 0x0,
2888 { &hf_h264_log2_max_pic_order_cnt_lsb_minus4,
2889 { "log2_max_pic_order_cnt_lsb_minus4", "h264.log2_max_pic_order_cnt_lsb_minus4",
2890 FT_UINT32, BASE_DEC, NULL, 0x0,
2893 { &hf_h264_delta_pic_order_always_zero_flag,
2894 { "delta_pic_order_always_zero_flag", "h264.delta_pic_order_always_zero_flag",
2895 FT_UINT8, BASE_DEC, NULL, 0x0,
2898 { &hf_h264_offset_for_non_ref_pic,
2899 { "offset_for_non_ref_pic", "h264.offset_for_non_ref_pic",
2900 FT_INT32, BASE_DEC, NULL, 0x0,
2903 { &hf_h264_offset_for_top_to_bottom_field,
2904 { "offset_for_top_to_bottom_field", "h264.offset_for_top_to_bottom_field",
2905 FT_INT32, BASE_DEC, NULL, 0x0,
2908 { &hf_h264_num_ref_frames_in_pic_order_cnt_cycle,
2909 { "num_ref_frames_in_pic_order_cnt_cycle", "h264.num_ref_frames_in_pic_order_cnt_cycle",
2910 FT_UINT32, BASE_DEC, NULL, 0x0,
2913 { &hf_h264_offset_for_ref_frame,
2914 { "offset_for_ref_frame", "h264.offset_for_ref_frame",
2915 FT_INT32, BASE_DEC, NULL, 0x0,
2918 { &hf_h264_num_ref_frames,
2919 { "num_ref_frames", "h264.num_ref_frames",
2920 FT_UINT32, BASE_DEC, NULL, 0x0,
2923 { &hf_h264_gaps_in_frame_num_value_allowed_flag,
2924 { "gaps_in_frame_num_value_allowed_flag", "h264.gaps_in_frame_num_value_allowed_flag",
2925 FT_UINT8, BASE_DEC, NULL, 0x0,
2928 { &hf_h264_pic_width_in_mbs_minus1,
2929 { "pic_width_in_mbs_minus1", "h264.pic_width_in_mbs_minus1",
2930 FT_UINT32, BASE_DEC, NULL, 0x0,
2933 { &hf_h264_pic_height_in_map_units_minus1,
2934 { "pic_height_in_map_units_minus1", "h264.pic_height_in_map_units_minus1",
2935 FT_UINT32, BASE_DEC, NULL, 0x0,
2938 { &hf_h264_frame_mbs_only_flag,
2939 { "frame_mbs_only_flag", "h264.frame_mbs_only_flag",
2940 FT_UINT8, BASE_DEC, NULL, 0x0,
2943 { &hf_h264_mb_adaptive_frame_field_flag,
2944 { "mb_adaptive_frame_field_flag", "h264.mb_adaptive_frame_field_flag",
2945 FT_UINT8, BASE_DEC, NULL, 0x0,
2948 { &hf_h264_direct_8x8_inference_flag,
2949 { "direct_8x8_inference_flag", "h264.direct_8x8_inference_flag",
2950 FT_UINT8, BASE_DEC, NULL, 0x0,
2953 { &hf_h264_frame_cropping_flag,
2954 { "frame_cropping_flag", "h264.frame_cropping_flag",
2955 FT_UINT8, BASE_DEC, NULL, 0x0,
2958 { &hf_h264_frame_crop_left_offset,
2959 { "frame_crop_left_offset", "h264.frame_crop_left_offset",
2960 FT_UINT32, BASE_DEC, NULL, 0x0,
2963 { &hf_h264_frame_crop_right_offset,
2964 { "frame_crop_left_offset", "h264.frame_crop_right_offset",
2965 FT_UINT32, BASE_DEC, NULL, 0x0,
2968 { &hf_h264_frame_crop_top_offset,
2969 { "frame_crop_top_offset", "h264.frame_crop_top_offset",
2970 FT_UINT32, BASE_DEC, NULL, 0x0,
2973 { &hf_h264_frame_crop_bottom_offset,
2974 { "frame_crop_bottom_offset", "h264.frame_crop_bottom_offset",
2975 FT_UINT32, BASE_DEC, NULL, 0x0,
2978 { &hf_h264_vui_parameters_present_flag,
2979 { "vui_parameters_present_flag", "h264.vui_parameters_present_flag",
2980 FT_UINT8, BASE_DEC, NULL, 0x0,
2983 { &hf_h264_pic_parameter_set_id,
2984 { "pic_parameter_set_id", "h264.pic_parameter_set_id",
2985 FT_UINT32, BASE_DEC, NULL, 0x0,
2988 { &hf_h264_entropy_coding_mode_flag,
2989 { "entropy_coding_mode_flag", "h264.entropy_coding_mode_flag",
2990 FT_UINT8, BASE_DEC, NULL, 0x0,
2993 { &hf_h264_pic_order_present_flag,
2994 { "pic_order_present_flag", "h264.pic_order_present_flag",
2995 FT_UINT8, BASE_DEC, NULL, 0x0,
2998 { &hf_h264_num_slice_groups_minus1,
2999 { "num_slice_groups_minus1", "h264.num_slice_groups_minus1",
3000 FT_UINT32, BASE_DEC, NULL, 0x0,
3003 { &hf_h264_slice_group_map_type,
3004 { "slice_group_map_type", "h264.slice_group_map_type",
3005 FT_UINT32, BASE_DEC, VALS(h264_slice_group_map_type_vals), 0x0,
3008 { &hf_h264_num_ref_idx_l0_active_minus1,
3009 { "num_ref_idx_l0_active_minus1", "h264.num_ref_idx_l0_active_minus1",
3010 FT_UINT32, BASE_DEC, NULL, 0x0,
3013 { &hf_h264_num_ref_idx_l1_active_minus1,
3014 { "num_ref_idx_l1_active_minus1", "h264.num_ref_idx_l1_active_minus1",
3015 FT_UINT32, BASE_DEC, NULL, 0x0,
3018 { &hf_h264_weighted_pred_flag,
3019 { "weighted_pred_flag", "h264.weighted_pred_flag",
3020 FT_UINT8, BASE_DEC, NULL, 0x0,
3023 { &hf_h264_weighted_bipred_idc,
3024 { "weighted_bipred_idc", "h264.weighted_bipred_idc",
3025 FT_UINT8, BASE_DEC, NULL, 0x0,
3028 { &hf_h264_pic_init_qp_minus26,
3029 { "pic_init_qp_minus26", "h264.pic_init_qp_minus26",
3030 FT_INT32, BASE_DEC, NULL, 0x0,
3033 { &hf_h264_pic_init_qs_minus26,
3034 { "pic_init_qs_minus26", "h264.pic_init_qs_minus26",
3035 FT_INT32, BASE_DEC, NULL, 0x0,
3038 { &hf_h264_chroma_qp_index_offset,
3039 { "chroma_qp_index_offset", "h264.chroma_qp_index_offset",
3040 FT_INT32, BASE_DEC, NULL, 0x0,
3043 { &hf_h264_deblocking_filter_control_present_flag,
3044 { "deblocking_filter_control_present_flag", "h264.deblocking_filter_control_present_flag",
3045 FT_UINT8, BASE_DEC, NULL, 0x0,
3048 { &hf_h264_constrained_intra_pred_flag,
3049 { "constrained_intra_pred_flag", "h264.constrained_intra_pred_flag",
3050 FT_UINT8, BASE_DEC, NULL, 0x0,
3053 { &hf_h264_redundant_pic_cnt_present_flag,
3054 { "redundant_pic_cnt_present_flag", "h264.redundant_pic_cnt_present_flag",
3055 FT_UINT8, BASE_DEC, NULL, 0x0,
3058 { &hf_h264_transform_8x8_mode_flag,
3059 { "transform_8x8_mode_flag", "h264.transform_8x8_mode_flag",
3060 FT_UINT8, BASE_DEC, NULL, 0x0,
3063 { &hf_h264_pic_scaling_matrix_present_flag,
3064 { "pic_scaling_matrix_present_flag", "h264.pic_scaling_matrix_present_flag",
3065 FT_UINT8, BASE_DEC, NULL, 0x0,
3068 { &hf_h264_second_chroma_qp_index_offset,
3069 { "second_chroma_qp_index_offset", "h264.second_chroma_qp_index_offset",
3070 FT_INT32, BASE_DEC, NULL, 0x0,
3074 { &hf_h264_aspect_ratio_info_present_flag,
3075 { "aspect_ratio_info_present_flag", "h264.aspect_ratio_info_present_flag",
3076 FT_UINT8, BASE_DEC, NULL, 0x0,
3079 { &hf_h264_aspect_ratio_idc,
3080 { "aspect_ratio_idc", "h264.aspect_ratio_idc",
3081 FT_UINT8, BASE_DEC, NULL, 0x0,
3084 { &hf_h264_sar_width,
3085 { "sar_width", "h264.sar_width",
3086 FT_UINT16, BASE_DEC, NULL, 0x0,
3089 { &hf_h264_sar_height,
3090 { "sar_height", "h264.sar_height",
3091 FT_UINT16, BASE_DEC, NULL, 0x0,
3094 { &hf_h264_overscan_info_present_flag,
3095 { "overscan_info_present_flag", "h264.overscan_info_present_flag",
3096 FT_UINT8, BASE_DEC, NULL, 0x0,
3099 { &hf_h264_overscan_appropriate_flag,
3100 { "overscan_appropriate_flag", "h264.overscan_appropriate_flag",
3101 FT_UINT8, BASE_DEC, NULL, 0x0,
3104 { &hf_h264_video_signal_type_present_flag,
3105 { "video_signal_type_present_flag", "h264.video_signal_type_present_flag",
3106 FT_UINT8, BASE_DEC, NULL, 0x0,
3109 { &hf_h264_video_format,
3110 { "video_format", "h264.video_format",
3111 FT_UINT8, BASE_DEC, VALS(h264_video_format_vals), 0x0,
3114 { &hf_h264_video_full_range_flag,
3115 { "video_full_range_flag", "h264.video_full_range_flag",
3116 FT_UINT8, BASE_DEC, NULL, 0x0,
3119 { &hf_h264_colour_description_present_flag,
3120 { "colour_description_present_flag", "h264.colour_description_present_flag",
3121 FT_UINT8, BASE_DEC, NULL, 0x0,
3124 { &hf_h264_colour_primaries,
3125 { "colour_primaries", "h264.colour_primaries",
3126 FT_UINT8, BASE_DEC, NULL, 0x0,
3129 { &hf_h264_transfer_characteristics,
3130 { "transfer_characteristics", "h264.transfer_characteristics",
3131 FT_UINT8, BASE_DEC, NULL, 0x0,
3134 { &hf_h264_matrix_coefficients,
3135 { "matrix_coefficients", "h264.matrix_coefficients",
3136 FT_UINT8, BASE_DEC, NULL, 0x0,
3139 { &hf_h264_chroma_loc_info_present_flag,
3140 { "chroma_loc_info_present_flag", "h264.chroma_loc_info_present_flag",
3141 FT_UINT8, BASE_DEC, NULL, 0x0,
3144 { &hf_h264_chroma_sample_loc_type_top_field,
3145 { "chroma_sample_loc_type_top_field", "h264.chroma_sample_loc_type_top_field",
3146 FT_UINT32, BASE_DEC, NULL, 0x0,
3149 { &hf_h264_chroma_sample_loc_type_bottom_field,
3150 { "chroma_sample_loc_type_bottom_field", "h264.chroma_sample_loc_type_bottom_field",
3151 FT_UINT32, BASE_DEC, NULL, 0x0,
3154 { &hf_h264_timing_info_present_flag,
3155 { "timing_info_present_flag", "h264.timing_info_present_flag",
3156 FT_UINT8, BASE_DEC, NULL, 0x0,
3159 { &hf_h264_num_units_in_tick,
3160 { "num_units_in_tick", "h264.num_units_in_tick",
3161 FT_UINT32, BASE_DEC, NULL, 0x0,
3164 { &hf_h264_time_scale,
3165 { "time_scale", "h264.time_scale",
3166 FT_UINT32, BASE_DEC, NULL, 0x0,
3169 { &hf_h264_fixed_frame_rate_flag,
3170 { "fixed_frame_rate_flag", "h264.fixed_frame_rate_flag",
3171 FT_UINT8, BASE_DEC, NULL, 0x0,
3174 { &hf_h264_nal_hrd_parameters_present_flag,
3175 { "nal_hrd_parameters_present_flag", "h264.nal_hrd_parameters_present_flag",
3176 FT_UINT8, BASE_DEC, NULL, 0x0,
3179 { &hf_h264_vcl_hrd_parameters_present_flag,
3180 { "vcl_hrd_parameters_present_flag", "h264.vcl_hrd_parameters_present_flag",
3181 FT_UINT8, BASE_DEC, NULL, 0x0,
3184 { &hf_h264_low_delay_hrd_flag,
3185 { "low_delay_hrd_flag", "h264.low_delay_hrd_flag",
3186 FT_UINT8, BASE_DEC, NULL, 0x0,
3189 { &hf_h264_pic_struct_present_flag,
3190 { "pic_struct_present_flag", "h264.pic_struct_present_flag",
3191 FT_UINT8, BASE_DEC, NULL, 0x0,
3194 { &hf_h264_bitstream_restriction_flag,
3195 { "bitstream_restriction_flag", "h264.bitstream_restriction_flag",
3196 FT_UINT8, BASE_DEC, NULL, 0x0,
3199 { &hf_h264_motion_vectors_over_pic_boundaries_flag,
3200 { "motion_vectors_over_pic_boundaries_flag", "h264.motion_vectors_over_pic_boundaries_flag",
3201 FT_UINT32, BASE_DEC, NULL, 0x0,
3204 { &hf_h264_max_bytes_per_pic_denom,
3205 { "max_bytes_per_pic_denom", "h264.max_bytes_per_pic_denom",
3206 FT_UINT32, BASE_DEC, NULL, 0x0,
3209 { &hf_h264_max_bits_per_mb_denom,
3210 { "max_bits_per_mb_denom", "h264.max_bits_per_mb_denom",
3211 FT_UINT32, BASE_DEC, NULL, 0x0,
3214 { &hf_h264_log2_max_mv_length_horizontal,
3215 { "max_mv_length_horizontal", "h264.max_mv_length_horizontal",
3216 FT_UINT32, BASE_DEC, NULL, 0x0,
3219 { &hf_h264_log2_max_mv_length_vertical,
3220 { "log2_max_mv_length_vertical", "h264.log2_max_mv_length_vertical",
3221 FT_UINT32, BASE_DEC, NULL, 0x0,
3224 { &hf_h264_num_reorder_frames,
3225 { "num_reorder_frames", "h264.num_reorder_frames",
3226 FT_UINT32, BASE_DEC, NULL, 0x0,
3229 { &hf_h264_max_dec_frame_buffering,
3230 { "max_dec_frame_buffering", "h264.max_dec_frame_buffering",
3231 FT_UINT32, BASE_DEC, NULL, 0x0,
3234 { &hf_h264_cpb_cnt_minus1,
3235 { "cpb_cnt_minus1", "h264.cpb_cnt_minus1",
3236 FT_UINT32, BASE_DEC, NULL, 0x0,
3239 { &hf_h264_bit_rate_scale,
3240 { "bit_rate_scale", "h264.bit_rate_scale",
3241 FT_UINT8, BASE_DEC, NULL, 0x0,
3244 { &hf_h264_cpb_size_scale,
3245 { "cpb_size_scale", "h264.cpb_size_scale",
3246 FT_UINT8, BASE_DEC, NULL, 0x0,
3249 { &hf_h264_bit_rate_value_minus1,
3250 { "bit_rate_value_minus1", "h264.bit_rate_value_minus1",
3251 FT_UINT32, BASE_DEC, NULL, 0x0,
3254 { &hf_h264_cpb_size_value_minus1,
3255 { "cpb_size_value_minus1", "h264.cpb_size_value_minus1",
3256 FT_UINT32, BASE_DEC, NULL, 0x0,
3259 { &hf_h264_cbr_flag,
3260 { "cbr_flag", "h264.cbr_flag",
3261 FT_UINT8, BASE_DEC, NULL, 0x0,
3264 { &hf_h264_initial_cpb_removal_delay_length_minus1,
3265 { "initial_cpb_removal_delay_length_minus1", "h264.initial_cpb_removal_delay_length_minus1",
3266 FT_UINT8, BASE_DEC, NULL, 0x0,
3269 { &hf_h264_cpb_removal_delay_length_minus1,
3270 { "cpb_removal_delay_length_minus1", "h264.cpb_removal_delay_length_minus1",
3271 FT_UINT8, BASE_DEC, NULL, 0x0,
3274 { &hf_h264_dpb_output_delay_length_minus11,
3275 { "dpb_output_delay_length_minus11", "h264.dpb_output_delay_length_minus11",
3276 FT_UINT8, BASE_DEC, NULL, 0x0,
3279 { &hf_h264_time_offset_length,
3280 { "time_offset_length", "h264.time_offset_length",
3281 FT_UINT8, BASE_DEC, NULL, 0x0,
3284 { &hf_h264_first_mb_in_slice,
3285 { "first_mb_in_slice", "h264.first_mb_in_slice",
3286 FT_UINT32, BASE_DEC, NULL, 0x0,
3289 { &hf_h264_slice_type,
3290 { "slice_type", "h264.slice_type",
3291 FT_UINT32, BASE_DEC, VALS(h264_slice_type_vals), 0x0,
3294 { &hf_h264_slice_id,
3295 { "slice_id", "h264.slice_id",
3296 FT_UINT32, BASE_DEC, NULL, 0x0,
3299 { &hf_h264_payloadsize,
3300 { "PayloadSize", "h264.payloadsize",
3301 FT_UINT32, BASE_DEC, NULL, 0x0,
3304 { &hf_h264_payloadtype,
3305 { "payloadType", "h264.payloadtype",
3306 FT_UINT32, BASE_DEC, VALS(h264_sei_payload_vals), 0x0,
3310 { &hf_h264_frame_num,
3311 { "frame_num", "h264.frame_num",
3312 FT_UINT8, BASE_DEC, NULL, 0x0,
3316 { &hf_h264_par_profile,
3317 { "Profile", "h264.profile",
3318 FT_UINT8, BASE_HEX, NULL, 0x00,
3320 { &hf_h264_par_profile_b,
3321 { "Baseline Profile", "h264.profile.base",
3322 FT_BOOLEAN, 8, NULL, 0x40,
3324 { &hf_h264_par_profile_m,
3325 { "Main Profile", "h264.profile.main",
3326 FT_BOOLEAN, 8, NULL, 0x20,
3328 { &hf_h264_par_profile_e,
3329 { "Extended Profile.", "h264.profile.ext",
3330 FT_BOOLEAN, 8, NULL, 0x10,
3332 { &hf_h264_par_profile_h,
3333 { "High Profile", "h264.profile.high",
3334 FT_BOOLEAN, 8, NULL, 0x08,
3336 { &hf_h264_par_profile_h10,
3337 { "High 10 Profile", "h264.profile.high10",
3338 FT_BOOLEAN, 8, NULL, 0x04,
3340 { &hf_h264_par_profile_h4_2_2,
3341 { "High 4:2:2 Profile", "h264.profile.high4_2_2",
3342 FT_BOOLEAN, 8, NULL, 0x02,
3344 { &hf_h264_par_profile_h4_4_4,
3345 { "High 4:4:4 Profile", "h264.profile.high4_4_4",
3346 FT_BOOLEAN, 8, NULL, 0x01,
3348 { &hf_h264_par_AdditionalModesSupported,
3349 { "AdditionalModesSupported", "h264.AdditionalModesSupported",
3350 FT_UINT8, BASE_HEX, NULL, 0x00,
3353 { &hf_h264_par_add_mode_sup,
3354 { "Additional Modes Supported", "h264.add_mode_sup",
3355 FT_UINT8, BASE_HEX, NULL, 0x00,
3358 { &hf_h264_par_add_mode_sup_rcdo,
3359 { "Reduced Complexity Decoding Operation (RCDO) support", "h264.add_mode_sup.rcdo",
3360 FT_BOOLEAN, 8, NULL, 0x40,
3362 { &hf_h264_par_ProfileIOP,
3363 { "ProfileIOP", "h264.ProfileIOP",
3364 FT_UINT8, BASE_HEX, NULL, 0x00,
3366 { &hf_h264_par_constraint_set0_flag,
3367 { "constraint_set0_flag", "h264.par.constraint_set0_flag",
3368 FT_BOOLEAN, 8, NULL, 0x80,
3370 { &hf_h264_par_constraint_set1_flag,
3371 { "constraint_set1_flag", "h264.par.constraint_set1_flag",
3372 FT_BOOLEAN, 8, NULL, 0x40,
3374 { &hf_h264_par_constraint_set2_flag,
3375 { "constraint_set2_flag", "h264.par.constraint_set2_flag",
3376 FT_BOOLEAN, 8, NULL, 0x20,
3378 /* Packization Values */
3379 { &hf_h264_nalu_size,
3380 { "NAL Unit Size", "h264.nalu_size",
3381 FT_UINT16, BASE_DEC, NULL, 0x0,
3385 { "Decoder Order Number", "h264.don",
3386 FT_UINT16, BASE_DEC, NULL, 0x0,
3390 { "MTAP Decoder Order Number Delta", "h264.don_delta",
3391 FT_UINT8, BASE_DEC, NULL, 0x0,
3394 { &hf_h264_ts_offset16,
3395 { "MTAP TS Offset", "h264.ts_offset16",
3396 FT_UINT16, BASE_DEC, NULL, 0x0,
3399 { &hf_h264_ts_offset24,
3400 { "MTAP TS Offset", "h264.ts_offset24",
3401 FT_UINT24, BASE_DEC, NULL, 0x0,
3404 { &hf_h264_nal_extension_subtype,
3405 { "Extension Header Subtype", "h264.nal_hdr_extension.subtype",
3406 FT_UINT8, BASE_DEC, VALS(h264_subtype_values), 0xF8,
3409 { &hf_h264_nal_extension_j,
3410 { "Extension Header J - DON Present Indicator", "h264.nal_hdr_extension.j",
3411 FT_BOOLEAN, 8, NULL, 0x4,
3414 { &hf_h264_nal_extension_k,
3415 { "Extension Header K", "h264.nal_hdr_extension.k",
3416 FT_BOOLEAN, 8, NULL, 0x2,
3419 { &hf_h264_nal_extension_l,
3420 { "Extension Header L", "h264.nal_hdr_extension.l",
3421 FT_BOOLEAN, 8, NULL, 0x1,
3425 /* SEI Parsing values */
3426 { &hf_h264_sei_uuid,
3427 { "UUID", "h264.sei.uuid",
3428 FT_GUID, BASE_NONE, NULL, 0x0,
3431 { &hf_h264_sei_ms_lpb,
3432 { "Layer Presence", "h264.sei.ms.layout.lpb",
3433 FT_UINT8, BASE_HEX, NULL, 0x0,
3436 { &hf_h264_sei_ms_layout_p,
3437 { "Layer Description Present", "h264.sei.ms.layout.p",
3438 FT_BOOLEAN, 8, NULL, 0x01,
3441 { &hf_h264_sei_ms_layout_ldsize,
3442 { "Layer Description Size", "h264.sei.ms.layout.desc.ldsize",
3443 FT_UINT8, BASE_DEC, NULL, 0x0,
3446 { &hf_h264_sei_ms_layer_desc_coded_width,
3447 { "Coded Width", "h264.sei.ms.layout.desc.coded_width",
3448 FT_UINT8, BASE_DEC, NULL, 0x0,
3451 { &hf_h264_sei_ms_layer_desc_coded_height,
3452 { "Coded Height", "h264.sei.ms.layout.desc.coded_height",
3453 FT_UINT8, BASE_DEC, NULL, 0x0,
3456 { &hf_h264_sei_ms_layer_desc_display_width,
3457 { "Display Width", "h264.sei.ms.layout.desc.display_width",
3458 FT_UINT8, BASE_DEC, NULL, 0x0,
3461 { &hf_h264_sei_ms_layer_desc_display_height,
3462 { "Display Height", "h264.sei.ms.layout.desc.display_height",
3463 FT_UINT8, BASE_DEC, NULL, 0x0,
3466 { &hf_h264_sei_ms_layer_desc_bitrate,
3467 { "Bitrate", "h264.sei.ms.layout.desc.bitrate",
3468 FT_UINT32, BASE_DEC, NULL, 0x0,
3471 { &hf_h264_sei_ms_layer_desc_frame_rate,
3472 { "Frame Rate Index", "h264.sei.ms.layout.desc.frame_rate",
3473 FT_UINT8, BASE_DEC, VALS(h264_sei_ms_frame_values), 0xF8,
3476 { &hf_h264_sei_ms_layer_desc_layer_type,
3477 { "Layer Type", "h264.sei.ms.layout.desc.layer_type",
3478 FT_UINT8, BASE_DEC, NULL, 0x07,
3481 { &hf_h264_sei_ms_layer_desc_prid,
3482 { "Priority ID", "h264.sei.ms.layout.desc.prid",
3483 FT_UINT8, BASE_DEC, NULL, 0xFC,
3486 { &hf_h264_sei_ms_layer_desc_cb,
3487 { "Constrained Baseline", "h264.sei.ms.layout.desc.constrained_baseline",
3488 FT_BOOLEAN, 8, NULL, 0x02,
3491 /* MS Bitstream SEI */
3492 { &hf_h264_sei_ms_bitstream_ref_frame_cnt,
3493 { "Reference Frame Count", "h264.sei.ms.bitstream_info.ref_frm_cnt",
3494 FT_UINT8, BASE_DEC, NULL, 0x0,
3497 { &hf_h264_sei_ms_bitstream_num_nalus,
3498 { "Number of NAL units", "h264.sei.ms.bitstrea3416m_info.num_nalus",
3499 FT_UINT8, BASE_DEC, NULL, 0x0,
3503 { &hf_h264_sei_ms_crop_num_data,
3504 { "Number of Data Entries", "h264.sei.ms.crop.num_data",
3505 FT_UINT8, BASE_DEC, NULL, 0x0,
3508 { &hf_h264_sei_ms_crop_info_type,
3509 { "Info Type", "h264.sei.ms.crop.info_type",
3510 FT_UINT8, BASE_DEC, NULL, 0x0,
3513 { &hf_h264_sei_ms_crop_confidence_level,
3514 { "Confidence Level", "h264.sei.ms.crop.confidence_level",
3515 FT_UINT8, BASE_DEC, NULL, 0x0,
3518 { &hf_h264_sei_ms_crop_frame_left_offset,
3519 { "Left Offset", "h264.sei.ms.crop.left_offset",
3520 FT_UINT16, BASE_DEC, NULL, 0x0,
3523 { &hf_h264_sei_ms_crop_frame_right_offset,
3524 { "Right Offset", "h264.sei.ms.crop.right_offset",
3525 FT_UINT16, BASE_DEC, NULL, 0x0,
3528 { &hf_h264_sei_ms_crop_frame_top_offset,
3529 { "Top Offset", "h264.sei.ms.crop.top_offset",
3530 FT_UINT16, BASE_DEC, NULL, 0x0,
3533 { &hf_h264_sei_ms_crop_frame_bottom_offset,
3534 { "Bottom Offset", "h264.sei.ms.crop.bottom_offset",
3535 FT_UINT16, BASE_DEC, NULL, 0x0,
3538 /* NALU Header Extension */
3539 /* Annex G NAL Unit Header SVC Extension */
3540 { &hf_h264_nal_hdr_ext_svc,
3541 { "SVC Extension / Reserved", "h264.nal_hdr_ext.r",
3542 FT_BOOLEAN, 8, NULL, 0x80,
3545 { &hf_h264_nal_hdr_ext_i,
3546 { "IDR Picture", "h264.nal_hdr_ext.i",
3547 FT_BOOLEAN, 8, NULL, 0x40,
3550 { &hf_h264_nal_hdr_ext_prid,
3551 { "Priority ID", "h264.nal_hdr_ext.prid",
3552 FT_UINT8, BASE_DEC, NULL, 0x3f,
3555 { &hf_h264_nal_hdr_ext_n,
3556 { "No Inter Layer Prediction", "h264.nal_hdr_ext.n",
3557 FT_BOOLEAN, 8, NULL, 0x80,
3560 { &hf_h264_nal_hdr_ext_did,
3561 { "Dependency ID", "h264.nal_hdr_ext.did",
3562 FT_UINT8, BASE_DEC, NULL, 0x70,
3565 { &hf_h264_nal_hdr_ext_qid,
3566 { "Quality ID", "h264.nal_hdr_ext.qid",
3567 FT_UINT8, BASE_DEC, NULL, 0x0f,
3570 { &hf_h264_nal_hdr_ext_tid,
3571 { "Temporal ID", "h264.nal_hdr_ext.tid",
3572 FT_UINT8, BASE_DEC, NULL, 0xe0,
3575 { &hf_h264_nal_hdr_ext_u,
3576 { "Use Ref Base Picture", "h264.nal_hdr_ext.u",
3577 FT_BOOLEAN, 8, NULL, 0x10,
3580 { &hf_h264_nal_hdr_ext_d,
3581 { "Discardable", "h264.nal_hdr_ext.d",
3582 FT_BOOLEAN, 8, NULL, 0x08,
3585 { &hf_h264_nal_hdr_ext_o,
3586 { "Output", "h264.nal_hdr_ext.o",
3587 FT_BOOLEAN, 8, NULL, 0x04,
3590 { &hf_h264_nal_hdr_ext_rr,
3591 { "Reserved", "h264.nal_hdr_ext.rr",
3592 FT_UINT8, BASE_HEX, NULL, 0x03,
3597 { "X - A,P,C Field Indicator", "h264.pacsi.x",
3598 FT_BOOLEAN, 8, NULL, 0x80,
3602 { "Y - Pic Fields Indicator", "h264.pacsi.y",
3603 FT_BOOLEAN, 8, NULL, 0x40,
3607 { "T - DONC Field Indicator", "h264.pacsi.t",
3608 FT_BOOLEAN, 8, NULL, 0x20,
3612 { "A - Anchor Layer", "h264.pacsi.a",
3613 FT_BOOLEAN, 8, NULL, 0x10,
3617 { "P - Redundant Slice", "h264.pacsi.p",
3618 FT_BOOLEAN, 8, NULL, 0x08,
3622 { "C - Intra Slice", "h264.pacsi.c",
3623 FT_BOOLEAN, 8, NULL, 0x04,
3627 { "S - First Nal Unit of Layer", "h264.pacsi.s",
3628 FT_BOOLEAN, 8, NULL, 0x02,
3632 { "E - Last Nal Unit of Layer", "h264.pacsi.e",
3633 FT_BOOLEAN, 8, NULL, 0x01,
3636 { &hf_h264_pacsi_tl0picidx,
3637 { "TL0PICIDX", "h264.pacsi.tl0picidx",
3638 FT_UINT8, BASE_DEC, NULL, 0xFF,
3641 { &hf_h264_pacsi_idrpicid,
3642 { "IDRPICID - IDR Picture ID", "h264.pacsi.idrpicid",
3643 FT_UINT16, BASE_DEC, NULL, 0x0,
3646 { &hf_h264_pacsi_donc,
3647 { "DONC - Cross Session Decoder Order Number", "h264.pacsi.donc",
3648 FT_UINT16, BASE_DEC, NULL, 0x0,
3654 /* Setup protocol subtree array */
3655 static gint *ett[] = {
3662 &ett_h264_par_profile,
3663 &ett_h264_par_AdditionalModesSupported,
3664 &ett_h264_par_ProfileIOP,
3665 &ett_h264_ms_layer_description,
3666 &ett_h264_ms_crop_data
3669 static ei_register_info ei[] = {
3670 { &ei_h264_undecoded, { "h264.undecoded", PI_UNDECODED, PI_WARN, "[Not decoded yet]", EXPFILL }},
3671 { &ei_h264_ms_layout_wrong_length, { "h264.ms_layout.wrong_length", PI_PROTOCOL, PI_WARN, "[Wrong Layer Description Table Length]", EXPFILL }},
3672 { &ei_h264_bad_nal_length, { "h264.bad_nalu_length", PI_MALFORMED, PI_ERROR, "[Bad NAL Unit Length]", EXPFILL }},
3675 /* Register the protocol name and description */
3676 proto_h264 = proto_register_protocol("H.264","H264", "h264");
3678 /* Required function calls to register the header fields and subtrees used */
3679 proto_register_field_array(proto_h264, hf, array_length(hf));
3680 proto_register_subtree_array(ett, array_length(ett));
3681 expert_h264 = expert_register_protocol(proto_h264);
3682 expert_register_field_array(expert_h264, ei, array_length(ei));
3683 /* Register a configuration option for port */
3686 h264_module = prefs_register_protocol(proto_h264, proto_reg_handoff_h264);
3689 prefs_register_range_preference(h264_module, "dynamic.payload.type",
3690 "H264 dynamic payload types",
3691 "Dynamic payload types which will be interpreted as H264"
3692 "; Values must be in the range 96 - 127",
3693 &temp_dynamic_payload_type_range, 127);
3695 register_dissector("h264", dissect_h264, proto_h264);
3699 /* Register the protocol with Wireshark */
3701 proto_reg_handoff_h264(void)
3703 static range_t *dynamic_payload_type_range = NULL;
3704 static gboolean h264_prefs_initialized = FALSE;
3706 if (!h264_prefs_initialized) {
3707 dissector_handle_t h264_name_handle;
3708 h264_capability_t *ftr;
3710 h264_handle = find_dissector("h264");
3711 dissector_add_string("rtp_dyn_payload_type","H264", h264_handle);
3712 dissector_add_string("rtp_dyn_payload_type","H264-SVC", h264_handle);
3713 dissector_add_string("rtp_dyn_payload_type","X-H264UC", h264_handle);
3715 h264_name_handle = new_create_dissector_handle(dissect_h264_name, proto_h264);
3716 for (ftr=h264_capability_tab; ftr->id; ftr++) {
3718 dissector_add_string("h245.gef.name", ftr->id, h264_name_handle);
3719 if (ftr->content_pdu)
3720 dissector_add_string("h245.gef.content", ftr->id, new_create_dissector_handle(ftr->content_pdu, proto_h264));
3722 h264_prefs_initialized = TRUE;
3724 range_foreach(dynamic_payload_type_range, range_delete_h264_rtp_pt_callback);
3725 g_free(dynamic_payload_type_range);
3728 dynamic_payload_type_range = range_copy(temp_dynamic_payload_type_range);
3729 range_foreach(dynamic_payload_type_range, range_add_h264_rtp_pt_callback);