]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/ripple.c
Usefull coment instead of "Gruik" (evenif I like the previous one...)
[vlc] / modules / video_filter / ripple.c
index de43d2d3e20bedb9a13583c9fd55b1aaea637fe4..6d9776fe1849ac15ee8472f16b0ecdf3c8bf7c07 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>
 
-#include <math.h>                                            /* sin(), cos() */
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
-#include <vlc/vlc.h>
-#include <vlc/decoder.h>
+#include <math.h>                                            /* sin(), cos() */
 
-#include "vlc_filter.h"
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_vout.h>
+#include <vlc_filter.h>
+#include "filter_picture.h"
 
 /*****************************************************************************
  * Local prototypes
@@ -47,7 +50,7 @@ static picture_t *Filter( filter_t *, picture_t * );
  * Module descriptor
  *****************************************************************************/
 vlc_module_begin();
-    set_description( _("Ripple video filter") );
+    set_description( N_("Ripple video filter") );
     set_shortname( N_( "Ripple" ));
     set_capability( "video filter2", 0 );
     set_category( CAT_VIDEO );
@@ -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;
 
@@ -121,12 +121,10 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
 
     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;
     }
 
@@ -136,13 +134,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 +153,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_vlc->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 +162,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_vlc->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_vlc->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_vlc->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 +199,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 );
 }