]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/gradient.c
playlist: Make sure we don't pl_Release(p_playlist).
[vlc] / modules / video_filter / gradient.c
index 0835c7f09b02928eabec8d4da775a62541edb026..f1c57cdeefe761bdfa96ba2b255b5f1bf54c1f56 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * gradient.c : Gradient and edge detection video effects 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 <math.h>                                            /* sin(), cos() */
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <math.h>                                            /* sin(), cos() */
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_sout.h>
 #include <vlc_vout.h>
 
 #include "vlc_filter.h"
+#include "filter_picture.h"
 
 enum { GRADIENT, EDGE, HOUGH };
 
@@ -69,14 +71,14 @@ static void FilterHough   ( filter_t *, picture_t *, picture_t * );
 #define CARTOON_LONGTEXT N_("Apply cartoon effect. It is only used by " \
     "\"gradient\" and \"edge\".")
 
-static const char *mode_list[] = { "gradient", "edge", "hough" };
-static const char *mode_list_text[] = { N_("Gradient"), N_("Edge"), N_("Hough") };
+static const char *const mode_list[] = { "gradient", "edge", "hough" };
+static const char *const mode_list_text[] = { N_("Gradient"), N_("Edge"), N_("Hough") };
 
 #define FILTER_PREFIX "gradient-"
 
 vlc_module_begin();
-    set_description( _("Gradient video filter") );
-    set_shortname( _( "Gradient" ));
+    set_description( N_("Gradient video filter") );
+    set_shortname( N_( "Gradient" ));
     set_capability( "video filter2", 0 );
     set_category( CAT_VIDEO );
     set_subcategory( SUBCAT_VIDEO_VFILTER );
@@ -94,7 +96,7 @@ vlc_module_begin();
     set_callbacks( Create, Destroy );
 vlc_module_end();
 
-static const char *ppsz_filter_options[] = {
+static const char *const ppsz_filter_options[] = {
     "mode", "type", "cartoon", NULL
 };
 
@@ -130,13 +132,21 @@ static int Create( vlc_object_t *p_this )
     filter_t *p_filter = (filter_t *)p_this;
     char *psz_method;
 
+    switch( p_filter->fmt_in.video.i_chroma )
+    {
+        CASE_PLANAR_YUV
+            break;
+
+        default:
+             msg_Err( p_filter, "Unsupported input chroma (%4s)",
+                      (char*)&(p_filter->fmt_in.video.i_chroma) );
+            return VLC_EGENERIC;
+    }
+
     /* 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;
 
@@ -223,12 +233,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;
     }
 
@@ -250,16 +258,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
             break;
     }
 
-    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 );
 }
 
 /*****************************************************************************