changeset 5239:fe6b890f68f2

Fix crash when playing multiple files. The bug was triggered when the first file had rgb data and the second had yuv data and sdl:aalib was used. Some code duplication removed in the process.
author ksorim
date Thu, 21 Mar 2002 10:22:55 +0000
parents 182fc3f585e8
children e766c07b1d5c
files libvo/vo_sdl.c
diffstat 1 files changed, 17 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_sdl.c	Thu Mar 21 09:22:55 2002 +0000
+++ b/libvo/vo_sdl.c	Thu Mar 21 10:22:55 2002 +0000
@@ -755,67 +755,43 @@
 //static int sdl_setup (int width, int height)
 {
 	struct sdl_priv_s *priv = &sdl_priv;
-        unsigned int sdl_format;
 #ifdef HAVE_X11	
 	static Display *XDisplay;
 	static int XScreen;
 #endif
 
-	sdl_format = format;
-        switch(format){
+    switch(format){
+        case IMGFMT_I420:
+            printf("SDL: Mapping I420 to IYUV\n");
+            format = SDL_IYUV_OVERLAY;
 		case IMGFMT_YV12:
-			if(verbose) printf("SDL: Using 0x%X (YV12) image format\n", format); break;
 		case IMGFMT_IYUV:
-			if(verbose) printf("SDL: Using 0x%X (IYUV) image format\n", format); break;
 		case IMGFMT_YUY2:
-			if(verbose) printf("SDL: Using 0x%X (YUY2) image format\n", format); break;
 		case IMGFMT_UYVY:
-			if(verbose) printf("SDL: Using 0x%X (UYVY) image format\n", format); break;
 		case IMGFMT_YVYU:
-			if(verbose) printf("SDL: Using 0x%X (YVYU) image format\n", format); break;
-		case IMGFMT_I420:
-			if(verbose) printf("SDL: Using 0x%X (I420) image format\n", format);
-			printf("SDL: Mapping I420 to IYUV\n");
-			sdl_format = SDL_IYUV_OVERLAY;
             priv->mode = YUV;
-		break;
+            break;
 		case IMGFMT_BGR15:	
-			if(verbose) printf("SDL: Using 0x%X (BGR15) image format\n", format);
+		case IMGFMT_BGR16:	
+		case IMGFMT_BGR24:	
+		case IMGFMT_BGR32:	
 			priv->mode = BGR;
 			break;
-		case IMGFMT_RGB15:	
-			if(verbose) printf("SDL: Using 0x%X (RGB15) image format\n", format);
-			priv->mode = RGB;
-			break;
-		case IMGFMT_BGR16:	
-			if(verbose) printf("SDL: Using 0x%X (BGR16) image format\n", format);
-			priv->mode = BGR;
-			break;
-		case IMGFMT_RGB16:	
-			if(verbose) printf("SDL: Using 0x%X (RGB16) image format\n", format);
-			priv->mode = RGB;
-			break;
-		case IMGFMT_BGR24:	
-			if(verbose) printf("SDL: Using 0x%X (BGR24) image format\n", format);
-			priv->mode = BGR;
-			break;
-		case IMGFMT_RGB24:	
-			if(verbose) printf("SDL: Using 0x%X (RGB24) image format\n", format);
-			priv->mode = RGB;
-			break;
-		case IMGFMT_BGR32:	
-			if(verbose) printf("SDL: Using 0x%X (BGR32) image format\n", format);
-			priv->mode = BGR;
-			break;
+        case IMGFMT_RGB15:	
+        case IMGFMT_RGB16:	
+        case IMGFMT_RGB24:	
 		case IMGFMT_RGB32:	
-			if(verbose) printf("SDL: Using 0x%X (RGB32) image format\n", format);
 			priv->mode = RGB;
 			break;
 		default:
 			printf("SDL: Unsupported image format (0x%X)\n",format);
 			return -1;
 	}
-	if(priv->mode) {
+
+    if(verbose) printf("SDL: Using 0x%X (%s) image format\n", format,
+                       vo_format_name(format));
+    
+    if(priv->mode != YUV) {
 		priv->sdlflags |= SDL_ANYFORMAT;
 		priv->sdlfullflags |= SDL_ANYFORMAT;
 	}
@@ -840,7 +816,7 @@
     priv->overlay = NULL;
     priv->surface = NULL;
     
-    priv->format = sdl_format;
+    priv->format = format;
     
 #ifdef HAVE_X11
 	if(getenv("DISPLAY")) {