[vlc-commits] image: clean video_format_t input/output usages of image_ReadUrl() callers

Steve Lhomme git at videolan.org
Thu Feb 7 16:36:09 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Feb  7 15:31:24 2019 +0100| [6a5b8756250646c4a64e2106d89955f78eb7e433] | committer: Steve Lhomme

image: clean video_format_t input/output usages of image_ReadUrl() callers

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6a5b8756250646c4a64e2106d89955f78eb7e433
---

 modules/access/screen/screen.c         |  4 ++--
 modules/gui/skins2/src/file_bitmap.cpp |  4 ++++
 modules/spu/logo.c                     |  7 ++++---
 modules/spu/rss.c                      | 11 ++++++-----
 modules/video_filter/blendbench.c      |  4 ++--
 5 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/modules/access/screen/screen.c b/modules/access/screen/screen.c
index bfe42968fd..0b065900c0 100644
--- a/modules/access/screen/screen.c
+++ b/modules/access/screen/screen.c
@@ -226,8 +226,7 @@ static int Open( vlc_object_t *p_this )
         image_handler_t *p_image;
         video_format_t fmt_out;
         msg_Dbg( p_demux, "Using %s for the mouse pointer image", mouseurl );
-        memset( &fmt_out, 0, sizeof( fmt_out ) );
-        fmt_out.i_chroma = VLC_CODEC_RGBA;
+        video_format_Init( &fmt_out, VLC_CODEC_RGBA );
         p_image = image_HandlerCreate( p_demux );
         if( p_image )
         {
@@ -239,6 +238,7 @@ static int Open( vlc_object_t *p_this )
             msg_Err( p_demux, "Failed to open mouse pointer image (%s)",
                      mouseurl );
         free( mouseurl );
+        video_format_Clean( &fmt_out );
     }
 #endif
 
diff --git a/modules/gui/skins2/src/file_bitmap.cpp b/modules/gui/skins2/src/file_bitmap.cpp
index b7b4859cda..658bdc122f 100644
--- a/modules/gui/skins2/src/file_bitmap.cpp
+++ b/modules/gui/skins2/src/file_bitmap.cpp
@@ -52,10 +52,14 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler,
 
     pPic = image_ReadUrl( pImageHandler, fileName.c_str(), &fmt_out );
     if( !pPic )
+    {
+        video_format_Clean( &fmt_out );
         return;
+    }
 
     m_width = fmt_out.i_width;
     m_height = fmt_out.i_height;
+    video_format_Clean( &fmt_out );
 
     m_pData = new uint8_t[m_height * m_width * 4];
 
diff --git a/modules/spu/logo.c b/modules/spu/logo.c
index bff4bfe1b1..efb33695b5 100644
--- a/modules/spu/logo.c
+++ b/modules/spu/logo.c
@@ -608,17 +608,18 @@ static picture_t *LoadImage( vlc_object_t *p_this, const char *psz_filename )
     if( !psz_filename )
         return NULL;
 
-    video_format_t fmt_out;
-    video_format_Init( &fmt_out, VLC_CODEC_YUVA );
-
     image_handler_t *p_image = image_HandlerCreate( p_this );
     if( !p_image )
         return NULL;
 
+    video_format_t fmt_out;
+    video_format_Init( &fmt_out, VLC_CODEC_YUVA );
+
     char *psz_url = vlc_path2uri( psz_filename, NULL );
     picture_t *p_pic = image_ReadUrl( p_image, psz_url, &fmt_out );
     free( psz_url );
     image_HandlerDelete( p_image );
+    video_format_Clean( &fmt_out );
 
     return p_pic;
 }
diff --git a/modules/spu/rss.c b/modules/spu/rss.c
index a41fc967ce..59fb4ead20 100644
--- a/modules/spu/rss.c
+++ b/modules/spu/rss.c
@@ -550,16 +550,14 @@ static subpicture_t *Filter( filter_t *p_filter, vlc_tick_t date )
 static picture_t *LoadImage( filter_t *p_filter, const char *psz_url )
 {
     filter_sys_t *p_sys = p_filter->p_sys;
-    video_format_t fmt_in;
     video_format_t fmt_out;
     picture_t *p_orig;
     picture_t *p_pic = NULL;
     image_handler_t *p_handler = image_HandlerCreate( p_filter );
 
-    memset( &fmt_in, 0, sizeof(video_format_t) );
-    memset( &fmt_out, 0, sizeof(video_format_t) );
+    video_format_Init( &fmt_in, 0 );
+    video_format_Init( &fmt_out, VLC_CODEC_YUVA );
 
-    fmt_out.i_chroma = VLC_CODEC_YUVA;
     p_orig = image_ReadUrl( p_handler, psz_url, &fmt_out );
 
     if( !p_orig )
@@ -568,8 +566,9 @@ static picture_t *LoadImage( filter_t *p_filter, const char *psz_url )
     }
     else if( p_sys->p_style->i_font_size > 0 )
     {
+        video_format_t fmt_in;
+        video_format_Copy( &fmt_in, &fmt_out );
 
-        fmt_in.i_chroma = VLC_CODEC_YUVA;
         fmt_in.i_height = p_orig->p[Y_PLANE].i_visible_lines;
         fmt_in.i_width = p_orig->p[Y_PLANE].i_visible_pitch;
         fmt_out.i_width = p_orig->p[Y_PLANE].i_visible_pitch
@@ -578,6 +577,7 @@ static picture_t *LoadImage( filter_t *p_filter, const char *psz_url )
 
         p_pic = image_Convert( p_handler, p_orig, &fmt_in, &fmt_out );
         picture_Release( p_orig );
+        video_format_Clean( &fmt_in );
         if( !p_pic )
         {
             msg_Warn( p_filter, "Error while converting %s", psz_url );
@@ -588,6 +588,7 @@ static picture_t *LoadImage( filter_t *p_filter, const char *psz_url )
         p_pic = p_orig;
     }
 
+    video_format_Clean( &fmt_out );
     image_HandlerDelete( p_handler );
 
     return p_pic;
diff --git a/modules/video_filter/blendbench.c b/modules/video_filter/blendbench.c
index a2c4d35f3d..02c45efe9e 100644
--- a/modules/video_filter/blendbench.c
+++ b/modules/video_filter/blendbench.c
@@ -124,11 +124,11 @@ static int blendbench_LoadImage( vlc_object_t *p_this, picture_t **pp_pic,
     image_handler_t *p_image;
     video_format_t fmt_out;
 
-    memset( &fmt_out, 0, sizeof(video_format_t) );
+    video_format_Init( &fmt_out, i_chroma );
 
-    fmt_out.i_chroma = i_chroma;
     p_image = image_HandlerCreate( p_this );
     *pp_pic = image_ReadUrl( p_image, psz_file, &fmt_out );
+    video_format_Clean( &fmt_out );
     image_HandlerDelete( p_image );
 
     if( *pp_pic == NULL )



More information about the vlc-commits mailing list