X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fframework%2Fmlt_frame.c;h=3ad896d2f3ce309085710710d4dfb466e2474bde;hb=45e92efd45d245cc9fb778db5a1ea340d5319336;hp=1c313fc56bcec552929dac5437065882f4c53371;hpb=44be0cb49abb583de820ab126d5085030345d186;p=mlt diff --git a/src/framework/mlt_frame.c b/src/framework/mlt_frame.c index 1c313fc5..3ad896d2 100644 --- a/src/framework/mlt_frame.c +++ b/src/framework/mlt_frame.c @@ -3,8 +3,9 @@ * \brief interface for all frame classes * \see mlt_frame_s * - * Copyright (C) 2003-2009 Ushodaya Enterprises Limited + * Copyright (C) 2003-2013 Ushodaya Enterprises Limited * \author Charles Yates + * \author Dan Dennedy * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -183,7 +184,7 @@ int mlt_frame_set_position( mlt_frame self, mlt_position value ) * * \public \memberof mlt_frame_s * \param self a frame - * \param the get_image callback + * \param get_image the get_image callback * \return true if error */ @@ -459,12 +460,12 @@ static int generate_test_image( mlt_properties properties, uint8_t **buffer, ml mlt_properties_set_data( properties, "test_card_frame", test_frame, 0, ( mlt_destructor )mlt_frame_close, NULL ); mlt_properties_set( test_properties, "rescale.interp", mlt_properties_get( properties, "rescale.interp" ) ); error = mlt_frame_get_image( test_frame, buffer, format, width, height, writable ); - if ( !error && *buffer ) + if ( !error && buffer && *buffer ) { mlt_properties_set_double( properties, "aspect_ratio", mlt_frame_get_aspect_ratio( test_frame ) ); mlt_properties_set_int( properties, "width", *width ); mlt_properties_set_int( properties, "height", *height ); - if ( test_frame->convert_image && *buffer && requested_format != mlt_image_none ) + if ( test_frame->convert_image && requested_format != mlt_image_none ) test_frame->convert_image( test_frame, buffer, format, requested_format ); mlt_properties_set_int( properties, "format", *format ); } @@ -474,7 +475,7 @@ static int generate_test_image( mlt_properties properties, uint8_t **buffer, ml mlt_properties_set_data( properties, "test_card_producer", NULL, 0, NULL, NULL ); } } - if ( error ) + if ( error && buffer && *format != mlt_image_none ) { int size = 0; @@ -570,11 +571,11 @@ int mlt_frame_get_image( mlt_frame self, uint8_t **buffer, mlt_image_format *for { mlt_properties_set_int( properties, "image_count", mlt_properties_get_int( properties, "image_count" ) - 1 ); error = get_image( self, buffer, format, width, height, writable ); - if ( !error && *buffer ) + if ( !error && buffer && *buffer ) { mlt_properties_set_int( properties, "width", *width ); mlt_properties_set_int( properties, "height", *height ); - if ( self->convert_image && *buffer && requested_format != mlt_image_none ) + if ( self->convert_image && requested_format != mlt_image_none ) self->convert_image( self, buffer, format, requested_format ); mlt_properties_set_int( properties, "format", *format ); } @@ -583,7 +584,7 @@ int mlt_frame_get_image( mlt_frame self, uint8_t **buffer, mlt_image_format *for error = generate_test_image( properties, buffer, format, width, height, writable ); } } - else if ( mlt_properties_get_data( properties, "image", NULL ) ) + else if ( mlt_properties_get_data( properties, "image", NULL ) && buffer ) { *format = mlt_properties_get_int( properties, "format" ); *buffer = mlt_properties_get_data( properties, "image", NULL ); @@ -982,7 +983,7 @@ void mlt_frame_write_ppm( mlt_frame frame ) FILE *file; char filename[16]; - sprintf( filename, "frame-%05d.ppm", mlt_frame_get_position( frame ) ); + sprintf( filename, "frame-%05d.ppm", (int)mlt_frame_get_position( frame ) ); file = fopen( filename, "wb" ); if ( !file ) return; @@ -1069,10 +1070,12 @@ mlt_frame mlt_frame_clone( mlt_frame self, int is_deep ) data = mlt_properties_get_data( properties, "image", &size ); if ( data ) { + int width = mlt_properties_get_int( properties, "width" ); + int height = mlt_properties_get_int( properties, "height" ); + if ( ! size ) size = mlt_image_format_size( mlt_properties_get_int( properties, "format" ), - mlt_properties_get_int( properties, "width" ), - mlt_properties_get_int( properties, "height" ), NULL ); + width, height, NULL ); copy = mlt_pool_alloc( size ); memcpy( copy, data, size ); mlt_properties_set_data( new_props, "image", copy, size, mlt_pool_release, NULL ); @@ -1081,8 +1084,7 @@ mlt_frame mlt_frame_clone( mlt_frame self, int is_deep ) if ( data ) { if ( ! size ) - size = mlt_properties_get_int( properties, "width" ) * - mlt_properties_get_int( properties, "height" ); + size = width * height; copy = mlt_pool_alloc( size ); memcpy( copy, data, size ); mlt_properties_set_data( new_props, "alpha", copy, size, mlt_pool_release, NULL );