# HG changeset patch # User kmkaplan # Date 1027001192 0 # Node ID 0e2b14e606acfddf8e92a24e4b732e80d6a2fd07 # Parent 9734bfbb200aa46a6c2fa242d8e852c7cb34d192 Round height or width to valid values when doing automatic calculation. diff -r 9734bfbb200a -r 0e2b14e606ac libmpcodecs/vf_scale.c --- a/libmpcodecs/vf_scale.c Wed Jul 17 23:28:37 2002 +0000 +++ b/libmpcodecs/vf_scale.c Thu Jul 18 14:06:32 2002 +0000 @@ -103,13 +103,29 @@ } // 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;