[vlc-devel] [PATCH] Reactivated an improved version of the crop-module

VlcVelope 1034-135 at online.de
Sun Apr 29 13:14:49 CEST 2012


Now the names of the variable are compatible with the old crop filter.

Regards,
VlcVelope
---
 modules/video_filter/crop.c |   65 +++++++++++++++++++++++--------------------
 1 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/modules/video_filter/crop.c b/modules/video_filter/crop.c
index 0a8e119..19065ae 100644
--- a/modules/video_filter/crop.c
+++ b/modules/video_filter/crop.c
@@ -108,26 +108,24 @@ vlc_module_begin ()
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_VFILTER )
 
-    add_string( CFG_PREFIX "crop-geometry", NULL, GEOMETRY_TEXT,
-                                             GEOMETRY_LONGTEXT, false )
+    add_shortcut( "crop" )
 
-    set_section( N_("autocrop"), NULL )
 
     add_bool( CFG_PREFIX "autocrop-enabled", false, AUTOCROP_TEXT,
-                                   AUTOCROP_LONGTEXT, false )
+                            AUTOCROP_LONGTEXT, false )
 
     add_integer_with_range( CFG_PREFIX "autocrop-ratio-max", 2405, 0, RATIO_MAX,
                             RATIOMAX_TEXT, RATIOMAX_LONGTEXT, true )
 
-    add_integer_with_range( CFG_PREFIX "crop-ratio", 0, 0, RATIO_MAX, RATIO_TEXT,
+    add_integer_with_range( CFG_PREFIX "autocrop-ratio", 0, 0, RATIO_MAX, RATIO_TEXT,
                             RATIO_LONGTEXT, false )
     add_integer( CFG_PREFIX "autocrop-time", 50, TIME_TEXT,
-                 TIME_LONGTEXT, true )
+                            TIME_LONGTEXT, true )
     add_integer( CFG_PREFIX "autocrop-diff", 8, DIFF_TEXT,
-                                            DIFF_LONGTEXT, true )
+                            DIFF_LONGTEXT, true )
 
     add_integer( CFG_PREFIX "autocrop-non-black-pixels", 3,
-                 NBP_TEXT, NBP_LONGTEXT, true )
+                            NBP_TEXT, NBP_LONGTEXT, true )
 
     add_integer_with_range( CFG_PREFIX "autocrop-skip-percent", 30, 0, 100,
                             SKIP_TEXT, SKIP_LONGTEXT, true )
@@ -142,7 +140,7 @@ vlc_module_begin ()
 vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
-    "autocrop-enabled", "autocrop-ratio-max", "crop-ratio", "autocrop-time", "autocrop-diff", "autocrop-non-black-pixels", "autocrop-skip-percent", "autocrop-luminance-threshold", "autocrop-seconds", "autocrop-slow-change",
+    "autocrop-enabled", "autocrop-ratio-max", "autocrop-ratio", "autocrop-time", "autocrop-diff", "autocrop-non-black-pixels", "autocrop-skip-percent", "autocrop-luminance-threshold", "autocrop-seconds", "autocrop-slow-change",
     NULL
 };
 
@@ -275,8 +273,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
     filter_sys_t *p_sys = p_filter->p_sys;
     picture_t *p_outpic;
     int i_plane;
-    int i_width, i_height,
-        i_outwidth, i_outheight;
+    int i_width, i_height, i_outwidth, i_outheight;
 
     if( !p_pic ) return NULL;
 
@@ -293,25 +290,32 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
         msg_Info( p_filter, "ratio %d (raw:%d) num %d den %d",  p_sys->i_aspect / 432,  p_sys->i_aspect,
             p_filter->fmt_out.video.i_sar_num,
             p_filter->fmt_out.video.i_sar_den );
-		p_sys->i_lastchange = 0;
-
-        int top = var_GetInteger( (vlc_object_t*)p_filter->p_owner, "crop-top" );
-        int bottom = var_GetInteger( (vlc_object_t*)p_filter->p_owner, "crop-bottom" );
-        int direction = p_sys->i_y-top;
-        if( p_sys->b_slowchange && direction )  top += direction / abs( direction ) * 2;
-        else                                    top += direction;
-        if( abs( top-p_sys->i_y ) < 2 )	        top = p_sys->i_y;
-        int newbottom=p_filter->fmt_in.video.i_height-(p_sys->i_height+p_sys->i_y);
-        direction=newbottom-bottom;
-        if( p_sys->b_slowchange && direction )  bottom += direction / abs( direction ) * 2;
-        else                                    bottom += direction;
-        if( abs( bottom - newbottom ) < 2 )     bottom = newbottom;
+        p_sys->i_lastchange = 0;
+
+        int top, bottom, newbottom, direction;
+        top = var_GetInteger( (vlc_object_t*)p_filter->p_owner, "crop-top" );
+        bottom = var_GetInteger( (vlc_object_t*)p_filter->p_owner, "crop-bottom" );
+        direction = p_sys->i_y-top;
+        if( p_sys->b_slowchange && direction )
+            top += direction / abs( direction ) * 2;
+        else
+            top += direction;
+        if( abs( top-p_sys->i_y ) < 2 )
+            top = p_sys->i_y;
+        newbottom = p_filter->fmt_in.video.i_height - ( p_sys->i_height + p_sys->i_y );
+        direction = newbottom - bottom;
+        if( p_sys->b_slowchange && direction )
+            bottom += direction / abs( direction ) * 2;
+        else
+            bottom += direction;
+        if( abs( bottom - newbottom ) < 2 )
+            bottom = newbottom;
         if( top == p_sys->i_y && bottom == newbottom )
             p_sys->b_changed = false;
         /* apply new crop */
         var_SetInteger( (vlc_object_t*)p_filter->p_owner, "crop-top", top );
         var_SetInteger( (vlc_object_t*)p_filter->p_owner, "crop-bottom", bottom );
-	}
+    }
 
     p_filter->fmt_out.video.i_height =
     p_filter->fmt_out.video.i_visible_height =
@@ -333,11 +337,11 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
     /* p_pic and p_outpic have the same chroma/number of planes but that's
      * about it. */
     {
-        plane_t *p_plane = p_pic->p+i_plane;
+        plane_t *p_plane    = p_pic->p+i_plane;
         plane_t *p_outplane = p_outpic->p+i_plane;
-        uint8_t *p_in = p_plane->p_pixels;
-        uint8_t *p_out = p_outplane->p_pixels;
-        int i_pixel_pitch = p_plane->i_pixel_pitch;
+        uint8_t *p_in       = p_plane->p_pixels;
+        uint8_t *p_out      = p_outplane->p_pixels;
+        int i_pixel_pitch   = p_plane->i_pixel_pitch;
 
         /* These assignments assume that the first plane always has
          * a width and height equal to the picture's */
@@ -443,7 +447,7 @@ static void UpdateStats( filter_t *p_filter, picture_t *p_pic )
                              p_sys->i_skipPercent,
                              p_sys->i_nonBlackPixel,
                              p_pic->format.i_chroma)
-						||
+                  ||
                 NonBlackLine(p_in, i_lines-i, i_pitch, i_visible_pitch, i_lines,
                              p_sys->i_threshold,
                              p_sys->i_skipPercent,
@@ -617,3 +621,4 @@ static bool NonBlackLine(uint8_t *p_in, int i_line, int i_pitch,
     return (i_count > i_nonBlackPixel);
 }
 
+
-- 
1.7.5.4




More information about the vlc-devel mailing list