X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fcore%2Fproducer_ppm.c;h=a0a9896fdba941c96c13e5e7c2086ecf10c0fa78;hb=1da06dddd4f117c21c07b3682fab5abab014d995;hp=3d3f5839d847fceeccedc3c0406a0e7f71df4ccd;hpb=7da5daf600f8b97781d85a137c3aa81effb7e610;p=melted diff --git a/src/modules/core/producer_ppm.c b/src/modules/core/producer_ppm.c index 3d3f583..a0a9896 100644 --- a/src/modules/core/producer_ppm.c +++ b/src/modules/core/producer_ppm.c @@ -19,7 +19,9 @@ */ #include "producer_ppm.h" + #include + #include #include @@ -43,12 +45,20 @@ mlt_producer producer_ppm_init( void *command ) if ( this != NULL && mlt_producer_init( &this->parent, this ) == 0 ) { mlt_producer producer = &this->parent; + mlt_properties properties = mlt_producer_properties( producer ); producer->get_frame = producer_get_frame; - producer->close = producer_close; + producer->close = ( mlt_destructor )producer_close; if ( command != NULL ) + { + mlt_properties_set( properties, "resource", command ); this->command = strdup( command ); + } + else + { + mlt_properties_set( properties, "resource", "ppm test" ); + } return producer; } @@ -73,9 +83,9 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma // Convert to requested format if ( *format == mlt_image_yuv422 ) { - uint8_t *image = malloc( *width * *height * 2 ); + uint8_t *image = mlt_pool_alloc( *width * ( *height + 1 ) * 2 ); mlt_convert_rgb24_to_yuv422( rgb, *width, *height, *width * 3, image ); - mlt_properties_set_data( properties, "image", image, *width * *height * 2, free, NULL ); + mlt_properties_set_data( properties, "image", image, *width * ( *height + 1 ) * 2, ( mlt_destructor )mlt_pool_release, NULL ); *buffer = image; } else if ( *format == mlt_image_rgb24 ) @@ -212,18 +222,19 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i // Read the video if ( video != NULL && read_ppm_header( video, &width, &height ) == 2 ) { - // Allocate an image - uint8_t *image = malloc( width * height * 3 ); + uint8_t *image = mlt_pool_alloc( width * ( height + 1 ) * 3 ); // Read it fread( image, width * height * 3, 1, video ); // Pass the data on the frame properties - mlt_properties_set_data( properties, "image", image, width * height * 3, free, NULL ); + mlt_properties_set_data( properties, "image", image, width * ( height + 1 ) * 3, ( mlt_destructor )mlt_pool_release, NULL ); mlt_properties_set_int( properties, "width", width ); mlt_properties_set_int( properties, "height", height ); mlt_properties_set_int( properties, "has_image", 1 ); + mlt_properties_set_int( properties, "progressive", 1 ); + mlt_properties_set_double( properties, "aspect_ratio", 1 ); // Push the image callback mlt_frame_push_get_image( *frame, producer_get_image ); @@ -241,7 +252,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i ( *frame )->get_audio = producer_get_audio; // Update timecode on the frame we're creating - mlt_frame_set_timecode( *frame, mlt_producer_position( producer ) ); + mlt_frame_set_position( *frame, mlt_producer_position( producer ) ); // Calculate the next timecode mlt_producer_prepare_next( producer ); @@ -261,4 +272,3 @@ static void producer_close( mlt_producer parent ) mlt_producer_close( parent ); free( this ); } -