]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/logo.c
atmo: fix mismatch allocation/deallocation.
[vlc] / modules / video_filter / logo.c
index f3baa53c8b62998adb30fbb28c0cb65807544c0d..6eba7a8c73092e6f0f504c4eab97dc213c634c48 100644 (file)
@@ -61,8 +61,8 @@
 #define POSY_TEXT N_("Y coordinate")
 #define POSY_LONGTEXT N_("Y coordinate of the logo. You can move the logo " \
                 "by left-clicking it." )
-#define TRANS_TEXT N_("Transparency of the logo")
-#define TRANS_LONGTEXT N_("Logo transparency value " \
+#define OPACITY_TEXT N_("Opacity of the logo")
+#define OPACITY_LONGTEXT N_("Logo opacity value " \
   "(from 0 for full transparency to 255 for full opacity)." )
 #define POS_TEXT N_("Logo position")
 #define POS_LONGTEXT N_( \
@@ -70,6 +70,8 @@
   "(0=center, 1=left, 2=right, 4=top, 8=bottom, you can " \
   "also use combinations of these values, eg 6 = top-right).")
 
+#define LOGO_HELP N_("Use a local picture as logo on the video")
+
 #define CFG_PREFIX "logo-"
 
 static const int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
@@ -84,7 +86,7 @@ static void Close    ( vlc_object_t * );
 vlc_module_begin ()
     set_category( CAT_VIDEO )
     set_subcategory( SUBCAT_VIDEO_SUBPIC )
-
+    set_help(LOGO_HELP)
     set_capability( "sub filter", 0 )
     set_callbacks( OpenSub, Close )
     set_description( N_("Logo sub filter") )
@@ -97,8 +99,8 @@ vlc_module_begin ()
     /* default to 1000 ms per image, continuously cycle through them */
     add_integer( CFG_PREFIX "delay", 1000, NULL, DELAY_TEXT, DELAY_LONGTEXT, true )
     add_integer( CFG_PREFIX "repeat", -1, NULL, REPEAT_TEXT, REPEAT_LONGTEXT, true )
-    add_integer_with_range( CFG_PREFIX "transparency", 255, 0, 255, NULL,
-        TRANS_TEXT, TRANS_LONGTEXT, false )
+    add_integer_with_range( CFG_PREFIX "opacity", 255, 0, 255, NULL,
+        OPACITY_TEXT, OPACITY_LONGTEXT, false )
     add_integer( CFG_PREFIX "position", -1, NULL, POS_TEXT, POS_LONGTEXT, false )
         change_integer_list( pi_pos_values, ppsz_pos_descriptions, NULL )
 
@@ -121,7 +123,6 @@ vlc_module_end ()
  */
 typedef struct
 {
-    char *psz_file;    /* candidate for deletion -- not needed */
     int i_delay;       /* -1 means use default delay */
     int i_alpha;       /* -1 means use default alpha */
     picture_t *p_pic;
@@ -170,7 +171,7 @@ struct filter_sys_t
 };
 
 static const char *const ppsz_filter_options[] = {
-    "file", "x", "y", "delay", "repeat", "transparency", "position", NULL
+    "file", "x", "y", "delay", "repeat", "opacity", "position", NULL
 };
 
 static const char *const ppsz_filter_callbacks[] = {
@@ -178,7 +179,7 @@ static const char *const ppsz_filter_callbacks[] = {
     "logo-x",
     "logo-y",
     "logo-position",
-    "logo-transparency",
+    "logo-opacity",
     "logo-repeat",
     NULL
 };
@@ -268,13 +269,10 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub )
     if( *psz_filename == '\0' )
         msg_Warn( p_this, "no logo file specified" );
 
-    p_list->i_alpha = var_CreateGetIntegerCommand( p_filter,
-                                                        "logo-transparency");
+    p_list->i_alpha = var_CreateGetIntegerCommand( p_filter, "logo-opacity");
     p_list->i_alpha = __MAX( __MIN( p_list->i_alpha, 255 ), 0 );
-    p_list->i_delay =
-        var_CreateGetIntegerCommand( p_filter, "logo-delay" );
-    p_list->i_repeat =
-        var_CreateGetIntegerCommand( p_filter, "logo-repeat" );
+    p_list->i_delay = var_CreateGetIntegerCommand( p_filter, "logo-delay" );
+    p_list->i_repeat = var_CreateGetIntegerCommand( p_filter, "logo-repeat" );
 
     p_sys->i_pos = var_CreateGetIntegerCommand( p_filter, "logo-position" );
     p_sys->i_pos_x = var_CreateGetIntegerCommand( p_filter, "logo-x" );
@@ -301,7 +299,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub )
     else
     {
         p_filter->pf_video_filter = FilterVideo;
-        p_filter->pf_mouse = Mouse;
+        p_filter->pf_video_mouse = Mouse;
     }
 
     free( psz_filename );
@@ -384,7 +382,6 @@ static subpicture_t *FilterSub( filter_t *p_filter, mtime_t date )
     /* Create new SPU region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_CODEC_YUVA;
-    fmt.i_aspect = VOUT_ASPECT_FACTOR;
     fmt.i_sar_num = fmt.i_sar_den = 1;
     fmt.i_width = fmt.i_visible_width = p_pic->p[Y_PLANE].i_visible_pitch;
     fmt.i_height = fmt.i_visible_height = p_pic->p[Y_PLANE].i_visible_lines;
@@ -579,7 +576,7 @@ static int LogoCallback( vlc_object_t *p_this, char const *psz_var,
     {
         p_sys->i_pos = newval.i_int;
     }
-    else if ( !strcmp( psz_var, "logo-transparency" ) )
+    else if ( !strcmp( psz_var, "logo-opacity" ) )
     {
         p_list->i_alpha = __MAX( __MIN( newval.i_int, 255 ), 0 );
     }
@@ -596,7 +593,7 @@ static int LogoCallback( vlc_object_t *p_this, char const *psz_var,
 /**
  * It loads the logo image into memory.
  */
-static picture_t *LoadImage( vlc_object_t *p_this, char *psz_filename )
+static picture_t *LoadImage( vlc_object_t *p_this, const char *psz_filename )
 {
     if( !psz_filename )
         return NULL;
@@ -620,22 +617,23 @@ static picture_t *LoadImage( vlc_object_t *p_this, char *psz_filename )
 /**
  * It loads the logo images into memory.
  *
- * Read the logo-file input switch, obtaining a list of images and associated
- * durations and transparencies.  Store the image(s), and times.  An image
- * without a stated time or transparency will use the logo-delay and
- * logo-transparency values.
+ * Read the logo-file input switch, obtaining a list of images and
+ * associated durations and transparencies. Store the image(s), and
+ * times. An image without a stated time or opacity will use the
+ * logo-delay and logo-opacity values.
  */
 static void LogoListLoad( vlc_object_t *p_this, logo_list_t *p_logo_list,
                           const char *psz_filename )
 {
     char *psz_list; /* the list: <logo>[,[<delay>[,[<alpha>]]]][;...] */
+    char *psz_original;
     unsigned int i;
     logo_t *p_logo;         /* the parsing's result */
 
     p_logo_list->i_counter = 0;
     p_logo_list->i_next_pic = 0;
 
-    psz_list = strdup( psz_filename );
+    psz_original = psz_list = strdup( psz_filename );
     if( !psz_list )
         abort();
 
@@ -678,27 +676,23 @@ static void LogoListLoad( vlc_object_t *p_this, logo_list_t *p_logo_list,
                 *p_c = '\0';
         }
 
-        p_logo[i].psz_file = strdup( psz_list );
-        p_logo[i].p_pic = LoadImage( p_this, p_logo[i].psz_file );
-
+        msg_Dbg( p_this, "logo file name %s, delay %d, alpha %d",
+                 psz_list, p_logo[i].i_delay, p_logo[i].i_alpha );
+        p_logo[i].p_pic = LoadImage( p_this, psz_list );
         if( !p_logo[i].p_pic )
         {
             msg_Warn( p_this, "error while loading logo %s, will be skipped",
-                      p_logo[i].psz_file );
+                      psz_list );
         }
 
         if( p_c )
             psz_list = &p_c[1];
     }
 
-    for( i = 0; i < p_logo_list->i_count; i++ )
-    {
-       msg_Dbg( p_this, "logo file name %s, delay %d, alpha %d",
-                p_logo[i].psz_file, p_logo[i].i_delay, p_logo[i].i_alpha );
-    }
-
     /* initialize so that on the first update it will wrap back to 0 */
     p_logo_list->i_counter = p_logo_list->i_count - 1;
+
+    free( psz_original );
 }
 
 /**
@@ -710,12 +704,8 @@ static void LogoListUnload( logo_list_t *p_list )
     {
         logo_t *p_logo = &p_list->p_logo[i];
 
-        free( p_logo->psz_file );
         if( p_logo->p_pic )
-        {
             picture_Release( p_logo->p_pic );
-            p_logo->p_pic = NULL;
-        }
     }
     free( p_list->p_logo );
 }