3 * Routines for ITU-T Recommendation H.263 dissection
5 * Copyright 2003 Niklas Ogren <niklas.ogren@7l.se>
6 * Seven Levels Consultants AB
8 * Copyright 2008 Richard van der Hoff, MX Telecom
9 * <richardv@mxtelecom.com>
13 * Wireshark - Network traffic analyzer
14 * By Gerald Combs <gerald@wireshark.org>
15 * Copyright 1998 Gerald Combs
17 * Copied structure from packet-h261.c
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
40 #include <epan/packet.h>
45 #include "packet-h263.h"
47 static int proto_h263_data = -1;
49 /* Fields for the data section */
50 static int hf_h263_psc = -1;
51 static int hf_h263_gbsc = -1;
52 static int hf_h263_TR =-1;
53 static int hf_h263_split_screen_indicator = -1;
54 static int hf_h263_document_camera_indicator = -1;
55 static int hf_h263_full_picture_freeze_release = -1;
56 static int hf_h263_source_format = -1;
57 static int hf_h263_payload_picture_coding_type = -1;
58 static int hf_h263_opt_unres_motion_vector_mode = -1;
59 static int hf_h263_syntax_based_arithmetic_coding_mode = -1;
60 static int hf_h263_optional_advanced_prediction_mode = -1;
61 static int hf_h263_PB_frames_mode = -1;
62 static int hf_h263_data = -1;
63 static int hf_h263_GN = -1;
64 static int hf_h263_UFEP = -1;
65 static int hf_h263_opptype = -1;
66 static int hf_h263_pquant = -1;
67 static int hf_h263_cpm = -1;
68 static int hf_h263_psbi = -1;
69 static int hf_h263_picture_type_code = -1;
70 static int hf_h263_ext_source_format = -1;
71 static int hf_h263_custom_pcf = -1;
72 static int hf_h263_pei = -1;
73 static int hf_h263_psupp = -1;
74 static int hf_h263_trb = -1;
75 static int hf_h263_not_dissected = -1;
77 /* H.263 fields defining a sub tree */
78 static gint ett_h263_payload = -1;
79 static gint ett_h263_optype = -1;
82 /* Source format types */
83 #define H263_SRCFORMAT_FORB 0 /* forbidden */
84 #define H263_SRCFORMAT_SQCIF 1
85 #define H263_SRCFORMAT_QCIF 2
86 #define H263_SRCFORMAT_CIF 3
87 #define H263_SRCFORMAT_4CIF 4
88 #define H263_SRCFORMAT_16CIF 5
89 #define H263_PLUSPTYPE 7
91 const value_string h263_srcformat_vals[] =
93 { H263_SRCFORMAT_FORB, "forbidden" },
94 { H263_SRCFORMAT_SQCIF, "sub-QCIF 128x96" },
95 { H263_SRCFORMAT_QCIF, "QCIF 176x144" },
96 { H263_SRCFORMAT_CIF, "CIF 352x288" },
97 { H263_SRCFORMAT_4CIF, "4CIF 704x576" },
98 { H263_SRCFORMAT_16CIF, "16CIF 1408x1152" },
100 { H263_PLUSPTYPE, "extended PTYPE" },
105 * If UFEP is "001", then the following bits are present in PLUSPTYPE:
106 * Bits 1-3 Source Format, "000" reserved, "001" sub-QCIF, "010" QCIF, "011" CIF,
107 * "100" 4CIF, "101" 16CIF, "110" custom source format, "111" reserved;
109 static const value_string ext_srcformat_vals[] =
112 { H263_SRCFORMAT_SQCIF, "sub-QCIF 128x96" },
113 { H263_SRCFORMAT_QCIF, "QCIF 176x144" },
114 { H263_SRCFORMAT_CIF, "CIF 352x288" },
115 { H263_SRCFORMAT_4CIF, "4CIF 704x576" },
116 { H263_SRCFORMAT_16CIF, "16CIF 1408x1152" },
117 { 6, "Custom source format",},
122 static const value_string h263_ufep_vals[] =
124 { 0, "Only MPPTYPE included" },
125 { 1, "All extended PTYPE fields are included" },
129 static const true_false_string on_off_flg = {
133 static const true_false_string picture_coding_type_flg = {
138 static const value_string picture_coding_type_vals[] =
145 static const true_false_string PB_frames_mode_flg = {
147 "Normal I- or P-picture"
150 static const true_false_string cpm_flg = {
155 static const true_false_string custom_pcf_flg = {
160 /* Bits 1-3 Picture Type Code:*/
161 static const value_string picture_type_code_vals[] =
163 { 0, "I-picture (INTRA)" },
164 { 1, "P-picture (INTER)" },
165 { 2, "Improved PB-frame (see Annex M)" },
166 { 3, "B-picture (see Annex O)" },
167 { 4, "EI-picture (see Annex O)" },
168 { 5, "EP-picture (see Annex O)" },
176 * 5.3 Macroblock layer
178 dissect_h263_macroblock_layer( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
186 dissect_h263_group_of_blocks_layer( tvbuff_t *tvb, proto_tree *tree, gint offset, gboolean is_rfc4626)
189 unsigned int offset_in_bits = offset << 3;
193 proto_tree_add_bits_item(tree, hf_h263_gbsc, tvb, offset_in_bits, 1, FALSE);
196 /* Group of Block Start Code (GBSC) (17 bits)
197 * A word of 17 bits. Its value is 0000 0000 0000 0000 1.
199 proto_tree_add_bits_item(tree, hf_h263_gbsc, tvb, offset_in_bits, 17, FALSE);
200 offset_in_bits = offset_in_bits +17;
203 * Group Number (GN) (5 bits)
205 proto_tree_add_bits_item(tree, hf_h263_GN, tvb, offset_in_bits, 5, FALSE);
206 offset_in_bits = offset_in_bits +5;
207 /* 5.2.4 GOB Sub-Bitstream Indicator (GSBI) (2 bits)
208 * A fixed length codeword of 2 bits that is only present if CPM is "1" in the picture header.
211 * 5.2.5 GOB Frame ID (GFID) (2 bits)
214 * 5.2.6 Quantizer Information (GQUANT) (5 bits)
217 * 5.3 Macroblock layer
220 return offset_in_bits>>3;
225 * Length is used for the "Extra header" otherwise set to -1.
228 dissect_h263_picture_layer( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset, gint length _U_, gboolean is_rfc4626)
230 proto_tree *h263_opptype_tree = NULL;
231 proto_item *opptype_item = NULL;
232 unsigned int offset_in_bits = offset << 3;
233 unsigned int saved_bit_offset;
234 guint64 source_format;
236 guint64 picture_coding_type;
237 guint64 PB_frames_mode = 0;
238 guint64 custom_pcf = 0;
239 guint64 picture_type_code =0;
245 proto_tree_add_bits_item(tree, hf_h263_psc, tvb, offset_in_bits, 6, FALSE);
246 offset_in_bits = offset_in_bits +6;
249 /* Check for PSC, PSC is a word of 22 bits.
250 * Its value is 0000 0000 0000 0000' 1000 00xx xxxx xxxx.
252 proto_tree_add_bits_item(tree, hf_h263_psc, tvb, offset_in_bits, 22, FALSE);
253 offset_in_bits = offset_in_bits +22;
256 proto_tree_add_bits_item(tree, hf_h263_TR, tvb, offset_in_bits, 8, FALSE);
257 offset_in_bits = offset_in_bits +8;
259 * Bit 1: Always "1", in order to avoid start code emulation.
260 * Bit 2: Always "0", for distinction with Recommendation H.261.
262 offset_in_bits = offset_in_bits +2;
263 /* Bit 3: Split screen indicator, "0" off, "1" on. */
264 proto_tree_add_bits_item( tree, hf_h263_split_screen_indicator, tvb, offset_in_bits, 1, FALSE);
266 /* Bit 4: Document camera indicator, */
267 proto_tree_add_bits_item( tree, hf_h263_document_camera_indicator, tvb, offset_in_bits, 1, FALSE);
269 /* Bit 5: Full Picture Freeze Release, "0" off, "1" on. */
270 proto_tree_add_bits_item( tree, hf_h263_full_picture_freeze_release, tvb, offset_in_bits, 1, FALSE);
272 /* Bits 6-8: Source Format, "000" forbidden, "001" sub-QCIF, "010" QCIF, "011" CIF,
273 * "100" 4CIF, "101" 16CIF, "110" reserved, "111" extended PTYPE.
275 proto_tree_add_bits_ret_val( tree, hf_h263_source_format, tvb, offset_in_bits, 3 ,&source_format, FALSE);
276 offset_in_bits = offset_in_bits +3;
277 if (source_format != H263_PLUSPTYPE){
278 /* Not extended PTYPE */
279 /* Bit 9: Picture Coding Type, "0" INTRA (I-picture), "1" INTER (P-picture). */
280 proto_tree_add_bits_ret_val( tree, hf_h263_payload_picture_coding_type, tvb, offset_in_bits, 1, &picture_coding_type, FALSE);
281 if ( check_col( pinfo->cinfo, COL_INFO) )
282 col_append_str(pinfo->cinfo, COL_INFO, val_to_str((guint32)picture_coding_type, picture_coding_type_vals, "Unknown (%u)"));
284 /* Bit 10: Optional Unrestricted Motion Vector mode (see Annex D), "0" off, "1" on. */
285 proto_tree_add_bits_item( tree, hf_h263_opt_unres_motion_vector_mode, tvb, offset_in_bits, 1, FALSE);
287 /* Bit 11: Optional Syntax-based Arithmetic Coding mode (see Annex E), "0" off, "1" on.*/
288 proto_tree_add_bits_item( tree, hf_h263_syntax_based_arithmetic_coding_mode, tvb, offset_in_bits, 1, FALSE);
290 /* Bit 12: Optional Advanced Prediction mode (see Annex F), "0" off, "1" on.*/
291 proto_tree_add_bits_item( tree, hf_h263_optional_advanced_prediction_mode, tvb, offset_in_bits, 1, FALSE);
293 /* Bit 13: Optional PB-frames mode (see Annex G), "0" normal I- or P-picture, "1" PB-frame.*/
294 proto_tree_add_bits_ret_val( tree, hf_h263_PB_frames_mode, tvb, offset_in_bits, 1, &PB_frames_mode, FALSE);
298 * Update Full Extended PTYPE (UFEP) (3 bits)
300 /* .... ..xx x... .... */
301 proto_tree_add_bits_ret_val( tree, hf_h263_UFEP, tvb, offset_in_bits, 3, &ufep, FALSE);
302 offset_in_bits = offset_in_bits +3;
304 /* The Optional Part of PLUSPTYPE (OPPTYPE) (18 bits)
306 /* .xxx xxxx xxxx xxxx xxx. .... */
307 opptype_item = proto_tree_add_bits_item( tree, hf_h263_opptype, tvb, offset_in_bits, 18, FALSE);
308 h263_opptype_tree = proto_item_add_subtree( opptype_item, ett_h263_optype );
310 * If UFEP is "001", then the following bits are present in PLUSPTYPE:
311 * Bits 1-3 Source Format, "000" reserved, "001" sub-QCIF, "010" QCIF, "011" CIF,
312 * "100" 4CIF, "101" 16CIF, "110" custom source format, "111" reserved;
314 proto_tree_add_bits_item( h263_opptype_tree, hf_h263_ext_source_format, tvb, offset_in_bits, 3, FALSE);
318 * Bit 4 Optional Custom PCF, "0" CIF PCF, "1" custom PCF;
320 proto_tree_add_bits_ret_val( h263_opptype_tree, hf_h263_custom_pcf, tvb, offset_in_bits, 1, &custom_pcf, FALSE);
322 saved_bit_offset=offset_in_bits;
324 * Bit 5 Optional Unrestricted Motion Vector (UMV) mode (see Annex D), "0" off, "1" on;
328 * Bit 6 Optional Syntax-based Arithmetic Coding (SAC) mode (see Annex E), "0" off, "1" on;
332 * Bit 7 Optional Advanced Prediction (AP) mode (see Annex F), "0" off, "1" on;
336 * Bit 8 Optional Advanced INTRA Coding (AIC) mode (see Annex I), "0" off, "1" on;
340 * Bit 9 Optional Deblocking Filter (DF) mode (see Annex J), "0" off, "1" on;
344 * Bit 10 Optional Slice Structured (SS) mode (see Annex K), "0" off, "1" on;
348 * Bit 11 Optional Reference Picture Selection (RPS) mode (see Annex N), "0" off, "1" on;
352 * Bit 12 Optional Independent Segment Decoding (ISD) mode (see Annex R), "0" off,"1" on;
356 * Bit 13 Optional Alternative INTER VLC (AIV) mode (see Annex S), "0" off, "1" on;
360 * Bit 14 Optional Modified Quantization (MQ) mode (see Annex T), "0" off, "1" on;
364 * Bit 15 Equal to "1" to prevent start code emulation;
368 * Bit 16 Reserved, shall be equal to "0";
372 * Bit 17 Reserved, shall be equal to "0";
376 * Bit 18 Reserved, shall be equal to "0".
379 proto_tree_add_bits_item( h263_opptype_tree, hf_h263_not_dissected, tvb, saved_bit_offset, offset_in_bits-saved_bit_offset, FALSE);
383 * 5.1.4.3 The mandatory part of PLUSPTYPE when PLUSPTYPE present (MPPTYPE) (9 bits)
384 * Regardless of the value of UFEP, the following 9 bits are also present in PLUSPTYPE:
385 * - Bits 1-3 Picture Type Code:
386 * "000" I-picture (INTRA);
387 * "001" P-picture (INTER);
388 * "010" Improved PB-frame (see Annex M);
389 * "011" B-picture (see Annex O);
390 * "100" EI-picture (see Annex O);
391 * "101" EP-picture (see Annex O);
395 proto_tree_add_bits_ret_val( tree, hf_h263_picture_type_code, tvb, offset_in_bits, 3, &picture_type_code, FALSE);
397 saved_bit_offset=offset_in_bits;
399 * Bit 4 Optional Reference Picture Resampling (RPR) mode (see Annex P), "0" off, "1" on;
403 * Bit 5 Optional Reduced-Resolution Update (RRU) mode (see Annex Q), "0" off, "1" on;
407 * Bit 6 Rounding Type (RTYPE) (see 6.1.2);
411 * Bit 7 Reserved, shall be equal to "0";
415 * Bit 8 Reserved, shall be equal to "0";
419 * Bit 9 Equal to "1" to prevent start code emulation.
422 proto_tree_add_bits_item( tree, hf_h263_not_dissected, tvb, saved_bit_offset, offset_in_bits-saved_bit_offset, FALSE);
423 /* The picture header location of CPM (1 bit) and PSBI (2 bits)
424 * the picture header depends on whether or not PLUSPTYPE is present
425 * (see 5.1.20 and 5.1.21). If PLUSPTYPE is present, then CPM follows
426 * immediately after PLUSPTYPE in the picture header.
428 proto_tree_add_bits_ret_val( tree, hf_h263_cpm, tvb, offset_in_bits, 1, &cpm, FALSE);
430 /* 5.1.21 Picture Sub-Bitstream Indicator (PSBI) (2 bits)
431 * only present if Continuous Presence Multipoint and Video
432 * Multiplex mode is indicated by CPM.
435 proto_tree_add_bits_item( tree, hf_h263_psbi, tvb, offset_in_bits, 2, FALSE);
438 return offset_in_bits>>3;
439 /* TODO Add the rest of the fields */
440 /* 5.1.5 Custom Picture Format (CPFMT) (23 bits)
441 * present only if the use of a custom picture format is
442 * signalled in PLUSPTYPE and UFEP is '001'. When present, CPFMT consists of:
443 * Bits 1-4 Pixel Aspect Ratio Code: A 4-bit index to the PAR value in Table 5. For
444 * extended PAR, the exact pixel aspect ratio shall be specified in EPAR
446 * Bits 5-13 Picture Width Indication: Range [0, ... , 511]; Number of pixels per
447 * line = (PWI + 1) * 4;
448 * Bit 14 Equal to "1" to prevent start code emulation;
449 * Bits 15-23 Picture Height Indication: Range [1, ... , 288]; Number of lines = PHI * 4.
451 /* 5.1.6 Extended Pixel Aspect Ratio (EPAR) (16 bits)
452 * A fixed length codeword of 16 bits that is present only if CPFMT is present and extended PAR is
453 * indicated therein. When present, EPAR consists of:
454 * Bits 1-8 PAR Width: "0" is forbidden. The natural binary representation of the PAR
456 * Bits 9-16 PAR Height: "0" is forbidden. The natural binary representation of the PAR
459 /* 5.1.7 Custom Picture Clock Frequency Code (CPCFC) (8 bits)
460 * A fixed length codeword of 8 bits that is present only if PLUSPTYPE is present and UFEP is 001
461 * and a custom picture clock frequency is signalled in PLUSPTYPE. When present, CPCFC consists of:
462 * Bit 1 Clock Conversion Code: "0" indicates a clock conversion factor of 1000 and
463 * "1" indicates 1001;
464 * Bits 2-8 Clock Divisor: "0" is forbidden. The natural binary representation of the value
465 * of the clock divisor.
467 /* 5.1.8 Extended Temporal Reference (ETR) (2 bits)
468 * A fixed length codeword of 2 bits which is present only if a custom picture clock frequency is in
469 * use (regardless of the value of UFEP). It is the two MSBs of the 10-bit number defined in 5.1.2.
471 /* 5.1.9 Unlimited Unrestricted Motion Vectors Indicator (UUI) (Variable length)
472 * A variable length codeword of 1 or 2 bits that is present only if the optional Unrestricted Motion
473 * Vector mode is indicated in PLUSPTYPE and UFEP is 001. When UUI is present it indicates the
474 * effective limitation of the range of the motion vectors being used.
475 * UUI = "1" The motion vector range is limited according to Tables D.1 and D.2.
476 * UUI = "01" The motion vector range is not limited except by the picture size.
479 * 5.1.10 Slice Structured Submode bits (SSS) (2 bits)
480 * A fixed length codeword of 2 bits which is present only if the optional Slice Structured mode
481 * (see Annex K) is indicated in PLUSPTYPE and UFEP is 001. If the Slice Structured mode is in use
482 * but UFEP is not 001, the last values sent for SSS shall remain in effect.
483 * - Bit 1 Rectangular Slices, "0" indicates free-running slices, "1" indicates rectangular
485 * - Bit 2 Arbitrary Slice Ordering, "0" indicates sequential order, "1" indicates arbitrary
487 * 5.1.11 Enhancement Layer Number (ELNUM) (4 bits)
488 * A fixed length codeword of 4 bits which is present only if the optional Temporal, SNR, and Spatial
489 * Scalability mode is in use (regardless of the value of UFEP). The particular enhancement layer is
490 * identified by an enhancement layer number, ELNUM. Picture correspondence between layers is
491 * achieved via the temporal reference. Picture size is either indicated within each enhancement layer
492 * using the existing source format fields or is inferred by the relationship to the reference layer. The
493 * first enhancement layer above the base layer is designated as Enhancement Layer Number 2, and
494 * the base layer has number 1.
495 * 5.1.12 Reference Layer Number (RLNUM) (4 bits)
496 * A fixed length codeword of 4 bits which is present only if the optional Temporal, SNR, and Spatial
497 * Scalability mode is in use (see Annex O) and UFEP is 001. The layer number for the pictures used
498 * as reference anchors is identified by a Reference Layer Number (RLNUM). Time correspondence
499 * between layers is achieved via the temporal reference.
500 * Note that for B-pictures in an enhancement layer having temporally surrounding EI- or EP-pictures
501 * which are present in the same enhancement layer, RLNUM shall be equal to ELNUM
503 * 5.1.13 Reference Picture Selection Mode Flags (RPSMF) (3 bits)
504 * A fixed length codeword of 3 bits that is present only if the Reference Picture Selection mode is in
505 * use and UFEP is 001. When present, RPSMF indicates which type of back-channel messages are
506 * needed by the encoder. If the Reference Picture Selection mode is in use but RPSMF is not present,
507 * the last value of RPSMF that was sent shall remain in effect.
508 * - 100: neither ACK nor NACK signals needed;
509 * - 101: need ACK signals to be returned;
510 * - 110: need NACK signals to be returned;
511 * - 111: need both ACK and NACK signals to be returned;
512 * - 000-011: Reserved.
513 * 5.1.14 Temporal Reference for Prediction Indication (TRPI) (1 bit)
514 * A fixed length codeword of 1 bit that is present only if the optional Reference Picture Selection
515 * mode is in use (regardless of the value of UFEP). When present, TRPI indicates the presence of the
516 * following TRP field:
517 * - 0: TRP field is not present;
518 * - 1: TRP field is present.
519 * TRPI shall be 0 whenever the picture header indicates an I- or EI-picture.
520 * 5.1.15 Temporal Reference for Prediction (TRP) (10 bits)
521 * When present (as indicated in TRPI), TRP indicates the Temporal Reference which is used for
522 * prediction of the encoding, except for in the case of B-pictures. For B-pictures, the picture having
523 * the temporal reference TRP is used for the prediction in the forward direction. (Prediction in the
524 * reverse-temporal direction always uses the immediately temporally subsequent picture.) TRP is a
525 * ten-bit number. If a custom picture clock frequency was not in use for the reference picture, the two
526 * MSBs of TRP are zero and the LSBs contain the eight-bit TR found in the picture header of the
527 * reference picture. If a custom picture clock frequency was in use for the reference picture, TRP is a
528 * ten-bit number consisting of the concatenation of ETR and TR from the reference picture header.
529 * When TRP is not present, the most recent temporally previous anchor picture shall be used for
530 * prediction, as when not in the Reference Picture Selection mode. TRP is valid until the next PSC,
532 * 5.1.16 Back-Channel message Indication (BCI) (Variable length)
533 * A variable length field of one or two bits that is present only if the optional Reference Picture
534 * Selection mode is in use. When set to "1", this signals the presence of the following optional video
535 * Back-Channel Message (BCM) field. "01" indicates the absence or the end of the video backchannel
536 * message field. Combinations of BCM and BCI may not be present, and may be repeated
537 * when present. BCI shall be set to "01" if the videomux submode of the optional Reference Picture
538 * Selection mode is not in use.
539 * 5.1.17 Back-Channel Message (BCM) (Variable length)
540 * The Back-Channel message with syntax as specified in N.4.2, which is present only if the preceding
541 * BCI field is present and is set to "1".
542 * 5.1.18 Reference Picture Resampling Parameters (RPRP) (Variable length)
543 * A variable length field that is present only if the optional Reference Picture Resampling mode bit is
544 * set in PLUSPTYPE. This field carries the parameters of the Reference Picture Resampling mode
545 * (see Annex P). Note that the Reference Picture Resampling mode can also be invoked implicitly by
546 * the occurrence of a picture header for an INTER coded picture having a picture size which differs
547 * from that of the previous encoded picture, in which case the RPRP field is not present and the
548 * Reference Picture Resampling mode bit is not set.
551 /* 5.1.19 Quantizer Information (PQUANT) (5 bits) */
552 proto_tree_add_bits_item( tree, hf_h263_pquant, tvb, offset_in_bits, 5, FALSE);
553 offset_in_bits = offset_in_bits +5;
554 if (source_format != H263_PLUSPTYPE){
555 proto_tree_add_bits_ret_val( tree, hf_h263_cpm, tvb, offset_in_bits, 1, &cpm, FALSE);
557 /* 5.1.21 Picture Sub-Bitstream Indicator (PSBI) (2 bits)
558 * only present if Continuous Presence Multipoint and Video
559 * Multiplex mode is indicated by CPM.
562 proto_tree_add_bits_item( tree, hf_h263_psbi, tvb, offset_in_bits, 2, FALSE);
563 offset_in_bits = offset_in_bits +2;
566 /* 5.1.22 Temporal Reference for B-pictures in PB-frames (TRB) (3/5 bits)
567 * TRB is present if PTYPE or PLUSPTYPE indicates "PB-frame" or "Improved PB-frame"
568 * It is 3 bits long for standard CIF picture clock frequency and is
569 * extended to 5 bits when a custom picture clock frequency is in use.
571 if((PB_frames_mode == 1)||(picture_type_code == 2 )){
573 proto_tree_add_bits_item( tree, hf_h263_trb, tvb, offset_in_bits, 3, FALSE);
574 offset_in_bits = offset_in_bits +3;
576 proto_tree_add_bits_item( tree, hf_h263_trb, tvb, offset_in_bits, 5, FALSE);
577 offset_in_bits = offset_in_bits +5;
580 /* 5.1.23 Quantization information for B-pictures in PB-frames (DBQUANT) (2 bits)
581 * DBQUANT is present if PTYPE or PLUSPTYPE indicates "PB-frame" or "Improved PB-frame"
583 if((PB_frames_mode == 1)||(picture_type_code == 2 )){
584 offset_in_bits = offset_in_bits +2;
586 /* 5.1.24 Extra Insertion Information (PEI) (1 bit)
587 * A bit which when set to "1" signals the presence of the following optional data field.
589 proto_tree_add_bits_ret_val( tree, hf_h263_pei, tvb, offset_in_bits, 1, &pei, FALSE);
593 /*5.1.25 Supplemental Enhancement Information (PSUPP) (0/8/16 ... bits)
594 * If PEI is set to "1", then 9 bits follow consisting of 8 bits of data (PSUPP) and then another PEI bit
595 * to indicate if a further 9 bits follow and so on. Encoders shall use PSUPP as specified in Annex L.
597 proto_tree_add_bits_item( tree, hf_h263_psupp, tvb, offset_in_bits, 8, FALSE);
599 proto_tree_add_bits_ret_val( tree, hf_h263_pei, tvb, offset_in_bits, 1, &pei, FALSE);
602 /* For the first GOB in each picture (with number 0), no GOB header shall be transmitted.
603 * For all other GOBs, the GOB header may be empty, depending on the encoder strategy.
607 * 5.3 Macroblock layer
608 * dissect_h263_macroblock_layer( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
611 return offset_in_bits>>3;
616 5.1.1 Picture Start Code (PSC) (22 bits)
617 PSC is a word of 22 bits. Its value is 0000 0000 0000 0000 1 00000. All picture start codes shall be
621 End Of Sequence (EOS) (22 bits)
622 A codeword of 22 bits. Its value is 0000 0000 0000 0000 1 11111.
625 Group of Block Start Code (GBSC) (17 bits)
626 A word of 17 bits. Its value is 0000 0000 0000 0000 1.
629 End Of Sub-Bitstream code (EOSBS) (23 bits)
630 The EOSBS code is a codeword of 23 bits. Its value is 0000 0000 0000 0000 1 11110 0.
633 Slice Start Code (SSC) (17 bits)
634 A word of 17 bits. Its value is 0000 0000 0000 0000 1.
637 static void dissect_h263_data( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
640 proto_item *h263_payload_item = NULL;
641 proto_tree *h263_payload_tree = NULL;
645 if ( check_col( pinfo->cinfo, COL_INFO) ) {
646 col_append_str( pinfo->cinfo, COL_INFO, "H263 payload ");
650 h263_payload_item = proto_tree_add_item( tree, proto_h263_data, tvb, offset, -1, FALSE );
651 h263_payload_tree = proto_item_add_subtree( h263_payload_item, ett_h263_payload );
654 /* Check for PSC, PSC is a word of 22 bits. Its value is 0000 0000 0000 0000' 1000 00xx xxxx xxxx. */
655 data = tvb_get_ntohl(tvb, offset);
657 if (( data & 0xffff8000) == 0x00008000 ) {
660 * Startc code holds bit 17 -23 of the codeword
662 startcode = tvb_get_guint8(tvb,offset+2)&0xfe;
663 if (startcode & 0x80){
666 /* End Of Sub-Bitstream code (EOSBS)
672 /* Picture Start Code (PSC)
675 if(check_col( pinfo->cinfo, COL_INFO))
676 col_append_str( pinfo->cinfo, COL_INFO, "(PSC) ");
677 offset = dissect_h263_picture_layer( tvb, pinfo, h263_payload_tree, offset, -1, FALSE);
681 /* End Of Sequence (EOS)
685 /* Group of Block Start Code (GBSC) or
686 * Slice Start Code (SSC)
688 if ( check_col( pinfo->cinfo, COL_INFO) )
689 col_append_str( pinfo->cinfo, COL_INFO, "(GBSC) ");
690 offset = dissect_h263_group_of_blocks_layer( tvb, h263_payload_tree, offset,FALSE);
698 proto_tree_add_item( h263_payload_tree, hf_h263_data, tvb, offset, -1, FALSE );
702 proto_register_h263_data(void)
704 static hf_register_info hf[] =
709 "H.263 Picture start Code",
715 "Picture start Code, PSC", HFILL
720 "H.263 Group of Block Start Code",
726 "Group of Block Start Code", HFILL
732 "H.263 Temporal Reference",
738 "Temporal Reference, TR", HFILL
744 "Temporal Reference for B frames",
750 "Temporal Reference for the B frame as defined by H.263", HFILL
754 &hf_h263_split_screen_indicator,
756 "H.263 Split screen indicator",
757 "h263.split_screen_indicator",
762 "Split screen indicator", HFILL
766 &hf_h263_document_camera_indicator,
768 "H.263 Document camera indicator",
769 "h263.document_camera_indicator",
774 "Document camera indicator", HFILL
778 &hf_h263_full_picture_freeze_release,
780 "H.263 Full Picture Freeze Release",
781 "h263.split_screen_indicator",
786 "Full Picture Freeze Release", HFILL
790 &hf_h263_source_format,
792 "H.263 Source Format",
793 "h263.source_format",
796 VALS(h263_srcformat_vals),
798 "Source Format", HFILL
802 &hf_h263_ext_source_format,
804 "H.263 Source Format",
805 "h263.ext_source_format",
808 VALS(ext_srcformat_vals),
810 "Source Format", HFILL
816 "H.263 Update Full Extended PTYPE",
820 VALS(h263_ufep_vals),
822 "Update Full Extended PTYPE", HFILL
828 "H.263 Optional Part of PLUSPTYPE",
834 "Optional Part of PLUSPTYPE", HFILL
838 &hf_h263_payload_picture_coding_type,
840 "H.263 Picture Coding Type",
841 "h263.picture_coding_type",
844 TFS(&picture_coding_type_flg),
846 "Picture Coding Type", HFILL
850 &hf_h263_opt_unres_motion_vector_mode,
852 "H.263 Optional Unrestricted Motion Vector mode",
853 "h263.opt_unres_motion_vector_mode",
858 "Optional Unrestricted Motion Vector mode", HFILL
862 &hf_h263_syntax_based_arithmetic_coding_mode,
864 "H.263 Optional Syntax-based Arithmetic Coding mode",
865 "h263.syntax_based_arithmetic_coding_mode",
870 "Optional Syntax-based Arithmetic Coding mode", HFILL
874 &hf_h263_optional_advanced_prediction_mode,
876 "H.263 Optional Advanced Prediction mode",
877 "h263.optional_advanced_prediction_mode",
882 "Optional Advanced Prediction mode", HFILL
886 &hf_h263_PB_frames_mode,
888 "H.263 Optional PB-frames mode",
889 "h263.PB_frames_mode",
892 TFS(&PB_frames_mode_flg),
894 "Optional PB-frames mode", HFILL
900 "H.263 Group Number",
906 "Group Number, GN", HFILL
912 "H.263 Quantizer Information (PQUANT)",
918 "Quantizer Information (PQUANT)", HFILL
924 "H.263 Continuous Presence Multipoint and Video Multiplex (CPM)",
930 "Continuous Presence Multipoint and Video Multiplex (CPM)", HFILL
936 "H.263 Picture Sub-Bitstream Indicator (PSBI)",
942 "Picture Sub-Bitstream Indicator (PSBI)", HFILL
946 &hf_h263_picture_type_code,
948 "H.263 Picture Type Code",
952 VALS(picture_type_code_vals),
954 "Picture Type Code", HFILL
964 TFS(&custom_pcf_flg),
972 "H.263 Extra Insertion Information (PEI)",
978 "Extra Insertion Information (PEI)", HFILL
984 "H.263 Supplemental Enhancement Information (PSUPP)",
990 "Supplemental Enhancement Information (PSUPP)", HFILL
1002 "The H.263 stream including its Picture, GOB or Macro block start code.", HFILL
1006 &hf_h263_not_dissected,
1008 "H.263 Bits currently not dissected",
1014 "These bits are not dissected(yet), displayed for clarity", HFILL
1019 static gint *ett[] =
1025 proto_register_subtree_array(ett, array_length(ett));
1027 proto_h263_data = proto_register_protocol("ITU-T Recommendation H.263",
1029 proto_register_field_array(proto_h263_data, hf, array_length(hf));
1030 register_dissector("h263data", dissect_h263_data, proto_h263_data);