From e2e5f63009bc5053270ce86f36ba155600ea980c Mon Sep 17 00:00:00 2001 From: kmkaplan Date: Thu, 18 Jul 2002 14:06:32 +0000 Subject: Round height or width to valid values when doing automatic calculation. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6747 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vf_scale.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'libmpcodecs') diff --git a/libmpcodecs/vf_scale.c b/libmpcodecs/vf_scale.c index 0ab96bbca0..8cd66c4687 100644 --- a/libmpcodecs/vf_scale.c +++ b/libmpcodecs/vf_scale.c @@ -103,13 +103,29 @@ static int config(struct vf_instance_s* vf, } // calculate the missing parameters: + switch(best) { + case IMGFMT_YUY2: /* YUY2 needs w rounded to 2 */ + if(vf->priv->w==-3) vf->priv->w=(vf->priv->h*width/height+1)&~1; else + if(vf->priv->w==-2) vf->priv->w=(vf->priv->h*d_width/d_height+1)&~1; + if(vf->priv->h==-3) vf->priv->h=vf->priv->w*height/width; else + if(vf->priv->h==-2) vf->priv->h=vf->priv->w*d_height/d_width; + break; + case IMGFMT_YV12: /* YV12 needs w & h rounded to 2 */ + if(vf->priv->w==-3) vf->priv->w=(vf->priv->h*width/height+1)&~1; else + if(vf->priv->w==-2) vf->priv->w=(vf->priv->h*d_width/d_height+1)&~1; + if(vf->priv->h==-3) vf->priv->h=(vf->priv->w*height/width+1)&~1; else + if(vf->priv->h==-2) vf->priv->h=(vf->priv->w*d_height/d_width+2)&~1; + break; + default: if(vf->priv->w==-3) vf->priv->w=vf->priv->h*width/height; else if(vf->priv->w==-2) vf->priv->w=vf->priv->h*d_width/d_height; + if(vf->priv->h==-3) vf->priv->h=vf->priv->w*height/width; else + if(vf->priv->h==-2) vf->priv->h=vf->priv->w*d_height/d_width; + break; + } if(vf->priv->w<0) vf->priv->w=width; else if(vf->priv->w==0) vf->priv->w=d_width; - if(vf->priv->h==-3) vf->priv->h=vf->priv->w*height/width; else - if(vf->priv->h==-2) vf->priv->h=vf->priv->w*d_height/d_width; if(vf->priv->h<0) vf->priv->h=height; else if(vf->priv->h==0) vf->priv->h=d_height; -- cgit v1.2.3