]> git.sesse.net Git - mlt/commitdiff
src/modules/core/consumer_null.c
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 25 Oct 2005 07:26:52 +0000 (07:26 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Tue, 25 Oct 2005 07:26:52 +0000 (07:26 +0000)
src/modules/sdl/consumer_sdl.c
+ Terminate on pause functionality

src/modules/motion_est/filter_autotrack_rectangle.c
+ Ensures that tracked area remains valid (out of bounds was causing core dumps)
? Currently, width/height is preserved on boundaries, but maybe it should shrink/grow?

git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@856 d19143bc-622f-0410-bfdd-b5b2a6649095

src/modules/core/consumer_null.c
src/modules/motion_est/filter_autotrack_rectangle.c
src/modules/sdl/consumer_sdl.c

index d2abe19db8a1bcdf44e6aa79a0a86e51ee1ac448..96183fd846e9e0b57bdf8a08ae43b93811b112a9 100644 (file)
@@ -80,6 +80,7 @@ static int consumer_start( mlt_consumer this )
 
                // Set the running state
                mlt_properties_set_int( properties, "running", 1 );
+               mlt_properties_set_int( properties, "joined", 0 );
 
                // Create the thread
                pthread_create( thread, NULL, consumer_thread, this );
@@ -96,13 +97,14 @@ static int consumer_stop( mlt_consumer this )
        mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
 
        // Check that we're running
-       if ( mlt_properties_get_int( properties, "running" ) )
+       if ( !mlt_properties_get_int( properties, "joined" ) )
        {
                // Get the thread
                pthread_t *thread = mlt_properties_get_data( properties, "thread", NULL );
 
                // Stop the thread
                mlt_properties_set_int( properties, "running", 0 );
+               mlt_properties_set_int( properties, "joined", 1 );
 
                // Wait for termination
                pthread_join( *thread, NULL );
@@ -132,15 +134,23 @@ static void *consumer_thread( void *arg )
        // Get the properties
        mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
 
+       // Convenience functionality
+       int terminate_on_pause = mlt_properties_get_int( properties, "terminate_on_pause" );
+       int terminated = 0;
+
        // Frame and size
        mlt_frame frame = NULL;
 
        // Loop while running
-       while( mlt_properties_get_int( properties, "running" ) )
+       while( !terminated && mlt_properties_get_int( properties, "running" ) )
        {
                // Get the frame
                frame = mlt_consumer_rt_frame( this );
 
+               // Check for termination
+               if ( terminate_on_pause && frame != NULL )
+                       terminated = mlt_properties_get_double( MLT_FRAME_PROPERTIES( frame ), "_speed" ) == 0.0;
+
                // Check that we have a frame to work with
                if ( frame != NULL )
                {
@@ -151,6 +161,7 @@ static void *consumer_thread( void *arg )
        }
 
        // Indicate that the consumer is stopped
+       mlt_properties_set_int( properties, "running", 0 );
        mlt_consumer_stopped( this );
 
        return NULL;
index a54faa7cb010fdc16fa28f807c35c546017af201..60d86605e42ca9d10c47a4c6403f0d1abc1c2d5c 100644 (file)
@@ -40,7 +40,9 @@ void caculate_motion( struct motion_vector_s *vectors,
                      int macroblock_width,
                      int macroblock_height,
                      int mv_buffer_width,
-                     int method )
+                     int method,
+                     int width,
+                     int height )
 {
 
 
@@ -90,6 +92,18 @@ void caculate_motion( struct motion_vector_s *vectors,
 
        boundry->x -= (double)average2_x / (double)n;
        boundry->y -= (double)average2_y / (double)n;
+
+       if ( boundry->x < 0 )
+               boundry->x = 0;
+
+       if ( boundry->y < 0 )
+               boundry->y = 0;
+
+       if ( boundry->x + boundry->w > width )
+               boundry->x = width - boundry->w;
+
+       if ( boundry->y + boundry->h > height )
+               boundry->y = height - boundry->h;
 }
 
 // Image stack(able) method
@@ -136,7 +150,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                int macroblock_width = mlt_properties_get_int( frame_properties, "motion_est.macroblock_width" );
                int mv_buffer_width = *width / macroblock_width;
 
-               caculate_motion( vectors, &boundry, macroblock_width, macroblock_height, mv_buffer_width, method );
+               caculate_motion( vectors, &boundry, macroblock_width, macroblock_height, mv_buffer_width, method, *width, *height );
 
 
                // Make the geometry object a real boy
@@ -168,6 +182,11 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                mlt_properties_set( MLT_FILTER_PROPERTIES( obscure ), "end", geom );
        }
                
+       if( mlt_properties_get_int( filter_properties, "collect" ) == 1 )
+       {
+               printf( "%d,%d,%d,%d\n", (int)boundry.x, (int)boundry.y, (int)boundry.w, (int)boundry.h );
+               fflush( stdout );
+       }
 
        return error;
 }
index bcd69a04c1f3ac361720b5d844c755e52be2929a..5879187205342eeeff77f9f88f256d2bda7d4afd 100644 (file)
@@ -683,6 +683,10 @@ static void *consumer_thread( void *arg )
        // Get the consumer
        mlt_consumer consumer = &this->parent;
 
+       // Convenience functionality
+       int terminate_on_pause = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "terminate_on_pause" );
+       int terminated = 0;
+
        // Video thread
        pthread_t thread;
 
@@ -696,11 +700,15 @@ static void *consumer_thread( void *arg )
        struct timespec tm = { 0, 100000 };
 
        // Loop until told not to
-       while( this->running )
+       while( !terminated && this->running )
        {
                // Get a frame from the attached producer
                frame = mlt_consumer_rt_frame( consumer );
 
+               // Check for termination
+               if ( terminate_on_pause && frame != NULL )
+                       terminated = mlt_properties_get_double( MLT_FRAME_PROPERTIES( frame ), "_speed" ) == 0.0;
+
                // Ensure that we have a frame
                if ( frame != NULL )
                {
@@ -737,6 +745,8 @@ static void *consumer_thread( void *arg )
                }
        }
 
+       this->running = 0;
+
        // Kill the video thread
        if ( init_video == 0 )
        {