X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_filter.c;h=0b4b03f690539db3ba4f0a3725edc2684f16b0b1;hb=36aad7b318537612374acfd3f626a8c1364ad95d;hp=22fefe22c0ddb3efee26b6518b1426dd65e235b0;hpb=661165812e3410fe2f6f49d7af882b36a0efcf82;p=melted diff --git a/src/framework/mlt_filter.c b/src/framework/mlt_filter.c index 22fefe2..0b4b03f 100644 --- a/src/framework/mlt_filter.c +++ b/src/framework/mlt_filter.c @@ -39,7 +39,17 @@ 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_position( properties, "in", 0 ); + mlt_properties_set_position( properties, "out", 0 ); + mlt_properties_set_int( properties, "track", 0 ); + mlt_properties_set( properties, "resource", "" ); + return 0; } return 1; @@ -53,6 +63,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 +79,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_position( properties, "in", 0 ); + mlt_properties_set_position( properties, "out", 0 ); + mlt_properties_set_int( properties, "track", index ); } return ret; @@ -76,10 +92,11 @@ int mlt_filter_connect( mlt_filter this, mlt_service producer, int index ) /** Tune the in/out points. */ -void mlt_filter_set_in_and_out( mlt_filter this, mlt_timecode in, mlt_timecode out ) +void mlt_filter_set_in_and_out( mlt_filter this, mlt_position in, mlt_position out ) { - this->in = in; - this->out = out; + mlt_properties properties = mlt_service_properties( &this->parent ); + mlt_properties_set_position( properties, "in", in ); + mlt_properties_set_position( properties, "out", out ); } /** Return the track that this filter is operating on. @@ -87,23 +104,26 @@ 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. */ -mlt_timecode mlt_filter_get_in( mlt_filter this ) +mlt_position mlt_filter_get_in( mlt_filter this ) { - return this->in; + mlt_properties properties = mlt_service_properties( &this->parent ); + return mlt_properties_get_position( properties, "in" ); } /** Get the out point. */ -mlt_timecode mlt_filter_get_out( mlt_filter this ) +mlt_position mlt_filter_get_out( mlt_filter this ) { - return this->out; + mlt_properties properties = mlt_service_properties( &this->parent ); + return mlt_properties_get_position( properties, "out" ); } /** Process the frame. @@ -123,17 +143,22 @@ 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 ) { 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 ) ) + mlt_position position = mlt_frame_get_position( *frame ); + if ( position >= in && ( out == 0 || position < out ) ) *frame = filter_process( this, *frame ); } return 0;