#include <framework/mlt_filter.h>
#include <framework/mlt_frame.h>
+#include <framework/mlt_profile.h>
#include <stdio.h>
#include <string.h>
while ( iheight -- )
{
// We're in the input range for this row.
- memcpy( out_line, in_line, iwidth * bpp );
+ memcpy( out_line, in_line, istride );
// Move to next input line
in_line += istride;
// Get the input image, width and height
uint8_t *input = mlt_properties_get_data( properties, "image", NULL );
uint8_t *alpha = mlt_frame_get_alpha_mask( this );
+ int alpha_size = 0;
+ mlt_properties_get_data( properties, "alpha", &alpha_size );
int iwidth = mlt_properties_get_int( properties, "width" );
int iheight = mlt_properties_get_int( properties, "height" );
// If width and height are correct, don't do anything
- if ( iwidth != owidth || iheight != oheight )
+ if ( iwidth < owidth || iheight < oheight )
{
uint8_t alpha_value = mlt_properties_get_int( properties, "resize_alpha" );
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
- alpha = resize_alpha( alpha, owidth, oheight, iwidth, iheight, alpha_value );
- if ( alpha != NULL )
+ if ( alpha && alpha_size >= iwidth * iheight )
{
- mlt_properties_set_data( properties, "alpha", alpha, owidth * oheight, ( mlt_destructor )mlt_pool_release, NULL );
- this->get_alpha_mask = NULL;
+ alpha = resize_alpha( alpha, owidth, oheight, iwidth, iheight, alpha_value );
+ if ( alpha )
+ {
+ mlt_frame_set_alpha( this, alpha, owidth * oheight, mlt_pool_release );
+ this->get_alpha_mask = NULL;
+ }
}
// Return the output
// 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 );
mlt_properties_set_int( properties, "resize_height", *height );
// Now get the image
+ if ( *format == mlt_image_yuv422 )
+ owidth -= owidth % 2;
error = mlt_frame_get_image( this, image, format, &owidth, &oheight, writable );
if ( error == 0 && *image )
// 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 *ptr = *image + owidth * bpp;
- memmove( ptr, *image, size - owidth * bpp );
+ uint8_t *new_image = mlt_pool_alloc( size );
+ 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, 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" ) )