Skip to content

Latest commit

 

History

History
649 lines (514 loc) · 17.7 KB

SDL_phyuv.c

File metadata and controls

649 lines (514 loc) · 17.7 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif
/* This is the QNX Realtime Platform version for SDL YUV video overlays */
#include <stdlib.h>
#include <string.h>
#ifndef bool
#define bool char
#define TRUE 1
#define FALSE 0
#endif
#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"
#if 0 //just for reference
/* YUV data formats FourCC Layout H sample (YUV) V sample (YUV) BPP */
#define Pg_VIDEO_FORMAT_IYU1 0x31555949 /* U2Y2Y2V2Y2Y2 144 111 12 */
#define Pg_VIDEO_FORMAT_IYU2 0x32555949 /* U4Y4V4U4Y4V4 111 111 24 */
#define Pg_VIDEO_FORMAT_UYVY 0x59565955 /* U8Y8V8Y8 122 111 16 */
#define Pg_VIDEO_FORMAT_YUY2 0x32595559 /* Y8U8Y8V8 122 111 16 */
#define Pg_VIDEO_FORMAT_YVYU 0x55595659 /* Y8V8Y8U8 122 111 16 */
#define Pg_VIDEO_FORMAT_V422 0x56343232 /* V8Y8U8Y8 122 111 16 */
#define Pg_VIDEO_FORMAT_CLJR 0x524a4c43 /* V6U6Y5Y5Y5Y5 133 111 8 */
#define Pg_VIDEO_FORMAT_YVU9 0x39555659 /* Planar YVU 144 144 9 */
#define Pg_VIDEO_FORMAT_YV12 0x32315659 /* Planar YUV 122 122 12 */
/* There seems to be no FourCC that matches this */
#define Pg_VIDEO_FORMAT_YUV420 0x00000100 /* Planar YUV 122 111 16 */
/* These formats are the same as YV12, except the U and V planes do not have to contiguously follow the Y plane */
/* but they're all the same to us, since we always have 3 plane pointers */
#define Pg_VIDEO_FORMAT_CLPL Pg_VIDEO_FORMAT_YV12 /* Cirrus Logic Planar format */
#define Pg_VIDEO_FORMAT_VBPL Pg_VIDEO_FORMAT_YV12 /* VooDoo Banshee planar format */
#define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U */
#define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V */
#define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 */
#define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 */
#define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 */
#endif
#define OVERLAY_STATE_UNINIT 0
#define OVERLAY_STATE_ACTIVE 1
/* The functions used to manipulate software video overlays */
static struct private_yuvhwfuncs ph_yuvfuncs = {
ph_LockYUVOverlay,
ph_UnlockYUVOverlay,
ph_DisplayYUVOverlay,
ph_FreeYUVOverlay
};
typedef struct {
int id;
int width, height;
int data_size; /* bytes */
int num_planes;
int *pitches; /* bytes */
int *offsets; /* bytes */
char *data;
void *obdata;
} XvImage;
struct private_yuvhwdata {
XvImage *image;
FRAMEDATA *CurrentFrameData;
FRAMEDATA *FrameData0;
FRAMEDATA *FrameData1;
PgScalerProps_t props;
May 19, 2002
May 19, 2002
106
PgScalerCaps_t caps;
Apr 26, 2001
Apr 26, 2001
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
PgVideoChannel_t *channel;
SDL_Rect CurrentWindow;
long format;
int screen_width;
int screen_height ;
int screen_bpp ; //2
bool planar;
bool scaler_on ;
int current;
long YStride;
long VStride;
long UStride;
long chromakey;
unsigned long State;
long flags;
};
extern PgVideoChannel_t * PgCreateVideoChannel(unsigned type, unsigned flags);
extern int PgGetScalerCapabilities( PgVideoChannel_t *channel, int format_index, PgScalerCaps_t *vcaps );
extern int PgConfigScalerChannel(PgVideoChannel_t *channel, PgScalerProps_t *props);
extern void PgDestroyVideoChannel(PgVideoChannel_t *channel);
extern PgColor_t PgGetOverlayChromaColor(void);
void
grab_ptrs2(PgVideoChannel_t *channel, FRAMEDATA *Frame0, FRAMEDATA *Frame1 )
{
/* 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);
}
May 19, 2002
May 19, 2002
144
SDL_Overlay* ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
Apr 26, 2001
Apr 26, 2001
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
{
SDL_Overlay *overlay;
struct private_yuvhwdata *hwdata;
int xv_port;
int rtncode;
// PhRect_t rect;
// PhSysInfo_t info;
// PhRegion_t region;
// short x, y;
PtArg_t argt;
int i =0;
// bool bCont = TRUE;
int Priority[20];
int Type[20];
int entries, select, highest;
PhDCSetCurrent(0); //Need to set draw context to window esp. if we we in Offscreeen mode
/* Create the overlay structure */
May 19, 2002
May 19, 2002
164
165
overlay = (SDL_Overlay *)malloc(sizeof(SDL_Overlay));
memset(overlay, 0x00, sizeof(SDL_Overlay));
Apr 26, 2001
Apr 26, 2001
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
if ( overlay == NULL ) {
SDL_OutOfMemory();
return(NULL);
}
memset(overlay, 0, (sizeof *overlay));
/* Fill in the basic members */
overlay->format = format;
overlay->w = width;
overlay->h = height;
/* Set up the YUV surface function structure */
overlay->hwfuncs = &ph_yuvfuncs;
/* Create the pixel data and lookup tables */
May 19, 2002
May 19, 2002
181
182
hwdata = (struct private_yuvhwdata *)malloc(sizeof(struct private_yuvhwdata));
memset(hwdata, 0x00, sizeof(struct private_yuvhwdata));
Apr 26, 2001
Apr 26, 2001
183
184
185
186
187
188
189
overlay->hwdata = hwdata;
if ( hwdata == NULL ) {
SDL_OutOfMemory();
SDL_FreeYUVOverlay(overlay);
return(NULL);
}
May 19, 2002
May 19, 2002
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
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 ));
free(overlay->hwdata);
free(overlay);
return (NULL);
}
}
overlay->hwdata->CurrentWindow.x = 0;
overlay->hwdata->CurrentWindow.y = 0;
overlay->hwdata->CurrentWindow.w = 320;
overlay->hwdata->CurrentWindow.h = 240;
overlay->hwdata->State = OVERLAY_STATE_UNINIT;
overlay->hwdata->screen_bpp = 2;
overlay->hwdata->scaler_on = FALSE;
overlay->hwdata->screen_width = 1024;
overlay->hwdata->screen_height = 768;
May 28, 2002
May 28, 2002
213
214
215
216
overlay->hwdata->FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof(FRAMEDATA)));
overlay->hwdata->FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof(FRAMEDATA)));
memset(overlay->hwdata->FrameData0, 0x00, (size_t)(sizeof(FRAMEDATA)));
memset(overlay->hwdata->FrameData1, 0x00, (size_t)(sizeof(FRAMEDATA)));
May 19, 2002
May 19, 2002
217
218
overlay->hwdata->caps.size = sizeof(overlay->hwdata->caps);
Apr 26, 2001
Apr 26, 2001
219
220
221
//Note you really don't need to do this for SDL as you are given a format, but this is a good example
May 19, 2002
May 19, 2002
222
223
224
xv_port = -1;
i=0;
Apr 26, 2001
Apr 26, 2001
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
while(PgGetScalerCapabilities(overlay->hwdata->channel, i++, &(overlay->hwdata->caps)) == 0)
{
if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_YV12) //in SDL
{
Priority[i-1] = 0;
Type[i-1] = Pg_VIDEO_FORMAT_YV12;
if(format == Pg_VIDEO_FORMAT_YV12)
{
overlay->hwdata->props.format = Pg_VIDEO_FORMAT_YV12;
xv_port = 1; //supported
Priority[i-1] = 100; //force selected
}
}
else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_YVU9) //in SDL
{
Priority[i-1] = 0;
Type[i-1] = Pg_VIDEO_FORMAT_YVU9;
if(format == Pg_VIDEO_FORMAT_YVU9)
{
overlay->hwdata->props.format = Pg_VIDEO_FORMAT_YVU9;
xv_port = 1; //supported
Priority[i-1] = 100; //force selected
}
}
#if 0 //this part of SDL is YUV specific
else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_RGB555)
{
Priority[i-1] = 3;
Type[i-1] = Pg_VIDEO_FORMAT_RGB555;
}
else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_RGB565)
{
Priority[i-1] = 2;
Type[i-1] = Pg_VIDEO_FORMAT_RGB565;
}
else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_RGB8888)
{
Priority[i-1] = 1;
Type[i-1] = Pg_VIDEO_FORMAT_RGB8888;
}
#endif
else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_IYU1)
{
Priority[i-1] = 0;
Type[i-1] = Pg_VIDEO_FORMAT_IYU1;
}
else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_IYU2)
{
Priority[i-1] = 0;
Type[i-1] = Pg_VIDEO_FORMAT_IYU2;
}
else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_UYVY) //in SDL
{
Priority[i-1] = 7;
Type[i-1] = Pg_VIDEO_FORMAT_UYVY;
if(format == Pg_VIDEO_FORMAT_UYVY)
{
overlay->hwdata->props.format = Pg_VIDEO_FORMAT_UYVY;
xv_port = 1; //supported
Priority[i-1] = 100; //force selected
}
}
else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_YUY2) //in SDL
{
Priority[i-1] = 8;
Type[i-1] = Pg_VIDEO_FORMAT_YUY2;
if(format == Pg_VIDEO_FORMAT_YUY2)
{
overlay->hwdata->props.format = Pg_VIDEO_FORMAT_YUY2;
xv_port = 1; //supported
Priority[i-1] = 100; //force selected
}
}
else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_YVYU) //in SDL
{
Priority[i-1] = 4;
Type[i-1] = Pg_VIDEO_FORMAT_YVYU;
if(format == Pg_VIDEO_FORMAT_YVYU)
{
overlay->hwdata->props.format = Pg_VIDEO_FORMAT_YVYU;
xv_port = 1; //supported
Priority[i-1] = 100; //force selected
}
}
else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_V422)
{
Priority[i-1] = 5;
Type[i-1] = Pg_VIDEO_FORMAT_V422;
}
else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_CLJR)
{
Priority[i-1] = 6;
Type[i-1] = Pg_VIDEO_FORMAT_CLJR;
}
else
{
Priority[i-1] = 0;
}
overlay->hwdata->caps.size = sizeof(overlay->hwdata->caps);
}
if ( xv_port == -1 )
{
SDL_SetError("No available video ports for requested format");
return(NULL);
}
//Pick the highest priority format
entries = i -2;
highest = Priority[0]; //make first entry top at begining
select = 0;
for (i = 1; i < entries; i++)
{
if(Priority[i] > highest)
{
highest = Priority[i];
select = i;
}
}
overlay->hwdata->caps.size = sizeof (overlay->hwdata->caps );
PgGetScalerCapabilities(overlay->hwdata->channel, select, &(overlay->hwdata->caps));
overlay->hwdata->props.format = overlay->hwdata->caps.format ;
overlay->hwdata->format = overlay->hwdata->props.format; //to make easier for apps to use
overlay->hwdata->props.size = sizeof (overlay->hwdata->props);
overlay->hwdata->props.src_dim.w = width;
overlay->hwdata->props.src_dim.h = height;
overlay->hwdata->chromakey = PgGetOverlayChromaColor();
// Set chromakey in video widget so we can see overlay data
/* I don't know where the container widget is!!!, I guess it is in hidden->window*/
PtEnter(0);
PtSetArg( &argt, Pt_ARG_FILL_COLOR, overlay->hwdata->chromakey, 0 );
PtSetResources( window, 1, &argt );
PtLeave(0);
fflush( stderr );
overlay->hwdata->props.viewport.ul.x = overlay->hwdata->CurrentWindow.x;
overlay->hwdata->props.viewport.ul.y = overlay->hwdata->CurrentWindow.y;
//Next line MIGHT have x and y reversed!!!!!!!!!!!!
overlay->hwdata->props.viewport.lr.x = overlay->hwdata->CurrentWindow.x +overlay->hwdata->CurrentWindow.w;
overlay->hwdata->props.viewport.lr.y = overlay->hwdata->CurrentWindow.y + overlay->hwdata->CurrentWindow.h;
overlay->hwdata->props.flags =
~Pg_SCALER_PROP_SCALER_ENABLE | Pg_SCALER_PROP_DOUBLE_BUFFER ;
if (overlay->hwdata->chromakey) {
overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_ENABLE;
overlay->hwdata->props.color_key = overlay->hwdata->chromakey;
overlay->hwdata->props.color_key_mask = 0xffffff;
}
else
{
overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_CHROMA_ENABLE;
}
overlay->hwdata->scaler_on = FALSE;
rtncode = PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props));
switch(rtncode)
{
case -1:
SDL_SetError("PgConfigScalerChannel failed\n");
SDL_FreeYUVOverlay(overlay);
return(NULL);
break;
case 1:
grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
break;
case 0:
default:
break;
}
grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
if(overlay->hwdata->channel->yplane1 != NULL)
overlay->hwdata->YStride = overlay->hwdata->channel->yplane1->pitch;
if(overlay->hwdata->channel->uplane1 != NULL)
overlay->hwdata->UStride = overlay->hwdata->channel->uplane1->pitch;
if(overlay->hwdata->channel->vplane1 != NULL)
overlay->hwdata->VStride = overlay->hwdata->channel->vplane1->pitch;
overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel);
if (overlay->hwdata->current == -1)
{
SDL_SetError("PgNextFrame failed, bailing out\n");
SDL_FreeYUVOverlay(overlay);
return(NULL);
}
//set current frame for double buffering
if(overlay->hwdata->current == 0)
{
overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0;
}
else
{
overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1;
}
overlay->hwdata->State = OVERLAY_STATE_ACTIVE;
/* We're all done.. */
return(overlay);
}
int ph_LockYUVOverlay(_THIS, SDL_Overlay *overlay)
{
//int rtncode;
if(overlay == NULL)
return 0;
//set current frame for double buffering
if(overlay->hwdata->current == 0)
{
overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0;
}
else
{
overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1;
}
//Lock gets the pointer and passes it to the app. The app writes all yuv data into overlay->pixels
//Note this is defined as Uint8 **pixels; /* Read-write */
overlay->pixels = &overlay->hwdata->CurrentFrameData->Y;
May 28, 2002
May 28, 2002
498
overlay->pitches = (Uint16*) &(overlay->hwdata->YStride);
Apr 26, 2001
Apr 26, 2001
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
return(0);
}
void ph_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay)
{
int rtncode;
if(overlay == NULL)
return ;
if(overlay->hwdata->scaler_on == FALSE)
{
overlay->hwdata->props.flags |= Pg_SCALER_PROP_SCALER_ENABLE;
rtncode =PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props));
switch(rtncode)
{
case -1:
SDL_SetError("PgConfigScalerChannel failed\n");
SDL_FreeYUVOverlay(overlay);
break;
case 1:
grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
overlay->hwdata->scaler_on = TRUE;
break;
case 0:
default:
overlay->hwdata->scaler_on = TRUE;
break;
}
//This would be the best place to draw chromakey but we do not have a SDL_Surface in the args
//This means we might see a chromakey flicker at startup
}
overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel);
if (overlay->hwdata->current == -1) {
SDL_SetError("PgNextVideoFrame failed\n");
SDL_FreeYUVOverlay(overlay);
return;
}
overlay->pixels = NULL;
}
int ph_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect)
{
int rtncode;
if(overlay == NULL)
return 0;
/*SDL_Rect CurrentWindow*/
//If CurrentWindow has change, move the viewport
if((overlay->hwdata->CurrentWindow.x != dstrect->x) ||
(overlay->hwdata->CurrentWindow.y != dstrect->y) ||
(overlay->hwdata->CurrentWindow.w != dstrect->w) ||
(overlay->hwdata->CurrentWindow.h != dstrect->h))
{
if(overlay->hwdata->State == OVERLAY_STATE_UNINIT)
return -1;
overlay->hwdata->CurrentWindow.x = dstrect->x;
overlay->hwdata->CurrentWindow.y = dstrect->y;
overlay->hwdata->CurrentWindow.w = dstrect->w;
overlay->hwdata->CurrentWindow.h = dstrect->h;
overlay->hwdata->props.viewport.ul.x = overlay->hwdata->CurrentWindow.x;
overlay->hwdata->props.viewport.ul.y = overlay->hwdata->CurrentWindow.y;
//Next line MIGHT have x and y reversed!!!!!!!!!!!!
overlay->hwdata->props.viewport.lr.x = overlay->hwdata->CurrentWindow.x +overlay->hwdata->CurrentWindow.w;
overlay->hwdata->props.viewport.lr.y = overlay->hwdata->CurrentWindow.y + overlay->hwdata->CurrentWindow.h;
rtncode = PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props));
switch(rtncode)
{
case -1:
SDL_SetError("PgConfigScalerChannel failed\n");
SDL_FreeYUVOverlay(overlay);
return(0);
break;
case 1:
grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
break;
case 0:
default:
break;
}
}
//JB the X11 file did this. We do this in SDL_unlock, we need to confirm that lock and unlock are called for each frame!
// XvShmPutImage(GFX_Display, hwdata->port, SDL_Window, SDL_GC,
// hwdata->image, 0, 0, overlay->w, overlay->h,
// dstrect->x, dstrect->y, dstrect->w, dstrect->h, False);
/* This is what this call is
int XvShmPutImage (
Display *dpy,
XvPortID port,
Drawable d,
GC gc,
XvImage *image,
int src_x,
int src_y,
unsigned int src_w,
unsigned int src_h,
int dest_x,
int dest_y,
unsigned int dest_w,
unsigned int dest_h,
Bool send_event
)
*/
return(0);
}
void ph_FreeYUVOverlay(_THIS, SDL_Overlay *overlay)
{
//struct private_yuvhwdata *hwdata;
if(overlay == NULL)
return;
if(overlay->hwdata == NULL)
return;
overlay->hwdata->State = OVERLAY_STATE_UNINIT;
if( overlay->hwdata->channel == NULL )
{
return;
}
PgDestroyVideoChannel(overlay->hwdata->channel);
overlay->hwdata->channel = NULL;
overlay->hwdata->CurrentFrameData = NULL;
free(overlay->hwdata->FrameData0);
free(overlay->hwdata->FrameData1);
overlay->hwdata->FrameData0 = NULL;
overlay->hwdata->FrameData1 = NULL;
free(overlay->hwdata);
}