]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/ripple.c
* display the GPL in a separate window linked in the About window and the Help menu...
[vlc] / modules / video_filter / ripple.c
index e2157e3a3b022068135cb5ad0c0f3eef0a77574a..75bba583d9236a05e8661711d3e31c4161956fba 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>
 
 #include <math.h>                                            /* sin(), cos() */
 
 #include <vlc/vlc.h>
-#include <vlc/decoder.h>
-
-#include "vlc_filter.h"
+#include <vlc_vout.h>
+#include <vlc_filter.h>
 
 /*****************************************************************************
  * Local prototypes
@@ -48,7 +45,7 @@ static picture_t *Filter( filter_t *, picture_t * );
  *****************************************************************************/
 vlc_module_begin();
     set_description( _("Ripple video filter") );
-    set_shortname( N_( "Ripple" ));
+    set_shortname( _( "Ripple" ));
     set_capability( "video filter2", 0 );
     set_category( CAT_VIDEO );
     set_subcategory( SUBCAT_VIDEO_VFILTER );
@@ -136,13 +133,16 @@ 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;
 
         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;
 
@@ -161,13 +161,13 @@ 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 )
             {
@@ -177,13 +177,15 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
                              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 );
+                    p_filter->p_libvlc->pf_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 );
+                    p_filter->p_libvlc->pf_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;
                 }