3 * Routines for ITU-T Recommendation H.263 dissection
5 * Copyright 2003 Niklas
\99gren <niklas.ogren@7l.se>
6 * Seven Levels Consultants AB
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * Copied structure from packet-h261.c
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.
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.
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.
32 * This dissector tries to dissect the H.263 protocol according to
33 * ITU-T Recommendations and RFC 2190,
34 * http://www.ietf.org/rfc/rfc4629.txt?number=4629
35 * and http://www.itu.int/rec/T-REC-H.263/en
44 #include <epan/packet.h>
49 #include <epan/emem.h>
50 #include <epan/rtp_pt.h>
51 #include <epan/iax2_codec_type.h>
53 static void dissect_h263_data( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree );
55 /* H.263 header fields */
56 static int proto_h263 = -1;
57 static int proto_h263P = -1;
58 static int proto_h263_data = -1;
61 static int hf_h263_ftype = -1;
62 static int hf_h263_pbframes = -1;
63 static int hf_h263_sbit = -1;
64 static int hf_h263_ebit = -1;
65 static int hf_h263_srcformat = -1;
66 static int hf_h263_picture_coding_type = -1;
67 static int hf_h263_unrestricted_motion_vector = -1;
68 static int hf_h263_syntax_based_arithmetic = -1;
69 static int hf_h263_advanced_prediction = -1;
70 static int hf_h263_r = -1;
71 static int hf_h263_rr = -1;
72 static int hf_h263_dbq = -1;
73 static int hf_h263_trb = -1;
74 static int hf_h263_tr = -1;
75 /* Additional fields for Mode B or C header */
76 static int hf_h263_quant = -1;
77 static int hf_h263_gobn = -1;
78 static int hf_h263_mba = -1;
79 static int hf_h263_hmv1 = -1;
80 static int hf_h263_vmv1 = -1;
81 static int hf_h263_hmv2 = -1;
82 static int hf_h263_vmv2 = -1;
83 /* Fields for the data section */
84 static int hf_h263_psc = -1;
85 static int hf_h263_gbsc = -1;
86 static int hf_h263_TR =-1;
87 static int hf_h263_split_screen_indicator = -1;
88 static int hf_h263_document_camera_indicator = -1;
89 static int hf_h263_full_picture_freeze_release = -1;
90 static int hf_h263_source_format = -1;
91 static int hf_h263_payload_picture_coding_type = -1;
92 static int hf_h263_opt_unres_motion_vector_mode = -1;
93 static int hf_h263_syntax_based_arithmetic_coding_mode = -1;
94 static int hf_h263_optional_advanced_prediction_mode = -1;
95 static int hf_h263_PB_frames_mode = -1;
96 static int hf_h263_data = -1;
97 static int hf_h263_payload = -1;
98 static int hf_h263_GN = -1;
99 static int hf_h263_UFEP = -1;
100 static int hf_h263_opptype = -1;
101 static int hf_h263_pquant = -1;
102 static int hf_h263_cpm = -1;
103 static int hf_h263_psbi = -1;
104 static int hf_h263_picture_type_code = -1;
105 static int hf_h263_ext_source_format = -1;
106 static int hf_h263_custom_pcf = -1;
107 static int hf_h263_pei = -1;
108 static int hf_h263_psupp = -1;
110 /* H.263 RFC 4629 fields */
111 static int hf_h263P_payload = -1;
112 static int hf_h263P_rr = -1;
113 static int hf_h263P_pbit = -1;
114 static int hf_h263P_vbit = -1;
115 static int hf_h263P_plen = -1;
116 static int hf_h263P_pebit = -1;
117 static int hf_h263P_tid = -1;
118 static int hf_h263P_trun = -1;
119 static int hf_h263P_s = -1;
120 static int hf_h263P_extra_hdr = -1;
121 static int hf_h263P_PSC = -1;
122 static int hf_h263P_TR = -1;
124 /* Source format types */
125 #define H263_SRCFORMAT_FORB 0 /* forbidden */
126 #define H263_SRCFORMAT_SQCIF 1
127 #define H263_SRCFORMAT_QCIF 2
128 #define H263_SRCFORMAT_CIF 3
129 #define H263_SRCFORMAT_4CIF 4
130 #define H263_SRCFORMAT_16CIF 5
131 #define H263_PLUSPTYPE 7
133 static const value_string srcformat_vals[] =
135 { H263_SRCFORMAT_FORB, "forbidden" },
136 { H263_SRCFORMAT_SQCIF, "sub-QCIF 128x96" },
137 { H263_SRCFORMAT_QCIF, "QCIF 176x144" },
138 { H263_SRCFORMAT_CIF, "CIF 352x288" },
139 { H263_SRCFORMAT_4CIF, "4CIF 704x576" },
140 { H263_SRCFORMAT_16CIF, "16CIF 1408x1152" },
142 { H263_PLUSPTYPE, "extended PTYPE" },
147 * If UFEP is "001", then the following bits are present in PLUSPTYPE:
148 * Bits 1-3 Source Format, "000" reserved, "001" sub-QCIF, "010" QCIF, "011" CIF,
149 * "100" 4CIF, "101" 16CIF, "110" custom source format, "111" reserved;
151 static const value_string ext_srcformat_vals[] =
154 { H263_SRCFORMAT_SQCIF, "sub-QCIF 128x96" },
155 { H263_SRCFORMAT_QCIF, "QCIF 176x144" },
156 { H263_SRCFORMAT_CIF, "CIF 352x288" },
157 { H263_SRCFORMAT_4CIF, "4CIF 704x576" },
158 { H263_SRCFORMAT_16CIF, "16CIF 1408x1152" },
159 { 6, "Custom source format",},
164 static const value_string h263_ufep_vals[] =
166 { 0, "Only MPPTYPE included" },
167 { 1, "All extended PTYPE fields are included" },
171 static const true_false_string on_off_flg = {
175 static const true_false_string picture_coding_type_flg = {
180 static const value_string picture_coding_type_vals[] =
187 static const true_false_string PB_frames_mode_flg = {
189 "Normal I- or P-picture"
192 static const true_false_string cpm_flg = {
197 static const true_false_string custom_pcf_flg = {
202 /* Bits 1-3 Picture Type Code:*/
203 static const value_string picture_type_code_vals[] =
205 { 0, "I-picture (INTRA)" },
206 { 1, "P-picture (INTER)" },
207 { 2, "Improved PB-frame (see Annex M)" },
208 { 3, "B-picture (see Annex O)" },
209 { 4, "EI-picture (see Annex O)" },
210 { 5, "EP-picture (see Annex O)" },
216 /* H.263 fields defining a sub tree */
217 static gint ett_h263 = -1;
218 static gint ett_h263_payload = -1;
219 static gint ett_h263_optype = -1;
221 /* H.263-1998 fields defining a sub tree */
222 static gint ett_h263P = -1;
223 static gint ett_h263P_extra_hdr = -1;
224 static gint ett_h263P_payload = -1;
225 static gint ett_h263P_data = -1;
228 dissect_h263( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
230 proto_item *ti = NULL;
231 proto_tree *h263_tree = NULL;
232 unsigned int offset = 0;
233 unsigned int h263_version = 0;
236 h263_version = (tvb_get_guint8( tvb, offset ) & 0xc0 ) >> 6;
238 if ( check_col( pinfo->cinfo, COL_PROTOCOL ) ) {
239 col_set_str( pinfo->cinfo, COL_PROTOCOL, "H.263 " );
242 if( h263_version == 0x00) {
243 if ( check_col( pinfo->cinfo, COL_INFO) ) {
244 col_append_str( pinfo->cinfo, COL_INFO, "MODE A ");
247 else if( h263_version == 0x02) {
248 if ( check_col( pinfo->cinfo, COL_INFO) ) {
249 col_append_str( pinfo->cinfo, COL_INFO, "MODE B ");
252 else if( h263_version == 0x03) {
253 if ( check_col( pinfo->cinfo, COL_INFO) ) {
254 col_append_str( pinfo->cinfo, COL_INFO, "MODE C ");
259 ti = proto_tree_add_item( tree, proto_h263, tvb, offset, -1, FALSE );
260 h263_tree = proto_item_add_subtree( ti, ett_h263 );
262 /* FBIT 1st octet, 1 bit */
263 proto_tree_add_boolean( h263_tree, hf_h263_ftype, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x80 );
264 /* PBIT 1st octet, 1 bit */
265 proto_tree_add_boolean( h263_tree, hf_h263_pbframes, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x40 );
266 /* SBIT 1st octet, 3 bits */
267 proto_tree_add_uint( h263_tree, hf_h263_sbit, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) & 0x38 ) >> 3 );
268 /* EBIT 1st octet, 3 bits */
269 proto_tree_add_uint( h263_tree, hf_h263_ebit, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x7 );
273 /* SRC 2nd octet, 3 bits */
274 proto_tree_add_uint( h263_tree, hf_h263_srcformat, tvb, offset, 1, tvb_get_guint8( tvb, offset ) >> 5 );
276 if(h263_version == 0x00) { /* MODE A */
278 proto_tree_add_boolean( h263_tree, hf_h263_picture_coding_type, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x10 );
280 proto_tree_add_boolean( h263_tree, hf_h263_unrestricted_motion_vector, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x08 );
282 proto_tree_add_boolean( h263_tree, hf_h263_syntax_based_arithmetic, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x04 );
284 proto_tree_add_boolean( h263_tree, hf_h263_advanced_prediction, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x02 );
286 /* Reserved 2nd octect, 1 bit + 3rd octect 3 bits */
287 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 ) );
291 /* DBQ 3 octect, 2 bits */
292 proto_tree_add_uint( h263_tree, hf_h263_dbq, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) & 0x18 ) >> 3 );
293 /* TRB 3 octect, 3 bits */
294 proto_tree_add_uint( h263_tree, hf_h263_trb, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) & 0x07 ) );
298 /* TR 4 octect, 8 bits */
299 proto_tree_add_uint( h263_tree, hf_h263_tr, tvb, offset, 1, tvb_get_guint8( tvb, offset ) );
303 } else { /* MODE B or MODE C */
305 /* QUANT 2 octect, 5 bits */
306 proto_tree_add_uint( h263_tree, hf_h263_quant, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x1f );
310 /* GOBN 3 octect, 5 bits */
311 proto_tree_add_uint( h263_tree, hf_h263_gobn, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) & 0xf8 ) >> 3);
312 /* MBA 3 octect, 3 bits + 4 octect 6 bits */
313 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 ) );
317 /* Reserved 4th octect, 2 bits */
318 proto_tree_add_uint( h263_tree, hf_h263_r, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) & 0x3 ) );
323 proto_tree_add_boolean( h263_tree, hf_h263_picture_coding_type, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x80 );
325 proto_tree_add_boolean( h263_tree, hf_h263_unrestricted_motion_vector, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x40 );
327 proto_tree_add_boolean( h263_tree, hf_h263_syntax_based_arithmetic, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x20 );
329 proto_tree_add_boolean( h263_tree, hf_h263_advanced_prediction, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x10 );
331 /* HMV1 5th octect, 4 bits + 6th octect 3 bits*/
332 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) );
336 /* VMV1 6th octect, 5 bits + 7th octect 2 bits*/
337 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) );
341 /* HMV2 7th octect, 6 bits + 8th octect 1 bit*/
342 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) );
346 /* VMV2 8th octect, 7 bits*/
347 proto_tree_add_uint( h263_tree, hf_h263_vmv2, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x7f );
351 if(h263_version == 0x03) { /* MODE C */
352 /* Reserved 9th to 11th octect, 8 + 8 + 3 bits */
353 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 ) );
357 /* DBQ 11th octect, 2 bits */
358 proto_tree_add_uint( h263_tree, hf_h263_dbq, tvb, offset, 1, ( tvb_get_guint8( tvb, offset ) & 0x18 ) >>3 );
359 /* TRB 11th octect, 3 bits */
360 proto_tree_add_uint( h263_tree, hf_h263_trb, tvb, offset, 1, tvb_get_guint8( tvb, offset ) & 0x07 );
364 /* TR 12th octect, 8 bits */
365 proto_tree_add_uint( h263_tree, hf_h263_tr, tvb, offset, 1, tvb_get_guint8( tvb, offset ) );
369 } /* end not mode a */
371 /* The rest of the packet is the H.263 stream */
372 next_tvb = tvb_new_subset( tvb, offset, tvb_length(tvb) - offset, tvb_reported_length(tvb) - offset);
373 dissect_h263_data( next_tvb, pinfo, h263_tree );
378 #define cVALS(x) (const value_string*)(x)
381 h263_proto_tree_add_bits(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, guint32 *return_value)
387 header_field_info *hf_field;
390 guint32 mask = 0, tmp;
391 gboolean is_bytealigned = FALSE;
393 guint16 mask16 = 0xffff;
394 guint32 mask24 = 0xffffff;
395 guint32 mask32 = 0xffffffff;
399 if((bit_offset&0x7)==0)
400 is_bytealigned = TRUE;
402 hf_field = proto_registrar_get_nth(hf_index);
404 offset = bit_offset>>3;
405 bit_length = ((bit_offset&0x7)+no_of_bits);
406 length = bit_length >>3;
407 if((bit_length&0x7)!=0)
412 mask8 = mask8 >>(bit_offset&0x7);
413 value = tvb_get_guint8(tvb,offset) & mask8;
415 shift = 8-((bit_offset + no_of_bits)&0x7);
417 value = value >> shift;
418 mask = mask >> shift;
420 }else if(no_of_bits < 9){
424 mask8 = mask8>>(bit_offset&0x7);
425 value = tvb_get_guint8(tvb,offset)&mask8;
429 mask16 = mask16>>(bit_offset&0x7);
430 value = tvb_get_ntohs(tvb,offset) & mask16;
433 shift = 8-((bit_offset + no_of_bits)&0x7);
435 value = value >> shift;
436 mask = mask >> shift;
439 }else if (no_of_bits < 17){
443 mask16 = mask16>>(bit_offset&0x7);
444 value = tvb_get_ntohs(tvb,offset) & mask16;
448 mask24 = mask24>>(bit_offset&0x7);
449 value = tvb_get_ntoh24(tvb,offset) & mask24;
452 shift = 8-((bit_offset + no_of_bits)&0x7);
454 value = value >> shift;
455 mask = mask >> shift;
458 }else if (no_of_bits < 25){
462 mask24 = mask24>>(bit_offset&0x7);
463 value = tvb_get_ntoh24(tvb,offset) & mask24;
467 mask32 = mask32>>(bit_offset&0x7);
468 value = tvb_get_ntohl(tvb,offset) & mask32;
471 shift = 8-((bit_offset + no_of_bits)&0x7);
473 value = value >> shift;
474 mask = mask >> shift;
477 }else if (no_of_bits < 33){
481 mask32 = mask32>>(bit_offset&0x7);
482 value = tvb_get_ntohl(tvb,offset) & mask32;
486 * Does not handle unaligned bits over 24
488 DISSECTOR_ASSERT_NOT_REACHED();
490 shift = 8-((bit_offset + no_of_bits)&0x7);
492 value = value >> shift;
493 mask = mask >> shift;
497 DISSECTOR_ASSERT_NOT_REACHED();
500 /* prepare the string */
503 for(bit=0;bit<((int)(bit_offset&0x07));bit++){
510 /* read the bits for the int */
511 for(i=0;i<no_of_bits;i++){
541 strcat(str,hf_field->name);
543 if (hf_field->type == FT_BOOLEAN){
545 if (hf_field->strings) {
546 const true_false_string *tfstring = &tfs_true_false;
547 tfstring = (const struct true_false_string*) hf_field->strings;
549 return proto_tree_add_boolean_format(tree, hf_index, tvb, offset, length, value,
552 value ? tfstring->true_string : tfstring->false_string);
554 return proto_tree_add_boolean_format(tree, hf_index, tvb, offset, length, value,
560 /* 1 - 32 bits field */
562 if (hf_field->strings) {
563 return proto_tree_add_uint_format(tree, hf_index, tvb, offset, length, value,
566 val_to_str(value, cVALS(hf_field->strings), "Unknown"));
568 switch(hf_field->display){
570 return proto_tree_add_uint_format(tree, hf_index, tvb, offset, length, value,
576 return proto_tree_add_uint_format(tree, hf_index, tvb, offset, length, value,
582 DISSECTOR_ASSERT_NOT_REACHED();
590 * 5.3 Macroblock layer
592 dissect_h263_macroblock_layer( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
600 dissect_h263_group_of_blocks_layer( tvbuff_t *tvb, proto_tree *tree, gint offset, gboolean is_rfc4626)
603 unsigned int offset_in_bits = offset << 3;
607 h263_proto_tree_add_bits(tree, hf_h263_gbsc, tvb, offset_in_bits, 1, NULL);
610 /* Group of Block Start Code (GBSC) (17 bits)
611 * A word of 17 bits. Its value is 0000 0000 0000 0000 1.
613 h263_proto_tree_add_bits(tree, hf_h263_gbsc, tvb, offset_in_bits, 17, NULL);
614 offset_in_bits = offset_in_bits +17;
617 * Group Number (GN) (5 bits)
619 h263_proto_tree_add_bits(tree, hf_h263_GN, tvb, offset_in_bits, 5, NULL);
620 offset_in_bits = offset_in_bits +5;
621 /* 5.2.4 GOB Sub-Bitstream Indicator (GSBI) (2 bits)
622 * A fixed length codeword of 2 bits that is only present if CPM is "1" in the picture header.
625 * 5.2.5 GOB Frame ID (GFID) (2 bits)
628 * 5.2.6 Quantizer Information (GQUANT) (5 bits)
631 * 5.3 Macroblock layer
634 return offset_in_bits>>3;
639 * Length is used for the "Extra header" otherwise set to -1.
642 dissect_h263_picture_layer( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset, gint length _U_, gboolean is_rfc4626)
644 proto_tree *h263_opptype_tree = NULL;
645 proto_item *opptype_item = NULL;
646 unsigned int offset_in_bits = offset << 3;
647 guint32 source_format;
649 guint32 picture_coding_type;
650 guint32 PB_frames_mode = 0;
651 guint32 custom_pcf = 0;
652 guint32 picture_type_code =0;
658 h263_proto_tree_add_bits(tree, hf_h263_psc, tvb, offset_in_bits, 6, NULL);
659 offset_in_bits = offset_in_bits +6;
662 /* Check for PSC, PSC is a word of 22 bits.
663 * Its value is 0000 0000 0000 0000' 1000 00xx xxxx xxxx.
665 h263_proto_tree_add_bits(tree, hf_h263_psc, tvb, offset_in_bits, 22, NULL);
666 offset_in_bits = offset_in_bits +22;
669 h263_proto_tree_add_bits(tree, hf_h263_TR, tvb, offset_in_bits, 8, NULL);
670 offset_in_bits = offset_in_bits +8;
672 * Bit 1: Always "1", in order to avoid start code emulation.
673 * Bit 2: Always "0", for distinction with Recommendation H.261.
675 offset_in_bits = offset_in_bits +2;
676 /* Bit 3: Split screen indicator, "0" off, "1" on. */
677 h263_proto_tree_add_bits( tree, hf_h263_split_screen_indicator, tvb, offset_in_bits, 1, NULL);
679 /* Bit 4: Document camera indicator, */
680 h263_proto_tree_add_bits( tree, hf_h263_document_camera_indicator, tvb, offset_in_bits, 1, NULL);
682 /* Bit 5: Full Picture Freeze Release, "0" off, "1" on. */
683 h263_proto_tree_add_bits( tree, hf_h263_full_picture_freeze_release, tvb, offset_in_bits, 1, NULL);
685 /* Bits 6-8: Source Format, "000" forbidden, "001" sub-QCIF, "010" QCIF, "011" CIF,
686 * "100" 4CIF, "101" 16CIF, "110" reserved, "111" extended PTYPE.
688 h263_proto_tree_add_bits( tree, hf_h263_source_format, tvb, offset_in_bits, 3 ,&source_format);
689 offset_in_bits = offset_in_bits +3;
690 if (source_format != H263_PLUSPTYPE){
691 /* Not extended PTYPE */
692 /* Bit 9: Picture Coding Type, "0" INTRA (I-picture), "1" INTER (P-picture). */
693 h263_proto_tree_add_bits( tree, hf_h263_payload_picture_coding_type, tvb, offset_in_bits, 1, &picture_coding_type);
694 if ( check_col( pinfo->cinfo, COL_INFO) )
695 col_append_fstr(pinfo->cinfo, COL_INFO, val_to_str(picture_coding_type, picture_coding_type_vals, "Unknown (%u)"));
697 /* Bit 10: Optional Unrestricted Motion Vector mode (see Annex D), "0" off, "1" on. */
698 h263_proto_tree_add_bits( tree, hf_h263_opt_unres_motion_vector_mode, tvb, offset_in_bits, 1, NULL);
700 /* Bit 11: Optional Syntax-based Arithmetic Coding mode (see Annex E), "0" off, "1" on.*/
701 h263_proto_tree_add_bits( tree, hf_h263_syntax_based_arithmetic_coding_mode, tvb, offset_in_bits, 1, NULL);
703 /* Bit 12: Optional Advanced Prediction mode (see Annex F), "0" off, "1" on.*/
704 h263_proto_tree_add_bits( tree, hf_h263_optional_advanced_prediction_mode, tvb, offset_in_bits, 1, NULL);
706 /* Bit 13: Optional PB-frames mode (see Annex G), "0" normal I- or P-picture, "1" PB-frame.*/
707 h263_proto_tree_add_bits( tree, hf_h263_PB_frames_mode, tvb, offset_in_bits, 1, &PB_frames_mode);
711 * Update Full Extended PTYPE (UFEP) (3 bits)
713 /* .... ..xx x... .... */
714 h263_proto_tree_add_bits( tree, hf_h263_UFEP, tvb, offset_in_bits, 3, &ufep);
715 offset_in_bits = offset_in_bits +3;
717 /* The Optional Part of PLUSPTYPE (OPPTYPE) (18 bits)
719 /* .xxx xxxx xxxx xxxx xxx. .... */
720 opptype_item = h263_proto_tree_add_bits( tree, hf_h263_opptype, tvb, offset_in_bits, 18, NULL);
721 h263_opptype_tree = proto_item_add_subtree( opptype_item, ett_h263_optype );
723 * If UFEP is "001", then the following bits are present in PLUSPTYPE:
724 * Bits 1-3 Source Format, "000" reserved, "001" sub-QCIF, "010" QCIF, "011" CIF,
725 * "100" 4CIF, "101" 16CIF, "110" custom source format, "111" reserved;
727 h263_proto_tree_add_bits( h263_opptype_tree, hf_h263_ext_source_format, tvb, offset_in_bits, 3, NULL);
728 offset_in_bits = offset_in_bits +3;
731 * Bit 4 Optional Custom PCF, "0" CIF PCF, "1" custom PCF;
733 h263_proto_tree_add_bits( h263_opptype_tree, hf_h263_custom_pcf, tvb, offset_in_bits, 3, &custom_pcf);
736 * Bit 5 Optional Unrestricted Motion Vector (UMV) mode (see Annex D), "0" off, "1" on;
740 * Bit 6 Optional Syntax-based Arithmetic Coding (SAC) mode (see Annex E), "0" off, "1" on;
744 * Bit 7 Optional Advanced Prediction (AP) mode (see Annex F), "0" off, "1" on;
748 * Bit 8 Optional Advanced INTRA Coding (AIC) mode (see Annex I), "0" off, "1" on;
752 * Bit 9 Optional Deblocking Filter (DF) mode (see Annex J), "0" off, "1" on;
756 * Bit 10 Optional Slice Structured (SS) mode (see Annex K), "0" off, "1" on;
760 * Bit 11 Optional Reference Picture Selection (RPS) mode (see Annex N), "0" off, "1" on;
764 * Bit 12 Optional Independent Segment Decoding (ISD) mode (see Annex R), "0" off,"1" on;
768 * Bit 13 Optional Alternative INTER VLC (AIV) mode (see Annex S), "0" off, "1" on;
772 * Bit 14 Optional Modified Quantization (MQ) mode (see Annex T), "0" off, "1" on;
776 * Bit 15 Equal to "1" to prevent start code emulation;
780 * Bit 16 Reserved, shall be equal to "0";
784 * Bit 17 Reserved, shall be equal to "0";
788 * Bit 18 Reserved, shall be equal to "0".
793 * 5.1.4.3 The mandatory part of PLUSPTYPE when PLUSPTYPE present (MPPTYPE) (9 bits)
794 * Regardless of the value of UFEP, the following 9 bits are also present in PLUSPTYPE:
795 * - Bits 1-3 Picture Type Code:
796 * "000" I-picture (INTRA);
797 * "001" P-picture (INTER);
798 * "010" Improved PB-frame (see Annex M);
799 * "011" B-picture (see Annex O);
800 * "100" EI-picture (see Annex O);
801 * "101" EP-picture (see Annex O);
805 h263_proto_tree_add_bits( tree, hf_h263_picture_type_code, tvb, offset_in_bits, 3, &picture_type_code);
806 offset_in_bits = offset_in_bits +3;
808 * Bit 4 Optional Reference Picture Resampling (RPR) mode (see Annex P), "0" off, "1" on;
812 * Bit 5 Optional Reduced-Resolution Update (RRU) mode (see Annex Q), "0" off, "1" on;
816 * Bit 6 Rounding Type (RTYPE) (see 6.1.2);
820 * Bit 7 Reserved, shall be equal to "0";
824 * Bit 8 Reserved, shall be equal to "0";
828 * Bit 9 Equal to "1" to prevent start code emulation.
831 /* The picture header location of CPM (1 bit) and PSBI (2 bits)
832 * the picture header depends on whether or not PLUSPTYPE is present
833 * (see 5.1.20 and 5.1.21). If PLUSPTYPE is present, then CPM follows
834 * immediately after PLUSPTYPE in the picture header.
836 h263_proto_tree_add_bits( tree, hf_h263_cpm, tvb, offset_in_bits, 1, &cpm);
838 /* 5.1.21 Picture Sub-Bitstream Indicator (PSBI) (2 bits)
839 * only present if Continuous Presence Multipoint and Video
840 * Multiplex mode is indicated by CPM.
843 h263_proto_tree_add_bits( tree, hf_h263_psbi, tvb, offset_in_bits, 2, NULL);
844 offset_in_bits = offset_in_bits +2;
846 /* TODO Add the rest of the fields */
847 /* 5.1.5 Custom Picture Format (CPFMT) (23 bits)
848 * present only if the use of a custom picture format is
849 * signalled in PLUSPTYPE and UFEP is '001'. When present, CPFMT consists of:
850 * Bits 1-4 Pixel Aspect Ratio Code: A 4-bit index to the PAR value in Table 5. For
851 * extended PAR, the exact pixel aspect ratio shall be specified in EPAR
853 * Bits 5-13 Picture Width Indication: Range [0, ... , 511]; Number of pixels per
854 * line = (PWI + 1) * 4;
855 * Bit 14 Equal to "1" to prevent start code emulation;
856 * Bits 15-23 Picture Height Indication: Range [1, ... , 288]; Number of lines = PHI * 4.
858 /* 5.1.6 Extended Pixel Aspect Ratio (EPAR) (16 bits)
859 * A fixed length codeword of 16 bits that is present only if CPFMT is present and extended PAR is
860 * indicated therein. When present, EPAR consists of:
861 * Bits 1-8 PAR Width: "0" is forbidden. The natural binary representation of the PAR
863 * Bits 9-16 PAR Height: "0" is forbidden. The natural binary representation of the PAR
866 /* 5.1.7 Custom Picture Clock Frequency Code (CPCFC) (8 bits)
867 * A fixed length codeword of 8 bits that is present only if PLUSPTYPE is present and UFEP is 001
868 * and a custom picture clock frequency is signalled in PLUSPTYPE. When present, CPCFC consists of:
869 * Bit 1 Clock Conversion Code: "0" indicates a clock conversion factor of 1000 and
870 * "1" indicates 1001;
871 * Bits 2-8 Clock Divisor: "0" is forbidden. The natural binary representation of the value
872 * of the clock divisor.
874 /* 5.1.8 Extended Temporal Reference (ETR) (2 bits)
875 * A fixed length codeword of 2 bits which is present only if a custom picture clock frequency is in
876 * use (regardless of the value of UFEP). It is the two MSBs of the 10-bit number defined in 5.1.2.
878 /* 5.1.9 Unlimited Unrestricted Motion Vectors Indicator (UUI) (Variable length)
879 * A variable length codeword of 1 or 2 bits that is present only if the optional Unrestricted Motion
880 * Vector mode is indicated in PLUSPTYPE and UFEP is 001. When UUI is present it indicates the
881 * effective limitation of the range of the motion vectors being used.
882 * UUI = "1" The motion vector range is limited according to Tables D.1 and D.2.
883 * UUI = "01" The motion vector range is not limited except by the picture size.
886 * 5.1.10 Slice Structured Submode bits (SSS) (2 bits)
887 * A fixed length codeword of 2 bits which is present only if the optional Slice Structured mode
888 * (see Annex K) is indicated in PLUSPTYPE and UFEP is 001. If the Slice Structured mode is in use
889 * but UFEP is not 001, the last values sent for SSS shall remain in effect.
890 * - Bit 1 Rectangular Slices, "0" indicates free-running slices, "1" indicates rectangular
892 * - Bit 2 Arbitrary Slice Ordering, "0" indicates sequential order, "1" indicates arbitrary
894 * 5.1.11 Enhancement Layer Number (ELNUM) (4 bits)
895 * A fixed length codeword of 4 bits which is present only if the optional Temporal, SNR, and Spatial
896 * Scalability mode is in use (regardless of the value of UFEP). The particular enhancement layer is
897 * identified by an enhancement layer number, ELNUM. Picture correspondence between layers is
898 * achieved via the temporal reference. Picture size is either indicated within each enhancement layer
899 * using the existing source format fields or is inferred by the relationship to the reference layer. The
900 * first enhancement layer above the base layer is designated as Enhancement Layer Number 2, and
901 * the base layer has number 1.
902 * 5.1.12 Reference Layer Number (RLNUM) (4 bits)
903 * A fixed length codeword of 4 bits which is present only if the optional Temporal, SNR, and Spatial
904 * Scalability mode is in use (see Annex O) and UFEP is 001. The layer number for the pictures used
905 * as reference anchors is identified by a Reference Layer Number (RLNUM). Time correspondence
906 * between layers is achieved via the temporal reference.
907 * Note that for B-pictures in an enhancement layer having temporally surrounding EI- or EP-pictures
908 * which are present in the same enhancement layer, RLNUM shall be equal to ELNUM
910 * 5.1.13 Reference Picture Selection Mode Flags (RPSMF) (3 bits)
911 * A fixed length codeword of 3 bits that is present only if the Reference Picture Selection mode is in
912 * use and UFEP is 001. When present, RPSMF indicates which type of back-channel messages are
913 * needed by the encoder. If the Reference Picture Selection mode is in use but RPSMF is not present,
914 * the last value of RPSMF that was sent shall remain in effect.
915 * - 100: neither ACK nor NACK signals needed;
916 * - 101: need ACK signals to be returned;
917 * - 110: need NACK signals to be returned;
918 * - 111: need both ACK and NACK signals to be returned;
919 * - 000-011: Reserved.
920 * 5.1.14 Temporal Reference for Prediction Indication (TRPI) (1 bit)
921 * A fixed length codeword of 1 bit that is present only if the optional Reference Picture Selection
922 * mode is in use (regardless of the value of UFEP). When present, TRPI indicates the presence of the
923 * following TRP field:
924 * - 0: TRP field is not present;
925 * - 1: TRP field is present.
926 * TRPI shall be 0 whenever the picture header indicates an I- or EI-picture.
927 * 5.1.15 Temporal Reference for Prediction (TRP) (10 bits)
928 * When present (as indicated in TRPI), TRP indicates the Temporal Reference which is used for
929 * prediction of the encoding, except for in the case of B-pictures. For B-pictures, the picture having
930 * the temporal reference TRP is used for the prediction in the forward direction. (Prediction in the
931 * reverse-temporal direction always uses the immediately temporally subsequent picture.) TRP is a
932 * ten-bit number. If a custom picture clock frequency was not in use for the reference picture, the two
933 * MSBs of TRP are zero and the LSBs contain the eight-bit TR found in the picture header of the
934 * reference picture. If a custom picture clock frequency was in use for the reference picture, TRP is a
935 * ten-bit number consisting of the concatenation of ETR and TR from the reference picture header.
936 * When TRP is not present, the most recent temporally previous anchor picture shall be used for
937 * prediction, as when not in the Reference Picture Selection mode. TRP is valid until the next PSC,
939 * 5.1.16 Back-Channel message Indication (BCI) (Variable length)
940 * A variable length field of one or two bits that is present only if the optional Reference Picture
941 * Selection mode is in use. When set to "1", this signals the presence of the following optional video
942 * Back-Channel Message (BCM) field. "01" indicates the absence or the end of the video backchannel
943 * message field. Combinations of BCM and BCI may not be present, and may be repeated
944 * when present. BCI shall be set to "01" if the videomux submode of the optional Reference Picture
945 * Selection mode is not in use.
946 * 5.1.17 Back-Channel Message (BCM) (Variable length)
947 * The Back-Channel message with syntax as specified in N.4.2, which is present only if the preceding
948 * BCI field is present and is set to "1".
949 * 5.1.18 Reference Picture Resampling Parameters (RPRP) (Variable length)
950 * A variable length field that is present only if the optional Reference Picture Resampling mode bit is
951 * set in PLUSPTYPE. This field carries the parameters of the Reference Picture Resampling mode
952 * (see Annex P). Note that the Reference Picture Resampling mode can also be invoked implicitly by
953 * the occurrence of a picture header for an INTER coded picture having a picture size which differs
954 * from that of the previous encoded picture, in which case the RPRP field is not present and the
955 * Reference Picture Resampling mode bit is not set.
958 /* 5.1.19 Quantizer Information (PQUANT) (5 bits) */
959 h263_proto_tree_add_bits( tree, hf_h263_pquant, tvb, offset_in_bits, 5, NULL);
960 offset_in_bits = offset_in_bits +5;
961 if (source_format != H263_PLUSPTYPE){
962 h263_proto_tree_add_bits( tree, hf_h263_cpm, tvb, offset_in_bits, 1, &cpm);
964 /* 5.1.21 Picture Sub-Bitstream Indicator (PSBI) (2 bits)
965 * only present if Continuous Presence Multipoint and Video
966 * Multiplex mode is indicated by CPM.
969 h263_proto_tree_add_bits( tree, hf_h263_psbi, tvb, offset_in_bits, 2, NULL);
970 offset_in_bits = offset_in_bits +2;
973 /* 5.1.22 Temporal Reference for B-pictures in PB-frames (TRB) (3/5 bits)
974 * TRB is present if PTYPE or PLUSPTYPE indicates "PB-frame" or "Improved PB-frame"
975 * It is 3 bits long for standard CIF picture clock frequency and is
976 * extended to 5 bits when a custom picture clock frequency is in use.
978 if((PB_frames_mode == 1)||(picture_type_code == 2 )){
980 h263_proto_tree_add_bits( tree, hf_h263_trb, tvb, offset_in_bits, 3, NULL);
981 offset_in_bits = offset_in_bits +3;
983 h263_proto_tree_add_bits( tree, hf_h263_trb, tvb, offset_in_bits, 5, NULL);
984 offset_in_bits = offset_in_bits +5;
987 /* 5.1.23 Quantization information for B-pictures in PB-frames (DBQUANT) (2 bits)
988 * DBQUANT is present if PTYPE or PLUSPTYPE indicates "PB-frame" or "Improved PB-frame"
990 if((PB_frames_mode == 1)||(picture_type_code == 2 )){
991 offset_in_bits = offset_in_bits +2;
993 /* 5.1.24 Extra Insertion Information (PEI) (1 bit)
994 * A bit which when set to "1" signals the presence of the following optional data field.
996 h263_proto_tree_add_bits( tree, hf_h263_pei, tvb, offset_in_bits, 1, &pei);
999 /*5.1.25 Supplemental Enhancement Information (PSUPP) (0/8/16 ... bits)
1000 * If PEI is set to "1", then 9 bits follow consisting of 8 bits of data (PSUPP) and then another PEI bit
1001 * to indicate if a further 9 bits follow and so on. Encoders shall use PSUPP as specified in Annex L.
1003 h263_proto_tree_add_bits( tree, hf_h263_psupp, tvb, offset_in_bits, 8, NULL);
1004 offset_in_bits = offset_in_bits +8;
1005 h263_proto_tree_add_bits( tree, hf_h263_pei, tvb, offset_in_bits, 1, &pei);
1008 /* For the first GOB in each picture (with number 0), no GOB header shall be transmitted.
1009 * For all other GOBs, the GOB header may be empty, depending on the encoder strategy.
1013 * 5.3 Macroblock layer
1014 * dissect_h263_macroblock_layer( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
1017 return offset_in_bits>>3;
1023 dissect_h263P( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
1025 proto_item *ti = NULL;
1026 proto_item *data_item = NULL;
1027 proto_item *extra_hdr_item = NULL;
1028 proto_tree *h263P_tree = NULL;
1029 proto_tree *h263P_extr_hdr_tree = NULL;
1030 proto_tree *h263P_data_tree = NULL;
1031 unsigned int offset = 0;
1032 unsigned int start_offset = 0;
1033 guint16 data16, plen;
1040 if ( check_col( pinfo->cinfo, COL_PROTOCOL ) ) {
1041 col_set_str( pinfo->cinfo, COL_PROTOCOL, "H.263 RFC4629 " );
1045 ti = proto_tree_add_item( tree, proto_h263P, tvb, offset, -1, FALSE );
1046 h263P_tree = proto_item_add_subtree( ti, ett_h263P );
1047 /* Add it as hidden to make a filter of h263 possible here as well */
1048 proto_tree_add_item_hidden( tree, proto_h263, tvb, offset, -1, FALSE );
1050 data16 = tvb_get_ntohs(tvb,offset);
1051 proto_tree_add_item( h263P_tree, hf_h263P_rr, tvb, offset, 2, FALSE );
1052 proto_tree_add_item( h263P_tree, hf_h263P_pbit, tvb, offset, 2, FALSE );
1053 proto_tree_add_item( h263P_tree, hf_h263P_vbit, tvb, offset, 2, FALSE );
1054 proto_tree_add_item( h263P_tree, hf_h263P_plen, tvb, offset, 2, FALSE );
1055 proto_tree_add_item( h263P_tree, hf_h263P_pebit, tvb, offset, 2, FALSE );
1060 * Indicates the presence of an 8-bit field containing information
1061 * for Video Redundancy Coding (VRC), which follows immediately after
1062 * the initial 16 bits of the payload header, if present. For syntax
1063 * and semantics of that 8-bit VRC field, see Section 5.2.
1066 if ((data16&0x0200)==0x0200){
1068 * The format of the VRC header extension is as follows:
1077 * Thread ID. Up to 7 threads are allowed. Each frame of H.263+ VRC
1078 * data will use as reference information only sync frames or frames
1079 * within the same thread. By convention, thread 0 is expected to be
1080 * the "canonical" thread, which is the thread from which the sync frame
1081 * should ideally be used. In the case of corruption or loss of the
1082 * thread 0 representation, a representation of the sync frame with a
1083 * higher thread number can be used by the decoder. Lower thread
1084 * numbers are expected to contain representations of the sync frames
1085 * equal to or better than higher thread numbers in the absence of data
1086 * corruption or loss. See [Vredun] for a detailed discussion of VRC.
1090 * Monotonically increasing (modulo 16) 4-bit number counting the packet
1091 * number within each thread.
1095 * A bit that indicates that the packet content is for a sync frame.
1098 proto_tree_add_item( h263P_tree, hf_h263P_tid, tvb, offset, 1, FALSE );
1099 proto_tree_add_item( h263P_tree, hf_h263P_trun, tvb, offset, 1, FALSE );
1100 proto_tree_add_item( h263P_tree, hf_h263P_s, tvb, offset, 1, FALSE );
1104 /* Length, in bytes, of the extra picture header. */
1105 plen = (data16 & 0x01f8) >> 3;
1107 start_offset = offset;
1108 extra_hdr_item = proto_tree_add_item( h263P_tree, hf_h263P_extra_hdr, tvb, offset, plen, FALSE );
1109 h263P_extr_hdr_tree = proto_item_add_subtree( extra_hdr_item, ett_h263P_extra_hdr );
1111 dissect_h263_picture_layer( tvb, pinfo, h263P_extr_hdr_tree, offset, plen, TRUE);
1113 offset = start_offset + plen;
1115 if ((data16&0x0400)!=0){
1117 data_item = proto_tree_add_item( h263P_tree, hf_h263P_payload, tvb, offset, -1, FALSE );
1118 h263P_data_tree = proto_item_add_subtree( data_item, ett_h263P_data );
1119 /* Startc code holds bit 17 -23 of the codeword */
1120 startcode = tvb_get_guint8(tvb,offset)&0xfe;
1121 if (startcode & 0x80){
1122 /* All picture, slice, and EOSBS start codes
1123 * shall be byte aligned, and GOB and EOS start codes may be byte aligned.
1127 /* End Of Sub-Bitstream code (EOSBS)
1128 * EOSBS codes shall be byte aligned
1134 /* Picture Start Code (PSC)
1137 if(check_col( pinfo->cinfo, COL_INFO))
1138 col_append_str( pinfo->cinfo, COL_INFO, "(PSC) ");
1139 offset = dissect_h263_picture_layer( tvb, pinfo, h263P_data_tree, offset, -1, TRUE);
1143 /* End Of Sequence (EOS)
1147 /* Group of Block Start Code (GBSC) or
1148 * Slice Start Code (SSC)
1150 if ( check_col( pinfo->cinfo, COL_INFO) )
1151 col_append_str( pinfo->cinfo, COL_INFO, "(GBSC) ");
1152 dissect_h263_group_of_blocks_layer( tvb, h263P_data_tree, offset,TRUE);
1160 proto_tree_add_item( h263P_tree, hf_h263P_payload, tvb, offset, -1, FALSE );
1164 5.1.1 Picture Start Code (PSC) (22 bits)
1165 PSC is a word of 22 bits. Its value is 0000 0000 0000 0000 1 00000. All picture start codes shall be
1169 End Of Sequence (EOS) (22 bits)
1170 A codeword of 22 bits. Its value is 0000 0000 0000 0000 1 11111.
1173 Group of Block Start Code (GBSC) (17 bits)
1174 A word of 17 bits. Its value is 0000 0000 0000 0000 1.
1177 End Of Sub-Bitstream code (EOSBS) (23 bits)
1178 The EOSBS code is a codeword of 23 bits. Its value is 0000 0000 0000 0000 1 11110 0.
1181 Slice Start Code (SSC) (17 bits)
1182 A word of 17 bits. Its value is 0000 0000 0000 0000 1.
1185 static void dissect_h263_data( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
1188 proto_item *h263_payload_item = NULL;
1189 proto_tree *h263_payload_tree = NULL;
1193 if ( check_col( pinfo->cinfo, COL_INFO) ) {
1194 col_append_str( pinfo->cinfo, COL_INFO, "H263 payload ");
1198 h263_payload_item = proto_tree_add_item( tree, hf_h263_payload, tvb, offset, -1, FALSE );
1199 h263_payload_tree = proto_item_add_subtree( h263_payload_item, ett_h263_payload );
1202 /* Check for PSC, PSC is a word of 22 bits. Its value is 0000 0000 0000 0000' 1000 00xx xxxx xxxx. */
1203 data = tvb_get_ntohl(tvb, offset);
1205 if (( data & 0xffff8000) == 0x00008000 ) {
1208 * Startc code holds bit 17 -23 of the codeword
1210 startcode = tvb_get_guint8(tvb,offset+2)&0xfe;
1211 if (startcode & 0x80){
1214 /* End Of Sub-Bitstream code (EOSBS)
1220 /* Picture Start Code (PSC)
1223 if(check_col( pinfo->cinfo, COL_INFO))
1224 col_append_str( pinfo->cinfo, COL_INFO, "(PSC) ");
1225 offset = dissect_h263_picture_layer( tvb, pinfo, h263_payload_tree, offset, -1, FALSE);
1229 /* End Of Sequence (EOS)
1233 /* Group of Block Start Code (GBSC) or
1234 * Slice Start Code (SSC)
1236 if ( check_col( pinfo->cinfo, COL_INFO) )
1237 col_append_str( pinfo->cinfo, COL_INFO, "(GBSC) ");
1238 offset = dissect_h263_group_of_blocks_layer( tvb, h263_payload_tree, offset,FALSE);
1246 proto_tree_add_item( h263_payload_tree, hf_h263_data, tvb, offset, -1, FALSE );
1250 proto_register_h263(void)
1252 static hf_register_info hf[] =
1263 "Indicates the mode of the payload header (MODE A or B/C)", HFILL
1275 "Optional PB-frames mode as defined by H.263 (MODE C)", HFILL
1281 "Start bit position",
1287 "Start bit position specifies number of most significant bits that shall be ignored in the first data byte.", HFILL
1299 "End bit position specifies number of least significant bits that shall be ignored in the last data byte.", HFILL
1309 VALS(srcformat_vals),
1311 "Source format specifies the resolution of the current picture.", HFILL
1315 &hf_h263_picture_coding_type,
1317 "Inter-coded frame",
1318 "h263.picture_coding_type",
1323 "Picture coding type, intra-coded (false) or inter-coded (true)", HFILL
1327 &hf_h263_unrestricted_motion_vector,
1330 "h263.unrestricted_motion_vector",
1335 "Unrestricted Motion Vector option for current picture", HFILL
1339 &hf_h263_syntax_based_arithmetic,
1341 "Syntax-based arithmetic coding",
1342 "h263.syntax_based_arithmetic",
1347 "Syntax-based Arithmetic Coding option for current picture", HFILL
1351 &hf_h263_advanced_prediction,
1353 "Advanced prediction option",
1354 "h263.advanced_prediction",
1359 "Advanced Prediction option for current picture", HFILL
1365 "Differential quantization parameter",
1371 "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
1377 "Temporal Reference for B frames",
1383 "Temporal Reference for the B frame as defined by H.263", HFILL
1389 "Temporal Reference for P frames",
1395 "Temporal Reference for the P frame as defined by H.263", HFILL
1407 "Quantization value for the first MB coded at the starting of the packet.", HFILL
1419 "GOB number in effect at the start of the packet.", HFILL
1425 "Macroblock address",
1431 "The address within the GOB of the first MB in the packet, counting from zero in scan order.", HFILL
1437 "Horizontal motion vector 1",
1443 "Horizontal motion vector predictor for the first MB in this packet ", HFILL
1449 "Vertical motion vector 1",
1455 "Vertical motion vector predictor for the first MB in this packet ", HFILL
1461 "Horizontal motion vector 2",
1467 "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
1473 "Vertical motion vector 2",
1479 "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
1491 "Reserved field that houls contain zeroes", HFILL
1503 "Reserved field that should contain zeroes", HFILL
1515 "The actual H.263 data", HFILL
1527 "The H.263 stream including its Picture, GOB or Macro block start code.", HFILL
1533 "H.263 Picture start Code",
1539 "Picture start Code, PSC", HFILL
1544 "H.263 Group of Block Start Code",
1550 "Group of Block Start Code", HFILL
1556 "H.263 Temporal Reference",
1562 "Temporal Reference, TR", HFILL
1566 &hf_h263_split_screen_indicator,
1568 "H.263 Split screen indicator",
1569 "h263.split_screen_indicator",
1574 "Split screen indicator", HFILL
1578 &hf_h263_document_camera_indicator,
1580 "H.263 Document camera indicator",
1581 "h263.document_camera_indicator",
1586 "Document camera indicator", HFILL
1590 &hf_h263_full_picture_freeze_release,
1592 "H.263 Full Picture Freeze Release",
1593 "h263.split_screen_indicator",
1598 "Full Picture Freeze Release", HFILL
1602 &hf_h263_source_format,
1604 "H.263 Source Format",
1605 "h263.source_format",
1608 VALS(srcformat_vals),
1610 "Source Format", HFILL
1614 &hf_h263_ext_source_format,
1616 "H.263 Source Format",
1617 "h263.ext_source_format",
1620 VALS(ext_srcformat_vals),
1622 "Source Format", HFILL
1628 "H.263 Update Full Extended PTYPE",
1632 VALS(h263_ufep_vals),
1634 "Update Full Extended PTYPE", HFILL
1640 "H.263 Optional Part of PLUSPTYPE",
1646 "Optional Part of PLUSPTYPE", HFILL
1650 &hf_h263_payload_picture_coding_type,
1652 "H.263 Picture Coding Type",
1653 "h263.picture_coding_type",
1656 TFS(&picture_coding_type_flg),
1658 "Picture Coding Typet", HFILL
1662 &hf_h263_opt_unres_motion_vector_mode,
1664 "H.263 Optional Unrestricted Motion Vector mode",
1665 "h263.opt_unres_motion_vector_mode",
1670 "Optional Unrestricted Motion Vector mode", HFILL
1674 &hf_h263_syntax_based_arithmetic_coding_mode,
1676 "H.263 Optional Syntax-based Arithmetic Coding mode",
1677 "h263.syntax_based_arithmetic_coding_mode",
1682 "Optional Syntax-based Arithmetic Coding mode", HFILL
1686 &hf_h263_optional_advanced_prediction_mode,
1688 "H.263 Optional Advanced Prediction mode",
1689 "h263.optional_advanced_prediction_mode",
1694 "Optional Advanced Prediction mode", HFILL
1698 &hf_h263_PB_frames_mode,
1700 "H.263 Optional PB-frames mode",
1701 "h263.PB_frames_mode",
1704 TFS(&PB_frames_mode_flg),
1706 "Optional PB-frames mode", HFILL
1712 "H.263 Group Number",
1718 "Group Number, GN", HFILL
1724 "H.263 Quantizer Information (PQUANT)",
1730 "Quantizer Information (PQUANT)", HFILL
1736 "H.263 Continuous Presence Multipoint and Video Multiplex (CPM)",
1742 "Continuous Presence Multipoint and Video Multiplex (CPM)", HFILL
1748 "H.263 Picture Sub-Bitstream Indicator (PSBI)",
1754 "Picture Sub-Bitstream Indicator (PSBI)", HFILL
1758 &hf_h263_picture_type_code,
1760 "H.263 Picture Type Code",
1764 VALS(picture_type_code_vals),
1766 "Picture Type Code", HFILL
1770 &hf_h263_custom_pcf,
1776 TFS(&custom_pcf_flg),
1784 "H.263 Extra Insertion Information (PEI)",
1790 "Extra Insertion Information (PEI)", HFILL
1796 "H.263 Supplemental Enhancement Information (PSUPP)",
1802 "Supplemental Enhancement Information (PSUPP)", HFILL
1807 static gint *ett[] =
1815 proto_h263 = proto_register_protocol("ITU-T Recommendation H.263 RTP Payload header (RFC2190)",
1817 proto_h263_data = proto_register_protocol("ITU-T Recommendation H.263",
1818 "H.263 data", "h263data");
1819 proto_register_field_array(proto_h263, hf, array_length(hf));
1820 proto_register_subtree_array(ett, array_length(ett));
1821 register_dissector("h263", dissect_h263, proto_h263);
1822 register_dissector("h263data", dissect_h263_data, proto_h263_data);
1826 proto_register_h263P(void)
1828 static hf_register_info hf[] =
1833 "H.263 RFC4629 payload",
1839 "The actual H.263 RFC4629 data", HFILL
1851 "Reserved SHALL be zero", HFILL
1863 "Indicates (GOB/Slice) start or (EOS or EOSBS)", HFILL
1875 "presence of Video Redundancy Coding (VRC) field", HFILL
1887 "Length, in bytes, of the extra picture header", HFILL
1899 "number of bits that shall be ignored in the last byte of the picture header", HFILL
1925 "Monotonically increasing (modulo 16) 4-bit number counting the packet number within each thread", HFILL
1937 "Indicates that the packet content is for a sync frame", HFILL
1941 &hf_h263P_extra_hdr,
1943 "Extra picture header",
1949 "Extra picture header", HFILL
1961 "Picture Start Code(PSC)", HFILL
1967 "H.263 Temporal Reference",
1973 "Temporal Reference, TR", HFILL
1979 static gint *ett[] =
1982 &ett_h263P_extra_hdr,
1988 proto_h263P = proto_register_protocol("ITU-T Recommendation H.263 RTP Payload header (RFC4629)",
1991 proto_register_field_array(proto_h263P, hf, array_length(hf));
1992 proto_register_subtree_array(ett, array_length(ett));
1994 register_dissector("h263P", dissect_h263P, proto_h263P);
1999 proto_reg_handoff_h263(void)
2001 dissector_handle_t h263_handle;
2003 h263_handle = find_dissector("h263");
2004 dissector_add("rtp.pt", PT_H263, h263_handle);
2005 dissector_add("iax2.codec", AST_FORMAT_H263, h263_handle);
2009 proto_reg_handoff_h263P(void)
2011 dissector_handle_t h263P_handle;
2013 h263P_handle = find_dissector("h263P");
2014 dissector_add_string("rtp_dyn_payload_type","H263-1998", h263P_handle);
2015 dissector_add_string("rtp_dyn_payload_type","H263-2000", h263P_handle);