]> git.sesse.net Git - mlt/blobdiff - src/modules/motion_est/filter_motion_est.c
enhance mlt_frame_clone with a deep/shallow parameter
[mlt] / src / modules / motion_est / filter_motion_est.c
index 80a11ad950a03505f21173347cb7ee017947124c..d2dff28402960da64f61e99e35495ee8accf21ed 100644 (file)
@@ -392,7 +392,7 @@ static void full_search(
 
 int ncompare (const void * a, const void * b)
 {
-       return ( *(int*)a - *(int*)b );
+       return ( *(const int*)a - *(const int*)b );
 }
 
 // motion vector denoising
@@ -782,11 +782,13 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        // Get the filter
        mlt_filter filter = mlt_frame_pop_service( frame );
 
+       mlt_service_lock( MLT_FILTER_SERVICE( filter ) );
+
        // Get the motion_est context object
        struct motion_est_context_s *c = mlt_properties_get_data( MLT_FILTER_PROPERTIES( filter ), "context", NULL);
 
-
        // Get the new image and frame number
+       *format = mlt_image_yuv422;
        int error = mlt_frame_get_image( frame, image, format, width, height, 1 );
 
        #ifdef BENCHMARK
@@ -869,17 +871,8 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
                c->former_vectors_valid = 0;
                memset( c->former_vectors, 0, c->mv_size );
 
-               // Calculate the size of our steps (the number of bytes that seperate adjacent pixels in X and Y direction)
-               switch( *format ) {
-                       case mlt_image_yuv422:
-                               c->xstride = 2;
-                               c->ystride = c->xstride * *width;
-                               break;
-                       default:
-                               // I don't know
-                               fprintf(stderr, "\"I am unfamiliar with your new fangled pixel format!\" -filter_motion_est\n");
-                               return -1;
-               }
+               c->xstride = 2;
+               c->ystride = c->xstride * *width;
 
                // Allocate a cache for the previous frame's image
                c->former_image = mlt_pool_alloc( *width * *height * 2 );
@@ -1038,7 +1031,6 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        // Remember which frame this is
        c->former_frame_position = c->current_frame_position;
 
-
        mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "motion_est.macroblock_width", c->mb_w );
        mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "motion_est.macroblock_height", c->mb_h );
        mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "motion_est.left_mb", c->left_mb );
@@ -1051,6 +1043,7 @@ static int filter_get_image( mlt_frame frame, uint8_t **image, mlt_image_format
        fprintf(stderr, " in frame %d:%d usec\n", c->current_frame_position, difference);
        #endif
 
+       mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
 
        return error;
 }