Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11yuv.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 | 51038e80ae59 |
children | 11775724e3fe |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
43 | 43 |
44 /* Workaround when pitch != width */ | 44 /* Workaround when pitch != width */ |
45 #define PITCH_WORKAROUND | 45 #define PITCH_WORKAROUND |
46 | 46 |
47 /* Fix for the NVidia GeForce 2 - use the last available adaptor */ | 47 /* Fix for the NVidia GeForce 2 - use the last available adaptor */ |
48 /*#define USE_LAST_ADAPTOR*/ /* Apparently the NVidia drivers are fixed */ | 48 /*#define USE_LAST_ADAPTOR *//* Apparently the NVidia drivers are fixed */ |
49 | 49 |
50 /* The functions used to manipulate software video overlays */ | 50 /* The functions used to manipulate software video overlays */ |
51 static struct private_yuvhwfuncs x11_yuvfuncs = { | 51 static struct private_yuvhwfuncs x11_yuvfuncs = { |
52 X11_LockYUVOverlay, | 52 X11_LockYUVOverlay, |
53 X11_UnlockYUVOverlay, | 53 X11_UnlockYUVOverlay, |
54 X11_DisplayYUVOverlay, | 54 X11_DisplayYUVOverlay, |
55 X11_FreeYUVOverlay | 55 X11_FreeYUVOverlay |
56 }; | 56 }; |
57 | 57 |
58 struct private_yuvhwdata { | 58 struct private_yuvhwdata |
59 int port; | 59 { |
60 #ifndef NO_SHARED_MEMORY | 60 int port; |
61 int yuv_use_mitshm; | 61 #ifndef NO_SHARED_MEMORY |
62 XShmSegmentInfo yuvshm; | 62 int yuv_use_mitshm; |
63 #endif | 63 XShmSegmentInfo yuvshm; |
64 SDL_NAME(XvImage) *image; | 64 #endif |
65 SDL_NAME (XvImage) * image; | |
65 }; | 66 }; |
66 | 67 |
67 | 68 |
68 static int (*X_handler)(Display *, XErrorEvent *) = NULL; | 69 static int (*X_handler) (Display *, XErrorEvent *) = NULL; |
69 | 70 |
70 #ifndef NO_SHARED_MEMORY | 71 #ifndef NO_SHARED_MEMORY |
71 /* Shared memory error handler routine */ | 72 /* Shared memory error handler routine */ |
72 static int shm_error; | 73 static int shm_error; |
73 static int shm_errhandler(Display *d, XErrorEvent *e) | 74 static int |
74 { | 75 shm_errhandler (Display * d, XErrorEvent * e) |
75 if ( e->error_code == BadAccess ) { | 76 { |
76 shm_error = True; | 77 if (e->error_code == BadAccess) { |
77 return(0); | 78 shm_error = True; |
78 } else | 79 return (0); |
79 return(X_handler(d,e)); | 80 } else |
81 return (X_handler (d, e)); | |
80 } | 82 } |
81 #endif /* !NO_SHARED_MEMORY */ | 83 #endif /* !NO_SHARED_MEMORY */ |
82 | 84 |
83 static int xv_error; | 85 static int xv_error; |
84 static int xv_errhandler(Display *d, XErrorEvent *e) | 86 static int |
85 { | 87 xv_errhandler (Display * d, XErrorEvent * e) |
86 if ( e->error_code == BadMatch ) { | 88 { |
87 xv_error = True; | 89 if (e->error_code == BadMatch) { |
88 return(0); | 90 xv_error = True; |
89 } else | 91 return (0); |
90 return(X_handler(d,e)); | 92 } else |
91 } | 93 return (X_handler (d, e)); |
92 | 94 } |
93 SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display) | 95 |
94 { | 96 SDL_Overlay * |
95 SDL_Overlay *overlay; | 97 X11_CreateYUVOverlay (_THIS, int width, int height, Uint32 format, |
96 struct private_yuvhwdata *hwdata; | 98 SDL_Surface * display) |
97 int xv_port; | 99 { |
98 unsigned int i, j, k; | 100 SDL_Overlay *overlay; |
99 unsigned int adaptors; | 101 struct private_yuvhwdata *hwdata; |
100 SDL_NAME(XvAdaptorInfo) *ainfo; | 102 int xv_port; |
101 int bpp; | 103 unsigned int i, j, k; |
102 #ifndef NO_SHARED_MEMORY | 104 unsigned int adaptors; |
103 XShmSegmentInfo *yuvshm; | 105 SDL_NAME (XvAdaptorInfo) * ainfo; |
104 #endif | 106 int bpp; |
105 | 107 #ifndef NO_SHARED_MEMORY |
106 /* Look for the XVideo extension with a valid port for this format */ | 108 XShmSegmentInfo *yuvshm; |
107 xv_port = -1; | 109 #endif |
108 if ( (Success == SDL_NAME(XvQueryExtension)(GFX_Display, &j, &j, &j, &j, &j)) && | 110 |
109 (Success == SDL_NAME(XvQueryAdaptors)(GFX_Display, | 111 /* Look for the XVideo extension with a valid port for this format */ |
110 RootWindow(GFX_Display, SDL_Screen), | 112 xv_port = -1; |
111 &adaptors, &ainfo)) ) { | 113 if ((Success == |
114 SDL_NAME (XvQueryExtension) (GFX_Display, &j, &j, &j, &j, &j)) | |
115 && (Success == | |
116 SDL_NAME (XvQueryAdaptors) (GFX_Display, | |
117 RootWindow (GFX_Display, SDL_Screen), | |
118 &adaptors, &ainfo))) { | |
112 #ifdef USE_LAST_ADAPTOR | 119 #ifdef USE_LAST_ADAPTOR |
113 for ( i=0; i < adaptors; ++i ) | 120 for (i = 0; i < adaptors; ++i) |
114 #else | 121 #else |
115 for ( i=0; (i < adaptors) && (xv_port == -1); ++i ) | 122 for (i = 0; (i < adaptors) && (xv_port == -1); ++i) |
116 #endif /* USE_LAST_ADAPTOR */ | 123 #endif /* USE_LAST_ADAPTOR */ |
117 { | 124 { |
118 /* Check to see if the visual can be used */ | 125 /* Check to see if the visual can be used */ |
119 if ( BUGGY_XFREE86(<=, 4001) ) { | 126 if (BUGGY_XFREE86 (<=, 4001)) { |
120 int visual_ok = 0; | 127 int visual_ok = 0; |
121 for ( j=0; j<ainfo[i].num_formats; ++j ) { | 128 for (j = 0; j < ainfo[i].num_formats; ++j) { |
122 if ( ainfo[i].formats[j].visual_id == | 129 if (ainfo[i].formats[j].visual_id == SDL_Visual->visualid) { |
123 SDL_Visual->visualid ) { | 130 visual_ok = 1; |
124 visual_ok = 1; | 131 break; |
125 break; | 132 } |
126 } | 133 } |
127 } | 134 if (!visual_ok) { |
128 if ( ! visual_ok ) { | 135 continue; |
129 continue; | 136 } |
130 } | 137 } |
131 } | 138 if ((ainfo[i].type & XvInputMask) && |
132 if ( (ainfo[i].type & XvInputMask) && | 139 (ainfo[i].type & XvImageMask)) { |
133 (ainfo[i].type & XvImageMask) ) { | 140 int num_formats; |
134 int num_formats; | 141 SDL_NAME (XvImageFormatValues) * formats; |
135 SDL_NAME(XvImageFormatValues) *formats; | 142 formats = SDL_NAME (XvListImageFormats) (GFX_Display, |
136 formats = SDL_NAME(XvListImageFormats)(GFX_Display, | 143 ainfo[i]. |
137 ainfo[i].base_id, &num_formats); | 144 base_id, |
145 &num_formats); | |
138 #ifdef USE_LAST_ADAPTOR | 146 #ifdef USE_LAST_ADAPTOR |
139 for ( j=0; j < num_formats; ++j ) | 147 for (j = 0; j < num_formats; ++j) |
140 #else | 148 #else |
141 for ( j=0; (j < num_formats) && (xv_port == -1); ++j ) | 149 for (j = 0; (j < num_formats) && (xv_port == -1); ++j) |
142 #endif /* USE_LAST_ADAPTOR */ | 150 #endif /* USE_LAST_ADAPTOR */ |
143 { | 151 { |
144 if ( (Uint32)formats[j].id == format ) { | 152 if ((Uint32) formats[j].id == format) { |
145 for ( k=0; k < ainfo[i].num_ports; ++k ) { | 153 for (k = 0; k < ainfo[i].num_ports; ++k) { |
146 if ( Success == SDL_NAME(XvGrabPort)(GFX_Display, ainfo[i].base_id+k, CurrentTime) ) { | 154 if (Success == SDL_NAME (XvGrabPort) |
147 xv_port = ainfo[i].base_id+k; | 155 (GFX_Display, |
148 break; | 156 ainfo[i].base_id + k, CurrentTime)) { |
149 } | 157 xv_port = ainfo[i].base_id + k; |
150 } | 158 break; |
151 } | 159 } |
152 } | 160 } |
153 if ( formats ) { | 161 } |
154 XFree(formats); | 162 } |
155 } | 163 if (formats) { |
156 } | 164 XFree (formats); |
157 } | 165 } |
158 SDL_NAME(XvFreeAdaptorInfo)(ainfo); | 166 } |
159 } | 167 } |
160 | 168 SDL_NAME (XvFreeAdaptorInfo) (ainfo); |
161 /* Precalculate the bpp for the pitch workaround below */ | 169 } |
162 switch (format) { | 170 |
163 /* Add any other cases we need to support... */ | 171 /* Precalculate the bpp for the pitch workaround below */ |
164 case SDL_YUY2_OVERLAY: | 172 switch (format) { |
165 case SDL_UYVY_OVERLAY: | 173 /* Add any other cases we need to support... */ |
166 case SDL_YVYU_OVERLAY: | 174 case SDL_YUY2_OVERLAY: |
167 bpp = 2; | 175 case SDL_UYVY_OVERLAY: |
168 break; | 176 case SDL_YVYU_OVERLAY: |
169 default: | 177 bpp = 2; |
170 bpp = 1; | 178 break; |
171 break; | 179 default: |
172 } | 180 bpp = 1; |
181 break; | |
182 } | |
173 | 183 |
174 #if 0 | 184 #if 0 |
175 /* | 185 /* |
176 * !!! FIXME: | 186 * !!! FIXME: |
177 * "Here are some diffs for X11 and yuv. Note that the last part 2nd | 187 * "Here are some diffs for X11 and yuv. Note that the last part 2nd |
180 * | 190 * |
181 * ACHTUNG: This is broken! It looks like XvFreeAdaptorInfo does this | 191 * ACHTUNG: This is broken! It looks like XvFreeAdaptorInfo does this |
182 * for you, so we end up with a double-free. I need to look at this | 192 * for you, so we end up with a double-free. I need to look at this |
183 * more closely... --ryan. | 193 * more closely... --ryan. |
184 */ | 194 */ |
185 for ( i=0; i < adaptors; ++i ) { | 195 for (i = 0; i < adaptors; ++i) { |
186 if (ainfo[i].name != NULL) Xfree(ainfo[i].name); | 196 if (ainfo[i].name != NULL) |
187 if (ainfo[i].formats != NULL) Xfree(ainfo[i].formats); | 197 Xfree (ainfo[i].name); |
188 } | 198 if (ainfo[i].formats != NULL) |
189 Xfree(ainfo); | 199 Xfree (ainfo[i].formats); |
190 #endif | 200 } |
191 | 201 Xfree (ainfo); |
192 if ( xv_port == -1 ) { | 202 #endif |
193 SDL_SetError("No available video ports for requested format"); | 203 |
194 return(NULL); | 204 if (xv_port == -1) { |
195 } | 205 SDL_SetError ("No available video ports for requested format"); |
196 | 206 return (NULL); |
197 /* Enable auto-painting of the overlay colorkey */ | 207 } |
198 { | 208 |
199 static const char *attr[] = { "XV_AUTOPAINT_COLORKEY", "XV_AUTOPAINT_COLOURKEY" }; | 209 /* Enable auto-painting of the overlay colorkey */ |
200 unsigned int i; | 210 { |
201 | 211 static const char *attr[] = |
202 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, True); | 212 { "XV_AUTOPAINT_COLORKEY", "XV_AUTOPAINT_COLOURKEY" }; |
203 X_handler = XSetErrorHandler(xv_errhandler); | 213 unsigned int i; |
204 for ( i=0; i < sizeof(attr)/(sizeof attr[0]); ++i ) { | 214 |
205 Atom a; | 215 SDL_NAME (XvSelectPortNotify) (GFX_Display, xv_port, True); |
206 | 216 X_handler = XSetErrorHandler (xv_errhandler); |
207 xv_error = False; | 217 for (i = 0; i < sizeof (attr) / (sizeof attr[0]); ++i) { |
208 a = XInternAtom(GFX_Display, attr[i], True); | 218 Atom a; |
209 if ( a != None ) { | 219 |
210 SDL_NAME(XvSetPortAttribute)(GFX_Display, xv_port, a, 1); | 220 xv_error = False; |
211 XSync(GFX_Display, True); | 221 a = XInternAtom (GFX_Display, attr[i], True); |
212 if ( ! xv_error ) { | 222 if (a != None) { |
213 break; | 223 SDL_NAME (XvSetPortAttribute) (GFX_Display, xv_port, a, 1); |
214 } | 224 XSync (GFX_Display, True); |
215 } | 225 if (!xv_error) { |
216 } | 226 break; |
217 XSetErrorHandler(X_handler); | 227 } |
218 SDL_NAME(XvSelectPortNotify)(GFX_Display, xv_port, False); | 228 } |
219 } | 229 } |
220 | 230 XSetErrorHandler (X_handler); |
221 /* Create the overlay structure */ | 231 SDL_NAME (XvSelectPortNotify) (GFX_Display, xv_port, False); |
222 overlay = (SDL_Overlay *)SDL_malloc(sizeof *overlay); | 232 } |
223 if ( overlay == NULL ) { | 233 |
224 SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime); | 234 /* Create the overlay structure */ |
225 SDL_OutOfMemory(); | 235 overlay = (SDL_Overlay *) SDL_malloc (sizeof *overlay); |
226 return(NULL); | 236 if (overlay == NULL) { |
227 } | 237 SDL_NAME (XvUngrabPort) (GFX_Display, xv_port, CurrentTime); |
228 SDL_memset(overlay, 0, (sizeof *overlay)); | 238 SDL_OutOfMemory (); |
229 | 239 return (NULL); |
230 /* Fill in the basic members */ | 240 } |
231 overlay->format = format; | 241 SDL_memset (overlay, 0, (sizeof *overlay)); |
232 overlay->w = width; | 242 |
233 overlay->h = height; | 243 /* Fill in the basic members */ |
234 | 244 overlay->format = format; |
235 /* Set up the YUV surface function structure */ | 245 overlay->w = width; |
236 overlay->hwfuncs = &x11_yuvfuncs; | 246 overlay->h = height; |
237 overlay->hw_overlay = 1; | 247 |
238 | 248 /* Set up the YUV surface function structure */ |
239 /* Create the pixel data and lookup tables */ | 249 overlay->hwfuncs = &x11_yuvfuncs; |
240 hwdata = (struct private_yuvhwdata *)SDL_malloc(sizeof *hwdata); | 250 overlay->hw_overlay = 1; |
241 overlay->hwdata = hwdata; | 251 |
242 if ( hwdata == NULL ) { | 252 /* Create the pixel data and lookup tables */ |
243 SDL_NAME(XvUngrabPort)(GFX_Display, xv_port, CurrentTime); | 253 hwdata = (struct private_yuvhwdata *) SDL_malloc (sizeof *hwdata); |
244 SDL_OutOfMemory(); | 254 overlay->hwdata = hwdata; |
245 SDL_FreeYUVOverlay(overlay); | 255 if (hwdata == NULL) { |
246 return(NULL); | 256 SDL_NAME (XvUngrabPort) (GFX_Display, xv_port, CurrentTime); |
247 } | 257 SDL_OutOfMemory (); |
248 hwdata->port = xv_port; | 258 SDL_FreeYUVOverlay (overlay); |
249 #ifndef NO_SHARED_MEMORY | 259 return (NULL); |
250 yuvshm = &hwdata->yuvshm; | 260 } |
251 SDL_memset(yuvshm, 0, sizeof(*yuvshm)); | 261 hwdata->port = xv_port; |
252 hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, | 262 #ifndef NO_SHARED_MEMORY |
253 0, width, height, yuvshm); | 263 yuvshm = &hwdata->yuvshm; |
264 SDL_memset (yuvshm, 0, sizeof (*yuvshm)); | |
265 hwdata->image = SDL_NAME (XvShmCreateImage) (GFX_Display, xv_port, format, | |
266 0, width, height, yuvshm); | |
254 #ifdef PITCH_WORKAROUND | 267 #ifdef PITCH_WORKAROUND |
255 if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { | 268 if (hwdata->image != NULL && hwdata->image->pitches[0] != (width * bpp)) { |
256 /* Ajust overlay width according to pitch */ | 269 /* Ajust overlay width according to pitch */ |
257 XFree(hwdata->image); | 270 XFree (hwdata->image); |
258 width = hwdata->image->pitches[0] / bpp; | 271 width = hwdata->image->pitches[0] / bpp; |
259 hwdata->image = SDL_NAME(XvShmCreateImage)(GFX_Display, xv_port, format, | 272 hwdata->image = |
260 0, width, height, yuvshm); | 273 SDL_NAME (XvShmCreateImage) (GFX_Display, xv_port, format, 0, |
261 } | 274 width, height, yuvshm); |
275 } | |
262 #endif /* PITCH_WORKAROUND */ | 276 #endif /* PITCH_WORKAROUND */ |
263 hwdata->yuv_use_mitshm = (hwdata->image != NULL); | 277 hwdata->yuv_use_mitshm = (hwdata->image != NULL); |
264 if ( hwdata->yuv_use_mitshm ) { | 278 if (hwdata->yuv_use_mitshm) { |
265 yuvshm->shmid = shmget(IPC_PRIVATE, hwdata->image->data_size, | 279 yuvshm->shmid = shmget (IPC_PRIVATE, hwdata->image->data_size, |
266 IPC_CREAT | 0777); | 280 IPC_CREAT | 0777); |
267 if ( yuvshm->shmid >= 0 ) { | 281 if (yuvshm->shmid >= 0) { |
268 yuvshm->shmaddr = (char *)shmat(yuvshm->shmid, 0, 0); | 282 yuvshm->shmaddr = (char *) shmat (yuvshm->shmid, 0, 0); |
269 yuvshm->readOnly = False; | 283 yuvshm->readOnly = False; |
270 if ( yuvshm->shmaddr != (char *)-1 ) { | 284 if (yuvshm->shmaddr != (char *) -1) { |
271 shm_error = False; | 285 shm_error = False; |
272 X_handler = XSetErrorHandler(shm_errhandler); | 286 X_handler = XSetErrorHandler (shm_errhandler); |
273 XShmAttach(GFX_Display, yuvshm); | 287 XShmAttach (GFX_Display, yuvshm); |
274 XSync(GFX_Display, True); | 288 XSync (GFX_Display, True); |
275 XSetErrorHandler(X_handler); | 289 XSetErrorHandler (X_handler); |
276 if ( shm_error ) | 290 if (shm_error) |
277 shmdt(yuvshm->shmaddr); | 291 shmdt (yuvshm->shmaddr); |
278 } else { | 292 } else { |
279 shm_error = True; | 293 shm_error = True; |
280 } | 294 } |
281 shmctl(yuvshm->shmid, IPC_RMID, NULL); | 295 shmctl (yuvshm->shmid, IPC_RMID, NULL); |
282 } else { | 296 } else { |
283 shm_error = True; | 297 shm_error = True; |
284 } | 298 } |
285 if ( shm_error ) { | 299 if (shm_error) { |
286 XFree(hwdata->image); | 300 XFree (hwdata->image); |
287 hwdata->yuv_use_mitshm = 0; | 301 hwdata->yuv_use_mitshm = 0; |
288 } else { | 302 } else { |
289 hwdata->image->data = yuvshm->shmaddr; | 303 hwdata->image->data = yuvshm->shmaddr; |
290 } | 304 } |
291 } | 305 } |
292 if ( !hwdata->yuv_use_mitshm ) | 306 if (!hwdata->yuv_use_mitshm) |
293 #endif /* NO_SHARED_MEMORY */ | 307 #endif /* NO_SHARED_MEMORY */ |
294 { | 308 { |
295 hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format, | 309 hwdata->image = |
296 0, width, height); | 310 SDL_NAME (XvCreateImage) (GFX_Display, xv_port, format, 0, |
311 width, height); | |
297 | 312 |
298 #ifdef PITCH_WORKAROUND | 313 #ifdef PITCH_WORKAROUND |
299 if ( hwdata->image != NULL && hwdata->image->pitches[0] != (width*bpp) ) { | 314 if (hwdata->image != NULL |
300 /* Ajust overlay width according to pitch */ | 315 && hwdata->image->pitches[0] != (width * bpp)) { |
301 XFree(hwdata->image); | 316 /* Ajust overlay width according to pitch */ |
302 width = hwdata->image->pitches[0] / bpp; | 317 XFree (hwdata->image); |
303 hwdata->image = SDL_NAME(XvCreateImage)(GFX_Display, xv_port, format, | 318 width = hwdata->image->pitches[0] / bpp; |
304 0, width, height); | 319 hwdata->image = |
305 } | 320 SDL_NAME (XvCreateImage) (GFX_Display, xv_port, format, 0, |
321 width, height); | |
322 } | |
306 #endif /* PITCH_WORKAROUND */ | 323 #endif /* PITCH_WORKAROUND */ |
307 if ( hwdata->image == NULL ) { | 324 if (hwdata->image == NULL) { |
308 SDL_SetError("Couldn't create XVideo image"); | 325 SDL_SetError ("Couldn't create XVideo image"); |
309 SDL_FreeYUVOverlay(overlay); | 326 SDL_FreeYUVOverlay (overlay); |
310 return(NULL); | 327 return (NULL); |
311 } | 328 } |
312 hwdata->image->data = SDL_malloc(hwdata->image->data_size); | 329 hwdata->image->data = SDL_malloc (hwdata->image->data_size); |
313 if ( hwdata->image->data == NULL ) { | 330 if (hwdata->image->data == NULL) { |
314 SDL_OutOfMemory(); | 331 SDL_OutOfMemory (); |
315 SDL_FreeYUVOverlay(overlay); | 332 SDL_FreeYUVOverlay (overlay); |
316 return(NULL); | 333 return (NULL); |
317 } | 334 } |
318 } | 335 } |
319 | 336 |
320 /* Find the pitch and offset values for the overlay */ | 337 /* Find the pitch and offset values for the overlay */ |
321 overlay->planes = hwdata->image->num_planes; | 338 overlay->planes = hwdata->image->num_planes; |
322 overlay->pitches = (Uint16 *)SDL_malloc(overlay->planes * sizeof(Uint16)); | 339 overlay->pitches = |
323 overlay->pixels = (Uint8 **)SDL_malloc(overlay->planes * sizeof(Uint8 *)); | 340 (Uint16 *) SDL_malloc (overlay->planes * sizeof (Uint16)); |
324 if ( !overlay->pitches || !overlay->pixels ) { | 341 overlay->pixels = |
325 SDL_OutOfMemory(); | 342 (Uint8 **) SDL_malloc (overlay->planes * sizeof (Uint8 *)); |
326 SDL_FreeYUVOverlay(overlay); | 343 if (!overlay->pitches || !overlay->pixels) { |
327 return(NULL); | 344 SDL_OutOfMemory (); |
328 } | 345 SDL_FreeYUVOverlay (overlay); |
329 for ( i=0; i<overlay->planes; ++i ) { | 346 return (NULL); |
330 overlay->pitches[i] = hwdata->image->pitches[i]; | 347 } |
331 overlay->pixels[i] = (Uint8 *)hwdata->image->data + | 348 for (i = 0; i < overlay->planes; ++i) { |
332 hwdata->image->offsets[i]; | 349 overlay->pitches[i] = hwdata->image->pitches[i]; |
333 } | 350 overlay->pixels[i] = (Uint8 *) hwdata->image->data + |
351 hwdata->image->offsets[i]; | |
352 } | |
334 | 353 |
335 #ifdef XFREE86_REFRESH_HACK | 354 #ifdef XFREE86_REFRESH_HACK |
336 /* Work around an XFree86 X server bug (?) | 355 /* Work around an XFree86 X server bug (?) |
337 We can't perform normal updates in windows that have video | 356 We can't perform normal updates in windows that have video |
338 being output to them. See SDL_x11image.c for more details. | 357 being output to them. See SDL_x11image.c for more details. |
339 */ | 358 */ |
340 X11_DisableAutoRefresh(this); | 359 X11_DisableAutoRefresh (this); |
341 #endif | 360 #endif |
342 | 361 |
343 /* We're all done.. */ | 362 /* We're all done.. */ |
344 return(overlay); | 363 return (overlay); |
345 } | 364 } |
346 | 365 |
347 int X11_LockYUVOverlay(_THIS, SDL_Overlay *overlay) | 366 int |
348 { | 367 X11_LockYUVOverlay (_THIS, SDL_Overlay * overlay) |
349 return(0); | 368 { |
350 } | 369 return (0); |
351 | 370 } |
352 void X11_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay) | 371 |
353 { | 372 void |
354 return; | 373 X11_UnlockYUVOverlay (_THIS, SDL_Overlay * overlay) |
355 } | 374 { |
356 | 375 return; |
357 int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst) | 376 } |
358 { | 377 |
359 struct private_yuvhwdata *hwdata; | 378 int |
360 | 379 X11_DisplayYUVOverlay (_THIS, SDL_Overlay * overlay, SDL_Rect * src, |
361 hwdata = overlay->hwdata; | 380 SDL_Rect * dst) |
362 | 381 { |
363 #ifndef NO_SHARED_MEMORY | 382 struct private_yuvhwdata *hwdata; |
364 if ( hwdata->yuv_use_mitshm ) { | 383 |
365 SDL_NAME(XvShmPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, | 384 hwdata = overlay->hwdata; |
366 hwdata->image, | 385 |
367 src->x, src->y, src->w, src->h, | 386 #ifndef NO_SHARED_MEMORY |
368 dst->x, dst->y, dst->w, dst->h, False); | 387 if (hwdata->yuv_use_mitshm) { |
369 } | 388 SDL_NAME (XvShmPutImage) (GFX_Display, hwdata->port, SDL_Window, |
370 else | 389 SDL_GC, hwdata->image, src->x, src->y, |
371 #endif | 390 src->w, src->h, dst->x, dst->y, dst->w, |
372 { | 391 dst->h, False); |
373 SDL_NAME(XvPutImage)(GFX_Display, hwdata->port, SDL_Window, SDL_GC, | 392 } else |
374 hwdata->image, | 393 #endif |
375 src->x, src->y, src->w, src->h, | 394 { |
376 dst->x, dst->y, dst->w, dst->h); | 395 SDL_NAME (XvPutImage) (GFX_Display, hwdata->port, SDL_Window, |
377 } | 396 SDL_GC, hwdata->image, src->x, src->y, |
378 XSync(GFX_Display, False); | 397 src->w, src->h, dst->x, dst->y, dst->w, |
379 return(0); | 398 dst->h); |
380 } | 399 } |
381 | 400 XSync (GFX_Display, False); |
382 void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay) | 401 return (0); |
383 { | 402 } |
384 struct private_yuvhwdata *hwdata; | 403 |
385 | 404 void |
386 hwdata = overlay->hwdata; | 405 X11_FreeYUVOverlay (_THIS, SDL_Overlay * overlay) |
387 if ( hwdata ) { | 406 { |
388 SDL_NAME(XvUngrabPort)(GFX_Display, hwdata->port, CurrentTime); | 407 struct private_yuvhwdata *hwdata; |
389 #ifndef NO_SHARED_MEMORY | 408 |
390 if ( hwdata->yuv_use_mitshm ) { | 409 hwdata = overlay->hwdata; |
391 XShmDetach(GFX_Display, &hwdata->yuvshm); | 410 if (hwdata) { |
392 shmdt(hwdata->yuvshm.shmaddr); | 411 SDL_NAME (XvUngrabPort) (GFX_Display, hwdata->port, CurrentTime); |
393 } | 412 #ifndef NO_SHARED_MEMORY |
394 #endif | 413 if (hwdata->yuv_use_mitshm) { |
395 if ( hwdata->image ) { | 414 XShmDetach (GFX_Display, &hwdata->yuvshm); |
396 XFree(hwdata->image); | 415 shmdt (hwdata->yuvshm.shmaddr); |
397 } | 416 } |
398 SDL_free(hwdata); | 417 #endif |
399 } | 418 if (hwdata->image) { |
400 if ( overlay->pitches ) { | 419 XFree (hwdata->image); |
401 SDL_free(overlay->pitches); | 420 } |
402 overlay->pitches = NULL; | 421 SDL_free (hwdata); |
403 } | 422 } |
404 if ( overlay->pixels ) { | 423 if (overlay->pitches) { |
405 SDL_free(overlay->pixels); | 424 SDL_free (overlay->pitches); |
406 overlay->pixels = NULL; | 425 overlay->pitches = NULL; |
407 } | 426 } |
427 if (overlay->pixels) { | |
428 SDL_free (overlay->pixels); | |
429 overlay->pixels = NULL; | |
430 } | |
408 #ifdef XFREE86_REFRESH_HACK | 431 #ifdef XFREE86_REFRESH_HACK |
409 X11_EnableAutoRefresh(this); | 432 X11_EnableAutoRefresh (this); |
410 #endif | 433 #endif |
411 } | 434 } |
412 | 435 |
413 #endif /* SDL_VIDEO_DRIVER_X11_XV */ | 436 #endif /* SDL_VIDEO_DRIVER_X11_XV */ |
437 /* vi: set ts=4 sw=4 expandtab: */ |