From e2c7f29878f985ede30b7e0b8a996fbb8852dcb7 Mon Sep 17 00:00:00 2001 From: ddennedy Date: Sat, 7 Feb 2004 03:31:00 +0000 Subject: [PATCH] rescale aspect handling redux git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@120 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/modules/gtk2/filter_rescale.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/modules/gtk2/filter_rescale.c b/src/modules/gtk2/filter_rescale.c index 3032e67..d9c7f83 100644 --- a/src/modules/gtk2/filter_rescale.c +++ b/src/modules/gtk2/filter_rescale.c @@ -58,19 +58,18 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * #if 0 // Determine maximum size within the aspect ratio: - double aspect_ratio = mlt_frame_get_aspect_ratio( this ); - // TODO: these need to be provided - double dsar = oheight < 576 ? (8.0 / 9.0) : (48.0 / 45.0); - double ssar = iheight < 576 ? (8.0 / 9.0) : (48.0 / 45.0); + double i_aspect_ratio = mlt_frame_get_aspect_ratio( this ); + // TODO: this needs to be provided q + #define o_aspect_ratio ( double )( 4.0 / 3.0 ) - if ( ( (double) owidth * dsar / iwidth * ssar ) < ( (double) oheight / iheight ) ) - oheight = (double) owidth * dsar / aspect_ratio; + if ( ( owidth * i_aspect_ratio * o_aspect_ratio ) > owidth ) + oheight *= o_aspect_ratio / i_aspect_ratio; else - owidth = (int)( ( aspect_ratio * oheight / dsar ) + 0.5 ) >> 1 << 1; + owidth *= i_aspect_ratio * o_aspect_ratio; - fprintf( stderr, "rescale: from %dx%d (%f) to %dx%d\n", iwidth, iheight, aspect_ratio, owidth, oheight ); + fprintf( stderr, "rescale: from %dx%d (%f) to %dx%d\n", iwidth, iheight, i_aspect_ratio, owidth, oheight ); #endif - + // If width and height are correct, don't do anything if ( input != NULL && ( iwidth != owidth || iheight != oheight ) ) { -- 1.7.4.4