Add HP Switch Protocol SAP value
[obnox/wireshark/wip.git] / epan / dissectors / packet-h263.c
1 /* packet-h263.c
2  *
3  * Routines for ITU-T Recommendation H.263 dissection
4  *
5  * Copyright 2003 Niklas Ă–gren <niklas.ogren@7l.se>
6  * Seven Levels Consultants AB
7  *
8  * $Id$
9  *
10  * Wireshark - Network traffic analyzer
11  * By Gerald Combs <gerald@wireshark.org>
12  * Copyright 1998 Gerald Combs
13  *
14  * Copied structure from packet-h261.c
15  *
16  * This program is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU General Public License
18  * as published by the Free Software Foundation; either version 2
19  * of the License, or (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
29  */
30
31 /*
32  * This dissector tries to dissect the H.263 protocol according to
33  * ITU-T Recommendations and RFC 2190
34  */
35
36
37 #ifdef HAVE_CONFIG_H
38 # include "config.h"
39 #endif
40
41 #include <glib.h>
42 #include <epan/packet.h>
43
44 #include <stdio.h>
45 #include <string.h>
46
47 #include <epan/rtp_pt.h>
48 #include <epan/iax2_codec_type.h>
49
50 static void dissect_h263_data( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree );
51
52 /* H.263 header fields             */
53 static int proto_h263          = -1;
54 static int proto_h263_data     = -1;
55
56 /* Mode A header */
57 static int hf_h263_ftype = -1;
58 static int hf_h263_pbframes = -1;
59 static int hf_h263_sbit = -1;
60 static int hf_h263_ebit = -1;
61 static int hf_h263_srcformat = -1;
62 static int hf_h263_picture_coding_type = -1;    
63 static int hf_h263_unrestricted_motion_vector = -1;
64 static int hf_h263_syntax_based_arithmetic = -1;
65 static int hf_h263_advanced_prediction = -1;
66 static int hf_h263_r = -1;
67 static int hf_h263_rr = -1;
68 static int hf_h263_dbq = -1;
69 static int hf_h263_trb = -1;
70 static int hf_h263_tr = -1;
71 /* Additional fields for Mode B or C header */
72 static int hf_h263_quant = -1;
73 static int hf_h263_gobn = -1;
74 static int hf_h263_mba = -1;
75 static int hf_h263_hmv1 = -1;
76 static int hf_h263_vmv1 = -1;
77 static int hf_h263_hmv2 = -1;
78 static int hf_h263_vmv2 = -1;
79 /* Fields for the data section */
80 static int hf_h263_psc = -1;
81 static int hf_h263_gbsc = -1;
82 static int hf_h263_TR =-1;
83 static int hf_h263_split_screen_indicator = -1;
84 static int hf_h263_document_camera_indicator = -1;
85 static int hf_h263_full_picture_freeze_release = -1;
86 static int hf_h263_source_format = -1;
87 static int hf_h263_payload_picture_coding_type = -1;
88 static int hf_h263_opt_unres_motion_vector_mode = -1;
89 static int hf_h263_syntax_based_arithmetic_coding_mode = -1;
90 static int hf_h263_optional_advanced_prediction_mode = -1;
91 static int hf_h263_PB_frames_mode = -1;
92 static int hf_h263_data        = -1;
93 static int hf_h263_payload     = -1;
94 static int hf_h263_GN          = -1;
95
96 /* Source format types */
97 #define SRCFORMAT_FORB   0  /* forbidden */
98 #define SRCFORMAT_SQCIF  1
99 #define SRCFORMAT_QCIF   2
100 #define SRCFORMAT_CIF    3
101 #define SRCFORMAT_4CIF   4
102 #define SRCFORMAT_16CIF  5
103
104 static const value_string srcformat_vals[] =
105 {
106   { SRCFORMAT_FORB,     "forbidden" },
107   { SRCFORMAT_SQCIF,    "sub-QCIF 128x96" },
108   { SRCFORMAT_QCIF,     "QCIF 176x144" },
109   { SRCFORMAT_CIF,      "CIF 352x288" },
110   { SRCFORMAT_4CIF,     "4CIF 704x576" },
111   { SRCFORMAT_16CIF,    "16CIF 1408x1152" },
112   { 0,          NULL },
113 };
114
115 static const true_false_string on_off_flg = {
116   "On",
117   "Off"
118 };
119 static const true_false_string picture_coding_type_flg = {
120   "INTER (P-picture)",
121   "INTRA (I-picture)"
122 };
123
124 static const true_false_string PB_frames_mode_flg = {
125   "PB-frame",
126   "Normal I- or P-picture"
127 };
128
129 /* H.263 fields defining a sub tree */
130 static gint ett_h263                    = -1;
131 static gint ett_h263_payload    = -1;
132 static void
133 dissect_h263( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
134 {
135         proto_item *ti                                  = NULL;
136         proto_tree *h263_tree                   = NULL;
137         unsigned int offset                             = 0;
138         unsigned int h263_version               = 0;
139         tvbuff_t *next_tvb;
140
141         h263_version = (tvb_get_guint8( tvb, offset ) & 0xc0 ) >> 6;
142
143         if ( check_col( pinfo->cinfo, COL_PROTOCOL ) )   {
144                 col_set_str( pinfo->cinfo, COL_PROTOCOL, "H.263 " );
145         }
146
147         if( h263_version == 0x00) {
148           if ( check_col( pinfo->cinfo, COL_INFO) ) {
149             col_append_str( pinfo->cinfo, COL_INFO, "MODE A ");
150           }
151         }
152         else if( h263_version == 0x02) {
153           if ( check_col( pinfo->cinfo, COL_INFO) ) {
154             col_append_str( pinfo->cinfo, COL_INFO, "MODE B ");
155           }
156         }
157         else if( h263_version == 0x03) {
158           if ( check_col( pinfo->cinfo, COL_INFO) ) {
159             col_append_str( pinfo->cinfo, COL_INFO, "MODE C ");
160           }
161         }
162
163         if ( tree ) {
164           ti = proto_tree_add_item( tree, proto_h263, tvb, offset, -1, FALSE );
165           h263_tree = proto_item_add_subtree( ti, ett_h263 );
166
167           /* FBIT 1st octet, 1 bit */
168           proto_tree_add_boolean( h263_tree, hf_h263_ftype, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x80 );
169           /* PBIT 1st octet, 1 bit */
170           proto_tree_add_boolean( h263_tree, hf_h263_pbframes, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x40 );
171           /* SBIT 1st octet, 3 bits */
172           proto_tree_add_uint( h263_tree, hf_h263_sbit, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) & 0x38 ) >> 3 );
173           /* EBIT 1st octet, 3 bits */
174           proto_tree_add_uint( h263_tree, hf_h263_ebit, tvb, offset, 1, tvb_get_guint8( tvb, offset )  & 0x7 );
175
176           offset++;
177
178           /* SRC 2nd octet, 3 bits */
179           proto_tree_add_uint( h263_tree, hf_h263_srcformat, tvb, offset, 1, tvb_get_guint8( tvb, offset ) >> 5 );
180
181           if(h263_version == 0x00) { /* MODE A */
182             /* I flag, 1 bit */
183             proto_tree_add_boolean( h263_tree, hf_h263_picture_coding_type, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x10 );
184             /* U flag, 1 bit */
185             proto_tree_add_boolean( h263_tree, hf_h263_unrestricted_motion_vector, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x08 );
186             /* S flag, 1 bit */
187             proto_tree_add_boolean( h263_tree, hf_h263_syntax_based_arithmetic, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x04 );
188             /* A flag, 1 bit */
189             proto_tree_add_boolean( h263_tree, hf_h263_advanced_prediction, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x02 );
190
191             /* Reserved 2nd octect, 1 bit + 3rd octect 3 bits */
192             proto_tree_add_uint( h263_tree, hf_h263_r, tvb, offset, 2, ( ( tvb_get_guint8( tvb, offset ) & 0x1 ) << 3 ) + ( ( tvb_get_guint8( tvb, offset + 1 ) & 0xe0 ) >> 5 ) );
193
194             offset++;
195
196             /* DBQ 3 octect, 2 bits */
197             proto_tree_add_uint( h263_tree, hf_h263_dbq, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) & 0x18 ) >> 3 );
198             /* TRB 3 octect, 3 bits */
199             proto_tree_add_uint( h263_tree, hf_h263_trb, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) & 0x07 ) );
200
201             offset++;
202             
203             /* TR 4 octect, 8 bits */
204             proto_tree_add_uint( h263_tree, hf_h263_tr, tvb, offset, 1, tvb_get_guint8( tvb, offset ) );
205             
206             offset++;
207
208           } else { /* MODE B or MODE C */
209
210             /* QUANT 2 octect, 5 bits */
211             proto_tree_add_uint( h263_tree, hf_h263_quant, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x1f );
212
213             offset++;
214
215             /* GOBN 3 octect, 5 bits */
216             proto_tree_add_uint( h263_tree, hf_h263_gobn, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) & 0xf8 ) >> 3);
217             /* MBA 3 octect, 3 bits + 4 octect 6 bits */
218             proto_tree_add_uint( h263_tree, hf_h263_mba, tvb, offset, 2, ( ( tvb_get_guint8( tvb, offset ) & 0x7 ) << 6 ) + ( ( tvb_get_guint8( tvb, offset + 1 ) & 0xfc ) >> 2 ) );
219             
220             offset++;
221
222             /* Reserved 4th octect, 2 bits */
223             proto_tree_add_uint( h263_tree, hf_h263_r, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) & 0x3 ) );
224
225             offset++;
226
227             /* I flag, 1 bit */
228             proto_tree_add_boolean( h263_tree, hf_h263_picture_coding_type, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x80 );
229             /* U flag, 1 bit */
230             proto_tree_add_boolean( h263_tree, hf_h263_unrestricted_motion_vector, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x40 );
231             /* S flag, 1 bit */
232             proto_tree_add_boolean( h263_tree, hf_h263_syntax_based_arithmetic, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x20 );
233             /* A flag, 1 bit */
234             proto_tree_add_boolean( h263_tree, hf_h263_advanced_prediction, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x10 );
235
236             /* HMV1 5th octect, 4 bits + 6th octect 3 bits*/
237             proto_tree_add_uint( h263_tree, hf_h263_hmv1, tvb, offset, 2,( ( tvb_get_guint8( tvb, offset ) & 0xf ) << 3 ) + ( ( tvb_get_guint8( tvb, offset+1 ) & 0xe0 ) >> 5) );
238
239             offset++;
240             
241             /* VMV1 6th octect, 5 bits + 7th octect 2 bits*/
242             proto_tree_add_uint( h263_tree, hf_h263_vmv1, tvb, offset, 2,( ( tvb_get_guint8( tvb, offset ) & 0x1f ) << 2 ) + ( ( tvb_get_guint8( tvb, offset+1 ) & 0xc0 ) >> 6) );
243             
244             offset++;
245
246             /* HMV2 7th octect, 6 bits + 8th octect 1 bit*/
247             proto_tree_add_uint( h263_tree, hf_h263_hmv2, tvb, offset, 2,( ( tvb_get_guint8( tvb, offset ) & 0x3f ) << 1 ) + ( ( tvb_get_guint8( tvb, offset+1 ) & 0xf0 ) >> 7) );
248             
249             offset++;
250
251             /* VMV2 8th octect, 7 bits*/
252             proto_tree_add_uint( h263_tree, hf_h263_vmv2, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x7f );
253                   
254             offset++;
255
256             if(h263_version == 0x03) { /* MODE C */
257               /* Reserved 9th to 11th octect, 8 + 8 + 3 bits */
258               proto_tree_add_uint( h263_tree, hf_h263_rr, tvb, offset, 3, ( tvb_get_guint8( tvb, offset ) << 11 ) + ( tvb_get_guint8( tvb, offset + 1 ) << 3 ) + ( ( tvb_get_guint8( tvb, offset + 2 ) & 0xe0 ) >> 5 ) );
259
260               offset+=2;
261
262               /* DBQ 11th octect, 2 bits */
263               proto_tree_add_uint( h263_tree, hf_h263_dbq, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) & 0x18 ) >>3 );
264               /* TRB 11th octect, 3 bits */
265               proto_tree_add_uint( h263_tree, hf_h263_trb, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x07 );
266               
267               offset++;
268               
269               /* TR 12th octect, 8 bits */
270               proto_tree_add_uint( h263_tree, hf_h263_tr, tvb, offset, 1, tvb_get_guint8( tvb, offset ) );
271               
272               offset++;
273             } /* end mode c */
274           } /* end not mode a */
275
276           /* The rest of the packet is the H.263 stream */
277           next_tvb = tvb_new_subset( tvb, offset, tvb_length(tvb) - offset, tvb_reported_length(tvb) - offset);
278           dissect_h263_data( next_tvb, pinfo, h263_tree );
279
280         }
281 }
282
283
284 static void dissect_h263_data( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
285 {
286         guint offset = 0;
287         proto_item *h263_payload_item   = NULL;
288         proto_tree *h263_payload_tree   = NULL;
289         guint32 data;
290         guint8 octet;
291
292         if ( check_col( pinfo->cinfo, COL_INFO) ) {
293           col_append_str( pinfo->cinfo, COL_INFO, "H263 payload ");
294         }
295
296         if( tree ) {
297           h263_payload_item = proto_tree_add_item( tree, hf_h263_payload, tvb, offset, -1, FALSE );
298           h263_payload_tree = proto_item_add_subtree( h263_payload_item, ett_h263_payload );
299         }
300
301         /* Check for PSC, PSC is a word of 22 bits. Its value is 0000 0000 0000 0000' 1000 00xx xxxx xxxx. */
302         data = tvb_get_ntohl(tvb, offset);
303         
304         if (( data & 0xffff8000) == 0x00008000 ) { /* PSC or Group of Block Start Code (GBSC) found */
305                 if (( data & 0x00007c00) == 0 ) { /* PSC found */
306                         if ( check_col( pinfo->cinfo, COL_INFO) )
307                           col_append_str( pinfo->cinfo, COL_INFO, "(PSC) ");
308                         if( tree ) {
309                           proto_tree_add_uint(h263_payload_tree, hf_h263_psc,tvb, offset,3,data);
310                           offset = offset + 2;
311                           proto_tree_add_uint(h263_payload_tree, hf_h263_TR,tvb, offset,2,data);
312                           /* Last two bits in the 32 bits fetched
313                            * Bit 1: Always "1", in order to avoid start code emulation. 
314                            * Bit 2: Always "0", for distinction with Recommendation H.261.
315                            */
316                           offset = offset + 2;
317                           /* Bit 3: Split screen indicator, "0" off, "1" on. */
318                           proto_tree_add_item( h263_payload_tree, hf_h263_split_screen_indicator, tvb, offset, 1, FALSE );
319                           /* Bit 4: Document camera indicator, */
320                           proto_tree_add_item( h263_payload_tree, hf_h263_document_camera_indicator, tvb, offset, 1, FALSE );
321                           /* Bit 5: Full Picture Freeze Release, "0" off, "1" on. */
322                           proto_tree_add_item( h263_payload_tree, hf_h263_full_picture_freeze_release, tvb, offset, 1, FALSE );
323                           /* Bits 6-8: Source Format, "000" forbidden, "001" sub-QCIF, "010" QCIF, "011" CIF,
324                            * "100" 4CIF, "101" 16CIF, "110" reserved, "111" extended PTYPE.
325                            */
326                           proto_tree_add_item( h263_payload_tree, hf_h263_source_format, tvb, offset, 1, TRUE );
327                           octet = tvb_get_guint8(tvb,offset);
328                           if (( octet & 0x1c) != 0x1c){
329                                   /* Not extended PTYPE */
330                                   /* Bit 9: Picture Coding Type, "0" INTRA (I-picture), "1" INTER (P-picture). */
331                                   proto_tree_add_item( h263_payload_tree, hf_h263_payload_picture_coding_type, tvb, offset, 1, FALSE );
332                                   /* Bit 10: Optional Unrestricted Motion Vector mode (see Annex D), "0" off, "1" on. */
333                                   proto_tree_add_item( h263_payload_tree, hf_h263_opt_unres_motion_vector_mode, tvb, offset, 1, FALSE );
334                                   offset++;
335                                   /* Bit 11: Optional Syntax-based Arithmetic Coding mode (see Annex E), "0" off, "1" on.*/
336                                   proto_tree_add_item( h263_payload_tree, hf_h263_syntax_based_arithmetic_coding_mode, tvb, offset, 1, FALSE );
337                                   /* Bit 12: Optional Advanced Prediction mode (see Annex F), "0" off, "1" on.*/
338                                   proto_tree_add_item( h263_payload_tree, hf_h263_optional_advanced_prediction_mode, tvb, offset, 1, FALSE );
339                                   /* Bit 13: Optional PB-frames mode (see Annex G), "0" normal I- or P-picture, "1" PB-frame.*/
340                                   proto_tree_add_item( h263_payload_tree, hf_h263_PB_frames_mode, tvb, offset, 1, FALSE );
341                           }
342                         }
343                 } else { /* GBSC found */
344                         if ( check_col( pinfo->cinfo, COL_INFO) )
345                           col_append_str( pinfo->cinfo, COL_INFO, "(GBSC) ");
346                         if( tree ) {
347                                 /* Group of Block Start Code (GBSC) (17 bits)
348                                  * A word of 17 bits. Its value is 0000 0000 0000 0000 1. GOB start codes may be byte aligned. This
349                                  * can be achieved by inserting GSTUF before the start code such that the first bit of the start code is
350                                  * the first (most significant) bit of a byte.
351                                  *
352                                  */
353                                 proto_tree_add_uint(h263_payload_tree, hf_h263_gbsc,tvb, offset,3,data);
354                                 proto_tree_add_uint(h263_payload_tree, hf_h263_GN, tvb, offset,3,data);
355                                 /* GN is followed by (optionally) GBSI, then
356                                  * GFID and GQUANT, but decoding them requires
357                                  * knowing the value of CPM in the picture
358                                  * header */
359                                 offset = offset + 2;
360                         }
361                 }
362         }
363         if( tree )
364                 proto_tree_add_item( h263_payload_tree, hf_h263_data, tvb, offset, -1, FALSE );
365 }
366
367 void
368 proto_register_h263(void)
369 {
370         static hf_register_info hf[] =
371         {
372                 {
373                         &hf_h263_ftype,
374                         {
375                                 "F",
376                                 "h263.ftype",
377                                 FT_BOOLEAN,
378                                 BASE_NONE,
379                                 NULL,
380                                 0x0,
381                                 "Indicates the mode of the payload header (MODE A or B/C)", HFILL
382                         }
383                 },
384                 {
385                         &hf_h263_pbframes,
386                         {
387                                 "p/b frame",
388                                 "h263.pbframes",
389                                 FT_BOOLEAN,
390                                 BASE_NONE,
391                                 NULL,
392                                 0x0,
393                                 "Optional PB-frames mode as defined by H.263 (MODE C)", HFILL
394                         }
395                 },
396                 {
397                         &hf_h263_sbit,
398                         {
399                                 "Start bit position",
400                                 "h263.sbit",
401                                 FT_UINT8,
402                                 BASE_DEC,
403                                 NULL,
404                                 0x0,
405                                 "Start bit position specifies number of most significant bits that shall be ignored in the first data byte.", HFILL
406                         }
407                 },
408                 {
409                         &hf_h263_ebit,
410                         {
411                                 "End bit position",
412                                 "h263.ebit",
413                                 FT_UINT8,
414                                 BASE_DEC,
415                                 NULL,
416                                 0x0,
417                                 "End bit position specifies number of least significant bits that shall be ignored in the last data byte.", HFILL
418                         }
419                 },
420                 {
421                         &hf_h263_srcformat,
422                         {
423                                 "SRC format",
424                                 "h263.srcformat",
425                                 FT_UINT8,
426                                 BASE_DEC,
427                                 VALS(srcformat_vals),
428                                 0x0,
429                                 "Source format specifies the resolution of the current picture.", HFILL
430                         }
431                 },
432                 {
433                         &hf_h263_picture_coding_type,
434                         {
435                                 "Inter-coded frame",
436                                 "h263.picture_coding_type",
437                                 FT_BOOLEAN,
438                                 BASE_NONE,
439                                 NULL,
440                                 0x0,
441                                 "Picture coding type, intra-coded (false) or inter-coded (true)", HFILL
442                         }
443                 },
444                 {
445                         &hf_h263_unrestricted_motion_vector,
446                         {
447                                 "Motion vector",
448                                 "h263.unrestricted_motion_vector",
449                                 FT_BOOLEAN,
450                                 BASE_NONE,
451                                 NULL,
452                                 0x0,
453                                 "Unrestricted Motion Vector option for current picture", HFILL
454                         }
455                 },
456                 {
457                         &hf_h263_syntax_based_arithmetic,
458                         {
459                                 "Syntax-based arithmetic coding",
460                                 "h263.syntax_based_arithmetic",
461                                 FT_BOOLEAN,
462                                 BASE_NONE,
463                                 NULL,
464                                 0x0,
465                                 "Syntax-based Arithmetic Coding option for current picture", HFILL
466                         }
467                 },
468                 {
469                         &hf_h263_advanced_prediction,
470                         {
471                                 "Advanced prediction option",
472                                 "h263.advanced_prediction",
473                                 FT_BOOLEAN,
474                                 BASE_NONE,
475                                 NULL,
476                                 0x0,
477                                 "Advanced Prediction option for current picture", HFILL
478                         }
479                 },
480                 {
481                         &hf_h263_dbq,
482                         {
483                                 "Differential quantization parameter",
484                                 "h263.dbq",
485                                 FT_UINT8,
486                                 BASE_DEC,
487                                 NULL,
488                                 0x0,
489                                 "Differential quantization parameter used to calculate quantizer for the B frame based on quantizer for the P frame, when PB-frames option is used.", HFILL
490                         }
491                 },
492                 {
493                         &hf_h263_trb,
494                         {
495                                 "Temporal Reference for B frames",
496                                 "h263.trb",
497                                 FT_UINT8,
498                                 BASE_DEC,
499                                 NULL,
500                                 0x0,
501                                 "Temporal Reference for the B frame as defined by H.263", HFILL
502                         }
503                 },
504                 {
505                         &hf_h263_tr,
506                         {
507                                 "Temporal Reference for P frames",
508                                 "h263.tr",
509                                 FT_UINT8,
510                                 BASE_DEC,
511                                 NULL,
512                                 0x0,
513                                 "Temporal Reference for the P frame as defined by H.263", HFILL
514                         }
515                 },
516                 {
517                         &hf_h263_quant,
518                         {
519                                 "Quantizer",
520                                 "h263.quant",
521                                 FT_UINT8,
522                                 BASE_DEC,
523                                 NULL,
524                                 0x0,
525                                 "Quantization value for the first MB coded at the starting of the packet.", HFILL
526                         }
527                 },
528                 {
529                         &hf_h263_gobn,
530                         {
531                                 "GOB Number",
532                                 "h263.gobn",
533                                 FT_UINT8,
534                                 BASE_DEC,
535                                 NULL,
536                                 0x0,
537                                 "GOB number in effect at the start of the packet.", HFILL
538                         }
539                 },
540                 {
541                         &hf_h263_mba,
542                         {
543                                 "Macroblock address",
544                                 "h263.mba",
545                                 FT_UINT16,
546                                 BASE_DEC,
547                                 NULL,
548                                 0x0,
549                                 "The address within the GOB of the first MB in the packet, counting from zero in scan order.", HFILL
550                         }
551                 },
552                 {
553                         &hf_h263_hmv1,
554                         {
555                                 "Horizontal motion vector 1",
556                                 "h263.hmv1",
557                                 FT_UINT8,
558                                 BASE_DEC,
559                                 NULL,
560                                 0x0,
561                                 "Horizontal motion vector predictor for the first MB in this packet ", HFILL
562                         }
563                 },
564                 {
565                         &hf_h263_vmv1,
566                         {
567                                 "Vertical motion vector 1",
568                                 "h263.vmv1",
569                                 FT_UINT8,
570                                 BASE_DEC,
571                                 NULL,
572                                 0x0,
573                                 "Vertical motion vector predictor for the first MB in this packet ", HFILL
574                         }
575                 },
576                 {
577                         &hf_h263_hmv2,
578                         {
579                                 "Horizontal motion vector 2",
580                                 "h263.hmv2",
581                                 FT_UINT8,
582                                 BASE_DEC,
583                                 NULL,
584                                 0x0,
585                                 "Horizontal motion vector predictor for block number 3 in the first MB in this packet when four motion vectors are used with the advanced prediction option.", HFILL
586                         }
587                 },
588                 {
589                         &hf_h263_vmv2,
590                         {
591                                 "Vertical motion vector 2",
592                                 "h263.vmv2",
593                                 FT_UINT8,
594                                 BASE_DEC,
595                                 NULL,
596                                 0x0,
597                                 "Vertical motion vector predictor for block number 3 in the first MB in this packet when four motion vectors are used with the advanced prediction option.", HFILL
598                         }
599                 },
600                 {
601                         &hf_h263_r,
602                         {
603                                 "Reserved field",
604                                 "h263.r",
605                                 FT_UINT8,
606                                 BASE_DEC,
607                                 NULL,
608                                 0x0,
609                                 "Reserved field that houls contain zeroes", HFILL
610                         }
611                 },
612                 {
613                         &hf_h263_rr,
614                         {
615                                 "Reserved field 2",
616                                 "h263.rr",
617                                 FT_UINT16,
618                                 BASE_DEC,
619                                 NULL,
620                                 0x0,
621                                 "Reserved field that should contain zeroes", HFILL
622                         }
623                 },
624                 {
625                         &hf_h263_payload,
626                         {
627                                 "H.263 payload",
628                                 "h263.payload",
629                                 FT_NONE,
630                                 BASE_NONE,
631                                 NULL,
632                                 0x0,
633                                 "The actual H.263 data", HFILL
634                         }
635                 },
636                 {
637                         &hf_h263_data,
638                         {
639                                 "H.263 stream",
640                                 "h263.stream",
641                                 FT_BYTES,
642                                 BASE_NONE,
643                                 NULL,
644                                 0x0,
645                                 "The H.263 stream including its Picture, GOB or Macro block start code.", HFILL
646                         }
647                 },
648                 {
649                         &hf_h263_psc,
650                         {
651                                 "H.263 Picture start Code",
652                                 "h263.psc",
653                                 FT_UINT32,
654                                 BASE_HEX,
655                                 NULL,
656                                 0xfffffc00,
657                                 "Picture start Code, PSC", HFILL
658                         }
659                 },
660                 { &hf_h263_gbsc,
661                         {
662                                 "H.263 Group of Block Start Code",
663                                 "h263.gbsc",
664                                 FT_UINT32,
665                                 BASE_HEX,
666                                 NULL,
667                                 0xffff8000,
668                                 "Group of Block Start Code", HFILL
669                         }
670                 },
671                 {
672                         &hf_h263_TR,
673                         {
674                                 "H.263 Temporal Reference",
675                                 "h263.tr2",
676                                 FT_UINT32,
677                                 BASE_HEX,
678                                 NULL,
679                                 0x000003fc,
680                                 "Temporal Reference, TR", HFILL
681                         }
682                 },
683                 {
684                         &hf_h263_split_screen_indicator,
685                         {
686                                 "H.263 Split screen indicator",
687                                 "h263.split_screen_indicator",
688                                 FT_BOOLEAN,
689                                 8,
690                                 TFS(&on_off_flg),
691                                 0x80,
692                                 "Split screen indicator", HFILL
693                         }
694                 },
695                 {
696                         &hf_h263_document_camera_indicator,
697                         {
698                                 "H.263 Document camera indicator",
699                                 "h263.document_camera_indicator",
700                                 FT_BOOLEAN,
701                                 8,
702                                 TFS(&on_off_flg),
703                                 0x40,
704                                 "Document camera indicator", HFILL
705                         }
706                 },
707                 {
708                         &hf_h263_full_picture_freeze_release,
709                         {
710                                 "H.263 Full Picture Freeze Release",
711                                 "h263.split_screen_indicator",
712                                 FT_BOOLEAN,
713                                 8,
714                                 TFS(&on_off_flg),
715                                 0x20,
716                                 "Full Picture Freeze Release", HFILL
717                         }
718                 },
719                 {
720                         &hf_h263_source_format,
721                         {
722                                 "H.263 Source Format",
723                                 "h263.split_screen_indicator",
724                                 FT_UINT8,
725                                 BASE_HEX,
726                                 VALS(srcformat_vals),
727                                 0x1c,
728                                 "Source Format", HFILL
729                         }
730                 },
731                 {
732                         &hf_h263_payload_picture_coding_type,
733                         {
734                                 "H.263 Picture Coding Type",
735                                 "h263.picture_coding_type",
736                                 FT_BOOLEAN,
737                                 8,
738                                 TFS(&picture_coding_type_flg),
739                                 0x02,
740                                 "Picture Coding Typet", HFILL
741                         }
742                 },
743                 {
744                         &hf_h263_opt_unres_motion_vector_mode,
745                         {
746                                 "H.263 Optional Unrestricted Motion Vector mode",
747                                 "h263.opt_unres_motion_vector_mode",
748                                 FT_BOOLEAN,
749                                 8,
750                                 TFS(&on_off_flg),
751                                 0x01,
752                                 "Optional Unrestricted Motion Vector mode", HFILL
753                         }
754                 },
755                 {
756                         &hf_h263_syntax_based_arithmetic_coding_mode,
757                         {
758                                 "H.263 Optional Syntax-based Arithmetic Coding mode",
759                                 "h263.syntax_based_arithmetic_coding_mode",
760                                 FT_BOOLEAN,
761                                 8,
762                                 TFS(&on_off_flg),
763                                 0x80,
764                                 "Optional Syntax-based Arithmetic Coding mode", HFILL
765                         }
766                 },
767                 {
768                         &hf_h263_optional_advanced_prediction_mode,
769                         {
770                                 "H.263 Optional Advanced Prediction mode",
771                                 "h263.optional_advanced_prediction_mode",
772                                 FT_BOOLEAN,
773                                 8,
774                                 TFS(&on_off_flg),
775                                 0x40,
776                                 "Optional Advanced Prediction mode", HFILL
777                         }
778                 },
779                 {
780                         &hf_h263_PB_frames_mode,
781                         {
782                                 "H.263 Optional PB-frames mode",
783                                 "h263.PB_frames_mode",
784                                 FT_BOOLEAN,
785                                 8,
786                                 TFS(&PB_frames_mode_flg),
787                                 0x20,
788                                 "Optional PB-frames mode", HFILL
789                         }
790                 },
791                 {
792                         &hf_h263_GN,
793                         {
794                                 "H.263 Group Number",
795                                 "h263.gn",
796                                 FT_UINT32,
797                                 BASE_DEC,
798                                 NULL,
799                                 0x00007c00,
800                                 "Group Number, GN", HFILL
801                         }
802                 },
803 };
804
805         static gint *ett[] =
806         {
807                 &ett_h263,
808                 &ett_h263_payload,
809         };
810
811
812         proto_h263 = proto_register_protocol("ITU-T Recommendation H.263 RTP Payload header (RFC2190)",
813             "H.263", "h263");
814         proto_h263_data = proto_register_protocol("ITU-T Recommendation H.263",
815             "H.263 data", "h263data");
816         proto_register_field_array(proto_h263, hf, array_length(hf));
817         proto_register_subtree_array(ett, array_length(ett));
818         register_dissector("h263", dissect_h263, proto_h263);
819         register_dissector("h263data", dissect_h263_data, proto_h263_data);
820 }
821
822 void
823 proto_reg_handoff_h263(void)
824 {
825         dissector_handle_t h263_handle;
826
827         h263_handle = find_dissector("h263");
828         dissector_add("rtp.pt", PT_H263, h263_handle);
829         dissector_add("iax2.codec", AST_FORMAT_H263, h263_handle);
830 }