4 * Marco Gittler <g.marco@freenet.de>
5 * Jakub Ksiezniak <j.ksiezniak@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include <vid.stab/libvidstab.h>
25 #include <framework/mlt.h>
32 static mlt_frame process_filter(mlt_filter filter, mlt_frame frame)
34 mlt_properties properties = MLT_FILTER_PROPERTIES(filter);
35 mlt_get_image vidstab_get_image = (mlt_get_image) mlt_properties_get_data( properties, "_vidstab_get_image", NULL );
38 mlt_position pos = mlt_filter_get_position(filter, frame);
39 mlt_position length = mlt_filter_get_length2(filter, frame) - 1;
42 mlt_properties_set_data(properties, "_vidstab_get_image", NULL, 0, NULL, NULL);
46 if(vidstab_get_image == NULL)
48 if(mlt_properties_get(properties, "vectors") == NULL)
50 // vectors are NULL, so use a detect filter
51 vidstab_get_image = get_image_and_detect;
53 // found vectors, so use a transform filter
54 vidstab_get_image = get_image_and_transform;
57 mlt_properties_set_data( properties, "_vidstab_get_image", (void*)vidstab_get_image, 0, NULL, NULL );
60 mlt_frame_push_service(frame, filter);
61 mlt_frame_push_get_image(frame, vidstab_get_image);
68 mlt_filter filter_vidstab_init(mlt_profile profile, mlt_service_type type,
69 const char *id, char *arg)
71 mlt_filter filter = NULL;
73 if ((filter = mlt_filter_new()))
75 filter->process = process_filter;
77 mlt_properties properties = MLT_FILTER_PROPERTIES(filter);
79 //properties for stabilize
80 mlt_properties_set(properties, "shakiness", "4");
81 mlt_properties_set(properties, "accuracy", "4");
82 mlt_properties_set(properties, "stepsize", "6");
83 mlt_properties_set(properties, "algo", "1");
84 mlt_properties_set(properties, "mincontrast", "0.3");
85 mlt_properties_set(properties, "show", "0");
86 mlt_properties_set(properties, "tripod", "0");
88 // properties for transform
89 mlt_properties_set(properties, "smoothing", "15");
90 mlt_properties_set(properties, "maxshift", "-1");
91 mlt_properties_set(properties, "maxangle", "-1");
92 mlt_properties_set(properties, "crop", "0");
93 mlt_properties_set(properties, "invert", "0");
94 mlt_properties_set(properties, "relative", "1");
95 mlt_properties_set(properties, "zoom", "0");
96 mlt_properties_set(properties, "optzoom", "1");
97 mlt_properties_set(properties, "zoomspeed", "0.25");
99 mlt_properties_set(properties, "vid.stab.version", LIBVIDSTAB_VERSION);