From 9a65b1f152190678357601b20ce0e3425347c54b Mon Sep 17 00:00:00 2001 From: ddennedy Date: Sun, 22 Jun 2008 17:46:30 +0000 Subject: [PATCH] mlt_consumer.c: make the realtime frame-dropping heuristic based on actual frame rate instead of 25fps git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1144 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/framework/mlt_consumer.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c index 83ef8ff..7d1d4af 100644 --- a/src/framework/mlt_consumer.c +++ b/src/framework/mlt_consumer.c @@ -29,6 +29,8 @@ #include #include +#undef DEINTERLACE_ON_NOT_NORMAL_SPEED + static void mlt_consumer_frame_render( mlt_listener listener, mlt_properties owner, mlt_service this, void **args ); static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner, mlt_service this, void **args ); static void mlt_consumer_property_changed( mlt_service owner, mlt_consumer this, char *name ); @@ -322,6 +324,11 @@ int mlt_consumer_start( mlt_consumer this ) mlt_properties_set_data( properties, "test_card_producer", NULL, 0, NULL, NULL ); } + // Set the frame duration in microseconds for the frame-dropping heuristic + int frame_duration = 1000000 / mlt_properties_get_int( properties, "frame_rate_num" ) * + mlt_properties_get_int( properties, "frame_rate_den" ); + mlt_properties_set_int( properties, "frame_duration", frame_duration ); + // Check and run an ante command if ( mlt_properties_get( properties, "ante" ) ) system( mlt_properties_get( properties, "ante" ) ); @@ -570,7 +577,9 @@ static void *consumer_read_ahead_thread( void *arg ) // All non normal playback frames should be shown if ( mlt_properties_get_int( MLT_FRAME_PROPERTIES( frame ), "_speed" ) != 1 ) { +#ifdef DEINTERLACE_ON_NOT_NORMAL_SPEED mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "consumer_deinterlace", 1 ); +#endif skipped = 0; time_frame = 0; time_process = 0; @@ -618,8 +627,12 @@ static void *consumer_read_ahead_thread( void *arg ) time_process += time_difference( &ante ); // Determine if the next frame should be skipped - if ( mlt_deque_count( this->queue ) <= 5 && ( ( time_wait + time_frame + time_process ) / count ) > 40000 ) - skip_next = 1; + if ( mlt_deque_count( this->queue ) <= 5 ) + { + int frame_duration = mlt_properties_get_int( properties, "frame_duration" ); + if ( ( ( time_wait + time_frame + time_process ) / count ) > frame_duration ) + skip_next = 1; + } // Unlock if there's a lock object if ( lock_object ) mlt_service_unlock( lock_object ); -- 1.7.4.4