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