* 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"
* 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 )
* 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
*****************************************************************************/
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_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
*****************************************************************************
*****************************************************************************/
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++;
{
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
*****************************************************************************/
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;
for( i_index = I_OUTPUTPICTURES ; i_index ; )
{
i_index--;
- free( PP_OUTPUTPICTURE[ i_index ]->p_data );
+ free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
}
}
*****************************************************************************/
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 );
}
{
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;
}
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;
}
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;
}
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;
{
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;
}
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;
}
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;
}