]> git.sesse.net Git - mlt/blobdiff - src/modules/motion_est/filter_crop_detect.c
Propogate service-changed event to cut producer's parent.
[mlt] / src / modules / motion_est / filter_crop_detect.c
index af58f359b539117c23306abf0770d282e95e84c8..37df47da1e73a55e376cce0e23ab3d638b8b4de8 100644 (file)
@@ -63,6 +63,8 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        // Producers may start with blank footage, by default we will skip, oh, 5 frames unless overridden
        int skip = mlt_properties_get_int( properties, "skip");
 
+       mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
+
        // The result
        mlt_geometry_item bounds = mlt_properties_get_data( properties, "bounds", NULL );
 
@@ -75,7 +77,7 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        }
 
        // For periodic detection (with offset of 'skip')
-       if( frequency == 0 || (int)(mlt_frame_get_position(this)+skip) % frequency  != 0)
+       if( frequency == 0 || (int)(mlt_filter_get_position(filter, this)+skip) % frequency  != 0)
        {
                // Inject in stream 
                mlt_properties_set_data( MLT_FRAME_PROPERTIES(this), "bounds", bounds, sizeof( struct mlt_geometry_item_s ), NULL, NULL );
@@ -87,17 +89,9 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        // There is no way to detect a crop for sure, so make up an arbitrary one
        int thresh = mlt_properties_get_int( properties, "thresh" );
 
-       int xstride, ystride;
-
-       switch( *format ) {
-               case mlt_image_yuv422:
-                       xstride = 2;
-                       ystride = 2 * *width;
-                       break;
-               default:
-                       fprintf(stderr, "image format not supported by filter_crop_detect\n");
-                       return -1;
-       }
+       *format = mlt_image_yuv422;
+       int xstride = 2;
+       int ystride = 2 * *width;
 
        int x, y, average_brightness, deviation; // Scratch variables
        uint8_t *q;
@@ -199,6 +193,8 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *
        /* inject into frame */
        mlt_properties_set_data( MLT_FRAME_PROPERTIES(this), "bounds", bounds, sizeof( struct mlt_geometry_item_s ), NULL, NULL );
 
+       mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
+
        return error;
 }
 
@@ -221,7 +217,7 @@ static mlt_frame filter_process( mlt_filter this, mlt_frame frame )
 
 /** Constructor for the filter.
 */
-mlt_filter filter_crop_detect_init( char *arg )
+mlt_filter filter_crop_detect_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
 {
        mlt_filter this = mlt_filter_new( );
        if ( this != NULL )