[MPlayer-dev-eng] [patch] auto-scaling to square pixels in mencoder
eric at lammerts.org
eric at lammerts.org
Sun Apr 28 23:01:13 CEST 2002
Hi,
When I convert MPGs to DivX, I have to watch the aspect ratio of the mpg,
.and scale it appropriately (using -vop scale=w:h). As far as I can see
the only way to do this is to calculate the w and h by hand.
With this patch you don't have to calculate w and h yourself anymore, you
can just use "-vop scale=correctaspect".
Eric
diff -u -r1.8 vf_scale.c
--- libmpcodecs/vf_scale.c 19 Apr 2002 23:29:41 -0000 1.8
+++ libmpcodecs/vf_scale.c 28 Apr 2002 21:01:40 -0000
@@ -15,6 +15,7 @@
struct vf_priv_s {
int w,h;
+ int correctaspect;
unsigned int fmt;
SwsContext *ctx;
};
@@ -82,8 +83,8 @@
}
// calculate the missing parameters:
- if(vf->priv->w<=0) vf->priv->w=width;
- if(vf->priv->h<=0) vf->priv->h=height;
+ if(vf->priv->w<=0) vf->priv->w=vf->priv->correctaspect?d_width:width;
+ if(vf->priv->h<=0) vf->priv->h=vf->priv->correctaspect?d_height:height;
printf("SwScale scaling %dx%d %s to %dx%d %s \n",
width,height,vo_format_name(outfmt),
@@ -166,12 +167,18 @@
vf->priv->ctx=NULL;
vf->priv->w=
vf->priv->h=-1;
- if(args) sscanf(args, "%d:%d",
- &vf->priv->w,
- &vf->priv->h);
- printf("SwScale: %d x %d\n",
- vf->priv->w,
- vf->priv->h);
+ vf->priv->correctaspect=0;
+ if(strcmp(args, "correctaspect") == 0){
+ vf->priv->correctaspect=1;
+ printf("SwScale: correctaspect\n");
+ }else{
+ if(args) sscanf(args, "%d:%d",
+ &vf->priv->w,
+ &vf->priv->h);
+ printf("SwScale: %d x %d\n",
+ vf->priv->w,
+ vf->priv->h);
+ }
return 1;
}
More information about the MPlayer-dev-eng
mailing list