/*****************************************************************************
* distort.c : Misc video effects plugin for vlc
*****************************************************************************
- * Copyright (C) 2000, 2001 VideoLAN
- * $Id: distort.c,v 1.4 2002/11/28 17:35:00 sam Exp $
+ * Copyright (C) 2000, 2001, 2002, 2003 VideoLAN
+ * $Id: distort.c,v 1.10 2003/05/15 22:27:37 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
static void DistortWave ( vout_thread_t *, picture_t *, picture_t * );
static void DistortRipple ( vout_thread_t *, picture_t *, picture_t * );
+static int SendEvents ( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
+
/*****************************************************************************
* Module descriptor
*****************************************************************************/
-#define MODE_TEXT N_("distort mode")
+#define MODE_TEXT N_("Distort mode")
#define MODE_LONGTEXT N_("Distort mode, one of \"wave\" and \"ripple\"")
static char *mode_list[] = { "wave", "ripple", NULL };
vlc_module_begin();
- add_category_hint( N_("Miscellaneous"), NULL );
+ add_category_hint( N_("Distort"), NULL, VLC_FALSE );
add_string_from_list( "distort-mode", "wave", mode_list, NULL,
- MODE_TEXT, MODE_LONGTEXT );
- set_description( _("miscellaneous video effects module") );
+ MODE_TEXT, MODE_LONGTEXT, VLC_FALSE );
+ set_description( _("miscellaneous distort video effects filter") );
set_capability( "video filter", 0 );
add_shortcut( "distort" );
set_callbacks( Create, Destroy );
if( p_vout->p_sys == NULL )
{
msg_Err( p_vout, "out of memory" );
- return( 1 );
+ return VLC_ENOMEM;
}
p_vout->pf_init = Init;
if( !(psz_method = psz_method_tmp = config_GetPsz( p_vout, "filter" )) )
{
msg_Err( p_vout, "configuration variable %s empty", "filter" );
- return( 1 );
+ return VLC_EGENERIC;
}
while( *psz_method && *psz_method != ':' )
{
p_vout->p_sys->i_mode = DISTORT_MODE_WAVE;
}
else {
-
+
if( !strcmp( psz_method, "wave" ) )
{
p_vout->p_sys->i_mode = DISTORT_MODE_WAVE;
{
p_vout->p_sys->i_mode = DISTORT_MODE_RIPPLE;
}
-
else
{
msg_Err( p_vout, "no valid distort mode provided, "
}
}
free( psz_method_tmp );
-
- return( 0 );
+
+ return VLC_SUCCESS;
}
-
+
/*****************************************************************************
* Init: initialize Distort video thread output method
*****************************************************************************/
{
msg_Err( p_vout, "cannot open vout, aborting" );
- return( 0 );
+ return VLC_EGENERIC;
}
ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
+ ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+
p_vout->p_sys->f_angle = 0.0;
p_vout->p_sys->last_date = 0;
- return( 0 );
+ return VLC_SUCCESS;
}
/*****************************************************************************
{
vout_thread_t *p_vout = (vout_thread_t *)p_this;
+ DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+ vlc_object_detach( p_vout->p_sys->p_vout );
vout_Destroy( p_vout->p_sys->p_vout );
free( p_vout->p_sys );
for( i_index = 0 ; i_index < p_inpic->i_planes ; i_index++ )
{
int i_line, i_num_lines, i_offset;
- u8 black_pixel;
- u8 *p_in, *p_out;
+ uint8_t black_pixel;
+ uint8_t *p_in, *p_out;
p_in = p_inpic->p[i_index].p_pixels;
p_out = p_outpic->p[i_index].p_pixels;
for( i_line = 0 ; i_line < i_num_lines ; i_line++ )
{
/* Calculate today's offset, don't go above 1/20th of the screen */
- i_offset = (int)( (double)(p_inpic->p[i_index].i_pitch)
+ i_offset = (int)( (double)(p_inpic->p[i_index].i_visible_pitch)
* sin( f_angle + 10.0 * (double)i_line
/ (double)i_num_lines )
/ 20.0 );
if( i_offset < 0 )
{
p_vout->p_vlc->pf_memcpy( p_out, p_in - i_offset,
- p_inpic->p[i_index].i_pitch + i_offset );
+ p_inpic->p[i_index].i_visible_pitch + i_offset );
p_in += p_inpic->p[i_index].i_pitch;
p_out += p_outpic->p[i_index].i_pitch;
memset( p_out + i_offset, black_pixel, -i_offset );
else
{
p_vout->p_vlc->pf_memcpy( p_out + i_offset, p_in,
- p_inpic->p[i_index].i_pitch - i_offset );
+ p_inpic->p[i_index].i_visible_pitch - i_offset );
memset( p_out, black_pixel, i_offset );
p_in += p_inpic->p[i_index].i_pitch;
p_out += p_outpic->p[i_index].i_pitch;
else
{
p_vout->p_vlc->pf_memcpy( p_out, p_in,
- p_inpic->p[i_index].i_pitch );
+ p_inpic->p[i_index].i_visible_pitch );
p_in += p_inpic->p[i_index].i_pitch;
p_out += p_outpic->p[i_index].i_pitch;
}
for( i_index = 0 ; i_index < p_inpic->i_planes ; i_index++ )
{
int i_line, i_first_line, i_num_lines, i_offset;
- u8 black_pixel;
- u8 *p_in, *p_out;
+ uint8_t black_pixel;
+ uint8_t *p_in, *p_out;
black_pixel = ( i_index == Y_PLANE ) ? 0x00 : 0x80;
p_in = p_inpic->p[i_index].p_pixels;
p_out = p_outpic->p[i_index].p_pixels;
- 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;
+ for( i_line = 0 ; i_line < i_first_line ; i_line++ )
+ {
+ p_vout->p_vlc->pf_memcpy( p_out, p_in,
+ p_inpic->p[i_index].i_visible_pitch );
+ p_in += p_inpic->p[i_index].i_pitch;
+ p_out += p_outpic->p[i_index].i_pitch;
+ }
/* Ok, we do 3 times the sin() calculation for each line. So what ? */
for( i_line = i_first_line ; i_line < i_num_lines ; i_line++ )
if( i_offset < 0 )
{
p_vout->p_vlc->pf_memcpy( p_out, p_in - i_offset,
- p_inpic->p[i_index].i_pitch + i_offset );
+ p_inpic->p[i_index].i_visible_pitch + i_offset );
p_in -= p_inpic->p[i_index].i_pitch;
p_out += p_outpic->p[i_index].i_pitch;
memset( p_out + i_offset, black_pixel, -i_offset );
else
{
p_vout->p_vlc->pf_memcpy( p_out + i_offset, p_in,
- p_inpic->p[i_index].i_pitch - i_offset );
+ p_inpic->p[i_index].i_visible_pitch - i_offset );
memset( p_out, black_pixel, i_offset );
p_in -= p_inpic->p[i_index].i_pitch;
p_out += p_outpic->p[i_index].i_pitch;
else
{
p_vout->p_vlc->pf_memcpy( p_out, p_in,
- p_inpic->p[i_index].i_pitch );
+ p_inpic->p[i_index].i_visible_pitch );
p_in -= p_inpic->p[i_index].i_pitch;
p_out += p_outpic->p[i_index].i_pitch;
}
}
}
}
+
+/*****************************************************************************
+ * SendEvents: forward mouse and keyboard events to the parent p_vout
+ *****************************************************************************/
+static int SendEvents( vlc_object_t *p_this, char const *psz_var,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+ var_Set( (vlc_object_t *)p_data, psz_var, newval );
+
+ return VLC_SUCCESS;
+}
+