Skip to content

Latest commit

 

History

History
511 lines (426 loc) · 15.3 KB

SDL_phyuv.c

File metadata and controls

511 lines (426 loc) · 15.3 KB
 
Apr 26, 2001
Apr 26, 2001
1
2
/*
SDL - Simple DirectMedia Layer
Mar 6, 2002
Mar 6, 2002
3
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
Apr 26, 2001
Apr 26, 2001
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
Dec 14, 2001
Dec 14, 2001
20
slouken@libsdl.org
Apr 26, 2001
Apr 26, 2001
21
22
23
24
25
26
27
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
Aug 4, 2003
Aug 4, 2003
28
/* This is the QNX Realtime Platform version of SDL YUV video overlays */
Apr 26, 2001
Apr 26, 2001
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <Ph.h>
#include <Pt.h>
#include "SDL_error.h"
#include "SDL_video.h"
#include "SDL_phyuv_c.h"
#include "SDL_yuvfuncs.h"
Jan 20, 2003
Jan 20, 2003
42
#define OVERLAY_STATE_UNINIT 0
Apr 26, 2001
Apr 26, 2001
43
44
45
#define OVERLAY_STATE_ACTIVE 1
/* The functions used to manipulate software video overlays */
Aug 4, 2003
Aug 4, 2003
46
47
static struct private_yuvhwfuncs ph_yuvfuncs =
{
Jan 20, 2003
Jan 20, 2003
48
49
50
51
ph_LockYUVOverlay,
ph_UnlockYUVOverlay,
ph_DisplayYUVOverlay,
ph_FreeYUVOverlay
Apr 26, 2001
Apr 26, 2001
52
53
};
Aug 4, 2003
Aug 4, 2003
54
int grab_ptrs2(PgVideoChannel_t* channel, FRAMEDATA* Frame0, FRAMEDATA* Frame1)
Apr 26, 2001
Apr 26, 2001
55
{
Jan 20, 2003
Jan 20, 2003
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
int planes = 0;
/* Buffers have moved; re-obtain the pointers */
Frame0->Y = (unsigned char *)PdGetOffscreenContextPtr(channel->yplane1);
Frame1->Y = (unsigned char *)PdGetOffscreenContextPtr(channel->yplane2);
Frame0->U = (unsigned char *)PdGetOffscreenContextPtr(channel->uplane1);
Frame1->U = (unsigned char *)PdGetOffscreenContextPtr(channel->uplane2);
Frame0->V = (unsigned char *)PdGetOffscreenContextPtr(channel->vplane1);
Frame1->V = (unsigned char *)PdGetOffscreenContextPtr(channel->vplane2);
if (Frame0->Y)
planes++;
if (Frame0->U)
planes++;
Apr 26, 2001
Apr 26, 2001
71
Jan 20, 2003
Jan 20, 2003
72
73
if (Frame0->V)
planes++;
Apr 26, 2001
Apr 26, 2001
74
Jan 20, 2003
Jan 20, 2003
75
return planes;
Apr 26, 2001
Apr 26, 2001
76
77
}
Aug 4, 2003
Aug 4, 2003
78
SDL_Overlay* ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface* display)
Apr 26, 2001
Apr 26, 2001
79
{
Aug 4, 2003
Aug 4, 2003
80
81
82
SDL_Overlay* overlay;
struct private_yuvhwdata* hwdata;
int vidport;
Jan 20, 2003
Jan 20, 2003
83
84
85
86
87
88
89
90
int rtncode;
int planes;
int i=0;
PhPoint_t pos;
/* Create the overlay structure */
overlay = calloc(1, sizeof(SDL_Overlay));
Aug 4, 2003
Aug 4, 2003
91
92
if (overlay == NULL)
{
Jan 20, 2003
Jan 20, 2003
93
SDL_OutOfMemory();
Aug 4, 2003
Aug 4, 2003
94
return NULL;
Jan 20, 2003
Jan 20, 2003
95
96
97
98
99
100
}
/* Fill in the basic members */
overlay->format = format;
overlay->w = width;
overlay->h = height;
Aug 4, 2003
Aug 4, 2003
101
overlay->hwdata = NULL;
Apr 26, 2001
Apr 26, 2001
102
Jan 20, 2003
Jan 20, 2003
103
104
105
106
107
108
/* Set up the YUV surface function structure */
overlay->hwfuncs = &ph_yuvfuncs;
/* Create the pixel data and lookup tables */
hwdata = calloc(1, sizeof(struct private_yuvhwdata));
Aug 4, 2003
Aug 4, 2003
109
110
if (hwdata == NULL)
{
Jan 20, 2003
Jan 20, 2003
111
112
SDL_OutOfMemory();
SDL_FreeYUVOverlay(overlay);
Aug 4, 2003
Aug 4, 2003
113
return NULL;
Jan 20, 2003
Jan 20, 2003
114
115
}
Aug 4, 2003
Aug 4, 2003
116
117
overlay->hwdata = hwdata;
Jan 20, 2003
Jan 20, 2003
118
PhDCSetCurrent(0);
May 19, 2002
May 19, 2002
119
120
if (overlay->hwdata->channel == NULL)
{
Aug 4, 2003
Aug 4, 2003
121
if ((overlay->hwdata->channel = PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER, 0)) == NULL)
May 19, 2002
May 19, 2002
122
{
Jan 20, 2003
Jan 20, 2003
123
124
SDL_SetError("ph_CreateYUVOverlay(): Create channel failed: %s\n", strerror(errno));
SDL_FreeYUVOverlay(overlay);
Aug 4, 2003
Aug 4, 2003
125
return NULL;
Jan 20, 2003
Jan 20, 2003
126
May 19, 2002
May 19, 2002
127
128
129
}
}
Aug 4, 2003
Aug 4, 2003
130
131
overlay->hwdata->forcedredraw=0;
Jan 20, 2003
Jan 20, 2003
132
PtGetAbsPosition(window, &pos.x, &pos.y);
Aug 4, 2003
Aug 4, 2003
133
134
135
136
137
138
overlay->hwdata->CurrentWindowPos.x = pos.x;
overlay->hwdata->CurrentWindowPos.y = pos.y;
overlay->hwdata->CurrentViewPort.pos.x = 0;
overlay->hwdata->CurrentViewPort.pos.y = 0;
overlay->hwdata->CurrentViewPort.size.w = width;
overlay->hwdata->CurrentViewPort.size.h = height;
May 19, 2002
May 19, 2002
139
overlay->hwdata->State = OVERLAY_STATE_UNINIT;
Jan 20, 2003
Jan 20, 2003
140
141
overlay->hwdata->FrameData0 = (FRAMEDATA *) calloc(1, sizeof(FRAMEDATA));
overlay->hwdata->FrameData1 = (FRAMEDATA *) calloc(1, sizeof(FRAMEDATA));
Apr 26, 2001
Apr 26, 2001
142
Aug 4, 2003
Aug 4, 2003
143
vidport = -1;
May 19, 2002
May 19, 2002
144
i=0;
Jan 20, 2003
Jan 20, 2003
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
overlay->hwdata->ischromakey=0;
do {
memset(&overlay->hwdata->caps, 0x00, sizeof(PgScalerCaps_t));
overlay->hwdata->caps.size = sizeof(PgScalerCaps_t);
rtncode = PgGetScalerCapabilities(overlay->hwdata->channel, i, &overlay->hwdata->caps);
if (rtncode==0)
{
if (overlay->hwdata->caps.format==format)
{
if ((overlay->hwdata->caps.flags & Pg_SCALER_CAP_DST_CHROMA_KEY) == Pg_SCALER_CAP_DST_CHROMA_KEY)
{
overlay->hwdata->ischromakey=1;
}
Aug 4, 2003
Aug 4, 2003
160
vidport=1;
Jan 20, 2003
Jan 20, 2003
161
162
163
164
165
166
167
168
169
break;
}
}
else
{
break;
}
i++;
} while(1);
May 19, 2002
May 19, 2002
170
Apr 26, 2001
Apr 26, 2001
171
Aug 4, 2003
Aug 4, 2003
172
if (vidport == -1)
Jan 20, 2003
Jan 20, 2003
173
174
175
{
SDL_SetError("No available video ports for requested format\n");
SDL_FreeYUVOverlay(overlay);
Aug 4, 2003
Aug 4, 2003
176
return NULL;
Jan 20, 2003
Jan 20, 2003
177
}
Aug 4, 2003
Aug 4, 2003
178
Jan 20, 2003
Jan 20, 2003
179
180
181
overlay->hwdata->format = format;
overlay->hwdata->props.format = format;
overlay->hwdata->props.size = sizeof(PgScalerProps_t);
Aug 4, 2003
Aug 4, 2003
182
183
overlay->hwdata->props.src_dim.w = width;
overlay->hwdata->props.src_dim.h = height;
Apr 26, 2001
Apr 26, 2001
184
Dec 10, 2003
Dec 10, 2003
185
186
187
/* overlay->hwdata->chromakey = PgGetOverlayChromaColor(); */
overlay->hwdata->chromakey = PgRGB(12, 6, 12); /* very dark pink color */
overlay->hwdata->props.color_key = overlay->hwdata->chromakey;
Aug 4, 2003
Aug 4, 2003
188
189
PhAreaToRect(&overlay->hwdata->CurrentViewPort, &overlay->hwdata->props.viewport);
Apr 26, 2001
Apr 26, 2001
190
Jan 20, 2003
Jan 20, 2003
191
overlay->hwdata->props.flags = Pg_SCALER_PROP_DOUBLE_BUFFER;
Apr 26, 2001
Apr 26, 2001
192
Jan 20, 2003
Jan 20, 2003
193
194
195
if ((overlay->hwdata->ischromakey)&&(overlay->hwdata->chromakey))
{
overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_ENABLE;
Dec 10, 2003
Dec 10, 2003
196
overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_SPECIFY_KEY_MASK;
Jan 20, 2003
Jan 20, 2003
197
198
199
200
201
}
else
{
overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_CHROMA_ENABLE;
}
Apr 26, 2001
Apr 26, 2001
202
Jan 20, 2003
Jan 20, 2003
203
rtncode = PgConfigScalerChannel(overlay->hwdata->channel, &overlay->hwdata->props);
Apr 26, 2001
Apr 26, 2001
204
Jan 20, 2003
Jan 20, 2003
205
206
207
switch(rtncode)
{
case -1: SDL_SetError("PgConfigScalerChannel failed\n");
Aug 4, 2003
Aug 4, 2003
208
209
SDL_FreeYUVOverlay(overlay);
return NULL;
Jan 20, 2003
Jan 20, 2003
210
211
212
213
214
case 1:
case 0:
default:
break;
}
Apr 26, 2001
Apr 26, 2001
215
Jan 20, 2003
Jan 20, 2003
216
planes = grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
Apr 26, 2001
Apr 26, 2001
217
Aug 4, 2003
Aug 4, 2003
218
if(overlay->hwdata->channel->yplane1 != NULL)
Jan 20, 2003
Jan 20, 2003
219
overlay->hwdata->YStride = overlay->hwdata->channel->yplane1->pitch;
Aug 4, 2003
Aug 4, 2003
220
if(overlay->hwdata->channel->uplane1 != NULL)
Jan 20, 2003
Jan 20, 2003
221
overlay->hwdata->UStride = overlay->hwdata->channel->uplane1->pitch;
Aug 4, 2003
Aug 4, 2003
222
if(overlay->hwdata->channel->vplane1 != NULL)
Jan 20, 2003
Jan 20, 2003
223
overlay->hwdata->VStride = overlay->hwdata->channel->vplane1->pitch;
Apr 26, 2001
Apr 26, 2001
224
Aug 4, 2003
Aug 4, 2003
225
226
227
228
229
230
231
232
233
234
/* check for the validness of all planes */
if ((overlay->hwdata->channel->yplane1 == NULL) &&
(overlay->hwdata->channel->uplane1 == NULL) &&
(overlay->hwdata->channel->vplane1 == NULL))
{
SDL_FreeYUVOverlay(overlay);
SDL_SetError("PgConfigScaler() returns all planes equal NULL\n");
return NULL;
}
/*
Jan 20, 2003
Jan 20, 2003
235
overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel);
Apr 26, 2001
Apr 26, 2001
236
Aug 4, 2003
Aug 4, 2003
237
238
if (overlay->hwdata->current==0)
{
Jan 20, 2003
Jan 20, 2003
239
overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0;
Aug 4, 2003
Aug 4, 2003
240
}
Jan 20, 2003
Jan 20, 2003
241
else
Aug 4, 2003
Aug 4, 2003
242
{
Jan 20, 2003
Jan 20, 2003
243
overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1;
Aug 4, 2003
Aug 4, 2003
244
245
246
}
*/
overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0;
Apr 26, 2001
Apr 26, 2001
247
Aug 4, 2003
Aug 4, 2003
248
/*
Jan 20, 2003
Jan 20, 2003
249
overlay->hwdata->locked = 1;
Aug 4, 2003
Aug 4, 2003
250
*/
Apr 26, 2001
Apr 26, 2001
251
Jan 20, 2003
Jan 20, 2003
252
253
254
255
256
257
258
259
260
261
/* Find the pitch and offset values for the overlay */
overlay->planes = planes;
overlay->pitches = calloc(overlay->planes, sizeof(Uint16));
overlay->pixels = calloc(overlay->planes, sizeof(Uint8*));
if (!overlay->pitches || !overlay->pixels)
{
SDL_OutOfMemory();
SDL_FreeYUVOverlay(overlay);
return(NULL);
}
Apr 26, 2001
Apr 26, 2001
262
Jan 20, 2003
Jan 20, 2003
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
if (overlay->planes > 0)
{
overlay->pitches[0] = overlay->hwdata->channel->yplane1->pitch;
overlay->pixels[0] = overlay->hwdata->CurrentFrameData->Y;
}
if (overlay->planes > 1)
{
overlay->pitches[1] = overlay->hwdata->channel->uplane1->pitch;
overlay->pixels[1] = overlay->hwdata->CurrentFrameData->U;
}
if (overlay->planes > 2)
{
overlay->pitches[2] = overlay->hwdata->channel->vplane1->pitch;
overlay->pixels[2] = overlay->hwdata->CurrentFrameData->V;
}
Apr 26, 2001
Apr 26, 2001
278
Jan 20, 2003
Jan 20, 2003
279
280
281
overlay->hwdata->State = OVERLAY_STATE_ACTIVE;
overlay->hwdata->scaler_on = 0;
overlay->hw_overlay = 1;
Apr 26, 2001
Apr 26, 2001
282
Aug 4, 2003
Aug 4, 2003
283
284
285
current_overlay=overlay;
return overlay;
Jan 20, 2003
Jan 20, 2003
286
}
Apr 26, 2001
Apr 26, 2001
287
Aug 4, 2003
Aug 4, 2003
288
int ph_LockYUVOverlay(_THIS, SDL_Overlay* overlay)
Jan 20, 2003
Jan 20, 2003
289
290
{
if (overlay == NULL)
Aug 4, 2003
Aug 4, 2003
291
{
Dec 10, 2003
Dec 10, 2003
292
return -1;
Aug 4, 2003
Aug 4, 2003
293
}
Apr 26, 2001
Apr 26, 2001
294
Aug 4, 2003
Aug 4, 2003
295
296
297
overlay->hwdata->locked = 1;
/* overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel);
Jan 20, 2003
Jan 20, 2003
298
299
if (overlay->hwdata->current == -1)
{
Aug 4, 2003
Aug 4, 2003
300
SDL_SetError("ph_LockYUVOverlay: PgNextFrame() failed, bailing out\n");
Jan 20, 2003
Jan 20, 2003
301
SDL_FreeYUVOverlay(overlay);
Aug 4, 2003
Aug 4, 2003
302
return 0;
Jan 20, 2003
Jan 20, 2003
303
}
Apr 26, 2001
Apr 26, 2001
304
Jan 20, 2003
Jan 20, 2003
305
if (overlay->hwdata->current == 0)
Aug 4, 2003
Aug 4, 2003
306
{
Jan 20, 2003
Jan 20, 2003
307
overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0;
Aug 4, 2003
Aug 4, 2003
308
}
Jan 20, 2003
Jan 20, 2003
309
else
Aug 4, 2003
Aug 4, 2003
310
{
Jan 20, 2003
Jan 20, 2003
311
overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1;
Aug 4, 2003
Aug 4, 2003
312
}
Apr 26, 2001
Apr 26, 2001
313
Jan 20, 2003
Jan 20, 2003
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
if (overlay->planes > 0)
{
overlay->pitches[0] = overlay->hwdata->channel->yplane1->pitch;
overlay->pixels[0] = overlay->hwdata->CurrentFrameData->Y;
}
if (overlay->planes > 1)
{
overlay->pitches[1] = overlay->hwdata->channel->uplane1->pitch;
overlay->pixels[1] = overlay->hwdata->CurrentFrameData->U;
}
if (overlay->planes > 2)
{
overlay->pitches[2] = overlay->hwdata->channel->vplane1->pitch;
overlay->pixels[2] = overlay->hwdata->CurrentFrameData->V;
}
Aug 4, 2003
Aug 4, 2003
329
*/
Apr 26, 2001
Apr 26, 2001
330
Jan 20, 2003
Jan 20, 2003
331
return(0);
Apr 26, 2001
Apr 26, 2001
332
333
}
Aug 4, 2003
Aug 4, 2003
334
void ph_UnlockYUVOverlay(_THIS, SDL_Overlay* overlay)
Apr 26, 2001
Apr 26, 2001
335
{
Aug 4, 2003
Aug 4, 2003
336
if (overlay == NULL)
Jan 20, 2003
Jan 20, 2003
337
{
Dec 10, 2003
Dec 10, 2003
338
return;
Jan 20, 2003
Jan 20, 2003
339
340
}
Aug 4, 2003
Aug 4, 2003
341
overlay->hwdata->locked = 0;
Apr 26, 2001
Apr 26, 2001
342
343
}
Aug 4, 2003
Aug 4, 2003
344
int ph_DisplayYUVOverlay(_THIS, SDL_Overlay* overlay, SDL_Rect* dstrect)
Apr 26, 2001
Apr 26, 2001
345
{
Jan 20, 2003
Jan 20, 2003
346
347
int rtncode;
PhPoint_t pos;
Aug 4, 2003
Aug 4, 2003
348
349
350
SDL_Rect backrect;
PhRect_t windowextent;
int winchanged=0;
Jan 20, 2003
Jan 20, 2003
351
Aug 4, 2003
Aug 4, 2003
352
353
if ((overlay == NULL) || (overlay->hwdata==NULL))
{
Jan 20, 2003
Jan 20, 2003
354
return -1;
Aug 4, 2003
Aug 4, 2003
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
}
if (overlay->hwdata->State == OVERLAY_STATE_UNINIT)
{
return -1;
}
PtGetAbsPosition(window, &pos.x, &pos.y);
if ((pos.x!=overlay->hwdata->CurrentWindowPos.x) ||
(pos.y!=overlay->hwdata->CurrentWindowPos.y))
{
winchanged=1;
overlay->hwdata->CurrentWindowPos.x=pos.x;
overlay->hwdata->CurrentWindowPos.y=pos.y;
}
Jan 20, 2003
Jan 20, 2003
370
Aug 4, 2003
Aug 4, 2003
371
372
373
374
375
376
377
/* If CurrentViewPort position/size has been changed, then move/resize the viewport */
if ((overlay->hwdata->CurrentViewPort.pos.x != dstrect->x) ||
(overlay->hwdata->CurrentViewPort.pos.y != dstrect->y) ||
(overlay->hwdata->CurrentViewPort.size.w != dstrect->w) ||
(overlay->hwdata->CurrentViewPort.size.h != dstrect->h) ||
(overlay->hwdata->scaler_on==0) || (winchanged==1) ||
(overlay->hwdata->forcedredraw==1))
Jan 20, 2003
Jan 20, 2003
378
{
Aug 4, 2003
Aug 4, 2003
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
if (overlay->hwdata->ischromakey==1)
{
/* restore screen behind the overlay/chroma color. */
backrect.x=overlay->hwdata->CurrentViewPort.pos.x;
backrect.y=overlay->hwdata->CurrentViewPort.pos.y;
backrect.w=overlay->hwdata->CurrentViewPort.size.w;
backrect.h=overlay->hwdata->CurrentViewPort.size.h;
this->UpdateRects(this, 1, &backrect);
/* Draw the new rectangle of the chroma color at the viewport position */
PgSetFillColor(overlay->hwdata->chromakey);
PgDrawIRect(dstrect->x, dstrect->y, dstrect->x+dstrect->w-1, dstrect->y+dstrect->h-1, Pg_DRAW_FILL);
PgFlush();
}
Apr 26, 2001
Apr 26, 2001
394
Jan 20, 2003
Jan 20, 2003
395
396
overlay->hwdata->props.flags |= Pg_SCALER_PROP_SCALER_ENABLE;
overlay->hwdata->scaler_on = 1;
Apr 26, 2001
Apr 26, 2001
397
Aug 4, 2003
Aug 4, 2003
398
399
400
401
402
403
404
405
PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, PtWidgetRid(window), &windowextent);
overlay->hwdata->CurrentViewPort.pos.x = pos.x-windowextent.ul.x+dstrect->x;
overlay->hwdata->CurrentViewPort.pos.y = pos.y-windowextent.ul.y+dstrect->y;
overlay->hwdata->CurrentViewPort.size.w = dstrect->w;
overlay->hwdata->CurrentViewPort.size.h = dstrect->h;
PhAreaToRect(&overlay->hwdata->CurrentViewPort, &overlay->hwdata->props.viewport);
overlay->hwdata->CurrentViewPort.pos.x = dstrect->x;
overlay->hwdata->CurrentViewPort.pos.y = dstrect->y;
Apr 26, 2001
Apr 26, 2001
406
Jan 20, 2003
Jan 20, 2003
407
rtncode = PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props));
Apr 26, 2001
Apr 26, 2001
408
Jan 20, 2003
Jan 20, 2003
409
410
411
switch(rtncode)
{
case -1:
Dec 10, 2003
Dec 10, 2003
412
SDL_SetError("PgConfigScalerChannel() function failed\n");
Jan 20, 2003
Jan 20, 2003
413
SDL_FreeYUVOverlay(overlay);
Dec 10, 2003
Dec 10, 2003
414
return -1;
Jan 20, 2003
Jan 20, 2003
415
416
417
418
419
420
421
422
case 1:
grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
break;
case 0:
default:
break;
}
}
Apr 26, 2001
Apr 26, 2001
423
Aug 4, 2003
Aug 4, 2003
424
425
426
/*
if (overlay->hwdata->locked==0)
Jan 20, 2003
Jan 20, 2003
427
428
429
430
{
overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel);
if (overlay->hwdata->current == -1)
{
Aug 4, 2003
Aug 4, 2003
431
SDL_SetError("ph_LockYUVOverlay: PgNextFrame() failed, bailing out\n");
Jan 20, 2003
Jan 20, 2003
432
433
434
SDL_FreeYUVOverlay(overlay);
return 0;
}
Aug 4, 2003
Aug 4, 2003
435
Jan 20, 2003
Jan 20, 2003
436
if (overlay->hwdata->current == 0)
Aug 4, 2003
Aug 4, 2003
437
{
Jan 20, 2003
Jan 20, 2003
438
overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0;
Aug 4, 2003
Aug 4, 2003
439
}
Jan 20, 2003
Jan 20, 2003
440
else
Aug 4, 2003
Aug 4, 2003
441
{
Jan 20, 2003
Jan 20, 2003
442
overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1;
Aug 4, 2003
Aug 4, 2003
443
}
Apr 26, 2001
Apr 26, 2001
444
Jan 20, 2003
Jan 20, 2003
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
if (overlay->planes > 0)
{
overlay->pitches[0] = overlay->hwdata->channel->yplane1->pitch;
overlay->pixels[0] = overlay->hwdata->CurrentFrameData->Y;
}
if (overlay->planes > 1)
{
overlay->pitches[1] = overlay->hwdata->channel->uplane1->pitch;
overlay->pixels[1] = overlay->hwdata->CurrentFrameData->U;
}
if (overlay->planes > 2)
{
overlay->pitches[2] = overlay->hwdata->channel->vplane1->pitch;
overlay->pixels[2] = overlay->hwdata->CurrentFrameData->V;
}
}
Aug 4, 2003
Aug 4, 2003
461
*/
Jan 20, 2003
Jan 20, 2003
462
463
return 0;
Apr 26, 2001
Apr 26, 2001
464
465
466
467
}
void ph_FreeYUVOverlay(_THIS, SDL_Overlay *overlay)
{
Aug 4, 2003
Aug 4, 2003
468
469
SDL_Rect backrect;
Jan 20, 2003
Jan 20, 2003
470
if (overlay == NULL)
Aug 4, 2003
Aug 4, 2003
471
{
Jan 20, 2003
Jan 20, 2003
472
return;
Aug 4, 2003
Aug 4, 2003
473
}
Apr 26, 2001
Apr 26, 2001
474
Jan 20, 2003
Jan 20, 2003
475
if (overlay->hwdata == NULL)
Aug 4, 2003
Aug 4, 2003
476
{
Jan 20, 2003
Jan 20, 2003
477
return;
Aug 4, 2003
Aug 4, 2003
478
479
480
481
482
483
484
485
486
487
}
current_overlay=NULL;
/* restore screen behind the overlay/chroma color. */
backrect.x=overlay->hwdata->CurrentViewPort.pos.x;
backrect.y=overlay->hwdata->CurrentViewPort.pos.y;
backrect.w=overlay->hwdata->CurrentViewPort.size.w;
backrect.h=overlay->hwdata->CurrentViewPort.size.h;
this->UpdateRects(this, 1, &backrect);
Apr 26, 2001
Apr 26, 2001
488
Jan 20, 2003
Jan 20, 2003
489
490
491
492
/* it is need for some buggy drivers, that can't hide overlay before */
/* freeing buffer, so we got trash on the srceen */
overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_SCALER_ENABLE;
PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props));
Apr 26, 2001
Apr 26, 2001
493
Jan 20, 2003
Jan 20, 2003
494
495
overlay->hwdata->scaler_on = 0;
overlay->hwdata->State = OVERLAY_STATE_UNINIT;
Apr 26, 2001
Apr 26, 2001
496
Jan 20, 2003
Jan 20, 2003
497
498
499
500
501
502
if (overlay->hwdata->channel != NULL)
{
PgDestroyVideoChannel(overlay->hwdata->channel);
overlay->hwdata->channel = NULL;
return;
}
Apr 26, 2001
Apr 26, 2001
503
Jan 20, 2003
Jan 20, 2003
504
505
506
507
508
509
510
overlay->hwdata->CurrentFrameData = NULL;
free(overlay->hwdata->FrameData0);
free(overlay->hwdata->FrameData1);
overlay->hwdata->FrameData0 = NULL;
overlay->hwdata->FrameData1 = NULL;
free(overlay->hwdata);
Apr 26, 2001
Apr 26, 2001
511
}