mlt_properties frame_properties = MLT_FRAME_PROPERTIES(frame);
// Get the frame position
- mlt_position position = mlt_frame_get_position( frame );
+ mlt_position position = mlt_filter_get_position( filter, frame );
// Get the new image
int error = mlt_frame_get_image( frame, image, format, width, height, 1 );
if( error != 0 )
mlt_properties_debug( frame_properties, "error after mlt_frame_get_image() in autotrack_rectangle", stderr );
+ mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
+
// Get the geometry object
mlt_geometry geometry = mlt_properties_get_data(filter_properties, "filter_geometry", NULL);
// Get the motion vectors
struct motion_vector_s *vectors = mlt_properties_get_data( frame_properties, "motion_est.vectors", NULL );
+ // Cleanse the geometry item
+ boundry.w = boundry.x < 0 ? boundry.w + boundry.x : boundry.w;
+ boundry.h = boundry.y < 0 ? boundry.h + boundry.y : boundry.h;
+ boundry.x = boundry.x < 0 ? 0 : boundry.x;
+ boundry.y = boundry.y < 0 ? 0 : boundry.y;
+ boundry.w = boundry.w < 0 ? 0 : boundry.w;
+ boundry.h = boundry.h < 0 ? 0 : boundry.h;
+
// How did the rectangle move?
if( vectors != NULL &&
boundry.key != 1 ) // Paused?
mlt_geometry_insert(geometry, &boundry);
}
- if( mlt_properties_get_int( filter_properties, "debug" ) == 1 )
+ mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
+
+ if( mlt_properties_get_int( filter_properties, "debug" ) == 1 )
{
init_arrows( format, *width, *height );
draw_rectangle_outline(*image, boundry.x, boundry.y, boundry.w, boundry.h, 100);
// Because filter_obscure needs to be rewritten to use mlt_geometry
char geom[100];
- sprintf( geom, "%d,%d:%dx%d", (int)boundry.x, (int)boundry.y, (int)boundry.w, (int)boundry.h );
+ sprintf( geom, "%d/%d:%dx%d", (int)boundry.x, (int)boundry.y, (int)boundry.w, (int)boundry.h );
mlt_properties_set( MLT_FILTER_PROPERTIES( obscure ), "start", geom );
mlt_properties_set( MLT_FILTER_PROPERTIES( obscure ), "end", geom );
}
mlt_properties frame_properties = MLT_FRAME_PROPERTIES(frame);
// Get the frame position
- mlt_position position = mlt_frame_get_position( frame );
+ mlt_position position = mlt_filter_get_position( filter, frame );
+ mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
+
// Get the geometry object
mlt_geometry geometry = mlt_properties_get_data(filter_properties, "filter_geometry", NULL);
if (geometry == NULL) {
geometry = mlt_properties_get_data(filter_properties, "filter_geometry", NULL);
}
+ mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
+
// Get the current geometry item
mlt_geometry_item geometry_item = mlt_pool_alloc( sizeof( struct mlt_geometry_item_s ) );
mlt_geometry_fetch(geometry, geometry_item, position);
+ // Cleanse the geometry item
+ geometry_item->w = geometry_item->x < 0 ? geometry_item->w + geometry_item->x : geometry_item->w;
+ geometry_item->h = geometry_item->y < 0 ? geometry_item->h + geometry_item->y : geometry_item->h;
+ geometry_item->x = geometry_item->x < 0 ? 0 : geometry_item->x;
+ geometry_item->y = geometry_item->y < 0 ? 0 : geometry_item->y;
+ geometry_item->w = geometry_item->w < 0 ? 0 : geometry_item->w;
+ geometry_item->h = geometry_item->h < 0 ? 0 : geometry_item->h;
+
mlt_properties_set_data( frame_properties, "bounds", geometry_item, sizeof( struct mlt_geometry_item_s ), mlt_pool_release, NULL );
// Get the new image
mlt_filter vismv = mlt_properties_get_data( MLT_FILTER_PROPERTIES(this), "_vismv", NULL );
if( vismv == NULL )
{
- vismv = mlt_factory_filter( "vismv", NULL );
+ mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( this ) );
+ vismv = mlt_factory_filter( profile, "vismv", NULL );
mlt_properties_set_data( MLT_FILTER_PROPERTIES(this), "_vismv", vismv, 0, (mlt_destructor)mlt_filter_close, NULL );
}
mlt_filter obscure = mlt_properties_get_data( MLT_FILTER_PROPERTIES(this), "_obscure", NULL );
if( obscure == NULL )
{
- obscure = mlt_factory_filter( "obscure", NULL );
+ mlt_profile profile = mlt_service_profile( MLT_FILTER_SERVICE( this ) );
+ obscure = mlt_factory_filter( profile, "obscure", NULL );
mlt_properties_set_data( MLT_FILTER_PROPERTIES(this), "_obscure", obscure, 0, (mlt_destructor)mlt_filter_close, NULL );
}
*/
-mlt_filter filter_autotrack_rectangle_init( char *arg )
+mlt_filter filter_autotrack_rectangle_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
mlt_filter this = mlt_filter_new( );
if ( this != NULL )
if( arg != NULL )
mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "geometry", arg );
else
- mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "geometry", "100,100:100x100" );
+ mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "geometry", "100/100:100x100" );
// create an instance of the motion_est and obscure filter
- mlt_filter motion_est = mlt_factory_filter( "motion_est", NULL );
+ mlt_filter motion_est = mlt_factory_filter( profile, "motion_est", NULL );
if( motion_est != NULL )
mlt_properties_set_data( MLT_FILTER_PROPERTIES(this), "_motion_est", motion_est, 0, (mlt_destructor)mlt_filter_close, NULL );
else {