]> git.sesse.net Git - vlc/blobdiff - plugins/filter/distort.c
* ./src/libvlc.c: p_vlc->pf_memset is now usable (it's always the libc
[vlc] / plugins / filter / distort.c
index caebb9bb4c8bdc0e9e1e83e26c9288b23ea567af..db1274e4ed5ee99147cc39765e5df9e5ff79c524 100644 (file)
@@ -2,7 +2,7 @@
  * distort.c : Misc video effects plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: distort.c,v 1.14 2002/06/01 12:31:59 sam Exp $
+ * $Id: distort.c,v 1.19 2002/07/31 20:56:51 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
 #define DISTORT_MODE_RIPPLE  2
 
 /*****************************************************************************
- * Capabilities defined in the other files.
+ * Local prototypes
  *****************************************************************************/
-static void vout_getfunctions( function_list_t * p_function_list );
+static int  Create    ( vlc_object_t * );
+static void Destroy   ( vlc_object_t * );
+
+static int  Init      ( vout_thread_t * );
+static void End       ( vout_thread_t * );
+static void Render    ( vout_thread_t *, picture_t * );
+
+static void DistortWave    ( vout_thread_t *, picture_t *, picture_t * );
+static void DistortRipple  ( vout_thread_t *, picture_t *, picture_t * );
 
 /*****************************************************************************
- * Build configuration tree.
+ * Module descriptor
  *****************************************************************************/
-MODULE_CONFIG_START
-ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
-ADD_STRING  ( "distort-mode", "wave", NULL, N_("distort mode"),
-              N_("one of \"wave\" and \"ripple\"") )
-MODULE_CONFIG_STOP
-
-MODULE_INIT_START
-    SET_DESCRIPTION( _("miscellaneous video effects 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( "distort" )
-MODULE_INIT_STOP
-
-MODULE_ACTIVATE_START
-    vout_getfunctions( &p_module->p_functions->vout );
-MODULE_ACTIVATE_STOP
-
-MODULE_DEACTIVATE_START
-MODULE_DEACTIVATE_STOP
+#define MODE_TEXT N_("Distort mode")
+#define MODE_LONGTEXT N_("one of \"wave\" and \"ripple\"")
+
+static char *mode_list[] = { "wave", "ripple", NULL };
+
+vlc_module_begin();
+    add_category_hint( N_("Miscellaneous"), NULL );
+    add_string_from_list( "distort-mode", "wave", mode_list, NULL,
+                          MODE_TEXT, MODE_LONGTEXT );
+    set_description( _("miscellaneous video effects module") );
+    set_capability( "video filter", 0 );
+    add_shortcut( "distort" );
+    set_callbacks( Create, Destroy );
+vlc_module_end();
 
 /*****************************************************************************
  * vout_sys_t: Distort video output method descriptor
@@ -73,7 +75,7 @@ MODULE_DEACTIVATE_STOP
  * This structure is part of the video output thread descriptor.
  * It describes the Distort specific properties of an output thread.
  *****************************************************************************/
-struct vout_sys_s
+struct vout_sys_t
 {
     int i_mode;
     vout_thread_t *p_vout;
@@ -84,41 +86,13 @@ struct vout_sys_s
 };
 
 /*****************************************************************************
- * Local prototypes
- *****************************************************************************/
-static int  vout_Create    ( vout_thread_t * );
-static int  vout_Init      ( vout_thread_t * );
-static void vout_End       ( vout_thread_t * );
-static void vout_Destroy   ( vout_thread_t * );
-static int  vout_Manage    ( vout_thread_t * );
-static void vout_Render    ( vout_thread_t *, picture_t * );
-static void vout_Display   ( vout_thread_t *, picture_t * );
-
-static void DistortWave    ( vout_thread_t *, picture_t *, picture_t * );
-static void DistortRipple  ( vout_thread_t *, picture_t *, picture_t * );
-
-/*****************************************************************************
- * Functions exported as capabilities. They are declared as static so that
- * we don't pollute the namespace too much.
- *****************************************************************************/
-static void vout_getfunctions( function_list_t * p_function_list )
-{
-    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;
-}
-
-/*****************************************************************************
- * vout_Create: allocates Distort video thread output method
+ * Create: allocates Distort video thread output method
  *****************************************************************************
  * This function allocates and initializes a Distort vout method.
  *****************************************************************************/
-static int vout_Create( vout_thread_t *p_vout )
+static int Create( vlc_object_t *p_this )
 {
+    vout_thread_t *p_vout = (vout_thread_t *)p_this;
     char *psz_method, *psz_method_tmp;
 
     /* Allocate structure */
@@ -128,6 +102,13 @@ static int vout_Create( vout_thread_t *p_vout )
         msg_Err( p_vout, "out of memory" );
         return( 1 );
     }
+
+    p_vout->pf_init = Init;
+    p_vout->pf_end = End;
+    p_vout->pf_manage = NULL;
+    p_vout->pf_render = Render;
+    p_vout->pf_display = NULL;
+
     p_vout->p_sys->i_mode = 0;
     /* Look what method was requested from command line*/
     if( !(psz_method = psz_method_tmp = config_GetPsz( p_vout, "filter" )) )
@@ -154,10 +135,10 @@ static int vout_Create( vout_thread_t *p_vout )
         /* No method given in commandline. Look what method was
          requested in configuration system */
         if( !(psz_method = psz_method_tmp
-              = config_GetPsz( p_vout, "distort_mode" )) )
+              = config_GetPsz( p_vout, "distort-mode" )) )
         {
             msg_Err( p_vout, "configuration variable %s empty, using 'wave'",
-                             "distort_mode" );
+                             "distort-mode" );
             p_vout->p_sys->i_mode = DISTORT_MODE_WAVE;
         }
         else {
@@ -185,12 +166,11 @@ static int vout_Create( vout_thread_t *p_vout )
 }
     
 /*****************************************************************************
- * vout_Init: initialize Distort video thread output method
+ * Init: initialize Distort video thread output method
  *****************************************************************************/
-static int vout_Init( vout_thread_t *p_vout )
+static int Init( vout_thread_t *p_vout )
 {
     int i_index;
-    char *psz_filter;
     picture_t *p_pic;
 
     I_OUTPUTPICTURES = 0;
@@ -202,19 +182,13 @@ static int vout_Init( vout_thread_t *p_vout )
     p_vout->output.i_aspect = p_vout->render.i_aspect;
 
     /* Try to open the real video output */
-    psz_filter = config_GetPsz( p_vout, "filter" );
-    config_PutPsz( p_vout, "filter", NULL );
-
     msg_Dbg( p_vout, "spawning the real video output" );
 
     p_vout->p_sys->p_vout =
-        vout_CreateThread( p_vout->p_this,
+        vout_CreateThread( p_vout,
                            p_vout->render.i_width, p_vout->render.i_height,
                            p_vout->render.i_chroma, p_vout->render.i_aspect );
 
-    config_PutPsz( p_vout, "filter", psz_filter );
-    if( psz_filter ) free( psz_filter );
-
     /* Everything failed */
     if( p_vout->p_sys->p_vout == NULL )
     {
@@ -232,9 +206,9 @@ static int vout_Init( vout_thread_t *p_vout )
 }
 
 /*****************************************************************************
- * vout_End: terminate Distort video thread output method
+ * End: terminate Distort video thread output method
  *****************************************************************************/
-static void vout_End( vout_thread_t *p_vout )
+static void End( vout_thread_t *p_vout )
 {
     int i_index;
 
@@ -247,36 +221,27 @@ static void vout_End( vout_thread_t *p_vout )
 }
 
 /*****************************************************************************
- * vout_Destroy: destroy Distort video thread output method
+ * Destroy: destroy Distort video thread output method
  *****************************************************************************
  * Terminate an output method created by DistortCreateOutputMethod
  *****************************************************************************/
-static void vout_Destroy( vout_thread_t *p_vout )
+static void Destroy( vlc_object_t *p_this )
 {
+    vout_thread_t *p_vout = (vout_thread_t *)p_this;
+
     vout_DestroyThread( p_vout->p_sys->p_vout );
 
     free( p_vout->p_sys );
 }
 
 /*****************************************************************************
- * vout_Manage: handle Distort events
- *****************************************************************************
- * This function should be called regularly by video output thread. It manages
- * console events. It returns a non null value on error.
- *****************************************************************************/
-static int vout_Manage( vout_thread_t *p_vout )
-{
-    return( 0 );
-}
-
-/*****************************************************************************
- * vout_Render: displays previously rendered output
+ * Render: displays previously rendered output
  *****************************************************************************
  * This function send the currently rendered image to Distort image, waits
  * until it is displayed and switch the two rendering buffers, preparing next
  * frame.
  *****************************************************************************/
-static void vout_Render( vout_thread_t *p_vout, picture_t *p_pic )
+static void Render( vout_thread_t *p_vout, picture_t *p_pic )
 {
     picture_t *p_outpic;
 
@@ -310,18 +275,6 @@ static void vout_Render( 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 )
-{
-    ;
-}
-
 /*****************************************************************************
  * DistortWave: draw a wave effect on the picture
  *****************************************************************************/
@@ -466,4 +419,3 @@ static void DistortRipple( vout_thread_t *p_vout, picture_t *p_inpic,
         }
     }
 }
-