]> git.sesse.net Git - vlc/blobdiff - plugins/filter/invert.c
* ./plugins/lirc/lirc.c: non-blocking patch from Sigmund Augdal
[vlc] / plugins / filter / invert.c
index 9b59796e74a50c108d1fd4ecfc061863c6f5f7de..ace5419e81f044a1de21b9787d0259ac83310d09 100644 (file)
@@ -2,7 +2,7 @@
  * invert.c : Invert video plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: invert.c,v 1.2 2001/12/19 03:50:22 sam Exp $
+ * $Id: invert.c,v 1.7 2002/02/15 13:32:53 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#define MODULE_NAME filter_invert
-#include "modules_inner.h"
-
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "defs.h"
-
 #include <errno.h>
 #include <stdlib.h>                                      /* malloc(), free() */
 #include <string.h>
 
-#include "common.h"                                     /* boolean_t, byte_t */
-#include "intf_msg.h"
-#include "threads.h"
-#include "mtime.h"
-#include "tests.h"
+#include <videolan/vlc.h>
 
 #include "video.h"
 #include "video_output.h"
 
 #include "filter_common.h"
 
-#include "modules.h"
-#include "modules_export.h"
-
 /*****************************************************************************
  * Capabilities defined in the other files.
  *****************************************************************************/
@@ -56,14 +44,14 @@ static void vout_getfunctions( function_list_t * p_function_list );
  * Build configuration tree.
  *****************************************************************************/
 MODULE_CONFIG_START
-ADD_WINDOW( "Configuration for Invert module" )
-    ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
 MODULE_CONFIG_STOP
 
 MODULE_INIT_START
-    p_module->i_capabilities = MODULE_CAPABILITY_NULL
-                                | MODULE_CAPABILITY_VOUT;
-    p_module->psz_longname = "invert video module";
+    SET_DESCRIPTION( "invert video module" )
+    /* Capability score set to 0 because we don't want to be spawned
+     * as a video output unless explicitly requested to */
+    ADD_CAPABILITY( VOUT, 0 )
+    ADD_SHORTCUT( "invert" )
 MODULE_INIT_STOP
 
 MODULE_ACTIVATE_START
@@ -88,12 +76,12 @@ typedef struct vout_sys_s
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int  vout_Probe     ( probedata_t *p_data );
 static int  vout_Create    ( struct vout_thread_s * );
 static int  vout_Init      ( struct vout_thread_s * );
 static void vout_End       ( struct vout_thread_s * );
 static void vout_Destroy   ( struct vout_thread_s * );
 static int  vout_Manage    ( struct vout_thread_s * );
+static void vout_Render    ( struct vout_thread_s *, struct picture_s * );
 static void vout_Display   ( struct vout_thread_s *, struct picture_s * );
 
 /*****************************************************************************
@@ -102,28 +90,13 @@ static void vout_Display   ( struct vout_thread_s *, struct picture_s * );
  *****************************************************************************/
 static void vout_getfunctions( function_list_t * p_function_list )
 {
-    p_function_list->pf_probe = vout_Probe;
     p_function_list->functions.vout.pf_create     = vout_Create;
     p_function_list->functions.vout.pf_init       = vout_Init;
     p_function_list->functions.vout.pf_end        = vout_End;
     p_function_list->functions.vout.pf_destroy    = vout_Destroy;
     p_function_list->functions.vout.pf_manage     = vout_Manage;
+    p_function_list->functions.vout.pf_render     = vout_Render;
     p_function_list->functions.vout.pf_display    = vout_Display;
-    p_function_list->functions.vout.pf_setpalette = NULL;
-}
-
-/*****************************************************************************
- * intf_Probe: return a score
- *****************************************************************************/
-static int vout_Probe( probedata_t *p_data )
-{
-    if( TestMethod( VOUT_FILTER_VAR, "invert" ) )
-    {
-        return( 999 );
-    }
-
-    /* If we weren't asked to filter, don't filter. */
-    return( 0 );
 }
 
 /*****************************************************************************
@@ -156,19 +129,10 @@ static int vout_Init( vout_thread_t *p_vout )
     I_OUTPUTPICTURES = 0;
 
     /* Initialize the output structure */
-    switch( p_vout->render.i_chroma )
-    {
-        case YUV_420_PICTURE:
-            p_vout->output.i_chroma = p_vout->render.i_chroma;
-            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;
-            break;
-
-        default:
-            return( 0 ); /* unknown chroma */
-            break;
-    }
+    p_vout->output.i_chroma = p_vout->render.i_chroma;
+    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;
 
     /* Try to open the real video output */
     psz_filter = main_GetPszVariable( VOUT_FILTER_VAR, "" );
@@ -207,7 +171,7 @@ static void vout_End( vout_thread_t *p_vout )
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
         i_index--;
-        free( PP_OUTPUTPICTURE[ i_index ]->planes[ 0 ].p_data );
+        free( PP_OUTPUTPICTURE[ i_index ]->p_data );
     }
 }
 
@@ -235,13 +199,13 @@ static int vout_Manage( vout_thread_t *p_vout )
 }
 
 /*****************************************************************************
- * vout_Display: displays previously rendered output
+ * vout_Render: displays previously rendered output
  *****************************************************************************
  * This function send the currently rendered image to Invert image, waits
  * until it is displayed and switch the two rendering buffers, preparing next
  * frame.
  *****************************************************************************/
-static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
+static void vout_Render( vout_thread_t *p_vout, picture_t *p_pic )
 {
     picture_t *p_outpic;
     int i_index;
@@ -257,17 +221,18 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
         msleep( VOUT_OUTMEM_SLEEP );
     }   
 
-    vout_DatePicture( p_vout->p_sys->p_vout, p_outpic, mdate() + 50000 );
+    vout_DatePicture( p_vout->p_sys->p_vout, p_outpic, p_pic->date );
     vout_LinkPicture( p_vout->p_sys->p_vout, p_outpic );
 
     for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ )
     {
-        pixel_data_t *p_in, *p_in_end, *p_out;
+        u8 *p_in, *p_in_end, *p_out;
 
-        p_in = p_pic->planes[ i_index ].p_data;
-        p_in_end = p_in + p_pic->planes[ i_index ].i_bytes - 64;
+        p_in = p_pic->p[i_index].p_pixels;
+        p_in_end = p_in - 64 + p_pic->p[i_index].i_lines
+                                * p_pic->p[i_index].i_pitch;
 
-        p_out = p_outpic->planes[ i_index ].p_data;
+        p_out = p_outpic->p[i_index].p_pixels;
 
         for( ; p_in < p_in_end ; )
         {
@@ -296,3 +261,15 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
     vout_DisplayPicture( p_vout->p_sys->p_vout, p_outpic );
 }
 
+/*****************************************************************************
+ * vout_Display: displays previously rendered output
+ *****************************************************************************
+ * This function send the currently rendered image to Invert image, waits
+ * until it is displayed and switch the two rendering buffers, preparing next
+ * frame.
+ *****************************************************************************/
+static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
+{
+    ;
+}
+