changeset 10002:b2b070bf934e

generate meaningful d_width & d_height when scaling, rather than useless nonsense.
author rfelker
date Sun, 27 Apr 2003 10:04:39 +0000
parents 3a6ae4199f67
children a93d75c7ab5f
files libmpcodecs/vf_scale.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_scale.c	Sun Apr 27 09:45:38 2003 +0000
+++ b/libmpcodecs/vf_scale.c	Sun Apr 27 10:04:39 2003 +0000
@@ -209,8 +209,17 @@
     }
 
     if(!opt_screen_size_x && !opt_screen_size_y){
-	d_width=d_width*vf->priv->w/width;
-	d_height=d_height*vf->priv->h/height;
+	// Compute new d_width and d_height, preserving aspect
+	// while ensuring that both are >= output size in pixels.
+	if (vf->priv->h * d_width > vf->priv->w * d_height) {
+		d_width = vf->priv->h * d_width / d_height;
+		d_height = vf->priv->h;
+	} else {
+		d_height = vf->priv->w * d_height / d_width;
+		d_width = vf->priv->w;
+	}
+	//d_width=d_width*vf->priv->w/width;
+	//d_height=d_height*vf->priv->h/height;
     }
     return vf_next_config(vf,vf->priv->w,vf->priv->h,d_width,d_height,flags,best);
 }