Date: Sat, 18 May 2002 17:40:53 +0300
authorSam Lantinga <slouken@libsdl.org>
Sun, 19 May 2002 19:54:01 +0000
changeset 370ba72f259bc88
parent 369 e405cf8bf580
child 371 db0cc6034336
Date: Sat, 18 May 2002 17:40:53 +0300
From: Mike Gorchak <mike@malva.ua>
Subject: New QNX patches

- Added more error check to avoid SEGFAULTS;
- Fixed bug in update function for SDL_HWSURFACE. BTW: update is much
faster than before.
- Added checks for SDL_HWSURFACE flag, chosen bpp must be equal to
desktop bpp for SDL_HWSURFACE.
- Fixed overlay bug, no more SEGFAULTS.
src/video/photon/SDL_ph_image.c
src/video/photon/SDL_ph_video.c
src/video/photon/SDL_phyuv.c
     1.1 --- a/src/video/photon/SDL_ph_image.c	Sun May 19 19:52:32 2002 +0000
     1.2 +++ b/src/video/photon/SDL_ph_image.c	Sun May 19 19:54:01 2002 +0000
     1.3 @@ -65,9 +65,7 @@
     1.4          }
     1.5          break;
     1.6          default:{
     1.7 -            /* should never get here */
     1.8 -            fprintf(stderr,"error: unsupported bbp = %d\n",
     1.9 -                    screen->format->BitsPerPixel);
    1.10 +            fprintf(stderr,"ph_SetupImage(): unsupported bbp = %d\n", screen->format->BitsPerPixel);
    1.11              return -1;
    1.12          }
    1.13          break;
    1.14 @@ -106,83 +104,82 @@
    1.15  
    1.16  int ph_SetupOCImage(_THIS, SDL_Surface *screen)
    1.17  {
    1.18 -	int type = 0;
    1.19 +    int type = 0;
    1.20  
    1.21 -	/* Determine image type */
    1.22 -	switch(screen->format->BitsPerPixel)
    1.23 -	{
    1.24 -		case 8:{
    1.25 -			type = Pg_IMAGE_PALETTE_BYTE;
    1.26 +    /* Determine image type */
    1.27 +    switch(screen->format->BitsPerPixel)
    1.28 +    {
    1.29 +        case 8: {
    1.30 +                    type = Pg_IMAGE_PALETTE_BYTE;
    1.31 +                }
    1.32 +                break;
    1.33 +        case 15:{
    1.34 +                    type = Pg_IMAGE_DIRECT_555; 
    1.35  		}
    1.36  		break;
    1.37 -		case 15:{
    1.38 -			type = Pg_IMAGE_DIRECT_555; 
    1.39 -		}
    1.40 -		break;
    1.41 -		case 16:{
    1.42 -			type = Pg_IMAGE_DIRECT_565; 
    1.43 -		}
    1.44 -		break;
    1.45 +        case 16:{
    1.46 +                    type = Pg_IMAGE_DIRECT_565; 
    1.47 +                }
    1.48 +                break;
    1.49 +        case 24:{
    1.50 +                    type = Pg_IMAGE_DIRECT_888;
    1.51 +                }
    1.52 +                break;
    1.53 +        case 32:{
    1.54 +                    type = Pg_IMAGE_DIRECT_8888;
    1.55 +                }
    1.56 +                break;
    1.57 +        default:{
    1.58 +                    fprintf(stderr,"ph_SetupOCImage(): unsupported bpp = %d\n", screen->format->BitsPerPixel);
    1.59 +                    return -1;
    1.60 +                }
    1.61 +                break;
    1.62 +    }
    1.63  
    1.64 -		case 24:{
    1.65 -			type = Pg_IMAGE_DIRECT_888;
    1.66 -		}
    1.67 -		break;
    1.68 -		
    1.69 -		case 32:{
    1.70 -			type = Pg_IMAGE_DIRECT_8888;
    1.71 -		}
    1.72 -		break;
    1.73 -		default:{
    1.74 -		/* should never get here */
    1.75 -			fprintf(stderr,"error: unsupported bbp = %d\n",
    1.76 -					screen->format->BitsPerPixel);
    1.77 -			return -1;
    1.78 -		}
    1.79 -		break;
    1.80 -	}
    1.81 +    OCImage.FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof(FRAMEDATA)));
    1.82 +    OCImage.FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof(FRAMEDATA)));
    1.83  
    1.84 -	OCImage.FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
    1.85 -	OCImage.FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
    1.86 +    if(OCImage.direct_context == NULL)
    1.87 +    {
    1.88 +        OCImage.direct_context = PdCreateDirectContext();
    1.89 +    }
    1.90  
    1.91 -	if(OCImage.direct_context == NULL)
    1.92 -	   OCImage.direct_context = PdCreateDirectContext();
    1.93 +    OCImage.offscreen_context = PdCreateOffscreenContext(0, screen->w, screen->h, Pg_OSC_MEM_PAGE_ALIGN);
    1.94  
    1.95 -	OCImage.offscreen_context = PdCreateOffscreenContext(0,screen->w,screen->h, Pg_OSC_MEM_PAGE_ALIGN);
    1.96 -				
    1.97 -	if (OCImage.offscreen_context == NULL)
    1.98 -	{
    1.99 -	   printf("PdCreateOffscreenContext  failed\n");
   1.100 -	   return -1;
   1.101 -	}
   1.102 +    if (OCImage.offscreen_context == NULL)
   1.103 +    {
   1.104 +        fprintf(stderr, "ph_SetupOCImage(): PdCreateOffscreenContext failed !\n");
   1.105 +        return -1;
   1.106 +    }
   1.107  
   1.108 -	OCImage.Stride = OCImage.offscreen_context->pitch;	
   1.109 +    OCImage.Stride = OCImage.offscreen_context->pitch;	
   1.110  
   1.111 -        if (OCImage.flags & SDL_DOUBLEBUF)
   1.112 -      	   printf("hardware flag for doublebuf offscreen context\n");
   1.113 +    if (OCImage.flags & SDL_DOUBLEBUF)
   1.114 +    {
   1.115 +        fprintf(stderr, "ph_SetupOCImage(): Hardware flag for doublebuf offscreen context\n");
   1.116 +    }
   1.117  
   1.118 -			
   1.119 -			OCImage.dc_ptr.ptr8 = (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context);
   1.120 -			
   1.121 -			OCImage.CurrentFrameData = OCImage.FrameData0;
   1.122 -			OCImage.CurrentFrameData->Y = OCImage.dc_ptr.ptr8;
   1.123 -			OCImage.CurrentFrameData->U = NULL;
   1.124 -			OCImage.CurrentFrameData->V = NULL;
   1.125 -			OCImage.current = 0;
   1.126 -	
   1.127 -			if(OCImage.dc_ptr.ptr8 == NULL)
   1.128 -			{
   1.129 - 				printf("PdGetOffscreenContextPtr failed\n");
   1.130 - 				return -1;
   1.131 -			}
   1.132 -			
   1.133 -			PhDCSetCurrent(OCImage.offscreen_context);
   1.134 +    OCImage.dc_ptr.ptr8 = (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context);
   1.135  
   1.136 -			screen->pixels = OCImage.CurrentFrameData->Y;
   1.137 -	
   1.138 -			this->UpdateRects = ph_OCUpdate;
   1.139 +    if (OCImage.dc_ptr.ptr8 == NULL)
   1.140 +    {
   1.141 +        fprintf(stderr, "ph_SetupOCImage(): PdGetOffscreenContextPtr failed !\n");
   1.142 +        return -1;
   1.143 +    }
   1.144  
   1.145 -	return 0;
   1.146 +    OCImage.CurrentFrameData = OCImage.FrameData0;
   1.147 +    OCImage.CurrentFrameData->Y = OCImage.dc_ptr.ptr8;
   1.148 +    OCImage.CurrentFrameData->U = NULL;
   1.149 +    OCImage.CurrentFrameData->V = NULL;
   1.150 +    OCImage.current = 0;
   1.151 +
   1.152 +    PhDCSetCurrent(OCImage.offscreen_context);
   1.153 +
   1.154 +    screen->pixels = OCImage.CurrentFrameData->Y;
   1.155 +
   1.156 +    this->UpdateRects = ph_OCUpdate;
   1.157 +
   1.158 +    return 0;
   1.159  }
   1.160  
   1.161  int ph_SetupOpenGLImage(_THIS, SDL_Surface* screen)
   1.162 @@ -242,7 +239,6 @@
   1.163          return ph_SetupImage(this, screen);
   1.164      }      
   1.165  }
   1.166 -
   1.167  int ph_AllocHWSurface(_THIS, SDL_Surface *surface)
   1.168  {
   1.169      return(-1);
   1.170 @@ -302,20 +298,21 @@
   1.171  
   1.172          if (PgDrawPhImageRectmx(&ph_pos, SDL_Image, &ph_rect, 0) < 0)
   1.173          {
   1.174 -            fprintf(stderr,"ph_NormalUpdate: PgDrawPhImageRectmx failed.\n");
   1.175 +            fprintf(stderr,"ph_NormalUpdate(): PgDrawPhImageRectmx failed.\n");
   1.176          }
   1.177      }
   1.178  
   1.179      if (PgFlush() < 0)
   1.180      {
   1.181 -    	fprintf(stderr,"ph_NormalUpdate: PgFlush failed.\n");
   1.182 +    	fprintf(stderr,"ph_NormalUpdate(): PgFlush failed.\n");
   1.183      }
   1.184  }
   1.185 +
   1.186  void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects)
   1.187  {
   1.188      PhPoint_t zero = {0};
   1.189 -    PhRect_t src_rect;
   1.190 -    PhRect_t dest_rect;
   1.191 +    PhArea_t src_rect;
   1.192 +    PhArea_t dest_rect;
   1.193  
   1.194      if(OCImage.direct_context == NULL)
   1.195      {
   1.196 @@ -323,7 +320,7 @@
   1.197      }
   1.198  
   1.199      PgSetRegion(PtWidgetRid(window));
   1.200 -    PgSetClipping(0,NULL);
   1.201 +    PgSetClipping(0, NULL);
   1.202      PgWaitHWIdle();
   1.203  
   1.204      for (i=0; i<numrects; ++i)
   1.205 @@ -333,24 +330,27 @@
   1.206              continue;
   1.207          }
   1.208  
   1.209 -        src_rect.ul.x=rects[i].x;
   1.210 -        src_rect.ul.y=rects[i].y;
   1.211 -        dest_rect.ul.x=rects[i].x;
   1.212 -        dest_rect.ul.y=rects[i].y;
   1.213 +        src_rect.pos.x=rects[i].x;
   1.214 +        src_rect.pos.y=rects[i].y;
   1.215 +        dest_rect.pos.x=rects[i].x;
   1.216 +        dest_rect.pos.y=rects[i].y;
   1.217  
   1.218 -        dest_rect.lr.x=src_rect.lr.x= rects[i].x +rects[i].w;
   1.219 -        dest_rect.lr.y=src_rect.lr.y= rects[i].y +rects[i].h;
   1.220 +        src_rect.size.w=rects[i].w;
   1.221 +        src_rect.size.h=rects[i].h;
   1.222 +        dest_rect.size.w=rects[i].w;
   1.223 +        dest_rect.size.h=rects[i].h;
   1.224  
   1.225 -        zero.x = zero.y = 0;
   1.226 -        PgSetTranslation (&zero, 0);
   1.227 +        zero.x = 0;
   1.228 +        zero.y = 0;
   1.229 +        PgSetTranslation(&zero, 0);
   1.230          PgSetRegion(PtWidgetRid(window));
   1.231 -        PgSetClipping(0,NULL);
   1.232 -        PgContextBlitArea(OCImage.offscreen_context, (PhArea_t *)(&src_rect), NULL, (PhArea_t *)(&dest_rect));
   1.233 +        PgSetClipping(0, NULL);
   1.234 +        PgContextBlitArea(OCImage.offscreen_context, &src_rect, NULL, &dest_rect);
   1.235 +    }
   1.236  
   1.237 -    }
   1.238      if (PgFlush() < 0)
   1.239      {
   1.240 -        fprintf(stderr,"ph_OCUpdate: PgFlush failed.\n");
   1.241 +        fprintf(stderr,"ph_OCUpdate(): PgFlush failed.\n");
   1.242      }
   1.243      
   1.244      /* later used to toggling double buffer */
     2.1 --- a/src/video/photon/SDL_ph_video.c	Sun May 19 19:52:32 2002 +0000
     2.2 +++ b/src/video/photon/SDL_ph_video.c	Sun May 19 19:54:01 2002 +0000
     2.3 @@ -255,6 +255,16 @@
     2.4      if ((flags & SDL_OPENGL)!=SDL_OPENGL)
     2.5      {
     2.6          pargc=0;
     2.7 +        
     2.8 +        // prevent using HWSURFACE in window mode if desktop bpp != chosen bpp
     2.9 +        if ((flags & SDL_HWSURFACE) && (!(flags & SDL_FULLSCREEN)))
    2.10 +        {
    2.11 +           if (desktopbpp!=bpp)
    2.12 +           {
    2.13 +              fprintf(stderr, "ph_SetVideoMode(): SDL_HWSURFACE available only with chosen bpp equal desktop bpp !\n");
    2.14 +              return NULL;
    2.15 +           }
    2.16 +        }
    2.17  
    2.18          PtSetArg(&arg[pargc++], Pt_ARG_DIM, &dim, 0);
    2.19          PtSetArg(&arg[pargc++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
    2.20 @@ -317,7 +327,7 @@
    2.21  #else
    2.22      if (flags & SDL_OPENGL) /* if no built-in OpenGL support */
    2.23      {
    2.24 -        fprintf(stderr, "error: no OpenGL support, try to recompile library.\n");
    2.25 +        fprintf(stderr, "ph_SetVideoMode(): no OpenGL support, try to recompile library.\n");
    2.26          current->flags=(flags & (~SDL_OPENGL));
    2.27          return NULL;
    2.28  #endif /* HAVE_OPENGL */
    2.29 @@ -332,7 +342,7 @@
    2.30              {
    2.31                  if ((mode = get_mode_any_format(width, height, bpp)) == 0)
    2.32                  {
    2.33 -                    fprintf(stderr,"error: get_mode_any_format failed\n");
    2.34 +                    fprintf(stderr,"ph_SetVideoMode(): get_mode_any_format failed !\n");
    2.35                      exit(1);
    2.36                  }
    2.37              }
    2.38 @@ -340,7 +350,7 @@
    2.39              {
    2.40                  if ((mode = get_mode(width, height, bpp)) == 0)
    2.41                  {
    2.42 -                    fprintf(stderr,"error: get_mode failed\n");
    2.43 +                    fprintf(stderr,"ph_SetVideoMode(): get_mode failed !\n");
    2.44                      exit(1);
    2.45                  }
    2.46              }
    2.47 @@ -362,7 +372,7 @@
    2.48  
    2.49              if (PgSetVideoMode(&settings) < 0)
    2.50              {
    2.51 -                fprintf(stderr,"error: PgSetVideoMode failed\n");
    2.52 +                fprintf(stderr,"ph_SetVideoMode(): PgSetVideoMode failed !\n");
    2.53              }
    2.54  
    2.55              current->flags = (flags & (~SDL_RESIZABLE)); /* no resize for Direct Context */
    2.56 @@ -424,8 +434,15 @@
    2.57      current->format->BitsPerPixel = bpp;
    2.58      current->format->BytesPerPixel = (bpp+7)/8;
    2.59      current->pitch = SDL_CalculatePitch(current);
    2.60 +
    2.61      /* Must call at least once it setup image planes */
    2.62 -    ph_ResizeImage(this, current, flags);
    2.63 +    rtnval = ph_ResizeImage(this, current, flags);
    2.64 +    
    2.65 +    if (rtnval==-1)
    2.66 +    {
    2.67 +        fprintf(stderr,"ph_SetVideoMode(): ph_ResizeImage failed !\n");
    2.68 +        return NULL;
    2.69 +    }
    2.70  
    2.71      /* delayed set caption call */
    2.72      if (captionflag)
    2.73 @@ -512,9 +529,10 @@
    2.74                  SDL_Image->palette[i] |= colors[i-firstcolor].g<<8;
    2.75                  SDL_Image->palette[i] |= colors[i-firstcolor].b;
    2.76              }
    2.77 +
    2.78 +           /* image needs to be redrawed, very slow method */
    2.79 +           PgDrawPhImage(&point, SDL_Image, 0);
    2.80          }
    2.81 -        /* image needs to be redrawed, very slow method */
    2.82 -        PgDrawPhImage(&point, SDL_Image, 0);
    2.83      }
    2.84      else
    2.85      {
    2.86 @@ -533,7 +551,10 @@
    2.87                  /* window mode must use soft palette */
    2.88                  PgSetPalette((PgColor_t*)&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_SOFT, 0);
    2.89                  /* image needs to be redrawed, very slow method */
    2.90 -                PgDrawPhImage(&point, SDL_Image, 0);
    2.91 +                if (SDL_Image)
    2.92 +                {
    2.93 +                   PgDrawPhImage(&point, SDL_Image, 0);
    2.94 +                }
    2.95              }
    2.96              else
    2.97              {
    2.98 @@ -602,7 +623,7 @@
    2.99  
   2.100      if (oglctx==NULL)
   2.101      {
   2.102 -        fprintf(stderr,"ph_SetupOpenGLContext: cannot create OpenGL context.\n");
   2.103 +        fprintf(stderr,"ph_SetupOpenGLContext(): cannot create OpenGL context.\n");
   2.104          return (-1);
   2.105      }
   2.106  
     3.1 --- a/src/video/photon/SDL_phyuv.c	Sun May 19 19:52:32 2002 +0000
     3.2 +++ b/src/video/photon/SDL_phyuv.c	Sun May 19 19:54:01 2002 +0000
     3.3 @@ -29,7 +29,6 @@
     3.4  
     3.5  #include <stdlib.h>
     3.6  #include <string.h>
     3.7 -//#include <ncurses.h> //only for bool
     3.8  #ifndef bool
     3.9  #define bool char
    3.10  #define TRUE 1
    3.11 @@ -104,7 +103,7 @@
    3.12  	FRAMEDATA *FrameData0;
    3.13  	FRAMEDATA *FrameData1;
    3.14  	PgScalerProps_t	props;
    3.15 -	PgScalerCaps_t		caps;
    3.16 +	PgScalerCaps_t	caps;
    3.17  	PgVideoChannel_t *channel;
    3.18  	SDL_Rect CurrentWindow;
    3.19  	long format;
    3.20 @@ -142,7 +141,7 @@
    3.21  
    3.22  }
    3.23  
    3.24 -SDL_Overlay *ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
    3.25 +SDL_Overlay* ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
    3.26  {
    3.27  	SDL_Overlay *overlay;
    3.28  	struct private_yuvhwdata *hwdata;
    3.29 @@ -162,7 +161,8 @@
    3.30  	PhDCSetCurrent(0);  //Need to set draw context to window esp. if we we in Offscreeen mode
    3.31  
    3.32  	/* Create the overlay structure */
    3.33 -	overlay = (SDL_Overlay *)malloc(sizeof *overlay);
    3.34 +	overlay = (SDL_Overlay *)malloc(sizeof(SDL_Overlay));
    3.35 +        memset(overlay, 0x00, sizeof(SDL_Overlay));
    3.36  	if ( overlay == NULL ) {
    3.37  		SDL_OutOfMemory();
    3.38  		return(NULL);
    3.39 @@ -178,7 +178,8 @@
    3.40  	overlay->hwfuncs = &ph_yuvfuncs;
    3.41  
    3.42  	/* Create the pixel data and lookup tables */
    3.43 -	hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata);
    3.44 +	hwdata = (struct private_yuvhwdata *)malloc(sizeof(struct private_yuvhwdata));
    3.45 +        memset(hwdata, 0x00, sizeof(struct private_yuvhwdata));
    3.46  	overlay->hwdata = hwdata;
    3.47  	if ( hwdata == NULL ) {
    3.48  		SDL_OutOfMemory();
    3.49 @@ -186,54 +187,41 @@
    3.50  		return(NULL);
    3.51  	}
    3.52  	
    3.53 -		if (overlay->hwdata->channel == NULL)
    3.54 -	{
    3.55 -	
    3.56 -  
    3.57 -		if ((overlay->hwdata->channel = PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER,0)) == NULL) 
    3.58 -		{
    3.59 -			SDL_SetError("Create channel failed:%s\n", strerror( errno ));
    3.60 -			free(overlay->hwdata);
    3.61 -			free(overlay);
    3.62 -			return(NULL);
    3.63 -		}
    3.64 -#if 0
    3.65 -		overlay->hwdata->caps.size = sizeof (overlay->hwdata->caps);
    3.66 -		PgGetScalerCapabilities(overlay->hwdata->channel, 0, &(overlay->hwdata->caps));
    3.67 -		if (overlay->hwdata->caps.flags & Pg_SCALER_CAP_DOUBLE_BUFFER)
    3.68 -			overlay->hwdata->props.flags |= Pg_SCALER_PROP_DOUBLE_BUFFER;
    3.69 -#endif	
    3.70 -	}
    3.71 +    if (overlay->hwdata->channel == NULL)
    3.72 +    {
    3.73 +        if ((overlay->hwdata->channel = PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER,0)) == NULL) 
    3.74 +        {
    3.75 +            SDL_SetError("ph_CreateYUVOverlay(): Create channel failed: %s\n", strerror( errno ));
    3.76 +            free(overlay->hwdata);
    3.77 +            free(overlay);
    3.78 +            return (NULL);
    3.79 +        }
    3.80 +    }
    3.81  
    3.82 -overlay->hwdata->CurrentWindow.x = 0;
    3.83 -overlay->hwdata->CurrentWindow.y = 0;
    3.84 -overlay->hwdata->CurrentWindow.w = 320;
    3.85 -overlay->hwdata->CurrentWindow.h = 240;
    3.86 +    overlay->hwdata->CurrentWindow.x = 0;
    3.87 +    overlay->hwdata->CurrentWindow.y = 0;
    3.88 +    overlay->hwdata->CurrentWindow.w = 320;
    3.89 +    overlay->hwdata->CurrentWindow.h = 240;
    3.90  
    3.91 +    overlay->hwdata->State = OVERLAY_STATE_UNINIT;
    3.92  
    3.93 +    overlay->hwdata->screen_bpp = 2;
    3.94 +    overlay->hwdata->scaler_on = FALSE;
    3.95 +    overlay->hwdata->screen_width = 1024;
    3.96 +    overlay->hwdata->screen_height  = 768;
    3.97  
    3.98 -overlay->hwdata->State = OVERLAY_STATE_UNINIT;
    3.99 +    overlay->hwdata->FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
   3.100 +    overlay->hwdata->FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
   3.101  
   3.102 -overlay->hwdata->screen_bpp = 2;
   3.103 -overlay->hwdata->scaler_on = FALSE;
   3.104 -
   3.105 -overlay->hwdata->screen_width = 1024;
   3.106 -overlay->hwdata->screen_height  = 768;
   3.107 -
   3.108 -overlay->hwdata->FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
   3.109 -overlay->hwdata->FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
   3.110 -
   3.111 -overlay->hwdata->caps.size = sizeof(overlay->hwdata->caps);
   3.112 -
   3.113 +    overlay->hwdata->caps.size = sizeof(overlay->hwdata->caps);
   3.114  
   3.115  //Note you really don't need to do this for SDL as you are given a format, but this is a good example
   3.116  
   3.117 -xv_port = -1;
   3.118 -i=0;
   3.119 -	
   3.120 +    xv_port = -1;
   3.121 +    i=0;
   3.122 +
   3.123  while(PgGetScalerCapabilities(overlay->hwdata->channel, i++, &(overlay->hwdata->caps)) == 0) 
   3.124  {
   3.125 -
   3.126  		if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_YV12) //in SDL
   3.127  		{
   3.128