]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/alphamask.c
Release the display mode when we are done with it.
[vlc] / modules / video_filter / alphamask.c
index 7b8806dfecfd6bfa6b96ab0fa10d4d77f092c054..c8a1f917a19368385ca887305ebfd5ccc5f283d7 100644 (file)
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
-#include <vlc_vout.h>
 
 #include <vlc_image.h>
 #include <vlc_filter.h>
+#include <vlc_url.h>
 
 #define ALPHAMASK_HELP N_( \
     "Use an image's alpha channel as a transparency mask." )
@@ -66,8 +66,7 @@ vlc_module_begin ()
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_VFILTER )
     set_capability( "video filter2", 0 )
-    add_shortcut( "alphamask" )
-    add_shortcut( "mask" )
+    add_shortcut( "alphamask", "mask" )
     set_callbacks( Create, Destroy )
 
     add_string( CFG_PREFIX "mask", NULL, NULL, MASK_TEXT,
@@ -93,7 +92,7 @@ static int Create( vlc_object_t *p_this )
     if( p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVA )
     {
         msg_Err( p_filter,
-                 "Unsupported input chroma \"%4s\". "
+                 "Unsupported input chroma \"%4.4s\". "
                  "Alphamask can only use \"YUVA\".",
                  (char*)&p_filter->fmt_in.video.i_chroma );
         return VLC_EGENERIC;
@@ -108,12 +107,8 @@ static int Create( vlc_object_t *p_this )
     config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
                        p_filter->p_cfg );
 
-    vlc_mutex_init( &p_sys->mask_lock );
     psz_string =
         var_CreateGetStringCommand( p_filter, CFG_PREFIX "mask" );
-    var_AddCallback( p_filter, CFG_PREFIX "mask", MaskCallback,
-                     p_filter );
-    p_sys->p_mask = NULL;
     if( psz_string && *psz_string )
     {
         LoadMask( p_filter, psz_string );
@@ -121,8 +116,13 @@ static int Create( vlc_object_t *p_this )
             msg_Err( p_filter, "Error while loading mask (%s).",
                      psz_string );
     }
+    else
+       p_sys->p_mask = NULL;
     free( psz_string );
 
+    vlc_mutex_init( &p_sys->mask_lock );
+    var_AddCallback( p_filter, CFG_PREFIX "mask", MaskCallback,
+                     p_filter );
     p_filter->pf_video_filter = Filter;
 
     return VLC_SUCCESS;
@@ -182,8 +182,10 @@ static void LoadMask( filter_t *p_filter, const char *psz_filename )
     if( p_filter->p_sys->p_mask )
         picture_Release( p_filter->p_sys->p_mask );
     p_image = image_HandlerCreate( p_filter );
+    char *psz_url = make_URI( psz_filename, NULL );
     p_filter->p_sys->p_mask =
-        image_ReadUrl( p_image, psz_filename, &fmt_in, &fmt_out );
+        image_ReadUrl( p_image, psz_url, &fmt_in, &fmt_out );
+    free( psz_url );
     image_HandlerDelete( p_image );
 }