]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/invert.c
* ALL: use i_visible_lines in plane_t.
[vlc] / modules / video_filter / invert.c
index 99c5f34012d91f94d6d274fbc1b86c8ae1fcdb49..5c10f778db22a11ac2a933483768ae711fb60801 100644 (file)
@@ -2,7 +2,7 @@
  * invert.c : Invert video plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000, 2001, 2002, 2003 VideoLAN
- * $Id: invert.c,v 1.5 2003/01/17 16:18:03 sam Exp $
+ * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -49,7 +49,7 @@ static int  SendEvents( vlc_object_t *, char const *,
  * Module descriptor
  *****************************************************************************/
 vlc_module_begin();
-    set_description( _("invert video module") );
+    set_description( _("Invert video filter") );
     set_capability( "video filter", 0 );
     add_shortcut( "invert" );
     set_callbacks( Create, Destroy );
@@ -66,6 +66,14 @@ struct vout_sys_t
     vout_thread_t *p_vout;
 };
 
+/*****************************************************************************
+ * 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 Invert video thread output method
  *****************************************************************************
@@ -88,6 +96,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;
 
     return VLC_SUCCESS;
 }
@@ -127,6 +136,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;
 }
 
@@ -154,8 +165,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 );
 }
@@ -191,28 +208,31 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
         uint8_t *p_in, *p_in_end, *p_line_end, *p_out;
 
         p_in = p_pic->p[i_index].p_pixels;
-        p_in_end = p_in + p_pic->p[i_index].i_lines
+        p_in_end = p_in + p_pic->p[i_index].i_visible_lines
                            * p_pic->p[i_index].i_pitch;
 
         p_out = p_outpic->p[i_index].p_pixels;
 
         for( ; p_in < p_in_end ; )
         {
+            uint64_t *p_in64, *p_out64;
+
             p_line_end = p_in + p_pic->p[i_index].i_visible_pitch - 64;
 
-            for( ; p_in < p_line_end ; )
+            p_in64 = (uint64_t*)p_in;
+            p_out64 = (uint64_t*)p_out;
+
+            for( ; (ptrdiff_t)p_in64 < (ptrdiff_t)p_line_end ; )
             {
                 /* Do 64 pixels at a time */
-                *((uint64_t*)p_out)++ = ~( *((uint64_t*)p_in)++ );
-                *((uint64_t*)p_out)++ = ~( *((uint64_t*)p_in)++ );
-                *((uint64_t*)p_out)++ = ~( *((uint64_t*)p_in)++ );
-                *((uint64_t*)p_out)++ = ~( *((uint64_t*)p_in)++ );
-                *((uint64_t*)p_out)++ = ~( *((uint64_t*)p_in)++ );
-                *((uint64_t*)p_out)++ = ~( *((uint64_t*)p_in)++ );
-                *((uint64_t*)p_out)++ = ~( *((uint64_t*)p_in)++ );
-                *((uint64_t*)p_out)++ = ~( *((uint64_t*)p_in)++ );
+                *p_out64++ = ~*p_in64++; *p_out64++ = ~*p_in64++;
+                *p_out64++ = ~*p_in64++; *p_out64++ = ~*p_in64++;
+                *p_out64++ = ~*p_in64++; *p_out64++ = ~*p_in64++;
+                *p_out64++ = ~*p_in64++; *p_out64++ = ~*p_in64++;
             }
 
+            p_in = (uint8_t*)p_in64;
+            p_out = (uint8_t*)p_out64;
             p_line_end += 64;
 
             for( ; p_in < p_line_end ; )
@@ -243,3 +263,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;
+}