Mercurial > sdl-ios-xcode
comparison src/video/Xext/Xv/Xv.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | ecba4bbaf9c2 |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
61 static char *xv_extension_name = XvName; | 61 static char *xv_extension_name = XvName; |
62 | 62 |
63 #define XvCheckExtension(dpy, i, val) \ | 63 #define XvCheckExtension(dpy, i, val) \ |
64 XextCheckExtension(dpy, i, xv_extension_name, val) | 64 XextCheckExtension(dpy, i, xv_extension_name, val) |
65 | 65 |
66 static char *xv_error_string(); | 66 static char *xv_error_string (); |
67 static int xv_close_display(); | 67 static int xv_close_display (); |
68 static Bool xv_wire_to_event(); | 68 static Bool xv_wire_to_event (); |
69 | 69 |
70 static XExtensionHooks xv_extension_hooks = { | 70 static XExtensionHooks xv_extension_hooks = { |
71 NULL, /* create_gc */ | 71 NULL, /* create_gc */ |
72 NULL, /* copy_gc */ | 72 NULL, /* copy_gc */ |
73 NULL, /* flush_gc */ | 73 NULL, /* flush_gc */ |
74 NULL, /* free_gc */ | 74 NULL, /* free_gc */ |
75 NULL, /* create_font */ | 75 NULL, /* create_font */ |
76 NULL, /* free_font */ | 76 NULL, /* free_font */ |
77 xv_close_display, /* close_display */ | 77 xv_close_display, /* close_display */ |
78 xv_wire_to_event, /* wire_to_event */ | 78 xv_wire_to_event, /* wire_to_event */ |
79 NULL, /* event_to_wire */ | 79 NULL, /* event_to_wire */ |
80 NULL, /* error */ | 80 NULL, /* error */ |
81 xv_error_string /* error_string */ | 81 xv_error_string /* error_string */ |
82 }; | 82 }; |
83 | 83 |
84 | 84 |
85 static char *xv_error_list[] = | 85 static char *xv_error_list[] = { |
86 { | 86 "BadPort", /* XvBadPort */ |
87 "BadPort", /* XvBadPort */ | 87 "BadEncoding", /* XvBadEncoding */ |
88 "BadEncoding", /* XvBadEncoding */ | 88 "BadControl" /* XvBadControl */ |
89 "BadControl" /* XvBadControl */ | |
90 }; | 89 }; |
91 | 90 |
92 static XEXT_GENERATE_CLOSE_DISPLAY (xv_close_display, xv_info) | 91 static |
93 | 92 XEXT_GENERATE_CLOSE_DISPLAY (xv_close_display, xv_info) |
94 | 93 static XEXT_GENERATE_FIND_DISPLAY (xv_find_display, xv_info, |
95 static XEXT_GENERATE_FIND_DISPLAY (xv_find_display, xv_info, | 94 xv_extension_name, |
96 xv_extension_name, | 95 &xv_extension_hooks, |
97 &xv_extension_hooks, | 96 XvNumEvents, NULL) |
98 XvNumEvents, NULL) | 97 static XEXT_GENERATE_ERROR_STRING (xv_error_string, xv_extension_name, |
99 | 98 XvNumErrors, xv_error_list) |
100 | 99 int SDL_NAME (XvQueryExtension) (Display * dpy, |
101 static XEXT_GENERATE_ERROR_STRING (xv_error_string, xv_extension_name, | 100 unsigned int *p_version, |
102 XvNumErrors, xv_error_list) | 101 unsigned int *p_revision, |
103 | 102 unsigned int *p_requestBase, |
103 unsigned int *p_eventBase, | |
104 unsigned int *p_errorBase) | |
105 { | |
106 XExtDisplayInfo *info = xv_find_display (dpy); | |
107 xvQueryExtensionReq *req; | |
108 xvQueryExtensionReply rep; | |
109 | |
110 XvCheckExtension (dpy, info, XvBadExtension); | |
111 | |
112 LockDisplay (dpy); | |
113 | |
114 XvGetReq (QueryExtension, req); | |
115 | |
116 if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { | |
117 UnlockDisplay (dpy); | |
118 SyncHandle (); | |
119 return XvBadExtension; | |
120 } | |
121 | |
122 *p_version = rep.version; | |
123 *p_revision = rep.revision; | |
124 *p_requestBase = info->codes->major_opcode; | |
125 *p_eventBase = info->codes->first_event; | |
126 *p_errorBase = info->codes->first_error; | |
127 | |
128 UnlockDisplay (dpy); | |
129 SyncHandle (); | |
130 | |
131 return Success; | |
132 } | |
104 | 133 |
105 int | 134 int |
106 SDL_NAME(XvQueryExtension)( | 135 SDL_NAME (XvQueryAdaptors) (Display * dpy, |
107 Display *dpy, | 136 Window window, |
108 unsigned int *p_version, | 137 unsigned int *p_nAdaptors, |
109 unsigned int *p_revision, | 138 SDL_NAME (XvAdaptorInfo) ** p_pAdaptors) |
110 unsigned int *p_requestBase, | 139 { |
111 unsigned int *p_eventBase, | 140 XExtDisplayInfo *info = xv_find_display (dpy); |
112 unsigned int *p_errorBase | 141 xvQueryAdaptorsReq *req; |
113 ){ | 142 xvQueryAdaptorsReply rep; |
114 XExtDisplayInfo *info = xv_find_display(dpy); | 143 int size, ii, jj; |
115 xvQueryExtensionReq *req; | 144 char *name; |
116 xvQueryExtensionReply rep; | 145 SDL_NAME (XvAdaptorInfo) * pas, *pa; |
117 | 146 SDL_NAME (XvFormat) * pfs, *pf; |
118 XvCheckExtension(dpy, info, XvBadExtension); | 147 char *buffer; |
119 | 148 union |
120 LockDisplay(dpy); | 149 { |
121 | 150 char *buffer; |
122 XvGetReq(QueryExtension, req); | 151 char *string; |
123 | 152 xvAdaptorInfo *pa; |
124 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { | 153 xvFormat *pf; |
125 UnlockDisplay(dpy); | 154 } u; |
126 SyncHandle(); | 155 |
127 return XvBadExtension; | 156 XvCheckExtension (dpy, info, XvBadExtension); |
128 } | 157 |
129 | 158 LockDisplay (dpy); |
130 *p_version = rep.version; | 159 |
131 *p_revision = rep.revision; | 160 XvGetReq (QueryAdaptors, req); |
132 *p_requestBase = info->codes->major_opcode; | 161 req->window = window; |
133 *p_eventBase = info->codes->first_event; | 162 |
134 *p_errorBase = info->codes->first_error; | 163 /* READ THE REPLY */ |
135 | 164 |
136 UnlockDisplay(dpy); | 165 if (_XReply (dpy, (xReply *) & rep, 0, xFalse) == 0) { |
137 SyncHandle(); | 166 UnlockDisplay (dpy); |
138 | 167 SyncHandle (); |
139 return Success; | 168 return (XvBadReply); |
169 } | |
170 | |
171 size = rep.length << 2; | |
172 if ((buffer = (char *) Xmalloc ((unsigned) size)) == NULL) { | |
173 UnlockDisplay (dpy); | |
174 SyncHandle (); | |
175 return (XvBadAlloc); | |
176 } | |
177 _XRead (dpy, buffer, size); | |
178 | |
179 u.buffer = buffer; | |
180 | |
181 /* GET INPUT ADAPTORS */ | |
182 | |
183 if (rep.num_adaptors == 0) { | |
184 pas = NULL; | |
185 } else { | |
186 size = rep.num_adaptors * sizeof (SDL_NAME (XvAdaptorInfo)); | |
187 if ((pas = (SDL_NAME (XvAdaptorInfo) *) Xmalloc (size)) == NULL) { | |
188 Xfree (buffer); | |
189 UnlockDisplay (dpy); | |
190 SyncHandle (); | |
191 return (XvBadAlloc); | |
192 } | |
193 } | |
194 | |
195 /* INIT ADAPTOR FIELDS */ | |
196 | |
197 pa = pas; | |
198 for (ii = 0; ii < rep.num_adaptors; ii++) { | |
199 pa->num_adaptors = 0; | |
200 pa->name = (char *) NULL; | |
201 pa->formats = (SDL_NAME (XvFormat) *) NULL; | |
202 pa++; | |
203 } | |
204 | |
205 pa = pas; | |
206 for (ii = 0; ii < rep.num_adaptors; ii++) { | |
207 pa->type = u.pa->type; | |
208 pa->base_id = u.pa->base_id; | |
209 pa->num_ports = u.pa->num_ports; | |
210 pa->num_formats = u.pa->num_formats; | |
211 pa->num_adaptors = rep.num_adaptors - ii; | |
212 | |
213 /* GET ADAPTOR NAME */ | |
214 | |
215 size = u.pa->name_size; | |
216 u.buffer += (sz_xvAdaptorInfo + 3) & ~3; | |
217 | |
218 if ((name = (char *) Xmalloc (size + 1)) == NULL) { | |
219 SDL_NAME (XvFreeAdaptorInfo) (pas); | |
220 Xfree (buffer); | |
221 UnlockDisplay (dpy); | |
222 SyncHandle (); | |
223 return (XvBadAlloc); | |
224 } | |
225 SDL_strlcpy (name, u.string, size); | |
226 pa->name = name; | |
227 | |
228 u.buffer += (size + 3) & ~3; | |
229 | |
230 /* GET FORMATS */ | |
231 | |
232 size = pa->num_formats * sizeof (SDL_NAME (XvFormat)); | |
233 if ((pfs = (SDL_NAME (XvFormat) *) Xmalloc (size)) == NULL) { | |
234 SDL_NAME (XvFreeAdaptorInfo) (pas); | |
235 Xfree (buffer); | |
236 UnlockDisplay (dpy); | |
237 SyncHandle (); | |
238 return (XvBadAlloc); | |
239 } | |
240 | |
241 pf = pfs; | |
242 for (jj = 0; jj < pa->num_formats; jj++) { | |
243 pf->depth = u.pf->depth; | |
244 pf->visual_id = u.pf->visual; | |
245 pf++; | |
246 | |
247 u.buffer += (sz_xvFormat + 3) & ~3; | |
248 } | |
249 | |
250 pa->formats = pfs; | |
251 | |
252 pa++; | |
253 | |
254 } | |
255 | |
256 *p_nAdaptors = rep.num_adaptors; | |
257 *p_pAdaptors = pas; | |
258 | |
259 Xfree (buffer); | |
260 UnlockDisplay (dpy); | |
261 SyncHandle (); | |
262 | |
263 return (Success); | |
264 } | |
265 | |
266 | |
267 void SDL_NAME (XvFreeAdaptorInfo) (SDL_NAME (XvAdaptorInfo) * pAdaptors) | |
268 { | |
269 | |
270 SDL_NAME (XvAdaptorInfo) * pa; | |
271 int ii; | |
272 | |
273 if (!pAdaptors) | |
274 return; | |
275 | |
276 pa = pAdaptors; | |
277 | |
278 for (ii = 0; ii < pAdaptors->num_adaptors; ii++, pa++) { | |
279 if (pa->name) { | |
280 Xfree (pa->name); | |
281 } | |
282 if (pa->formats) { | |
283 Xfree (pa->formats); | |
284 } | |
285 } | |
286 | |
287 Xfree (pAdaptors); | |
140 } | 288 } |
141 | 289 |
142 int | 290 int |
143 SDL_NAME(XvQueryAdaptors)( | 291 SDL_NAME (XvQueryEncodings) (Display * dpy, |
144 Display *dpy, | 292 XvPortID port, |
145 Window window, | 293 unsigned int *p_nEncodings, |
146 unsigned int *p_nAdaptors, | 294 SDL_NAME (XvEncodingInfo) ** p_pEncodings) |
147 SDL_NAME(XvAdaptorInfo) **p_pAdaptors | 295 { |
148 ){ | 296 XExtDisplayInfo *info = xv_find_display (dpy); |
149 XExtDisplayInfo *info = xv_find_display(dpy); | 297 xvQueryEncodingsReq *req; |
150 xvQueryAdaptorsReq *req; | 298 xvQueryEncodingsReply rep; |
151 xvQueryAdaptorsReply rep; | 299 int size, jj; |
152 int size,ii,jj; | 300 char *name; |
153 char *name; | 301 SDL_NAME (XvEncodingInfo) * pes, *pe; |
154 SDL_NAME(XvAdaptorInfo) *pas, *pa; | 302 char *buffer; |
155 SDL_NAME(XvFormat) *pfs, *pf; | 303 union |
156 char *buffer; | |
157 union | |
158 { | 304 { |
159 char *buffer; | 305 char *buffer; |
160 char *string; | 306 char *string; |
161 xvAdaptorInfo *pa; | 307 xvEncodingInfo *pe; |
162 xvFormat *pf; | |
163 } u; | 308 } u; |
164 | 309 |
165 XvCheckExtension(dpy, info, XvBadExtension); | 310 XvCheckExtension (dpy, info, XvBadExtension); |
166 | 311 |
167 LockDisplay(dpy); | 312 LockDisplay (dpy); |
168 | 313 |
169 XvGetReq(QueryAdaptors, req); | 314 XvGetReq (QueryEncodings, req); |
170 req->window = window; | 315 req->port = port; |
171 | 316 |
172 /* READ THE REPLY */ | 317 /* READ THE REPLY */ |
173 | 318 |
174 if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) { | 319 if (_XReply (dpy, (xReply *) & rep, 0, xFalse) == 0) { |
175 UnlockDisplay(dpy); | 320 UnlockDisplay (dpy); |
176 SyncHandle(); | 321 SyncHandle (); |
177 return(XvBadReply); | 322 return (XvBadReply); |
178 } | 323 } |
179 | 324 |
180 size = rep.length << 2; | 325 size = rep.length << 2; |
181 if ( (buffer = (char *)Xmalloc ((unsigned) size)) == NULL) { | 326 if ((buffer = (char *) Xmalloc ((unsigned) size)) == NULL) { |
182 UnlockDisplay(dpy); | 327 UnlockDisplay (dpy); |
183 SyncHandle(); | 328 SyncHandle (); |
184 return(XvBadAlloc); | 329 return (XvBadAlloc); |
185 } | 330 } |
186 _XRead (dpy, buffer, size); | 331 _XRead (dpy, buffer, size); |
187 | 332 |
188 u.buffer = buffer; | 333 u.buffer = buffer; |
189 | 334 |
190 /* GET INPUT ADAPTORS */ | 335 /* GET ENCODINGS */ |
191 | 336 |
192 if (rep.num_adaptors == 0) { | 337 size = rep.num_encodings * sizeof (SDL_NAME (XvEncodingInfo)); |
193 pas = NULL; | 338 if ((pes = (SDL_NAME (XvEncodingInfo) *) Xmalloc (size)) == NULL) { |
194 } else { | 339 Xfree (buffer); |
195 size = rep.num_adaptors*sizeof(SDL_NAME(XvAdaptorInfo)); | 340 UnlockDisplay (dpy); |
196 if ((pas=(SDL_NAME(XvAdaptorInfo) *)Xmalloc(size))==NULL) { | 341 SyncHandle (); |
197 Xfree(buffer); | 342 return (XvBadAlloc); |
198 UnlockDisplay(dpy); | 343 } |
199 SyncHandle(); | 344 |
200 return(XvBadAlloc); | 345 /* INITIALIZE THE ENCODING POINTER */ |
201 } | 346 |
202 } | 347 pe = pes; |
203 | 348 for (jj = 0; jj < rep.num_encodings; jj++) { |
204 /* INIT ADAPTOR FIELDS */ | 349 pe->name = (char *) NULL; |
205 | 350 pe->num_encodings = 0; |
206 pa = pas; | 351 pe++; |
207 for (ii=0; ii<rep.num_adaptors; ii++) { | 352 } |
208 pa->num_adaptors = 0; | 353 |
209 pa->name = (char *)NULL; | 354 pe = pes; |
210 pa->formats = (SDL_NAME(XvFormat) *)NULL; | 355 for (jj = 0; jj < rep.num_encodings; jj++) { |
211 pa++; | 356 pe->encoding_id = u.pe->encoding; |
212 } | 357 pe->width = u.pe->width; |
213 | 358 pe->height = u.pe->height; |
214 pa = pas; | 359 pe->rate.numerator = u.pe->rate.numerator; |
215 for (ii=0; ii<rep.num_adaptors; ii++) { | 360 pe->rate.denominator = u.pe->rate.denominator; |
216 pa->type = u.pa->type; | 361 pe->num_encodings = rep.num_encodings - jj; |
217 pa->base_id = u.pa->base_id; | 362 |
218 pa->num_ports = u.pa->num_ports; | 363 size = u.pe->name_size; |
219 pa->num_formats = u.pa->num_formats; | 364 u.buffer += (sz_xvEncodingInfo + 3) & ~3; |
220 pa->num_adaptors = rep.num_adaptors - ii; | 365 |
221 | 366 if ((name = (char *) Xmalloc (size + 1)) == NULL) { |
222 /* GET ADAPTOR NAME */ | 367 Xfree (buffer); |
223 | 368 UnlockDisplay (dpy); |
224 size = u.pa->name_size; | 369 SyncHandle (); |
225 u.buffer += (sz_xvAdaptorInfo + 3) & ~3; | 370 return (XvBadAlloc); |
226 | 371 } |
227 if ( (name = (char *)Xmalloc(size+1)) == NULL) | 372 SDL_strlcpy (name, u.string, size); |
228 { | 373 pe->name = name; |
229 SDL_NAME(XvFreeAdaptorInfo)(pas); | 374 pe++; |
230 Xfree(buffer); | 375 |
231 UnlockDisplay(dpy); | 376 u.buffer += (size + 3) & ~3; |
232 SyncHandle(); | 377 } |
233 return(XvBadAlloc); | 378 |
234 } | 379 *p_nEncodings = rep.num_encodings; |
235 SDL_strlcpy(name, u.string, size); | 380 *p_pEncodings = pes; |
236 pa->name = name; | 381 |
237 | 382 Xfree (buffer); |
238 u.buffer += (size + 3) & ~3; | 383 UnlockDisplay (dpy); |
239 | 384 SyncHandle (); |
240 /* GET FORMATS */ | 385 |
241 | 386 return (Success); |
242 size = pa->num_formats*sizeof(SDL_NAME(XvFormat)); | 387 } |
243 if ((pfs=(SDL_NAME(XvFormat) *)Xmalloc(size))==NULL) { | 388 |
244 SDL_NAME(XvFreeAdaptorInfo)(pas); | 389 void SDL_NAME (XvFreeEncodingInfo) (SDL_NAME (XvEncodingInfo) * pEncodings) |
245 Xfree(buffer); | 390 { |
246 UnlockDisplay(dpy); | 391 |
247 SyncHandle(); | 392 SDL_NAME (XvEncodingInfo) * pe; |
248 return(XvBadAlloc); | 393 int ii; |
249 } | 394 |
250 | 395 if (!pEncodings) |
251 pf = pfs; | 396 return; |
252 for (jj=0; jj<pa->num_formats; jj++) { | 397 |
253 pf->depth = u.pf->depth; | 398 pe = pEncodings; |
254 pf->visual_id = u.pf->visual; | 399 |
255 pf++; | 400 for (ii = 0; ii < pEncodings->num_encodings; ii++, pe++) { |
256 | 401 if (pe->name) |
257 u.buffer += (sz_xvFormat + 3) & ~3; | 402 Xfree (pe->name); |
258 } | 403 } |
259 | 404 |
260 pa->formats = pfs; | 405 Xfree (pEncodings); |
261 | |
262 pa++; | |
263 | |
264 } | |
265 | |
266 *p_nAdaptors = rep.num_adaptors; | |
267 *p_pAdaptors = pas; | |
268 | |
269 Xfree(buffer); | |
270 UnlockDisplay(dpy); | |
271 SyncHandle(); | |
272 | |
273 return (Success); | |
274 } | |
275 | |
276 | |
277 void | |
278 SDL_NAME(XvFreeAdaptorInfo)(SDL_NAME(XvAdaptorInfo) *pAdaptors) | |
279 { | |
280 | |
281 SDL_NAME(XvAdaptorInfo) *pa; | |
282 int ii; | |
283 | |
284 if (!pAdaptors) return; | |
285 | |
286 pa = pAdaptors; | |
287 | |
288 for (ii=0; ii<pAdaptors->num_adaptors; ii++, pa++) | |
289 { | |
290 if (pa->name) | |
291 { | |
292 Xfree(pa->name); | |
293 } | |
294 if (pa->formats) | |
295 { | |
296 Xfree(pa->formats); | |
297 } | |
298 } | |
299 | |
300 Xfree(pAdaptors); | |
301 } | 406 } |
302 | 407 |
303 int | 408 int |
304 SDL_NAME(XvQueryEncodings)( | 409 SDL_NAME (XvPutVideo) (Display * dpy, |
305 Display *dpy, | 410 XvPortID port, |
306 XvPortID port, | 411 Drawable d, |
307 unsigned int *p_nEncodings, | 412 GC gc, |
308 SDL_NAME(XvEncodingInfo) **p_pEncodings | 413 int vx, int vy, |
309 ){ | 414 unsigned int vw, unsigned int vh, |
310 XExtDisplayInfo *info = xv_find_display(dpy); | 415 int dx, int dy, unsigned int dw, unsigned int dh) |
311 xvQueryEncodingsReq *req; | 416 { |
312 xvQueryEncodingsReply rep; | 417 XExtDisplayInfo *info = xv_find_display (dpy); |
313 int size, jj; | 418 xvPutVideoReq *req; |
314 char *name; | 419 |
315 SDL_NAME(XvEncodingInfo) *pes, *pe; | 420 XvCheckExtension (dpy, info, XvBadExtension); |
316 char *buffer; | 421 |
317 union | 422 LockDisplay (dpy); |
318 { | 423 |
319 char *buffer; | 424 FlushGC (dpy, gc); |
320 char *string; | 425 |
321 xvEncodingInfo *pe; | 426 XvGetReq (PutVideo, req); |
322 } u; | 427 |
323 | 428 req->port = port; |
324 XvCheckExtension(dpy, info, XvBadExtension); | 429 req->drawable = d; |
325 | 430 req->gc = gc->gid; |
326 LockDisplay(dpy); | 431 req->vid_x = vx; |
327 | 432 req->vid_y = vy; |
328 XvGetReq(QueryEncodings, req); | 433 req->vid_w = vw; |
329 req->port = port; | 434 req->vid_h = vh; |
330 | 435 req->drw_x = dx; |
331 /* READ THE REPLY */ | 436 req->drw_y = dy; |
332 | 437 req->drw_w = dw; |
333 if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) { | 438 req->drw_h = dh; |
334 UnlockDisplay(dpy); | 439 |
335 SyncHandle(); | 440 UnlockDisplay (dpy); |
336 return(XvBadReply); | 441 SyncHandle (); |
337 } | 442 |
338 | 443 return Success; |
339 size = rep.length << 2; | |
340 if ( (buffer = (char *)Xmalloc ((unsigned) size)) == NULL) { | |
341 UnlockDisplay(dpy); | |
342 SyncHandle(); | |
343 return(XvBadAlloc); | |
344 } | |
345 _XRead (dpy, buffer, size); | |
346 | |
347 u.buffer = buffer; | |
348 | |
349 /* GET ENCODINGS */ | |
350 | |
351 size = rep.num_encodings*sizeof(SDL_NAME(XvEncodingInfo)); | |
352 if ( (pes = (SDL_NAME(XvEncodingInfo) *)Xmalloc(size)) == NULL) { | |
353 Xfree(buffer); | |
354 UnlockDisplay(dpy); | |
355 SyncHandle(); | |
356 return(XvBadAlloc); | |
357 } | |
358 | |
359 /* INITIALIZE THE ENCODING POINTER */ | |
360 | |
361 pe = pes; | |
362 for (jj=0; jj<rep.num_encodings; jj++) { | |
363 pe->name = (char *)NULL; | |
364 pe->num_encodings = 0; | |
365 pe++; | |
366 } | |
367 | |
368 pe = pes; | |
369 for (jj=0; jj<rep.num_encodings; jj++) { | |
370 pe->encoding_id = u.pe->encoding; | |
371 pe->width = u.pe->width; | |
372 pe->height = u.pe->height; | |
373 pe->rate.numerator = u.pe->rate.numerator; | |
374 pe->rate.denominator = u.pe->rate.denominator; | |
375 pe->num_encodings = rep.num_encodings - jj; | |
376 | |
377 size = u.pe->name_size; | |
378 u.buffer += (sz_xvEncodingInfo + 3) & ~3; | |
379 | |
380 if ( (name = (char *)Xmalloc(size+1)) == NULL) { | |
381 Xfree(buffer); | |
382 UnlockDisplay(dpy); | |
383 SyncHandle(); | |
384 return(XvBadAlloc); | |
385 } | |
386 SDL_strlcpy(name, u.string, size); | |
387 pe->name = name; | |
388 pe++; | |
389 | |
390 u.buffer += (size + 3) & ~3; | |
391 } | |
392 | |
393 *p_nEncodings = rep.num_encodings; | |
394 *p_pEncodings = pes; | |
395 | |
396 Xfree(buffer); | |
397 UnlockDisplay(dpy); | |
398 SyncHandle(); | |
399 | |
400 return (Success); | |
401 } | |
402 | |
403 void | |
404 SDL_NAME(XvFreeEncodingInfo)(SDL_NAME(XvEncodingInfo) *pEncodings) | |
405 { | |
406 | |
407 SDL_NAME(XvEncodingInfo) *pe; | |
408 int ii; | |
409 | |
410 if (!pEncodings) return; | |
411 | |
412 pe = pEncodings; | |
413 | |
414 for (ii=0; ii<pEncodings->num_encodings; ii++, pe++) { | |
415 if (pe->name) Xfree(pe->name); | |
416 } | |
417 | |
418 Xfree(pEncodings); | |
419 } | 444 } |
420 | 445 |
421 int | 446 int |
422 SDL_NAME(XvPutVideo)( | 447 SDL_NAME (XvPutStill) (Display * dpy, |
423 Display *dpy, | 448 XvPortID port, |
424 XvPortID port, | 449 Drawable d, |
425 Drawable d, | 450 GC gc, |
426 GC gc, | 451 int vx, int vy, |
427 int vx, int vy, | 452 unsigned int vw, unsigned int vh, |
428 unsigned int vw, unsigned int vh, | 453 int dx, int dy, unsigned int dw, unsigned int dh) |
429 int dx, int dy, | 454 { |
430 unsigned int dw, unsigned int dh | 455 XExtDisplayInfo *info = xv_find_display (dpy); |
431 ){ | 456 xvPutStillReq *req; |
432 XExtDisplayInfo *info = xv_find_display(dpy); | 457 |
433 xvPutVideoReq *req; | 458 XvCheckExtension (dpy, info, XvBadExtension); |
434 | 459 |
435 XvCheckExtension(dpy, info, XvBadExtension); | 460 LockDisplay (dpy); |
436 | 461 |
437 LockDisplay(dpy); | 462 FlushGC (dpy, gc); |
438 | 463 |
439 FlushGC(dpy, gc); | 464 XvGetReq (PutStill, req); |
440 | 465 req->port = port; |
441 XvGetReq(PutVideo, req); | 466 req->drawable = d; |
442 | 467 req->gc = gc->gid; |
443 req->port = port; | 468 req->vid_x = vx; |
444 req->drawable = d; | 469 req->vid_y = vy; |
445 req->gc = gc->gid; | 470 req->vid_w = vw; |
446 req->vid_x = vx; | 471 req->vid_h = vh; |
447 req->vid_y = vy; | 472 req->drw_x = dx; |
448 req->vid_w = vw; | 473 req->drw_y = dy; |
449 req->vid_h = vh; | 474 req->drw_w = dw; |
450 req->drw_x = dx; | 475 req->drw_h = dh; |
451 req->drw_y = dy; | 476 |
452 req->drw_w = dw; | 477 UnlockDisplay (dpy); |
453 req->drw_h = dh; | 478 SyncHandle (); |
454 | 479 |
455 UnlockDisplay(dpy); | 480 return Success; |
456 SyncHandle(); | |
457 | |
458 return Success; | |
459 } | 481 } |
460 | 482 |
461 int | 483 int |
462 SDL_NAME(XvPutStill)( | 484 SDL_NAME (XvGetVideo) (Display * dpy, |
463 Display *dpy, | 485 XvPortID port, |
464 XvPortID port, | 486 Drawable d, |
465 Drawable d, | 487 GC gc, |
466 GC gc, | 488 int vx, int vy, |
467 int vx, int vy, | 489 unsigned int vw, unsigned int vh, |
468 unsigned int vw, unsigned int vh, | 490 int dx, int dy, unsigned int dw, unsigned int dh) |
469 int dx, int dy, | 491 { |
470 unsigned int dw, unsigned int dh | 492 XExtDisplayInfo *info = xv_find_display (dpy); |
471 ){ | 493 xvGetVideoReq *req; |
472 XExtDisplayInfo *info = xv_find_display(dpy); | 494 |
473 xvPutStillReq *req; | 495 XvCheckExtension (dpy, info, XvBadExtension); |
474 | 496 |
475 XvCheckExtension(dpy, info, XvBadExtension); | 497 LockDisplay (dpy); |
476 | 498 |
477 LockDisplay(dpy); | 499 FlushGC (dpy, gc); |
478 | 500 |
479 FlushGC(dpy, gc); | 501 XvGetReq (GetVideo, req); |
480 | 502 req->port = port; |
481 XvGetReq(PutStill, req); | 503 req->drawable = d; |
482 req->port = port; | 504 req->gc = gc->gid; |
483 req->drawable = d; | 505 req->vid_x = vx; |
484 req->gc = gc->gid; | 506 req->vid_y = vy; |
485 req->vid_x = vx; | 507 req->vid_w = vw; |
486 req->vid_y = vy; | 508 req->vid_h = vh; |
487 req->vid_w = vw; | 509 req->drw_x = dx; |
488 req->vid_h = vh; | 510 req->drw_y = dy; |
489 req->drw_x = dx; | 511 req->drw_w = dw; |
490 req->drw_y = dy; | 512 req->drw_h = dh; |
491 req->drw_w = dw; | 513 |
492 req->drw_h = dh; | 514 UnlockDisplay (dpy); |
493 | 515 SyncHandle (); |
494 UnlockDisplay(dpy); | 516 |
495 SyncHandle(); | 517 return Success; |
496 | |
497 return Success; | |
498 } | 518 } |
499 | 519 |
500 int | 520 int |
501 SDL_NAME(XvGetVideo)( | 521 SDL_NAME (XvGetStill) (Display * dpy, |
502 Display *dpy, | 522 XvPortID port, |
503 XvPortID port, | 523 Drawable d, |
504 Drawable d, | 524 GC gc, |
505 GC gc, | 525 int vx, int vy, |
506 int vx, int vy, | 526 unsigned int vw, unsigned int vh, |
507 unsigned int vw, unsigned int vh, | 527 int dx, int dy, unsigned int dw, unsigned int dh) |
508 int dx, int dy, | 528 { |
509 unsigned int dw, unsigned int dh | 529 XExtDisplayInfo *info = xv_find_display (dpy); |
510 ){ | 530 xvGetStillReq *req; |
511 XExtDisplayInfo *info = xv_find_display(dpy); | 531 |
512 xvGetVideoReq *req; | 532 XvCheckExtension (dpy, info, XvBadExtension); |
513 | 533 |
514 XvCheckExtension(dpy, info, XvBadExtension); | 534 LockDisplay (dpy); |
515 | 535 |
516 LockDisplay(dpy); | 536 FlushGC (dpy, gc); |
517 | 537 |
518 FlushGC(dpy, gc); | 538 XvGetReq (GetStill, req); |
519 | 539 req->port = port; |
520 XvGetReq(GetVideo, req); | 540 req->drawable = d; |
521 req->port = port; | 541 req->gc = gc->gid; |
522 req->drawable = d; | 542 req->vid_x = vx; |
523 req->gc = gc->gid; | 543 req->vid_y = vy; |
524 req->vid_x = vx; | 544 req->vid_w = vw; |
525 req->vid_y = vy; | 545 req->vid_h = vh; |
526 req->vid_w = vw; | 546 req->drw_x = dx; |
527 req->vid_h = vh; | 547 req->drw_y = dy; |
528 req->drw_x = dx; | 548 req->drw_w = dw; |
529 req->drw_y = dy; | 549 req->drw_h = dh; |
530 req->drw_w = dw; | 550 |
531 req->drw_h = dh; | 551 UnlockDisplay (dpy); |
532 | 552 SyncHandle (); |
533 UnlockDisplay(dpy); | 553 |
534 SyncHandle(); | 554 return Success; |
535 | 555 } |
536 return Success; | 556 |
557 int SDL_NAME (XvStopVideo) (Display * dpy, XvPortID port, Drawable draw) | |
558 { | |
559 XExtDisplayInfo *info = xv_find_display (dpy); | |
560 xvStopVideoReq *req; | |
561 | |
562 XvCheckExtension (dpy, info, XvBadExtension); | |
563 | |
564 LockDisplay (dpy); | |
565 | |
566 XvGetReq (StopVideo, req); | |
567 req->port = port; | |
568 req->drawable = draw; | |
569 | |
570 UnlockDisplay (dpy); | |
571 SyncHandle (); | |
572 | |
573 return Success; | |
574 } | |
575 | |
576 int SDL_NAME (XvGrabPort) (Display * dpy, XvPortID port, Time time) | |
577 { | |
578 XExtDisplayInfo *info = xv_find_display (dpy); | |
579 int result; | |
580 xvGrabPortReply rep; | |
581 xvGrabPortReq *req; | |
582 | |
583 XvCheckExtension (dpy, info, XvBadExtension); | |
584 | |
585 LockDisplay (dpy); | |
586 | |
587 XvGetReq (GrabPort, req); | |
588 req->port = port; | |
589 req->time = time; | |
590 | |
591 if (_XReply (dpy, (xReply *) & rep, 0, xTrue) == 0) | |
592 rep.result = GrabSuccess; | |
593 | |
594 result = rep.result; | |
595 | |
596 UnlockDisplay (dpy); | |
597 SyncHandle (); | |
598 | |
599 return result; | |
600 } | |
601 | |
602 int SDL_NAME (XvUngrabPort) (Display * dpy, XvPortID port, Time time) | |
603 { | |
604 XExtDisplayInfo *info = xv_find_display (dpy); | |
605 xvUngrabPortReq *req; | |
606 | |
607 XvCheckExtension (dpy, info, XvBadExtension); | |
608 | |
609 LockDisplay (dpy); | |
610 | |
611 XvGetReq (UngrabPort, req); | |
612 req->port = port; | |
613 req->time = time; | |
614 | |
615 UnlockDisplay (dpy); | |
616 SyncHandle (); | |
617 | |
618 return Success; | |
537 } | 619 } |
538 | 620 |
539 int | 621 int |
540 SDL_NAME(XvGetStill)( | 622 SDL_NAME (XvSelectVideoNotify) (Display * dpy, Drawable drawable, Bool onoff) |
541 Display *dpy, | 623 { |
542 XvPortID port, | 624 XExtDisplayInfo *info = xv_find_display (dpy); |
543 Drawable d, | 625 xvSelectVideoNotifyReq *req; |
544 GC gc, | 626 |
545 int vx, int vy, | 627 XvCheckExtension (dpy, info, XvBadExtension); |
546 unsigned int vw, unsigned int vh, | 628 |
547 int dx, int dy, | 629 LockDisplay (dpy); |
548 unsigned int dw, unsigned int dh | 630 |
549 ){ | 631 XvGetReq (SelectVideoNotify, req); |
550 XExtDisplayInfo *info = xv_find_display(dpy); | 632 req->drawable = drawable; |
551 xvGetStillReq *req; | 633 req->onoff = onoff; |
552 | 634 |
553 XvCheckExtension(dpy, info, XvBadExtension); | 635 UnlockDisplay (dpy); |
554 | 636 SyncHandle (); |
555 LockDisplay(dpy); | 637 |
556 | 638 return Success; |
557 FlushGC(dpy, gc); | 639 } |
558 | 640 |
559 XvGetReq(GetStill, req); | 641 int SDL_NAME (XvSelectPortNotify) (Display * dpy, XvPortID port, Bool onoff) |
560 req->port = port; | 642 { |
561 req->drawable = d; | 643 XExtDisplayInfo *info = xv_find_display (dpy); |
562 req->gc = gc->gid; | 644 xvSelectPortNotifyReq *req; |
563 req->vid_x = vx; | 645 |
564 req->vid_y = vy; | 646 XvCheckExtension (dpy, info, XvBadExtension); |
565 req->vid_w = vw; | 647 |
566 req->vid_h = vh; | 648 LockDisplay (dpy); |
567 req->drw_x = dx; | 649 |
568 req->drw_y = dy; | 650 XvGetReq (SelectPortNotify, req); |
569 req->drw_w = dw; | 651 req->port = port; |
570 req->drw_h = dh; | 652 req->onoff = onoff; |
571 | 653 |
572 UnlockDisplay(dpy); | 654 UnlockDisplay (dpy); |
573 SyncHandle(); | 655 SyncHandle (); |
574 | 656 |
575 return Success; | 657 return Success; |
576 } | 658 } |
577 | 659 |
578 int | 660 int |
579 SDL_NAME(XvStopVideo)( | 661 SDL_NAME (XvSetPortAttribute) (Display * dpy, |
580 Display *dpy, | 662 XvPortID port, Atom attribute, int value) |
581 XvPortID port, | 663 { |
582 Drawable draw | 664 XExtDisplayInfo *info = xv_find_display (dpy); |
583 ){ | 665 xvSetPortAttributeReq *req; |
584 XExtDisplayInfo *info = xv_find_display(dpy); | 666 |
585 xvStopVideoReq *req; | 667 XvCheckExtension (dpy, info, XvBadExtension); |
586 | 668 |
587 XvCheckExtension(dpy, info, XvBadExtension); | 669 LockDisplay (dpy); |
588 | 670 |
589 LockDisplay(dpy); | 671 XvGetReq (SetPortAttribute, req); |
590 | 672 req->port = port; |
591 XvGetReq(StopVideo, req); | 673 req->attribute = attribute; |
592 req->port = port; | 674 req->value = value; |
593 req->drawable = draw; | 675 |
594 | 676 UnlockDisplay (dpy); |
595 UnlockDisplay(dpy); | 677 SyncHandle (); |
596 SyncHandle(); | 678 |
597 | 679 return (Success); |
598 return Success; | |
599 } | 680 } |
600 | 681 |
601 int | 682 int |
602 SDL_NAME(XvGrabPort)( | 683 SDL_NAME (XvGetPortAttribute) (Display * dpy, |
603 Display *dpy, | 684 XvPortID port, Atom attribute, int *p_value) |
604 XvPortID port, | 685 { |
605 Time time | 686 XExtDisplayInfo *info = xv_find_display (dpy); |
606 ){ | 687 xvGetPortAttributeReq *req; |
607 XExtDisplayInfo *info = xv_find_display(dpy); | 688 xvGetPortAttributeReply rep; |
608 int result; | 689 |
609 xvGrabPortReply rep; | 690 XvCheckExtension (dpy, info, XvBadExtension); |
610 xvGrabPortReq *req; | 691 |
611 | 692 LockDisplay (dpy); |
612 XvCheckExtension(dpy, info, XvBadExtension); | 693 |
613 | 694 XvGetReq (GetPortAttribute, req); |
614 LockDisplay(dpy); | 695 req->port = port; |
615 | 696 req->attribute = attribute; |
616 XvGetReq(GrabPort, req); | 697 |
617 req->port = port; | 698 /* READ THE REPLY */ |
618 req->time = time; | 699 |
619 | 700 if (_XReply (dpy, (xReply *) & rep, 0, xFalse) == 0) { |
620 if (_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0) | 701 UnlockDisplay (dpy); |
621 rep.result = GrabSuccess; | 702 SyncHandle (); |
622 | 703 return (XvBadReply); |
623 result = rep.result; | 704 } |
624 | 705 |
625 UnlockDisplay(dpy); | 706 *p_value = rep.value; |
626 SyncHandle(); | 707 |
627 | 708 UnlockDisplay (dpy); |
628 return result; | 709 SyncHandle (); |
710 | |
711 return (Success); | |
629 } | 712 } |
630 | 713 |
631 int | 714 int |
632 SDL_NAME(XvUngrabPort)( | 715 SDL_NAME (XvQueryBestSize) (Display * dpy, |
633 Display *dpy, | 716 XvPortID port, |
634 XvPortID port, | 717 Bool motion, |
635 Time time | 718 unsigned int vid_w, |
636 ){ | 719 unsigned int vid_h, |
637 XExtDisplayInfo *info = xv_find_display(dpy); | 720 unsigned int drw_w, |
638 xvUngrabPortReq *req; | 721 unsigned int drw_h, |
639 | 722 unsigned int *p_actual_width, |
640 XvCheckExtension(dpy, info, XvBadExtension); | 723 unsigned int *p_actual_height) |
641 | 724 { |
642 LockDisplay(dpy); | 725 XExtDisplayInfo *info = xv_find_display (dpy); |
643 | 726 xvQueryBestSizeReq *req; |
644 XvGetReq(UngrabPort, req); | 727 xvQueryBestSizeReply rep; |
645 req->port = port; | 728 |
646 req->time = time; | 729 XvCheckExtension (dpy, info, XvBadExtension); |
647 | 730 |
648 UnlockDisplay(dpy); | 731 LockDisplay (dpy); |
649 SyncHandle(); | 732 |
650 | 733 XvGetReq (QueryBestSize, req); |
651 return Success; | 734 req->port = port; |
652 } | 735 req->motion = motion; |
653 | 736 req->vid_w = vid_w; |
654 int | 737 req->vid_h = vid_h; |
655 SDL_NAME(XvSelectVideoNotify)( | 738 req->drw_w = drw_w; |
656 Display *dpy, | 739 req->drw_h = drw_h; |
657 Drawable drawable, | 740 |
658 Bool onoff | 741 /* READ THE REPLY */ |
659 ){ | 742 |
660 XExtDisplayInfo *info = xv_find_display(dpy); | 743 if (_XReply (dpy, (xReply *) & rep, 0, xFalse) == 0) { |
661 xvSelectVideoNotifyReq *req; | 744 UnlockDisplay (dpy); |
662 | 745 SyncHandle (); |
663 XvCheckExtension(dpy, info, XvBadExtension); | 746 return (XvBadReply); |
664 | 747 } |
665 LockDisplay(dpy); | 748 |
666 | 749 *p_actual_width = rep.actual_width; |
667 XvGetReq(SelectVideoNotify, req); | 750 *p_actual_height = rep.actual_height; |
668 req->drawable = drawable; | 751 |
669 req->onoff = onoff; | 752 UnlockDisplay (dpy); |
670 | 753 SyncHandle (); |
671 UnlockDisplay(dpy); | 754 |
672 SyncHandle(); | 755 return (Success); |
673 | 756 } |
674 return Success; | 757 |
675 } | 758 |
676 | 759 SDL_NAME (XvAttribute) * |
677 int | 760 SDL_NAME (XvQueryPortAttributes) (Display * dpy, XvPortID port, int *num) |
678 SDL_NAME(XvSelectPortNotify)( | 761 { |
679 Display *dpy, | 762 XExtDisplayInfo *info = xv_find_display (dpy); |
680 XvPortID port, | 763 xvQueryPortAttributesReq *req; |
681 Bool onoff | 764 xvQueryPortAttributesReply rep; |
682 ){ | 765 SDL_NAME (XvAttribute) * ret = NULL; |
683 XExtDisplayInfo *info = xv_find_display(dpy); | 766 |
684 xvSelectPortNotifyReq *req; | 767 *num = 0; |
685 | 768 |
686 XvCheckExtension(dpy, info, XvBadExtension); | 769 XvCheckExtension (dpy, info, NULL); |
687 | 770 |
688 LockDisplay(dpy); | 771 LockDisplay (dpy); |
689 | 772 |
690 XvGetReq(SelectPortNotify, req); | 773 XvGetReq (QueryPortAttributes, req); |
691 req->port = port; | 774 req->port = port; |
692 req->onoff = onoff; | 775 |
693 | 776 /* READ THE REPLY */ |
694 UnlockDisplay(dpy); | 777 |
695 SyncHandle(); | 778 if (_XReply (dpy, (xReply *) & rep, 0, xFalse) == 0) { |
696 | 779 UnlockDisplay (dpy); |
697 return Success; | 780 SyncHandle (); |
698 } | 781 return ret; |
699 | 782 } |
700 int | 783 |
701 SDL_NAME(XvSetPortAttribute) ( | 784 if (rep.num_attributes) { |
702 Display *dpy, | 785 int size = |
703 XvPortID port, | 786 (rep.num_attributes * sizeof (SDL_NAME (XvAttribute))) + |
704 Atom attribute, | 787 rep.text_size; |
705 int value | 788 |
706 ) | 789 if ((ret = Xmalloc (size))) { |
707 { | 790 char *marker = (char *) (&ret[rep.num_attributes]); |
708 XExtDisplayInfo *info = xv_find_display(dpy); | 791 xvAttributeInfo Info; |
709 xvSetPortAttributeReq *req; | 792 int i; |
710 | 793 |
711 XvCheckExtension(dpy, info, XvBadExtension); | 794 for (i = 0; i < rep.num_attributes; i++) { |
712 | 795 _XRead (dpy, (char *) (&Info), sz_xvAttributeInfo); |
713 LockDisplay(dpy); | 796 ret[i].flags = (int) Info.flags; |
714 | 797 ret[i].min_value = Info.min; |
715 XvGetReq(SetPortAttribute, req); | 798 ret[i].max_value = Info.max; |
716 req->port = port; | 799 ret[i].name = marker; |
717 req->attribute = attribute; | 800 _XRead (dpy, marker, Info.size); |
718 req->value = value; | 801 marker += Info.size; |
719 | 802 (*num)++; |
720 UnlockDisplay(dpy); | 803 } |
721 SyncHandle(); | 804 } else |
722 | 805 _XEatData (dpy, rep.length << 2); |
723 return (Success); | 806 } |
724 } | 807 |
725 | 808 UnlockDisplay (dpy); |
726 int | 809 SyncHandle (); |
727 SDL_NAME(XvGetPortAttribute) ( | 810 |
728 Display *dpy, | 811 return ret; |
729 XvPortID port, | 812 } |
730 Atom attribute, | 813 |
731 int *p_value | 814 SDL_NAME (XvImageFormatValues) * SDL_NAME (XvListImageFormats) (Display * dpy, |
732 ) | 815 XvPortID port, |
733 { | 816 int *num) |
734 XExtDisplayInfo *info = xv_find_display(dpy); | 817 { |
735 xvGetPortAttributeReq *req; | 818 XExtDisplayInfo *info = xv_find_display (dpy); |
736 xvGetPortAttributeReply rep; | 819 xvListImageFormatsReq *req; |
737 | 820 xvListImageFormatsReply rep; |
738 XvCheckExtension(dpy, info, XvBadExtension); | 821 SDL_NAME (XvImageFormatValues) * ret = NULL; |
739 | 822 |
740 LockDisplay(dpy); | 823 *num = 0; |
741 | 824 |
742 XvGetReq(GetPortAttribute, req); | 825 XvCheckExtension (dpy, info, NULL); |
743 req->port = port; | 826 |
744 req->attribute = attribute; | 827 LockDisplay (dpy); |
745 | 828 |
746 /* READ THE REPLY */ | 829 XvGetReq (ListImageFormats, req); |
747 | 830 req->port = port; |
748 if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) { | 831 |
749 UnlockDisplay(dpy); | 832 /* READ THE REPLY */ |
750 SyncHandle(); | 833 |
751 return(XvBadReply); | 834 if (_XReply (dpy, (xReply *) & rep, 0, xFalse) == 0) { |
752 } | 835 UnlockDisplay (dpy); |
753 | 836 SyncHandle (); |
754 *p_value = rep.value; | 837 return NULL; |
755 | 838 } |
756 UnlockDisplay(dpy); | 839 |
757 SyncHandle(); | 840 if (rep.num_formats) { |
758 | 841 int size = |
759 return (Success); | 842 (rep.num_formats * sizeof (SDL_NAME (XvImageFormatValues))); |
760 } | 843 |
761 | 844 if ((ret = Xmalloc (size))) { |
762 int | 845 xvImageFormatInfo Info; |
763 SDL_NAME(XvQueryBestSize)( | 846 int i; |
764 Display *dpy, | 847 |
765 XvPortID port, | 848 for (i = 0; i < rep.num_formats; i++) { |
766 Bool motion, | 849 _XRead (dpy, (char *) (&Info), sz_xvImageFormatInfo); |
767 unsigned int vid_w, | 850 ret[i].id = Info.id; |
768 unsigned int vid_h, | 851 ret[i].type = Info.type; |
769 unsigned int drw_w, | 852 ret[i].byte_order = Info.byte_order; |
770 unsigned int drw_h, | 853 memcpy (&(ret[i].guid[0]), &(Info.guid[0]), 16); |
771 unsigned int *p_actual_width, | 854 ret[i].bits_per_pixel = Info.bpp; |
772 unsigned int *p_actual_height | 855 ret[i].format = Info.format; |
773 ) | 856 ret[i].num_planes = Info.num_planes; |
774 { | 857 ret[i].depth = Info.depth; |
775 XExtDisplayInfo *info = xv_find_display(dpy); | 858 ret[i].red_mask = Info.red_mask; |
776 xvQueryBestSizeReq *req; | 859 ret[i].green_mask = Info.green_mask; |
777 xvQueryBestSizeReply rep; | 860 ret[i].blue_mask = Info.blue_mask; |
778 | 861 ret[i].y_sample_bits = Info.y_sample_bits; |
779 XvCheckExtension(dpy, info, XvBadExtension); | 862 ret[i].u_sample_bits = Info.u_sample_bits; |
780 | 863 ret[i].v_sample_bits = Info.v_sample_bits; |
781 LockDisplay(dpy); | 864 ret[i].horz_y_period = Info.horz_y_period; |
782 | 865 ret[i].horz_u_period = Info.horz_u_period; |
783 XvGetReq(QueryBestSize, req); | 866 ret[i].horz_v_period = Info.horz_v_period; |
784 req->port = port; | 867 ret[i].vert_y_period = Info.vert_y_period; |
785 req->motion = motion; | 868 ret[i].vert_u_period = Info.vert_u_period; |
786 req->vid_w = vid_w; | 869 ret[i].vert_v_period = Info.vert_v_period; |
787 req->vid_h = vid_h; | 870 memcpy (&(ret[i].component_order[0]), |
788 req->drw_w = drw_w; | 871 &(Info.comp_order[0]), 32); |
789 req->drw_h = drw_h; | 872 ret[i].scanline_order = Info.scanline_order; |
790 | 873 (*num)++; |
791 /* READ THE REPLY */ | 874 } |
792 | 875 } else |
793 if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) { | 876 _XEatData (dpy, rep.length << 2); |
794 UnlockDisplay(dpy); | 877 } |
795 SyncHandle(); | 878 |
796 return(XvBadReply); | 879 UnlockDisplay (dpy); |
797 } | 880 SyncHandle (); |
798 | 881 |
799 *p_actual_width = rep.actual_width; | 882 return ret; |
800 *p_actual_height = rep.actual_height; | 883 } |
801 | 884 |
802 UnlockDisplay(dpy); | 885 SDL_NAME (XvImage) * SDL_NAME (XvCreateImage) (Display * dpy, |
803 SyncHandle(); | 886 XvPortID port, |
804 | 887 int id, |
805 return (Success); | 888 char *data, |
806 } | 889 int width, int height) |
807 | 890 { |
808 | 891 XExtDisplayInfo *info = xv_find_display (dpy); |
809 SDL_NAME(XvAttribute)* | 892 xvQueryImageAttributesReq *req; |
810 SDL_NAME(XvQueryPortAttributes)(Display *dpy, XvPortID port, int *num) | 893 xvQueryImageAttributesReply rep; |
811 { | 894 SDL_NAME (XvImage) * ret = NULL; |
812 XExtDisplayInfo *info = xv_find_display(dpy); | 895 |
813 xvQueryPortAttributesReq *req; | 896 XvCheckExtension (dpy, info, NULL); |
814 xvQueryPortAttributesReply rep; | 897 |
815 SDL_NAME(XvAttribute) *ret = NULL; | 898 LockDisplay (dpy); |
816 | 899 |
817 *num = 0; | 900 XvGetReq (QueryImageAttributes, req); |
818 | 901 req->id = id; |
819 XvCheckExtension(dpy, info, NULL); | 902 req->port = port; |
820 | 903 req->width = width; |
821 LockDisplay(dpy); | 904 req->height = height; |
822 | 905 |
823 XvGetReq(QueryPortAttributes, req); | 906 /* READ THE REPLY */ |
824 req->port = port; | 907 |
825 | 908 if (!_XReply (dpy, (xReply *) & rep, 0, xFalse)) { |
826 /* READ THE REPLY */ | 909 UnlockDisplay (dpy); |
827 | 910 SyncHandle (); |
828 if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) { | 911 return NULL; |
829 UnlockDisplay(dpy); | 912 } |
830 SyncHandle(); | 913 |
831 return ret; | 914 if ((ret = |
832 } | 915 (SDL_NAME (XvImage) *) Xmalloc (sizeof (SDL_NAME (XvImage)) + |
833 | 916 (rep.num_planes << 3)))) { |
834 if(rep.num_attributes) { | 917 ret->id = id; |
835 int size = (rep.num_attributes * sizeof(SDL_NAME(XvAttribute))) + rep.text_size; | 918 ret->width = rep.width; |
836 | 919 ret->height = rep.height; |
837 if((ret = Xmalloc(size))) { | 920 ret->data_size = rep.data_size; |
838 char* marker = (char*)(&ret[rep.num_attributes]); | 921 ret->num_planes = rep.num_planes; |
839 xvAttributeInfo Info; | 922 ret->pitches = (int *) (&ret[1]); |
840 int i; | 923 ret->offsets = ret->pitches + rep.num_planes; |
841 | 924 ret->data = data; |
842 for(i = 0; i < rep.num_attributes; i++) { | 925 ret->obdata = NULL; |
843 _XRead(dpy, (char*)(&Info), sz_xvAttributeInfo); | 926 _XRead (dpy, (char *) (ret->pitches), rep.num_planes << 2); |
844 ret[i].flags = (int)Info.flags; | 927 _XRead (dpy, (char *) (ret->offsets), rep.num_planes << 2); |
845 ret[i].min_value = Info.min; | 928 } else |
846 ret[i].max_value = Info.max; | 929 _XEatData (dpy, rep.length << 2); |
847 ret[i].name = marker; | 930 |
848 _XRead(dpy, marker, Info.size); | 931 UnlockDisplay (dpy); |
849 marker += Info.size; | 932 SyncHandle (); |
850 (*num)++; | 933 return ret; |
851 } | 934 } |
852 } else | 935 |
853 _XEatData(dpy, rep.length << 2); | 936 SDL_NAME (XvImage) * SDL_NAME (XvShmCreateImage) (Display * dpy, |
854 } | 937 XvPortID port, |
855 | 938 int id, |
856 UnlockDisplay(dpy); | 939 char *data, |
857 SyncHandle(); | 940 int width, |
858 | 941 int height, |
859 return ret; | 942 XShmSegmentInfo * shminfo) |
860 } | 943 { |
861 | 944 SDL_NAME (XvImage) * ret; |
862 SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) ( | 945 |
863 Display *dpy, | 946 ret = SDL_NAME (XvCreateImage) (dpy, port, id, data, width, height); |
864 XvPortID port, | 947 |
865 int *num | 948 if (ret) |
866 ){ | 949 ret->obdata = (XPointer) shminfo; |
867 XExtDisplayInfo *info = xv_find_display(dpy); | 950 |
868 xvListImageFormatsReq *req; | 951 return ret; |
869 xvListImageFormatsReply rep; | 952 } |
870 SDL_NAME(XvImageFormatValues) *ret = NULL; | 953 |
871 | 954 int SDL_NAME (XvPutImage) (Display * dpy, |
872 *num = 0; | 955 XvPortID port, |
873 | 956 Drawable d, |
874 XvCheckExtension(dpy, info, NULL); | 957 GC gc, |
875 | 958 SDL_NAME (XvImage) * image, |
876 LockDisplay(dpy); | 959 int src_x, |
877 | 960 int src_y, |
878 XvGetReq(ListImageFormats, req); | 961 unsigned int src_w, |
879 req->port = port; | 962 unsigned int src_h, |
880 | 963 int dest_x, |
881 /* READ THE REPLY */ | 964 int dest_y, |
882 | 965 unsigned int dest_w, unsigned int dest_h) |
883 if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) { | 966 { |
884 UnlockDisplay(dpy); | 967 XExtDisplayInfo *info = xv_find_display (dpy); |
885 SyncHandle(); | 968 xvPutImageReq *req; |
886 return NULL; | 969 int len; |
887 } | 970 |
888 | 971 XvCheckExtension (dpy, info, XvBadExtension); |
889 if(rep.num_formats) { | 972 |
890 int size = (rep.num_formats * sizeof(SDL_NAME(XvImageFormatValues))); | 973 LockDisplay (dpy); |
891 | 974 |
892 if((ret = Xmalloc(size))) { | 975 FlushGC (dpy, gc); |
893 xvImageFormatInfo Info; | 976 |
894 int i; | 977 XvGetReq (PutImage, req); |
895 | 978 |
896 for(i = 0; i < rep.num_formats; i++) { | 979 req->port = port; |
897 _XRead(dpy, (char*)(&Info), sz_xvImageFormatInfo); | 980 req->drawable = d; |
898 ret[i].id = Info.id; | 981 req->gc = gc->gid; |
899 ret[i].type = Info.type; | 982 req->id = image->id; |
900 ret[i].byte_order = Info.byte_order; | 983 req->src_x = src_x; |
901 memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16); | 984 req->src_y = src_y; |
902 ret[i].bits_per_pixel = Info.bpp; | 985 req->src_w = src_w; |
903 ret[i].format = Info.format; | 986 req->src_h = src_h; |
904 ret[i].num_planes = Info.num_planes; | 987 req->drw_x = dest_x; |
905 ret[i].depth = Info.depth; | 988 req->drw_y = dest_y; |
906 ret[i].red_mask = Info.red_mask; | 989 req->drw_w = dest_w; |
907 ret[i].green_mask = Info.green_mask; | 990 req->drw_h = dest_h; |
908 ret[i].blue_mask = Info.blue_mask; | 991 req->width = image->width; |
909 ret[i].y_sample_bits = Info.y_sample_bits; | 992 req->height = image->height; |
910 ret[i].u_sample_bits = Info.u_sample_bits; | 993 |
911 ret[i].v_sample_bits = Info.v_sample_bits; | 994 len = (image->data_size + 3) >> 2; |
912 ret[i].horz_y_period = Info.horz_y_period; | 995 SetReqLen (req, len, len); |
913 ret[i].horz_u_period = Info.horz_u_period; | 996 |
914 ret[i].horz_v_period = Info.horz_v_period; | 997 /* Yes it's kindof lame that we are sending the whole thing, |
915 ret[i].vert_y_period = Info.vert_y_period; | 998 but for video all of it may be needed even if displaying |
916 ret[i].vert_u_period = Info.vert_u_period; | 999 only a subsection, and I don't want to go through the |
917 ret[i].vert_v_period = Info.vert_v_period; | 1000 trouble of creating subregions to send */ |
918 memcpy(&(ret[i].component_order[0]), &(Info.comp_order[0]), 32); | 1001 Data (dpy, (char *) image->data, image->data_size); |
919 ret[i].scanline_order = Info.scanline_order; | 1002 |
920 (*num)++; | 1003 UnlockDisplay (dpy); |
921 } | 1004 SyncHandle (); |
922 } else | 1005 |
923 _XEatData(dpy, rep.length << 2); | 1006 return Success; |
924 } | 1007 } |
925 | 1008 |
926 UnlockDisplay(dpy); | 1009 int SDL_NAME (XvShmPutImage) (Display * dpy, |
927 SyncHandle(); | 1010 XvPortID port, |
928 | 1011 Drawable d, |
929 return ret; | 1012 GC gc, |
930 } | 1013 SDL_NAME (XvImage) * image, |
931 | 1014 int src_x, |
932 SDL_NAME(XvImage) * SDL_NAME(XvCreateImage) ( | 1015 int src_y, |
933 Display *dpy, | 1016 unsigned int src_w, |
934 XvPortID port, | 1017 unsigned int src_h, |
935 int id, | 1018 int dest_x, |
936 char *data, | 1019 int dest_y, |
937 int width, | 1020 unsigned int dest_w, |
938 int height | 1021 unsigned int dest_h, Bool send_event) |
939 ) { | 1022 { |
940 XExtDisplayInfo *info = xv_find_display(dpy); | 1023 XExtDisplayInfo *info = xv_find_display (dpy); |
941 xvQueryImageAttributesReq *req; | 1024 XShmSegmentInfo *shminfo = (XShmSegmentInfo *) image->obdata; |
942 xvQueryImageAttributesReply rep; | 1025 xvShmPutImageReq *req; |
943 SDL_NAME(XvImage) *ret = NULL; | 1026 |
944 | 1027 XvCheckExtension (dpy, info, XvBadExtension); |
945 XvCheckExtension(dpy, info, NULL); | 1028 |
946 | 1029 LockDisplay (dpy); |
947 LockDisplay(dpy); | 1030 |
948 | 1031 FlushGC (dpy, gc); |
949 XvGetReq(QueryImageAttributes, req); | 1032 |
950 req->id = id; | 1033 XvGetReq (ShmPutImage, req); |
951 req->port = port; | 1034 |
952 req->width = width; | 1035 req->port = port; |
953 req->height = height; | 1036 req->drawable = d; |
954 | 1037 req->gc = gc->gid; |
955 /* READ THE REPLY */ | 1038 req->shmseg = shminfo->shmseg; |
956 | 1039 req->id = image->id; |
957 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { | 1040 req->src_x = src_x; |
958 UnlockDisplay(dpy); | 1041 req->src_y = src_y; |
959 SyncHandle(); | 1042 req->src_w = src_w; |
960 return NULL; | 1043 req->src_h = src_h; |
961 } | 1044 req->drw_x = dest_x; |
962 | 1045 req->drw_y = dest_y; |
963 if((ret = (SDL_NAME(XvImage)*)Xmalloc(sizeof(SDL_NAME(XvImage)) + (rep.num_planes << 3)))) { | 1046 req->drw_w = dest_w; |
964 ret->id = id; | 1047 req->drw_h = dest_h; |
965 ret->width = rep.width; | 1048 req->offset = image->data - shminfo->shmaddr; |
966 ret->height = rep.height; | 1049 req->width = image->width; |
967 ret->data_size = rep.data_size; | 1050 req->height = image->height; |
968 ret->num_planes = rep.num_planes; | 1051 req->send_event = send_event; |
969 ret->pitches = (int*)(&ret[1]); | 1052 |
970 ret->offsets = ret->pitches + rep.num_planes; | 1053 UnlockDisplay (dpy); |
971 ret->data = data; | 1054 SyncHandle (); |
972 ret->obdata = NULL; | 1055 |
973 _XRead(dpy, (char*)(ret->pitches), rep.num_planes << 2); | 1056 return Success; |
974 _XRead(dpy, (char*)(ret->offsets), rep.num_planes << 2); | |
975 } else | |
976 _XEatData(dpy, rep.length << 2); | |
977 | |
978 UnlockDisplay(dpy); | |
979 SyncHandle(); | |
980 return ret; | |
981 } | |
982 | |
983 SDL_NAME(XvImage) * SDL_NAME(XvShmCreateImage) ( | |
984 Display *dpy, | |
985 XvPortID port, | |
986 int id, | |
987 char *data, | |
988 int width, | |
989 int height, | |
990 XShmSegmentInfo *shminfo | |
991 ){ | |
992 SDL_NAME(XvImage) *ret; | |
993 | |
994 ret = SDL_NAME(XvCreateImage)(dpy, port, id, data, width, height); | |
995 | |
996 if(ret) ret->obdata = (XPointer)shminfo; | |
997 | |
998 return ret; | |
999 } | |
1000 | |
1001 int SDL_NAME(XvPutImage) ( | |
1002 Display *dpy, | |
1003 XvPortID port, | |
1004 Drawable d, | |
1005 GC gc, | |
1006 SDL_NAME(XvImage) *image, | |
1007 int src_x, | |
1008 int src_y, | |
1009 unsigned int src_w, | |
1010 unsigned int src_h, | |
1011 int dest_x, | |
1012 int dest_y, | |
1013 unsigned int dest_w, | |
1014 unsigned int dest_h | |
1015 ){ | |
1016 XExtDisplayInfo *info = xv_find_display(dpy); | |
1017 xvPutImageReq *req; | |
1018 int len; | |
1019 | |
1020 XvCheckExtension(dpy, info, XvBadExtension); | |
1021 | |
1022 LockDisplay(dpy); | |
1023 | |
1024 FlushGC(dpy, gc); | |
1025 | |
1026 XvGetReq(PutImage, req); | |
1027 | |
1028 req->port = port; | |
1029 req->drawable = d; | |
1030 req->gc = gc->gid; | |
1031 req->id = image->id; | |
1032 req->src_x = src_x; | |
1033 req->src_y = src_y; | |
1034 req->src_w = src_w; | |
1035 req->src_h = src_h; | |
1036 req->drw_x = dest_x; | |
1037 req->drw_y = dest_y; | |
1038 req->drw_w = dest_w; | |
1039 req->drw_h = dest_h; | |
1040 req->width = image->width; | |
1041 req->height = image->height; | |
1042 | |
1043 len = (image->data_size + 3) >> 2; | |
1044 SetReqLen(req, len, len); | |
1045 | |
1046 /* Yes it's kindof lame that we are sending the whole thing, | |
1047 but for video all of it may be needed even if displaying | |
1048 only a subsection, and I don't want to go through the | |
1049 trouble of creating subregions to send */ | |
1050 Data(dpy, (char *)image->data, image->data_size); | |
1051 | |
1052 UnlockDisplay(dpy); | |
1053 SyncHandle(); | |
1054 | |
1055 return Success; | |
1056 } | |
1057 | |
1058 int SDL_NAME(XvShmPutImage) ( | |
1059 Display *dpy, | |
1060 XvPortID port, | |
1061 Drawable d, | |
1062 GC gc, | |
1063 SDL_NAME(XvImage) *image, | |
1064 int src_x, | |
1065 int src_y, | |
1066 unsigned int src_w, | |
1067 unsigned int src_h, | |
1068 int dest_x, | |
1069 int dest_y, | |
1070 unsigned int dest_w, | |
1071 unsigned int dest_h, | |
1072 Bool send_event | |
1073 ){ | |
1074 XExtDisplayInfo *info = xv_find_display(dpy); | |
1075 XShmSegmentInfo *shminfo = (XShmSegmentInfo *)image->obdata; | |
1076 xvShmPutImageReq *req; | |
1077 | |
1078 XvCheckExtension(dpy, info, XvBadExtension); | |
1079 | |
1080 LockDisplay(dpy); | |
1081 | |
1082 FlushGC(dpy, gc); | |
1083 | |
1084 XvGetReq(ShmPutImage, req); | |
1085 | |
1086 req->port = port; | |
1087 req->drawable = d; | |
1088 req->gc = gc->gid; | |
1089 req->shmseg = shminfo->shmseg; | |
1090 req->id = image->id; | |
1091 req->src_x = src_x; | |
1092 req->src_y = src_y; | |
1093 req->src_w = src_w; | |
1094 req->src_h = src_h; | |
1095 req->drw_x = dest_x; | |
1096 req->drw_y = dest_y; | |
1097 req->drw_w = dest_w; | |
1098 req->drw_h = dest_h; | |
1099 req->offset = image->data - shminfo->shmaddr; | |
1100 req->width = image->width; | |
1101 req->height = image->height; | |
1102 req->send_event = send_event; | |
1103 | |
1104 UnlockDisplay(dpy); | |
1105 SyncHandle(); | |
1106 | |
1107 return Success; | |
1108 } | 1057 } |
1109 | 1058 |
1110 | 1059 |
1111 static Bool | 1060 static Bool |
1112 xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire) | 1061 xv_wire_to_event (Display * dpy, XEvent * host, xEvent * wire) |
1113 { | 1062 { |
1114 XExtDisplayInfo *info = xv_find_display(dpy); | 1063 XExtDisplayInfo *info = xv_find_display (dpy); |
1115 SDL_NAME(XvEvent) *re = (SDL_NAME(XvEvent) *)host; | 1064 SDL_NAME (XvEvent) * re = (SDL_NAME (XvEvent) *) host; |
1116 xvEvent *event = (xvEvent *)wire; | 1065 xvEvent *event = (xvEvent *) wire; |
1117 | 1066 |
1118 XvCheckExtension(dpy, info, False); | 1067 XvCheckExtension (dpy, info, False); |
1119 | 1068 |
1120 switch((event->u.u.type & 0x7F) - info->codes->first_event) | 1069 switch ((event->u.u.type & 0x7F) - info->codes->first_event) { |
1121 { | |
1122 case XvVideoNotify: | 1070 case XvVideoNotify: |
1123 re->xvvideo.type = event->u.u.type & 0x7f; | 1071 re->xvvideo.type = event->u.u.type & 0x7f; |
1124 re->xvvideo.serial = | 1072 re->xvvideo.serial = |
1125 _XSetLastRequestRead(dpy, (xGenericReply *)event); | 1073 _XSetLastRequestRead (dpy, (xGenericReply *) event); |
1126 re->xvvideo.send_event = ((event->u.u.type & 0x80) != 0); | 1074 re->xvvideo.send_event = ((event->u.u.type & 0x80) != 0); |
1127 re->xvvideo.display = dpy; | 1075 re->xvvideo.display = dpy; |
1128 re->xvvideo.time = event->u.videoNotify.time; | 1076 re->xvvideo.time = event->u.videoNotify.time; |
1129 re->xvvideo.reason = event->u.videoNotify.reason; | 1077 re->xvvideo.reason = event->u.videoNotify.reason; |
1130 re->xvvideo.drawable = event->u.videoNotify.drawable; | 1078 re->xvvideo.drawable = event->u.videoNotify.drawable; |
1131 re->xvvideo.port_id = event->u.videoNotify.port; | 1079 re->xvvideo.port_id = event->u.videoNotify.port; |
1132 break; | 1080 break; |
1133 case XvPortNotify: | 1081 case XvPortNotify: |
1134 re->xvport.type = event->u.u.type & 0x7f; | 1082 re->xvport.type = event->u.u.type & 0x7f; |
1135 re->xvport.serial = | 1083 re->xvport.serial = |
1136 _XSetLastRequestRead(dpy, (xGenericReply *)event); | 1084 _XSetLastRequestRead (dpy, (xGenericReply *) event); |
1137 re->xvport.send_event = ((event->u.u.type & 0x80) != 0); | 1085 re->xvport.send_event = ((event->u.u.type & 0x80) != 0); |
1138 re->xvport.display = dpy; | 1086 re->xvport.display = dpy; |
1139 re->xvport.time = event->u.portNotify.time; | 1087 re->xvport.time = event->u.portNotify.time; |
1140 re->xvport.port_id = event->u.portNotify.port; | 1088 re->xvport.port_id = event->u.portNotify.port; |
1141 re->xvport.attribute = event->u.portNotify.attribute; | 1089 re->xvport.attribute = event->u.portNotify.attribute; |
1142 re->xvport.value = event->u.portNotify.value; | 1090 re->xvport.value = event->u.portNotify.value; |
1143 break; | 1091 break; |
1144 default: | 1092 default: |
1145 return False; | 1093 return False; |
1146 } | 1094 } |
1147 | 1095 |
1148 return (True); | 1096 return (True); |
1149 } | 1097 } |
1150 | 1098 |
1151 | 1099 /* vi: set ts=4 sw=4 expandtab: */ |