]> git.sesse.net Git - mlt/commitdiff
move printf -> mlt_log*
authorMarco Gittler <g.marco@freenet.de>
Sun, 11 Sep 2011 10:31:32 +0000 (12:31 +0200)
committerDan Dennedy <dan@dennedy.org>
Mon, 31 Oct 2011 04:52:36 +0000 (21:52 -0700)
src/modules/videostab/stabilize.c
src/modules/videostab/transform_image.c

index 189b4121cc18ec05e3e29eb46f839e3b04474472..444578016eb36232f66daa345049e330cd992130 100644 (file)
@@ -52,6 +52,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <framework/mlt_types.h>
+#include <framework/mlt_log.h>
 
 
 void addTrans(StabData* sd, Transform sl)
@@ -76,11 +77,11 @@ int initFields(StabData* sd)
     // 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;
@@ -259,7 +260,6 @@ double contrastSubImg(unsigned char* const I, const Field* field,
 */
 Transform calcShiftRGBSimple(StabData* sd)
 {
-       printf("calc shoft rgb simple\n");
     int x = 0, y = 0;
     int i, j;
     double minerror = 1e20;  
@@ -286,7 +286,6 @@ Transform calcShiftRGBSimple(StabData* sd)
 */
 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;
@@ -414,18 +413,18 @@ Transform calcFieldTransYUV(StabData* sd, const Field* field, int fieldnum)
     }
 #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;
     }
@@ -823,20 +822,20 @@ int stabilize_configure(StabData* instance
     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.
@@ -844,7 +843,7 @@ int stabilize_configure(StabData* instance
             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){
@@ -889,7 +888,7 @@ int stabilize_filter_video(StabData* instance,
                 addTrans(sd, calcTransFields(sd, calcFieldTransYUV,
                                              contrastSubImgYUV));
         } else {
-            printf("unsupported Codec: %i\n",
+            mlt_log_warning (NULL,"unsupported Codec: %i\n",
                         pixelformat);
             return 0;
         }
@@ -931,6 +930,8 @@ int stabilize_stop(StabData* instance)
        // and all transforms
        tc_list_foreach(sd->transs, stabilize_dump_trans, &ID);
 */
+       /* FOR DEBUG ONLY
+       
        tlist* transf=sd->transs;
        int num=0;
        while (transf ){
@@ -939,6 +940,7 @@ int stabilize_stop(StabData* instance)
                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);
index e5697ac89f4905ec644bb4af28878449aba469fd..f782c534900fbe27432e4e8b3d570fd871e4ba73 100644 (file)
@@ -26,6 +26,8 @@
 #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))
@@ -438,7 +440,7 @@ int preprocess_transforms(TransformData* td)
     if (td->trans_len < 1)
         return 0;
     if (0) {
-        printf("Preprocess transforms:");
+        mlt_log_warning(NULL,"Preprocess transforms:");
     }
     if (td->smoothing>0) {
         /* smoothing */
@@ -490,10 +492,10 @@ int preprocess_transforms(TransformData* td)
             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);      
@@ -515,7 +517,7 @@ int preprocess_transforms(TransformData* td)
         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); 
@@ -544,7 +546,7 @@ int preprocess_transforms(TransformData* td)
         // 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 */
@@ -601,7 +603,7 @@ int transform_configure(TransformData *self,int width,int height, mlt_image_form
     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;
     }
   
@@ -638,23 +640,23 @@ int transform_configure(TransformData *self,int width,int height, mlt_image_form
        
     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
@@ -663,7 +665,7 @@ int transform_configure(TransformData *self,int width,int height, mlt_image_form
         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;            
     }  
 
@@ -695,7 +697,7 @@ int transform_filter_video(TransformData *self,
     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;        
     }
   
@@ -704,7 +706,7 @@ int transform_filter_video(TransformData *self,
     } 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++;