[Mplayer-cvslog] CVS: main/libvo vo_vesa.c,1.2,1.3

Nick Kurshev nick at mplayer.dev.hu
Fri Oct 19 17:09:42 CEST 2001


Update of /cvsroot/mplayer/main/libvo
In directory mplayer:/var/tmp.root/cvs-serv26490/main/libvo

Modified Files:
	vo_vesa.c 
Log Message:
Better resolution detection

Index: vo_vesa.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_vesa.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- vo_vesa.c	18 Oct 2001 15:50:49 -0000	1.2
+++ vo_vesa.c	19 Oct 2001 15:09:40 -0000	1.3
@@ -72,7 +72,7 @@
 static unsigned init_mode; /* mode before run of mplayer */
 static void *init_state = NULL; /* state before run of mplayer */
 static struct win_frame win; /* real-mode window to video memory */
-static void *temp_buffer = NULL; /* for yuv2rgb and sw_scaling */
+static void *yuv_buffer = NULL; /* for yuv2rgb and sw_scaling */
 static unsigned video_mode; /* selected video mode for playback */
 static struct VesaModeInfoBlock video_mode_info;
 
@@ -106,7 +106,7 @@
   int err;
   if((err=vbeRestoreState(init_state)) != VBE_OK) PRINT_VBE_ERR("vbeRestoreState",err);
   if((err=vbeSetMode(init_mode,NULL)) != VBE_OK) PRINT_VBE_ERR("vbeSetMode",err);
-  free(temp_buffer);
+  free(yuv_buffer);
   vbeDestroy();
 }
 
@@ -222,9 +222,10 @@
 /* is called for yuv only */
 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
 {
-	yuv2rgb(temp_buffer, image[0], image[1], image[2], w, h, image_width * ((video_mode_info.BitsPerPixel+7)/8),
+	yuv2rgb(yuv_buffer, image[0], image[1], image[2], w, h,
+		image_width * ((video_mode_info.BitsPerPixel+7)/8),
 		stride[0], stride[1]);
-	__vbeCopyData((uint8_t *)temp_buffer);
+	__vbeCopyData((uint8_t *)yuv_buffer);
 	return 0;
 }
 
@@ -274,6 +275,24 @@
 	return retval;
 }
 
+static char *model2str(unsigned char type)
+{
+  char *retval;
+  switch(type)
+  {
+    case memText: retval = "Text"; break;
+    case memCGA:  retval="CGA"; break;
+    case memHercules: retval="Hercules"; break;
+    case memPL: retval="Planar"; break;
+    case memPK: retval="Packed pixel"; break;
+    case mem256: retval="256"; break;
+    case memRGB: retval="Direct color RGB"; break;
+    case memYUV: retval="Direct color YUV"; break;
+    default: retval="Unknown"; break;
+  }
+  return retval;
+}
+
 /* fullscreen:
  * bit 0 (0x01) means fullscreen (-fs)
  * bit 1 (0x02) means mode switching (-vm)
@@ -295,11 +314,6 @@
 	{
 	  printf("vo_vesa: switches: -fs, -zoom, -flip are not supported\n");
 	}
-	if(!(temp_buffer = malloc(width*height*4)))
-	{
-	  printf("vo_vesa: Can't allocate temporary buffer\n");
-	  return -1;
-	}
 	if((err=vbeInit()) != VBE_OK) { PRINT_VBE_ERR("vbeInit",err); return -1; }
 	memcpy(vib.VESASignature,"VBE2",4);
 	if((err=vbeGetControllerInfo(&vib)) != VBE_OK)
@@ -371,14 +385,14 @@
 			PRINT_VBE_ERR("vbeGetModeInfo",err);
 			return -1;
 		}
-		if(vmib.XResolution > image_width &&
-		   vmib.YResolution > image_height &&
+		if(vmib.XResolution >= image_width &&
+		   vmib.YResolution >= image_height &&
 		   (vmib.ModeAttributes & MOVIE_MODE) == MOVIE_MODE &&
 		   vmib.BitsPerPixel == bpp &&
 		   vmib.MemoryModel == memRGB)
 		   {
-			if(vmib.XResolution < best_x &&
-			   vmib.YResolution < best_y)
+			if(vmib.XResolution <= best_x &&
+			   vmib.YResolution <= best_y)
 			   {
 				best_x = vmib.XResolution;
 				best_y = vmib.YResolution;
@@ -387,12 +401,12 @@
 		   }
 		if(verbose)
 		{
-		  printf("vo_vesa: Mode (%03u): mode=%04X %ux%u@%u attr=%u\n"
-		  	 "vo_vesa:             #planes=%u model=%u #pages=%u\n"
-		  	 "vo_vesa:             winA=%X(attr=%u) winB=%X(attr=%u) winSize=%u winGran=%u\n"
-		  	 "vo_vesa:             direct_color=%u DGA_phys_addr=%08X\n"
+		  printf("vo_vesa: Mode (%03u): mode=%04X %ux%u@%u attr=%x\n"
+			 "vo_vesa:             #planes=%u model=%u(%s) #pages=%u\n"
+			 "vo_vesa:             winA=%X(attr=%u) winB=%X(attr=%u) winSize=%u winGran=%u\n"
+			 "vo_vesa:             direct_color=%u DGA_phys_addr=%08X\n"
 			 ,i,mode_ptr[i],vmib.XResolution,vmib.YResolution,vmib.BitsPerPixel,vmib.ModeAttributes
-			 ,vmib.NumberOfPlanes,vmib.MemoryModel,vmib.NumberOfImagePages
+			 ,vmib.NumberOfPlanes,vmib.MemoryModel,model2str(vmib.MemoryModel),vmib.NumberOfImagePages
 			 ,vmib.WinASegment,vmib.WinAAttributes,vmib.WinBSegment,vmib.WinBAttributes,vmib.WinSize,vmib.WinGranularity
 			 ,vmib.DirectColorModeInfo,vmib.PhysBasePtr);
 		  if(vmib.MemoryModel == 6 || vmib.MemoryModel == 7)
@@ -416,6 +430,11 @@
 		{
 			PRINT_VBE_ERR("vbeGetModeInfo",err);
 			return -1;
+		}
+		if(!(yuv_buffer = malloc(video_mode_info.XResolution*video_mode_info.YResolution*4)))
+		{
+		  printf("vo_vesa: Can't allocate temporary buffer\n");
+		  return -1;
 		}
 		if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE)
 		   win.idx = 0; /* frame A */




More information about the MPlayer-cvslog mailing list