[MPlayer-dev-eng] autoexpand patch
jan gregor
pamela at rak.bb.euroweb.sk
Fri Nov 5 09:27:27 CET 2004
> why not add a new (6th) option to expand, so someone could do things
> like:
> -vf expand=:600:::4/3 to get the video expanded to 600 height, and
> the width calculated from the given 4:3 aspect ratio.
> also if someone only wants aspect set, do -vf expand=aspect=4/3
> (it's handled by subconfig parser, equal to expand=:::::4/3)
Hello.
I have inserted aspect option to vf_expand.c as suggested here, with one
exception: aspect is not defined like x/y, but there are 2 separate
parameters named ratio_x and ratio_y. Functionality is the same, only
"/" did problems with buitin checks on parameters, because it expected
it to be one integer value. Maybe there was some workaround (type of
parameter other than integer), but I am not too familiar with mplayer
source code, so I simply split it.
So, if you want to expand movie resolution to 4/3, you have to specify:
-vf expand=:::::4:3.
Patch included, suggestions welcome.
Best regards
Jan Gregor
-------------- next part --------------
diff -u -N -r ../MPlayer-1.0pre5/libmpcodecs/vf_expand.c ./libmpcodecs/vf_expand.c
--- ../MPlayer-1.0pre5/libmpcodecs/vf_expand.c 2003-06-19 20:26:13.000000000 +0200
+++ ./libmpcodecs/vf_expand.c 2004-11-05 08:49:36.000000000 +0100
@@ -27,11 +27,13 @@
int exp_w,exp_h;
int exp_x,exp_y;
int osd;
+ int ratio_x,ratio_y;
unsigned char* fb_ptr;
} vf_priv_dflt = {
-1,-1,
-1,-1,
0,
+ 1,1,
NULL
};
@@ -160,7 +162,9 @@
static int config(struct vf_instance_s* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
+ float aspect;
if (outfmt == IMGFMT_IF09) return 0;
+
// calculate the missing parameters:
#if 0
if(vf->priv->exp_w<width) vf->priv->exp_w=width;
@@ -172,6 +176,19 @@
if ( vf->priv->exp_h == -1 ) vf->priv->exp_h=height;
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;
+ if (vf->priv->ratio_x>1 || vf->priv->ratio_y>1) {
+ // calculate expand aspect
+ aspect=(float)vf->priv->ratio_x/vf->priv->ratio_y;
+ // set expanded values to default width/height for further calculations
+ //vf->priv->exp_w=width;
+ //vf->priv->exp_h=height;
+ // calculates which resolution should be expanded
+ if (vf->priv->exp_h*aspect < vf->priv->exp_w) {
+ vf->priv->exp_h=vf->priv->exp_w/aspect;
+ } else if (vf->priv->exp_w/aspect < vf->priv->exp_h) {
+ vf->priv->exp_w=vf->priv->exp_h*aspect;
+ }
+ }
#endif
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;
@@ -343,18 +361,24 @@
vf->priv->osd=0;
// parse args ->
} // if(!vf->priv)
- if(args) sscanf(args, "%d:%d:%d:%d:%d",
+ if(args) sscanf(args, "%d:%d:%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",
+ &vf->priv->osd,
+ &vf->priv->ratio_x,
+ &vf->priv->ratio_y
+ );
+ mp_msg(MSGT_VFILTER, MSGL_INFO, "Expand: %d x %d, %d ; %d (-1=autodetect) osd: %d ratio: %d/%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->ratio_x,
+ vf->priv->ratio_y
+ );
return 1;
}
@@ -365,6 +389,8 @@
{"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},
{"osd", ST_OFF(osd), CONF_TYPE_FLAG, 0 , 0, 1, NULL},
+ {"ratio_x", ST_OFF(ratio_x), CONF_TYPE_INT, M_OPT_MIN , 1, 0, NULL},
+ {"ratio_y", ST_OFF(ratio_y), CONF_TYPE_INT, M_OPT_MIN , 1, 0, NULL},
{ NULL, NULL, 0, 0, 0, 0, NULL }
};
More information about the MPlayer-dev-eng
mailing list