src/video/photon/SDL_phyuv.c
changeset 370 ba72f259bc88
parent 297 f6ffac90895c
child 380 bce7171e7a85
     1.1 --- a/src/video/photon/SDL_phyuv.c	Sun May 19 19:52:32 2002 +0000
     1.2 +++ b/src/video/photon/SDL_phyuv.c	Sun May 19 19:54:01 2002 +0000
     1.3 @@ -29,7 +29,6 @@
     1.4  
     1.5  #include <stdlib.h>
     1.6  #include <string.h>
     1.7 -//#include <ncurses.h> //only for bool
     1.8  #ifndef bool
     1.9  #define bool char
    1.10  #define TRUE 1
    1.11 @@ -104,7 +103,7 @@
    1.12  	FRAMEDATA *FrameData0;
    1.13  	FRAMEDATA *FrameData1;
    1.14  	PgScalerProps_t	props;
    1.15 -	PgScalerCaps_t		caps;
    1.16 +	PgScalerCaps_t	caps;
    1.17  	PgVideoChannel_t *channel;
    1.18  	SDL_Rect CurrentWindow;
    1.19  	long format;
    1.20 @@ -142,7 +141,7 @@
    1.21  
    1.22  }
    1.23  
    1.24 -SDL_Overlay *ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
    1.25 +SDL_Overlay* ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
    1.26  {
    1.27  	SDL_Overlay *overlay;
    1.28  	struct private_yuvhwdata *hwdata;
    1.29 @@ -162,7 +161,8 @@
    1.30  	PhDCSetCurrent(0);  //Need to set draw context to window esp. if we we in Offscreeen mode
    1.31  
    1.32  	/* Create the overlay structure */
    1.33 -	overlay = (SDL_Overlay *)malloc(sizeof *overlay);
    1.34 +	overlay = (SDL_Overlay *)malloc(sizeof(SDL_Overlay));
    1.35 +        memset(overlay, 0x00, sizeof(SDL_Overlay));
    1.36  	if ( overlay == NULL ) {
    1.37  		SDL_OutOfMemory();
    1.38  		return(NULL);
    1.39 @@ -178,7 +178,8 @@
    1.40  	overlay->hwfuncs = &ph_yuvfuncs;
    1.41  
    1.42  	/* Create the pixel data and lookup tables */
    1.43 -	hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata);
    1.44 +	hwdata = (struct private_yuvhwdata *)malloc(sizeof(struct private_yuvhwdata));
    1.45 +        memset(hwdata, 0x00, sizeof(struct private_yuvhwdata));
    1.46  	overlay->hwdata = hwdata;
    1.47  	if ( hwdata == NULL ) {
    1.48  		SDL_OutOfMemory();
    1.49 @@ -186,54 +187,41 @@
    1.50  		return(NULL);
    1.51  	}
    1.52  	
    1.53 -		if (overlay->hwdata->channel == NULL)
    1.54 -	{
    1.55 -	
    1.56 -  
    1.57 -		if ((overlay->hwdata->channel = PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER,0)) == NULL) 
    1.58 -		{
    1.59 -			SDL_SetError("Create channel failed:%s\n", strerror( errno ));
    1.60 -			free(overlay->hwdata);
    1.61 -			free(overlay);
    1.62 -			return(NULL);
    1.63 -		}
    1.64 -#if 0
    1.65 -		overlay->hwdata->caps.size = sizeof (overlay->hwdata->caps);
    1.66 -		PgGetScalerCapabilities(overlay->hwdata->channel, 0, &(overlay->hwdata->caps));
    1.67 -		if (overlay->hwdata->caps.flags & Pg_SCALER_CAP_DOUBLE_BUFFER)
    1.68 -			overlay->hwdata->props.flags |= Pg_SCALER_PROP_DOUBLE_BUFFER;
    1.69 -#endif	
    1.70 -	}
    1.71 +    if (overlay->hwdata->channel == NULL)
    1.72 +    {
    1.73 +        if ((overlay->hwdata->channel = PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER,0)) == NULL) 
    1.74 +        {
    1.75 +            SDL_SetError("ph_CreateYUVOverlay(): Create channel failed: %s\n", strerror( errno ));
    1.76 +            free(overlay->hwdata);
    1.77 +            free(overlay);
    1.78 +            return (NULL);
    1.79 +        }
    1.80 +    }
    1.81  
    1.82 -overlay->hwdata->CurrentWindow.x = 0;
    1.83 -overlay->hwdata->CurrentWindow.y = 0;
    1.84 -overlay->hwdata->CurrentWindow.w = 320;
    1.85 -overlay->hwdata->CurrentWindow.h = 240;
    1.86 +    overlay->hwdata->CurrentWindow.x = 0;
    1.87 +    overlay->hwdata->CurrentWindow.y = 0;
    1.88 +    overlay->hwdata->CurrentWindow.w = 320;
    1.89 +    overlay->hwdata->CurrentWindow.h = 240;
    1.90  
    1.91 +    overlay->hwdata->State = OVERLAY_STATE_UNINIT;
    1.92  
    1.93 +    overlay->hwdata->screen_bpp = 2;
    1.94 +    overlay->hwdata->scaler_on = FALSE;
    1.95 +    overlay->hwdata->screen_width = 1024;
    1.96 +    overlay->hwdata->screen_height  = 768;
    1.97  
    1.98 -overlay->hwdata->State = OVERLAY_STATE_UNINIT;
    1.99 +    overlay->hwdata->FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
   1.100 +    overlay->hwdata->FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
   1.101  
   1.102 -overlay->hwdata->screen_bpp = 2;
   1.103 -overlay->hwdata->scaler_on = FALSE;
   1.104 -
   1.105 -overlay->hwdata->screen_width = 1024;
   1.106 -overlay->hwdata->screen_height  = 768;
   1.107 -
   1.108 -overlay->hwdata->FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
   1.109 -overlay->hwdata->FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
   1.110 -
   1.111 -overlay->hwdata->caps.size = sizeof(overlay->hwdata->caps);
   1.112 -
   1.113 +    overlay->hwdata->caps.size = sizeof(overlay->hwdata->caps);
   1.114  
   1.115  //Note you really don't need to do this for SDL as you are given a format, but this is a good example
   1.116  
   1.117 -xv_port = -1;
   1.118 -i=0;
   1.119 -	
   1.120 +    xv_port = -1;
   1.121 +    i=0;
   1.122 +
   1.123  while(PgGetScalerCapabilities(overlay->hwdata->channel, i++, &(overlay->hwdata->caps)) == 0) 
   1.124  {
   1.125 -
   1.126  		if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_YV12) //in SDL
   1.127  		{
   1.128