From 9ad7cb6cdea367db7a720fa0335f8b8eccf0ae09 Mon Sep 17 00:00:00 2001 From: lilo_booter Date: Tue, 5 Oct 2004 19:54:14 +0000 Subject: [PATCH] Multitrack rearrangement and tractor cleanup git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@464 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/framework/mlt_multitrack.c | 20 ++------------------ src/framework/mlt_playlist.c | 5 ++++- src/framework/mlt_producer.c | 12 ++++++++++-- src/framework/mlt_tractor.c | 18 +++++++++++++----- src/inigo/inigo.c | 31 ++++++++++++++++++------------- 5 files changed, 47 insertions(+), 39 deletions(-) diff --git a/src/framework/mlt_multitrack.c b/src/framework/mlt_multitrack.c index 5d99b3f..50a9426 100644 --- a/src/framework/mlt_multitrack.c +++ b/src/framework/mlt_multitrack.c @@ -381,8 +381,6 @@ mlt_position mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int in out of sync. See playlist logic too. - - This is not as clean as it should be... */ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index ) @@ -393,28 +391,14 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int ind // Check if we have a track for this index if ( index < this->count && this->list[ index ] != NULL ) { - // Determine the in point - int in = mlt_producer_is_cut( this->list[ index ]->producer ) ? mlt_producer_get_in( this->list[ index ]->producer ) : 0; - // Get the producer for this track - mlt_producer producer = mlt_producer_cut_parent( this->list[ index ]->producer ); + mlt_producer producer = this->list[ index ]->producer; // Obtain the current position mlt_position position = mlt_producer_frame( parent ); - // Get the clone index - int clone_index = mlt_properties_get_int( mlt_producer_properties( this->list[ index ]->producer ), "_clone" ); - - // Additionally, check if we're supposed to use a clone here - if ( clone_index > 0 ) - { - char key[ 25 ]; - sprintf( key, "_clone.%d", clone_index - 1 ); - producer = mlt_properties_get_data( mlt_producer_properties( producer ), key, NULL ); - } - // Make sure we're at the same point - mlt_producer_seek( producer, in + position ); + mlt_producer_seek( producer, position ); // Get the frame from the producer mlt_service_get_frame( mlt_producer_service( producer ), frame, 0 ); diff --git a/src/framework/mlt_playlist.c b/src/framework/mlt_playlist.c index b59ee0d..222d5bf 100644 --- a/src/framework/mlt_playlist.c +++ b/src/framework/mlt_playlist.c @@ -765,7 +765,8 @@ int mlt_playlist_split( mlt_playlist this, int clip, mlt_position position ) if ( error == 0 ) { playlist_entry *entry = this->list[ clip ]; - if ( position >= 0 && position < entry->frame_count ) + position = position < 0 ? entry->frame_count + position - 1 : position; + if ( position >= 0 && position <= entry->frame_count ) { mlt_producer split = NULL; int in = entry->frame_in; @@ -804,6 +805,8 @@ int mlt_playlist_join( mlt_playlist this, int clip, int count, int merge ) playlist_entry *entry = this->list[ clip ]; mlt_playlist_append( new_clip, entry->producer ); mlt_playlist_repeat_clip( new_clip, i, entry->repeat ); + if ( entry->frame_count == entry->repeat ) + mlt_properties_set_int( mlt_playlist_properties( new_clip ), "hide", 2 ); entry->preservation_hack = 1; mlt_playlist_remove( this, clip ); } diff --git a/src/framework/mlt_producer.c b/src/framework/mlt_producer.c index 98498c4..89d81cd 100644 --- a/src/framework/mlt_producer.c +++ b/src/framework/mlt_producer.c @@ -442,10 +442,15 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind char key[ 25 ]; sprintf( key, "_clone.%d", clone_index - 1 ); clone = mlt_properties_get_data( mlt_producer_properties( mlt_producer_cut_parent( this ) ), key, NULL ); + if ( clone == NULL ) fprintf( stderr, "requested clone doesn't exist\n" ); clone = clone == NULL ? this : clone; } - mlt_producer_seek( clone, mlt_properties_get_int( properties, "_position" ) ); - result = producer_get_frame( mlt_producer_service( mlt_producer_cut_parent( clone ) ), frame, index ); + else + { + clone = mlt_producer_cut_parent( this ); + } + mlt_producer_seek( clone, mlt_producer_get_in( this ) + mlt_properties_get_int( properties, "_position" ) ); + result = producer_get_frame( mlt_producer_service( clone ), frame, index ); double speed = mlt_producer_get_speed( this ); mlt_properties_set_double( mlt_frame_properties( *frame ), "_speed", speed ); mlt_producer_prepare_next( clone ); @@ -503,6 +508,9 @@ static mlt_producer mlt_producer_clone( mlt_producer this ) if ( clone == NULL && resource != NULL ) clone = mlt_factory_producer( "fezzik", resource ); + if ( clone != NULL ) + mlt_properties_inherit( mlt_producer_properties( clone ), properties ); + return clone; } diff --git a/src/framework/mlt_tractor.c b/src/framework/mlt_tractor.c index 83f82f9..b5ee3a9 100644 --- a/src/framework/mlt_tractor.c +++ b/src/framework/mlt_tractor.c @@ -211,7 +211,14 @@ static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_forma uint8_t *data = NULL; mlt_properties properties = mlt_frame_properties( this ); mlt_frame frame = mlt_frame_pop_service( this ); - mlt_properties_inherit( mlt_frame_properties( frame ), properties ); + mlt_properties frame_properties = mlt_frame_properties( frame ); + mlt_properties_set_int( frame_properties, "width", mlt_properties_get_int( properties, "width" ) ); + mlt_properties_set_int( frame_properties, "height", mlt_properties_get_int( properties, "height" ) ); + mlt_properties_set( frame_properties, "rescale.interp", mlt_properties_get( properties, "rescale.interp" ) ); + mlt_properties_set_double( frame_properties, "aspect_ratio", mlt_properties_get_double( properties, "aspect_ratio" ) ); + mlt_properties_set_double( frame_properties, "consumer_aspect_ratio", mlt_properties_get_double( properties, "consumer_aspect_ratio" ) ); + mlt_properties_set_int( frame_properties, "consumer_progressive", mlt_properties_get_double( properties, "consumer_progressive" ) ); + mlt_properties_set_int( frame_properties, "consumer_deinterlace", mlt_properties_get_double( properties, "consumer_deinterlace" ) ); mlt_frame_get_image( frame, buffer, format, width, height, writable ); mlt_properties_set_data( properties, "image", *buffer, *width * *height * 2, NULL, NULL ); mlt_properties_set_int( properties, "width", *width ); @@ -227,7 +234,6 @@ static int producer_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_forma { mlt_properties properties = mlt_frame_properties( this ); mlt_frame frame = mlt_frame_pop_audio( this ); - mlt_properties_inherit( mlt_frame_properties( frame ), properties ); mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples ); mlt_properties_set_data( properties, "audio", *buffer, 0, NULL, NULL ); mlt_properties_set_int( properties, "frequency", *frequency ); @@ -318,15 +324,17 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int tra { mlt_frame_push_audio( *frame, audio ); ( *frame )->get_audio = producer_get_audio; - mlt_properties_inherit( mlt_frame_properties( *frame ), mlt_frame_properties( audio ) ); } if ( video != NULL ) { - mlt_properties_set_data( mlt_frame_properties( *frame ), "data_queue", data_queue, 0, NULL, NULL ); + mlt_properties video_properties = mlt_frame_properties( video ); mlt_frame_push_service( *frame, video ); mlt_frame_push_service( *frame, producer_get_image ); - mlt_properties_inherit( mlt_frame_properties( *frame ), mlt_frame_properties( video ) ); + mlt_properties_set_data( frame_properties, "data_queue", data_queue, 0, NULL, NULL ); + mlt_properties_set_int( frame_properties, "width", mlt_properties_get_int( video_properties, "width" ) ); + mlt_properties_set_int( frame_properties, "height", mlt_properties_get_int( video_properties, "height" ) ); + mlt_properties_set_double( frame_properties, "aspect_ratio", mlt_properties_get_double( video_properties, "aspect_ratio" ) ); } mlt_properties_set_int( mlt_frame_properties( *frame ), "test_audio", audio == NULL ); diff --git a/src/inigo/inigo.c b/src/inigo/inigo.c index b29df70..e39b21d 100644 --- a/src/inigo/inigo.c +++ b/src/inigo/inigo.c @@ -144,33 +144,38 @@ static mlt_consumer create_consumer( char *id, mlt_producer producer ) static void transport( mlt_producer producer, mlt_consumer consumer ) { mlt_properties properties = mlt_producer_properties( producer ); + int silent = mlt_properties_get_int( mlt_consumer_properties( consumer ), "silent" ); term_init( ); if ( mlt_properties_get_int( properties, "done" ) == 0 && !mlt_consumer_is_stopped( consumer ) ) { - fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" ); - fprintf( stderr, "|1=-10| |2= -5| |3= -2| |4= -1| |5= 0| |6= 1| |7= 2| |8= 5| |9= 10|\n" ); - fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" ); - - fprintf( stderr, "+---------------------------------------------------------------------+\n" ); - fprintf( stderr, "| H = back 1 minute, L = forward 1 minute |\n" ); - fprintf( stderr, "| h = previous frame, l = next frame |\n" ); - fprintf( stderr, "| g = start of clip, j = next clip, k = previous clip |\n" ); - fprintf( stderr, "| 0 = restart, q = quit, space = play |\n" ); - fprintf( stderr, "+---------------------------------------------------------------------+\n" ); + if ( !silent ) + { + fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" ); + fprintf( stderr, "|1=-10| |2= -5| |3= -2| |4= -1| |5= 0| |6= 1| |7= 2| |8= 5| |9= 10|\n" ); + fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" ); + + fprintf( stderr, "+---------------------------------------------------------------------+\n" ); + fprintf( stderr, "| H = back 1 minute, L = forward 1 minute |\n" ); + fprintf( stderr, "| h = previous frame, l = next frame |\n" ); + fprintf( stderr, "| g = start of clip, j = next clip, k = previous clip |\n" ); + fprintf( stderr, "| 0 = restart, q = quit, space = play |\n" ); + fprintf( stderr, "+---------------------------------------------------------------------+\n" ); + } while( mlt_properties_get_int( properties, "done" ) == 0 && !mlt_consumer_is_stopped( consumer ) ) { int value = term_read( ); if ( value != -1 ) transport_action( producer, ( char * )&value ); - - if ( mlt_properties_get_int( properties, "stats_off" ) == 0 ) + + if ( !silent && mlt_properties_get_int( properties, "stats_off" ) == 0 ) fprintf( stderr, "Current Position: %10d\r", mlt_producer_position( producer ) ); } - fprintf( stderr, "\n" ); + if ( !silent ) + fprintf( stderr, "\n" ); } } -- 1.7.4.4