int ncompare (const void * a, const void * b)
{
- return ( *(int*)a - *(int*)b );
+ return ( *(const int*)a - *(const int*)b );
}
// motion vector denoising
// 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
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 );
// 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 );
fprintf(stderr, " in frame %d:%d usec\n", c->current_frame_position, difference);
#endif
+ mlt_service_unlock( MLT_FILTER_SERVICE( filter ) );
return error;
}