+static void get_config( VSTransformConfig* tconf, VSMotionDetectConfig* mconf, mlt_filter filter, mlt_frame frame )
+{
+ mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
+ const char* filterName = mlt_properties_get( properties, "mlt_service" );
+
+ memset( mconf, 0, sizeof(VSMotionDetectConfig) );
+ *mconf = vsMotionDetectGetDefaultConfig( filterName );
+ mconf->shakiness = mlt_properties_get_int( properties, "shakiness" );
+ mconf->accuracy = mlt_properties_get_int(properties, "accuracy");
+ mconf->stepSize = mlt_properties_get_int(properties, "stepsize");
+ mconf->contrastThreshold = mlt_properties_get_double(properties, "mincontrast");
+
+ memset( tconf, 0, sizeof(VSTransformConfig) );
+ *tconf = vsTransformGetDefaultConfig( filterName );
+ tconf->smoothing = mlt_properties_get_int(properties, "smoothing");
+ tconf->maxShift = mlt_properties_get_int(properties, "maxshift");
+ tconf->maxAngle = mlt_properties_get_double(properties, "maxangle");
+ tconf->crop = (VSBorderType) mlt_properties_get_int(properties, "crop");
+ tconf->zoom = mlt_properties_get_int(properties, "zoom");
+ tconf->optZoom = mlt_properties_get_int(properties, "optzoom");
+ tconf->zoomSpeed = mlt_properties_get_double(properties, "zoomspeed");
+ tconf->relative = 1;
+
+ // by default a bicubic interpolation is selected
+ const char *interps = mlt_properties_get( MLT_FRAME_PROPERTIES( frame ), "rescale.interp" );
+ tconf->interpolType = VS_BiCubic;
+ if ( strcmp( interps, "nearest" ) == 0 || strcmp( interps, "neighbor" ) == 0 )
+ tconf->interpolType = VS_Zero;
+ else if ( strcmp( interps, "tiles" ) == 0 || strcmp( interps, "fast_bilinear" ) == 0 )
+ tconf->interpolType = VS_Linear;
+ else if ( strcmp( interps, "bilinear" ) == 0 )
+ tconf->interpolType = VS_BiLinear;
+}
+
+static int check_config( mlt_filter filter, mlt_frame frame )
+{
+ DeshakeData *data = static_cast<DeshakeData*>( filter->child );
+ VSTransformConfig new_tconf;
+ VSMotionDetectConfig new_mconf;
+
+ get_config( &new_tconf, &new_mconf, filter, frame );
+
+ if( compare_transform_config( &data->tconf, &new_tconf ) ||
+ compare_motion_config( &data->mconf, &new_mconf ) )
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+static void init_deshake( DeshakeData *data, mlt_filter filter, mlt_frame frame,
+ VSPixelFormat vs_format, int *width, int *height )