From 4b72d1071d80828a599085618bbba67a18d14e56 Mon Sep 17 00:00:00 2001 From: ddennedy Date: Tue, 5 Apr 2005 05:03:28 +0000 Subject: [PATCH] realtime scheduling updates; suppress libdv errors; add frame property deinterlace_method; default producer_hold to use onefield; add begin property to producer_pixbuf git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@688 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/albino/albino.c | 8 ++++++++ src/framework/mlt_consumer.c | 8 +------- src/inigo/inigo.c | 7 +++++++ src/miracle/miracle.c | 7 +++++++ src/miracle/miracle_server.c | 21 +++------------------ src/modules/avformat/consumer_avformat.c | 7 +------ src/modules/core/consumer_null.c | 7 +------ src/modules/dv/consumer_libdv.c | 7 +------ src/modules/dv/producer_libdv.c | 1 + src/modules/fezzik/producer_hold.c | 4 ++++ src/modules/gtk2/producer_pixbuf.c | 2 +- src/modules/sdl/consumer_sdl.c | 8 +------- src/modules/sdl/consumer_sdl_preview.c | 8 +------- src/modules/sdl/consumer_sdl_still.c | 8 +------- src/modules/xine/filter_deinterlace.c | 9 +++++++-- 15 files changed, 45 insertions(+), 67 deletions(-) diff --git a/src/albino/albino.c b/src/albino/albino.c index 0bee314..506f795 100644 --- a/src/albino/albino.c +++ b/src/albino/albino.c @@ -22,6 +22,7 @@ #include #include #include +#include /* Application header files */ #include @@ -58,6 +59,13 @@ int main( int argc, char **argv ) } else { + struct sched_param scp; + + // Use realtime scheduling if possible + memset( &scp, '\0', sizeof( scp ) ); + scp.sched_priority = sched_get_priority_max( SCHED_FIFO ) - 1; + sched_setscheduler( 0, SCHED_RR, &scp ); + printf( "Miracle Standalone Instance\n" ); parser = miracle_parser_init_local( ); response = valerie_parser_connect( parser ); diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c index 44f9452..3a839d2 100644 --- a/src/framework/mlt_consumer.c +++ b/src/framework/mlt_consumer.c @@ -494,8 +494,6 @@ static void *consumer_read_ahead_thread( void *arg ) static void consumer_read_ahead_start( mlt_consumer this ) { - pthread_attr_t thread_attributes; - // We're running now this->ahead = 1; @@ -508,12 +506,8 @@ static void consumer_read_ahead_start( mlt_consumer this ) // Create the condition pthread_cond_init( &this->cond, NULL ); - // Inherit the scheduling priority - pthread_attr_init( &thread_attributes ); - pthread_attr_setinheritsched( &thread_attributes, PTHREAD_INHERIT_SCHED ); - // Create the read ahead - pthread_create( &this->ahead_thread, &thread_attributes, consumer_read_ahead_thread, this ); + pthread_create( &this->ahead_thread, NULL, consumer_read_ahead_thread, this ); } static void consumer_read_ahead_stop( mlt_consumer this ) diff --git a/src/inigo/inigo.c b/src/inigo/inigo.c index d37a447..77575d5 100644 --- a/src/inigo/inigo.c +++ b/src/inigo/inigo.c @@ -1,6 +1,7 @@ #include #include #include +#include #include @@ -191,6 +192,12 @@ int main( int argc, char **argv ) mlt_producer inigo = NULL; FILE *store = NULL; char *name = NULL; + struct sched_param scp; + + // Use realtime scheduling if possible + memset( &scp, '\0', sizeof( scp ) ); + scp.sched_priority = sched_get_priority_max( SCHED_FIFO ) - 1; + sched_setscheduler( 0, SCHED_FIFO, &scp ); // Construct the factory mlt_factory_init( NULL ); diff --git a/src/miracle/miracle.c b/src/miracle/miracle.c index 913f785..d735662 100644 --- a/src/miracle/miracle.c +++ b/src/miracle/miracle.c @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -66,6 +67,12 @@ int main( int argc, char **argv ) int index = 0; int background = 1; struct timespec tm = { 5, 0 }; + struct sched_param scp; + + // Use realtime scheduling if possible + memset( &scp, '\0', sizeof( scp ) ); + scp.sched_priority = sched_get_priority_max( SCHED_FIFO ) - 1; + sched_setscheduler( 0, SCHED_RR, &scp ); mlt_factory_init( NULL ); diff --git a/src/miracle/miracle_server.c b/src/miracle/miracle_server.c index 151ce31..d0a96b9 100644 --- a/src/miracle/miracle_server.c +++ b/src/miracle/miracle_server.c @@ -158,9 +158,6 @@ static void *miracle_server_run( void *arg ) their resources get freed automatically. (CY: ... hmmph...) */ pthread_attr_init( &thread_attributes ); pthread_attr_setdetachstate( &thread_attributes, PTHREAD_CREATE_DETACHED ); - pthread_attr_init( &thread_attributes ); - pthread_attr_setinheritsched( &thread_attributes, PTHREAD_INHERIT_SCHED ); - /* pthread_attr_setschedpolicy( &thread_attributes, SCHED_RR ); */ while ( !server->shutdown ) { @@ -267,25 +264,13 @@ int miracle_server_execute( miracle_server server ) if ( response != NULL ) { - pthread_attr_t attr; int result; - pthread_attr_init( &attr ); - pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_JOINABLE ); - pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); - pthread_attr_setschedpolicy( &attr, SCHED_FIFO ); - pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM ); valerie_response_close( response ); - result = pthread_create( &server->thread, &attr, miracle_server_run, server ); + result = pthread_create( &server->thread, NULL, miracle_server_run, server ); if ( result ) { - miracle_log( LOG_WARNING, "Failed to schedule realtime (%s)", strerror(errno) ); - pthread_attr_setschedpolicy( &attr, SCHED_OTHER ); - result = pthread_create( &server->thread, &attr, miracle_server_run, server ); - if ( result ) - { - miracle_log( LOG_CRIT, "Failed to launch TCP listener thread" ); - error = -1; - } + miracle_log( LOG_CRIT, "Failed to launch TCP listener thread" ); + error = -1; } } } diff --git a/src/modules/avformat/consumer_avformat.c b/src/modules/avformat/consumer_avformat.c index e5a4ddd..021c501 100644 --- a/src/modules/avformat/consumer_avformat.c +++ b/src/modules/avformat/consumer_avformat.c @@ -235,7 +235,6 @@ static int consumer_start( mlt_consumer this ) { // Allocate a thread pthread_t *thread = calloc( 1, sizeof( pthread_t ) ); - pthread_attr_t thread_attributes; // Get the width and height int width = mlt_properties_get_int( properties, "width" ); @@ -269,12 +268,8 @@ static int consumer_start( mlt_consumer this ) // Set the running state mlt_properties_set_int( properties, "running", 1 ); - // Inherit the scheduling priority - pthread_attr_init( &thread_attributes ); - pthread_attr_setinheritsched( &thread_attributes, PTHREAD_INHERIT_SCHED ); - // Create the thread - pthread_create( thread, &thread_attributes, consumer_thread, this ); + pthread_create( thread, NULL, consumer_thread, this ); } return 0; } diff --git a/src/modules/core/consumer_null.c b/src/modules/core/consumer_null.c index 88a7947..d2abe19 100644 --- a/src/modules/core/consumer_null.c +++ b/src/modules/core/consumer_null.c @@ -74,7 +74,6 @@ static int consumer_start( mlt_consumer this ) { // Allocate a thread pthread_t *thread = calloc( 1, sizeof( pthread_t ) ); - pthread_attr_t thread_attributes; // Assign the thread to properties mlt_properties_set_data( properties, "thread", thread, sizeof( pthread_t ), free, NULL ); @@ -82,12 +81,8 @@ static int consumer_start( mlt_consumer this ) // Set the running state mlt_properties_set_int( properties, "running", 1 ); - // Inherit the scheduling priority - pthread_attr_init( &thread_attributes ); - pthread_attr_setinheritsched( &thread_attributes, PTHREAD_INHERIT_SCHED ); - // Create the thread - pthread_create( thread, &thread_attributes, consumer_thread, this ); + pthread_create( thread, NULL, consumer_thread, this ); } return 0; } diff --git a/src/modules/dv/consumer_libdv.c b/src/modules/dv/consumer_libdv.c index 448c225..c8f58bd 100644 --- a/src/modules/dv/consumer_libdv.c +++ b/src/modules/dv/consumer_libdv.c @@ -99,7 +99,6 @@ static int consumer_start( mlt_consumer this ) { // Allocate a thread pthread_t *thread = calloc( 1, sizeof( pthread_t ) ); - pthread_attr_t thread_attributes; // Assign the thread to properties mlt_properties_set_data( properties, "thread", thread, sizeof( pthread_t ), free, NULL ); @@ -107,12 +106,8 @@ static int consumer_start( mlt_consumer this ) // Set the running state mlt_properties_set_int( properties, "running", 1 ); - // Inherit the scheduling priority - pthread_attr_init( &thread_attributes ); - pthread_attr_setinheritsched( &thread_attributes, PTHREAD_INHERIT_SCHED ); - // Create the thread - pthread_create( thread, &thread_attributes, consumer_thread, this ); + pthread_create( thread, NULL, consumer_thread, this ); } return 0; } diff --git a/src/modules/dv/producer_libdv.c b/src/modules/dv/producer_libdv.c index 9516c10..0ab10e0 100644 --- a/src/modules/dv/producer_libdv.c +++ b/src/modules/dv/producer_libdv.c @@ -79,6 +79,7 @@ dv_decoder_t *dv_decoder_alloc( ) this->quality = DV_QUALITY_COLOR | DV_QUALITY_AC_2; this->audio->arg_audio_emphasis = 2; dv_set_audio_correction( this, DV_AUDIO_CORRECT_AVERAGE ); + dv_set_error_log( this, NULL ); // Register it with the properties to ensure clean up sprintf( label, "%p", this ); diff --git a/src/modules/fezzik/producer_hold.c b/src/modules/fezzik/producer_hold.c index 77afe3f..2a376f7 100644 --- a/src/modules/fezzik/producer_hold.c +++ b/src/modules/fezzik/producer_hold.c @@ -59,6 +59,7 @@ mlt_producer producer_hold_init( char *arg ) mlt_properties_set_position( properties, "out", 25 ); mlt_properties_set_position( properties, "length", 15000 ); mlt_properties_set( properties, "resource", arg ); + mlt_properties_set( properties, "method", "onefield" ); // Override the get_frame method this->get_frame = producer_get_frame; @@ -182,6 +183,9 @@ static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index // Ensure that the consumer sees what the real frame has mlt_properties_pass( MLT_FRAME_PROPERTIES( *frame ), MLT_FRAME_PROPERTIES( real_frame ), "" ); + + mlt_properties_set( MLT_FRAME_PROPERTIES( real_frame ), "deinterlace_method", + mlt_properties_get( properties, "method" ) ); } // Move to the next position diff --git a/src/modules/gtk2/producer_pixbuf.c b/src/modules/gtk2/producer_pixbuf.c index a37d6e9..7f8b46c 100644 --- a/src/modules/gtk2/producer_pixbuf.c +++ b/src/modules/gtk2/producer_pixbuf.c @@ -315,7 +315,7 @@ static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int i else if ( strchr( filename, '%' ) != NULL ) { // handle picture sequences - int i = 0; + int i = mlt_properties_get_int( properties, "begin" ); int gap = 0; char full[1024]; diff --git a/src/modules/sdl/consumer_sdl.c b/src/modules/sdl/consumer_sdl.c index 50e08d8..35c39c8 100644 --- a/src/modules/sdl/consumer_sdl.c +++ b/src/modules/sdl/consumer_sdl.c @@ -175,8 +175,6 @@ int consumer_start( mlt_consumer parent ) if ( !this->running ) { - pthread_attr_t thread_attributes; - consumer_stop( parent ); this->running = 1; @@ -189,11 +187,7 @@ int consumer_start( mlt_consumer parent ) mlt_properties_set_int( this->properties, "height", this->height ); } - // Inherit the scheduling priority - pthread_attr_init( &thread_attributes ); - pthread_attr_setinheritsched( &thread_attributes, PTHREAD_INHERIT_SCHED ); - - pthread_create( &this->thread, &thread_attributes, consumer_thread, this ); + pthread_create( &this->thread, NULL, consumer_thread, this ); } return 0; diff --git a/src/modules/sdl/consumer_sdl_preview.c b/src/modules/sdl/consumer_sdl_preview.c index 1d84943..d2dd859 100644 --- a/src/modules/sdl/consumer_sdl_preview.c +++ b/src/modules/sdl/consumer_sdl_preview.c @@ -135,19 +135,13 @@ static int consumer_start( mlt_consumer parent ) if ( !this->running ) { - pthread_attr_t thread_attributes; - consumer_stop( parent ); this->running = 1; this->joined = 0; this->last_speed = 1; - // Inherit the scheduling priority - pthread_attr_init( &thread_attributes ); - pthread_attr_setinheritsched( &thread_attributes, PTHREAD_INHERIT_SCHED ); - - pthread_create( &this->thread, &thread_attributes, consumer_thread, this ); + pthread_create( &this->thread, NULL, consumer_thread, this ); } return 0; diff --git a/src/modules/sdl/consumer_sdl_still.c b/src/modules/sdl/consumer_sdl_still.c index bc4489a..f2146f5 100644 --- a/src/modules/sdl/consumer_sdl_still.c +++ b/src/modules/sdl/consumer_sdl_still.c @@ -158,8 +158,6 @@ static int consumer_start( mlt_consumer parent ) if ( !this->running ) { - pthread_attr_t thread_attributes; - // Attach a colour space converter if ( !this->filtered ) { @@ -185,11 +183,7 @@ static int consumer_start( mlt_consumer parent ) //this->width = this->height * this->display_aspect; - // Inherit the scheduling priority - pthread_attr_init( &thread_attributes ); - pthread_attr_setinheritsched( &thread_attributes, PTHREAD_INHERIT_SCHED ); - - pthread_create( &this->thread, &thread_attributes, consumer_thread, this ); + pthread_create( &this->thread, NULL, consumer_thread, this ); } return 0; diff --git a/src/modules/xine/filter_deinterlace.c b/src/modules/xine/filter_deinterlace.c index fa48a4d..9d122a9 100644 --- a/src/modules/xine/filter_deinterlace.c +++ b/src/modules/xine/filter_deinterlace.c @@ -95,7 +95,12 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * char *method_str = mlt_properties_get( MLT_FILTER_PROPERTIES( filter ), "method" ); int method = DEINTERLACE_LINEARBLEND; - if ( strcmp( method_str, "bob" ) == 0 ) + if ( method_str == NULL ) + method_str = mlt_properties_get( MLT_FRAME_PROPERTIES( this ), "deinterlace_method" ); + + if ( method_str == NULL ) + mlt_properties_set( MLT_FILTER_PROPERTIES( filter ), "method", "linearblend" ); + else if ( strcmp( method_str, "bob" ) == 0 ) method = DEINTERLACE_BOB; else if ( strcmp( method_str, "weave" ) == 0 ) method = DEINTERLACE_BOB; @@ -142,7 +147,7 @@ mlt_filter filter_deinterlace_init( void *arg ) if ( this != NULL ) { this->process = deinterlace_process; - mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "method", arg == NULL ? "linearblend" : arg ); + mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "method", arg ); } return this; } -- 1.7.4.4