]> git.sesse.net Git - mlt/blobdiff - src/modules/motion_est/filter_autotrack_rectangle.c
Use '/' for coordinate delimiter instead of period.
[mlt] / src / modules / motion_est / filter_autotrack_rectangle.c
index befdfb7df7627ef07ac692c9f8cf3738633dccdc..b5b0022f448d4c805601449523471ed66017a02c 100644 (file)
@@ -120,7 +120,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        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 );
@@ -128,6 +128,8 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        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);
 
@@ -142,7 +144,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        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.x = boundry.y < 0 ? 0 : boundry.y;
+       boundry.y = boundry.y < 0 ? 0 : boundry.y;
        boundry.w = boundry.w < 0 ? 0 : boundry.w;
        boundry.h = boundry.h < 0 ? 0 : boundry.h;
 
@@ -171,7 +173,9 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                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);
@@ -185,7 +189,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
 
                // 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 );
        }
@@ -211,8 +215,10 @@ static int attach_boundry_to_frame( mlt_frame frame, uint8_t **image, mlt_image_
        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) {
@@ -232,6 +238,8 @@ static int attach_boundry_to_frame( mlt_frame frame, uint8_t **image, mlt_image_
                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);
@@ -323,7 +331,7 @@ mlt_filter filter_autotrack_rectangle_init( mlt_profile profile, mlt_service_typ
                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( profile, "motion_est", NULL );