X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_filter%2Fripple.c;h=00108565401be8a5d1df385c0501beec77a629c0;hb=e2a614c82b502ea6c3cdee7d0fc39cbb9627041e;hp=e5c1ddc71d60dcec1f14d6e2118c7e84d07a6a62;hpb=12efe797994da9153a6c1275f28631888d3d2a80;p=vlc diff --git a/modules/video_filter/ripple.c b/modules/video_filter/ripple.c index e5c1ddc71d..0010856540 100644 --- a/modules/video_filter/ripple.c +++ b/modules/video_filter/ripple.c @@ -25,15 +25,18 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* malloc(), free() */ -#include -#include /* sin(), cos() */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif -#include -#include +#include /* sin(), cos() */ -#include "vlc_filter.h" +#include +#include +#include +#include +#include "filter_picture.h" /***************************************************************************** * Local prototypes @@ -47,8 +50,8 @@ static picture_t *Filter( filter_t *, picture_t * ); * Module descriptor *****************************************************************************/ vlc_module_begin(); - set_description( _("Ripple video filter") ); - set_shortname( _( "Ripple" )); + set_description( N_("Ripple video filter") ); + set_shortname( N_( "Ripple" )); set_capability( "video filter2", 0 ); set_category( CAT_VIDEO ); set_subcategory( SUBCAT_VIDEO_VFILTER ); @@ -81,10 +84,7 @@ static int Create( vlc_object_t *p_this ) /* 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; @@ -136,13 +136,17 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ ) { - int i_line, i_first_line, i_num_lines, i_offset; + int i_line, i_first_line, i_num_lines, i_offset, i_pixel_pitch, + i_visible_pixels; uint8_t black_pixel; uint8_t *p_in, *p_out; - black_pixel = ( i_index == Y_PLANE ) ? 0x00 : 0x80; + black_pixel = ( p_pic->i_planes > 1 && i_index == Y_PLANE ) ? 0x00 + : 0x80; i_num_lines = p_pic->p[i_index].i_visible_lines; + i_pixel_pitch = p_pic->p[i_index].i_pixel_pitch; + i_visible_pixels = p_pic->p[i_index].i_visible_pitch/p_pic->p[i_index].i_pixel_pitch; i_first_line = i_num_lines * 4 / 5; @@ -151,8 +155,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) for( i_line = 0 ; i_line < i_first_line ; i_line++ ) { - p_filter->p_libvlc->pf_memcpy( p_out, p_in, - p_pic->p[i_index].i_visible_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_index].i_visible_pitch ); p_in += p_pic->p[i_index].i_pitch; p_out += p_outpic->p[i_index].i_pitch; } @@ -161,37 +164,36 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) for( i_line = i_first_line ; 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_pitch) + i_offset = (int)( (double)(i_visible_pixels) * sin( f_angle + 2.0 * (double)i_line / (double)( 1 + i_line - i_first_line) ) * (double)(i_line - i_first_line) / (double)i_num_lines - / 8.0 ); + / 8.0 )*p_pic->p[i_index].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, + p_pic->p[i_index].i_visible_pitch + i_offset ); p_in -= p_pic->p[i_index].i_pitch; p_out += p_outpic->p[i_index].i_pitch; - 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 ); - memset( p_out, black_pixel, i_offset ); + vlc_memcpy( p_out + i_offset, p_in, + p_pic->p[i_index].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, p_pic->p[i_index].i_visible_pitch ); p_in -= p_pic->p[i_index].i_pitch; p_out += p_outpic->p[i_index].i_pitch; } @@ -199,14 +201,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) } } - 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 ); }