SDL_phyuv.c
上传用户:sun1608
上传日期:2007-02-02
资源大小:6116k
文件大小:18k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

Visual C++

  1. /*
  2.     SDL - Simple DirectMedia Layer
  3.     Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License as published by the Free Software Foundation; either
  7.     version 2 of the License, or (at your option) any later version.
  8.     This library is distributed in the hope that it will be useful,
  9.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.     Library General Public License for more details.
  12.     You should have received a copy of the GNU Library General Public
  13.     License along with this library; if not, write to the Free
  14.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  15.     Sam Lantinga
  16.     slouken@libsdl.org
  17. */
  18. #ifdef SAVE_RCSID
  19. static char rcsid =
  20.  "@(#) $Id: SDL_phyuv.c,v 1.4 2002/04/22 21:38:05 wmay Exp $";
  21. #endif
  22. /* This is the QNX Realtime Platform version for SDL YUV video overlays */
  23. #include <stdlib.h>
  24. #include <string.h>
  25. //#include <ncurses.h> //only for bool
  26. #ifndef bool
  27. #define bool char
  28. #define TRUE 1
  29. #define FALSE 0
  30. #endif
  31. #include <errno.h>
  32. #include <Ph.h>
  33. #include <Pt.h>
  34. #include "SDL_error.h"
  35. #include "SDL_video.h"
  36. #include "SDL_phyuv_c.h"
  37. #include "SDL_yuvfuncs.h"
  38. #if 0  //just for reference
  39. /* YUV data formats FourCC    Layout H sample (YUV) V sample (YUV) BPP */
  40. #define Pg_VIDEO_FORMAT_IYU1 0x31555949 /* U2Y2Y2V2Y2Y2 144 111 12  */
  41. #define Pg_VIDEO_FORMAT_IYU2 0x32555949 /* U4Y4V4U4Y4V4 111 111 24  */
  42. #define Pg_VIDEO_FORMAT_UYVY 0x59565955 /* U8Y8V8Y8 122 111 16  */
  43. #define Pg_VIDEO_FORMAT_YUY2 0x32595559 /* Y8U8Y8V8 122 111 16  */
  44. #define Pg_VIDEO_FORMAT_YVYU 0x55595659 /* Y8V8Y8U8 122 111 16  */
  45. #define Pg_VIDEO_FORMAT_V422 0x56343232 /* V8Y8U8Y8 122 111 16  */
  46. #define Pg_VIDEO_FORMAT_CLJR 0x524a4c43 /* V6U6Y5Y5Y5Y5 133 111 8   */
  47. #define Pg_VIDEO_FORMAT_YVU9 0x39555659 /* Planar YVU 144 144 9   */
  48. #define Pg_VIDEO_FORMAT_YV12 0x32315659 /* Planar YUV 122 122 12  */
  49. /* There seems to be no FourCC that matches this */
  50. #define Pg_VIDEO_FORMAT_YUV420 0x00000100 /* Planar YUV 122 111 16  */
  51. /* These formats are the same as YV12, except the U and V planes do not have to contiguously follow the Y plane */
  52. /* but they're all the same to us, since we always have 3 plane pointers */
  53. #define Pg_VIDEO_FORMAT_CLPL Pg_VIDEO_FORMAT_YV12 /* Cirrus Logic Planar format */
  54. #define Pg_VIDEO_FORMAT_VBPL Pg_VIDEO_FORMAT_YV12 /* VooDoo Banshee planar format */
  55. #define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U */
  56. #define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V */
  57. #define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 */
  58. #define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 */
  59. #define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 */
  60. #endif 
  61. #define OVERLAY_STATE_UNINIT  0
  62. #define OVERLAY_STATE_ACTIVE 1
  63. /* The functions used to manipulate software video overlays */
  64. static struct private_yuvhwfuncs ph_yuvfuncs = {
  65. ph_LockYUVOverlay,
  66. ph_UnlockYUVOverlay,
  67. ph_DisplayYUVOverlay,
  68. ph_FreeYUVOverlay
  69. };
  70. typedef struct {
  71.   int id;
  72.   int width, height;
  73.   int data_size;              /* bytes */
  74.   int num_planes;
  75.   int *pitches;               /* bytes */
  76.   int *offsets;               /* bytes */
  77.   char *data;
  78.   void *obdata;     
  79. } XvImage;
  80. struct private_yuvhwdata {
  81. XvImage *image;
  82. FRAMEDATA *CurrentFrameData;
  83. FRAMEDATA *FrameData0;
  84. FRAMEDATA *FrameData1;
  85. PgScalerProps_t props;
  86. PgScalerCaps_t caps;
  87. PgVideoChannel_t *channel;
  88. SDL_Rect CurrentWindow;
  89. long format;
  90. int screen_width;
  91. int screen_height ;
  92. int screen_bpp ;    //2
  93. bool planar;
  94. bool scaler_on ;
  95. int current;
  96. long YStride;
  97. long VStride;
  98. long UStride;
  99. long chromakey;
  100. unsigned long State;
  101. long flags;
  102. };
  103. extern PgVideoChannel_t * PgCreateVideoChannel(unsigned type, unsigned flags);
  104. extern int PgGetScalerCapabilities( PgVideoChannel_t *channel, int format_index, PgScalerCaps_t *vcaps );
  105. extern int PgConfigScalerChannel(PgVideoChannel_t *channel, PgScalerProps_t *props);
  106. extern void PgDestroyVideoChannel(PgVideoChannel_t *channel);
  107. extern PgColor_t PgGetOverlayChromaColor(void);
  108. void
  109. grab_ptrs2(PgVideoChannel_t *channel, FRAMEDATA *Frame0, FRAMEDATA *Frame1 )
  110. {
  111. /* Buffers have moved; re-obtain the pointers */
  112. Frame0->Y = (unsigned char *)PdGetOffscreenContextPtr(channel->yplane1);
  113. Frame1->Y = (unsigned char *)PdGetOffscreenContextPtr(channel->yplane2);
  114. Frame0->U = (unsigned char *)PdGetOffscreenContextPtr(channel->uplane1);
  115. Frame1->U = (unsigned char *)PdGetOffscreenContextPtr(channel->uplane2);
  116. Frame0->V = (unsigned char *)PdGetOffscreenContextPtr(channel->vplane1);
  117. Frame1->V = (unsigned char *)PdGetOffscreenContextPtr(channel->vplane2);
  118. }
  119. SDL_Overlay *ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
  120. {
  121. SDL_Overlay *overlay;
  122. struct private_yuvhwdata *hwdata;
  123. int xv_port;
  124. int rtncode;
  125. // PhRect_t rect;
  126. // PhSysInfo_t info;
  127. // PhRegion_t region;
  128. // short x, y;
  129. PtArg_t argt;
  130. int i =0;
  131. // bool bCont = TRUE;
  132. int Priority[20];
  133. int Type[20];
  134. int entries, select, highest;
  135. PhDCSetCurrent(0);  //Need to set draw context to window esp. if we we in Offscreeen mode
  136. /* Create the overlay structure */
  137. overlay = (SDL_Overlay *)malloc(sizeof *overlay);
  138. if ( overlay == NULL ) {
  139. SDL_OutOfMemory();
  140. return(NULL);
  141. }
  142. memset(overlay, 0, (sizeof *overlay));
  143. /* Fill in the basic members */
  144. overlay->format = format;
  145. overlay->w = width;
  146. overlay->h = height;
  147. /* Set up the YUV surface function structure */
  148. overlay->hwfuncs = &ph_yuvfuncs;
  149. /* Create the pixel data and lookup tables */
  150. hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata);
  151. overlay->hwdata = hwdata;
  152. if ( hwdata == NULL ) {
  153. SDL_OutOfMemory();
  154. SDL_FreeYUVOverlay(overlay);
  155. return(NULL);
  156. }
  157. if (overlay->hwdata->channel == NULL)
  158. {
  159.   
  160. if ((overlay->hwdata->channel = PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER,0)) == NULL) 
  161. {
  162. SDL_SetError("Create channel failed:%sn", strerror( errno ));
  163. free(overlay->hwdata);
  164. free(overlay);
  165. return(NULL);
  166. }
  167. #if 0
  168. overlay->hwdata->caps.size = sizeof (overlay->hwdata->caps);
  169. PgGetScalerCapabilities(overlay->hwdata->channel, 0, &(overlay->hwdata->caps));
  170. if (overlay->hwdata->caps.flags & Pg_SCALER_CAP_DOUBLE_BUFFER)
  171. overlay->hwdata->props.flags |= Pg_SCALER_PROP_DOUBLE_BUFFER;
  172. #endif
  173. }
  174. overlay->hwdata->CurrentWindow.x = 0;
  175. overlay->hwdata->CurrentWindow.y = 0;
  176. overlay->hwdata->CurrentWindow.w = 320;
  177. overlay->hwdata->CurrentWindow.h = 240;
  178. overlay->hwdata->State = OVERLAY_STATE_UNINIT;
  179. overlay->hwdata->screen_bpp = 2;
  180. overlay->hwdata->scaler_on = FALSE;
  181. overlay->hwdata->screen_width = 1024;
  182. overlay->hwdata->screen_height  = 768;
  183. overlay->hwdata->FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
  184. overlay->hwdata->FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
  185. overlay->hwdata->caps.size = sizeof(overlay->hwdata->caps);
  186. //Note you really don't need to do this for SDL as you are given a format, but this is a good example
  187. xv_port = -1;
  188. i=0;
  189. while(PgGetScalerCapabilities(overlay->hwdata->channel, i++, &(overlay->hwdata->caps)) == 0) 
  190. {
  191. if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_YV12) //in SDL
  192. {
  193. Priority[i-1] = 0;
  194. Type[i-1] = Pg_VIDEO_FORMAT_YV12;
  195. if(format == Pg_VIDEO_FORMAT_YV12)
  196. {
  197. overlay->hwdata->props.format =  Pg_VIDEO_FORMAT_YV12;
  198. xv_port = 1; //supported
  199. Priority[i-1] = 100; //force selected
  200. }
  201. }
  202. else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_YVU9) //in SDL
  203. {
  204. Priority[i-1] = 0;
  205. Type[i-1] = Pg_VIDEO_FORMAT_YVU9;
  206. if(format == Pg_VIDEO_FORMAT_YVU9)
  207. {
  208. overlay->hwdata->props.format =  Pg_VIDEO_FORMAT_YVU9;
  209. xv_port = 1; //supported
  210. Priority[i-1] = 100; //force selected
  211. }
  212. }
  213. #if 0 //this part of SDL is YUV specific
  214. else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_RGB555)
  215. {
  216. Priority[i-1] = 3;
  217. Type[i-1] = Pg_VIDEO_FORMAT_RGB555;
  218. }
  219. else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_RGB565)
  220. {
  221. Priority[i-1] =  2;
  222. Type[i-1] = Pg_VIDEO_FORMAT_RGB565;
  223. }
  224. else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_RGB8888)
  225. {
  226. Priority[i-1] = 1;
  227. Type[i-1] = Pg_VIDEO_FORMAT_RGB8888;
  228. }
  229. #endif
  230. else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_IYU1)
  231. {
  232. Priority[i-1] = 0;
  233. Type[i-1] = Pg_VIDEO_FORMAT_IYU1;
  234. }
  235. else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_IYU2)
  236. {
  237. Priority[i-1] = 0;
  238. Type[i-1] = Pg_VIDEO_FORMAT_IYU2;
  239. }
  240. else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_UYVY) //in SDL
  241. {
  242. Priority[i-1] = 7;
  243. Type[i-1] = Pg_VIDEO_FORMAT_UYVY;
  244. if(format == Pg_VIDEO_FORMAT_UYVY)
  245. {
  246. overlay->hwdata->props.format =  Pg_VIDEO_FORMAT_UYVY;
  247. xv_port = 1; //supported
  248. Priority[i-1] = 100; //force selected
  249. }
  250. }
  251. else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_YUY2) //in SDL
  252. {
  253. Priority[i-1] = 8;
  254. Type[i-1] = Pg_VIDEO_FORMAT_YUY2;
  255. if(format == Pg_VIDEO_FORMAT_YUY2)
  256. {
  257. overlay->hwdata->props.format =  Pg_VIDEO_FORMAT_YUY2;
  258. xv_port = 1; //supported
  259. Priority[i-1] = 100; //force selected
  260. }
  261. }
  262. else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_YVYU) //in SDL
  263. {
  264. Priority[i-1] = 4;
  265. Type[i-1] = Pg_VIDEO_FORMAT_YVYU;
  266. if(format == Pg_VIDEO_FORMAT_YVYU)
  267. {
  268. overlay->hwdata->props.format =  Pg_VIDEO_FORMAT_YVYU;
  269. xv_port = 1; //supported
  270. Priority[i-1] = 100; //force selected
  271. }
  272. }
  273. else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_V422)
  274. {
  275. Priority[i-1] = 5;
  276. Type[i-1] = Pg_VIDEO_FORMAT_V422;
  277. }
  278. else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_CLJR)
  279. {
  280. Priority[i-1] = 6;
  281. Type[i-1] = Pg_VIDEO_FORMAT_CLJR;
  282. }
  283. else
  284. {
  285. Priority[i-1] = 0;
  286. }
  287. overlay->hwdata->caps.size = sizeof(overlay->hwdata->caps);
  288. }
  289. if ( xv_port == -1 )
  290. {
  291. SDL_SetError("No available video ports for requested format");
  292. return(NULL);
  293. }
  294.  
  295. //Pick the highest priority format
  296. entries = i -2;
  297. highest = Priority[0]; //make first entry top at begining
  298. select = 0;
  299. for (i = 1; i < entries; i++)
  300. {
  301.    if(Priority[i] > highest)
  302.    {
  303.       highest = Priority[i];
  304.       select  = i;
  305.    }
  306.  
  307.  
  308.  overlay->hwdata->caps.size = sizeof (overlay->hwdata->caps );
  309. PgGetScalerCapabilities(overlay->hwdata->channel, select, &(overlay->hwdata->caps));
  310. overlay->hwdata->props.format = overlay->hwdata->caps.format ;
  311.     overlay->hwdata->format = overlay->hwdata->props.format;  //to make easier for apps to use
  312. overlay->hwdata->props.size = sizeof (overlay->hwdata->props);
  313.     overlay->hwdata->props.src_dim.w = width;   
  314.     overlay->hwdata->props.src_dim.h = height;   
  315. overlay->hwdata->chromakey = PgGetOverlayChromaColor();
  316. // Set chromakey in video widget so we can see overlay data
  317. /* I don't know where the container widget is!!!, I guess it is in hidden->window*/
  318. PtEnter(0);
  319. PtSetArg( &argt, Pt_ARG_FILL_COLOR, overlay->hwdata->chromakey, 0 );
  320. PtSetResources( window, 1, &argt ); 
  321. PtLeave(0);
  322. fflush( stderr );
  323. overlay->hwdata->props.viewport.ul.x = overlay->hwdata->CurrentWindow.x;
  324. overlay->hwdata->props.viewport.ul.y = overlay->hwdata->CurrentWindow.y;
  325. //Next line MIGHT have x and y reversed!!!!!!!!!!!!
  326. overlay->hwdata->props.viewport.lr.x = overlay->hwdata->CurrentWindow.x +overlay->hwdata->CurrentWindow.w;
  327. overlay->hwdata->props.viewport.lr.y = overlay->hwdata->CurrentWindow.y + overlay->hwdata->CurrentWindow.h;
  328. overlay->hwdata->props.flags =
  329.     ~Pg_SCALER_PROP_SCALER_ENABLE | Pg_SCALER_PROP_DOUBLE_BUFFER ;
  330. if (overlay->hwdata->chromakey) {
  331. overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_ENABLE;
  332. overlay->hwdata->props.color_key = overlay->hwdata->chromakey;
  333. overlay->hwdata->props.color_key_mask = 0xffffff;
  334. else
  335. {
  336. overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_CHROMA_ENABLE;
  337. }
  338. overlay->hwdata->scaler_on = FALSE;
  339.  rtncode =    PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props));
  340. switch(rtncode)
  341. {
  342. case -1:
  343. SDL_SetError("PgConfigScalerChannel failedn");
  344. SDL_FreeYUVOverlay(overlay);
  345. return(NULL);
  346.     break;
  347. case 1:
  348. grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
  349. break;
  350. case 0:
  351. default:
  352.     break;
  353. }
  354. grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
  355. if(overlay->hwdata->channel->yplane1 != NULL)
  356. overlay->hwdata->YStride = overlay->hwdata->channel->yplane1->pitch;
  357. if(overlay->hwdata->channel->uplane1 != NULL)
  358. overlay->hwdata->UStride = overlay->hwdata->channel->uplane1->pitch;
  359. if(overlay->hwdata->channel->vplane1 != NULL)
  360. overlay->hwdata->VStride = overlay->hwdata->channel->vplane1->pitch;
  361. overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel);
  362. if (overlay->hwdata->current == -1)
  363. {
  364. SDL_SetError("PgNextFrame failed, bailing outn");
  365. SDL_FreeYUVOverlay(overlay);
  366. return(NULL);
  367. }
  368.         
  369.         //set current frame for double buffering
  370. if(overlay->hwdata->current == 0)
  371. {
  372. overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0;
  373. }
  374. else
  375. {
  376. overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1;
  377. }
  378.     
  379. overlay->hwdata->State = OVERLAY_STATE_ACTIVE;
  380. /* We're all done.. */
  381. return(overlay);
  382. }
  383. int ph_LockYUVOverlay(_THIS, SDL_Overlay *overlay)
  384. {
  385. //int rtncode;
  386. if(overlay == NULL)
  387.    return 0;
  388. //set current frame for double buffering
  389. if(overlay->hwdata->current == 0)
  390. {
  391. overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0;
  392. }
  393. else
  394. {
  395. overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1;
  396. }
  397. //Lock gets the pointer and passes it to the app. The app writes all yuv data into overlay->pixels
  398. //Note this is defined as Uint8 **pixels; /* Read-write */
  399. overlay->pixels = &overlay->hwdata->CurrentFrameData->Y; 
  400. overlay->pitches  = &overlay->hwdata->YStride;
  401. return(0);
  402. }
  403. void ph_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay)
  404. {
  405. int rtncode;
  406. if(overlay == NULL)
  407.    return ;
  408. if(overlay->hwdata->scaler_on == FALSE) 
  409. {
  410. overlay->hwdata->props.flags |= Pg_SCALER_PROP_SCALER_ENABLE;
  411.         rtncode =PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props));
  412.          switch(rtncode)
  413. {
  414. case -1:
  415. SDL_SetError("PgConfigScalerChannel failedn");
  416. SDL_FreeYUVOverlay(overlay);
  417.     break;
  418. case 1:
  419. grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
  420. overlay->hwdata->scaler_on = TRUE;
  421. break;
  422. case 0:
  423. default:
  424. overlay->hwdata->scaler_on = TRUE;
  425.     break;
  426. }
  427. //This would be the best place to draw chromakey but we do not have a SDL_Surface in the args
  428. //This means we might see a chromakey flicker at startup
  429. }
  430. overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel);
  431. if (overlay->hwdata->current == -1) {
  432. SDL_SetError("PgNextVideoFrame failedn");
  433. SDL_FreeYUVOverlay(overlay);
  434. return;
  435. }
  436. overlay->pixels = NULL;
  437. }
  438. int ph_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect)
  439. {
  440. int rtncode;
  441. if(overlay == NULL)
  442.    return 0;
  443. /*SDL_Rect CurrentWindow*/
  444. //If CurrentWindow has change, move the viewport
  445. if((overlay->hwdata->CurrentWindow.x != dstrect->x) ||
  446.   (overlay->hwdata->CurrentWindow.y != dstrect->y) ||
  447.   (overlay->hwdata->CurrentWindow.w != dstrect->w) ||
  448.   (overlay->hwdata->CurrentWindow.h != dstrect->h))
  449. {
  450. if(overlay->hwdata->State == OVERLAY_STATE_UNINIT)
  451. return -1;
  452. overlay->hwdata->CurrentWindow.x = dstrect->x;
  453.    overlay->hwdata->CurrentWindow.y = dstrect->y;
  454.    overlay->hwdata->CurrentWindow.w = dstrect->w;
  455.    overlay->hwdata->CurrentWindow.h = dstrect->h;
  456. overlay->hwdata->props.viewport.ul.x = overlay->hwdata->CurrentWindow.x;
  457. overlay->hwdata->props.viewport.ul.y = overlay->hwdata->CurrentWindow.y;
  458. //Next line MIGHT have x and y reversed!!!!!!!!!!!!
  459. overlay->hwdata->props.viewport.lr.x = overlay->hwdata->CurrentWindow.x +overlay->hwdata->CurrentWindow.w;
  460. overlay->hwdata->props.viewport.lr.y = overlay->hwdata->CurrentWindow.y + overlay->hwdata->CurrentWindow.h;
  461.      rtncode = PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props));
  462. switch(rtncode)
  463. {
  464. case -1:
  465. SDL_SetError("PgConfigScalerChannel failedn");
  466. SDL_FreeYUVOverlay(overlay);
  467. return(0);
  468.     break;
  469. case 1:
  470. grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
  471. break;
  472. case 0:
  473. default:
  474.     break;
  475. }
  476. }
  477. //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!
  478. // XvShmPutImage(GFX_Display, hwdata->port, SDL_Window, SDL_GC,
  479. //               hwdata->image, 0, 0, overlay->w, overlay->h,
  480. //               dstrect->x, dstrect->y, dstrect->w, dstrect->h, False);            
  481. /*  This is what this call is
  482. int XvShmPutImage (
  483.    Display *dpy,
  484.    XvPortID port,
  485.    Drawable d,
  486.    GC gc,
  487.    XvImage *image,
  488.    int src_x,
  489.    int src_y,
  490.    unsigned int src_w,
  491.    unsigned int src_h,
  492.    int dest_x, 
  493.    int dest_y,
  494.    unsigned int dest_w,
  495.    unsigned int dest_h,
  496.    Bool send_event
  497. )
  498. */
  499. return(0);
  500. }
  501. void ph_FreeYUVOverlay(_THIS, SDL_Overlay *overlay)
  502. {
  503. //struct private_yuvhwdata *hwdata;
  504. if(overlay == NULL)
  505. return;
  506. if(overlay->hwdata == NULL)
  507. return;
  508. overlay->hwdata->State = OVERLAY_STATE_UNINIT;
  509. if( overlay->hwdata->channel == NULL )
  510. {
  511. return;
  512. }
  513. PgDestroyVideoChannel(overlay->hwdata->channel);
  514. overlay->hwdata->channel = NULL;
  515. overlay->hwdata->CurrentFrameData = NULL;  
  516. free(overlay->hwdata->FrameData0);
  517. free(overlay->hwdata->FrameData1);
  518. overlay->hwdata->FrameData0 = NULL;
  519. overlay->hwdata->FrameData1 = NULL;
  520. free(overlay->hwdata);
  521. }