]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/crop.c
filter_t: use struct of non-anymous unions, seems more portable
[vlc] / modules / video_filter / crop.c
index 286ce642c80ea03a7d3d1d72fc5c0f232d1847db..fe89d9ec844176b1285eec6189746d4f85468174 100644 (file)
@@ -76,6 +76,8 @@ static int FilterCallback ( vlc_object_t *, char const *,
 #define AUTOCROP_TEXT N_("Automatic cropping")
 #define AUTOCROP_LONGTEXT N_("Automatically detect black borders and crop them.")
 
+#define CROP_HELP N_("Remove borders of the video and replace them by black borders")
+
 #ifdef BEST_AUTOCROP
 #define RATIOMAX_TEXT N_("Ratio max (x 1000)")
 #define RATIOMAX_LONGTEXT N_("Maximum image ratio. The crop plugin will never automatically crop to a higher ratio (ie, to a more \"flat\" image). The value is x1000: 1333 means 4/3.")
@@ -103,13 +105,14 @@ static int FilterCallback ( vlc_object_t *, char const *,
 vlc_module_begin ()
     set_description( N_("Crop video filter") )
     set_shortname( N_("Crop" ))
+    set_help(CROP_HELP)
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_VFILTER )
     set_capability( "video filter", 0 )
 
     add_string( "crop-geometry", NULL, NULL, GEOMETRY_TEXT,
                                              GEOMETRY_LONGTEXT, false )
-    add_bool( "autocrop", 0, NULL, AUTOCROP_TEXT,
+    add_bool( "autocrop", false, NULL, AUTOCROP_TEXT,
                                    AUTOCROP_LONGTEXT, false )
 
 #ifdef BEST_AUTOCROP
@@ -351,9 +354,9 @@ static int Init( vout_thread_t *p_vout )
                      p_vout->p_sys->i_x, p_vout->p_sys->i_y,
                      p_vout->p_sys->b_autocrop ? "" : "not " );
     /* Set current output image properties */
-    p_vout->p_sys->i_aspect = p_vout->fmt_out.i_aspect
-           * p_vout->fmt_out.i_visible_height / p_vout->p_sys->i_height
-           * p_vout->p_sys->i_width / p_vout->fmt_out.i_visible_width;
+    p_vout->p_sys->i_aspect = (int64_t)VOUT_ASPECT_FACTOR *
+        p_vout->fmt_out.i_sar_num * p_vout->p_sys->i_width /
+        (p_vout->fmt_out.i_sar_den * p_vout->p_sys->i_height);
 
 #ifdef BEST_AUTOCROP
     msg_Info( p_vout, "ratio %d",  p_vout->p_sys->i_aspect / 432);
@@ -362,22 +365,21 @@ static int Init( vout_thread_t *p_vout )
     fmt.i_height = fmt.i_visible_height = p_vout->p_sys->i_height;
     fmt.i_x_offset = fmt.i_y_offset = 0;
     fmt.i_chroma = p_vout->render.i_chroma;
-    fmt.i_aspect = p_vout->p_sys->i_aspect;
-    fmt.i_sar_num = p_vout->p_sys->i_aspect * fmt.i_height / fmt.i_width;
-    fmt.i_sar_den = VOUT_ASPECT_FACTOR;
+    fmt.i_sar_num = p_vout->p_sys->i_aspect * fmt.i_height;
+    fmt.i_sar_den = VOUT_ASPECT_FACTOR * fmt.i_width;
 
     /* Try to open the real video output */
     p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
     if( p_vout->p_sys->p_vout == NULL )
     {
         msg_Err( p_vout, "failed to create vout" );
-        dialog_Fatal( p_vout, _("Cropping failed"),
+        dialog_Fatal( p_vout, _("Cropping failed"), "%s",
                         _("VLC could not open the video output module.") );
         return VLC_EGENERIC;
     }
 
-#ifdef BEST_AUTOCROP
     vlc_mutex_init( &p_vout->p_sys->lock );
+#ifdef BEST_AUTOCROP
     var_AddCallback( p_vout, "ratio-crop", FilterCallback, NULL );
 #endif
 
@@ -455,7 +457,6 @@ static int Manage( vout_thread_t *p_vout )
     fmt.i_height = fmt.i_visible_height = p_vout->p_sys->i_height;
     fmt.i_x_offset = fmt.i_y_offset = 0;
     fmt.i_chroma = p_vout->render.i_chroma;
-    fmt.i_aspect = p_vout->p_sys->i_aspect;
     fmt.i_sar_num = p_vout->p_sys->i_aspect * fmt.i_height / fmt.i_width;
     fmt.i_sar_den = VOUT_ASPECT_FACTOR;
 
@@ -463,7 +464,7 @@ static int Manage( vout_thread_t *p_vout )
     if( p_vout->p_sys->p_vout == NULL )
     {
         msg_Err( p_vout, "failed to create vout" );
-        dialog_Fatal( p_vout, _("Cropping failed"),
+        dialog_Fatal( p_vout, _("Cropping failed"), "%s",
                         _("VLC could not open the video output module.") );
         return VLC_EGENERIC;
     }