]> git.sesse.net Git - mlt/commitdiff
Revised attached filter handling and clones
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Thu, 7 Oct 2004 18:48:52 +0000 (18:48 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Thu, 7 Oct 2004 18:48:52 +0000 (18:48 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@467 d19143bc-622f-0410-bfdd-b5b2a6649095

src/framework/mlt_filter.c
src/framework/mlt_producer.c
src/framework/mlt_service.c
src/framework/mlt_tractor.c
src/modules/avformat/consumer_avformat.c
src/modules/core/filter_data_show.c
src/modules/core/filter_watermark.c
src/modules/plus/filter_affine.c

index ccdf45dab3c0638960684be788d8523e96008e0a..37f91db3b8ed7cbd63660b0a907fb42d586fcb98 100644 (file)
@@ -176,11 +176,7 @@ static int filter_get_frame( mlt_service service, mlt_frame_ptr frame, int index
                {
                        mlt_position position = mlt_frame_get_position( *frame );
                        if ( position >= in && ( out == 0 || position <= out ) )
-                       {
-                               mlt_frame_set_position( *frame, position - in );
                                *frame = mlt_filter_process( this, *frame );
-                               mlt_frame_set_position( *frame, position + in );
-                       }
                        return 0;
                }
                else
index ddcda2855f66c7373925015f97702528ad694a00..f29f4c5802ab10a1fd0325d880fa104e0ea2c28e 100644 (file)
@@ -397,9 +397,21 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind
 
        if ( !mlt_producer_is_cut( this ) )
        {
+               // Get the properties of this producer
+               mlt_properties properties = mlt_producer_properties( this );
+
                // Determine eof handling
                char *eof = mlt_properties_get( mlt_producer_properties( this ), "eof" );
 
+               // Get the speed of the producer
+               double speed = mlt_producer_get_speed( this );
+
+               // We need to use the clone if it's specified
+               mlt_producer clone = mlt_properties_get_data( properties, "use_clone", NULL );
+
+               // If no clone is specified, use this
+               clone = clone == NULL ? this : clone;
+
                // A properly instatiated producer will have a get_frame method...
                if ( this->get_frame == NULL || ( !strcmp( eof, "continue" ) && mlt_producer_position( this ) > mlt_producer_get_out( this ) ) )
                {
@@ -419,12 +431,11 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind
                else
                {
                        // Get the frame from the implementation
-                       result = this->get_frame( this, frame, index );
+                       result = this->get_frame( clone, frame, index );
                }
 
                // Copy the fps and speed of the producer onto the frame
-               mlt_properties properties = mlt_frame_properties( *frame );
-               double speed = mlt_producer_get_speed( this );
+               properties = mlt_frame_properties( *frame );
                mlt_properties_set_double( properties, "_speed", speed );
                mlt_properties_set_double( properties, "fps", mlt_producer_get_fps( this ) );
                mlt_properties_set_int( properties, "test_audio", mlt_frame_is_test_audio( *frame ) );
@@ -434,9 +445,21 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind
        }
        else
        {
+               // Get the parent of this cut
+               mlt_producer parent = mlt_producer_cut_parent( this );
+
+               // Get the properties of the parent
+               mlt_properties parent_properties = mlt_producer_properties( parent );
+
+               // Get the properties of the cut
                mlt_properties properties = mlt_producer_properties( this );
+
+               // Determine the clone index
                int clone_index = mlt_properties_get_int( properties, "_clone" );
+
+               // Determine the clone to use
                mlt_producer clone = this;
+
                if ( clone_index > 0 )
                {
                        char key[ 25 ];
@@ -447,13 +470,20 @@ static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int ind
                }
                else
                {
-                       clone = mlt_producer_cut_parent( this );
+                       clone = parent;
                }
+
+               // We need to seek to the correct position in the clone
                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 );
+
+               // Assign the clone property to the parent
+               mlt_properties_set_data( parent_properties, "use_clone", clone, 0, NULL, NULL );
+
+               // Now get the frame from the parents service
+               result = mlt_service_get_frame( mlt_producer_service( parent ), frame, index );
+
+               // We're done with the clone now
+               mlt_properties_set_data( parent_properties, "use_clone", NULL, 0, NULL, NULL );
        }
 
        return result;
index 9a1cc376e3dbe36209fdc910ec589f06dbcbf948..df416f0db9d25d86bc046c3be3f0b9ed511996dc 100644 (file)
@@ -308,14 +308,6 @@ void mlt_service_apply_filters( mlt_service this, mlt_frame frame, int index )
        mlt_position this_in = mlt_properties_get_position( service_properties, "in" );
        mlt_position this_out = mlt_properties_get_position( service_properties, "out" );
 
-       // Hmm - special case for cuts - apply filters from the parent first
-       if ( mlt_properties_get_int( service_properties, "_cut" ) )
-       {
-               mlt_service_apply_filters( ( mlt_service )mlt_properties_get_data( service_properties, "_cut_parent", NULL ), frame, 0 );
-               position -= this_in;
-               mlt_frame_set_position( frame, position );
-       }
-
        if ( index == 0 || mlt_properties_get_int( service_properties, "_filter_private" ) == 0 )
        {
                // Process the frame with the attached filters
@@ -329,21 +321,12 @@ void mlt_service_apply_filters( mlt_service this, mlt_frame frame, int index )
                                {
                                        mlt_properties_set_position( frame_properties, "in", 0 );
                                        mlt_properties_set_position( frame_properties, "out", out == 0 ? this_out - this_in : out - in );
-                                       mlt_frame_set_position( frame, position - in );
                                        mlt_filter_process( base->filters[ i ], frame );
                                        mlt_service_apply_filters( mlt_filter_service( base->filters[ i ] ), frame, index + 1 );
-                                       mlt_frame_set_position( frame, position + in );
                                }
                        }
                }
        }
-
-       if ( mlt_properties_get_int( service_properties, "_cut" ) )
-       {
-               mlt_properties_set_position( frame_properties, "in", this_in );
-               mlt_properties_set_position( frame_properties, "out", this_out );
-               mlt_frame_set_position( frame, position + this_in );
-       }
 }
 
 /** Obtain a frame.
index 537e4c88615899ea03059213a86b2ff5a70a683a..92a10dc977fb568b1932d256500808e301fbfd44 100644 (file)
@@ -328,10 +328,8 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int tra
                        // Now stack callbacks
                        if ( audio != NULL )
                        {
-                               mlt_properties audio_properties = mlt_frame_properties( audio );
                                mlt_frame_push_audio( *frame, audio );
                                ( *frame )->get_audio = producer_get_audio;
-                               mlt_properties_set_position( frame_properties, "_position", mlt_properties_get_position( audio_properties, "_position" ) );
                        }
 
                        if ( video != NULL )
@@ -343,7 +341,6 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int tra
                                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_position( frame_properties, "_position", mlt_properties_get_position( video_properties, "_position" ) );
                        }
 
                        mlt_frame_set_position( *frame, mlt_producer_frame( parent ) );
index 6bb672a1ba489d5be8be0d14daedc9a3371e4a03..318aec6baaced4f5297d1c4f877a4049a0450174 100644 (file)
@@ -819,12 +819,13 @@ static void *consumer_thread( void *arg )
 
                                        pkt.size = avcodec_encode_audio( c, audio_outbuf, audio_outbuf_size, buffer );
                                        // Write the compressed frame in the media file
-                                       pkt.pts= c->coded_frame->pts;
+                                       if ( c->coded_frame )
+                                               pkt.pts= c->coded_frame->pts;
                                        pkt.flags |= PKT_FLAG_KEY;
                                        pkt.stream_index= audio_st->index;
                                        pkt.data= audio_outbuf;
 
-                                       if ( av_write_frame( oc, &pkt ) != 0) 
+                                       if ( av_interleaved_write_frame( oc, &pkt ) != 0) 
                                                fprintf(stderr, "Error while writing audio frame\n");
                                }
                                else
@@ -897,7 +898,8 @@ static void *consumer_thread( void *arg )
                                                        AVPacket pkt;
                                                        av_init_packet( &pkt );
 
-                                                       pkt.pts= c->coded_frame->pts;
+                                                       if ( c->coded_frame )
+                                                               pkt.pts= c->coded_frame->pts;
                                                        if(c->coded_frame->key_frame)
                                                                pkt.flags |= PKT_FLAG_KEY;
                                                        pkt.stream_index= video_st->index;
@@ -905,7 +907,7 @@ static void *consumer_thread( void *arg )
                                                        pkt.size= out_size;
 
                                        // write the compressed frame in the media file
-                                                       ret = av_write_frame(oc, &pkt);
+                                                       ret = av_interleaved_write_frame(oc, &pkt);
                                                } 
                                        }
                                        frame_count++;
index 2843ddee2df7c11cba6cf79278629956c923d318..6323236bd128d60ab6198ecffed3fe87df7c49b5 100644 (file)
@@ -150,7 +150,7 @@ static int process_feed( mlt_properties feed, mlt_filter filter, mlt_frame frame
                }
 
                // Set the original position on the frame
-               mlt_frame_set_position( frame, mlt_properties_get_int( feed, "position" ) );
+               mlt_frame_set_position( frame, mlt_properties_get_int( feed, "position" ) - mlt_properties_get_int( feed, "in" ) );
 
                // Process the filter
                mlt_filter_process( requested, frame );
index 4908d441073e7eca174d0f8412cd690676326c9a..e91aeadd36302af231253ee38fc58eecb89bb0da 100644 (file)
@@ -193,7 +193,7 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
        char *name = mlt_properties_get( mlt_filter_properties( this ), "_unique_id" );
 
        // Assign the current position to the name
-       mlt_properties_set_position( properties, name, mlt_frame_get_position( frame ) );
+       mlt_properties_set_position( properties, name, mlt_frame_get_position( frame ) - mlt_filter_get_in( this ) );
 
        // Push the filter on to the stack
        mlt_frame_push_service( frame, this );
index 2e76c51c31b539dd86def97634f91071f0c0e81a..f3d0b6bb29bd69a692e300adb344586026169009 100644 (file)
@@ -96,7 +96,7 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
        char *name = mlt_properties_get( mlt_filter_properties( this ), "_unique_id" );
 
        // Assign the current position to the name
-       mlt_properties_set_position( properties, name, mlt_frame_get_position( frame ) );
+       mlt_properties_set_position( properties, name, mlt_frame_get_position( frame ) - mlt_filter_get_in( this ) );
 
        // Push the frame filter
        mlt_frame_push_service( frame, this );