]> git.sesse.net Git - vlc/blobdiff - plugins/filter/distort.c
* Fixed some compile issues with what I checked in.
[vlc] / plugins / filter / distort.c
index c36fc663f86a15c24fcbb0f2c12b9ab46071a517..60c418e88202805080201acc05245d2e99113267 100644 (file)
@@ -2,7 +2,7 @@
  * distort.c : Misc video effects plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: distort.c,v 1.6 2002/01/05 03:49:18 sam Exp $
+ * $Id: distort.c,v 1.15 2002/06/01 18:04:48 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
 
 #include <math.h>                                            /* sin(), cos() */
 
-#include <videolan/vlc.h>
-
-#include "video.h"
-#include "video_output.h"
+#include <vlc/vlc.h>
+#include <vlc/vout.h>
 
 #include "filter_common.h"
 
@@ -49,10 +47,13 @@ static void vout_getfunctions( function_list_t * p_function_list );
  * Build configuration tree.
  *****************************************************************************/
 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" )
+    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 )
@@ -72,33 +73,29 @@ MODULE_DEACTIVATE_STOP
  * This structure is part of the video output thread descriptor.
  * It describes the Distort specific properties of an output thread.
  *****************************************************************************/
-typedef struct vout_sys_s
+struct vout_sys_s
 {
     int i_mode;
-    struct vout_thread_s *p_vout;
+    vout_thread_t *p_vout;
 
     /* For the wave mode */
     double  f_angle;
     mtime_t last_date;
-
-} vout_sys_t;
+};
 
 /*****************************************************************************
  * 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 * );
-
-static void DistortWave    ( struct vout_thread_s *, struct picture_s *,
-                                                     struct picture_s * );
-static void DistortRipple  ( struct vout_thread_s *, struct picture_s *,
-                                                     struct picture_s * );
+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
@@ -106,7 +103,6 @@ static void DistortRipple  ( 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;
@@ -116,14 +112,6 @@ static void vout_getfunctions( function_list_t * p_function_list )
     p_function_list->functions.vout.pf_display    = vout_Display;
 }
 
-/*****************************************************************************
- * intf_Probe: return a score
- *****************************************************************************/
-static int vout_Probe( probedata_t *p_data )
-{
-    return( 0 );
-}
-
 /*****************************************************************************
  * vout_Create: allocates Distort video thread output method
  *****************************************************************************
@@ -131,19 +119,22 @@ static int vout_Probe( probedata_t *p_data )
  *****************************************************************************/
 static int vout_Create( vout_thread_t *p_vout )
 {
-    char *psz_method;
+    char *psz_method, *psz_method_tmp;
 
     /* Allocate structure */
     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
     if( p_vout->p_sys == NULL )
     {
-        intf_ErrMsg("error: %s", strerror(ENOMEM) );
+        msg_Err( p_vout, "out of memory" );
+        return( 1 );
+    }
+    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" )) )
+    {
+        msg_Err( p_vout, "configuration variable %s empty", "filter" );
         return( 1 );
     }
-
-    /* Look what method was requested */
-    psz_method = main_GetPszVariable( VOUT_FILTER_VAR, "" );
-
     while( *psz_method && *psz_method != ':' )
     {
         psz_method++;
@@ -157,16 +148,42 @@ static int vout_Create( vout_thread_t *p_vout )
     {
         p_vout->p_sys->i_mode = DISTORT_MODE_RIPPLE;
     }
-    else
+    free( psz_method_tmp );
+    if( !p_vout->p_sys->i_mode )
     {
-        intf_ErrMsg( "filter error: no valid distort mode provided, "
-                     "using distort:wave" );
-        p_vout->p_sys->i_mode = DISTORT_MODE_WAVE;
+        /* 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" )) )
+        {
+            msg_Err( p_vout, "configuration variable %s empty, using 'wave'",
+                             "distort_mode" );
+            p_vout->p_sys->i_mode = DISTORT_MODE_WAVE;
+        }
+        else {
+        
+            if( !strcmp( psz_method, "wave" ) )
+            {
+                p_vout->p_sys->i_mode = DISTORT_MODE_WAVE;
+            }
+            else if( !strcmp( psz_method, "ripple" ) )
+            {
+                p_vout->p_sys->i_mode = DISTORT_MODE_RIPPLE;
+            }
+            
+            else
+            {
+                msg_Err( p_vout, "no valid distort mode provided, "
+                                 "using wave" );
+                p_vout->p_sys->i_mode = DISTORT_MODE_WAVE;
+            }
+        }
     }
-
+    free( psz_method_tmp );
+    
     return( 0 );
 }
-
+    
 /*****************************************************************************
  * vout_Init: initialize Distort video thread output method
  *****************************************************************************/
@@ -185,26 +202,27 @@ 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 = main_GetPszVariable( VOUT_FILTER_VAR, "" );
-    main_PutPszVariable( VOUT_FILTER_VAR, "" );
+    psz_filter = config_GetPsz( p_vout, "filter" );
+    config_PutPsz( p_vout, "filter", NULL );
 
-    intf_WarnMsg( 1, "filter: spawning the real video output" );
+    msg_Dbg( p_vout, "spawning the real video output" );
 
     p_vout->p_sys->p_vout =
-        vout_CreateThread( NULL,
+        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 )
     {
-        intf_ErrMsg( "filter error: can't open vout, aborting" );
+        msg_Err( p_vout, "cannot open vout, aborting" );
 
         return( 0 );
     }
  
-    main_PutPszVariable( VOUT_FILTER_VAR, psz_filter );
-
     ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
 
     p_vout->p_sys->f_angle = 0.0;
@@ -224,7 +242,7 @@ static void vout_End( vout_thread_t *p_vout )
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
         i_index--;
-        free( PP_OUTPUTPICTURE[ i_index ]->p_data );
+        free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
     }
 }
 
@@ -235,7 +253,7 @@ static void vout_End( vout_thread_t *p_vout )
  *****************************************************************************/
 static void vout_Destroy( vout_thread_t *p_vout )
 {
-    vout_DestroyThread( p_vout->p_sys->p_vout, NULL );
+    vout_DestroyThread( p_vout->p_sys->p_vout );
 
     free( p_vout->p_sys );
 }
@@ -344,7 +362,7 @@ static void DistortWave( vout_thread_t *p_vout, picture_t *p_inpic,
             {
                 if( i_offset < 0 )
                 {
-                    FAST_MEMCPY( p_out, p_in - i_offset,
+                    p_vout->p_vlc->pf_memcpy( p_out, p_in - i_offset,
                                  p_inpic->p[i_index].i_pitch + i_offset );
                     p_in += p_inpic->p[i_index].i_pitch;
                     p_out += p_outpic->p[i_index].i_pitch;
@@ -352,7 +370,7 @@ static void DistortWave( vout_thread_t *p_vout, picture_t *p_inpic,
                 }
                 else
                 {
-                    FAST_MEMCPY( p_out + i_offset, p_in,
+                    p_vout->p_vlc->pf_memcpy( p_out + i_offset, p_in,
                                  p_inpic->p[i_index].i_pitch - i_offset );
                     memset( p_out, black_pixel, i_offset );
                     p_in += p_inpic->p[i_index].i_pitch;
@@ -361,7 +379,8 @@ static void DistortWave( vout_thread_t *p_vout, picture_t *p_inpic,
             }
             else
             {
-                FAST_MEMCPY( p_out, p_in, p_inpic->p[i_index].i_pitch );
+                p_vout->p_vlc->pf_memcpy( p_out, p_in,
+                                          p_inpic->p[i_index].i_pitch );
                 p_in += p_inpic->p[i_index].i_pitch;
                 p_out += p_outpic->p[i_index].i_pitch;
             }
@@ -399,7 +418,8 @@ static void DistortRipple( vout_thread_t *p_vout, picture_t *p_inpic,
         p_in = p_inpic->p[i_index].p_pixels;
         p_out = p_outpic->p[i_index].p_pixels;
 
-        FAST_MEMCPY( p_out, p_in, i_first_line * p_inpic->p[i_index].i_pitch );
+        p_vout->p_vlc->pf_memcpy( p_out, p_in,
+                                  i_first_line * p_inpic->p[i_index].i_pitch );
 
         p_in += i_first_line * p_inpic->p[i_index].i_pitch;
         p_out += i_first_line * p_outpic->p[i_index].i_pitch;
@@ -420,7 +440,7 @@ static void DistortRipple( vout_thread_t *p_vout, picture_t *p_inpic,
             {
                 if( i_offset < 0 )
                 {
-                    FAST_MEMCPY( p_out, p_in - i_offset,
+                    p_vout->p_vlc->pf_memcpy( p_out, p_in - i_offset,
                                  p_inpic->p[i_index].i_pitch + i_offset );
                     p_in -= p_inpic->p[i_index].i_pitch;
                     p_out += p_outpic->p[i_index].i_pitch;
@@ -428,7 +448,7 @@ static void DistortRipple( vout_thread_t *p_vout, picture_t *p_inpic,
                 }
                 else
                 {
-                    FAST_MEMCPY( p_out + i_offset, p_in,
+                    p_vout->p_vlc->pf_memcpy( p_out + i_offset, p_in,
                                  p_inpic->p[i_index].i_pitch - i_offset );
                     memset( p_out, black_pixel, i_offset );
                     p_in -= p_inpic->p[i_index].i_pitch;
@@ -437,7 +457,8 @@ static void DistortRipple( vout_thread_t *p_vout, picture_t *p_inpic,
             }
             else
             {
-                FAST_MEMCPY( p_out, p_in, p_inpic->p[i_index].i_pitch );
+                p_vout->p_vlc->pf_memcpy( p_out, p_in,
+                                          p_inpic->p[i_index].i_pitch );
                 p_in -= p_inpic->p[i_index].i_pitch;
                 p_out += p_outpic->p[i_index].i_pitch;
             }