X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fkdenlive%2Fproducer_framebuffer.c;h=bb25ae3fcf1c3133dac84dbd3af651d1b3a6b3cc;hb=d33f444d4ef4c7bc4074d07a49eca0ab7d108394;hp=4a1393e9a0676ee438e400a3b9acca9d5c4e2946;hpb=b5bf7e90101c8ff6efd2a1e993673e4f56735caf;p=melted diff --git a/src/modules/kdenlive/producer_framebuffer.c b/src/modules/kdenlive/producer_framebuffer.c index 4a1393e..bb25ae3 100644 --- a/src/modules/kdenlive/producer_framebuffer.c +++ b/src/modules/kdenlive/producer_framebuffer.c @@ -18,7 +18,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "producer_framebuffer.h" #include #include @@ -47,20 +46,26 @@ static int framebuffer_get_image( mlt_frame this, uint8_t **image, mlt_image_for mlt_properties frame_properties = MLT_FRAME_PROPERTIES( this ); mlt_properties first_frame_properties = MLT_FRAME_PROPERTIES( first_frame ); - // image stride - int size, xstride, ystride; - switch( *format ){ - case mlt_image_yuv422: - size = *width * *height * 2; - xstride = 2; - ystride = 2 * *width; + *width = mlt_properties_get_int( frame_properties, "width" ); + *height = mlt_properties_get_int( frame_properties, "height" ); + + int size; + switch ( *format ) + { + case mlt_image_yuv420p: + size = *width * 3 * ( *height + 1 ) / 2; + break; + case mlt_image_rgb24: + size = *width * ( *height + 1 ) * 3; break; default: - fprintf(stderr, "Unsupported image format\n"); - return -1; + *format = mlt_image_yuv422; + size = *width * ( *height + 1 ) * 2; + break; } - uint8_t *output = mlt_properties_get_data( producer_properties, "output_buffer", 0 ); + uint8_t *output = mlt_properties_get_data( producer_properties, "output_buffer", NULL ); + if( output == NULL ) { output = mlt_pool_alloc( size ); @@ -103,8 +108,8 @@ static int framebuffer_get_image( mlt_frame this, uint8_t **image, mlt_image_for static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index ) { // Construct a new frame - *frame = mlt_frame_init( ); - mlt_properties properties = MLT_PRODUCER_PROPERTIES(this); + *frame = mlt_frame_init( MLT_PRODUCER_SERVICE( this ) ); + mlt_properties properties = MLT_PRODUCER_PROPERTIES( this ); if( frame != NULL ) { @@ -161,8 +166,11 @@ static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index // Get the frame mlt_service_get_frame( MLT_PRODUCER_SERVICE( real_producer ), &first_frame, index ); - } + double ratio = mlt_properties_get_double( MLT_PRODUCER_PROPERTIES( real_producer ), "aspect_ratio" ) * (double) mlt_properties_get_int( MLT_FRAME_PROPERTIES( first_frame ), "width" ) / (double) mlt_properties_get_int( MLT_FRAME_PROPERTIES( first_frame ), "height" ) / ( (double) mlt_properties_get_int(MLT_FRAME_PROPERTIES( *frame ), "width" ) / (double) mlt_properties_get_int( MLT_FRAME_PROPERTIES( *frame ), "height" )); + + mlt_properties_set_double( properties, "ratio_fix", ratio ); + } // Make sure things are in their place mlt_properties_set_data( properties, "first_frame", first_frame, 0, NULL, NULL ); @@ -174,21 +182,22 @@ static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index mlt_frame_push_service( *frame, this ); mlt_frame_push_service( *frame, framebuffer_get_image ); + // Give the returned frame temporal identity mlt_frame_set_position( *frame, mlt_producer_position( this ) ); - + mlt_properties_set_double( MLT_FRAME_PROPERTIES(*frame), "aspect_ratio", mlt_properties_get_double( properties, "ratio_fix" )); } return 0; } -mlt_producer producer_framebuffer_init( char *arg ) +mlt_producer producer_framebuffer_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg ) { mlt_producer this = NULL; this = calloc( 1, sizeof( struct mlt_producer_s ) ); - mlt_producer_init( this, NULL ); + mlt_producer_init( this, NULL ); // Wrap fezzik mlt_producer real_producer; @@ -217,7 +226,7 @@ mlt_producer producer_framebuffer_init( char *arg ) count = strcspn( ptr, ":" ); ptr[count] = '\0'; - real_producer = mlt_factory_producer( "fezzik", props ); + real_producer = mlt_factory_producer( profile, "fezzik", props ); ptr += count + 1; ptr += strspn( ptr, ":" ); @@ -240,14 +249,14 @@ mlt_producer producer_framebuffer_init( char *arg ) // Store the producer and fitler mlt_properties_set_data( properties, "producer", real_producer, 0, ( mlt_destructor )mlt_producer_close, NULL ); - // Grap some stuff from the real_producer - mlt_properties_pass_list( properties, MLT_PRODUCER_PROPERTIES( real_producer ), - "length,resource,width,height" ); + // Grab some stuff from the real_producer + mlt_properties_pass_list( properties, MLT_PRODUCER_PROPERTIES( real_producer ), "length,resource,width,height" ); + if ( speed != 1.0 ) { double real_length = (double) mlt_producer_get_length( real_producer ); - mlt_properties_set_position( properties, "length", real_length * 2 / speed ); + mlt_properties_set_position( properties, "length", real_length / speed ); } // Since we control the seeking, prevent it from seeking on its own