]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/invert.c
Fix a bug with preferences
[vlc] / modules / video_filter / invert.c
index 189728dabac27505b14ff19ef928d6dde109caa4..8fcbe6ced655f22f154b720ed9219846b04262cb 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.9 2004/01/25 03:28:41 hartman Exp $
+ * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -50,6 +50,9 @@ static int  SendEvents( vlc_object_t *, char const *,
  *****************************************************************************/
 vlc_module_begin();
     set_description( _("Invert video filter") );
+    set_shortname( N_("Color inversion" ));
+    set_category( CAT_VIDEO );
+    set_subcategory( SUBCAT_VIDEO_VFILTER );
     set_capability( "video filter", 0 );
     add_shortcut( "invert" );
     set_callbacks( Create, Destroy );
@@ -66,6 +69,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 +99,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;
 }
@@ -156,9 +168,12 @@ 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 );
-    vlc_object_detach( p_vout->p_sys->p_vout );
-    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 );
 
@@ -196,28 +211,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 ; )