3 * Routines for MPEG4 dissection
4 * Copyright 2007-2008, Anders Broman <anders.broman[at]ericsson.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 * https://tools.ietf.org/html/rfc3016
19 #include <epan/packet.h>
20 #include <epan/expert.h>
21 #include <epan/asn1.h>
23 #include <epan/prefs.h>
25 #include "packet-mp4ves.h"
27 void proto_register_mp4ves(void);
28 void proto_reg_handoff_mp4ves(void);
30 /* Initialize the protocol and registered fields */
31 static int proto_mp4ves
;
33 static int hf_mp4ves_config
;
34 static int hf_mp4ves_start_code_prefix
;
35 static int hf_mp4ves_start_code
;
36 static int hf_mp4ves_vop_coding_type
;
37 static int hf_mp4ves_profile_and_level_indication
;
38 static int hf_mp4ves_is_visual_object_identifier
;
39 static int hf_mp4ves_visual_object_type
;
40 static int hf_mp4ves_video_signal_type
;
41 static int hf_mp4ves_stuffing
;
42 static int hf_mp4ves_video_object_type_indication
;
43 static int hf_mp4ves_random_accessible_vol
;
44 static int hf_mp4ves_is_object_layer_identifier
;
45 static int hf_mp4ves_aspect_ratio_info
;
46 static int hf_mp4ves_vol_control_parameters
;
47 static int hf_mp4ves_video_object_layer_shape
;
48 static int hf_mp4ves_user_data
;
49 static int hf_mp4ves_data
;
51 /* Initialize the subtree pointers */
52 static int ett_mp4ves
;
53 static int ett_mp4ves_config
;
55 static expert_field ei_mp4ves_config_too_short
;
56 static expert_field ei_mp4ves_not_dissected_bits
;
58 static dissector_handle_t mp4ves_name_handle
;
60 static dissector_handle_t mp4ves_handle
;
63 14496-2, Annex G, Table G-1.
64 Table G-1 FLC table for profile_and_level_indication Profile/Level Code
66 const value_string mp4ves_level_indication_vals
[] =
69 { 1, "Simple Profile/Level 1" },
70 { 2, "Simple Profile/Level 2" },
76 { 8, "Simple Profile/Level 0" },
77 { 9, "Simple Profile/Level 0b" },
78 /* Reserved 00001001 - 00010000 */
79 { 0x11, "Simple Scalable Profile/Level 1" },
80 { 0x12, "Simple Scalable Profile/Level 2" },
81 /* Reserved 00010011 - 00100000 */
82 { 0x21, "Core Profile/Level 1" },
83 { 0x22, "Core Profile/Level 2" },
84 /* Reserved 00100011 - 00110001 */
85 { 0x32, "Main Profile/Level 2" },
86 { 0x33, "Main Profile/Level 3" },
87 { 0x34, "Main Profile/Level 4" },
88 /* Reserved 00110101 - 01000001 */
89 { 0x42, "N-bit Profile/Level 2" },
90 /* Reserved 01000011 - 01010000 */
91 { 0x51, "Scalable Texture Profile/Level 1" },
92 /* Reserved 01010010 - 01100000 */
93 { 0x61, "Simple Face Animation Profile/Level 1" },
94 { 0x62, "Simple Face Animation Profile/Level 2" },
95 { 0x63, "Simple FBA Profile/Level 1" },
96 { 0x64, "Simple FBA Profile/Level 2" },
97 /* Reserved 01100101 - 01110000 */
98 { 0x71, "Basic Animated Texture Profile/Level 1" },
99 { 0x72, "Basic Animated Texture Profile/Level 2" },
100 /* Reserved 01110011 - 10000000 */
101 { 0x81, "Hybrid Profile/Level 1" },
102 { 0x82, "Hybrid Profile/Level 2" },
103 /* Reserved 10000011 - 10010000 */
104 { 0x91, "Advanced Real Time Simple Profile/Level 1" },
105 { 0x92, "Advanced Real Time Simple Profile/Level 2" },
106 { 0x93, "Advanced Real Time Simple Profile/Level 3" },
107 { 0x94, "Advanced Real Time Simple Profile/Level 4" },
108 /* Reserved 10010101 - 10100000 */
109 { 0xa1, "Core Scalable Profile/Level 1" },
110 { 0xa2, "Core Scalable Profile/Level 2" },
111 { 0xa3, "Core Scalable Profile/Level 3" },
112 /* Reserved 10100100 - 10110000 */
113 { 0xb1, "Advanced Coding Efficiency Profile/Level 1" },
114 { 0xb2, "Advanced Coding Efficiency Profile/Level 2" },
115 { 0xb3, "Advanced Coding Efficiency Profile/Level 3" },
116 { 0xb4, "Advanced Coding Efficiency Profile/Level 4" },
117 /* Reserved 10110101 - 11000000 */
118 { 0xc1, "Advanced Core Profile/Level 1" },
119 { 0xc2, "Advanced Core Profile/Level 2" },
120 /* Reserved 11000011 - 11010000 */
121 { 0xd1, "Advanced Scalable Texture/Level 1" },
122 { 0xd2, "Advanced Scalable Texture/Level 2" },
123 { 0xd3, "Advanced Scalable Texture/Level 3" },
124 /* Reserved 11010100 - 11100000 */
125 { 0xe1, "Simple Studio Profile/Level 1" },
126 { 0xe2, "Simple Studio Profile/Level 2" },
127 { 0xe3, "Simple Studio Profile/Level 3" },
128 { 0xe4, "Simple Studio Profile/Level 4" },
129 { 0xe5, "Core Studio Profile/Level 1" },
130 { 0xe6, "Core Studio Profile/Level 2" },
131 { 0xe7, "Core Studio Profile/Level 3" },
132 { 0xe8, "Core Studio Profile/Level 4" },
133 /* Reserved 11101001 - 11101111 */
134 { 0xf0, "Advanced Simple Profile/Level 0" },
135 { 0xf1, "Advanced Simple Profile/Level 1" },
136 { 0xf2, "Advanced Simple Profile/Level 2" },
137 { 0xf3, "Advanced Simple Profile/Level 3" },
138 { 0xf4, "Advanced Simple Profile/Level 4" },
139 { 0xf5, "Advanced Simple Profile/Level 5" },
140 /* Reserved 11110110 - 11110111 */
141 { 0xf8, "Fine Granularity Scalable Profile/Level 0" },
142 { 0xf9, "Fine Granularity Scalable Profile/Level 1" },
143 { 0xfa, "Fine Granularity Scalable Profile/Level 2" },
144 { 0xfb, "Fine Granularity Scalable Profile/Level 3" },
145 { 0xfc, "Fine Granularity Scalable Profile/Level 4" },
146 { 0xfd, "Fine Granularity Scalable Profile/Level 5" },
147 { 0xfe, "Reserved" },
148 { 0xff, "Reserved for Escape" },
151 static const range_string mp4ves_startcode_vals
[] = {
152 { 0x00, 0x1f, "video_object_start_code" },
153 { 0x20, 0x2f, "video_object_layer_start_code" },
154 { 0x30, 0xaf, "reserved" },
155 { 0xb0, 0xb0, "visual_object_sequence_start_code" },
156 { 0xb1, 0xb1, "visual_object_sequence_end_code" },
157 { 0xb2, 0xb2, "user_data_start_code" },
158 { 0xb3, 0xb3, "group_of_vop_start_code" },
159 { 0xb4, 0xb4, "video_session_error_code" },
160 { 0xb5, 0xb5, "visual_object_start_code" },
161 { 0xb6, 0xb6, "vop_start_code" },
162 { 0xb7, 0xb9, "reserved" },
163 { 0xba, 0xba, "fba_object_start_code" },
164 { 0xbb, 0xbb, "fba_object_plane_start_code" },
165 { 0xbc, 0xbc, "mesh_object_start_code" },
166 { 0xbd, 0xbd, "mesh_object_plane_start_code" },
167 { 0xbe, 0xbe, "still_texture_object_start_code" },
168 { 0xbf, 0xbf, "texture_spatial_layer_start_code" },
169 { 0xc0, 0xc0, "texture_snr_layer_start_code" },
170 { 0xc1, 0xc1, "texture_tile_start_code" },
171 { 0xc2, 0xc2, "texture_shape_layer_start_code" },
172 { 0xc3, 0xc3, "stuffing_start_code" },
173 { 0xc4, 0xc5, "reserved" },
174 { 0xc6, 0xcf, "System start codes" }, /* NOTE System start codes are defined in ISO/IEC 14496-1:1999 */
178 static const value_string mp4ves_vop_coding_type_vals
[] = {
179 { 0, "intra-coded (I)" },
180 { 1, "predictive-coded (P)" },
181 { 2, "bidirectionally-predictive-coded (B)" },
187 * FLC table for video_object_type indication
189 static const value_string mp4ves_video_object_type_vals
[] = {
191 { 0x1, "Simple Object Type" },
192 { 0x2, "Simple Scalable Object Type" },
193 { 0x3, "Core Object Type" },
194 { 0x4, "Main Object Type" },
195 { 0x5, "N-bit Object Type" },
196 { 0x6, "Basic Anim. 2D Texture" },
197 { 0x7, "Anim. 2D Mesh" },
198 { 0x8, "Simple Face" },
199 { 0x9, "Still Scalable Texture" },
200 { 0xa, "Advanced Real Time Simple" },
201 { 0xb, "Core Scalable" },
202 { 0xc, "Advanced Coding Efficiency" },
203 { 0xd, "Advanced Scalable Texture" },
204 { 0xe, "Simple FBA" },
207 /* Visual object type */
208 static const value_string mp4ves_visual_object_type_vals
[] = {
211 { 0x2, "still texture ID" },
214 { 0x5, "3D mesh ID" },
228 static const value_string mp4ves_video_object_type_indication_vals
[] = {
230 { 0x1, "Simple Object Type" },
231 { 0x2, "Simple Scalable Object Type" },
232 { 0x3, "Core Object Type" },
233 { 0x4, "Main Object Type" },
234 { 0x5, "N-bit Object Type" },
235 { 0x6, "Basic Anim. 2D Texture" },
236 { 0x7, "Anim. 2D Mesh" },
237 { 0x8, "Simple Face" },
238 { 0x9, "Still Scalable Texture" },
239 { 0xa, "Advanced Real Time Simple" },
240 { 0xb, "Core Scalable" },
241 { 0xc, "Advanced Coding Efficiency" },
242 { 0xd, "Advanced Scalable Texture" },
243 { 0xe, "Simple FBA" },
245 /* Reserved 00001111 - 11111111 */
248 /* 6.2.2.1 User data */
250 dissect_mp4ves_user_data(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, int bit_offset
)
252 int start_bit_offset
;
254 /* user_data_start_code */
255 proto_tree_add_bits_item(tree
, hf_mp4ves_start_code_prefix
, tvb
, bit_offset
, 24, ENC_BIG_ENDIAN
);
257 proto_tree_add_bits_item(tree
, hf_mp4ves_start_code
, tvb
, bit_offset
, 8, ENC_BIG_ENDIAN
);
259 start_bit_offset
= bit_offset
;
260 /* while( next_bits() != '000 0000 0000 0000 0000 0001') { */
261 while ( tvb_get_bits32(tvb
,bit_offset
, 24, ENC_BIG_ENDIAN
) != 1){
263 /* user_data 8 bits */
265 proto_tree_add_item(tree
, hf_mp4ves_user_data
, tvb
, start_bit_offset
>>3, (bit_offset
- start_bit_offset
)>>2, ENC_NA
);
272 while (!bytealigned())
277 dissect_mp4ves_next_start_code(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, int bit_offset
)
280 int start_bit_offset
;
282 start_bit_offset
= bit_offset
;
284 zero_bit
= tvb_get_bits8(tvb
,bit_offset
,1);
290 /* zero stuffing bits */
291 if(bit_offset
%8 == 0)
294 while(bit_offset
%8 != 0){
298 proto_tree_add_bits_item(tree
, hf_mp4ves_stuffing
, tvb
, start_bit_offset
, bit_offset
-start_bit_offset
, ENC_BIG_ENDIAN
);
304 video_signal_type() {
306 if (video_signal_type
) {
307 video_format
3 uimsbf
309 colour_description
1 bslbf
310 if (colour_description
) {
311 colour_primaries
8 uimsbf
312 transfer_characteristics
8 uimsbf
313 matrix_coefficients
8 uimsbf
320 dissect_mp4ves_visual_object_type(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, int bit_offset
)
322 uint8_t video_signal_type
, colour_description
;
324 video_signal_type
= tvb_get_bits8(tvb
,bit_offset
,1);
325 proto_tree_add_bits_item(tree
, hf_mp4ves_video_signal_type
, tvb
, bit_offset
, 1, ENC_BIG_ENDIAN
);
327 if (video_signal_type
) {
328 /* video_format 3 bits */
330 /* video_range 1 bit */
332 /* colour_description 1 bit */
333 colour_description
= tvb_get_bits8(tvb
,bit_offset
,1);
334 if (colour_description
) {
335 /* colour_primaries 8 bits */
337 /* transfer_characteristics 8 bits */
339 /* matrix_coefficients 8 bits*/
347 * 6.2.3 Video Object Layer
351 * Table 6-12 -- Meaning of pixel aspect ratio
354 static const value_string mp4ves_aspect_ratio_info_vals
[] = {
355 { 0x0, "Forbidden" },
356 { 0x1, "1:1 (Square)" },
357 { 0x2, "12:11 (625-type for 4:3 picture)" },
358 { 0x3, "10:11 (525-type for 4:3 picture)" },
359 { 0x4, "16:11 (625-type stretched for 16:9 picture)" },
360 { 0x5, "40:33 (525-type stretched for 16:9 picture)" },
370 { 0xf, "Extended PAR" },
374 /* Table 6-14 Video Object Layer shape type */
375 static const value_string mp4ves_video_object_layer_shape_vals
[] = {
376 { 0x0, "rectangular" },
378 { 0x2, "binary only" },
379 { 0x3, "grayscale" },
384 dissect_mp4ves_VideoObjectLayer(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, int bit_offset
)
387 int current_bit_offset
;
388 uint8_t octet
, is_object_layer_identifier
, aspect_ratio_info
, vol_control_parameters
, vbv_parameters
;
389 uint8_t video_object_layer_shape
, video_object_layer_verid
= 0;
391 /* if(next_bits() == video_object_layer_start_code) { */
392 dword
= tvb_get_bits32(tvb
,bit_offset
, 24, ENC_BIG_ENDIAN
);
396 octet
= tvb_get_bits8(tvb
,bit_offset
+24, 8);
397 if((octet
>=0x20)&&(octet
<=0x2f)){
402 /* video_object_layer_start_code */
403 proto_tree_add_bits_item(tree
, hf_mp4ves_start_code_prefix
, tvb
, bit_offset
, 24, ENC_BIG_ENDIAN
);
405 proto_tree_add_bits_item(tree
, hf_mp4ves_start_code
, tvb
, bit_offset
, 8, ENC_BIG_ENDIAN
);
408 /* short_video_header = 0 */
409 /* random_accessible_vol 1 */
410 proto_tree_add_bits_item(tree
, hf_mp4ves_random_accessible_vol
, tvb
, bit_offset
, 1, ENC_BIG_ENDIAN
);
412 /* video_object_type_indication 8 */
413 proto_tree_add_bits_item(tree
, hf_mp4ves_video_object_type_indication
, tvb
, bit_offset
, 8, ENC_BIG_ENDIAN
);
415 /* is_object_layer_identifier 1 */
416 is_object_layer_identifier
= tvb_get_bits8(tvb
,bit_offset
, 1);
417 proto_tree_add_bits_item(tree
, hf_mp4ves_is_object_layer_identifier
, tvb
, bit_offset
, 1, ENC_BIG_ENDIAN
);
419 if(is_object_layer_identifier
) {
420 /* video_object_layer_verid 4 uimsbf */
422 /* video_object_layer_priority 3 uimsbf */
425 /* aspect_ratio_info 4 uimsbf */
426 aspect_ratio_info
= tvb_get_bits8(tvb
,bit_offset
, 1);
427 proto_tree_add_bits_item(tree
, hf_mp4ves_aspect_ratio_info
, tvb
, bit_offset
, 4, ENC_BIG_ENDIAN
);
428 if (aspect_ratio_info
== 0xf /*"extended_PAR"*/ ) {
429 /* par_width 8 uimsbf */
431 /* par_height 8 uimsbf */
434 /* vol_control_parameters 1 bslbf */
435 /* vol_control_parameters 1 bslbf */
436 vol_control_parameters
= tvb_get_bits8(tvb
,bit_offset
, 1);
437 proto_tree_add_bits_item(tree
, hf_mp4ves_vol_control_parameters
, tvb
, bit_offset
, 1, ENC_BIG_ENDIAN
);
439 current_bit_offset
= bit_offset
;
440 if (vol_control_parameters
) {
441 /* chroma_format 2 uimsbf */
443 /* low_delay 1 uimsbf */
445 /* vbv_parameters 1 blsbf */
446 vbv_parameters
= tvb_get_bits8(tvb
,bit_offset
, 1);
448 if (vbv_parameters
) {
449 /* first_half_bit_rate 15 uimsbf */
451 /* marker_bit 1 bslbf */
453 /* latter_half_bit_rate 15 uimsbf */
455 /* marker_bit 1 bslbf */
457 /* first_half_vbv_buffer_size 15 uimsbf */
459 /* marker_bit 1 bslbf */
461 /* latter_half_vbv_buffer_size 3 uimsbf */
463 /* first_half_vbv_occupancy 11 uimsbf */
465 /* marker_bit 1 blsbf */
467 /* latter_half_vbv_occupancy 15 uimsbf */
469 /* marker_bit 1 blsbf */
473 if(bit_offset
-current_bit_offset
> 0)
474 proto_tree_add_expert(tree
, pinfo
, &ei_mp4ves_not_dissected_bits
, tvb
, current_bit_offset
>>3, (bit_offset
+7)>>3);
475 /* video_object_layer_shape 2 uimsbf */
476 video_object_layer_shape
= tvb_get_bits8(tvb
,bit_offset
, 2);
477 proto_tree_add_bits_item(tree
, hf_mp4ves_video_object_layer_shape
, tvb
, bit_offset
, 2, ENC_BIG_ENDIAN
);
479 if (video_object_layer_shape
== 3/*"grayscale"*/&& video_object_layer_verid
!= 1){
480 /* video_object_layer_shape_extension 4 uimsbf */
483 /* marker_bit 1 bslbf */
485 /* vop_time_increment_resolution 16 uimsbf */
487 /* marker_bit 1 bslbf */
489 /* fixed_vop_rate 1 bslbf */
498 visual_object_start_code
499 is_visual_object_identifier
500 if (is_visual_object_identifier) {
502 visual_object_priority
505 if (visual_object_type == "Video ID" || visual_object_type == "still textureID") {
509 while ( next_bits()== user_data_start_code){
512 if (visual_object_type == "Video ID") {
513 video_object_start_code
516 else if (visual_object_type == "still texture ID") {
519 else if (visual_object_type == "mesh ID") {
522 else if (visual_object_type == "FBA ID") {
525 else if (visual_object_type == "3D mesh ID") {
528 if (next_bits() != "0000 0000 0000 0000 0000 0001")
533 dissect_mp4ves_VisualObject(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, int bit_offset
)
535 uint8_t is_visual_object_identifier
, visual_object_type
;
539 is_visual_object_identifier
= tvb_get_bits8(tvb
,bit_offset
,1);
540 proto_tree_add_bits_item(tree
, hf_mp4ves_is_visual_object_identifier
, tvb
, bit_offset
, 1, ENC_BIG_ENDIAN
);
542 if(is_visual_object_identifier
){
543 /* visual_object_verid 4 bits*/
545 /* visual_object_priority 3 bits*/
548 /* visual_object_type 4 bits*/
549 visual_object_type
= tvb_get_bits8(tvb
,bit_offset
,4);
550 proto_tree_add_bits_item(tree
, hf_mp4ves_visual_object_type
, tvb
, bit_offset
, 4, ENC_BIG_ENDIAN
);
552 if ((visual_object_type
== 1/*"Video ID"*/) || (visual_object_type
== 2/*"still textureID"*/)) {
553 /* video_signal_type() */
554 bit_offset
= dissect_mp4ves_visual_object_type(tvb
, pinfo
, tree
, bit_offset
);
556 /* next_start_code() */
557 bit_offset
= dissect_mp4ves_next_start_code(tvb
, pinfo
, tree
, bit_offset
);
558 dword
= tvb_get_bits32(tvb
,bit_offset
, 32, ENC_BIG_ENDIAN
);
560 while ( next_bits()== user_data_start_code){
565 bit_offset
= dissect_mp4ves_user_data(tvb
, pinfo
, tree
, bit_offset
);
566 dword
= tvb_get_bits32(tvb
,bit_offset
, 32, ENC_BIG_ENDIAN
);
568 if (visual_object_type
== 1/*"Video ID"*/) {
570 * video_object_start_code
572 dword
= tvb_get_bits32(tvb
,bit_offset
, 24, ENC_BIG_ENDIAN
);
577 octet
= tvb_get_bits8(tvb
,bit_offset
+24, 8);
582 proto_tree_add_bits_item(tree
, hf_mp4ves_start_code_prefix
, tvb
, bit_offset
, 24, ENC_BIG_ENDIAN
);
584 proto_tree_add_bits_item(tree
, hf_mp4ves_start_code
, tvb
, bit_offset
, 8, ENC_BIG_ENDIAN
);
586 if(tvb_reported_length_remaining(tvb
,(bit_offset
>>3))<=0){
587 proto_tree_add_expert(tree
, pinfo
, &ei_mp4ves_config_too_short
, tvb
, 0, -1);
593 bit_offset
= dissect_mp4ves_VideoObjectLayer(tvb
, pinfo
, tree
, bit_offset
);
600 dissect_mp4ves_VisualObjectSequence(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, int bit_offset
)
604 /*VisualObjectSequence() {
606 visual_object_sequence_start_code
609 /* Get start code prefix */
610 dword
= tvb_get_bits32(tvb
,bit_offset
, 32, ENC_BIG_ENDIAN
);
611 if ((dword
& 0x00000100) != 0x00000100){
612 /* No start code prefix */
615 proto_tree_add_bits_item(tree
, hf_mp4ves_start_code_prefix
, tvb
, bit_offset
, 24, ENC_BIG_ENDIAN
);
618 proto_tree_add_bits_item(tree
, hf_mp4ves_start_code
, tvb
, bit_offset
, 8, ENC_BIG_ENDIAN
);
621 /* Expect visual_object_sequence_start_code */
624 /* profile_and_level_indication */
625 proto_tree_add_bits_item(tree
, hf_mp4ves_profile_and_level_indication
, tvb
, bit_offset
, 8, ENC_BIG_ENDIAN
);
628 /* while ( next_bits()== user_data_start_code){
632 dword
= tvb_get_bits32(tvb
,bit_offset
, 32, ENC_BIG_ENDIAN
);
634 if ((dword
& 0x00000100) != 0x00000100){
635 /* No start code prefix */
640 * user_data_start_code
641 * XXX call user data dissection here
649 bit_offset
= dissect_mp4ves_VisualObject(tvb
, pinfo
, tree
, bit_offset
);
652 } while ( next_bits() != visual_object_sequence_end_code)
653 visual_object_sequence_end_code
659 dissect_mp4ves_config(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
662 proto_tree
*mp4ves_tree
;
664 item
= proto_tree_add_item(tree
, hf_mp4ves_config
, tvb
, 0, -1, ENC_NA
);
665 mp4ves_tree
= proto_item_add_subtree(item
, ett_mp4ves_config
);
667 dissect_mp4ves_VisualObjectSequence(tvb
, pinfo
, mp4ves_tree
, 0);
668 return tvb_captured_length(tvb
);
672 dissect_mp4ves(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
676 proto_tree
*mp4ves_tree
;
679 /* Make entries in Protocol column and Info column on summary display */
680 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MP4V-ES");
682 item
= proto_tree_add_item(tree
, proto_mp4ves
, tvb
, 0, -1, ENC_NA
);
683 mp4ves_tree
= proto_item_add_subtree(item
, ett_mp4ves
);
685 +------+------+------+------+
686 (a) | RTP | VS | VO | VOL |
687 |header|header|header|header|
688 +------+------+------+------+
690 +------+------+------+------+------------+
691 (b) | RTP | VS | VO | VOL |Video Packet|
692 |header|header|header|header| |
693 +------+------+------+------+------------+
695 +------+-----+------------------+
696 (c) | RTP | GOV |Video Object Plane|
698 +------+-----+------------------+
700 +------+------+------------+ +------+------+------------+
701 (d) | RTP | VOP |Video Packet| | RTP | VP |Video Packet|
702 |header|header| (1) | |header|header| (2) |
703 +------+------+------------+ +------+------+------------+
705 +------+------+------------+------+------------+------+------------+
706 (e) | RTP | VP |Video Packet| VP |Video Packet| VP |Video Packet|
707 |header|header| (1) |header| (2) |header| (3) |
708 +------+------+------------+------+------------+------+------------+
710 +------+------+------------+ +------+------------+
711 (f) | RTP | VOP |VOP fragment| | RTP |VOP fragment|
712 |header|header| (1) | |header| (2) | ___
713 +------+------+------------+ +------+------------+
715 Figure 2 - Examples of RTP packetized MPEG-4 Visual bitstream
717 So a valid packet should start with
718 VS - Visual Object Sequence Header
719 GOV - Group_of_VideoObjectPlane
720 VOP - Video Object Plane
722 Otherwise it's a VOP fragment.
724 visual_object_sequence_start_code: The visual_object_sequence_start_code is
725 the bit string '000001B0' in hexadecimal. It initiates a visual session.
727 group_of_vop_start_code: The group_of_vop_start_code is the bit string '000001B3' in hexadecimal. It identifies
728 the beginning of a GOV header.
730 vop_start_code: This is the bit string '000001B6' in hexadecimal.
734 if (tvb_reported_length(tvb
)< 4){
735 /* To short to be a start code */
736 proto_tree_add_item(mp4ves_tree
, hf_mp4ves_data
, tvb
, bit_offset
>>3, -1, ENC_NA
);
737 return tvb_captured_length(tvb
);
739 dword
= tvb_get_bits32(tvb
,bit_offset
, 24, ENC_BIG_ENDIAN
);
741 /* if it's not 23 zeros followed by 1 it isn't a start code */
742 proto_tree_add_item(mp4ves_tree
, hf_mp4ves_data
, tvb
, bit_offset
>>3, -1, ENC_NA
);
743 return tvb_captured_length(tvb
);
745 dword
= tvb_get_bits8(tvb
,24, 8);
746 bit_offset
= bit_offset
+8;
750 proto_tree_add_bits_item(mp4ves_tree
, hf_mp4ves_start_code_prefix
, tvb
, bit_offset
, 24, ENC_BIG_ENDIAN
);
751 bit_offset
= bit_offset
+24;
752 /* vop_coding_type 2 bits */
753 proto_tree_add_bits_item(mp4ves_tree
, hf_mp4ves_vop_coding_type
, tvb
, bit_offset
, 2, ENC_BIG_ENDIAN
);
757 /*bit_offset = */dissect_mp4ves_VisualObjectSequence(tvb
, pinfo
, mp4ves_tree
, 0);
760 proto_tree_add_bits_item(mp4ves_tree
, hf_mp4ves_start_code_prefix
, tvb
, bit_offset
, 24, ENC_BIG_ENDIAN
);
761 /*bit_offset = bit_offset+24;*/
766 return tvb_captured_length(tvb
);
769 * Parameter name profileAndLevel
770 * Parameter description This is a nonCollapsing GenericParameter
771 * Parameter identifier value 0
772 * Parameter status Mandatory
773 * Parameter type unsignedMax. Shall be in the range 0..255.
775 * unsignedMax INTEGER(0..65535), -- Look for max
778 dissect_mp4ves_par_profile(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree _U_
, void *data
)
782 const char *p
= NULL
;
785 /* Reject the packet if data is NULL */
788 actx
= get_asn1_ctx(data
);
789 DISSECTOR_ASSERT(actx
);
791 lvl
= tvb_get_ntohs(tvb
, offset
);
792 p
= try_val_to_str(lvl
, VALS(mp4ves_level_indication_vals
));
794 proto_item_append_text(actx
->created_item
, " - profileAndLevel %s", p
);
800 dissect_mp4ves_par_video_object_type(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree _U_
, void *data
)
804 const char *p
= NULL
;
807 /* Reject the packet if data is NULL */
810 actx
= get_asn1_ctx(data
);
811 DISSECTOR_ASSERT(actx
);
813 lvl
= tvb_get_ntohs(tvb
, offset
);
814 p
= try_val_to_str(lvl
, VALS(mp4ves_video_object_type_vals
));
816 proto_item_append_text(actx
->created_item
, " - video_object_type %s", p
);
823 dissect_mp4ves_par_decoderConfigurationInformation(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
827 /* Reject the packet if data is NULL */
830 actx
= get_asn1_ctx(data
);
831 DISSECTOR_ASSERT(actx
);
833 dissect_mp4ves_config(tvb
, pinfo
, tree
, data
);
835 return tvb_reported_length(tvb
);
838 typedef struct _mp4ves_capability_t
{
841 dissector_t content_pdu
;
842 } mp4ves_capability_t
;
844 static mp4ves_capability_t mp4ves_capability_tab
[] = {
845 /* ITU-T H.245 capabilities ISO/IEC 14496-2(m*/
846 { "GenericCapability/0.0.8.245.1.0.0/nonCollapsing/0", "profileAndLevel", dissect_mp4ves_par_profile
},
847 { "GenericCapability/0.0.8.245.1.0.0/nonCollapsing/1", "object", dissect_mp4ves_par_video_object_type
},
848 { "GenericCapability/0.0.8.245.1.0.0/nonCollapsing/2", "decoderConfigurationInformation", dissect_mp4ves_par_decoderConfigurationInformation
},
849 { "GenericCapability/0.0.8.245.1.0.0/nonCollapsing/3", "drawingOrder", NULL
},
850 { "GenericCapability/0.0.8.245.1.0.0/collapsing/4", "visualBackChannelHandle", NULL
},
851 { NULL
, NULL
, NULL
},
854 static mp4ves_capability_t
*find_cap(const char *id
) {
855 mp4ves_capability_t
*ftr
= NULL
;
856 mp4ves_capability_t
*f
;
858 for (f
=mp4ves_capability_tab
; f
->id
; f
++) {
859 if (!strcmp(id
, f
->id
)) { ftr
= f
; break; }
865 dissect_mp4ves_name(tvbuff_t
*tvb _U_
, packet_info
*pinfo
, proto_tree
*tree
, void* data
)
868 mp4ves_capability_t
*ftr
;
870 /* Reject the packet if data is NULL */
873 actx
= get_asn1_ctx(data
);
874 DISSECTOR_ASSERT(actx
);
877 ftr
= find_cap(pinfo
->match_string
);
879 proto_item_append_text(actx
->created_item
, " - %s", ftr
->name
);
880 proto_item_append_text(proto_item_get_parent(proto_tree_get_parent(tree
)), ": %s", ftr
->name
);
882 proto_item_append_text(actx
->created_item
, " - unknown(%s)", pinfo
->match_string
);
886 return tvb_reported_length(tvb
);
890 proto_register_mp4ves(void)
894 /* Setup list of header fields See Section 1.6.1 for details*/
895 static hf_register_info hf
[] = {
897 { "Configuration", "mp4ves.configuration",
898 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
901 { &hf_mp4ves_start_code_prefix
,
902 { "start code prefix", "mp4ves.start_code_prefix",
903 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
906 { &hf_mp4ves_start_code
,
907 { "Start code", "mp4ves.start_code",
908 FT_UINT8
, BASE_RANGE_STRING
|BASE_HEX
, RVALS(mp4ves_startcode_vals
), 0x0,
911 { &hf_mp4ves_vop_coding_type
,
912 { "vop_coding_type", "mp4ves.vop_coding_type",
913 FT_UINT8
, BASE_DEC
, VALS(mp4ves_vop_coding_type_vals
), 0x0,
914 "Start code", HFILL
}
916 {&hf_mp4ves_profile_and_level_indication
,
917 { "profile_and_level_indication", "mp4ves.profile_and_level_indication",
918 FT_UINT8
, BASE_DEC
,VALS(mp4ves_level_indication_vals
), 0x0,
921 { &hf_mp4ves_is_visual_object_identifier
,
922 { "visual_object_identifier", "mp4ves.visual_object_identifier",
923 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
926 { &hf_mp4ves_visual_object_type
,
927 { "visual_object_type", "mp4ves.visual_object_type",
928 FT_UINT32
, BASE_DEC
, VALS(mp4ves_visual_object_type_vals
), 0x0,
931 { &hf_mp4ves_video_signal_type
,
932 { "video_signal_type", "mp4ves.video_signal_type",
933 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
936 { &hf_mp4ves_stuffing
,
937 { "Stuffing", "mp4ves.stuffing",
938 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
941 { &hf_mp4ves_video_object_type_indication
,
942 { "video_object_type_indication", "mp4ves.video_object_type_indication",
943 FT_UINT8
, BASE_DEC
, VALS(mp4ves_video_object_type_indication_vals
), 0x0,
946 { &hf_mp4ves_random_accessible_vol
,
947 { "random_accessible_vol", "mp4ves.random_accessible_vol",
948 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
949 "video_object_type_indication", HFILL
}
951 { &hf_mp4ves_is_object_layer_identifier
,
952 { "is_object_layer_identifier", "mp4ves.is_object_layer_identifier",
953 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
956 { &hf_mp4ves_aspect_ratio_info
,
957 { "aspect_ratio_info", "mp4ves.aspect_ratio_info",
958 FT_UINT8
, BASE_DEC
, VALS(mp4ves_aspect_ratio_info_vals
), 0x0,
961 { &hf_mp4ves_vol_control_parameters
,
962 { "vol_control_parameters", "mp4ves.vol_control_parameters",
963 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
966 { &hf_mp4ves_video_object_layer_shape
,
967 { "video_object_layer_shape", "mp4ves.video_object_layer_shape",
968 FT_UINT8
, BASE_DEC
, VALS(mp4ves_video_object_layer_shape_vals
), 0x0,
971 { &hf_mp4ves_user_data
,
972 { "User data", "mp4ves.user_data",
973 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
977 { "Data", "mp4ves.data",
978 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
983 /* Setup protocol subtree array */
984 static int *ett
[] = {
989 static ei_register_info ei
[] = {
990 { &ei_mp4ves_config_too_short
, { "mp4ves.config_too_short", PI_MALFORMED
, PI_ERROR
, "Config string too short", EXPFILL
}},
991 { &ei_mp4ves_not_dissected_bits
, { "mp4ves.not_dissected_bits", PI_UNDECODED
, PI_WARN
, "Not dissected bits", EXPFILL
}},
994 module_t
*mp4ves_module
;
995 expert_module_t
* expert_mp4ves
;
997 /* Register the protocol name and description */
998 proto_mp4ves
= proto_register_protocol("MP4V-ES","MP4V-ES", "mp4v-es");
1000 /* Required function calls to register the header fields and subtrees used */
1001 proto_register_field_array(proto_mp4ves
, hf
, array_length(hf
));
1002 proto_register_subtree_array(ett
, array_length(ett
));
1003 expert_mp4ves
= expert_register_protocol(proto_mp4ves
);
1004 expert_register_field_array(expert_mp4ves
, ei
, array_length(ei
));
1005 /* Register a configuration option for port */
1007 mp4ves_handle
= register_dissector("mp4ves", dissect_mp4ves
, proto_mp4ves
);
1008 register_dissector("mp4ves_config", dissect_mp4ves_config
, proto_mp4ves
);
1010 /* Register a configuration option for port */
1011 mp4ves_module
= prefs_register_protocol(proto_mp4ves
, NULL
);
1013 prefs_register_obsolete_preference(mp4ves_module
, "dynamic.payload.type");
1018 proto_reg_handoff_mp4ves(void)
1020 mp4ves_capability_t
*ftr
;
1022 dissector_add_string("rtp_dyn_payload_type","MP4V-ES", mp4ves_handle
);
1024 mp4ves_name_handle
= create_dissector_handle(dissect_mp4ves_name
, proto_mp4ves
);
1025 for (ftr
=mp4ves_capability_tab
; ftr
->id
; ftr
++) {
1027 dissector_add_string("h245.gef.name", ftr
->id
, mp4ves_name_handle
);
1028 if (ftr
->content_pdu
)
1029 dissector_add_string("h245.gef.content", ftr
->id
, create_dissector_handle(ftr
->content_pdu
, proto_mp4ves
));
1032 dissector_add_uint_range_with_preference("rtp.pt", "", mp4ves_handle
);
1036 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1041 * indent-tabs-mode: t
1044 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1045 * :indentSize=8:tabSize=8:noTabs=false: