]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/motionblur.c
* modules/video_filter/*: use p_vout->fmt_in/out.
[vlc] / modules / video_filter / motionblur.c
index 665088d1307505f5caa6a84afab28aa29e122a3c..df36717c5223d09471ebec95e901d8e4db13546d 100644 (file)
@@ -1,10 +1,10 @@
 /*****************************************************************************
  * motion_blur.c : motion blur filter for vlc
  *****************************************************************************
- * Copyright (C) 2000, 2001, 2002, 2003 VideoLAN
- * $Id: motionblur.c,v 1.7 2003/01/28 22:03:21 sam Exp $
+ * Copyright (C) 2000, 2001, 2002, 2003 the VideoLAN team
+ * $Id$
  *
- * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
+ * Authors: Sigmund Augdal Helberg <dnumgis@videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -51,14 +51,19 @@ static int  SendEvents( vlc_object_t *, char const *,
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-#define MODE_TEXT N_("blur factor")
-#define MODE_LONGTEXT N_("The degree of blurring from 1 to 127")
+#define MODE_TEXT N_("Blur factor (1-127)")
+#define MODE_LONGTEXT N_("The degree of blurring from 1 to 127.")
 
 vlc_module_begin();
-    add_category_hint( N_("Miscellaneous"), NULL );
-    add_integer( "blur-factor", 80, NULL, MODE_TEXT, MODE_LONGTEXT );
+    set_shortname( _("Motion blur") );
     set_description( _("Motion blur filter") );
     set_capability( "video filter", 0 );
+    set_category( CAT_VIDEO );
+    set_subcategory( SUBCAT_VIDEO_VFILTER );
+
+    add_integer_with_range( "blur-factor", 80, 1, 127, NULL,
+        MODE_TEXT, MODE_LONGTEXT, VLC_FALSE );
+    
     set_callbacks( Create, Destroy );
 vlc_module_end();
 
@@ -80,6 +85,14 @@ struct vout_sys_t
     picture_t *p_lastpic;
 };
 
+/*****************************************************************************
+ * 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 Deinterlace video thread output method
  *****************************************************************************
@@ -102,6 +115,7 @@ static int Create( vlc_object_t *p_this )
     p_vout->pf_manage = NULL;
     p_vout->pf_render = Render;
     p_vout->pf_display = NULL;
+    p_vout->pf_control = Control;
 
     p_vout->p_sys->i_factor = config_GetInt( p_vout, "blur-factor" );
     p_vout->p_sys->b_double_rate = 0;
@@ -118,6 +132,7 @@ static int Init( vout_thread_t *p_vout )
 {
     int i_index;
     picture_t *p_pic;
+    video_format_t fmt = {0};
 
     I_OUTPUTPICTURES = 0;
 
@@ -133,6 +148,8 @@ static int Init( vout_thread_t *p_vout )
             p_vout->output.i_width  = p_vout->render.i_width;
             p_vout->output.i_height = p_vout->render.i_height;
             p_vout->output.i_aspect = p_vout->render.i_aspect;
+            p_vout->fmt_out = p_vout->fmt_in;
+            fmt = p_vout->fmt_out;
             break;
 
         default:
@@ -147,9 +164,7 @@ static int Init( vout_thread_t *p_vout )
     case VLC_FOURCC('I','4','2','0'):
     case VLC_FOURCC('I','Y','U','V'):
     case VLC_FOURCC('Y','V','1','2'):
-        p_vout->p_sys->p_vout = vout_Create( p_vout,
-                           p_vout->output.i_width, p_vout->output.i_height,
-                           p_vout->output.i_chroma, p_vout->output.i_aspect );
+        p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
         break;
     default:
         break;
@@ -167,6 +182,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;
 }
 
@@ -194,8 +211,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 );
 }
@@ -274,7 +297,7 @@ static void CopyPicture( vout_thread_t * p_vout,
             /* There are margins, but with the same width : perfect ! */
             p_vout->p_vlc->pf_memcpy(
                          p_dest->p[i].p_pixels, p_src->p[i].p_pixels,
-                         p_src->p[i].i_pitch * p_src->p[i].i_lines );
+                         p_src->p[i].i_pitch * p_src->p[i].i_visible_lines );
         }
         else
         {
@@ -283,7 +306,7 @@ static void CopyPicture( vout_thread_t * p_vout,
             uint8_t *p_out = p_dest->p[i].p_pixels;
             int i_line;
 
-            for( i_line = p_src->p[i].i_lines; i_line--; )
+            for( i_line = p_src->p[i].i_visible_lines; i_line--; )
             {
                 p_vout->p_vlc->pf_memcpy( p_out, p_in,
                                           p_src->p[i].i_visible_pitch );
@@ -310,7 +333,7 @@ static void RenderBlur( vout_thread_t *p_vout, picture_t *p_oldpic,
         p_new = p_newpic->p[i_plane].p_pixels;
         p_old = p_oldpic->p[i_plane].p_pixels;
         p_out_end = p_out + p_outpic->p[i_plane].i_pitch *
-                             p_outpic->p[i_plane].i_lines;
+                             p_outpic->p[i_plane].i_visible_lines;
         while ( p_out < p_out_end )
         {
             p_out_line_end = p_out + p_outpic->p[i_plane].i_visible_pitch;
@@ -344,3 +367,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;
+}