]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/wave.c
Sync PO files
[vlc] / modules / video_filter / wave.c
index 898f569dc5800cfb2d959115e8741ae1922859a7..03fb7c25879b159f8139851d9a4952692d218986 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * 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
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>
+
+#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
@@ -47,8 +51,8 @@ static picture_t *Filter( filter_t *, picture_t * );
  * 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 );
@@ -81,10 +85,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 +122,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,7 +135,8 @@ 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_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;
 
@@ -144,41 +144,44 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
         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;
-                    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,
+                                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;
             }
@@ -186,14 +189,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 );
 }