[MPlayer-dev-eng] [PATCH] Aspect for vf_expand

Oded Shimon ods15 at ods15.dyndns.org
Fri Jul 1 15:34:08 CEST 2005


Add an 'aspect' and 'round' parameters for vf_expand ...

Works good..

- ods15
-------------- next part --------------
Index: libmpcodecs/vf_expand.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_expand.c,v
retrieving revision 1.29
diff -u -r1.29 vf_expand.c
--- libmpcodecs/vf_expand.c	24 Apr 2005 09:29:01 -0000	1.29
+++ libmpcodecs/vf_expand.c	1 Jul 2005 13:31:49 -0000
@@ -27,12 +27,16 @@
     int exp_w,exp_h;
     int exp_x,exp_y;
     int osd;
+    double aspect;
+    int round;
     unsigned char* fb_ptr;
     int first_slice;
 } vf_priv_dflt = {
   -1,-1,
   -1,-1,
   0,
+  0.,
+  1,
   NULL,
   0
 };
@@ -178,6 +182,18 @@
       else if ( vf->priv->exp_h < -1 ) vf->priv->exp_h=height - vf->priv->exp_h;
         else if( vf->priv->exp_h<height ) vf->priv->exp_h=height;
 #endif
+    if (vf->priv->aspect) {
+        if (vf->priv->exp_h < vf->priv->exp_w * vf->priv->aspect) {
+            vf->priv->exp_h = vf->priv->exp_w * vf->priv->aspect;
+        } else {
+            vf->priv->exp_w = vf->priv->exp_h / vf->priv->aspect;
+        }
+    }
+    if (vf->priv->round > 1) {
+    	vf->priv->exp_w = (1 + (vf->priv->exp_w - 1) / vf->priv->round) * vf->priv->round;
+        vf->priv->exp_h = (1 + (vf->priv->exp_h - 1) / vf->priv->round) * vf->priv->round;
+    }
+
     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;
@@ -377,27 +393,14 @@
     vf->draw_slice=draw_slice;
     vf->get_image=get_image;
     vf->put_image=put_image;
-    if(!vf->priv) {
-    vf->priv=malloc(sizeof(struct vf_priv_s));
-    vf->priv->exp_x=
-    vf->priv->exp_y=
-    vf->priv->exp_w=
-    vf->priv->exp_h=-1;
-    vf->priv->osd=0;
-    //  parse args ->
-    } // if(!vf->priv)
-    if(args) sscanf(args, "%d:%d:%d:%d:%d", 
-    &vf->priv->exp_w,
-    &vf->priv->exp_h,
-    &vf->priv->exp_x,
-    &vf->priv->exp_y,
-    &vf->priv->osd);
-    mp_msg(MSGT_VFILTER, MSGL_INFO, "Expand: %d x %d, %d ; %d  (-1=autodetect) osd: %d\n",
+    mp_msg(MSGT_VFILTER, MSGL_INFO, "Expand: %d x %d, %d ; %d, osd: %d, aspect: %lf, round: %d\n",
     vf->priv->exp_w,
     vf->priv->exp_h,
     vf->priv->exp_x,
     vf->priv->exp_y,
-    vf->priv->osd);
+    vf->priv->osd,
+    vf->priv->aspect,
+    vf->priv->round);
     return 1;
 }
 
@@ -407,6 +410,8 @@
   {"h", ST_OFF(exp_h), CONF_TYPE_INT, 0, 0 ,0, NULL},
   {"x", ST_OFF(exp_x), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL},
   {"y", ST_OFF(exp_y), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL},
+  {"aspect", ST_OFF(aspect), CONF_TYPE_DOUBLE, M_OPT_MIN, 0, 0, NULL},
+  {"round", ST_OFF(round), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL},
   {"osd", ST_OFF(osd), CONF_TYPE_FLAG, 0 , 0, 1, NULL},
   { NULL, NULL, 0, 0, 0, 0,  NULL }
 };
Index: DOCS/man/en/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/man/en/mplayer.1,v
retrieving revision 1.1022
diff -u -r1.1022 mplayer.1
--- DOCS/man/en/mplayer.1	20 Jun 2005 18:28:46 -0000	1.1022
+++ DOCS/man/en/mplayer.1	1 Jul 2005 13:31:57 -0000
@@ -4176,7 +4176,7 @@
 .PD 1
 .
 .TP
-.B expand[=w:h:x:y:o]
+.B expand[=w:h:x:y:o:a:r]
 Expands (not scales) movie resolution to the given value and places the
 unscaled original at coordinates x, y.
 Can be used for placing subtitles/\:OSD in the resulting black bands.
@@ -4201,6 +4201,19 @@
 .br
 1: enable
 .REss
+.IPs <a>\ \ 
+Expands to an aspect instead of a resolution. (default: 0)
+.sp 1
+.I EXAMPLE:
+.PD 0
+.RSs
+.IP expand=800::::3/4
+Expands to 800x600, unless the movie is higher resolution, then it
+expands to fill a 3/4 aspect.
+.RE
+.PD 1
+.IPs <r>\ \ 
+Rounds up to make both width and height divisable by r. (default: 1)
 .RE
 .
 .TP


More information about the MPlayer-dev-eng mailing list