X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_consumer.c;h=8f99db4dce52086ca24c6b8d73e35bb658af1279;hb=833934cc90094c909078f709532e6fe6f8f13b60;hp=1819a0ff7a0e586867febafc1f2bcaf4f7d03472;hpb=cab7cd53c3a4d9c4355751088fec61860dcabbce;p=melted diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c index 1819a0f..8f99db4 100644 --- a/src/framework/mlt_consumer.c +++ b/src/framework/mlt_consumer.c @@ -28,6 +28,7 @@ #include #include +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 ); /** Public final methods @@ -52,6 +53,8 @@ int mlt_consumer_init( mlt_consumer this, void *child ) { mlt_properties_set( properties, "normalisation", "PAL" ); mlt_properties_set_double( properties, "fps", 25.0 ); + mlt_properties_set_int( properties, "frame_rate_den", 25 ); + mlt_properties_set_int( properties, "frame_rate_num", 1 ); mlt_properties_set_int( properties, "width", 720 ); mlt_properties_set_int( properties, "height", 576 ); mlt_properties_set_int( properties, "progressive", 0 ); @@ -61,6 +64,8 @@ int mlt_consumer_init( mlt_consumer this, void *child ) { mlt_properties_set( properties, "normalisation", "NTSC" ); mlt_properties_set_double( properties, "fps", 30000.0 / 1001.0 ); + mlt_properties_set_int( properties, "frame_rate_den", 30000 ); + mlt_properties_set_int( properties, "frame_rate_num", 1001 ); mlt_properties_set_int( properties, "width", 720 ); mlt_properties_set_int( properties, "height", 480 ); mlt_properties_set_int( properties, "progressive", 0 ); @@ -87,6 +92,7 @@ int mlt_consumer_init( mlt_consumer this, void *child ) this->format = mlt_image_yuv422; mlt_events_register( properties, "consumer-frame-show", ( mlt_transmitter )mlt_consumer_frame_show ); + mlt_events_register( properties, "consumer-frame-render", ( mlt_transmitter )mlt_consumer_frame_render ); mlt_events_register( properties, "consumer-stopped", NULL ); // Create the push mutex and condition @@ -103,6 +109,12 @@ static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner listener( owner, this, ( mlt_frame )args[ 0 ] ); } +static void mlt_consumer_frame_render( mlt_listener listener, mlt_properties owner, mlt_service this, void **args ) +{ + if ( listener != NULL ) + listener( owner, this, ( mlt_frame )args[ 0 ] ); +} + /** Create a new consumer. */ @@ -171,9 +183,9 @@ int mlt_consumer_start( mlt_consumer this ) if ( producer != NULL ) { // Test card should loop I guess... - mlt_properties_set( MLT_PRODUCER_PROPERTIES( producer ), "eof", "pause" ); - mlt_producer_set_speed( producer, 0 ); - mlt_producer_set_in_and_out( producer, 0, 0 ); + mlt_properties_set( MLT_PRODUCER_PROPERTIES( producer ), "eof", "loop" ); + //mlt_producer_set_speed( producer, 0 ); + //mlt_producer_set_in_and_out( producer, 0, 0 ); // Set the test card on the consumer mlt_properties_set_data( properties, "test_card_producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL ); @@ -276,6 +288,10 @@ mlt_frame mlt_consumer_get_frame( mlt_consumer this ) { mlt_service_get_frame( service, &frame, 0 ); } + else + { + frame = mlt_frame_init( ); + } if ( frame != NULL ) { @@ -295,6 +311,7 @@ mlt_frame mlt_consumer_get_frame( mlt_consumer this ) // Aspect ratio and other jiggery pokery mlt_properties_set_double( frame_properties, "consumer_aspect_ratio", mlt_properties_get_double( properties, "aspect_ratio" ) ); mlt_properties_set_int( frame_properties, "consumer_deinterlace", mlt_properties_get_int( properties, "progressive" ) | mlt_properties_get_int( properties, "deinterlace" ) ); + mlt_properties_set( frame_properties, "deinterlace_method", mlt_properties_get( properties, "deinterlace_method" ) ); } // Return the frame @@ -367,7 +384,10 @@ static void *consumer_read_ahead_thread( void *arg ) // Get the image of the first frame if ( !video_off ) + { + mlt_events_fire( MLT_CONSUMER_PROPERTIES( this ), "consumer-frame-render", frame, NULL ); mlt_frame_get_image( frame, &image, &this->format, &width, &height, 0 ); + } if ( !audio_off ) { @@ -417,6 +437,7 @@ 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 ) { + mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "consumer_deinterlace", 1 ); skipped = 0; time_frame = 0; time_process = 0; @@ -430,7 +451,10 @@ static void *consumer_read_ahead_thread( void *arg ) { // Get the image, mark as rendered and time it if ( !video_off ) + { + mlt_events_fire( MLT_CONSUMER_PROPERTIES( this ), "consumer-frame-render", frame, NULL ); mlt_frame_get_image( frame, &image, &this->format, &width, &height, 0 ); + } mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "rendered", 1 ); } else @@ -476,8 +500,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; @@ -490,12 +512,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 )