[MPlayer-dev-eng] [PATCH] vidix ckey support & cvidix aspect

Jake Page jake at CS.Stanford.EDU
Thu Oct 16 23:31:37 CEST 2003


On Thu, 16 Oct 2003, Alex Beregszaszi wrote:
 
> > This patch also has aspect/fullscreen support added to the cvidix
> > driver. The code is almost identical to the fbdev:vidix aspect code.
> > Since cvidix doesn't know anything about the screen resolution, I
> > added parameters to the -vo line to allow for example:
> > 
> > "mplayer -vo cvidix:width=1024:height=768"
> > 
> > The default is 640x480 (same as it was previously).

> Could you separate this part from your patch?

Attached is just the patch to vo_cvidix.c for aspect support.

-Jake
-------------- next part --------------
Index: libvo/vo_cvidix.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_cvidix.c,v
retrieving revision 1.3
diff -u -r1.3 vo_cvidix.c
--- libvo/vo_cvidix.c	5 Oct 2003 15:39:00 -0000	1.3
+++ libvo/vo_cvidix.c	16 Oct 2003 21:30:19 -0000
@@ -18,6 +18,7 @@
 #include "video_out.h"
 #include "video_out_internal.h"
 
+#include "aspect.h"
 #include "mp_msg.h"
 
 #include "vosub_vidix.h"
@@ -38,11 +39,47 @@
 /* VIDIX related */
 static char *vidix_name;
 
+/* "screen" dimensions */
+static int screen_xres = 640;
+static int screen_yres = 480;
+
+static int fs;
 
 static vidix_grkey_t gr_key;
     
 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width,uint32_t d_height, uint32_t flags, char *title, uint32_t format){
-  if(vidix_init(width, height, 0, 0, d_width, d_height, format, 32, 640, 480))mp_msg(MSGT_VO, MSGL_FATAL, "Can't initialize VIDIX driver: %s\n", strerror(errno));
+
+  int image_width,image_height,x_offset,y_offset;
+  int zoom = flags & 0x04;
+
+  fs = flags & 0x01;
+
+  if (zoom || fs) {
+      aspect_save_orig(width,height);
+      aspect_save_prescale(d_width,d_height);
+      aspect_save_screenres(screen_xres,screen_yres);
+      aspect(&image_width,&image_height,fs ? A_ZOOM : A_NOZOOM);    
+  } else {
+      image_width = width;
+      image_height = height;
+  }
+
+  if(screen_xres > image_width)
+      x_offset = (screen_xres - image_width) / 2;
+  else x_offset = 0;
+  if(screen_yres > image_height)
+      y_offset = (screen_yres - image_height) / 2;
+  else y_offset = 0;
+
+  if(vidix_init(width, height, x_offset, y_offset, image_width,
+		image_height, format, 32, screen_xres, screen_yres)) {
+      mp_msg(MSGT_VO, MSGL_FATAL, "Can't initialize VIDIX driver: %s\n",
+	     strerror(errno));
+      return -1;
+  }
+
+  vidix_start();
+
   /*set colorkey*/       
   vidix_start();
   if(vidix_grkey_support()){
@@ -101,10 +138,38 @@
 }
 
 static uint32_t preinit(const char *arg){
-  if(arg)vidix_name = strdup(arg);
-  else {
+  int i;
+  char* endptr = NULL;
+
+  vidix_name = NULL;
+  if(arg) {
+    while(*arg) {
+      if (!strncmp(arg, "width=", 6)) {
+	arg += 6;
+	screen_xres = strtoul(arg, &endptr, 10);
+	if (arg == endptr) {
+	  screen_xres = 640;
+	}
+	arg = endptr;
+      } else if (!strncmp(arg, "height=", 7)) {
+	arg += 7;
+	screen_yres = strtoul(arg, &endptr, 10);
+	if (arg == endptr) {
+	  screen_yres = 480;
+	}
+	arg = endptr;
+      } else {
+	i = 0;
+	while(arg[i] && arg[i] != ':') i++;
+	if (i > 0)
+	  vidix_name = strndup(arg, i);
+	arg += i;
+      }
+      if (*arg == ':')
+	arg++;
+    }
+  } else {
     mp_msg(MSGT_VO, MSGL_INFO, "vo_cvidix: No vidix driver name provided, probing available ones!\n");
-	vidix_name = NULL;
   }
   if(vidix_preinit(vidix_name, &video_out_cvidix))return 1;
   return 0;


More information about the MPlayer-dev-eng mailing list