Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
509 lines (424 loc) · 15.5 KB

SDL_phyuv.c

File metadata and controls

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