X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=mlt%2Fsrc%2Fframework%2Fmlt_filter.c;h=9c0a295234443da8b29cf4105fe6313eb04f6e8c;hb=8bf137cd71aafb9c8f6a42c78ddb6bd0a8fe99db;hp=22fefe22c0ddb3efee26b6518b1426dd65e235b0;hpb=661165812e3410fe2f6f49d7af882b36a0efcf82;p=melted diff --git a/mlt/src/framework/mlt_filter.c b/mlt/src/framework/mlt_filter.c index 22fefe2..9c0a295 100644 --- a/mlt/src/framework/mlt_filter.c +++ b/mlt/src/framework/mlt_filter.c @@ -39,7 +39,16 @@ int mlt_filter_init( mlt_filter this, void *child ) this->child = child; if ( mlt_service_init( service, this ) == 0 ) { + mlt_properties properties = mlt_service_properties( service ); + + // Override the get_frame method service->get_frame = filter_get_frame; + + // Default in, out, track properties + mlt_properties_set_timecode( properties, "in", 0 ); + mlt_properties_set_timecode( properties, "out", 0 ); + mlt_properties_set_int( properties, "track", 0 ); + return 0; } return 1; @@ -53,6 +62,11 @@ mlt_service mlt_filter_service( mlt_filter this ) return &this->parent; } +mlt_properties mlt_filter_properties( mlt_filter this ) +{ + return mlt_service_properties( mlt_filter_service( this ) ); +} + /** Connect this filter to a producers track. Note that a filter only operates on a single track, and by default it operates on the entirety of that track. */ @@ -64,10 +78,11 @@ int mlt_filter_connect( mlt_filter this, mlt_service producer, int index ) // If the connection was successful, grab the producer, track and reset in/out if ( ret == 0 ) { + mlt_properties properties = mlt_service_properties( &this->parent ); this->producer = producer; - this->track = index; - this->in = 0; - this->out = 0; + mlt_properties_set_timecode( properties, "in", 0 ); + mlt_properties_set_timecode( properties, "out", 0 ); + mlt_properties_set_int( properties, "track", index ); } return ret; @@ -78,8 +93,9 @@ int mlt_filter_connect( mlt_filter this, mlt_service producer, int index ) void mlt_filter_set_in_and_out( mlt_filter this, mlt_timecode in, mlt_timecode out ) { - this->in = in; - this->out = out; + mlt_properties properties = mlt_service_properties( &this->parent ); + mlt_properties_set_timecode( properties, "in", in ); + mlt_properties_set_timecode( properties, "out", out ); } /** Return the track that this filter is operating on. @@ -87,7 +103,8 @@ void mlt_filter_set_in_and_out( mlt_filter this, mlt_timecode in, mlt_timecode o int mlt_filter_get_track( mlt_filter this ) { - return this->track; + mlt_properties properties = mlt_service_properties( &this->parent ); + return mlt_properties_get_int( properties, "track" ); } /** Get the in point. @@ -95,7 +112,8 @@ int mlt_filter_get_track( mlt_filter this ) mlt_timecode mlt_filter_get_in( mlt_filter this ) { - return this->in; + mlt_properties properties = mlt_service_properties( &this->parent ); + return mlt_properties_get_timecode( properties, "in" ); } /** Get the out point. @@ -103,7 +121,8 @@ mlt_timecode mlt_filter_get_in( mlt_filter this ) mlt_timecode mlt_filter_get_out( mlt_filter this ) { - return this->out; + mlt_properties properties = mlt_service_properties( &this->parent ); + return mlt_properties_get_timecode( properties, "out" ); } /** Process the frame. @@ -123,9 +142,14 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) static int filter_get_frame( mlt_service service, mlt_frame_ptr frame, int index ) { mlt_filter this = service->child; + + // Get coords in/out/track + int track = mlt_filter_get_track( this ); + int in = mlt_filter_get_in( this ); + int out = mlt_filter_get_out( this ); // If the frame request is for this filters track, we need to process it - if ( index == this->track ) + if ( index == track ) { int ret = mlt_service_get_frame( this->producer, frame, index ); if ( ret == 0 ) @@ -133,7 +157,7 @@ static int filter_get_frame( mlt_service service, mlt_frame_ptr frame, int index if ( !mlt_frame_is_test_card( *frame ) ) { mlt_timecode timecode = mlt_frame_get_timecode( *frame ); - if ( timecode >= this->in && ( this->out == 0 || timecode < this->out ) ) + if ( timecode >= in && ( out == 0 || timecode < out ) ) *frame = filter_process( this, *frame ); } return 0;