[Mplayer-cvslog] CVS: main/libmpcodecs vf_crop.c,1.4,1.5 vf_expand.c,1.9,1.10 vf_scale.c,1.9,1.10

Arpi of Ize arpi at mplayerhq.hu
Sun May 12 21:06:24 CEST 2002


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv6643

Modified Files:
	vf_crop.c vf_expand.c vf_scale.c 
Log Message:
keep aspect ratio - based on Fredrik Kuivinen's idea

Index: vf_crop.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_crop.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- vf_crop.c	14 Apr 2002 02:07:29 -0000	1.4
+++ vf_crop.c	12 May 2002 19:06:15 -0000	1.5
@@ -13,24 +13,30 @@
     int crop_x,crop_y;
 };
 
+extern int opt_screen_size_x;
+extern int opt_screen_size_y;
+
 //===========================================================================//
 
 static int config(struct vf_instance_s* vf,
         int width, int height, int d_width, int d_height,
 	unsigned int flags, unsigned int outfmt){
-    int ret;
-    printf("crop->config() called\n");
     // calculate the missing parameters:
     if(vf->priv->crop_w<=0 || vf->priv->crop_w>width) vf->priv->crop_w=width;
     if(vf->priv->crop_h<=0 || vf->priv->crop_h>height) vf->priv->crop_h=height;
     if(vf->priv->crop_x<0) vf->priv->crop_x=(width-vf->priv->crop_w)/2;
     if(vf->priv->crop_y<0) vf->priv->crop_y=(height-vf->priv->crop_h)/2;
     // check:
-    if(vf->priv->crop_w+vf->priv->crop_x>width) return 0; // bad width
-    if(vf->priv->crop_h+vf->priv->crop_y>height) return 0; // bad height
-    ret=vf_next_config(vf,vf->priv->crop_w,vf->priv->crop_h,d_width,d_height,flags,outfmt);
-    printf("crop->config() return %d\n",ret);
-    return ret;
+    if(vf->priv->crop_w+vf->priv->crop_x>width ||
+       vf->priv->crop_h+vf->priv->crop_y>height){
+	printf("crop: bad position/width/height - cropped area is out of the original!\n");
+	return 0;
+    }
+    if(!opt_screen_size_x && !opt_screen_size_y){
+	d_width=d_width*vf->priv->crop_w/width;
+	d_height=d_height*vf->priv->crop_h/height;
+    }
+    return vf_next_config(vf,vf->priv->crop_w,vf->priv->crop_h,d_width,d_height,flags,outfmt);
 }
 
 static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){

Index: vf_expand.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_expand.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- vf_expand.c	1 May 2002 14:15:05 -0000	1.9
+++ vf_expand.c	12 May 2002 19:06:15 -0000	1.10
@@ -26,6 +26,9 @@
     unsigned char* fb_ptr;
 };
 
+extern int opt_screen_size_x;
+extern int opt_screen_size_y;
+
 //===========================================================================//
 #ifdef OSD_SUPPORT
 
@@ -143,7 +146,6 @@
 static int config(struct vf_instance_s* vf,
         int width, int height, int d_width, int d_height,
 	unsigned int flags, unsigned int outfmt){
-    int ret;
     // calculate the missing parameters:
 #if 0
     if(vf->priv->exp_w<width) vf->priv->exp_w=width;
@@ -159,8 +161,12 @@
     if(vf->priv->exp_x<0 || vf->priv->exp_x+width>vf->priv->exp_w) vf->priv->exp_x=(vf->priv->exp_w-width)/2;
     if(vf->priv->exp_y<0 || vf->priv->exp_y+height>vf->priv->exp_h) vf->priv->exp_y=(vf->priv->exp_h-height)/2;
     vf->priv->fb_ptr=NULL;
-    ret=vf_next_config(vf,vf->priv->exp_w,vf->priv->exp_h,d_width,d_height,flags,outfmt);
-    return ret;
+
+    if(!opt_screen_size_x && !opt_screen_size_y){
+	d_width=d_width*vf->priv->exp_w/width;
+	d_height=d_height*vf->priv->exp_h/height;
+    }
+    return vf_next_config(vf,vf->priv->exp_w,vf->priv->exp_h,d_width,d_height,flags,outfmt);
 }
 
 // there are 4 cases:

Index: vf_scale.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_scale.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- vf_scale.c	6 May 2002 22:50:02 -0000	1.9
+++ vf_scale.c	12 May 2002 19:06:15 -0000	1.10
@@ -19,6 +19,9 @@
     SwsContext *ctx;
 };
 
+extern int opt_screen_size_x;
+extern int opt_screen_size_y;
+
 //===========================================================================//
 
 static unsigned int outfmt_list[]={
@@ -105,7 +108,11 @@
 	return 0;
     }
     vf->priv->fmt=best;
-    
+
+    if(!opt_screen_size_x && !opt_screen_size_y){
+	d_width=d_width*vf->priv->w/width;
+	d_height=d_height*vf->priv->h/height;
+    }
     return vf_next_config(vf,vf->priv->w,vf->priv->h,d_width,d_height,flags,best);
 }
 




More information about the MPlayer-cvslog mailing list