]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/invert.c
Qt4: compressor and Spatializer widget margin shouldn't be 0
[vlc] / modules / video_filter / invert.c
index 2cc54ad0291fe8718e72bb05098671850b2b7b19..33b2884e08b8495d788fff7e0d49de624d70d09a 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>
 
-#include <vlc/vlc.h>
-#include <vlc_vout.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
-#include "vlc_filter.h"
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+
+#include <vlc_filter.h>
+#include "filter_picture.h"
 
 /*****************************************************************************
  * Local prototypes
@@ -43,25 +46,15 @@ static picture_t *Filter( filter_t *, picture_t * );
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-vlc_module_begin();
-    set_description( _("Invert video filter") );
-    set_shortname( _("Color inversion" ));
-    set_category( CAT_VIDEO );
-    set_subcategory( SUBCAT_VIDEO_VFILTER );
-    set_capability( "video filter2", 0 );
-    add_shortcut( "invert" );
-    set_callbacks( Create, Destroy );
-vlc_module_end();
-
-/*****************************************************************************
- * vout_sys_t: Invert video output method descriptor
- *****************************************************************************
- * This structure is part of the video output thread descriptor.
- * It describes the Invert specific properties of an output thread.
- *****************************************************************************/
-struct filter_sys_t
-{
-};
+vlc_module_begin ()
+    set_description( N_("Invert video filter") )
+    set_shortname( N_("Color inversion" ))
+    set_category( CAT_VIDEO )
+    set_subcategory( SUBCAT_VIDEO_VFILTER )
+    set_capability( "video filter2", 0 )
+    add_shortcut( "invert" )
+    set_callbacks( Create, Destroy )
+vlc_module_end ()
 
 /*****************************************************************************
  * Create: allocates Invert video thread output method
@@ -72,14 +65,6 @@ static int Create( vlc_object_t *p_this )
 {
     filter_t *p_filter = (filter_t *)p_this;
 
-    /* Allocate structure */
-    p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
-    if( p_filter->p_sys == NULL )
-    {
-        msg_Err( p_filter, "out of memory" );
-        return VLC_ENOMEM;
-    }
-
     p_filter->pf_video_filter = Filter;
 
     return VLC_SUCCESS;
@@ -92,9 +77,7 @@ static int Create( vlc_object_t *p_this )
  *****************************************************************************/
 static void Destroy( vlc_object_t *p_this )
 {
-    filter_t *p_filter = (filter_t *)p_this;
-
-    free( p_filter->p_sys );
+    (void)p_this;
 }
 
 /*****************************************************************************
@@ -108,19 +91,32 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
 {
     picture_t *p_outpic;
     int i_index;
+    int i_planes;
 
     if( !p_pic ) return NULL;
 
-    p_outpic = p_filter->pf_vout_buffer_new( p_filter );
+    p_outpic = filter_NewPicture( p_filter );
     if( !p_outpic )
     {
         msg_Warn( p_filter, "can't get output picture" );
-        if( p_pic->pf_release )
-            p_pic->pf_release( p_pic );
+        picture_Release( p_pic );
         return NULL;
     }
 
-    for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ )
+    if( p_pic->format.i_chroma == VLC_CODEC_YUVA )
+    {
+        /* We don't want to invert the alpha plane */
+        i_planes = p_pic->i_planes - 1;
+        vlc_memcpy(
+            p_outpic->p[A_PLANE].p_pixels, p_pic->p[A_PLANE].p_pixels,
+            p_pic->p[A_PLANE].i_pitch *  p_pic->p[A_PLANE].i_lines );
+    }
+    else
+    {
+        i_planes = p_pic->i_planes;
+    }
+
+    for( i_index = 0 ; i_index < i_planes ; i_index++ )
     {
         uint8_t *p_in, *p_in_end, *p_line_end, *p_out;
 
@@ -139,7 +135,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
             p_in64 = (uint64_t*)p_in;
             p_out64 = (uint64_t*)p_out;
 
-            for( ; (ptrdiff_t)p_in64 < (ptrdiff_t)p_line_end ; )
+            while( p_in64 < (uint64_t *)p_line_end )
             {
                 /* Do 64 pixels at a time */
                 *p_out64++ = ~*p_in64++; *p_out64++ = ~*p_in64++;
@@ -164,14 +160,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
         }
     }
 
-    p_outpic->date = p_pic->date;
-    p_outpic->b_force = p_pic->b_force;
-    p_outpic->i_nb_fields = p_pic->i_nb_fields;
-    p_outpic->b_progressive = p_pic->b_progressive;
-    p_outpic->b_top_field_first = p_pic->b_top_field_first;
-
-    if( p_pic->pf_release )
-        p_pic->pf_release( p_pic );
-
-    return p_outpic;
+    return CopyInfoAndRelease( p_outpic, p_pic );
 }