]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/crop.c
* modules/demux/mkv.cpp: compilation fixes.
[vlc] / modules / video_filter / crop.c
index 8e61671a8da1052631fc9cdb9f5ddbfd875cab78..5e341962034f584694a83f055ec30253f0a5b3de 100644 (file)
@@ -2,7 +2,7 @@
  * crop.c : Crop video plugin for vlc
  *****************************************************************************
  * Copyright (C) 2002, 2003 VideoLAN
- * $Id: crop.c,v 1.7 2003/01/17 16:18:03 sam Exp $
+ * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -51,18 +51,22 @@ static int  SendEvents( vlc_object_t *, char const *,
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-#define GEOMETRY_TEXT N_("crop geometry")
-#define GEOMETRY_LONGTEXT N_("Set the geometry of the zone to crop")
+#define GEOMETRY_TEXT N_("Crop geometry (pixels)")
+#define GEOMETRY_LONGTEXT N_("Set the geometry of the zone to crop. This is set as <width> x <height> + <left offset> + <top offset>.")
 
-#define AUTOCROP_TEXT N_("automatic cropping")
-#define AUTOCROP_LONGTEXT N_("Activate automatic black border cropping")
+#define AUTOCROP_TEXT N_("Automatic cropping")
+#define AUTOCROP_LONGTEXT N_("Activate automatic black border cropping.")
 
 vlc_module_begin();
-    add_category_hint( N_("Miscellaneous"), NULL );
-    add_string( "crop-geometry", NULL, NULL, GEOMETRY_TEXT, GEOMETRY_LONGTEXT );
-    add_bool( "autocrop", 0, NULL, AUTOCROP_TEXT, AUTOCROP_LONGTEXT );
-    set_description( _("image crop video module") );
+    set_description( _("Crop video filter") );
+    set_shortname( N_("Crop" ));
+    set_category( CAT_VIDEO );
+    set_subcategory( SUBCAT_VIDEO_VFILTER );
     set_capability( "video filter", 0 );
+
+    add_string( "crop-geometry", NULL, NULL, GEOMETRY_TEXT, GEOMETRY_LONGTEXT, VLC_FALSE );
+    add_bool( "autocrop", 0, NULL, AUTOCROP_TEXT, AUTOCROP_LONGTEXT, VLC_FALSE );
+
     add_shortcut( "crop" );
     set_callbacks( Create, Destroy );
 vlc_module_end();
@@ -87,6 +91,14 @@ struct vout_sys_t
     vlc_bool_t   b_changed;
 };
 
+/*****************************************************************************
+ * Control: control facility for the vout (forwards to child vout)
+ *****************************************************************************/
+static int Control( vout_thread_t *p_vout, int i_query, va_list args )
+{
+    return vout_vaControl( p_vout->p_sys->p_vout, i_query, args );
+}
+
 /*****************************************************************************
  * Create: allocates Crop video thread output method
  *****************************************************************************
@@ -109,6 +121,7 @@ static int Create( vlc_object_t *p_this )
     p_vout->pf_manage = Manage;
     p_vout->pf_render = Render;
     p_vout->pf_display = NULL;
+    p_vout->pf_control = Control;
 
     return VLC_SUCCESS;
 }
@@ -248,6 +261,8 @@ static int Init( vout_thread_t *p_vout )
 
     ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
 
+    ADD_PARENT_CALLBACKS( SendEventsToChild );
+
     return VLC_SUCCESS;
 }
 
@@ -275,8 +290,14 @@ static void Destroy( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
-    DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-    vout_Destroy( p_vout->p_sys->p_vout );
+    if( p_vout->p_sys->p_vout )
+    {
+        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+        vlc_object_detach( p_vout->p_sys->p_vout );
+        vout_Destroy( p_vout->p_sys->p_vout );
+    }
+
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
 
     free( p_vout->p_sys );
 }
@@ -353,13 +374,13 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
 
         p_in = p_pic->p[i_plane].p_pixels
                 /* Skip the right amount of lines */
-                + i_in_pitch * ( p_pic->p[i_plane].i_lines * p_vout->p_sys->i_y
-                                  / p_vout->output.i_height )
+                + i_in_pitch * ( p_pic->p[i_plane].i_visible_lines *
+                                 p_vout->p_sys->i_y / p_vout->output.i_height )
                 /* Skip the right amount of columns */
                 + i_in_pitch * p_vout->p_sys->i_x / p_vout->output.i_width;
 
         p_out = p_outpic->p[i_plane].p_pixels;
-        p_out_end = p_out + i_out_pitch * p_outpic->p[i_plane].i_lines;
+        p_out_end = p_out + i_out_pitch * p_outpic->p[i_plane].i_visible_lines;
 
         while( p_out < p_out_end )
         {
@@ -384,7 +405,7 @@ static void UpdateStats( vout_thread_t *p_vout, picture_t *p_pic )
     uint8_t *p_in = p_pic->p[0].p_pixels;
     int i_pitch = p_pic->p[0].i_pitch;
     int i_visible_pitch = p_pic->p[0].i_visible_pitch;
-    int i_lines = p_pic->p[0].i_lines;
+    int i_lines = p_pic->p[0].i_visible_lines;
     int i_firstwhite = -1, i_lastwhite = -1, i;
 
     /* Determine where black borders are */
@@ -491,3 +512,13 @@ static int SendEvents( vlc_object_t *p_this, char const *psz_var,
     return VLC_SUCCESS;
 }
 
+/*****************************************************************************
+ * SendEventsToChild: forward events to the child/children vout
+ *****************************************************************************/
+static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var,
+                       vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+    vout_thread_t *p_vout = (vout_thread_t *)p_this;
+    var_Set( p_vout->p_sys->p_vout, psz_var, newval );
+    return VLC_SUCCESS;
+}