#include <framework/mlt_filter.h>
#include <framework/mlt_frame.h>
+#include <framework/mlt_profile.h>
#include <stdio.h>
#include <string.h>
resize_image( output, owidth, oheight, input, iwidth, iheight, bpp );
// Now update the frame
- mlt_properties_set_data( properties, "image", output, owidth * ( oheight + 1 ) * bpp, ( mlt_destructor )mlt_pool_release, NULL );
- mlt_properties_set_int( properties, "width", owidth );
- mlt_properties_set_int( properties, "height", oheight );
+ mlt_frame_set_image( this, output, owidth * ( oheight + 1 ) * bpp, mlt_pool_release );
// We should resize the alpha too
if ( alpha && alpha_size >= iwidth * iheight )
alpha = resize_alpha( alpha, owidth, oheight, iwidth, iheight, alpha_value );
if ( alpha )
{
- mlt_properties_set_data( properties, "alpha", alpha, owidth * oheight, ( mlt_destructor )mlt_pool_release, NULL );
+ mlt_frame_set_alpha( this, alpha, owidth * oheight, mlt_pool_release );
this->get_alpha_mask = NULL;
}
}
// Retrieve the aspect ratio
double aspect_ratio = mlt_deque_pop_back_double( MLT_FRAME_IMAGE_STACK( this ) );
+ double consumer_aspect = mlt_profile_sar( mlt_service_profile( MLT_FILTER_SERVICE( filter ) ) );
// Correct Width/height if necessary
if ( *width == 0 || *height == 0 )
// Check for the special case - no aspect ratio means no problem :-)
if ( aspect_ratio == 0.0 )
- aspect_ratio = mlt_properties_get_double( properties, "consumer_aspect_ratio" );
+ aspect_ratio = consumer_aspect;
// Reset the aspect ratio
mlt_properties_set_double( properties, "aspect_ratio", aspect_ratio );
if ( real_height == 0 )
real_height = mlt_properties_get_int( properties, "height" );
double input_ar = aspect_ratio * real_width / real_height;
- double output_ar = mlt_properties_get_double( properties, "consumer_aspect_ratio" ) * owidth / oheight;
+ double output_ar = consumer_aspect * owidth / oheight;
// fprintf( stderr, "real %dx%d normalised %dx%d output %dx%d sar %f in-dar %f out-dar %f\n",
// real_width, real_height, normalised_width, normalised_height, owidth, oheight, aspect_ratio, input_ar, output_ar);
oheight = rint( scaled_height * oheight / normalised_height );
// Tell frame we have conformed the aspect to the consumer
- mlt_frame_set_aspect_ratio( this, mlt_properties_get_double( properties, "consumer_aspect_ratio" ) );
+ mlt_frame_set_aspect_ratio( this, consumer_aspect );
}
mlt_properties_set_int( properties, "distort", 0 );
// Get the requested scale operation
char *op = mlt_properties_get( MLT_FILTER_PROPERTIES( filter ), "scale" );
int bpp;
-
- switch ( *format )
- {
- case mlt_image_yuv422:
- bpp = 2;
- break;
- case mlt_image_rgb24:
- bpp = 3;
- break;
- case mlt_image_rgb24a:
- case mlt_image_opengl:
- bpp = 4;
- break;
- default:
- // XXX: we only know how to resize packed formats
- return 1;
- }
+ int size = mlt_image_format_size( *format, owidth, oheight, &bpp );
+ int tff = mlt_properties_get_int( properties, "consumer_tff" );
// Provides a manual override for misreported field order
if ( mlt_properties_get( properties, "meta.top_field_first" ) )
mlt_properties_set_int( properties, "top_field_first", mlt_properties_get_int( properties, "meta.top_field_first" ) );
// Correct field order if needed
- if ( mlt_properties_get_int( properties, "top_field_first" ) == 1 &&
+ if ( mlt_properties_get_int( properties, "top_field_first" ) != tff &&
mlt_properties_get( properties, "progressive" ) &&
mlt_properties_get_int( properties, "progressive" ) == 0 )
{
// Get the input image, width and height
- int size = owidth * oheight * bpp;
uint8_t *new_image = mlt_pool_alloc( size );
- mlt_properties_set_data( properties, "image", new_image, size, ( mlt_destructor )mlt_pool_release, NULL );
+ mlt_frame_set_image( this, new_image, size, mlt_pool_release );
uint8_t *ptr = new_image + owidth * bpp;
memcpy( new_image, *image, owidth * bpp );
- memcpy( ptr, *image, size - owidth * bpp );
+ memcpy( ptr, *image, owidth * ( oheight - 1 ) * bpp );
*image = new_image;
// Set the normalised field order
- mlt_properties_set_int( properties, "top_field_first", 0 );
- mlt_properties_set_int( properties, "meta.top_field_first", 0 );
+ mlt_properties_set_int( properties, "top_field_first", tff );
+ mlt_properties_set_int( properties, "meta.top_field_first", tff );
}
if ( !strcmp( op, "affine" ) )