]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/wave.c
Use var_InheritString for --decklink-video-connection.
[vlc] / modules / video_filter / wave.c
index 7b4fe3cb565e4e0ba75155ff949e95abe47f00c5..6ad3ac27171ea742ab29c72cf651cb756075b283 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/decoder.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 
-#include "vlc_filter.h"
+#include <vlc_filter.h>
+#include "filter_picture.h"
 
 /*****************************************************************************
  * Local prototypes
@@ -46,19 +49,19 @@ static picture_t *Filter( filter_t *, picture_t * );
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-vlc_module_begin();
-    set_description( _("Wave video filter") );
-    set_shortname( N_( "Wave" ));
-    set_capability( "video filter2", 0 );
-    set_category( CAT_VIDEO );
-    set_subcategory( SUBCAT_VIDEO_VFILTER );
+vlc_module_begin ()
+    set_description( N_("Wave video filter") )
+    set_shortname( N_( "Wave" ))
+    set_capability( "video filter2", 0 )
+    set_category( CAT_VIDEO )
+    set_subcategory( SUBCAT_VIDEO_VFILTER )
 
-    add_shortcut( "wave" );
-    set_callbacks( Create, Destroy );
-vlc_module_end();
+    add_shortcut( "wave" )
+    set_callbacks( Create, Destroy )
+vlc_module_end ()
 
 /*****************************************************************************
- * vout_sys_t: Distort video output method descriptor
+ * filter_sys_t: Distort video output method descriptor
  *****************************************************************************
  * This structure is part of the video output thread descriptor.
  * It describes the Distort specific properties of an output thread.
@@ -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,7 +134,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 +143,51 @@ 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;
+        switch( p_filter->fmt_in.video.i_chroma )
+        {
+            CASE_PACKED_YUV_422
+                // Quick hack to fix u/v inversion occuring with 2 byte pixel pitch
+                i_pixel_pitch *= 2;
+                break;
+        }
+        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_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,
+                                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,
+                                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, i_visible_pitch );
                 p_in += p_pic->p[i_index].i_pitch;
                 p_out += p_outpic->p[i_index].i_pitch;
             }
@@ -186,14 +195,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 );
 }