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
// 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 );
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 );
// 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 )
{
}
// Indicate that the consumer is stopped
+ mlt_properties_set_int( properties, "running", 0 );
mlt_consumer_stopped( this );
return NULL;
int macroblock_width,
int macroblock_height,
int mv_buffer_width,
- int method )
+ int method,
+ int width,
+ int height )
{
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
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
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;
}
// 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;
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 )
{
}
}
+ this->running = 0;
+
// Kill the video thread
if ( init_video == 0 )
{