[MPlayer-dev-eng] [PATCH] allow relative coordinates for the vf_crop

René Rebe rene at exactcode.de
Mon Feb 13 14:52:43 CET 2006


Hi all,

It got on my nerves for some time that I have to compute the resulting width and
height manually all the itme - a task screaming for a computer. Also just
cutting off the overscan noise usually on DVB broadcasts requires multiple
parameter sets depending on the actual broadcast format (e.g. classic 4:3
vs. a real (black border-less) 16:9 transmissions).

Allow relative cuts using negative values, e.g. crop="-20:-200".

If something like this is ok for you, I'll patch the documentation accordingly.

  - Rene Rebe <rene at exactcode.de>

--- MPlayer-1.0pre7try2/libmpcodecs/vf_crop.c	2003-05-20 19:42:33.000000000 +0200
+++ MPlayer-1.0pre7try2-fixed/libmpcodecs/vf_crop.c	2006-02-13 13:35:19.927524500 +0100
@@ -28,9 +28,13 @@
 static int config(struct vf_instance_s* vf,
         int width, int height, int d_width, int d_height,
 	unsigned int flags, unsigned int outfmt){
+    if (vf->priv->crop_w < 0)
+      vf->priv->crop_w = width + vf->priv->crop_w;
+    if (vf->priv->crop_h < 0)
+      vf->priv->crop_h = height + vf->priv->crop_h;
     // 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_w>width) vf->priv->crop_w=width;
+    if(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;
     // rounding:
@@ -156,7 +163,7 @@
     &vf->priv->crop_h,
     &vf->priv->crop_x,
     &vf->priv->crop_y);
-    mp_msg(MSGT_VFILTER, MSGL_INFO, "Crop: %d x %d, %d ; %d\n",
+   mp_msg(MSGT_VFILTER, MSGL_INFO, "Crop: %d x %d @%d,%d\n",
     vf->priv->crop_w,
     vf->priv->crop_h,
     vf->priv->crop_x,
@@ -166,10 +173,10 @@
 
 #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
 static m_option_t vf_opts_fields[] = {
-  {"w", ST_OFF(crop_w), CONF_TYPE_INT, M_OPT_MIN,0 ,0, NULL},
-  {"h", ST_OFF(crop_h), CONF_TYPE_INT, M_OPT_MIN,0 ,0, NULL},
-  {"x", ST_OFF(crop_x), CONF_TYPE_INT, M_OPT_MIN,-1 ,0, NULL},
-  {"y", ST_OFF(crop_y), CONF_TYPE_INT, M_OPT_MIN,-1 ,0, NULL},
+  {"w", ST_OFF(crop_w), CONF_TYPE_INT, 0, 0, 0, NULL},
+  {"h", ST_OFF(crop_h), CONF_TYPE_INT, 0, 0, 0, NULL},
+  {"x", ST_OFF(crop_x), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL},
+  {"y", ST_OFF(crop_y), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL},
   { NULL, NULL, 0, 0, 0, 0,  NULL }
 };
 


-- 
René Rebe - Rubensstr. 64 - 12157 Berlin (Europe / Germany)
            http://www.exactcode.de | http://www.t2-project.org
            +49 (0)30  255 897 45




More information about the MPlayer-dev-eng mailing list