/*****************************************************************************
* wave.c : Wave video effect plugin for vlc
*****************************************************************************
- * Copyright (C) 2000-2006 the VideoLAN team
+ * Copyright (C) 2000-2008 the VideoLAN team
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Preamble
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <math.h> /* sin(), cos() */
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_vout.h>
#include "vlc_filter.h"
+#include "filter_picture.h"
/*****************************************************************************
* Local prototypes
* Module descriptor
*****************************************************************************/
vlc_module_begin();
- set_description( _("Wave video filter") );
- set_shortname( _( "Wave" ));
+ set_description( N_("Wave video filter") );
+ set_shortname( N_( "Wave" ));
set_capability( "video filter2", 0 );
set_category( CAT_VIDEO );
set_subcategory( SUBCAT_VIDEO_VFILTER );
/* Allocate structure */
p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
if( p_filter->p_sys == NULL )
- {
- msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
- }
p_filter->pf_video_filter = Filter;
if( !p_pic ) return NULL;
- p_outpic = p_filter->pf_vout_buffer_new( p_filter );
+ p_outpic = filter_NewPicture( p_filter );
if( !p_outpic )
{
- msg_Warn( p_filter, "can't get output picture" );
- if( p_pic->pf_release )
- p_pic->pf_release( p_pic );
+ picture_Release( p_pic );
return NULL;
}
for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ )
{
- int i_line, i_num_lines, i_offset;
+ int i_line, i_num_lines, i_visible_pitch, i_pixel_pitch, i_offset,
+ i_visible_pixels;
uint8_t black_pixel;
uint8_t *p_in, *p_out;
p_out = p_outpic->p[i_index].p_pixels;
i_num_lines = p_pic->p[i_index].i_visible_lines;
+ i_visible_pitch = p_pic->p[i_index].i_visible_pitch;
+ i_pixel_pitch = p_pic->p[i_index].i_pixel_pitch;
+ i_visible_pixels = i_visible_pitch/i_pixel_pitch;
- black_pixel = ( i_index == Y_PLANE ) ? 0x00 : 0x80;
+ black_pixel = ( p_pic->i_planes > 1 && i_index == Y_PLANE ) ? 0x00
+ : 0x80;
/* Ok, we do 3 times the sin() calculation for each line. So what ? */
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_pic->p[i_index].i_visible_pitch)
+ i_offset = (int)( (double)(i_visible_pixels)
* sin( f_angle + 10.0 * (double)i_line
/ (double)i_num_lines )
- / 20.0 );
+ / 20.0 )*i_pixel_pitch;
if( i_offset )
{
if( i_offset < 0 )
{
- p_filter->p_libvlc->pf_memcpy( p_out, p_in - i_offset,
- p_pic->p[i_index].i_visible_pitch + i_offset );
+ vlc_memcpy( p_out, p_in - i_offset,
+ i_visible_pitch + i_offset );
p_in += p_pic->p[i_index].i_pitch;
p_out += p_outpic->p[i_index].i_pitch;
- p_filter->p_libvlc->pf_memset( p_out + i_offset,
- black_pixel, -i_offset );
+ vlc_memset( p_out + i_offset, black_pixel, -i_offset );
}
else
{
- p_filter->p_libvlc->pf_memcpy( p_out + i_offset, p_in,
- p_pic->p[i_index].i_visible_pitch - i_offset );
- p_filter->p_libvlc->pf_memset( p_out, black_pixel,
- i_offset );
+ vlc_memcpy( p_out + i_offset, p_in,
+ i_visible_pitch - i_offset );
+ vlc_memset( p_out, black_pixel, i_offset );
p_in += p_pic->p[i_index].i_pitch;
p_out += p_outpic->p[i_index].i_pitch;
}
}
else
{
- p_filter->p_libvlc->pf_memcpy( p_out, p_in,
- p_pic->p[i_index].i_visible_pitch );
+ vlc_memcpy( p_out, p_in, i_visible_pitch );
p_in += p_pic->p[i_index].i_pitch;
p_out += p_outpic->p[i_index].i_pitch;
}
}
}
- p_outpic->date = p_pic->date;
- p_outpic->b_force = p_pic->b_force;
- p_outpic->i_nb_fields = p_pic->i_nb_fields;
- p_outpic->b_progressive = p_pic->b_progressive;
- p_outpic->b_top_field_first = p_pic->b_top_field_first;
-
- if( p_pic->pf_release )
- p_pic->pf_release( p_pic );
-
- return p_outpic;
+ return CopyInfoAndRelease( p_outpic, p_pic );
}