HACK: 2nd try to match RowsetProperties
[wireshark-wip.git] / epan / dissectors / packet-mpeg-pes.c
blob7d589eb56c42e3aa4cda9623b49056e04fb76961
1 /* Do not modify this file. Changes will be overwritten. */
2 /* Generated automatically by the ASN.1 to Wireshark dissector compiler */
3 /* packet-mpeg-pes.c */
4 /* ../../tools/asn2wrs.py -p mpeg-pes -c ./mpeg-pes.cnf -s ./packet-mpeg-pes-template -D . -O ../../epan/dissectors mpeg-pes.asn */
6 /* Input file: packet-mpeg-pes-template.c */
8 #line 1 "../../asn1/mpeg-pes/packet-mpeg-pes-template.c"
9 /* MPEG Packetized Elementary Stream (PES) packet decoder.
10 * Written by Shaun Jackman <sjackman@gmail.com>.
11 * Copyright 2007 Shaun Jackman
13 * $Id$
15 * Wireshark - Network traffic analyzer
16 * By Gerald Combs <gerald@wireshark.org>
17 * Copyright 1998 Gerald Combs
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
34 #include "config.h"
36 #include <glib.h>
38 #include <epan/packet.h>
39 #include <epan/asn1.h>
41 #include "packet-per.h"
44 /*--- Included file: packet-mpeg-pes-hf.c ---*/
45 #line 1 "../../asn1/mpeg-pes/packet-mpeg-pes-hf.c"
46 static int hf_mpeg_pes_prefix = -1; /* OCTET_STRING_SIZE_3 */
47 static int hf_mpeg_pes_stream = -1; /* T_stream */
48 static int hf_mpeg_pes_length = -1; /* INTEGER_0_65535 */
49 static int hf_mpeg_pes_must_be_one = -1; /* BOOLEAN */
50 static int hf_mpeg_pes_must_be_zero = -1; /* BOOLEAN */
51 static int hf_mpeg_pes_scrambling_control = -1; /* T_scrambling_control */
52 static int hf_mpeg_pes_priority = -1; /* BOOLEAN */
53 static int hf_mpeg_pes_data_alignment = -1; /* BOOLEAN */
54 static int hf_mpeg_pes_copyright = -1; /* BOOLEAN */
55 static int hf_mpeg_pes_original = -1; /* BOOLEAN */
56 static int hf_mpeg_pes_pts_flag = -1; /* BOOLEAN */
57 static int hf_mpeg_pes_dts_flag = -1; /* BOOLEAN */
58 static int hf_mpeg_pes_escr_flag = -1; /* BOOLEAN */
59 static int hf_mpeg_pes_es_rate_flag = -1; /* BOOLEAN */
60 static int hf_mpeg_pes_dsm_trick_mode_flag = -1; /* BOOLEAN */
61 static int hf_mpeg_pes_additional_copy_info_flag = -1; /* BOOLEAN */
62 static int hf_mpeg_pes_crc_flag = -1; /* BOOLEAN */
63 static int hf_mpeg_pes_extension_flag = -1; /* BOOLEAN */
64 static int hf_mpeg_pes_header_data_length = -1; /* INTEGER_0_255 */
65 static int hf_mpeg_pes_horizontal_size = -1; /* BIT_STRING_SIZE_12 */
66 static int hf_mpeg_pes_vertical_size = -1; /* BIT_STRING_SIZE_12 */
67 static int hf_mpeg_pes_aspect_ratio = -1; /* T_aspect_ratio */
68 static int hf_mpeg_pes_frame_rate = -1; /* T_frame_rate */
69 static int hf_mpeg_pes_bit_rate = -1; /* BIT_STRING_SIZE_18 */
70 static int hf_mpeg_pes_vbv_buffer_size = -1; /* BIT_STRING_SIZE_10 */
71 static int hf_mpeg_pes_constrained_parameters_flag = -1; /* BOOLEAN */
72 static int hf_mpeg_pes_load_intra_quantiser_matrix = -1; /* BOOLEAN */
73 static int hf_mpeg_pes_load_non_intra_quantiser_matrix = -1; /* BOOLEAN */
74 static int hf_mpeg_pes_must_be_0001 = -1; /* BIT_STRING_SIZE_4 */
75 static int hf_mpeg_pes_profile_and_level = -1; /* INTEGER_0_255 */
76 static int hf_mpeg_pes_progressive_sequence = -1; /* BOOLEAN */
77 static int hf_mpeg_pes_chroma_format = -1; /* INTEGER_0_3 */
78 static int hf_mpeg_pes_horizontal_size_extension = -1; /* INTEGER_0_3 */
79 static int hf_mpeg_pes_vertical_size_extension = -1; /* INTEGER_0_3 */
80 static int hf_mpeg_pes_bit_rate_extension = -1; /* BIT_STRING_SIZE_12 */
81 static int hf_mpeg_pes_vbv_buffer_size_extension = -1; /* INTEGER_0_255 */
82 static int hf_mpeg_pes_low_delay = -1; /* BOOLEAN */
83 static int hf_mpeg_pes_frame_rate_extension_n = -1; /* INTEGER_0_3 */
84 static int hf_mpeg_pes_frame_rate_extension_d = -1; /* INTEGER_0_3 */
85 static int hf_mpeg_pes_drop_frame_flag = -1; /* BOOLEAN */
86 static int hf_mpeg_pes_hour = -1; /* INTEGER_0_32 */
87 static int hf_mpeg_pes_minute = -1; /* INTEGER_0_64 */
88 static int hf_mpeg_pes_second = -1; /* INTEGER_0_64 */
89 static int hf_mpeg_pes_frame = -1; /* INTEGER_0_64 */
90 static int hf_mpeg_pes_closed_gop = -1; /* BOOLEAN */
91 static int hf_mpeg_pes_broken_gop = -1; /* BOOLEAN */
92 static int hf_mpeg_pes_must_be_zero_01 = -1; /* BIT_STRING_SIZE_5 */
93 static int hf_mpeg_pes_temporal_sequence_number = -1; /* BIT_STRING_SIZE_10 */
94 static int hf_mpeg_pes_frame_type = -1; /* T_frame_type */
95 static int hf_mpeg_pes_vbv_delay = -1; /* BIT_STRING_SIZE_16 */
97 /*--- End of included file: packet-mpeg-pes-hf.c ---*/
98 #line 36 "../../asn1/mpeg-pes/packet-mpeg-pes-template.c"
100 /*--- Included file: packet-mpeg-pes-ett.c ---*/
101 #line 1 "../../asn1/mpeg-pes/packet-mpeg-pes-ett.c"
102 static gint ett_mpeg_pes_PES = -1;
103 static gint ett_mpeg_pes_Stream = -1;
104 static gint ett_mpeg_pes_Sequence_header = -1;
105 static gint ett_mpeg_pes_Sequence_extension = -1;
106 static gint ett_mpeg_pes_Group_of_pictures = -1;
107 static gint ett_mpeg_pes_Picture = -1;
109 /*--- End of included file: packet-mpeg-pes-ett.c ---*/
110 #line 37 "../../asn1/mpeg-pes/packet-mpeg-pes-template.c"
112 /*--- Included file: packet-mpeg-pes-fn.c ---*/
113 #line 1 "../../asn1/mpeg-pes/packet-mpeg-pes-fn.c"
116 static int
117 dissect_mpeg_pes_OCTET_STRING_SIZE_3(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
118 offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index,
119 3, 3, FALSE, NULL);
121 return offset;
125 static const value_string mpeg_pes_T_stream_vals[] = {
126 { 0, "picture" },
127 { 179, "sequence-header" },
128 { 181, "sequence-header-extension" },
129 { 184, "group-of-pictures" },
130 { 185, "program-end" },
131 { 186, "pack-header" },
132 { 187, "system-header" },
133 { 188, "program-stream-map" },
134 { 189, "private-stream-1" },
135 { 190, "padding-stream" },
136 { 191, "private-stream-2" },
137 { 192, "audio-stream" },
138 { 224, "video-stream" },
139 { 0, NULL }
143 static int
144 dissect_mpeg_pes_T_stream(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
145 offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
146 0U, 255U, NULL, FALSE);
148 return offset;
152 static const per_sequence_t PES_sequence[] = {
153 { &hf_mpeg_pes_prefix , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_OCTET_STRING_SIZE_3 },
154 { &hf_mpeg_pes_stream , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_T_stream },
155 { NULL, 0, 0, NULL }
158 static int
159 dissect_mpeg_pes_PES(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
160 offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
161 ett_mpeg_pes_PES, PES_sequence);
163 return offset;
168 static int
169 dissect_mpeg_pes_INTEGER_0_65535(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
170 offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
171 0U, 65535U, NULL, FALSE);
173 return offset;
178 static int
179 dissect_mpeg_pes_BOOLEAN(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
180 offset = dissect_per_boolean(tvb, offset, actx, tree, hf_index, NULL);
182 return offset;
186 static const value_string mpeg_pes_T_scrambling_control_vals[] = {
187 { 0, "not-scrambled" },
188 { 0, NULL }
192 static int
193 dissect_mpeg_pes_T_scrambling_control(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
194 offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
195 0U, 3U, NULL, FALSE);
197 return offset;
202 static int
203 dissect_mpeg_pes_INTEGER_0_255(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
204 offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
205 0U, 255U, NULL, FALSE);
207 return offset;
211 static const per_sequence_t Stream_sequence[] = {
212 { &hf_mpeg_pes_length , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_INTEGER_0_65535 },
213 { &hf_mpeg_pes_must_be_one, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
214 { &hf_mpeg_pes_must_be_zero, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
215 { &hf_mpeg_pes_scrambling_control, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_T_scrambling_control },
216 { &hf_mpeg_pes_priority , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
217 { &hf_mpeg_pes_data_alignment, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
218 { &hf_mpeg_pes_copyright , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
219 { &hf_mpeg_pes_original , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
220 { &hf_mpeg_pes_pts_flag , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
221 { &hf_mpeg_pes_dts_flag , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
222 { &hf_mpeg_pes_escr_flag , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
223 { &hf_mpeg_pes_es_rate_flag, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
224 { &hf_mpeg_pes_dsm_trick_mode_flag, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
225 { &hf_mpeg_pes_additional_copy_info_flag, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
226 { &hf_mpeg_pes_crc_flag , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
227 { &hf_mpeg_pes_extension_flag, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
228 { &hf_mpeg_pes_header_data_length, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_INTEGER_0_255 },
229 { NULL, 0, 0, NULL }
232 static int
233 dissect_mpeg_pes_Stream(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
234 offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
235 ett_mpeg_pes_Stream, Stream_sequence);
237 return offset;
242 static int
243 dissect_mpeg_pes_BIT_STRING_SIZE_12(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
244 offset = dissect_per_bit_string(tvb, offset, actx, tree, hf_index,
245 12, 12, FALSE, NULL);
247 return offset;
251 static const value_string mpeg_pes_T_aspect_ratio_vals[] = {
252 { 1, "aspect-1to1" },
253 { 2, "aspect-4to3" },
254 { 3, "aspect-16to9" },
255 { 4, "aspect-2-21to1" },
256 { 0, NULL }
260 static int
261 dissect_mpeg_pes_T_aspect_ratio(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
262 offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
263 0U, 15U, NULL, FALSE);
265 return offset;
269 static const value_string mpeg_pes_T_frame_rate_vals[] = {
270 { 0, "reserved" },
271 { 23976, "fr" },
272 { 24000, "fr" },
273 { 25000, "fr" },
274 { 29970, "fr" },
275 { 30000, "fr" },
276 { 50000, "fr" },
277 { 59940, "fr" },
278 { 60000, "fr" },
279 { 0, NULL }
282 static guint32 T_frame_rate_value_map[9+0] = {0, 23976, 24000, 25000, 29970, 30000, 50000, 59940, 60000};
284 static int
285 dissect_mpeg_pes_T_frame_rate(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
286 offset = dissect_per_enumerated(tvb, offset, actx, tree, hf_index,
287 9, NULL, FALSE, 0, T_frame_rate_value_map);
289 return offset;
294 static int
295 dissect_mpeg_pes_BIT_STRING_SIZE_18(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
296 offset = dissect_per_bit_string(tvb, offset, actx, tree, hf_index,
297 18, 18, FALSE, NULL);
299 return offset;
304 static int
305 dissect_mpeg_pes_BIT_STRING_SIZE_10(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
306 offset = dissect_per_bit_string(tvb, offset, actx, tree, hf_index,
307 10, 10, FALSE, NULL);
309 return offset;
313 static const per_sequence_t Sequence_header_sequence[] = {
314 { &hf_mpeg_pes_horizontal_size, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BIT_STRING_SIZE_12 },
315 { &hf_mpeg_pes_vertical_size, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BIT_STRING_SIZE_12 },
316 { &hf_mpeg_pes_aspect_ratio, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_T_aspect_ratio },
317 { &hf_mpeg_pes_frame_rate , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_T_frame_rate },
318 { &hf_mpeg_pes_bit_rate , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BIT_STRING_SIZE_18 },
319 { &hf_mpeg_pes_must_be_one, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
320 { &hf_mpeg_pes_vbv_buffer_size, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BIT_STRING_SIZE_10 },
321 { &hf_mpeg_pes_constrained_parameters_flag, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
322 { &hf_mpeg_pes_load_intra_quantiser_matrix, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
323 { &hf_mpeg_pes_load_non_intra_quantiser_matrix, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
324 { NULL, 0, 0, NULL }
327 static int
328 dissect_mpeg_pes_Sequence_header(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
329 offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
330 ett_mpeg_pes_Sequence_header, Sequence_header_sequence);
332 return offset;
337 static int
338 dissect_mpeg_pes_BIT_STRING_SIZE_4(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
339 offset = dissect_per_bit_string(tvb, offset, actx, tree, hf_index,
340 4, 4, FALSE, NULL);
342 return offset;
347 static int
348 dissect_mpeg_pes_INTEGER_0_3(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
349 offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
350 0U, 3U, NULL, FALSE);
352 return offset;
356 static const per_sequence_t Sequence_extension_sequence[] = {
357 { &hf_mpeg_pes_must_be_0001, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BIT_STRING_SIZE_4 },
358 { &hf_mpeg_pes_profile_and_level, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_INTEGER_0_255 },
359 { &hf_mpeg_pes_progressive_sequence, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
360 { &hf_mpeg_pes_chroma_format, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_INTEGER_0_3 },
361 { &hf_mpeg_pes_horizontal_size_extension, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_INTEGER_0_3 },
362 { &hf_mpeg_pes_vertical_size_extension, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_INTEGER_0_3 },
363 { &hf_mpeg_pes_bit_rate_extension, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BIT_STRING_SIZE_12 },
364 { &hf_mpeg_pes_must_be_one, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
365 { &hf_mpeg_pes_vbv_buffer_size_extension, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_INTEGER_0_255 },
366 { &hf_mpeg_pes_low_delay , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
367 { &hf_mpeg_pes_frame_rate_extension_n, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_INTEGER_0_3 },
368 { &hf_mpeg_pes_frame_rate_extension_d, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_INTEGER_0_3 },
369 { NULL, 0, 0, NULL }
372 static int
373 dissect_mpeg_pes_Sequence_extension(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
374 offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
375 ett_mpeg_pes_Sequence_extension, Sequence_extension_sequence);
377 return offset;
382 static int
383 dissect_mpeg_pes_INTEGER_0_32(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
384 offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
385 0U, 32U, NULL, FALSE);
387 return offset;
392 static int
393 dissect_mpeg_pes_INTEGER_0_64(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
394 offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
395 0U, 64U, NULL, FALSE);
397 return offset;
402 static int
403 dissect_mpeg_pes_BIT_STRING_SIZE_5(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
404 offset = dissect_per_bit_string(tvb, offset, actx, tree, hf_index,
405 5, 5, FALSE, NULL);
407 return offset;
411 static const per_sequence_t Group_of_pictures_sequence[] = {
412 { &hf_mpeg_pes_drop_frame_flag, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
413 { &hf_mpeg_pes_hour , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_INTEGER_0_32 },
414 { &hf_mpeg_pes_minute , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_INTEGER_0_64 },
415 { &hf_mpeg_pes_must_be_one, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
416 { &hf_mpeg_pes_second , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_INTEGER_0_64 },
417 { &hf_mpeg_pes_frame , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_INTEGER_0_64 },
418 { &hf_mpeg_pes_closed_gop , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
419 { &hf_mpeg_pes_broken_gop , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BOOLEAN },
420 { &hf_mpeg_pes_must_be_zero_01, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BIT_STRING_SIZE_5 },
421 { NULL, 0, 0, NULL }
424 static int
425 dissect_mpeg_pes_Group_of_pictures(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
426 offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
427 ett_mpeg_pes_Group_of_pictures, Group_of_pictures_sequence);
429 return offset;
433 static const value_string mpeg_pes_T_frame_type_vals[] = {
434 { 1, "i-frame" },
435 { 2, "p-frame" },
436 { 3, "b-frame" },
437 { 4, "d-frame" },
438 { 0, NULL }
442 static int
443 dissect_mpeg_pes_T_frame_type(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
444 offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
445 0U, 7U, NULL, FALSE);
447 return offset;
452 static int
453 dissect_mpeg_pes_BIT_STRING_SIZE_16(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
454 offset = dissect_per_bit_string(tvb, offset, actx, tree, hf_index,
455 16, 16, FALSE, NULL);
457 return offset;
461 static const per_sequence_t Picture_sequence[] = {
462 { &hf_mpeg_pes_temporal_sequence_number, ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BIT_STRING_SIZE_10 },
463 { &hf_mpeg_pes_frame_type , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_T_frame_type },
464 { &hf_mpeg_pes_vbv_delay , ASN1_NO_EXTENSIONS , ASN1_NOT_OPTIONAL, dissect_mpeg_pes_BIT_STRING_SIZE_16 },
465 { NULL, 0, 0, NULL }
468 static int
469 dissect_mpeg_pes_Picture(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
470 offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
471 ett_mpeg_pes_Picture, Picture_sequence);
473 return offset;
477 /*--- End of included file: packet-mpeg-pes-fn.c ---*/
478 #line 38 "../../asn1/mpeg-pes/packet-mpeg-pes-template.c"
480 static int proto_mpeg = -1;
481 static int proto_mpeg_pes = -1;
483 static int ett_mpeg_pes_pack_header = -1;
484 static int ett_mpeg_pes_header_data = -1;
485 static int ett_mpeg_pes_trick_mode = -1;
487 static int hf_mpeg_pes_pack_header = -1;
488 static int hf_mpeg_pes_scr = -1;
489 static int hf_mpeg_pes_program_mux_rate = -1;
490 static int hf_mpeg_pes_stuffing_length = -1;
491 static int hf_mpeg_pes_stuffing = -1;
492 static int hf_mpeg_pes_extension = -1;
493 static int hf_mpeg_pes_header_data = -1;
494 static int hf_mpeg_pes_pts = -1;
495 static int hf_mpeg_pes_dts = -1;
496 static int hf_mpeg_pes_escr = -1;
497 static int hf_mpeg_pes_es_rate = -1;
498 static int hf_mpeg_pes_dsm_trick_mode = -1;
499 static int hf_mpeg_pes_dsm_trick_mode_control = -1;
500 static int hf_mpeg_pes_dsm_trick_mode_field_id = -1;
501 static int hf_mpeg_pes_dsm_trick_mode_intra_slice_refresh = -1;
502 static int hf_mpeg_pes_dsm_trick_mode_frequency_truncation = -1;
503 static int hf_mpeg_pes_dsm_trick_mode_rep_cntrl = -1;
504 static int hf_mpeg_pes_copy_info = -1;
505 static int hf_mpeg_pes_crc = -1;
506 static int hf_mpeg_pes_extension_flags = -1;
507 static int hf_mpeg_pes_private_data = -1;
508 static int hf_mpeg_pes_pack_length = -1;
509 static int hf_mpeg_pes_sequence = -1;
510 static int hf_mpeg_pes_pstd_buffer = -1;
511 static int hf_mpeg_pes_extension2 = -1;
512 static int hf_mpeg_pes_padding = -1;
513 static int hf_mpeg_pes_data = -1;
515 static int hf_mpeg_video_sequence_header = -1;
516 static int hf_mpeg_video_sequence_extension = -1;
517 static int hf_mpeg_video_group_of_pictures = -1;
518 static int hf_mpeg_video_picture = -1;
519 static int hf_mpeg_video_quantization_matrix = -1;
520 static int hf_mpeg_video_data = -1;
522 enum { PES_PREFIX = 1 };
524 enum {
525 STREAM_PICTURE = 0x00,
526 STREAM_SEQUENCE = 0xb3,
527 STREAM_SEQUENCE_EXTENSION = 0xb5,
528 STREAM_GOP = 0xb8,
529 STREAM_END = 0xb9,
530 STREAM_PACK = 0xba,
531 STREAM_SYSTEM = 0xbb,
532 STREAM_PROGRAM = 0xbc,
533 STREAM_PRIVATE1 = 0xbd,
534 STREAM_PADDING = 0xbe,
535 STREAM_PRIVATE2 = 0xbf,
536 STREAM_AUDIO = 0xc0,
537 STREAM_VIDEO = 0xe0
540 enum {
541 PTS_FLAG = 0x80,
542 DTS_FLAG = 0x40,
543 ESCR_FLAG = 0x20,
544 ES_RATE_FLAG = 0x10,
545 DSM_TRICK_MODE_FLAG = 0x08,
546 COPY_INFO_FLAG = 0x04,
547 CRC_FLAG = 0x02,
548 EXTENSION_FLAG = 0x01
551 enum {
552 PRIVATE_DATA_FLAG = 0x80,
553 PACK_LENGTH_FLAG = 0x40,
554 SEQUENCE_FLAG = 0x20,
555 PSTD_BUFFER_FLAG = 0x10,
556 MUST_BE_ONES = 0x07,
557 EXTENSION_FLAG2 = 0x01
560 enum {
561 FAST_FORWARD_CONTROL = 0x00,
562 SLOW_MOTION_CONTROL = 0x01,
563 FREEZE_FRAME_CONTROL = 0x02,
564 FAST_REVERSE_CONTROL = 0x03,
565 SLOW_REVERSE_CONTROL = 0x04
568 static const value_string mpeg_pes_TrickModeControl_vals[] = {
569 { FAST_FORWARD_CONTROL, "fast-forward" },
570 { SLOW_MOTION_CONTROL, "slow-motion" },
571 { FREEZE_FRAME_CONTROL, "freeze-frame" },
572 { FAST_REVERSE_CONTROL, "fast-reverse" },
573 { SLOW_REVERSE_CONTROL, "slow-reverse" },
574 { 5, "reserved" },
575 { 6, "reserved" },
576 { 7, "reserved" },
577 { 0, NULL }
580 static const value_string mpeg_pes_TrickModeFieldId_vals[] = {
581 { 0, "display-from-top-field-only" },
582 { 1, "display-from-bottom-field-only" },
583 { 2, "display-complete-frame" },
584 { 3, "reserved" },
585 { 0, NULL }
588 static const value_string mpeg_pes_TrickModeIntraSliceRefresh_vals[] = {
589 { 0, "macroblocks-may-not-be-missing" },
590 { 1, "macroblocks-may-be-missing" },
591 { 0, NULL }
594 static const value_string mpeg_pes_TrickModeFrequencyTruncation_vals[] = {
595 { 0, "only-DC-coefficients-are-non-zero" },
596 { 1, "only-the-first-three-coefficients-are-non-zero" },
597 { 2, "only-the-first-six-coefficients-are-non-zero" },
598 { 3, "all-coefficients-may-be-non-zero" },
599 { 0, NULL }
602 #define TSHZ 90000
604 static guint64 decode_time_stamp(tvbuff_t *tvb, gint offset, nstime_t *nst)
606 guint64 bytes = tvb_get_ntoh40(tvb, offset);
607 guint64 ts =
608 (bytes >> 33 & 0x0007) << 30 |
609 (bytes >> 17 & 0x7fff) << 15 |
610 (bytes >> 1 & 0x7fff) << 0;
611 unsigned int rem = (unsigned int)(ts % TSHZ);
612 nst->secs = (time_t)(ts / TSHZ);
613 nst->nsecs = (int)(G_GINT64_CONSTANT(1000000000) * rem / TSHZ);
614 return ts;
617 #define SCRHZ 27000000
619 static guint64 decode_clock_reference(tvbuff_t *tvb, gint offset,
620 nstime_t *nst)
622 guint64 bytes = tvb_get_ntoh48(tvb, offset);
623 guint64 ts =
624 (bytes >> 43 & 0x0007) << 30 |
625 (bytes >> 27 & 0x7fff) << 15 |
626 (bytes >> 11 & 0x7fff) << 0;
627 unsigned int ext = (unsigned int)((bytes >> 1) & 0x1ff);
628 guint64 cr = 300 * ts + ext;
629 unsigned int rem = (unsigned int)(cr % SCRHZ);
630 nst->secs = (time_t)(cr / SCRHZ);
631 nst->nsecs = (int)(G_GINT64_CONSTANT(1000000000) * rem / SCRHZ);
632 return cr;
635 static int
636 dissect_mpeg_pes_header_data(tvbuff_t *tvb, packet_info *pinfo,
637 proto_tree *root, unsigned int flags)
639 proto_item *item = proto_tree_add_item(root, hf_mpeg_pes_header_data, tvb,
640 0, -1, ENC_NA);
641 proto_tree *tree = proto_item_add_subtree(item, ett_mpeg_pes_header_data);
643 gint offset = 0;
644 if (flags & PTS_FLAG) {
645 nstime_t nst;
646 decode_time_stamp(tvb, offset, &nst);
647 proto_tree_add_time(tree, hf_mpeg_pes_pts, tvb,
648 offset, 5, &nst);
649 offset += 5;
651 SET_ADDRESS(&pinfo->dst, AT_NONE, 0, NULL);
652 col_add_fstr(pinfo->cinfo, COL_DEF_DST,
653 "PTS %ld.%09u",
654 (long) nst.secs, nst.nsecs);
656 if (flags & DTS_FLAG) {
657 nstime_t nst;
658 decode_time_stamp(tvb, offset, &nst);
659 proto_tree_add_time(tree, hf_mpeg_pes_dts, tvb,
660 offset, 5, &nst);
661 offset += 5;
663 SET_ADDRESS(&pinfo->src, AT_NONE, 0, NULL);
664 col_add_fstr(pinfo->cinfo, COL_DEF_SRC,
665 "DTS %ld.%09u",
666 (long) nst.secs, nst.nsecs);
668 if (flags & ESCR_FLAG) {
669 nstime_t nst;
670 decode_clock_reference(tvb, offset, &nst);
671 proto_tree_add_time(tree, hf_mpeg_pes_escr, tvb,
672 offset, 6, &nst);
673 offset += 6;
675 if (flags & ES_RATE_FLAG) {
676 unsigned int es_rate = (tvb_get_ntohs(tvb, offset) >> 1 & 0x3fff) * 50;
677 proto_tree_add_uint(tree, hf_mpeg_pes_es_rate, tvb,
678 offset, 3, es_rate);
679 offset += 3;
681 if (flags & DSM_TRICK_MODE_FLAG)
683 guint8 value = tvb_get_guint8(tvb, offset);
684 guint8 control;
685 proto_tree *trick_tree;
686 proto_item *trick_item;
688 trick_item = proto_tree_add_item(item,
689 hf_mpeg_pes_dsm_trick_mode, tvb,
690 offset, 1, ENC_NA);
692 trick_tree = proto_item_add_subtree(trick_item,
693 ett_mpeg_pes_trick_mode);
695 control = (value >> 5);
696 proto_tree_add_uint(trick_tree,
697 hf_mpeg_pes_dsm_trick_mode_control, tvb,
698 offset, 1,
699 control);
701 if (control == FAST_FORWARD_CONTROL
702 || control == FAST_REVERSE_CONTROL)
704 proto_tree_add_uint(trick_tree,
705 hf_mpeg_pes_dsm_trick_mode_field_id, tvb,
706 offset, 1,
707 (value & 0x18) >> 3);
709 proto_tree_add_uint(trick_tree,
710 hf_mpeg_pes_dsm_trick_mode_intra_slice_refresh, tvb,
711 offset, 1,
712 (value & 0x04) >> 2);
714 proto_tree_add_uint(trick_tree,
715 hf_mpeg_pes_dsm_trick_mode_frequency_truncation, tvb,
716 offset, 1,
717 (value & 0x03));
719 else if (control == SLOW_MOTION_CONTROL
720 || control == SLOW_REVERSE_CONTROL)
722 proto_tree_add_uint(trick_tree,
723 hf_mpeg_pes_dsm_trick_mode_rep_cntrl, tvb,
724 offset, 1,
725 (value & 0x1F));
727 else if (control == FREEZE_FRAME_CONTROL)
729 proto_tree_add_uint(trick_tree,
730 hf_mpeg_pes_dsm_trick_mode_field_id, tvb,
731 offset, 1,
732 (value & 0x18) >> 3);
735 offset += 1;
737 if (flags & COPY_INFO_FLAG) {
738 proto_tree_add_item(tree, hf_mpeg_pes_copy_info, tvb,
739 offset, 1, ENC_BIG_ENDIAN);
740 offset++;
742 if (flags & CRC_FLAG) {
743 proto_tree_add_item(tree, hf_mpeg_pes_crc, tvb,
744 offset, 2, ENC_BIG_ENDIAN);
745 offset += 2;
748 if (flags & EXTENSION_FLAG) {
749 int flags2 = tvb_get_guint8(tvb, offset);
750 proto_tree_add_item(tree, hf_mpeg_pes_extension_flags, tvb,
751 offset, 1, ENC_BIG_ENDIAN);
752 offset++;
754 if (flags2 & PRIVATE_DATA_FLAG) {
755 proto_tree_add_item(tree, hf_mpeg_pes_private_data, tvb,
756 offset, 16, ENC_BIG_ENDIAN);
757 offset += 16;
759 if (flags2 & PACK_LENGTH_FLAG) {
760 proto_tree_add_item(tree, hf_mpeg_pes_pack_length, tvb,
761 offset, 1, ENC_BIG_ENDIAN);
762 offset++;
764 if (flags2 & SEQUENCE_FLAG) {
765 proto_tree_add_item(tree, hf_mpeg_pes_sequence, tvb,
766 offset, 2, ENC_BIG_ENDIAN);
767 offset += 2;
769 if (flags2 & PSTD_BUFFER_FLAG) {
770 unsigned int pstd = tvb_get_ntohs(tvb, offset);
771 proto_tree_add_uint(tree, hf_mpeg_pes_pstd_buffer, tvb,
772 offset, 2, (pstd & 0x2000 ? 1024 : 128) * (pstd & 0x1ff));
773 offset += 2;
775 if (flags2 & EXTENSION_FLAG2) {
776 proto_tree_add_item(tree, hf_mpeg_pes_extension2, tvb,
777 offset, 2, ENC_BIG_ENDIAN);
778 offset += 2;
781 return offset;
784 static gint
785 dissect_mpeg_pes_pack_header(tvbuff_t *tvb, gint offset,
786 packet_info *pinfo, proto_tree *root)
788 unsigned int program_mux_rate, stuffing_length;
790 proto_item *item = proto_tree_add_item(root, hf_mpeg_pes_pack_header, tvb,
791 offset / 8, 10, ENC_NA);
792 proto_tree *tree = proto_item_add_subtree(item, ett_mpeg_pes_pack_header);
794 nstime_t nst;
795 decode_clock_reference(tvb, offset / 8, &nst);
796 proto_tree_add_time(tree, hf_mpeg_pes_scr, tvb, offset / 8, 6, &nst);
797 offset += 6 * 8;
799 program_mux_rate = (tvb_get_ntoh24(tvb, offset / 8) >> 2) * 50;
800 proto_tree_add_uint(tree, hf_mpeg_pes_program_mux_rate, tvb, offset / 8, 3,
801 program_mux_rate);
802 offset += 3 * 8;
804 SET_ADDRESS(&pinfo->src, AT_NONE, 0, NULL);
805 col_add_fstr(pinfo->cinfo, COL_DEF_SRC, "%u B/s", program_mux_rate);
807 stuffing_length = tvb_get_guint8(tvb, offset / 8) & 0x07;
808 proto_tree_add_item(tree, hf_mpeg_pes_stuffing_length, tvb,
809 offset / 8, 1, ENC_BIG_ENDIAN);
810 offset += 1 * 8;
812 if (stuffing_length > 0) {
813 proto_tree_add_item(tree, hf_mpeg_pes_stuffing, tvb,
814 offset / 8, stuffing_length, ENC_NA);
815 offset += stuffing_length * 8;
818 return offset;
821 static void
822 dissect_mpeg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
824 static gboolean
825 dissect_mpeg_pes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
827 int prefix;
828 int stream;
829 asn1_ctx_t asn1_ctx;
830 gint offset = 0;
831 const char *s;
833 if (!tvb_bytes_exist(tvb, 0, 3))
834 return FALSE; /* not enough bytes for a PES prefix */
836 prefix = tvb_get_ntoh24(tvb, 0);
837 if (prefix != PES_PREFIX)
838 return FALSE;
839 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPEG PES");
840 col_clear(pinfo->cinfo, COL_INFO);
842 stream = tvb_get_guint8(tvb, 3);
843 s = try_val_to_str(stream, mpeg_pes_T_stream_vals);
844 if (s != NULL)
845 col_set_str(pinfo->cinfo, COL_INFO, s);
847 #if 0
848 if (tree == NULL)
849 return TRUE;
850 #endif
851 asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, pinfo);
852 offset = dissect_mpeg_pes_PES(tvb, offset, &asn1_ctx,
853 tree, proto_mpeg_pes);
855 if (stream == STREAM_PICTURE) {
856 int frame_type;
858 frame_type = tvb_get_guint8(tvb, 5) >> 3 & 0x07;
859 s = try_val_to_str(frame_type, mpeg_pes_T_frame_type_vals);
860 if (s != NULL)
861 col_set_str(pinfo->cinfo, COL_INFO, s);
863 offset = dissect_mpeg_pes_Picture(tvb, offset, &asn1_ctx,
864 tree, hf_mpeg_video_picture);
865 proto_tree_add_item(tree, hf_mpeg_video_data, tvb,
866 offset / 8, -1, ENC_NA);
867 } else if (stream == STREAM_SEQUENCE) {
868 tvbuff_t *es;
870 offset = dissect_mpeg_pes_Sequence_header(tvb, offset, &asn1_ctx,
871 tree, hf_mpeg_video_sequence_header);
873 proto_tree_add_item(tree, hf_mpeg_video_quantization_matrix, tvb,
874 offset / 8, 64, ENC_NA);
875 offset += 64 * 8;
877 es = tvb_new_subset_remaining(tvb, offset / 8);
878 dissect_mpeg_pes(es, pinfo, tree, NULL);
879 } else if (stream == STREAM_SEQUENCE_EXTENSION) {
880 tvbuff_t *es;
882 offset = dissect_mpeg_pes_Sequence_extension(tvb, offset, &asn1_ctx,
883 tree, hf_mpeg_video_sequence_extension);
885 es = tvb_new_subset_remaining(tvb, offset / 8);
886 dissect_mpeg_pes(es, pinfo, tree, NULL);
887 } else if (stream == STREAM_GOP) {
888 tvbuff_t *es;
890 offset = dissect_mpeg_pes_Group_of_pictures(tvb, offset, &asn1_ctx,
891 tree, hf_mpeg_video_group_of_pictures);
893 es = tvb_new_subset_remaining(tvb, offset / 8);
894 dissect_mpeg_pes(es, pinfo, tree, NULL);
895 } else if (stream == STREAM_PACK) {
896 if (tvb_get_guint8(tvb, offset / 8) >> 6 == 1) {
897 dissect_mpeg_pes_pack_header(tvb, offset, pinfo, tree);
898 } else {
899 proto_tree_add_item(tree, hf_mpeg_pes_data, tvb,
900 offset / 8, 8, ENC_NA);
902 } else if (stream == STREAM_SYSTEM || stream == STREAM_PRIVATE2) {
903 unsigned int data_length = tvb_get_ntohs(tvb, offset / 8);
904 proto_tree_add_item(tree, hf_mpeg_pes_length, tvb,
905 offset / 8, 2, ENC_BIG_ENDIAN);
906 offset += 2 * 8;
908 proto_tree_add_item(tree, hf_mpeg_pes_data, tvb,
909 offset / 8, data_length, ENC_NA);
910 } else if (stream == STREAM_PADDING) {
911 unsigned int padding_length = tvb_get_ntohs(tvb, offset / 8);
912 proto_tree_add_item(tree, hf_mpeg_pes_length, tvb,
913 offset / 8, 2, ENC_BIG_ENDIAN);
914 offset += 2 * 8;
916 proto_tree_add_item(tree, hf_mpeg_pes_padding, tvb,
917 offset / 8, padding_length, ENC_NA);
918 } else if (stream == STREAM_PRIVATE1
919 || stream >= STREAM_AUDIO) {
920 int length = tvb_get_ntohs(tvb, 4);
922 if ((tvb_get_guint8(tvb, 6) & 0xc0) == 0x80) {
923 int header_length;
924 tvbuff_t *es;
926 offset = dissect_mpeg_pes_Stream(tvb, offset, &asn1_ctx,
927 tree, hf_mpeg_pes_extension);
928 /* https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2229
929 * A value of 0 indicates that the PES packet length is neither specified nor
930 * bounded and is allowed only in PES packets whose payload is a video elementary
931 * stream contained in Transport Stream packets.
932 * XXX Some one with access to the spec should check this
934 if(length !=0 && stream != STREAM_VIDEO){
935 length -= 5;
938 header_length = tvb_get_guint8(tvb, 8);
939 if (header_length > 0) {
940 int flags = tvb_get_guint8(tvb, 7);
941 tvbuff_t *header_data = tvb_new_subset(tvb, offset / 8,
942 header_length, header_length);
943 dissect_mpeg_pes_header_data(header_data, pinfo, tree, flags);
944 offset += header_length * 8;
945 /* length may be zero for Video stream */
946 if(length !=0 && stream != STREAM_VIDEO){
947 length -= header_length;
951 /* length may be zero for Video stream */
952 if(length==0){
953 proto_tree_add_item(tree, hf_mpeg_pes_data, tvb, (offset>>3),-1, ENC_NA);
954 return TRUE;
957 es = tvb_new_subset(tvb, offset / 8, -1, length);
958 if (tvb_get_ntoh24(es, 0) == PES_PREFIX)
959 dissect_mpeg_pes(es, pinfo, tree, NULL);
960 else if (tvb_get_guint8(es, 0) == 0xff)
961 dissect_mpeg(es, pinfo, tree);
962 else
963 proto_tree_add_item(tree, hf_mpeg_pes_data, es,
964 0, -1, ENC_NA);
965 } else {
966 unsigned int data_length = tvb_get_ntohs(tvb, offset / 8);
967 proto_tree_add_item(tree, hf_mpeg_pes_length, tvb,
968 offset / 8, 2, ENC_BIG_ENDIAN);
969 offset += 2 * 8;
971 proto_tree_add_item(tree, hf_mpeg_pes_data, tvb,
972 offset / 8, data_length, ENC_NA);
974 } else {
975 proto_tree_add_item(tree, hf_mpeg_pes_data, tvb,
976 offset / 8, -1, ENC_NA);
978 return TRUE;
981 static heur_dissector_list_t heur_subdissector_list;
983 static void
984 dissect_mpeg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
986 if (!dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, tree, NULL)) {
987 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPEG");
988 col_clear(pinfo->cinfo, COL_INFO);
989 if (tree)
990 proto_tree_add_item(tree, proto_mpeg, tvb, 0, -1, ENC_NA);
994 void
995 proto_register_mpeg_pes(void)
997 static hf_register_info hf[] = {
999 /*--- Included file: packet-mpeg-pes-hfarr.c ---*/
1000 #line 1 "../../asn1/mpeg-pes/packet-mpeg-pes-hfarr.c"
1001 { &hf_mpeg_pes_prefix,
1002 { "prefix", "mpeg-pes.prefix",
1003 FT_BYTES, BASE_NONE, NULL, 0,
1004 "OCTET_STRING_SIZE_3", HFILL }},
1005 { &hf_mpeg_pes_stream,
1006 { "stream", "mpeg-pes.stream",
1007 FT_UINT8, BASE_HEX, VALS(mpeg_pes_T_stream_vals), 0,
1008 NULL, HFILL }},
1009 { &hf_mpeg_pes_length,
1010 { "length", "mpeg-pes.length",
1011 FT_UINT16, BASE_DEC, NULL, 0,
1012 "INTEGER_0_65535", HFILL }},
1013 { &hf_mpeg_pes_must_be_one,
1014 { "must-be-one", "mpeg-pes.must_be_one",
1015 FT_BOOLEAN, BASE_NONE, NULL, 0,
1016 "BOOLEAN", HFILL }},
1017 { &hf_mpeg_pes_must_be_zero,
1018 { "must-be-zero", "mpeg-pes.must_be_zero",
1019 FT_BOOLEAN, BASE_NONE, NULL, 0,
1020 "BOOLEAN", HFILL }},
1021 { &hf_mpeg_pes_scrambling_control,
1022 { "scrambling-control", "mpeg-pes.scrambling_control",
1023 FT_UINT32, BASE_DEC, VALS(mpeg_pes_T_scrambling_control_vals), 0,
1024 NULL, HFILL }},
1025 { &hf_mpeg_pes_priority,
1026 { "priority", "mpeg-pes.priority",
1027 FT_BOOLEAN, BASE_NONE, NULL, 0,
1028 "BOOLEAN", HFILL }},
1029 { &hf_mpeg_pes_data_alignment,
1030 { "data-alignment", "mpeg-pes.data_alignment",
1031 FT_BOOLEAN, BASE_NONE, NULL, 0,
1032 "BOOLEAN", HFILL }},
1033 { &hf_mpeg_pes_copyright,
1034 { "copyright", "mpeg-pes.copyright",
1035 FT_BOOLEAN, BASE_NONE, NULL, 0,
1036 "BOOLEAN", HFILL }},
1037 { &hf_mpeg_pes_original,
1038 { "original", "mpeg-pes.original",
1039 FT_BOOLEAN, BASE_NONE, NULL, 0,
1040 "BOOLEAN", HFILL }},
1041 { &hf_mpeg_pes_pts_flag,
1042 { "pts-flag", "mpeg-pes.pts_flag",
1043 FT_BOOLEAN, BASE_NONE, NULL, 0,
1044 "BOOLEAN", HFILL }},
1045 { &hf_mpeg_pes_dts_flag,
1046 { "dts-flag", "mpeg-pes.dts_flag",
1047 FT_BOOLEAN, BASE_NONE, NULL, 0,
1048 "BOOLEAN", HFILL }},
1049 { &hf_mpeg_pes_escr_flag,
1050 { "escr-flag", "mpeg-pes.escr_flag",
1051 FT_BOOLEAN, BASE_NONE, NULL, 0,
1052 "BOOLEAN", HFILL }},
1053 { &hf_mpeg_pes_es_rate_flag,
1054 { "es-rate-flag", "mpeg-pes.es_rate_flag",
1055 FT_BOOLEAN, BASE_NONE, NULL, 0,
1056 "BOOLEAN", HFILL }},
1057 { &hf_mpeg_pes_dsm_trick_mode_flag,
1058 { "dsm-trick-mode-flag", "mpeg-pes.dsm_trick_mode_flag",
1059 FT_BOOLEAN, BASE_NONE, NULL, 0,
1060 "BOOLEAN", HFILL }},
1061 { &hf_mpeg_pes_additional_copy_info_flag,
1062 { "additional-copy-info-flag", "mpeg-pes.additional_copy_info_flag",
1063 FT_BOOLEAN, BASE_NONE, NULL, 0,
1064 "BOOLEAN", HFILL }},
1065 { &hf_mpeg_pes_crc_flag,
1066 { "crc-flag", "mpeg-pes.crc_flag",
1067 FT_BOOLEAN, BASE_NONE, NULL, 0,
1068 "BOOLEAN", HFILL }},
1069 { &hf_mpeg_pes_extension_flag,
1070 { "extension-flag", "mpeg-pes.extension_flag",
1071 FT_BOOLEAN, BASE_NONE, NULL, 0,
1072 "BOOLEAN", HFILL }},
1073 { &hf_mpeg_pes_header_data_length,
1074 { "header-data-length", "mpeg-pes.header_data_length",
1075 FT_UINT32, BASE_DEC, NULL, 0,
1076 "INTEGER_0_255", HFILL }},
1077 { &hf_mpeg_pes_horizontal_size,
1078 { "horizontal-size", "mpeg-pes.horizontal_size",
1079 FT_BYTES, BASE_NONE, NULL, 0,
1080 "BIT_STRING_SIZE_12", HFILL }},
1081 { &hf_mpeg_pes_vertical_size,
1082 { "vertical-size", "mpeg-pes.vertical_size",
1083 FT_BYTES, BASE_NONE, NULL, 0,
1084 "BIT_STRING_SIZE_12", HFILL }},
1085 { &hf_mpeg_pes_aspect_ratio,
1086 { "aspect-ratio", "mpeg-pes.aspect_ratio",
1087 FT_UINT32, BASE_DEC, VALS(mpeg_pes_T_aspect_ratio_vals), 0,
1088 "T_aspect_ratio", HFILL }},
1089 { &hf_mpeg_pes_frame_rate,
1090 { "frame-rate", "mpeg-pes.frame_rate",
1091 FT_UINT32, BASE_DEC, VALS(mpeg_pes_T_frame_rate_vals), 0,
1092 NULL, HFILL }},
1093 { &hf_mpeg_pes_bit_rate,
1094 { "bit-rate", "mpeg-pes.bit_rate",
1095 FT_BYTES, BASE_NONE, NULL, 0,
1096 "BIT_STRING_SIZE_18", HFILL }},
1097 { &hf_mpeg_pes_vbv_buffer_size,
1098 { "vbv-buffer-size", "mpeg-pes.vbv_buffer_size",
1099 FT_BYTES, BASE_NONE, NULL, 0,
1100 "BIT_STRING_SIZE_10", HFILL }},
1101 { &hf_mpeg_pes_constrained_parameters_flag,
1102 { "constrained-parameters-flag", "mpeg-pes.constrained_parameters_flag",
1103 FT_BOOLEAN, BASE_NONE, NULL, 0,
1104 "BOOLEAN", HFILL }},
1105 { &hf_mpeg_pes_load_intra_quantiser_matrix,
1106 { "load-intra-quantiser-matrix", "mpeg-pes.load_intra_quantiser_matrix",
1107 FT_BOOLEAN, BASE_NONE, NULL, 0,
1108 "BOOLEAN", HFILL }},
1109 { &hf_mpeg_pes_load_non_intra_quantiser_matrix,
1110 { "load-non-intra-quantiser-matrix", "mpeg-pes.load_non_intra_quantiser_matrix",
1111 FT_BOOLEAN, BASE_NONE, NULL, 0,
1112 "BOOLEAN", HFILL }},
1113 { &hf_mpeg_pes_must_be_0001,
1114 { "must-be-0001", "mpeg-pes.must_be_0001",
1115 FT_BYTES, BASE_NONE, NULL, 0,
1116 "BIT_STRING_SIZE_4", HFILL }},
1117 { &hf_mpeg_pes_profile_and_level,
1118 { "profile-and-level", "mpeg-pes.profile_and_level",
1119 FT_UINT32, BASE_DEC, NULL, 0,
1120 "INTEGER_0_255", HFILL }},
1121 { &hf_mpeg_pes_progressive_sequence,
1122 { "progressive-sequence", "mpeg-pes.progressive_sequence",
1123 FT_BOOLEAN, BASE_NONE, NULL, 0,
1124 "BOOLEAN", HFILL }},
1125 { &hf_mpeg_pes_chroma_format,
1126 { "chroma-format", "mpeg-pes.chroma_format",
1127 FT_UINT32, BASE_DEC, NULL, 0,
1128 "INTEGER_0_3", HFILL }},
1129 { &hf_mpeg_pes_horizontal_size_extension,
1130 { "horizontal-size-extension", "mpeg-pes.horizontal_size_extension",
1131 FT_UINT32, BASE_DEC, NULL, 0,
1132 "INTEGER_0_3", HFILL }},
1133 { &hf_mpeg_pes_vertical_size_extension,
1134 { "vertical-size-extension", "mpeg-pes.vertical_size_extension",
1135 FT_UINT32, BASE_DEC, NULL, 0,
1136 "INTEGER_0_3", HFILL }},
1137 { &hf_mpeg_pes_bit_rate_extension,
1138 { "bit-rate-extension", "mpeg-pes.bit_rate_extension",
1139 FT_BYTES, BASE_NONE, NULL, 0,
1140 "BIT_STRING_SIZE_12", HFILL }},
1141 { &hf_mpeg_pes_vbv_buffer_size_extension,
1142 { "vbv-buffer-size-extension", "mpeg-pes.vbv_buffer_size_extension",
1143 FT_UINT32, BASE_DEC, NULL, 0,
1144 "INTEGER_0_255", HFILL }},
1145 { &hf_mpeg_pes_low_delay,
1146 { "low-delay", "mpeg-pes.low_delay",
1147 FT_BOOLEAN, BASE_NONE, NULL, 0,
1148 "BOOLEAN", HFILL }},
1149 { &hf_mpeg_pes_frame_rate_extension_n,
1150 { "frame-rate-extension-n", "mpeg-pes.frame_rate_extension_n",
1151 FT_UINT32, BASE_DEC, NULL, 0,
1152 "INTEGER_0_3", HFILL }},
1153 { &hf_mpeg_pes_frame_rate_extension_d,
1154 { "frame-rate-extension-d", "mpeg-pes.frame_rate_extension_d",
1155 FT_UINT32, BASE_DEC, NULL, 0,
1156 "INTEGER_0_3", HFILL }},
1157 { &hf_mpeg_pes_drop_frame_flag,
1158 { "drop-frame-flag", "mpeg-pes.drop_frame_flag",
1159 FT_BOOLEAN, BASE_NONE, NULL, 0,
1160 "BOOLEAN", HFILL }},
1161 { &hf_mpeg_pes_hour,
1162 { "hour", "mpeg-pes.hour",
1163 FT_UINT32, BASE_DEC, NULL, 0,
1164 "INTEGER_0_32", HFILL }},
1165 { &hf_mpeg_pes_minute,
1166 { "minute", "mpeg-pes.minute",
1167 FT_UINT32, BASE_DEC, NULL, 0,
1168 "INTEGER_0_64", HFILL }},
1169 { &hf_mpeg_pes_second,
1170 { "second", "mpeg-pes.second",
1171 FT_UINT32, BASE_DEC, NULL, 0,
1172 "INTEGER_0_64", HFILL }},
1173 { &hf_mpeg_pes_frame,
1174 { "frame", "mpeg-pes.frame",
1175 FT_UINT32, BASE_DEC, NULL, 0,
1176 "INTEGER_0_64", HFILL }},
1177 { &hf_mpeg_pes_closed_gop,
1178 { "closed-gop", "mpeg-pes.closed_gop",
1179 FT_BOOLEAN, BASE_NONE, NULL, 0,
1180 "BOOLEAN", HFILL }},
1181 { &hf_mpeg_pes_broken_gop,
1182 { "broken-gop", "mpeg-pes.broken_gop",
1183 FT_BOOLEAN, BASE_NONE, NULL, 0,
1184 "BOOLEAN", HFILL }},
1185 { &hf_mpeg_pes_must_be_zero_01,
1186 { "must-be-zero", "mpeg-pes.must_be_zero",
1187 FT_BYTES, BASE_NONE, NULL, 0,
1188 "BIT_STRING_SIZE_5", HFILL }},
1189 { &hf_mpeg_pes_temporal_sequence_number,
1190 { "temporal-sequence-number", "mpeg-pes.temporal_sequence_number",
1191 FT_BYTES, BASE_NONE, NULL, 0,
1192 "BIT_STRING_SIZE_10", HFILL }},
1193 { &hf_mpeg_pes_frame_type,
1194 { "frame-type", "mpeg-pes.frame_type",
1195 FT_UINT32, BASE_DEC, VALS(mpeg_pes_T_frame_type_vals), 0,
1196 NULL, HFILL }},
1197 { &hf_mpeg_pes_vbv_delay,
1198 { "vbv-delay", "mpeg-pes.vbv_delay",
1199 FT_BYTES, BASE_NONE, NULL, 0,
1200 "BIT_STRING_SIZE_16", HFILL }},
1202 /*--- End of included file: packet-mpeg-pes-hfarr.c ---*/
1203 #line 558 "../../asn1/mpeg-pes/packet-mpeg-pes-template.c"
1204 { &hf_mpeg_pes_pack_header,
1205 { "Pack header", "mpeg-pes.pack",
1206 FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
1207 { &hf_mpeg_pes_scr,
1208 { "system clock reference (SCR)", "mpeg-pes.scr",
1209 FT_RELATIVE_TIME, BASE_NONE, NULL, 0, NULL, HFILL }},
1210 { &hf_mpeg_pes_program_mux_rate,
1211 { "PES program mux rate", "mpeg-pes.program-mux-rate",
1212 FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1213 { &hf_mpeg_pes_stuffing_length,
1214 { "PES stuffing length", "mpeg-pes.stuffing-length",
1215 FT_UINT8, BASE_DEC, NULL, 0x07, NULL, HFILL }},
1216 { &hf_mpeg_pes_stuffing,
1217 { "PES stuffing bytes", "mpeg-pes.stuffing",
1218 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1219 { &hf_mpeg_pes_extension,
1220 { "PES extension", "mpeg-pes.extension",
1221 FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
1222 { &hf_mpeg_pes_header_data,
1223 { "PES header data", "mpeg-pes.header-data",
1224 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1225 { &hf_mpeg_pes_pts,
1226 { "presentation time stamp (PTS)", "mpeg-pes.pts",
1227 FT_RELATIVE_TIME, BASE_NONE, NULL, 0, NULL, HFILL }},
1228 { &hf_mpeg_pes_dts,
1229 { "decode time stamp (DTS)", "mpeg-pes.dts",
1230 FT_RELATIVE_TIME, BASE_NONE, NULL, 0, NULL, HFILL }},
1231 { &hf_mpeg_pes_escr,
1232 { "elementary stream clock reference (ESCR)", "mpeg-pes.escr",
1233 FT_RELATIVE_TIME, BASE_NONE, NULL, 0, NULL, HFILL }},
1234 { &hf_mpeg_pes_es_rate,
1235 { "elementary stream rate", "mpeg-pes.es-rate",
1236 FT_UINT24, BASE_DEC, NULL, 0x7ffe, NULL, HFILL }},
1237 { &hf_mpeg_pes_dsm_trick_mode,
1238 { "Trick mode", "mpeg-pes.trick-mode",
1239 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1240 { &hf_mpeg_pes_dsm_trick_mode_control,
1241 { "control", "mpeg-pes.trick-mode-control",
1242 FT_UINT8, BASE_HEX, VALS(mpeg_pes_TrickModeControl_vals), 0,
1243 "mpeg_pes trick mode control", HFILL }},
1244 { &hf_mpeg_pes_dsm_trick_mode_field_id,
1245 { "field id", "mpeg-pes.trick-mode-field-id",
1246 FT_UINT8, BASE_HEX, VALS(mpeg_pes_TrickModeFieldId_vals), 0,
1247 "mpeg_pes trick mode field id", HFILL }},
1248 { &hf_mpeg_pes_dsm_trick_mode_intra_slice_refresh,
1249 { "intra slice refresh", "mpeg-pes.trick-mode-intra-slice-refresh",
1250 FT_UINT8, BASE_HEX, VALS(mpeg_pes_TrickModeIntraSliceRefresh_vals), 0,
1251 "mpeg_pes trick mode intra slice refresh", HFILL }},
1252 { &hf_mpeg_pes_dsm_trick_mode_frequency_truncation,
1253 { "frequency truncation", "mpeg-pes.trick-mode-frequeny-truncation",
1254 FT_UINT8, BASE_HEX, VALS(mpeg_pes_TrickModeFrequencyTruncation_vals), 0,
1255 "mpeg_pes trick mode frequency truncation", HFILL }},
1256 { &hf_mpeg_pes_dsm_trick_mode_rep_cntrl,
1257 { "rep cntrl", "mpeg-pes.trick-mode-rep-cntrl",
1258 FT_UINT8, BASE_HEX, NULL, 0, "mpeg_pes trick mode rep cntrl", HFILL }},
1259 { &hf_mpeg_pes_copy_info,
1260 { "copy info", "mpeg-pes.copy-info",
1261 FT_UINT8, BASE_DEC, NULL, 0x7f, NULL, HFILL }},
1262 { &hf_mpeg_pes_crc,
1263 { "CRC", "mpeg-pes.crc",
1264 FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1265 { &hf_mpeg_pes_extension_flags,
1266 { "extension flags", "mpeg-pes.extension-flags",
1267 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }},
1268 { &hf_mpeg_pes_private_data,
1269 { "private data", "mpeg-pes.private-data",
1270 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1271 { &hf_mpeg_pes_pack_length,
1272 { "pack length", "mpeg-pes.pack-length",
1273 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1274 { &hf_mpeg_pes_sequence,
1275 { "sequence", "mpeg-pes.sequence",
1276 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL }},
1277 { &hf_mpeg_pes_pstd_buffer,
1278 { "P-STD buffer size", "mpeg-pes.pstd-buffer",
1279 FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1280 { &hf_mpeg_pes_extension2,
1281 { "extension2", "mpeg-pes.extension2",
1282 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL }},
1283 { &hf_mpeg_pes_padding,
1284 { "PES padding", "mpeg-pes.padding",
1285 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1286 { &hf_mpeg_pes_data,
1287 { "PES data", "mpeg-pes.data",
1288 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1289 { &hf_mpeg_video_sequence_header,
1290 { "MPEG sequence header", "mpeg-video.sequence",
1291 FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
1292 { &hf_mpeg_video_sequence_extension,
1293 { "MPEG sequence extension", "mpeg-video.sequence-ext",
1294 FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
1295 { &hf_mpeg_video_group_of_pictures,
1296 { "MPEG group of pictures", "mpeg-video.gop",
1297 FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
1298 { &hf_mpeg_video_picture,
1299 { "MPEG picture", "mpeg-video.picture",
1300 FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
1301 { &hf_mpeg_video_quantization_matrix,
1302 { "MPEG quantization matrix", "mpeg-video.quant",
1303 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1304 { &hf_mpeg_video_data,
1305 { "MPEG picture data", "mpeg-video.data",
1306 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1309 static gint *ett[] = {
1311 /*--- Included file: packet-mpeg-pes-ettarr.c ---*/
1312 #line 1 "../../asn1/mpeg-pes/packet-mpeg-pes-ettarr.c"
1313 &ett_mpeg_pes_PES,
1314 &ett_mpeg_pes_Stream,
1315 &ett_mpeg_pes_Sequence_header,
1316 &ett_mpeg_pes_Sequence_extension,
1317 &ett_mpeg_pes_Group_of_pictures,
1318 &ett_mpeg_pes_Picture,
1320 /*--- End of included file: packet-mpeg-pes-ettarr.c ---*/
1321 #line 665 "../../asn1/mpeg-pes/packet-mpeg-pes-template.c"
1322 &ett_mpeg_pes_pack_header,
1323 &ett_mpeg_pes_header_data,
1324 &ett_mpeg_pes_trick_mode
1327 proto_mpeg = proto_register_protocol(
1328 "Moving Picture Experts Group", "MPEG", "mpeg");
1329 register_dissector("mpeg", dissect_mpeg, proto_mpeg);
1330 register_heur_dissector_list("mpeg", &heur_subdissector_list);
1332 proto_mpeg_pes = proto_register_protocol(
1333 "Packetized Elementary Stream", "MPEG PES", "mpeg-pes");
1334 proto_register_field_array(proto_mpeg_pes, hf, array_length(hf));
1335 proto_register_subtree_array(ett, array_length(ett));
1336 new_register_dissector("mpeg-pes", dissect_mpeg_pes, proto_mpeg_pes);
1339 void
1340 proto_reg_handoff_mpeg_pes(void)
1342 dissector_handle_t mpeg_handle = find_dissector("mpeg");
1344 dissector_add_uint("wtap_encap", WTAP_ENCAP_MPEG, mpeg_handle);
1345 heur_dissector_add("mpeg", dissect_mpeg_pes, proto_mpeg_pes);