#include <stdlib.h>
#include <string.h>
#include <framework/mlt_types.h>
+#include <framework/mlt_log.h>
void addTrans(StabData* sd, Transform sl)
// make sure that the remaining rows have the same length
sd->field_num = rows*cols;
sd->field_rows = rows;
- printf("field setup: rows: %i cols: %i Total: %i fields",
+ mlt_log_warning (NULL,"field setup: rows: %i cols: %i Total: %i fields",
rows, cols, sd->field_num);
if (!(sd->fields = malloc(sizeof(Field) * sd->field_num))) {
- printf( "malloc failed!\n");
+ mlt_log_error ( NULL, "malloc failed!\n");
return 0;
} else {
int i, j;
*/
Transform calcShiftRGBSimple(StabData* sd)
{
- printf("calc shoft rgb simple\n");
int x = 0, y = 0;
int i, j;
double minerror = 1e20;
*/
Transform calcShiftYUVSimple(StabData* sd)
{
- printf("calc shoft yuv\n");
int x = 0, y = 0;
int i, j;
unsigned char *Y_c, *Y_p;// , *Cb, *Cr;
}
#ifdef STABVERBOSE
fclose(f);
- printf( "Minerror: %f\n", minerror);
+ mlt_log_warning ( "Minerror: %f\n", minerror);
#endif
if (!sd->allowmax && fabs(t.x) == sd->maxshift) {
#ifdef STABVERBOSE
- printf( "maximal x shift ");
+ mlt_log_warning ( "maximal x shift ");
#endif
t.x = 0;
}
if (!sd->allowmax && fabs(t.y) == sd->maxshift) {
#ifdef STABVERBOSE
- printf("maximal y shift ");
+ mlt_log_warning ("maximal y shift ");
#endif
t.y = 0;
}
sd->shakiness = MIN(10,MAX(1,sd->shakiness));
sd->accuracy = MAX(sd->shakiness,MIN(15,MAX(1,sd->accuracy)));
if (1) {
- printf( "Image Stabilization Settings:\n");
- printf( " shakiness = %d\n", sd->shakiness);
- printf( " accuracy = %d\n", sd->accuracy);
- printf( " stepsize = %d\n", sd->stepsize);
- printf( " algo = %d\n", sd->algo);
- printf(" mincontrast = %f\n", sd->contrast_threshold);
- printf( " show = %d\n", sd->show);
+ mlt_log_warning (NULL, "Image Stabilization Settings:\n");
+ mlt_log_warning (NULL, " shakiness = %d\n", sd->shakiness);
+ mlt_log_warning (NULL, " accuracy = %d\n", sd->accuracy);
+ mlt_log_warning (NULL, " stepsize = %d\n", sd->stepsize);
+ mlt_log_warning (NULL, " algo = %d\n", sd->algo);
+ mlt_log_warning (NULL, " mincontrast = %f\n", sd->contrast_threshold);
+ mlt_log_warning (NULL, " show = %d\n", sd->show);
}
// shift and size: shakiness 1: height/40; 10: height/4
sd->maxshift = MIN(sd->width, sd->height)*sd->shakiness/40;
sd->field_size = MIN(sd->width, sd->height)*sd->shakiness/40;
- printf( "Fieldsize: %i, Maximal translation: %i pixel\n",
+ mlt_log_warning ( NULL, "Fieldsize: %i, Maximal translation: %i pixel\n",
sd->field_size, sd->maxshift);
if (sd->algo==1) {
// initialize measurement fields. field_num is set here.
return -1;
}
sd->maxfields = (sd->accuracy) * sd->field_num / 15;
- printf( "Number of used measurement fields: %i out of %i\n",
+ mlt_log_warning ( NULL, "Number of used measurement fields: %i out of %i\n",
sd->maxfields, sd->field_num);
}
if (sd->show){
addTrans(sd, calcTransFields(sd, calcFieldTransYUV,
contrastSubImgYUV));
} else {
- printf("unsupported Codec: %i\n",
+ mlt_log_warning (NULL,"unsupported Codec: %i\n",
pixelformat);
return 0;
}
// and all transforms
tc_list_foreach(sd->transs, stabilize_dump_trans, &ID);
*/
+ /* FOR DEBUG ONLY
+
tlist* transf=sd->transs;
int num=0;
while (transf ){
printf("%d %f %f %f %f %d\n",num++,t->x,t->y,t->alpha,t->zoom,t->extra);
transf=transf->next;
}
+ */
//tc_list_del(sd->transs, 1 );
if (sd->prev) {
free(sd->prev);
#include "transform_image.h"
#include <string.h>
#include <stdlib.h>
+#include <framework/mlt_log.h>
+
#define MAX (a,b) (((a)>(b)?(a):(b)))
#define MIN (a,b) (((a)<(b)?(a):(b)))
#define CLAMP(a,x,y) MIN( MAX( (a),(x) ,y))
if (td->trans_len < 1)
return 0;
if (0) {
- printf("Preprocess transforms:");
+ mlt_log_warning(NULL,"Preprocess transforms:");
}
if (td->smoothing>0) {
/* smoothing */
ts[i] = sub_transforms(&ts[i], &avg2);
if (0 /*verbose*/ ) {
- printf("s_sum: %5lf %5lf %5lf, ts: %5lf, %5lf, %5lf\n",
+ mlt_log_warning(NULL,"s_sum: %5lf %5lf %5lf, ts: %5lf, %5lf, %5lf\n",
s_sum.x, s_sum.y, s_sum.alpha,
ts[i].x, ts[i].y, ts[i].alpha);
- printf(
+ mlt_log_warning(NULL,
" avg: %5lf, %5lf, %5lf avg2: %5lf, %5lf, %5lf",
avg.x, avg.y, avg.alpha,
avg2.x, avg2.y, avg2.alpha);
Transform t = ts[0];
for (i = 1; i < td->trans_len; i++) {
if (0/*verbose*/ ) {
- printf( "shift: %5lf %5lf %lf \n",
+ mlt_log_warning(NULL, "shift: %5lf %5lf %lf \n",
t.x, t.y, t.alpha *180/M_PI);
}
ts[i] = add_transforms(&ts[i], &t);
// the zoom value only for y
double zy = 2*TC_MAX(max_t.y,fabs(min_t.y))/td->height_src;
td->zoom += 100* TC_MAX(zx,zy); // use maximum
- printf("Final zoom: %lf\n", td->zoom);
+ mlt_log_warning(NULL,"Final zoom: %lf\n", td->zoom);
}
/* apply global zoom */
td->framesize_src = width*height*(pixelformat==mlt_image_rgb24 ? 3 : (3.0/2.0));
td->src = malloc(td->framesize_src); /* FIXME */
if (td->src == NULL) {
- printf("tc_malloc failed\n");
+ mlt_log_error(NULL,"tc_malloc failed\n");
return -1;
}
td->interpoltype = TC_MIN(td->interpoltype,4);
if (0) {
- printf( "Image Transformation/Stabilization Settings:\n");
- printf( " input = %s\n", td->input);
- printf( " smoothing = %d\n", td->smoothing);
- printf( " maxshift = %d\n", td->maxshift);
- printf( " maxangle = %f\n", td->maxangle);
- printf( " crop = %s\n",
+ mlt_log_warning(NULL, "Image Transformation/Stabilization Settings:\n");
+ mlt_log_warning(NULL, " input = %s\n", td->input);
+ mlt_log_warning(NULL, " smoothing = %d\n", td->smoothing);
+ mlt_log_warning(NULL, " maxshift = %d\n", td->maxshift);
+ mlt_log_warning(NULL, " maxangle = %f\n", td->maxangle);
+ mlt_log_warning(NULL, " crop = %s\n",
td->crop ? "Black" : "Keep");
- printf( " relative = %s\n",
+ mlt_log_warning(NULL, " relative = %s\n",
td->relative ? "True": "False");
- printf( " invert = %s\n",
+ mlt_log_warning(NULL, " invert = %s\n",
td->invert ? "True" : "False");
- printf( " zoom = %f\n", td->zoom);
- printf( " optzoom = %s\n",
+ mlt_log_warning(NULL, " zoom = %f\n", td->zoom);
+ mlt_log_warning(NULL, " optzoom = %s\n",
td->optzoom ? "On" : "Off");
- printf( " interpol = %s\n",
+ mlt_log_warning(NULL, " interpol = %s\n",
interpoltypes[td->interpoltype]);
- printf( " sharpen = %f\n", td->sharpen);
+ mlt_log_warning(NULL, " sharpen = %f\n", td->sharpen);
}
if (td->maxshift > td->width_dest/2
td->maxshift = td->height_dest/2;
if (!preprocess_transforms(td)) {
- printf("error while preprocessing transforms!");
+ mlt_log_error(NULL,"error while preprocessing transforms!");
return -1;
}
if (td->current_trans >= td->trans_len) {
td->current_trans = td->trans_len-1;
if(!td->warned_transform_end)
- printf("not enough transforms found, use last transformation!\n");
+ mlt_log_warning(NULL,"not enough transforms found, use last transformation!\n");
td->warned_transform_end = 1;
}
} else if (pixelformat == mlt_image_yuv420p) {
transformYUV(td);
} else {
- printf("unsupported Codec: %i\n", pixelformat);
+ mlt_log_error(NULL,"unsupported Codec: %i\n", pixelformat);
return 1;
}
td->current_trans++;