X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fgtk2%2Ffilter_rescale.c;h=46de666aed06f854a8b225c39dc637964f970fc1;hb=dc57bd7b4020663b49149f44f1607c4d78c4d2d5;hp=cf0905ed82a65b63c5afcb8f900dbb8622013891;hpb=acebb83a8ead55799505891f9a95be4eead9eb49;p=melted diff --git a/src/modules/gtk2/filter_rescale.c b/src/modules/gtk2/filter_rescale.c index cf0905e..46de666 100644 --- a/src/modules/gtk2/filter_rescale.c +++ b/src/modules/gtk2/filter_rescale.c @@ -56,8 +56,20 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * mlt_frame_get_image( this, &input, format, &iwidth, &iheight, 0 ); + // Determine maximum size within the aspect ratio: + double aspect_ratio = mlt_frame_get_aspect_ratio( this ); + float display_aspect_ratio = 4.0 / 3.0; // (float)iwidth / (float)iheight; + if ( *width < *height * aspect_ratio ) + oheight = *width / aspect_ratio; + else + owidth = *height * aspect_ratio; + if ( ( float )owidth * display_aspect_ratio < *width ) + owidth = ( int )( ( float )owidth * display_aspect_ratio ); + else if ( ( float )oheight * display_aspect_ratio < *height ) + oheight = ( int )( ( float )oheight * display_aspect_ratio ); + // If width and height are correct, don't do anything - if ( iwidth != owidth || iheight != oheight ) + if ( input != NULL && ( iwidth != owidth || iheight != oheight ) ) { if ( *format == mlt_image_yuv422 ) {