Regenerate asn.1 dissectors.
[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 . -O ../../epan/dissectors mpeg-pes.asn */
5
6 /* Input file: packet-mpeg-pes-template.c */
7
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
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32  */
33
34 #include "config.h"
35
36 #include <glib.h>
37
38 #include <epan/packet.h>
39 #include <epan/asn1.h>
40
41 #include "packet-per.h"
42
43
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 */
96
97 /*--- End of included file: packet-mpeg-pes-hf.c ---*/
98 #line 36 "../../asn1/mpeg-pes/packet-mpeg-pes-template.c"
99
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;
108
109 /*--- End of included file: packet-mpeg-pes-ett.c ---*/
110 #line 37 "../../asn1/mpeg-pes/packet-mpeg-pes-template.c"
111
112 /*--- Included file: packet-mpeg-pes-fn.c ---*/
113 #line 1 "../../asn1/mpeg-pes/packet-mpeg-pes-fn.c"
114
115
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);
120
121   return offset;
122 }
123
124
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 }
140 };
141
142
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);
147
148   return offset;
149 }
150
151
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 }
156 };
157
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);
162
163   return offset;
164 }
165
166
167
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);
172
173   return offset;
174 }
175
176
177
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);
181
182   return offset;
183 }
184
185
186 static const value_string mpeg_pes_T_scrambling_control_vals[] = {
187   {   0, "not-scrambled" },
188   { 0, NULL }
189 };
190
191
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);
196
197   return offset;
198 }
199
200
201
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);
206
207   return offset;
208 }
209
210
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 }
230 };
231
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);
236
237   return offset;
238 }
239
240
241
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);
246
247   return offset;
248 }
249
250
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 }
257 };
258
259
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);
264
265   return offset;
266 }
267
268
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 }
280 };
281
282 static guint32 T_frame_rate_value_map[9+0] = {0, 23976, 24000, 25000, 29970, 30000, 50000, 59940, 60000};
283
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);
288
289   return offset;
290 }
291
292
293
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);
298
299   return offset;
300 }
301
302
303
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);
308
309   return offset;
310 }
311
312
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 }
325 };
326
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);
331
332   return offset;
333 }
334
335
336
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);
341
342   return offset;
343 }
344
345
346
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);
351
352   return offset;
353 }
354
355
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 }
370 };
371
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);
376
377   return offset;
378 }
379
380
381
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);
386
387   return offset;
388 }
389
390
391
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);
396
397   return offset;
398 }
399
400
401
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);
406
407   return offset;
408 }
409
410
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 }
422 };
423
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);
428
429   return offset;
430 }
431
432
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 }
439 };
440
441
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);
446
447   return offset;
448 }
449
450
451
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);
456
457   return offset;
458 }
459
460
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 }
466 };
467
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);
472
473   return offset;
474 }
475
476
477 /*--- End of included file: packet-mpeg-pes-fn.c ---*/
478 #line 38 "../../asn1/mpeg-pes/packet-mpeg-pes-template.c"
479
480 static int proto_mpeg = -1;
481 static int proto_mpeg_pes = -1;
482
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;
486
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;
514
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;
521
522 enum { PES_PREFIX = 1 };
523
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
538 };
539
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
549 };
550
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
558 };
559
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
566 };
567
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 }
578 };
579
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 }
586 };
587
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 }
592 };
593
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 }
600 };
601
602 #define TSHZ 90000
603
604 static guint64 decode_time_stamp(tvbuff_t *tvb, gint offset, nstime_t *nst)
605 {
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 rem = (unsigned)(ts % TSHZ);
612         nst->secs = (time_t)(ts / TSHZ);
613         nst->nsecs = (int)(G_GINT64_CONSTANT(1000000000) * rem / TSHZ);
614         return ts;
615 }
616
617 #define SCRHZ 27000000
618
619 static guint64 decode_clock_reference(tvbuff_t *tvb, gint offset,
620                 nstime_t *nst)
621 {
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 ext = (unsigned)((bytes >> 1) & 0x1ff);
628         guint64 cr = 300 * ts + ext;
629         unsigned rem = (unsigned)(cr % SCRHZ);
630         nst->secs = (time_t)(cr / SCRHZ);
631         nst->nsecs = (int)(G_GINT64_CONSTANT(1000000000) * rem / SCRHZ);
632         return cr;
633 }
634
635 static int
636 dissect_mpeg_pes_header_data(tvbuff_t *tvb, packet_info *pinfo,
637                 proto_tree *root, unsigned flags)
638 {
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);
642
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;
650
651                 if (check_col(pinfo->cinfo, COL_DEF_DST)) {
652                         SET_ADDRESS(&pinfo->dst, AT_NONE, 0, NULL);
653                         col_add_fstr(pinfo->cinfo, COL_DEF_DST,
654                                         "PTS %ld.%09u",
655                                         (long) nst.secs, nst.nsecs);
656                 }
657         }
658         if (flags & DTS_FLAG) {
659                 nstime_t nst;
660                 decode_time_stamp(tvb, offset, &nst);
661                 proto_tree_add_time(tree, hf_mpeg_pes_dts, tvb,
662                                 offset, 5, &nst);
663                 offset += 5;
664
665                 if (check_col(pinfo->cinfo, COL_DEF_SRC)) {
666                         SET_ADDRESS(&pinfo->src, AT_NONE, 0, NULL);
667                         col_add_fstr(pinfo->cinfo, COL_DEF_SRC,
668                                         "DTS %ld.%09u",
669                                         (long) nst.secs, nst.nsecs);
670                 }
671         }
672         if (flags & ESCR_FLAG) {
673                 nstime_t nst;
674                 decode_clock_reference(tvb, offset, &nst);
675                 proto_tree_add_time(tree, hf_mpeg_pes_escr, tvb,
676                                 offset, 6, &nst);
677                 offset += 6;
678         }
679         if (flags & ES_RATE_FLAG) {
680                 unsigned es_rate = (tvb_get_ntohs(tvb, offset) >> 1 & 0x3fff) * 50;
681                 proto_tree_add_uint(tree, hf_mpeg_pes_es_rate, tvb,
682                                 offset, 3, es_rate);
683                 offset += 3;
684         }
685         if (flags & DSM_TRICK_MODE_FLAG)
686         {
687                 guint8 value = tvb_get_guint8(tvb, offset);
688                 guint8 control;
689                 proto_tree *trick_tree;
690                 proto_item *trick_item;
691
692                 trick_item = proto_tree_add_item(item,
693                         hf_mpeg_pes_dsm_trick_mode, tvb,
694                                 offset, 1, ENC_NA);
695
696                 trick_tree = proto_item_add_subtree(trick_item,
697                         ett_mpeg_pes_trick_mode);
698
699                 control = (value >> 5);
700                 proto_tree_add_uint(trick_tree,
701                         hf_mpeg_pes_dsm_trick_mode_control, tvb,
702                         offset, 1,
703                         control);
704
705                 if (control == FAST_FORWARD_CONTROL
706                         || control == FAST_REVERSE_CONTROL)
707                 {
708                         proto_tree_add_uint(trick_tree,
709                                 hf_mpeg_pes_dsm_trick_mode_field_id, tvb,
710                                 offset, 1,
711                                 (value & 0x18) >> 3);
712
713                         proto_tree_add_uint(trick_tree,
714                                 hf_mpeg_pes_dsm_trick_mode_intra_slice_refresh, tvb,
715                                 offset, 1,
716                                 (value & 0x04) >> 2);
717
718                         proto_tree_add_uint(trick_tree,
719                                 hf_mpeg_pes_dsm_trick_mode_frequency_truncation, tvb,
720                                 offset, 1,
721                                 (value & 0x03));
722                 }
723                 else if (control == SLOW_MOTION_CONTROL
724                         || control == SLOW_REVERSE_CONTROL)
725                 {
726                         proto_tree_add_uint(trick_tree,
727                                 hf_mpeg_pes_dsm_trick_mode_rep_cntrl, tvb,
728                                 offset, 1,
729                                 (value & 0x1F));
730                 }
731                 else if (control == FREEZE_FRAME_CONTROL)
732                 {
733                         proto_tree_add_uint(trick_tree,
734                                 hf_mpeg_pes_dsm_trick_mode_field_id, tvb,
735                                 offset, 1,
736                                 (value & 0x18) >> 3);
737                 }
738
739                 offset += 1;
740         }
741         if (flags & COPY_INFO_FLAG) {
742                 proto_tree_add_item(tree, hf_mpeg_pes_copy_info, tvb,
743                                 offset, 1, ENC_BIG_ENDIAN);
744                 offset++;
745         }
746         if (flags & CRC_FLAG) {
747                 proto_tree_add_item(tree, hf_mpeg_pes_crc, tvb,
748                                 offset, 2, ENC_BIG_ENDIAN);
749                 offset += 2;
750         }
751
752         if (flags & EXTENSION_FLAG) {
753                 int flags2 = tvb_get_guint8(tvb, offset);
754                 proto_tree_add_item(tree, hf_mpeg_pes_extension_flags, tvb,
755                                 offset, 1, ENC_BIG_ENDIAN);
756                 offset++;
757
758                 if (flags2 & PRIVATE_DATA_FLAG) {
759                         proto_tree_add_item(tree, hf_mpeg_pes_private_data, tvb,
760                                         offset, 2, ENC_BIG_ENDIAN);
761                         offset += 2;
762                 }
763                 if (flags2 & PACK_LENGTH_FLAG) {
764                         proto_tree_add_item(tree, hf_mpeg_pes_pack_length, tvb,
765                                         offset, 1, ENC_BIG_ENDIAN);
766                         offset++;
767                 }
768                 if (flags2 & SEQUENCE_FLAG) {
769                         proto_tree_add_item(tree, hf_mpeg_pes_sequence, tvb,
770                                         offset, 2, ENC_BIG_ENDIAN);
771                         offset += 2;
772                 }
773                 if (flags2 & PSTD_BUFFER_FLAG) {
774                         unsigned pstd = tvb_get_ntohs(tvb, offset);
775                         proto_tree_add_uint(tree, hf_mpeg_pes_pstd_buffer, tvb,
776                                         offset, 2, (pstd & 0x2000 ? 1024 : 128) * (pstd & 0x1ff));
777                         offset += 2;
778                 }
779                 if (flags2 & EXTENSION_FLAG2) {
780                         proto_tree_add_item(tree, hf_mpeg_pes_extension2, tvb,
781                                         offset, 2, ENC_BIG_ENDIAN);
782                         offset += 2;
783                 }
784         }
785         return offset;
786 }
787
788 static gint
789 dissect_mpeg_pes_pack_header(tvbuff_t *tvb, gint offset,
790                 packet_info *pinfo, proto_tree *root)
791 {
792         unsigned program_mux_rate, stuffing_length;
793
794         proto_item *item = proto_tree_add_item(root, hf_mpeg_pes_pack_header, tvb,
795                         offset / 8, 10, ENC_NA);
796         proto_tree *tree = proto_item_add_subtree(item, ett_mpeg_pes_pack_header);
797
798         nstime_t nst;
799         decode_clock_reference(tvb, offset / 8, &nst);
800         proto_tree_add_time(tree, hf_mpeg_pes_scr, tvb, offset / 8, 6, &nst);
801         offset += 6 * 8;
802
803         program_mux_rate = (tvb_get_ntoh24(tvb, offset / 8) >> 2) * 50;
804         proto_tree_add_uint(tree, hf_mpeg_pes_program_mux_rate, tvb, offset / 8, 3,
805                         program_mux_rate);
806         offset += 3 * 8;
807
808         if (check_col(pinfo->cinfo, COL_DEF_SRC)) {
809                 SET_ADDRESS(&pinfo->src, AT_NONE, 0, NULL);
810                 col_add_fstr(pinfo->cinfo, COL_DEF_SRC, "%u B/s", program_mux_rate);
811         }
812
813         stuffing_length = tvb_get_guint8(tvb, offset / 8) & 0x07;
814         proto_tree_add_item(tree, hf_mpeg_pes_stuffing_length, tvb,
815                         offset / 8, 1, ENC_BIG_ENDIAN);
816         offset += 1 * 8;
817
818         if (stuffing_length > 0) {
819                 proto_tree_add_item(tree, hf_mpeg_pes_stuffing, tvb,
820                                 offset / 8, stuffing_length, ENC_NA);
821                 offset += stuffing_length * 8;
822         }
823
824         return offset;
825 }
826
827 static void
828 dissect_mpeg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
829
830 static gboolean
831 dissect_mpeg_pes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
832 {
833         int prefix;
834         int stream;
835         asn1_ctx_t asn1_ctx;
836         gint offset = 0;
837
838         if (!tvb_bytes_exist(tvb, 0, 3))
839                 return FALSE;   /* not enough bytes for a PES prefix */
840
841         prefix = tvb_get_ntoh24(tvb, 0);
842         if (prefix != PES_PREFIX)
843                 return FALSE;
844         col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPEG PES");
845         col_clear(pinfo->cinfo, COL_INFO);
846
847         stream = tvb_get_guint8(tvb, 3);
848         if (check_col(pinfo->cinfo, COL_INFO)) {
849                 const char *s = match_strval(stream, mpeg_pes_T_stream_vals);
850                 if (s != NULL)
851                         col_set_str(pinfo->cinfo, COL_INFO, s);
852         }
853
854 #if 0
855         if (tree == NULL)
856                 return TRUE;
857 #endif
858         asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, pinfo);
859         offset = dissect_mpeg_pes_PES(tvb, offset, &asn1_ctx,
860                         tree, proto_mpeg_pes);
861
862         if (stream == STREAM_PICTURE) {
863                 int frame_type;
864
865                 frame_type = tvb_get_guint8(tvb, 5) >> 3 & 0x07;
866                 if (check_col(pinfo->cinfo, COL_INFO)) {
867                         const char *s = match_strval(frame_type,
868                                         mpeg_pes_T_frame_type_vals);
869                         if (s != NULL)
870                                 col_set_str(pinfo->cinfo, COL_INFO, s);
871                 }
872
873                 offset = dissect_mpeg_pes_Picture(tvb, offset, &asn1_ctx,
874                                 tree, hf_mpeg_video_picture);
875                 proto_tree_add_item(tree, hf_mpeg_video_data, tvb,
876                                 offset / 8, -1, ENC_NA);
877         } else if (stream == STREAM_SEQUENCE) {
878                 tvbuff_t *es;
879
880                 offset = dissect_mpeg_pes_Sequence_header(tvb, offset, &asn1_ctx,
881                                 tree, hf_mpeg_video_sequence_header);
882
883                 proto_tree_add_item(tree, hf_mpeg_video_quantization_matrix, tvb,
884                                 offset / 8, 64, ENC_NA);
885                 offset += 64 * 8;
886
887                 es = tvb_new_subset_remaining(tvb, offset / 8);
888                 dissect_mpeg_pes(es, pinfo, tree, NULL);
889         } else if (stream == STREAM_SEQUENCE_EXTENSION) {
890                 tvbuff_t *es;
891
892                 offset = dissect_mpeg_pes_Sequence_extension(tvb, offset, &asn1_ctx,
893                                 tree, hf_mpeg_video_sequence_extension);
894
895                 es = tvb_new_subset_remaining(tvb, offset / 8);
896                 dissect_mpeg_pes(es, pinfo, tree, NULL);
897         } else if (stream == STREAM_GOP) {
898                 tvbuff_t *es;
899
900                 offset = dissect_mpeg_pes_Group_of_pictures(tvb, offset, &asn1_ctx,
901                                 tree, hf_mpeg_video_group_of_pictures);
902
903                 es = tvb_new_subset_remaining(tvb, offset / 8);
904                 dissect_mpeg_pes(es, pinfo, tree, NULL);
905         } else if (stream == STREAM_PACK) {
906                 if (tvb_get_guint8(tvb, offset / 8) >> 6 == 1) {
907                         dissect_mpeg_pes_pack_header(tvb, offset, pinfo, tree);
908                 } else {
909                         proto_tree_add_item(tree, hf_mpeg_pes_data, tvb,
910                                         offset / 8, 8, ENC_NA);
911                 }
912         } else if (stream == STREAM_SYSTEM || stream == STREAM_PRIVATE2) {
913                 unsigned data_length = tvb_get_ntohs(tvb, offset / 8);
914                 proto_tree_add_item(tree, hf_mpeg_pes_length, tvb,
915                                 offset / 8, 2, ENC_BIG_ENDIAN);
916                 offset += 2 * 8;
917
918                 proto_tree_add_item(tree, hf_mpeg_pes_data, tvb,
919                                 offset / 8, data_length, ENC_NA);
920         } else if (stream == STREAM_PADDING) {
921                 unsigned padding_length = tvb_get_ntohs(tvb, offset / 8);
922                 proto_tree_add_item(tree, hf_mpeg_pes_length, tvb,
923                                 offset / 8, 2, ENC_BIG_ENDIAN);
924                 offset += 2 * 8;
925
926                 proto_tree_add_item(tree, hf_mpeg_pes_padding, tvb,
927                                 offset / 8, padding_length, ENC_NA);
928         } else if (stream == STREAM_PRIVATE1
929                         || stream >= STREAM_AUDIO) {
930                 int length = tvb_get_ntohs(tvb, 4);
931
932                 if ((tvb_get_guint8(tvb, 6) & 0xc0) == 0x80) {
933                         int header_length;
934                         tvbuff_t *es;
935
936                         offset = dissect_mpeg_pes_Stream(tvb, offset, &asn1_ctx,
937                                         tree, hf_mpeg_pes_extension);
938                         /* https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2229
939                          * A value of 0 indicates that the PES packet length is neither specified nor
940                          * bounded and is allowed only in PES packets whose payload is a video elementary
941                          * stream contained in Transport Stream packets.
942                          * XXX Some one with access to the spec should check this
943                          */
944                          if(length !=0 && stream != STREAM_VIDEO){
945                                  length -= 5 * 8;
946                          }
947
948                         header_length = tvb_get_guint8(tvb, 8);
949                         if (header_length > 0) {
950                                 int flags = tvb_get_guint8(tvb, 7);
951                                 tvbuff_t *header_data = tvb_new_subset(tvb, offset / 8,
952                                                 header_length, header_length);
953                                 dissect_mpeg_pes_header_data(header_data, pinfo, tree, flags);
954                                 offset += header_length * 8;
955                                  /* length may be zero for Video stream */
956                                 if(length !=0 && stream != STREAM_VIDEO){
957                                         length -= header_length * 8;
958                                 }
959                         }
960
961                         /* length may be zero for Video stream */
962                         if(length==0){
963                                 proto_tree_add_item(tree, hf_mpeg_pes_data, tvb, (offset>>3),-1, ENC_NA);
964                                 return TRUE;
965                         }
966
967                         es = tvb_new_subset(tvb, offset / 8, -1, length / 8);
968                         if (tvb_get_ntoh24(es, 0) == PES_PREFIX)
969                                 dissect_mpeg_pes(es, pinfo, tree, NULL);
970                         else if (tvb_get_guint8(es, 0) == 0xff)
971                                 dissect_mpeg(es, pinfo, tree);
972                         else
973                                 proto_tree_add_item(tree, hf_mpeg_pes_data, es,
974                                                 0, -1, ENC_NA);
975                 } else {
976                         unsigned data_length = tvb_get_ntohs(tvb, offset / 8);
977                         proto_tree_add_item(tree, hf_mpeg_pes_length, tvb,
978                                         offset / 8, 2, ENC_BIG_ENDIAN);
979                         offset += 2 * 8;
980
981                         proto_tree_add_item(tree, hf_mpeg_pes_data, tvb,
982                                         offset / 8, data_length, ENC_NA);
983                 }
984         } else {
985                 proto_tree_add_item(tree, hf_mpeg_pes_data, tvb,
986                                 offset / 8, -1, ENC_NA);
987         }
988         return TRUE;
989 }
990
991 static heur_dissector_list_t heur_subdissector_list;
992
993 static void
994 dissect_mpeg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
995 {
996     if (!dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, tree, NULL)) {
997         col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPEG");
998         col_clear(pinfo->cinfo, COL_INFO);
999         if (tree)
1000             proto_tree_add_item(tree, proto_mpeg, tvb, 0, -1, ENC_NA);
1001     }
1002 }
1003
1004 void
1005 proto_register_mpeg_pes(void)
1006 {
1007         static hf_register_info hf[] = {
1008
1009 /*--- Included file: packet-mpeg-pes-hfarr.c ---*/
1010 #line 1 "../../asn1/mpeg-pes/packet-mpeg-pes-hfarr.c"
1011     { &hf_mpeg_pes_prefix,
1012       { "prefix", "mpeg-pes.prefix",
1013         FT_BYTES, BASE_NONE, NULL, 0,
1014         "OCTET_STRING_SIZE_3", HFILL }},
1015     { &hf_mpeg_pes_stream,
1016       { "stream", "mpeg-pes.stream",
1017         FT_UINT8, BASE_HEX, VALS(mpeg_pes_T_stream_vals), 0,
1018         NULL, HFILL }},
1019     { &hf_mpeg_pes_length,
1020       { "length", "mpeg-pes.length",
1021         FT_UINT16, BASE_DEC, NULL, 0,
1022         "INTEGER_0_65535", HFILL }},
1023     { &hf_mpeg_pes_must_be_one,
1024       { "must-be-one", "mpeg-pes.must_be_one",
1025         FT_BOOLEAN, BASE_NONE, NULL, 0,
1026         "BOOLEAN", HFILL }},
1027     { &hf_mpeg_pes_must_be_zero,
1028       { "must-be-zero", "mpeg-pes.must_be_zero",
1029         FT_BOOLEAN, BASE_NONE, NULL, 0,
1030         "BOOLEAN", HFILL }},
1031     { &hf_mpeg_pes_scrambling_control,
1032       { "scrambling-control", "mpeg-pes.scrambling_control",
1033         FT_UINT32, BASE_DEC, VALS(mpeg_pes_T_scrambling_control_vals), 0,
1034         NULL, HFILL }},
1035     { &hf_mpeg_pes_priority,
1036       { "priority", "mpeg-pes.priority",
1037         FT_BOOLEAN, BASE_NONE, NULL, 0,
1038         "BOOLEAN", HFILL }},
1039     { &hf_mpeg_pes_data_alignment,
1040       { "data-alignment", "mpeg-pes.data_alignment",
1041         FT_BOOLEAN, BASE_NONE, NULL, 0,
1042         "BOOLEAN", HFILL }},
1043     { &hf_mpeg_pes_copyright,
1044       { "copyright", "mpeg-pes.copyright",
1045         FT_BOOLEAN, BASE_NONE, NULL, 0,
1046         "BOOLEAN", HFILL }},
1047     { &hf_mpeg_pes_original,
1048       { "original", "mpeg-pes.original",
1049         FT_BOOLEAN, BASE_NONE, NULL, 0,
1050         "BOOLEAN", HFILL }},
1051     { &hf_mpeg_pes_pts_flag,
1052       { "pts-flag", "mpeg-pes.pts_flag",
1053         FT_BOOLEAN, BASE_NONE, NULL, 0,
1054         "BOOLEAN", HFILL }},
1055     { &hf_mpeg_pes_dts_flag,
1056       { "dts-flag", "mpeg-pes.dts_flag",
1057         FT_BOOLEAN, BASE_NONE, NULL, 0,
1058         "BOOLEAN", HFILL }},
1059     { &hf_mpeg_pes_escr_flag,
1060       { "escr-flag", "mpeg-pes.escr_flag",
1061         FT_BOOLEAN, BASE_NONE, NULL, 0,
1062         "BOOLEAN", HFILL }},
1063     { &hf_mpeg_pes_es_rate_flag,
1064       { "es-rate-flag", "mpeg-pes.es_rate_flag",
1065         FT_BOOLEAN, BASE_NONE, NULL, 0,
1066         "BOOLEAN", HFILL }},
1067     { &hf_mpeg_pes_dsm_trick_mode_flag,
1068       { "dsm-trick-mode-flag", "mpeg-pes.dsm_trick_mode_flag",
1069         FT_BOOLEAN, BASE_NONE, NULL, 0,
1070         "BOOLEAN", HFILL }},
1071     { &hf_mpeg_pes_additional_copy_info_flag,
1072       { "additional-copy-info-flag", "mpeg-pes.additional_copy_info_flag",
1073         FT_BOOLEAN, BASE_NONE, NULL, 0,
1074         "BOOLEAN", HFILL }},
1075     { &hf_mpeg_pes_crc_flag,
1076       { "crc-flag", "mpeg-pes.crc_flag",
1077         FT_BOOLEAN, BASE_NONE, NULL, 0,
1078         "BOOLEAN", HFILL }},
1079     { &hf_mpeg_pes_extension_flag,
1080       { "extension-flag", "mpeg-pes.extension_flag",
1081         FT_BOOLEAN, BASE_NONE, NULL, 0,
1082         "BOOLEAN", HFILL }},
1083     { &hf_mpeg_pes_header_data_length,
1084       { "header-data-length", "mpeg-pes.header_data_length",
1085         FT_UINT32, BASE_DEC, NULL, 0,
1086         "INTEGER_0_255", HFILL }},
1087     { &hf_mpeg_pes_horizontal_size,
1088       { "horizontal-size", "mpeg-pes.horizontal_size",
1089         FT_BYTES, BASE_NONE, NULL, 0,
1090         "BIT_STRING_SIZE_12", HFILL }},
1091     { &hf_mpeg_pes_vertical_size,
1092       { "vertical-size", "mpeg-pes.vertical_size",
1093         FT_BYTES, BASE_NONE, NULL, 0,
1094         "BIT_STRING_SIZE_12", HFILL }},
1095     { &hf_mpeg_pes_aspect_ratio,
1096       { "aspect-ratio", "mpeg-pes.aspect_ratio",
1097         FT_UINT32, BASE_DEC, VALS(mpeg_pes_T_aspect_ratio_vals), 0,
1098         "T_aspect_ratio", HFILL }},
1099     { &hf_mpeg_pes_frame_rate,
1100       { "frame-rate", "mpeg-pes.frame_rate",
1101         FT_UINT32, BASE_DEC, VALS(mpeg_pes_T_frame_rate_vals), 0,
1102         NULL, HFILL }},
1103     { &hf_mpeg_pes_bit_rate,
1104       { "bit-rate", "mpeg-pes.bit_rate",
1105         FT_BYTES, BASE_NONE, NULL, 0,
1106         "BIT_STRING_SIZE_18", HFILL }},
1107     { &hf_mpeg_pes_vbv_buffer_size,
1108       { "vbv-buffer-size", "mpeg-pes.vbv_buffer_size",
1109         FT_BYTES, BASE_NONE, NULL, 0,
1110         "BIT_STRING_SIZE_10", HFILL }},
1111     { &hf_mpeg_pes_constrained_parameters_flag,
1112       { "constrained-parameters-flag", "mpeg-pes.constrained_parameters_flag",
1113         FT_BOOLEAN, BASE_NONE, NULL, 0,
1114         "BOOLEAN", HFILL }},
1115     { &hf_mpeg_pes_load_intra_quantiser_matrix,
1116       { "load-intra-quantiser-matrix", "mpeg-pes.load_intra_quantiser_matrix",
1117         FT_BOOLEAN, BASE_NONE, NULL, 0,
1118         "BOOLEAN", HFILL }},
1119     { &hf_mpeg_pes_load_non_intra_quantiser_matrix,
1120       { "load-non-intra-quantiser-matrix", "mpeg-pes.load_non_intra_quantiser_matrix",
1121         FT_BOOLEAN, BASE_NONE, NULL, 0,
1122         "BOOLEAN", HFILL }},
1123     { &hf_mpeg_pes_must_be_0001,
1124       { "must-be-0001", "mpeg-pes.must_be_0001",
1125         FT_BYTES, BASE_NONE, NULL, 0,
1126         "BIT_STRING_SIZE_4", HFILL }},
1127     { &hf_mpeg_pes_profile_and_level,
1128       { "profile-and-level", "mpeg-pes.profile_and_level",
1129         FT_UINT32, BASE_DEC, NULL, 0,
1130         "INTEGER_0_255", HFILL }},
1131     { &hf_mpeg_pes_progressive_sequence,
1132       { "progressive-sequence", "mpeg-pes.progressive_sequence",
1133         FT_BOOLEAN, BASE_NONE, NULL, 0,
1134         "BOOLEAN", HFILL }},
1135     { &hf_mpeg_pes_chroma_format,
1136       { "chroma-format", "mpeg-pes.chroma_format",
1137         FT_UINT32, BASE_DEC, NULL, 0,
1138         "INTEGER_0_3", HFILL }},
1139     { &hf_mpeg_pes_horizontal_size_extension,
1140       { "horizontal-size-extension", "mpeg-pes.horizontal_size_extension",
1141         FT_UINT32, BASE_DEC, NULL, 0,
1142         "INTEGER_0_3", HFILL }},
1143     { &hf_mpeg_pes_vertical_size_extension,
1144       { "vertical-size-extension", "mpeg-pes.vertical_size_extension",
1145         FT_UINT32, BASE_DEC, NULL, 0,
1146         "INTEGER_0_3", HFILL }},
1147     { &hf_mpeg_pes_bit_rate_extension,
1148       { "bit-rate-extension", "mpeg-pes.bit_rate_extension",
1149         FT_BYTES, BASE_NONE, NULL, 0,
1150         "BIT_STRING_SIZE_12", HFILL }},
1151     { &hf_mpeg_pes_vbv_buffer_size_extension,
1152       { "vbv-buffer-size-extension", "mpeg-pes.vbv_buffer_size_extension",
1153         FT_UINT32, BASE_DEC, NULL, 0,
1154         "INTEGER_0_255", HFILL }},
1155     { &hf_mpeg_pes_low_delay,
1156       { "low-delay", "mpeg-pes.low_delay",
1157         FT_BOOLEAN, BASE_NONE, NULL, 0,
1158         "BOOLEAN", HFILL }},
1159     { &hf_mpeg_pes_frame_rate_extension_n,
1160       { "frame-rate-extension-n", "mpeg-pes.frame_rate_extension_n",
1161         FT_UINT32, BASE_DEC, NULL, 0,
1162         "INTEGER_0_3", HFILL }},
1163     { &hf_mpeg_pes_frame_rate_extension_d,
1164       { "frame-rate-extension-d", "mpeg-pes.frame_rate_extension_d",
1165         FT_UINT32, BASE_DEC, NULL, 0,
1166         "INTEGER_0_3", HFILL }},
1167     { &hf_mpeg_pes_drop_frame_flag,
1168       { "drop-frame-flag", "mpeg-pes.drop_frame_flag",
1169         FT_BOOLEAN, BASE_NONE, NULL, 0,
1170         "BOOLEAN", HFILL }},
1171     { &hf_mpeg_pes_hour,
1172       { "hour", "mpeg-pes.hour",
1173         FT_UINT32, BASE_DEC, NULL, 0,
1174         "INTEGER_0_32", HFILL }},
1175     { &hf_mpeg_pes_minute,
1176       { "minute", "mpeg-pes.minute",
1177         FT_UINT32, BASE_DEC, NULL, 0,
1178         "INTEGER_0_64", HFILL }},
1179     { &hf_mpeg_pes_second,
1180       { "second", "mpeg-pes.second",
1181         FT_UINT32, BASE_DEC, NULL, 0,
1182         "INTEGER_0_64", HFILL }},
1183     { &hf_mpeg_pes_frame,
1184       { "frame", "mpeg-pes.frame",
1185         FT_UINT32, BASE_DEC, NULL, 0,
1186         "INTEGER_0_64", HFILL }},
1187     { &hf_mpeg_pes_closed_gop,
1188       { "closed-gop", "mpeg-pes.closed_gop",
1189         FT_BOOLEAN, BASE_NONE, NULL, 0,
1190         "BOOLEAN", HFILL }},
1191     { &hf_mpeg_pes_broken_gop,
1192       { "broken-gop", "mpeg-pes.broken_gop",
1193         FT_BOOLEAN, BASE_NONE, NULL, 0,
1194         "BOOLEAN", HFILL }},
1195     { &hf_mpeg_pes_must_be_zero_01,
1196       { "must-be-zero", "mpeg-pes.must_be_zero",
1197         FT_BYTES, BASE_NONE, NULL, 0,
1198         "BIT_STRING_SIZE_5", HFILL }},
1199     { &hf_mpeg_pes_temporal_sequence_number,
1200       { "temporal-sequence-number", "mpeg-pes.temporal_sequence_number",
1201         FT_BYTES, BASE_NONE, NULL, 0,
1202         "BIT_STRING_SIZE_10", HFILL }},
1203     { &hf_mpeg_pes_frame_type,
1204       { "frame-type", "mpeg-pes.frame_type",
1205         FT_UINT32, BASE_DEC, VALS(mpeg_pes_T_frame_type_vals), 0,
1206         NULL, HFILL }},
1207     { &hf_mpeg_pes_vbv_delay,
1208       { "vbv-delay", "mpeg-pes.vbv_delay",
1209         FT_BYTES, BASE_NONE, NULL, 0,
1210         "BIT_STRING_SIZE_16", HFILL }},
1211
1212 /*--- End of included file: packet-mpeg-pes-hfarr.c ---*/
1213 #line 568 "../../asn1/mpeg-pes/packet-mpeg-pes-template.c"
1214                 { &hf_mpeg_pes_pack_header,
1215                         { "Pack header", "mpeg-pes.pack",
1216                                 FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
1217                 { &hf_mpeg_pes_scr,
1218                         { "system clock reference (SCR)", "mpeg-pes.scr",
1219                                 FT_RELATIVE_TIME, BASE_NONE, NULL, 0, NULL, HFILL }},
1220                 { &hf_mpeg_pes_program_mux_rate,
1221                         { "PES program mux rate", "mpeg-pes.program-mux-rate",
1222                                 FT_UINT24, BASE_DEC, NULL, 0, NULL, HFILL }},
1223                 { &hf_mpeg_pes_stuffing_length,
1224                         { "PES stuffing length", "mpeg-pes.stuffing-length",
1225                                 FT_UINT8, BASE_DEC, NULL, 0x07, NULL, HFILL }},
1226                 { &hf_mpeg_pes_stuffing,
1227                         { "PES stuffing bytes", "mpeg-pes.stuffing",
1228                                 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1229                 { &hf_mpeg_pes_extension,
1230                         { "PES extension", "mpeg-pes.extension",
1231                                 FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
1232                 { &hf_mpeg_pes_header_data,
1233                         { "PES header data", "mpeg-pes.header-data",
1234                                 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1235                 { &hf_mpeg_pes_pts,
1236                         { "presentation time stamp (PTS)", "mpeg-pes.pts",
1237                                 FT_RELATIVE_TIME, BASE_NONE, NULL, 0, NULL, HFILL }},
1238                 { &hf_mpeg_pes_dts,
1239                         { "decode time stamp (DTS)", "mpeg-pes.dts",
1240                                 FT_RELATIVE_TIME, BASE_NONE, NULL, 0, NULL, HFILL }},
1241                 { &hf_mpeg_pes_escr,
1242                         { "elementary stream clock reference (ESCR)", "mpeg-pes.escr",
1243                                 FT_RELATIVE_TIME, BASE_NONE, NULL, 0, NULL, HFILL }},
1244                 { &hf_mpeg_pes_es_rate,
1245                         { "elementary stream rate", "mpeg-pes.es-rate",
1246                                 FT_UINT24, BASE_DEC, NULL, 0x7ffe, NULL, HFILL }},
1247                 { &hf_mpeg_pes_dsm_trick_mode,
1248                         { "Trick mode", "mpeg-pes.trick-mode",
1249                                 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1250                 { &hf_mpeg_pes_dsm_trick_mode_control,
1251                         { "control", "mpeg-pes.trick-mode-control",
1252                                 FT_UINT8, BASE_HEX, VALS(mpeg_pes_TrickModeControl_vals), 0,
1253                                 "mpeg_pes trick mode control", HFILL }},
1254                 { &hf_mpeg_pes_dsm_trick_mode_field_id,
1255                         { "field id", "mpeg-pes.trick-mode-field-id",
1256                                 FT_UINT8, BASE_HEX, VALS(mpeg_pes_TrickModeFieldId_vals), 0,
1257                                 "mpeg_pes trick mode field id", HFILL }},
1258                 { &hf_mpeg_pes_dsm_trick_mode_intra_slice_refresh,
1259                         { "intra slice refresh", "mpeg-pes.trick-mode-intra-slice-refresh",
1260                                 FT_UINT8, BASE_HEX, VALS(mpeg_pes_TrickModeIntraSliceRefresh_vals), 0,
1261                                 "mpeg_pes trick mode intra slice refresh", HFILL }},
1262                 { &hf_mpeg_pes_dsm_trick_mode_frequency_truncation,
1263                         { "frequency truncation", "mpeg-pes.trick-mode-frequeny-truncation",
1264                                 FT_UINT8, BASE_HEX, VALS(mpeg_pes_TrickModeFrequencyTruncation_vals), 0,
1265                                 "mpeg_pes trick mode frequency truncation", HFILL }},
1266                 { &hf_mpeg_pes_dsm_trick_mode_rep_cntrl,
1267                         { "rep cntrl", "mpeg-pes.trick-mode-rep-cntrl",
1268                                 FT_UINT8, BASE_HEX, NULL, 0, "mpeg_pes trick mode rep cntrl", HFILL }},
1269                 { &hf_mpeg_pes_copy_info,
1270                         { "copy info", "mpeg-pes.copy-info",
1271                                 FT_UINT8, BASE_DEC, NULL, 0x7f, NULL, HFILL }},
1272                 { &hf_mpeg_pes_crc,
1273                         { "CRC", "mpeg-pes.crc",
1274                                 FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1275                 { &hf_mpeg_pes_extension_flags,
1276                         { "extension flags", "mpeg-pes.extension-flags",
1277                                 FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }},
1278                 { &hf_mpeg_pes_private_data,
1279                         { "private data", "mpeg-pes.private-data",
1280                                 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL }},
1281                 { &hf_mpeg_pes_pack_length,
1282                         { "pack length", "mpeg-pes.pack-length",
1283                                 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
1284                 { &hf_mpeg_pes_sequence,
1285                         { "sequence", "mpeg-pes.sequence",
1286                                 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL }},
1287                 { &hf_mpeg_pes_pstd_buffer,
1288                         { "P-STD buffer size", "mpeg-pes.pstd-buffer",
1289                                 FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
1290                 { &hf_mpeg_pes_extension2,
1291                         { "extension2", "mpeg-pes.extension2",
1292                                 FT_UINT16, BASE_HEX, NULL, 0, NULL, HFILL }},
1293                 { &hf_mpeg_pes_padding,
1294                         { "PES padding", "mpeg-pes.padding",
1295                                 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1296                 { &hf_mpeg_pes_data,
1297                         { "PES data", "mpeg-pes.data",
1298                                 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1299                 { &hf_mpeg_video_sequence_header,
1300                         { "MPEG sequence header", "mpeg-video.sequence",
1301                                 FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
1302                 { &hf_mpeg_video_sequence_extension,
1303                         { "MPEG sequence extension", "mpeg-video.sequence-ext",
1304                                 FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
1305                 { &hf_mpeg_video_group_of_pictures,
1306                         { "MPEG group of pictures", "mpeg-video.gop",
1307                                 FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
1308                 { &hf_mpeg_video_picture,
1309                         { "MPEG picture", "mpeg-video.picture",
1310                                 FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
1311                 { &hf_mpeg_video_quantization_matrix,
1312                         { "MPEG quantization matrix", "mpeg-video.quant",
1313                                 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1314                 { &hf_mpeg_video_data,
1315                         { "MPEG picture data", "mpeg-video.data",
1316                                 FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
1317         };
1318
1319         static gint *ett[] = {
1320
1321 /*--- Included file: packet-mpeg-pes-ettarr.c ---*/
1322 #line 1 "../../asn1/mpeg-pes/packet-mpeg-pes-ettarr.c"
1323     &ett_mpeg_pes_PES,
1324     &ett_mpeg_pes_Stream,
1325     &ett_mpeg_pes_Sequence_header,
1326     &ett_mpeg_pes_Sequence_extension,
1327     &ett_mpeg_pes_Group_of_pictures,
1328     &ett_mpeg_pes_Picture,
1329
1330 /*--- End of included file: packet-mpeg-pes-ettarr.c ---*/
1331 #line 675 "../../asn1/mpeg-pes/packet-mpeg-pes-template.c"
1332                 &ett_mpeg_pes_pack_header,
1333                 &ett_mpeg_pes_header_data,
1334                 &ett_mpeg_pes_trick_mode
1335         };
1336
1337         proto_mpeg = proto_register_protocol(
1338                         "Moving Picture Experts Group", "MPEG", "mpeg");
1339         register_dissector("mpeg", dissect_mpeg, proto_mpeg);
1340         register_heur_dissector_list("mpeg", &heur_subdissector_list);
1341
1342         proto_mpeg_pes = proto_register_protocol(
1343                         "Packetized Elementary Stream", "MPEG PES", "mpeg-pes");
1344         proto_register_field_array(proto_mpeg_pes, hf, array_length(hf));
1345         proto_register_subtree_array(ett, array_length(ett));
1346         new_register_dissector("mpeg-pes", dissect_mpeg_pes, proto_mpeg_pes);
1347 }
1348
1349 void
1350 proto_reg_handoff_mpeg_pes(void)
1351 {
1352         dissector_handle_t mpeg_handle = find_dissector("mpeg");
1353
1354         dissector_add_uint("wtap_encap", WTAP_ENCAP_MPEG, mpeg_handle);
1355         heur_dissector_add("mpeg", dissect_mpeg_pes, proto_mpeg_pes);
1356 }