]> git.sesse.net Git - vlc/blobdiff - modules/video_output/image.c
Merge branch 'df-for-upstream' of git://repo.or.cz/vlc/davidf-public
[vlc] / modules / video_output / image.c
index 57656ecb92e3de3d216887e8fbac1acad5d4511b..3bcecbcbe8272bda2b86b1af99548373b5f878e5 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>
 
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_vout.h>
 #include <vlc_interface.h>
 
@@ -73,37 +77,37 @@ static void Display   ( vout_thread_t *, picture_t * );
                             "creating one file per image. In this case, " \
                              "the number is not appended to the filename." )
 
-static const char *psz_format_list[] = { "png", "jpeg" };
-static const char *psz_format_list_text[] = { "PNG", "JPEG" };
+static const char *const psz_format_list[] = { "png", "jpeg" };
+static const char *const psz_format_list_text[] = { "PNG", "JPEG" };
 
 #define CFG_PREFIX "image-out-"
 
 vlc_module_begin( );
-    set_shortname( _( "Image file" ) );
-    set_description( _( "Image video output" ) );
+    set_shortname( N_( "Image file" ) );
+    set_description( N_( "Image video output" ) );
     set_category( CAT_VIDEO );
     set_subcategory( SUBCAT_VIDEO_VOUT );
     set_capability( "video output", 0 );
 
     add_string(  CFG_PREFIX "format", "png", NULL,
-                 FORMAT_TEXT, FORMAT_LONGTEXT, VLC_FALSE );
+                 FORMAT_TEXT, FORMAT_LONGTEXT, false );
     change_string_list( psz_format_list, psz_format_list_text, 0 );
-    add_integer( CFG_PREFIX "width", -1, NULL,
-                 WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE );
-        add_deprecated( "image-width", VLC_FALSE ); /* since 0.9.0 */
-    add_integer( CFG_PREFIX "height", -1, NULL,
-                 HEIGHT_TEXT, HEIGHT_LONGTEXT, VLC_TRUE );
-        add_deprecated( "image-height", VLC_FALSE ); /* since 0.9.0 */
+    add_integer( CFG_PREFIX "width", 0, NULL,
+                 WIDTH_TEXT, WIDTH_LONGTEXT, true );
+        add_deprecated_alias( "image-width" ); /* since 0.9.0 */
+    add_integer( CFG_PREFIX "height", 0, NULL,
+                 HEIGHT_TEXT, HEIGHT_LONGTEXT, true );
+        add_deprecated_alias( "image-height" ); /* since 0.9.0 */
     add_integer( CFG_PREFIX "ratio", 3, NULL,
-                 RATIO_TEXT, RATIO_LONGTEXT, VLC_FALSE );
+                 RATIO_TEXT, RATIO_LONGTEXT, false );
     add_string(  CFG_PREFIX "prefix", "img", NULL,
-                 PREFIX_TEXT, PREFIX_LONGTEXT, VLC_FALSE );
+                 PREFIX_TEXT, PREFIX_LONGTEXT, false );
     add_bool(    CFG_PREFIX "replace", 0, NULL,
-                 REPLACE_TEXT, REPLACE_LONGTEXT, VLC_FALSE );
+                 REPLACE_TEXT, REPLACE_LONGTEXT, false );
     set_callbacks( Create, Destroy );
 vlc_module_end();
 
-static const char *ppsz_vout_options[] = {
+static const char *const ppsz_vout_options[] = {
     "format", "width", "height", "ratio", "prefix", "replace", NULL
 };
 
@@ -116,16 +120,16 @@ 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 */
 
-    vlc_bool_t  b_replace;
+    bool  b_replace;
 
-    vlc_bool_t b_time;
-    vlc_bool_t b_meta;
+    bool b_time;
+    bool b_meta;
 
     image_handler_t *p_image;
 };
@@ -150,9 +154,9 @@ static int Create( vlc_object_t *p_this )
     p_vout->p_sys->psz_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;
+                            ? true : false;
     p_vout->p_sys->b_meta = strchr( p_vout->p_sys->psz_prefix, '$' )
-                            ? VLC_TRUE : VLC_FALSE;
+                            ? true : false;
     p_vout->p_sys->psz_format =
             var_CreateGetString( p_this, CFG_PREFIX "format" );
     p_vout->p_sys->i_width =
@@ -170,6 +174,7 @@ static int Create( vlc_object_t *p_this )
     {
         msg_Err( p_this, "unable to create image handler") ;
         FREENULL( p_vout->p_sys->psz_prefix );
+        FREENULL( p_vout->p_sys->psz_format );
         FREENULL( p_vout->p_sys );
         return VLC_EGENERIC;
     }
@@ -288,9 +293,9 @@ 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 )
@@ -311,6 +316,9 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic )
         psz_prefix = psz_tmp;
     psz_filename = (char *)malloc( 10 + strlen( psz_prefix )
                                       + strlen( p_vout->p_sys->psz_format ) );
+    if( !psz_filename )
+        return;
+
     if( p_vout->p_sys->b_replace )
     {
         sprintf( psz_filename, "%s.%s", psz_prefix,
@@ -336,4 +344,5 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic )
 
 static void End( vout_thread_t *p_vout )
 {
+    VLC_UNUSED(p_vout);
 }