Finalisation of first phase of cut handling (unmanaged)
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sat, 25 Sep 2004 09:31:33 +0000 (09:31 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sat, 25 Sep 2004 09:31:33 +0000 (09:31 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@445 d19143bc-622f-0410-bfdd-b5b2a6649095

src/framework/mlt_playlist.c
src/framework/mlt_transition.c
src/modules/westley/consumer_westley.c
src/modules/westley/producer_westley.c

index f181dde..bd9d6b2 100644 (file)
@@ -170,8 +170,9 @@ static int mlt_playlist_virtual_refresh( mlt_playlist this )
                }
 
                // Check if the length of the producer has changed
-               if ( this->list[ i ]->frame_in != mlt_producer_get_in( producer ) ||
-                        this->list[ i ]->frame_out != mlt_producer_get_out( producer ) );
+               if ( this->list[ i ]->producer != &this->blank &&
+                        ( this->list[ i ]->frame_in != mlt_producer_get_in( producer ) ||
+                          this->list[ i ]->frame_out != mlt_producer_get_out( producer ) ) )
                {
                        // This clip should be removed...
                        if ( current_length == 1 )
@@ -219,16 +220,36 @@ static void mlt_playlist_listener( mlt_producer producer, mlt_playlist this )
 
 static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer source, mlt_position in, mlt_position out )
 {
-       mlt_producer producer = mlt_producer_is_cut( source ) ? source : mlt_producer_cut( source, in, out );
-       mlt_properties properties = mlt_producer_properties( producer );
+       mlt_producer producer = NULL;
+       mlt_properties properties = NULL;
 
        // If we have a cut, then use the in/out points from the cut
-       if ( mlt_producer_is_cut( source ) )
+       if ( &this->blank == source )
        {
+               producer = source;
+               properties = mlt_producer_properties( producer );
                mlt_properties_inc_ref( properties );
-               in = mlt_producer_get_in( source );
-               out = mlt_producer_get_out( source );
        }
+       else if ( mlt_producer_is_cut( source ) )
+       {
+               producer = source;
+               if ( in == -1 )
+                       in = mlt_producer_get_in( producer );
+               if ( out == -1 || out > mlt_producer_get_out( producer ) )
+                       out = mlt_producer_get_out( producer );
+               properties = mlt_producer_properties( producer );
+               mlt_properties_inc_ref( properties );
+       }
+       else
+       {
+               producer = mlt_producer_cut( source, in, out );
+               if ( in == -1 || in < mlt_producer_get_in( producer ) )
+                       in = mlt_producer_get_in( producer );
+               if ( out == -1 || out > mlt_producer_get_out( producer ) )
+                       out = mlt_producer_get_out( producer );
+               properties = mlt_producer_properties( producer );
+       }
+
 
        // Check that we have room
        if ( this->count >= this->size )
@@ -248,13 +269,14 @@ static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer source,
        this->list[ this->count ]->event = mlt_events_listen( properties, this, "producer-changed", ( mlt_listener )mlt_playlist_listener );
        mlt_event_inc_ref( this->list[ this->count ]->event );
 
+       mlt_properties_set( mlt_producer_properties( source ), "eof", "pause" );
        mlt_properties_set( properties, "eof", "pause" );
 
+       mlt_producer_set_speed( source, 0 );
        mlt_producer_set_speed( producer, 0 );
 
        this->count ++;
 
-
        return mlt_playlist_virtual_refresh( this );
 }
 
@@ -772,11 +794,14 @@ int mlt_playlist_mix( mlt_playlist this, int clip, int length, mlt_transition tr
                mlt_tractor tractor = mlt_tractor_new( );
                mlt_events_block( mlt_playlist_properties( this ), this );
 
-               mlt_playlist_resize_clip( this, clip, clip_a->frame_in, clip_a->frame_out - length );
+               track_a = mlt_producer_cut( clip_a->producer, clip_a->frame_out - length + 1, clip_a->frame_out );
+               mlt_properties_set_int( mlt_producer_properties( track_a ), "cut", 1 );
+               track_b = mlt_producer_cut( clip_b->producer, clip_b->frame_in, clip_b->frame_in + length - 1 );
+               mlt_properties_set_int( mlt_producer_properties( track_b ), "cut", 1 );
+
+               mlt_playlist_resize_clip( this, clip, clip_a->frame_in, clip_a->frame_out - length + 1 );
                mlt_playlist_resize_clip( this, clip + 1, clip_b->frame_in + length, clip_b->frame_out );
 
-               track_a = mlt_producer_cut( mlt_producer_cut_parent( clip_a->producer ), clip_a->frame_out + 1, clip_a->frame_out + length );
-               track_b = mlt_producer_cut( mlt_producer_cut_parent( clip_b->producer ), clip_b->frame_in - length, clip_b->frame_in - 1 );
                mlt_tractor_set_track( tractor, track_a, 0 );
                mlt_tractor_set_track( tractor, track_b, 1 );
                mlt_playlist_insert( this, mlt_tractor_producer( tractor ), clip + 1, -1, -1 );
index 5996e14..21ccfda 100644 (file)
@@ -150,10 +150,8 @@ mlt_position mlt_transition_get_out( mlt_transition this )
 
 mlt_frame mlt_transition_process( mlt_transition this, mlt_frame a_frame, mlt_frame b_frame )
 {
-       if ( this->process == NULL || b_frame == NULL || ( mlt_frame_is_test_card( b_frame ) && mlt_frame_is_test_audio( b_frame ) ) )
+       if ( this->process == NULL )
                return a_frame;
-       else if ( a_frame == NULL || ( mlt_frame_is_test_card( a_frame ) && mlt_frame_is_test_audio( a_frame ) ) )
-               return b_frame;
        else
                return this->process( this, a_frame, b_frame );
 }
@@ -199,18 +197,30 @@ static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int i
                mlt_position position = mlt_frame_get_position( this->a_frame );
                if ( position >= in && position <= out )
                {
-                       // Process the transition
-                       *frame = mlt_transition_process( this, this->a_frame, this->b_frame );
-                       if ( *frame == this->b_frame )
+#if 0
+                       // TODO: This could is breaking muliple transitions, but it would be nice to have...
+                       // essentially, it allows transitions to run over whole tracks, while ignoring test cards
+                       // (alternative is to put the handling in the transitions themselves :-/)
+                       if ( this->b_frame == NULL || ( mlt_frame_is_test_card( this->b_frame ) && mlt_frame_is_test_audio( this->b_frame ) ) )
+                       {
+                               *frame = this->a_frame;
+                       }
+                       else if ( this->a_frame == NULL || ( mlt_frame_is_test_card( this->a_frame ) && mlt_frame_is_test_audio( this->a_frame ) ) )
                        {
                                mlt_frame t = this->a_frame;
                                this->a_frame = this->b_frame;
                                this->b_frame = t;
+                               *frame = this->a_frame;
+                       }
+                       else
+#endif
+                       {
+                               *frame = mlt_transition_process( this, this->a_frame, this->b_frame );
+                               if ( !mlt_properties_get_int( mlt_frame_properties( this->a_frame ), "test_image" ) )
+                                       mlt_properties_set_int( mlt_frame_properties( this->b_frame ), "test_image", 1 );
+                               if ( !mlt_properties_get_int( mlt_frame_properties( this->a_frame ), "test_audio" ) )
+                                       mlt_properties_set_int( mlt_frame_properties( this->b_frame ), "test_audio", 1 );
                        }
-                       if ( !mlt_properties_get_int( mlt_frame_properties( this->a_frame ), "test_image" ) )
-                               mlt_properties_set_int( mlt_frame_properties( this->b_frame ), "test_image", 1 );
-                       if ( !mlt_properties_get_int( mlt_frame_properties( this->a_frame ), "test_audio" ) )
-                               mlt_properties_set_int( mlt_frame_properties( this->b_frame ), "test_audio", 1 );
                        this->a_held = 0;
                }
                else
index ebe5fda..15bd525 100644 (file)
@@ -297,8 +297,11 @@ static void serialise_multitrack( serialise_context context, mlt_service service
 
                        char *id = westley_get_id( context, MLT_SERVICE( parent ), westley_existing );
                        xmlNewProp( track, "producer", id );
-                       xmlNewProp( track, "in", mlt_properties_get( properties, "in" ) );
-                       xmlNewProp( track, "out", mlt_properties_get( properties, "out" ) );
+                       if ( mlt_properties_get_int( properties, "cut" ) == 1 )
+                       {
+                               xmlNewProp( track, "in", mlt_properties_get( properties, "in" ) );
+                               xmlNewProp( track, "out", mlt_properties_get( properties, "out" ) );
+                       }
                        
                        hide = mlt_properties_get_int( context->hide_map, id );
                        if ( hide )
index 45d4dbb..ff7c580 100644 (file)
@@ -721,12 +721,13 @@ static void on_end_track( deserialise_context context, const xmlChar *name )
                        // Set the track on the multitrack
 
                        // Set producer i/o if specified
-                       if ( mlt_properties_get( track_props, "in" ) != NULL ||
-                               mlt_properties_get( track_props, "out" ) != NULL )
+                       if ( mlt_properties_get( track_props, "in" ) != NULL &&
+                                mlt_properties_get( track_props, "out" ) != NULL )
                        {
                                mlt_producer cut = mlt_producer_cut( MLT_PRODUCER( producer ),
                                        mlt_properties_get_position( track_props, "in" ),
                                        mlt_properties_get_position( track_props, "out" ) );
+                               mlt_properties_set_int( mlt_producer_properties( cut ), "cut", 1 );
                                mlt_multitrack_connect( multitrack, cut, mlt_multitrack_count( multitrack ) );
                                mlt_producer_close( cut );
                        }