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., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, 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/gstrtpbasepayload.h>
29 #define GST_TYPE_RTP_H263_PAY \
30 (gst_rtp_h263_pay_get_type())
31 #define GST_RTP_H263_PAY(obj) \
32 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_H263_PAY,GstRtpH263Pay))
33 #define GST_RTP_H263_PAY_CLASS(klass) \
34 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_H263_PAY,GstRtpH263PayClass))
35 #define GST_IS_RTP_H263_PAY(obj) \
36 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_H263_PAY))
37 #define GST_IS_RTP_H263_PAY_CLASS(klass) \
38 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_H263_PAY))
39 // blocks per macroblock
41 #define DEFAULT_MODE_A FALSE
42 #define MTU_SECURITY_OFFSET 50
43 typedef enum _GstRtpH263PayHeaderMode
45 GST_RTP_H263_PAYLOAD_HEADER_MODE_A = 4,
46 GST_RTP_H263_PAYLOAD_HEADER_MODE_B = 8,
47 GST_RTP_H263_PAYLOAD_HEADER_MODE_C = 12
48 } GstRtpH263PayHeaderMode;
50 typedef struct _GstRtpH263PayContext GstRtpH263PayContext;
51 typedef struct _GstRtpH263PayPic GstRtpH263PayPic;
52 typedef struct _GstRtpH263PayClass GstRtpH263PayClass;
53 typedef struct _GstRtpH263Pay GstRtpH263Pay;
54 typedef struct _GstRtpH263PayBoundry GstRtpH263PayBoundry;
55 typedef struct _GstRtpH263PayMB GstRtpH263PayMB;
56 typedef struct _GstRtpH263PayGob GstRtpH263PayGob;
57 typedef struct _GstRtpH263PayPackage GstRtpH263PayPackage;
59 //typedef enum _GstRtpH263PayHeaderMode GstRtpH263PayHeaderMode;
63 GstRTPBasePayload payload;
65 GstBuffer *current_buffer;
68 GstClockTime first_ts;
69 gboolean prop_payload_mode;
75 struct _GstRtpH263PayContext
77 GstRtpH263PayPic *piclayer;
85 GstRtpH263PayGob **gobs;
89 struct _GstRtpH263PayClass
91 GstRTPBasePayloadClass parent_class;
94 typedef struct _GstRtpH263PayAHeader
96 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
97 unsigned int ebit:3; /* End position */
98 unsigned int sbit:3; /* Start position */
99 unsigned int p:1; /* PB-frames mode */
100 unsigned int f:1; /* flag bit */
102 unsigned int r1:1; /* Reserved */
103 unsigned int a:1; /* Advanced Prediction */
104 unsigned int s:1; /* syntax based arithmetic coding */
105 unsigned int u:1; /* Unrestricted motion vector */
106 unsigned int i:1; /* Picture coding type */
107 unsigned int src:3; /* Source format */
109 unsigned int trb:3; /* Temporal ref for B frame */
110 unsigned int dbq:2; /* Differential Quantisation parameter */
111 unsigned int r2:3; /* Reserved */
112 #elif G_BYTE_ORDER == G_BIG_ENDIAN
113 unsigned int f:1; /* flag bit */
114 unsigned int p:1; /* PB-frames mode */
115 unsigned int sbit:3; /* Start position */
116 unsigned int ebit:3; /* End position */
118 unsigned int src:3; /* Source format */
119 unsigned int i:1; /* Picture coding type */
120 unsigned int u:1; /* Unrestricted motion vector */
121 unsigned int s:1; /* syntax based arithmetic coding */
122 unsigned int a:1; /* Advanced Prediction */
123 unsigned int r1:1; /* Reserved */
125 unsigned int r2:3; /* Reserved */
126 unsigned int dbq:2; /* Differential Quantisation parameter */
127 unsigned int trb:3; /* Temporal ref for B frame */
129 #error "G_BYTE_ORDER should be big or little endian."
131 unsigned int tr:8; /* Temporal ref for P frame */
132 } GstRtpH263PayAHeader;
134 typedef struct _GstRtpH263PayBHeader
136 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
137 unsigned int ebit:3; /* End position */
138 unsigned int sbit:3; /* Start position */
139 unsigned int p:1; /* PB-frames mode */
140 unsigned int f:1; /* flag bit */
142 unsigned int quant:5; /* Quantization value for first MB */
143 unsigned int src:3; /* Source format */
145 unsigned int mba1:3; /* Address of first MB starting count from 0 - part1 */
146 unsigned int gobn:5; /* GOB number in effect at start of packet */
148 unsigned int r:2; /* Reserved */
149 unsigned int mba2:6; /* Address of first MB starting count from 0 - part2 */
151 unsigned int hmv11:4; /* horizontal motion vector predictor for MB 1 - part 1 */
152 unsigned int a:1; /* Advanced Prediction */
153 unsigned int s:1; /* syntax based arithmetic coding */
154 unsigned int u:1; /* Unrestricted motion vector */
155 unsigned int i:1; /* Picture coding type */
157 unsigned int vmv11:5; /* vertical motion vector predictor for MB 1 - part 1 */
158 unsigned int hmv12:3; /* horizontal motion vector predictor for MB 1 - part 2 */
160 unsigned int hmv21:6; /* horizontal motion vector predictor for MB 3 - part 1 */
161 unsigned int vmv12:2; /* vertical motion vector predictor for MB 1 - part 2 */
163 unsigned int vmv21:7; /* vertical motion vector predictor for MB 3 */
164 unsigned int hmv22:1; /* horizontal motion vector predictor for MB 3 - part 2 */
166 #elif G_BYTE_ORDER == G_BIG_ENDIAN
167 unsigned int f:1; /* flag bit */
168 unsigned int p:1; /* PB-frames mode */
169 unsigned int sbit:3; /* Start position */
170 unsigned int ebit:3; /* End position */
172 unsigned int src:3; /* Source format */
173 unsigned int quant:5; /* Quantization value for first MB */
175 unsigned int gobn:5; /* GOB number in effect at start of packet */
176 unsigned int mba1:3; /* Address of first MB starting count from 0 - part1 */
178 unsigned int mba2:6; /* Address of first MB starting count from 0 - part2 */
179 unsigned int r:2; /* Reserved */
181 unsigned int i:1; /* Picture coding type */
182 unsigned int u:1; /* Unrestricted motion vector */
183 unsigned int s:1; /* syntax based arithmetic coding */
184 unsigned int a:1; /* Advanced Prediction */
185 unsigned int hmv11:4; /* horizontal motion vector predictor for MB 1 - part 1 */
187 unsigned int hmv12:3; /* horizontal motion vector predictor for MB 1 - part 2 */
188 unsigned int vmv11:5; /* vertical motion vector predictor for MB 1 - part 1 */
190 unsigned int vmv12:2; /* vertical motion vector predictor for MB 1 - part 2 */
191 unsigned int hmv21:6; /* horizontal motion vector predictor for MB 3 - part 1 */
193 unsigned int hmv22:1; /* horizontal motion vector predictor for MB 3 - part 2 */
194 unsigned int vmv21:7; /* vertical motion vector predictor for MB 3 */
196 #error "G_BYTE_ORDER should be big or little endian."
198 } GstRtpH263PayBHeader;
200 typedef struct _GstRtpH263PayCHeader
202 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
203 unsigned int ebit:3; /* End position */
204 unsigned int sbit:3; /* Start position */
205 unsigned int p:1; /* PB-frames mode */
206 unsigned int f:1; /* flag bit */
208 unsigned int quant:5; /* Quantization value for first MB */
209 unsigned int src:3; /* Source format */
211 unsigned int mba1:3; /* Address of first MB starting count from 0 - part1 */
212 unsigned int gobn:5; /* GOB number in effect at start of packet */
214 unsigned int r:2; /* Reserved */
215 unsigned int mba2:6; /* Address of first MB starting count from 0 - part2 */
217 unsigned int hmv11:4; /* horizontal motion vector predictor for MB 1 - part 1 */
218 unsigned int a:1; /* Advanced Prediction */
219 unsigned int s:1; /* syntax based arithmetic coding */
220 unsigned int u:1; /* Unrestricted motion vector */
221 unsigned int i:1; /* Picture coding type */
223 unsigned int vmv11:5; /* vertical motion vector predictor for MB 1 - part 1 */
224 unsigned int hmv12:3; /* horizontal motion vector predictor for MB 1 - part 2 */
226 unsigned int hmv21:6; /* horizontal motion vector predictor for MB 3 - part 1 */
227 unsigned int vmv12:2; /* vertical motion vector predictor for MB 1 - part 2 */
229 unsigned int vmv21:7; /* vertical motion vector predictor for MB 3 */
230 unsigned int hmv22:1; /* horizontal motion vector predictor for MB 3 - part 2 */
232 unsigned int rr1:8; /* reserved */
234 unsigned int rr2:8; /* reserved */
236 unsigned int trb:3; /* Temporal Reference for the B */
237 unsigned int dbq:2; /* Differential quantization parameter */
238 unsigned int rr3:3; /* reserved */
240 unsigned int tr:8; /* Temporal Reference for the P frame */
242 #elif G_BYTE_ORDER == G_BIG_ENDIAN
243 unsigned int f:1; /* flag bit */
244 unsigned int p:1; /* PB-frames mode */
245 unsigned int sbit:3; /* Start position */
246 unsigned int ebit:3; /* End position */
248 unsigned int src:3; /* Source format */
249 unsigned int quant:5; /* Quantization value for first MB */
251 unsigned int gobn:5; /* GOB number in effect at start of packet */
252 unsigned int mba1:3; /* Address of first MB starting count from 0 - part1 */
254 unsigned int mba2:6; /* Address of first MB starting count from 0 - part2 */
255 unsigned int r:2; /* Reserved */
257 unsigned int i:1; /* Picture coding type */
258 unsigned int u:1; /* Unrestricted motion vector */
259 unsigned int s:1; /* syntax based arithmetic coding */
260 unsigned int a:1; /* Advanced Prediction */
261 unsigned int hmv11:4; /* horizontal motion vector predictor for MB 1 - part 1 */
263 unsigned int hmv12:3; /* horizontal motion vector predictor for MB 1 - part 2 */
264 unsigned int vmv11:5; /* vertical motion vector predictor for MB 1 - part 1 */
266 unsigned int vmv12:2; /* vertical motion vector predictor for MB 1 - part 2 */
267 unsigned int hmv21:6; /* horizontal motion vector predictor for MB 3 - part 1 */
269 unsigned int hmv22:1; /* horizontal motion vector predictor for MB 3 - part 2 */
270 unsigned int vmv21:7; /* vertical motion vector predictor for MB 3 */
271 unsigned int rr1:8; /* reserved */
272 unsigned int rr2:8; /* reserved */
274 unsigned int rr3:3; /* reserved */
275 unsigned int dbq:2; /* Differential quantization parameter */
276 unsigned int trb:3; /* Temporal Reference for the B */
278 unsigned int tr:8; /* Temporal Reference for the P frame */
280 #error "G_BYTE_ORDER should be big or little endian."
282 } GstRtpH263PayCHeader;
284 struct _GstRtpH263PayPic
286 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
287 unsigned int psc1:16;
292 unsigned int ptype_263:1;
293 unsigned int ptype_start:1;
296 unsigned int ptype_umvmode:1;
297 unsigned int ptype_pictype:1;
298 unsigned int ptype_srcformat:3;
299 unsigned int ptype_freeze:1;
300 unsigned int ptype_camera:1;
301 unsigned int ptype_split:1;
303 unsigned int pquant:5;
304 unsigned int ptype_pbmode:1;
305 unsigned int ptype_apmode:1;
306 unsigned int ptype_sacmode:1;
308 #elif G_BYTE_ORDER == G_BIG_ENDIAN
309 unsigned int psc1:16;
315 unsigned int ptype_start:2;
317 unsigned int ptype_split:1;
318 unsigned int ptype_camera:1;
319 unsigned int ptype_freeze:1;
320 unsigned int ptype_srcformat:3;
321 unsigned int ptype_pictype:1;
322 unsigned int ptype_umvmode:1;
324 unsigned int ptype_sacmode:1;
325 unsigned int ptype_apmode:1;
326 unsigned int ptype_pbmode:1;
327 unsigned int pquant:5;
330 #error "G_BYTE_ORDER should be big or little endian."
334 struct _GstRtpH263PayBoundry
344 struct _GstRtpH263PayMB
359 struct _GstRtpH263PayGob
370 GstRtpH263PayMB **macroblocks;
374 struct _GstRtpH263PayPackage
376 guint8 *payload_start;
384 GstRtpH263PayHeaderMode mode;
397 #define GST_H263_PICTURELAYER_PLSRC(buf) (((GstRtpH263PayPic *)(buf))->ptype_srcformat)
398 #define GST_H263_PICTURELAYER_PLTYPE(buf) (((GstRtpH263PayPic *)(buf))->ptype_pictype)
399 #define GST_H263_PICTURELAYER_PLUMV(buf) (((GstRtpH263PayPic *)(buf))->ptype_umvmode)
400 #define GST_H263_PICTURELAYER_PLSAC(buf) (((GstRtpH263PayPic *)(buf))->ptype_sacmode)
401 #define GST_H263_PICTURELAYER_PLAP(buf) (((GstRtpH263PayPic *)(buf))->ptype_apmode)
404 * TODO: PB frame relevant tables
407 #define GST_RTP_H263_PAY_END(start, len) (((guint8 *)start) + ((guint)len))
408 #define GST_RTP_H263_PAY_GOBN(gob) (((((guint8 *) gob)[2] >> 2) & 0x1f)
410 GType gst_rtp_h263_pay_get_type (void);
413 #endif /* __GST_RTP_H263_PAY_H__ */