3 * Routines for RFC-4629-encapsulated 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>
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * SPDX-License-Identifier: GPL-2.0-or-later
20 #include <epan/packet.h>
22 #include <epan/prefs.h>
24 #include "packet-h263.h"
26 void proto_reg_handoff_h263P(void);
27 void proto_register_h263P(void);
29 static int proto_h263P
;
31 /* H.263 RFC 4629 fields */
32 static int hf_h263P_payload
;
33 static int hf_h263P_rr
;
34 static int hf_h263P_pbit
;
35 static int hf_h263P_vbit
;
36 static int hf_h263P_plen
;
37 static int hf_h263P_pebit
;
38 static int hf_h263P_tid
;
39 static int hf_h263P_trun
;
40 static int hf_h263P_s
;
41 static int hf_h263P_extra_hdr
;
42 /* static int hf_h263P_PSC; */
43 /* static int hf_h263P_TR; */
46 /* H.263-1998 fields defining a sub tree */
48 static int ett_h263P_extra_hdr
;
49 static int ett_h263P_payload
;
50 static int ett_h263P_data
;
52 static dissector_handle_t h263P_handle
;
56 dissect_h263P( tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
58 proto_item
*ti
= NULL
;
59 proto_item
*data_item
= NULL
;
60 proto_item
*extra_hdr_item
= NULL
;
61 proto_tree
*h263P_tree
= NULL
;
62 proto_tree
*h263P_extr_hdr_tree
= NULL
;
63 proto_tree
*h263P_data_tree
= NULL
;
64 unsigned int offset
= 0;
65 uint16_t data16
, plen
;
72 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "H.263 RFC4629 ");
75 ti
= proto_tree_add_item( tree
, proto_h263P
, tvb
, offset
, -1, ENC_NA
);
76 h263P_tree
= proto_item_add_subtree( ti
, ett_h263P
);
78 data16
= tvb_get_ntohs(tvb
,offset
);
79 proto_tree_add_item( h263P_tree
, hf_h263P_rr
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
80 proto_tree_add_item( h263P_tree
, hf_h263P_pbit
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
81 proto_tree_add_item( h263P_tree
, hf_h263P_vbit
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
82 proto_tree_add_item( h263P_tree
, hf_h263P_plen
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
83 proto_tree_add_item( h263P_tree
, hf_h263P_pebit
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
88 * Indicates the presence of an 8-bit field containing information
89 * for Video Redundancy Coding (VRC), which follows immediately after
90 * the initial 16 bits of the payload header, if present. For syntax
91 * and semantics of that 8-bit VRC field, see Section 5.2.
94 if ((data16
&0x0200)==0x0200){
96 * The format of the VRC header extension is as follows:
105 * Thread ID. Up to 7 threads are allowed. Each frame of H.263+ VRC
106 * data will use as reference information only sync frames or frames
107 * within the same thread. By convention, thread 0 is expected to be
108 * the "canonical" thread, which is the thread from which the sync frame
109 * should ideally be used. In the case of corruption or loss of the
110 * thread 0 representation, a representation of the sync frame with a
111 * higher thread number can be used by the decoder. Lower thread
112 * numbers are expected to contain representations of the sync frames
113 * equal to or better than higher thread numbers in the absence of data
114 * corruption or loss. See [Vredun] for a detailed discussion of VRC.
118 * Monotonically increasing (modulo 16) 4-bit number counting the packet
119 * number within each thread.
123 * A bit that indicates that the packet content is for a sync frame.
126 proto_tree_add_item( h263P_tree
, hf_h263P_tid
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
127 proto_tree_add_item( h263P_tree
, hf_h263P_trun
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
128 proto_tree_add_item( h263P_tree
, hf_h263P_s
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
132 /* Length, in bytes, of the extra picture header. */
133 plen
= (data16
& 0x01f8) >> 3;
135 extra_hdr_item
= proto_tree_add_item( h263P_tree
, hf_h263P_extra_hdr
, tvb
, offset
, plen
, ENC_NA
);
136 h263P_extr_hdr_tree
= proto_item_add_subtree( extra_hdr_item
, ett_h263P_extra_hdr
);
137 dissect_h263_picture_layer( tvb
, pinfo
, h263P_extr_hdr_tree
, offset
, plen
, true);
140 if ((data16
&0x0400)!=0){
142 data_item
= proto_tree_add_item( h263P_tree
, hf_h263P_payload
, tvb
, offset
, -1, ENC_NA
);
143 h263P_data_tree
= proto_item_add_subtree( data_item
, ett_h263P_data
);
144 /* Startc code holds bit 17 -23 of the codeword */
145 startcode
= tvb_get_uint8(tvb
,offset
)&0xfe;
146 if (startcode
& 0x80){
147 /* All picture, slice, and EOSBS start codes
148 * shall be byte aligned, and GOB and EOS start codes may be byte aligned.
152 /* End Of Sub-Bitstream code (EOSBS)
153 * EOSBS codes shall be byte aligned
159 /* Picture Start Code (PSC)
162 col_append_str( pinfo
->cinfo
, COL_INFO
, "(PSC) ");
163 dissect_h263_picture_layer( tvb
, pinfo
, h263P_data_tree
, offset
, -1, true);
167 /* End Of Sequence (EOS)
171 /* Group of Block Start Code (GBSC) or
172 * Slice Start Code (SSC)
174 col_append_str( pinfo
->cinfo
, COL_INFO
, "(GBSC) ");
175 dissect_h263_group_of_blocks_layer( tvb
, h263P_data_tree
, offset
,true);
181 return tvb_captured_length(tvb
);
183 proto_tree_add_item( h263P_tree
, hf_h263P_payload
, tvb
, offset
, -1, ENC_NA
);
185 return tvb_captured_length(tvb
);
189 proto_reg_handoff_h263P(void)
191 dissector_add_string("rtp_dyn_payload_type","H263-1998", h263P_handle
);
192 dissector_add_string("rtp_dyn_payload_type","H263-2000", h263P_handle
);
193 dissector_add_uint_range_with_preference("rtp.pt", "", h263P_handle
);
198 proto_register_h263P(void)
200 module_t
*h263P_module
;
202 static hf_register_info hf
[] =
207 "H.263 RFC4629 payload",
213 "The actual H.263 RFC4629 data", HFILL
225 "Reserved SHALL be zero", HFILL
237 "Indicates (GOB/Slice) start or (EOS or EOSBS)", HFILL
249 "presence of Video Redundancy Coding (VRC) field", HFILL
261 "Length, in bytes, of the extra picture header", HFILL
273 "number of bits that shall be ignored in the last byte of the picture header", HFILL
299 "Monotonically increasing (modulo 16) 4-bit number counting the packet number within each thread", HFILL
311 "Indicates that the packet content is for a sync frame", HFILL
317 "Extra picture header",
336 "Picture Start Code(PSC)", HFILL
344 "H.263 Temporal Reference",
350 "Temporal Reference, TR", HFILL
360 &ett_h263P_extra_hdr
,
366 proto_h263P
= proto_register_protocol("ITU-T Recommendation H.263 RTP Payload header (RFC4629)",
369 proto_register_field_array(proto_h263P
, hf
, array_length(hf
));
370 proto_register_subtree_array(ett
, array_length(ett
));
372 h263P_module
= prefs_register_protocol(proto_h263P
, NULL
);
374 prefs_register_obsolete_preference(h263P_module
, "dynamic.payload.type");
376 h263P_handle
= register_dissector("h263P", dissect_h263P
, proto_h263P
);
380 * Editor modelines - https://www.wireshark.org/tools/modelines.html
385 * indent-tabs-mode: nil
388 * vi: set shiftwidth=4 tabstop=8 expandtab:
389 * :indentSize=4:tabSize=8:noTabs=true: