2 * Copyright (C) <2005> Wim Taymans <wim.taymans@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
19 * Author: Dejan Sakelsak sahel@kiberpipa.org
22 #ifndef __GST_RTP_H263_PAY_H__
23 #define __GST_RTP_H263_PAY_H__
26 #include <gst/rtp/gstbasertppayload.h>
27 #include <gst/base/gstadapter.h>
30 #define GST_TYPE_RTP_H263_PAY \
31 (gst_rtp_h263_pay_get_type())
32 #define GST_RTP_H263_PAY(obj) \
33 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_H263_PAY,GstRtpH263Pay))
34 #define GST_RTP_H263_PAY_CLASS(klass) \
35 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_H263_PAY,GstRtpH263PayClass))
36 #define GST_IS_RTP_H263_PAY(obj) \
37 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_H263_PAY))
38 #define GST_IS_RTP_H263_PAY_CLASS(klass) \
39 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_H263_PAY))
40 // blocks per macroblock
42 #define DEFAULT_MODE_A FALSE
43 #define MTU_SECURITY_OFFSET 50
44 typedef enum _GstRtpH263PayHeaderMode
46 GST_RTP_H263_PAYLOAD_HEADER_MODE_A = 4,
47 GST_RTP_H263_PAYLOAD_HEADER_MODE_B = 8,
48 GST_RTP_H263_PAYLOAD_HEADER_MODE_C = 12
49 } GstRtpH263PayHeaderMode;
51 typedef struct _GstRtpH263PayContext GstRtpH263PayContext;
52 typedef struct _GstRtpH263PayPic GstRtpH263PayPic;
53 typedef struct _GstRtpH263PayClass GstRtpH263PayClass;
54 typedef struct _GstRtpH263Pay GstRtpH263Pay;
55 typedef struct _GstRtpH263PayBoundry GstRtpH263PayBoundry;
56 typedef struct _GstRtpH263PayMB GstRtpH263PayMB;
57 typedef struct _GstRtpH263PayGob GstRtpH263PayGob;
58 typedef struct _GstRtpH263PayPackage GstRtpH263PayPackage;
60 //typedef enum _GstRtpH263PayHeaderMode GstRtpH263PayHeaderMode;
64 GstBaseRTPPayload payload;
67 GstClockTime first_ts;
68 gboolean prop_payload_mode;
74 struct _GstRtpH263PayContext
76 GstRtpH263PayPic *piclayer;
84 GstRtpH263PayGob **gobs;
88 struct _GstRtpH263PayClass
90 GstBaseRTPPayloadClass parent_class;
93 typedef struct _GstRtpH263PayAHeader
95 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
96 unsigned int ebit:3; /* End position */
97 unsigned int sbit:3; /* Start position */
98 unsigned int p:1; /* PB-frames mode */
99 unsigned int f:1; /* flag bit */
101 unsigned int r1:1; /* Reserved */
102 unsigned int a:1; /* Advanced Prediction */
103 unsigned int s:1; /* syntax based arithmetic coding */
104 unsigned int u:1; /* Unrestricted motion vector */
105 unsigned int i:1; /* Picture coding type */
106 unsigned int src:3; /* Source format */
108 unsigned int trb:3; /* Temporal ref for B frame */
109 unsigned int dbq:2; /* Differential Quantisation parameter */
110 unsigned int r2:3; /* Reserved */
111 #elif G_BYTE_ORDER == G_BIG_ENDIAN
112 unsigned int f:1; /* flag bit */
113 unsigned int p:1; /* PB-frames mode */
114 unsigned int sbit:3; /* Start position */
115 unsigned int ebit:3; /* End position */
117 unsigned int src:3; /* Source format */
118 unsigned int i:1; /* Picture coding type */
119 unsigned int u:1; /* Unrestricted motion vector */
120 unsigned int s:1; /* syntax based arithmetic coding */
121 unsigned int a:1; /* Advanced Prediction */
122 unsigned int r1:1; /* Reserved */
124 unsigned int r2:3; /* Reserved */
125 unsigned int dbq:2; /* Differential Quantisation parameter */
126 unsigned int trb:3; /* Temporal ref for B frame */
128 #error "G_BYTE_ORDER should be big or little endian."
130 unsigned int tr:8; /* Temporal ref for P frame */
131 } GstRtpH263PayAHeader;
133 typedef struct _GstRtpH263PayBHeader
135 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
136 unsigned int ebit:3; /* End position */
137 unsigned int sbit:3; /* Start position */
138 unsigned int p:1; /* PB-frames mode */
139 unsigned int f:1; /* flag bit */
141 unsigned int quant:5; /* Quantization value for first MB */
142 unsigned int src:3; /* Source format */
144 unsigned int mba1:3; /* Address of first MB starting count from 0 - part1 */
145 unsigned int gobn:5; /* GOB number in effect at start of packet */
147 unsigned int r:2; /* Reserved */
148 unsigned int mba2:6; /* Address of first MB starting count from 0 - part2 */
150 unsigned int hmv11:4; /* horizontal motion vector predictor for MB 1 - part 1 */
151 unsigned int a:1; /* Advanced Prediction */
152 unsigned int s:1; /* syntax based arithmetic coding */
153 unsigned int u:1; /* Unrestricted motion vector */
154 unsigned int i:1; /* Picture coding type */
156 unsigned int vmv11:5; /* vertical motion vector predictor for MB 1 - part 1 */
157 unsigned int hmv12:3; /* horizontal motion vector predictor for MB 1 - part 2 */
159 unsigned int hmv21:6; /* horizontal motion vector predictor for MB 3 - part 1 */
160 unsigned int vmv12:2; /* vertical motion vector predictor for MB 1 - part 2 */
162 unsigned int vmv21:7; /* vertical motion vector predictor for MB 3 */
163 unsigned int hmv22:1; /* horizontal motion vector predictor for MB 3 - part 2 */
165 #elif G_BYTE_ORDER == G_BIG_ENDIAN
166 unsigned int f:1; /* flag bit */
167 unsigned int p:1; /* PB-frames mode */
168 unsigned int sbit:3; /* Start position */
169 unsigned int ebit:3; /* End position */
171 unsigned int src:3; /* Source format */
172 unsigned int quant:5; /* Quantization value for first MB */
174 unsigned int gobn:5; /* GOB number in effect at start of packet */
175 unsigned int mba1:3; /* Address of first MB starting count from 0 - part1 */
177 unsigned int mba2:6; /* Address of first MB starting count from 0 - part2 */
178 unsigned int r:2; /* Reserved */
180 unsigned int i:1; /* Picture coding type */
181 unsigned int u:1; /* Unrestricted motion vector */
182 unsigned int s:1; /* syntax based arithmetic coding */
183 unsigned int a:1; /* Advanced Prediction */
184 unsigned int hmv11:4; /* horizontal motion vector predictor for MB 1 - part 1 */
186 unsigned int hmv12:3; /* horizontal motion vector predictor for MB 1 - part 2 */
187 unsigned int vmv11:5; /* vertical motion vector predictor for MB 1 - part 1 */
189 unsigned int vmv12:2; /* vertical motion vector predictor for MB 1 - part 2 */
190 unsigned int hmv21:6; /* horizontal motion vector predictor for MB 3 - part 1 */
192 unsigned int hmv22:1; /* horizontal motion vector predictor for MB 3 - part 2 */
193 unsigned int vmv21:7; /* vertical motion vector predictor for MB 3 */
195 #error "G_BYTE_ORDER should be big or little endian."
197 } GstRtpH263PayBHeader;
199 typedef struct _GstRtpH263PayCHeader
201 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
202 unsigned int ebit:3; /* End position */
203 unsigned int sbit:3; /* Start position */
204 unsigned int p:1; /* PB-frames mode */
205 unsigned int f:1; /* flag bit */
207 unsigned int quant:5; /* Quantization value for first MB */
208 unsigned int src:3; /* Source format */
210 unsigned int mba1:3; /* Address of first MB starting count from 0 - part1 */
211 unsigned int gobn:5; /* GOB number in effect at start of packet */
213 unsigned int r:2; /* Reserved */
214 unsigned int mba2:6; /* Address of first MB starting count from 0 - part2 */
216 unsigned int hmv11:4; /* horizontal motion vector predictor for MB 1 - part 1 */
217 unsigned int a:1; /* Advanced Prediction */
218 unsigned int s:1; /* syntax based arithmetic coding */
219 unsigned int u:1; /* Unrestricted motion vector */
220 unsigned int i:1; /* Picture coding type */
222 unsigned int vmv11:5; /* vertical motion vector predictor for MB 1 - part 1 */
223 unsigned int hmv12:3; /* horizontal motion vector predictor for MB 1 - part 2 */
225 unsigned int hmv21:6; /* horizontal motion vector predictor for MB 3 - part 1 */
226 unsigned int vmv12:2; /* vertical motion vector predictor for MB 1 - part 2 */
228 unsigned int vmv21:7; /* vertical motion vector predictor for MB 3 */
229 unsigned int hmv22:1; /* horizontal motion vector predictor for MB 3 - part 2 */
231 unsigned int rr1:8; /* reserved */
233 unsigned int rr2:8; /* reserved */
235 unsigned int trb:3; /* Temporal Reference for the B */
236 unsigned int dbq:2; /* Differential quantization parameter */
237 unsigned int rr3:3; /* reserved */
239 unsigned int tr:8; /* Temporal Reference for the P frame */
241 #elif G_BYTE_ORDER == G_BIG_ENDIAN
242 unsigned int f:1; /* flag bit */
243 unsigned int p:1; /* PB-frames mode */
244 unsigned int sbit:3; /* Start position */
245 unsigned int ebit:3; /* End position */
247 unsigned int src:3; /* Source format */
248 unsigned int quant:5; /* Quantization value for first MB */
250 unsigned int gobn:5; /* GOB number in effect at start of packet */
251 unsigned int mba1:3; /* Address of first MB starting count from 0 - part1 */
253 unsigned int mba2:6; /* Address of first MB starting count from 0 - part2 */
254 unsigned int r:2; /* Reserved */
256 unsigned int i:1; /* Picture coding type */
257 unsigned int u:1; /* Unrestricted motion vector */
258 unsigned int s:1; /* syntax based arithmetic coding */
259 unsigned int a:1; /* Advanced Prediction */
260 unsigned int hmv11:4; /* horizontal motion vector predictor for MB 1 - part 1 */
262 unsigned int hmv12:3; /* horizontal motion vector predictor for MB 1 - part 2 */
263 unsigned int vmv11:5; /* vertical motion vector predictor for MB 1 - part 1 */
265 unsigned int vmv12:2; /* vertical motion vector predictor for MB 1 - part 2 */
266 unsigned int hmv21:6; /* horizontal motion vector predictor for MB 3 - part 1 */
268 unsigned int hmv22:1; /* horizontal motion vector predictor for MB 3 - part 2 */
269 unsigned int vmv21:7; /* vertical motion vector predictor for MB 3 */
270 unsigned int rr1:8; /* reserved */
271 unsigned int rr2:8; /* reserved */
273 unsigned int rr3:3; /* reserved */
274 unsigned int dbq:2; /* Differential quantization parameter */
275 unsigned int trb:3; /* Temporal Reference for the B */
277 unsigned int tr:8; /* Temporal Reference for the P frame */
279 #error "G_BYTE_ORDER should be big or little endian."
281 } GstRtpH263PayCHeader;
283 struct _GstRtpH263PayPic
285 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
286 unsigned int psc1:16;
291 unsigned int ptype_263:1;
292 unsigned int ptype_start:1;
295 unsigned int ptype_umvmode:1;
296 unsigned int ptype_pictype:1;
297 unsigned int ptype_srcformat:3;
298 unsigned int ptype_freeze:1;
299 unsigned int ptype_camera:1;
300 unsigned int ptype_split:1;
302 unsigned int pquant:5;
303 unsigned int ptype_pbmode:1;
304 unsigned int ptype_apmode:1;
305 unsigned int ptype_sacmode:1;
307 #elif G_BYTE_ORDER == G_BIG_ENDIAN
308 unsigned int psc1:16;
314 unsigned int ptype_start:2;
316 unsigned int ptype_split:1;
317 unsigned int ptype_camera:1;
318 unsigned int ptype_freeze:1;
319 unsigned int ptype_srcformat:3;
320 unsigned int ptype_pictype:1;
321 unsigned int ptype_umvmode:1;
323 unsigned int ptype_sacmode:1;
324 unsigned int ptype_apmode:1;
325 unsigned int ptype_pbmode:1;
326 unsigned int pquant:5;
329 #error "G_BYTE_ORDER should be big or little endian."
333 struct _GstRtpH263PayBoundry
343 struct _GstRtpH263PayMB
358 struct _GstRtpH263PayGob
369 GstRtpH263PayMB **macroblocks;
373 struct _GstRtpH263PayPackage
375 guint8 *payload_start;
383 GstRtpH263PayHeaderMode mode;
396 #define GST_H263_PICTURELAYER_PLSRC(buf) (((GstRtpH263PayPic *)(buf))->ptype_srcformat)
397 #define GST_H263_PICTURELAYER_PLTYPE(buf) (((GstRtpH263PayPic *)(buf))->ptype_pictype)
398 #define GST_H263_PICTURELAYER_PLUMV(buf) (((GstRtpH263PayPic *)(buf))->ptype_umvmode)
399 #define GST_H263_PICTURELAYER_PLSAC(buf) (((GstRtpH263PayPic *)(buf))->ptype_sacmode)
400 #define GST_H263_PICTURELAYER_PLAP(buf) (((GstRtpH263PayPic *)(buf))->ptype_apmode)
403 * TODO: PB frame relevant tables
406 #define GST_RTP_H263_PAY_END(start, len) (((guint8 *)start) + ((guint)len))
407 #define GST_RTP_H263_PAY_GOBN(gob) (((((guint8 *) gob)[2] >> 2) & 0x1f)
409 GType gst_rtp_h263_pay_get_type (void);
411 gboolean gst_rtp_h263_pay_plugin_init (GstPlugin * plugin);
414 #endif /* __GST_RTP_H263_PAY_H__ */