X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fgtk2%2Ffilter_rescale.c;h=f70c039cfa4563476be1827efa021e05630e7e7c;hb=0b288164cbeb9a3c98107d439d86844be13ba910;hp=526b58a3dddab60bf1fc6931ec9e03b39f9f0922;hpb=74268cd86c30a0af9f03981c799aa4bba253c6e9;p=melted diff --git a/src/modules/gtk2/filter_rescale.c b/src/modules/gtk2/filter_rescale.c index 526b58a..f70c039 100644 --- a/src/modules/gtk2/filter_rescale.c +++ b/src/modules/gtk2/filter_rescale.c @@ -47,8 +47,6 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * uint8_t *input = NULL; char *interps = mlt_properties_get( properties, "rescale.interp" ); int interp = PIXOPS_INTERP_BILINEAR; - double i_aspect_ratio = mlt_frame_get_aspect_ratio( this ); - double o_aspect_ratio = mlt_properties_get_double( properties, "consumer_aspect_ratio" ); if ( strcmp( interps, "nearest" ) == 0 ) interp = PIXOPS_INTERP_NEAREST; @@ -57,25 +55,19 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * else if ( strcmp( interps, "hyper" ) == 0 ) interp = PIXOPS_INTERP_HYPER; - mlt_frame_get_image( this, &input, format, &iwidth, &iheight, writable ); - - if ( o_aspect_ratio != 0 && o_aspect_ratio != i_aspect_ratio && mlt_properties_get( properties, "distort" ) == NULL ) + // If real_width/height exist, we want that as minimum information + if ( mlt_properties_get_int( properties, "real_width" ) ) { - int temp_width = i_aspect_ratio / o_aspect_ratio * owidth + 0.5; - - // Determine maximum size within the aspect ratio: - if ( temp_width > owidth ) - if ( i_aspect_ratio > o_aspect_ratio ) - oheight = o_aspect_ratio / i_aspect_ratio * oheight + 0.5; - else - oheight = i_aspect_ratio / o_aspect_ratio * oheight + 0.5; - else - owidth = temp_width; - - // Tell frame we have conformed the aspect to the consumer - mlt_frame_set_aspect_ratio( this, o_aspect_ratio ); + iwidth = mlt_properties_get_int( properties, "real_width" ); + iheight = mlt_properties_get_int( properties, "real_height" ); } - //fprintf( stderr, "rescale: from %dx%d (aspect %f) to %dx%d (aspect %f)\n", iwidth, iheight, i_aspect_ratio, owidth, oheight, o_aspect_ratio ); + + // Let the producer know what we are actually requested to obtain + mlt_properties_set_int( properties, "rescale_width", *width ); + mlt_properties_set_int( properties, "rescale_height", *height ); + + // Get the image as requested + mlt_frame_get_image( this, &input, format, &iwidth, &iheight, writable ); if ( input != NULL ) { @@ -83,8 +75,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * if ( *format == mlt_image_yuv422 && strcmp( interps, "none" ) && ( iwidth != owidth || iheight != oheight ) ) { // Create the output image - // IRRIGATE ME - uint8_t *output = malloc( owidth * ( oheight + 1 ) * 2 ); + uint8_t *output = mlt_pool_alloc( owidth * ( oheight + 1 ) * 2 ); // Calculate strides int istride = iwidth * 2; @@ -93,7 +84,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * yuv422_scale_simple( output, owidth, oheight, ostride, input, iwidth, iheight, istride, interp ); // Now update the frame - mlt_properties_set_data( properties, "image", output, owidth * ( oheight + 1 ) * 2, free, NULL ); + mlt_properties_set_data( properties, "image", output, owidth * ( oheight + 1 ) * 2, ( mlt_destructor )mlt_pool_release, NULL ); mlt_properties_set_int( properties, "width", owidth ); mlt_properties_set_int( properties, "height", oheight ); @@ -105,8 +96,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * int bpp = (*format == mlt_image_rgb24a ? 4 : 3 ); // Create the yuv image - // IRRIGATE ME - uint8_t *output = malloc( owidth * ( oheight + 1 ) * 2 ); + uint8_t *output = mlt_pool_alloc( owidth * ( oheight + 1 ) * 2 ); if ( strcmp( interps, "none" ) && ( iwidth != owidth || iheight != oheight ) ) { @@ -121,8 +111,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * if ( bpp == 4 ) { // Allocate the alpha mask - // IRRIGATE ME - uint8_t *alpha = malloc( owidth * ( oheight + 1 ) ); + uint8_t *alpha = mlt_pool_alloc( owidth * ( oheight + 1 ) ); // Convert the image and extract alpha mlt_convert_rgb24a_to_yuv422( gdk_pixbuf_get_pixels( scaled ), @@ -130,7 +119,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * gdk_pixbuf_get_rowstride( scaled ), output, alpha ); - mlt_properties_set_data( properties, "alpha", alpha, owidth * ( oheight + 1 ), free, NULL ); + mlt_properties_set_data( properties, "alpha", alpha, owidth * ( oheight + 1 ), ( mlt_destructor )mlt_pool_release, NULL ); } else { @@ -148,8 +137,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * if ( bpp == 4 ) { // Allocate the alpha mask - // IRRIGATE ME - uint8_t *alpha = malloc( owidth * ( oheight + 1 ) ); + uint8_t *alpha = mlt_pool_alloc( owidth * ( oheight + 1 ) ); // Convert the image and extract alpha mlt_convert_rgb24a_to_yuv422( input, @@ -157,7 +145,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * owidth * 4, output, alpha ); - mlt_properties_set_data( properties, "alpha", alpha, owidth * ( oheight + 1 ), free, NULL ); + mlt_properties_set_data( properties, "alpha", alpha, owidth * ( oheight + 1 ), ( mlt_destructor )mlt_pool_release, NULL ); } else { @@ -170,11 +158,12 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * } // Now update the frame - mlt_properties_set_data( properties, "image", output, owidth * ( oheight + 1 ) * 2, free, NULL ); + mlt_properties_set_data( properties, "image", output, owidth * ( oheight + 1 ) * 2, ( mlt_destructor )mlt_pool_release, NULL ); mlt_properties_set_int( properties, "width", owidth ); mlt_properties_set_int( properties, "height", oheight ); // Return the output + *format = mlt_image_yuv422; *width = owidth; *height = oheight; *image = output;