[MPlayer-dev-eng] Scaling with maximum limit
Jan Engelhardt
jengelh at medozas.de
Sat May 30 16:12:25 CEST 2009
The following patch implements a noup=3 mode, which is doing about the
same as xine's -G option, whereby the window will be up- or down-scaled
but never to go over the specified maximum size in any dimension.
Example:
mplayer foo.avi -vf scale=400:300::::::3
VIDEO: [XVID] 704x396 12bpp 23.976 fps 885.7 kbps (108.1 kbyte/s)
[swscaler @ 0x8997300]704x396 -> 400x226
VO: [xv] 400x226 => 401x226 Planar YV12
(Oh see, there's a slight rounding issue yet.)
mplayer foo.avi -vf scale=1024:768::::::3
[swscaler @ 0x8997300]704x396 -> 1024x576
VO: [xv] 1024x576 => 1024x576 Planar YV12
The drawback here is that it uses swscaler, and I would have liked to
make use of hardware scaling when available, but mplayer's
current options are limited.
---
libmpcodecs/vf_scale.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
Index: MPlayer-1.0rc2_r29116/libmpcodecs/vf_scale.c
===================================================================
--- MPlayer-1.0rc2_r29116.orig/libmpcodecs/vf_scale.c
+++ MPlayer-1.0rc2_r29116/libmpcodecs/vf_scale.c
@@ -152,7 +152,16 @@ static int config(struct vf_instance_s*
}
}
- if(vf->priv->noup){
+ if (vf->priv->noup == 3) {
+ double f;
+ if ((double)vf->priv->w / vf->priv->h >=
+ (double)width / height)
+ f = (double)vf->priv->h / height;
+ else
+ f = (double)vf->priv->w / width;
+ vf->priv->w = width * f;
+ vf->priv->h = height * f;
+ } else if (vf->priv->noup > 0) {
if((vf->priv->w > width) + (vf->priv->h > height) >= vf->priv->noup){
vf->priv->w= width;
vf->priv->h= height;
@@ -659,7 +671,7 @@ static m_option_t vf_opts_fields[] = {
// Note that here the 2 field is NULL (ie 0)
// As we want this option to act on the option struct itself
{"presize", 0, CONF_TYPE_OBJ_PRESETS, 0, 0, 0, &size_preset},
- {"noup", ST_OFF(noup), CONF_TYPE_INT, M_OPT_RANGE, 0, 2, NULL},
+ {"noup", ST_OFF(noup), CONF_TYPE_INT, M_OPT_RANGE, 0, 3, NULL},
{"arnd", ST_OFF(accurate_rnd), CONF_TYPE_FLAG, 0, 0, 1, NULL},
{ NULL, NULL, 0, 0, 0, 0, NULL }
};
More information about the MPlayer-dev-eng
mailing list