]> git.sesse.net Git - vlc/blobdiff - modules/video_output/image.c
- Cleanup and fixes deprecated options:
[vlc] / modules / video_output / image.c
index a80e55d49b6845e2f401ba20fe972c99b513c560..0336a54d6ffccf616125f851d8360307f4830b2e 100644 (file)
@@ -76,6 +76,8 @@ static void Display   ( vout_thread_t *, picture_t * );
 static const char *psz_format_list[] = { "png", "jpeg" };
 static const char *psz_format_list_text[] = { "PNG", "JPEG" };
 
+#define CFG_PREFIX "image-out-"
+
 vlc_module_begin( );
     set_shortname( _( "Image file" ) );
     set_description( _( "Image video output" ) );
@@ -83,22 +85,28 @@ vlc_module_begin( );
     set_subcategory( SUBCAT_VIDEO_VOUT );
     set_capability( "video output", 0 );
 
-    add_string( "image-out-format", "png", NULL,  FORMAT_TEXT, FORMAT_LONGTEXT,
-                                                  VLC_FALSE );
+    add_string(  CFG_PREFIX "format", "png", NULL,
+                 FORMAT_TEXT, FORMAT_LONGTEXT, VLC_FALSE );
     change_string_list( psz_format_list, psz_format_list_text, 0 );
-    add_integer( "image-width", -1, NULL,  WIDTH_TEXT, WIDTH_LONGTEXT,
-                                                  VLC_TRUE );
-    add_integer( "image-height", -1, NULL,  HEIGHT_TEXT, HEIGHT_LONGTEXT,
-                                                  VLC_TRUE );
-    add_integer( "image-out-ratio", 3, NULL, RATIO_TEXT, RATIO_LONGTEXT,
-                                                  VLC_FALSE );
-    add_string( "image-out-prefix", "img", NULL, PREFIX_TEXT, PREFIX_LONGTEXT,
-                                                  VLC_FALSE );
-    add_bool( "image-out-replace", 0, NULL, REPLACE_TEXT, REPLACE_LONGTEXT,
-                                                  VLC_FALSE );
+    add_integer( CFG_PREFIX "width", -1, NULL,
+                 WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE );
+        add_deprecated_alias( "image-width" ); /* since 0.9.0 */
+    add_integer( CFG_PREFIX "height", -1, NULL,
+                 HEIGHT_TEXT, HEIGHT_LONGTEXT, VLC_TRUE );
+        add_deprecated_alias( "image-height" ); /* since 0.9.0 */
+    add_integer( CFG_PREFIX "ratio", 3, NULL,
+                 RATIO_TEXT, RATIO_LONGTEXT, VLC_FALSE );
+    add_string(  CFG_PREFIX "prefix", "img", NULL,
+                 PREFIX_TEXT, PREFIX_LONGTEXT, VLC_FALSE );
+    add_bool(    CFG_PREFIX "replace", 0, NULL,
+                 REPLACE_TEXT, REPLACE_LONGTEXT, VLC_FALSE );
     set_callbacks( Create, Destroy );
 vlc_module_end();
 
+static const char *ppsz_vout_options[] = {
+    "format", "width", "height", "ratio", "prefix", "replace", NULL
+};
+
 /*****************************************************************************
  * vout_sys_t: video output descriptor
  *****************************************************************************/
@@ -108,8 +116,8 @@ struct vout_sys_t
     char        *psz_format;          /* Format */
     int         i_ratio;         /* Image ratio */
 
-    int         i_width;         /* Image width */
-    int         i_height;       /* Image height */
+    unsigned int i_width;        /* Image width */
+    unsigned int i_height;      /* Image height */
 
     int         i_current;     /* Current image */
     int         i_frames;   /* Number of frames */
@@ -136,22 +144,25 @@ static int Create( vlc_object_t *p_this )
     if( ! p_vout->p_sys )
         return VLC_ENOMEM;
 
+    config_ChainParse( p_vout, CFG_PREFIX, ppsz_vout_options,
+                       p_vout->p_cfg );
+
     p_vout->p_sys->psz_prefix =
-            var_CreateGetString( p_this, "image-out-prefix" );
+            var_CreateGetString( p_this, CFG_PREFIX "prefix" );
     p_vout->p_sys->b_time = strchr( p_vout->p_sys->psz_prefix, '%' )
                             ? VLC_TRUE : VLC_FALSE;
     p_vout->p_sys->b_meta = strchr( p_vout->p_sys->psz_prefix, '$' )
                             ? VLC_TRUE : VLC_FALSE;
     p_vout->p_sys->psz_format =
-            var_CreateGetString( p_this, "image-out-format" );
+            var_CreateGetString( p_this, CFG_PREFIX "format" );
     p_vout->p_sys->i_width =
-            var_CreateGetInteger( p_this, "image-width" );
+            var_CreateGetInteger( p_this, CFG_PREFIX "width" );
     p_vout->p_sys->i_height =
-            var_CreateGetInteger( p_this, "image-height" );
+            var_CreateGetInteger( p_this, CFG_PREFIX "height" );
     p_vout->p_sys->i_ratio =
-            var_CreateGetInteger( p_this, "image-out-ratio" );
+            var_CreateGetInteger( p_this, CFG_PREFIX "ratio" );
     p_vout->p_sys->b_replace =
-            var_CreateGetBool( p_this, "image-out-replace" );
+            var_CreateGetBool( p_this, CFG_PREFIX "replace" );
     p_vout->p_sys->i_current = 0;
     p_vout->p_sys->p_image = image_HandlerCreate( p_vout );
 
@@ -257,12 +268,15 @@ static void Destroy( vlc_object_t *p_this )
  *****************************************************************************/
 static void Display( vout_thread_t *p_vout, picture_t *p_pic )
 {
-    video_format_t fmt_in = {0}, fmt_out = {0};
+    video_format_t fmt_in, fmt_out;
 
     char *psz_filename;
     char *psz_prefix;
     char *psz_tmp;
 
+    memset( &fmt_in, 0, sizeof( fmt_in ) );
+    memset( &fmt_out, 0, sizeof( fmt_out ) );
+
     if( p_vout->p_sys->i_frames % p_vout->p_sys->i_ratio != 0 )
     {
         p_vout->p_sys->i_frames++;
@@ -274,18 +288,22 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic )
     fmt_in.i_width = p_vout->render.i_width;
     fmt_in.i_height = p_vout->render.i_height;
 
-    fmt_out.i_width = p_vout->p_sys->i_width > 0 ? p_vout->p_sys->i_width :
+    fmt_out.i_width = (p_vout->p_sys->i_width > 0) ? p_vout->p_sys->i_width :
                                                    p_vout->render.i_width;
-    fmt_out.i_height = p_vout->p_sys->i_height > 0 ? p_vout->p_sys->i_height :
+    fmt_out.i_height = (p_vout->p_sys->i_height > 0) ? p_vout->p_sys->i_height :
                                                      p_vout->render.i_height;
 
     if( p_vout->p_sys->b_time )
+    {
         psz_tmp = str_format_time( p_vout->p_sys->psz_prefix );
+        path_sanitize( psz_tmp );
+    }
     else
         psz_tmp = p_vout->p_sys->psz_prefix;
     if( p_vout->p_sys->b_meta )
     {
         psz_prefix = str_format_meta( p_vout, psz_tmp );
+        path_sanitize( psz_prefix );
         if( p_vout->p_sys->b_time )
             free( psz_tmp );
     }