[vlc-commits] image: remove the source video_format parameter from image_ReadUrl()

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


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Feb  7 16:13:24 2019 +0100| [62904dbc9215cb9d63c3b61e4b1d92d2aec3538c] | committer: Steve Lhomme

image: remove the source video_format parameter from image_ReadUrl()

It's always an empty video format with an 0 chroma. The format will be known
from the MIME type or the file probing.

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

 include/vlc_image.h                      |  4 ++--
 modules/access/screen/screen.c           |  5 ++---
 modules/gui/skins2/src/file_bitmap.cpp   |  5 ++---
 modules/spu/logo.c                       |  5 +----
 modules/spu/rss.c                        |  2 +-
 modules/stream_out/sdi/DBMSDIOutput.cpp  |  9 ++++-----
 modules/video_filter/alphamask.c         |  6 ++----
 modules/video_filter/blendbench.c        |  5 ++---
 modules/video_filter/erase.c             |  6 ++----
 modules/video_output/decklink.cpp        |  9 ++++-----
 src/misc/image.c                         | 25 ++++++++++---------------
 src/video_output/vout_spuregion_helper.h |  5 +----
 12 files changed, 33 insertions(+), 53 deletions(-)

diff --git a/include/vlc_image.h b/include/vlc_image.h
index 1b917d0676..fafe0fbbd9 100644
--- a/include/vlc_image.h
+++ b/include/vlc_image.h
@@ -41,7 +41,7 @@ struct image_handler_t
                                   const video_format_t *, const uint8_t *, size_t,
                                   video_format_t * );
     picture_t * (*pf_read_url)  ( image_handler_t *, const char *,
-                                  const video_format_t *, video_format_t * );
+                                  video_format_t * );
     block_t * (*pf_write)       ( image_handler_t *, picture_t *,
                                   const video_format_t *, const video_format_t * );
     int (*pf_write_url)         ( image_handler_t *, picture_t *,
@@ -66,7 +66,7 @@ VLC_API void image_HandlerDelete( image_handler_t * );
 
 #define image_Read( a, b, c, d ) a->pf_read( a, b, c, NULL, 0, d )
 #define image_ReadExt( a, b, c, d, e, f ) a->pf_read( a, b, c, d, e, f )
-#define image_ReadUrl( a, b, c, d ) a->pf_read_url( a, b, c, d )
+#define image_ReadUrl( a, b, c ) a->pf_read_url( a, b, c )
 #define image_Write( a, b, c, d ) a->pf_write( a, b, c, d )
 #define image_WriteUrl( a, b, c, d, e ) a->pf_write_url( a, b, c, d, e )
 #define image_Convert( a, b, c, d ) a->pf_convert( a, b, c, d )
diff --git a/modules/access/screen/screen.c b/modules/access/screen/screen.c
index 12dcc5a81b..bfe42968fd 100644
--- a/modules/access/screen/screen.c
+++ b/modules/access/screen/screen.c
@@ -224,16 +224,15 @@ static int Open( vlc_object_t *p_this )
     if( mouseurl )
     {
         image_handler_t *p_image;
-        video_format_t fmt_in, fmt_out;
+        video_format_t fmt_out;
         msg_Dbg( p_demux, "Using %s for the mouse pointer image", mouseurl );
-        memset( &fmt_in, 0, sizeof( fmt_in ) );
         memset( &fmt_out, 0, sizeof( fmt_out ) );
         fmt_out.i_chroma = VLC_CODEC_RGBA;
         p_image = image_HandlerCreate( p_demux );
         if( p_image )
         {
             p_sys->p_mouse =
-                image_ReadUrl( p_image, mouseurl, &fmt_in, &fmt_out );
+                image_ReadUrl( p_image, mouseurl, &fmt_out );
             image_HandlerDelete( p_image );
         }
         if( !p_sys->p_mouse )
diff --git a/modules/gui/skins2/src/file_bitmap.cpp b/modules/gui/skins2/src/file_bitmap.cpp
index d89bb69267..b7b4859cda 100644
--- a/modules/gui/skins2/src/file_bitmap.cpp
+++ b/modules/gui/skins2/src/file_bitmap.cpp
@@ -36,10 +36,9 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler,
     GenericBitmap( pIntf, nbFrames, fps, nbLoops ), m_width( 0 ), m_height( 0 ),
     m_pData( NULL )
 {
-    video_format_t fmt_in, fmt_out;
+    video_format_t fmt_out;
     picture_t *pPic;
 
-    video_format_Init( &fmt_in, 0 );
     video_format_Init( &fmt_out, VLC_CODEC_RGBA );
 
     if( strstr( fileName.c_str(), "://" ) == NULL )
@@ -51,7 +50,7 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler,
         free( psz_uri );
     }
 
-    pPic = image_ReadUrl( pImageHandler, fileName.c_str(), &fmt_in, &fmt_out );
+    pPic = image_ReadUrl( pImageHandler, fileName.c_str(), &fmt_out );
     if( !pPic )
         return;
 
diff --git a/modules/spu/logo.c b/modules/spu/logo.c
index 82223df089..bff4bfe1b1 100644
--- a/modules/spu/logo.c
+++ b/modules/spu/logo.c
@@ -608,9 +608,6 @@ static picture_t *LoadImage( vlc_object_t *p_this, const char *psz_filename )
     if( !psz_filename )
         return NULL;
 
-    video_format_t fmt_in;
-    video_format_Init( &fmt_in, 0 );
-
     video_format_t fmt_out;
     video_format_Init( &fmt_out, VLC_CODEC_YUVA );
 
@@ -619,7 +616,7 @@ static picture_t *LoadImage( vlc_object_t *p_this, const char *psz_filename )
         return NULL;
 
     char *psz_url = vlc_path2uri( psz_filename, NULL );
-    picture_t *p_pic = image_ReadUrl( p_image, psz_url, &fmt_in, &fmt_out );
+    picture_t *p_pic = image_ReadUrl( p_image, psz_url, &fmt_out );
     free( psz_url );
     image_HandlerDelete( p_image );
 
diff --git a/modules/spu/rss.c b/modules/spu/rss.c
index bd70b0e100..a41fc967ce 100644
--- a/modules/spu/rss.c
+++ b/modules/spu/rss.c
@@ -560,7 +560,7 @@ static picture_t *LoadImage( filter_t *p_filter, const char *psz_url )
     memset( &fmt_out, 0, sizeof(video_format_t) );
 
     fmt_out.i_chroma = VLC_CODEC_YUVA;
-    p_orig = image_ReadUrl( p_handler, psz_url, &fmt_in, &fmt_out );
+    p_orig = image_ReadUrl( p_handler, psz_url, &fmt_out );
 
     if( !p_orig )
     {
diff --git a/modules/stream_out/sdi/DBMSDIOutput.cpp b/modules/stream_out/sdi/DBMSDIOutput.cpp
index 5bbbcdf177..d54d2ce688 100644
--- a/modules/stream_out/sdi/DBMSDIOutput.cpp
+++ b/modules/stream_out/sdi/DBMSDIOutput.cpp
@@ -735,17 +735,16 @@ picture_t * DBMSDIOutput::CreateNoSignalPicture(const char *psz_file, const vide
     image_handler_t *img = image_HandlerCreate(p_stream);
     if (img)
     {
-        video_format_t in, dummy;
-        video_format_Init(&dummy, 0);
+        video_format_t in;
         video_format_Init(&in, 0);
         video_format_Setup(&in, 0,
                            fmt->i_width, fmt->i_height,
                            fmt->i_width, fmt->i_height, 1, 1);
 
-        picture_t *png = image_ReadUrl(img, psz_file, &dummy, &in);
+        picture_t *png = image_ReadUrl(img, psz_file, &in);
         if (png)
         {
-            video_format_Clean(&dummy);
+            video_format_t dummy;
             video_format_Copy(&dummy, fmt);
             p_pic = image_Convert(img, png, &in, &dummy);
             if(!video_format_IsSimilar(&dummy, fmt))
@@ -754,10 +753,10 @@ picture_t * DBMSDIOutput::CreateNoSignalPicture(const char *psz_file, const vide
                 p_pic = NULL;
             }
             picture_Release(png);
+            video_format_Clean(&dummy);
         }
         image_HandlerDelete(img);
         video_format_Clean(&in);
-        video_format_Clean(&dummy);
     }
     return p_pic;
 }
diff --git a/modules/video_filter/alphamask.c b/modules/video_filter/alphamask.c
index a928459585..7268496010 100644
--- a/modules/video_filter/alphamask.c
+++ b/modules/video_filter/alphamask.c
@@ -175,17 +175,15 @@ static void LoadMask( filter_t *p_filter, const char *psz_filename )
 {
     filter_sys_t *p_sys = p_filter->p_sys;
     image_handler_t *p_image;
-    video_format_t fmt_in, fmt_out;
-    video_format_Init( &fmt_in, 0 );
+    video_format_t fmt_out;
     video_format_Init( &fmt_out, VLC_CODEC_YUVA );
     if( p_sys->p_mask )
         picture_Release( p_sys->p_mask );
     p_image = image_HandlerCreate( p_filter );
     char *psz_url = vlc_path2uri( psz_filename, NULL );
     p_sys->p_mask =
-        image_ReadUrl( p_image, psz_url, &fmt_in, &fmt_out );
+        image_ReadUrl( p_image, psz_url, &fmt_out );
     free( psz_url );
-    video_format_Clean( &fmt_in );
     video_format_Clean( &fmt_out );
     image_HandlerDelete( p_image );
 }
diff --git a/modules/video_filter/blendbench.c b/modules/video_filter/blendbench.c
index f204fd6d09..a2c4d35f3d 100644
--- a/modules/video_filter/blendbench.c
+++ b/modules/video_filter/blendbench.c
@@ -122,14 +122,13 @@ static int blendbench_LoadImage( vlc_object_t *p_this, picture_t **pp_pic,
                                  vlc_fourcc_t i_chroma, char *psz_file, const char *psz_name )
 {
     image_handler_t *p_image;
-    video_format_t fmt_in, fmt_out;
+    video_format_t fmt_out;
 
-    memset( &fmt_in, 0, sizeof(video_format_t) );
     memset( &fmt_out, 0, sizeof(video_format_t) );
 
     fmt_out.i_chroma = i_chroma;
     p_image = image_HandlerCreate( p_this );
-    *pp_pic = image_ReadUrl( p_image, psz_file, &fmt_in, &fmt_out );
+    *pp_pic = image_ReadUrl( p_image, psz_file, &fmt_out );
     image_HandlerDelete( p_image );
 
     if( *pp_pic == NULL )
diff --git a/modules/video_filter/erase.c b/modules/video_filter/erase.c
index b71f90ad61..91a6b7bf89 100644
--- a/modules/video_filter/erase.c
+++ b/modules/video_filter/erase.c
@@ -98,15 +98,13 @@ static void LoadMask( filter_t *p_filter, const char *psz_filename )
 {
     filter_sys_t *p_sys = p_filter->p_sys;
     image_handler_t *p_image;
-    video_format_t fmt_in, fmt_out;
+    video_format_t fmt_out;
     picture_t *p_old_mask = p_sys->p_mask;
-    video_format_Init( &fmt_in, 0 );
     video_format_Init( &fmt_out, VLC_CODEC_YUVA );
     p_image = image_HandlerCreate( p_filter );
     char *psz_url = vlc_path2uri( psz_filename, NULL );
-    p_sys->p_mask = image_ReadUrl( p_image, psz_url, &fmt_in, &fmt_out );
+    p_sys->p_mask = image_ReadUrl( p_image, psz_url, &fmt_out );
     free( psz_url );
-    video_format_Clean( &fmt_in );
     video_format_Clean( &fmt_out );
     if( p_sys->p_mask )
     {
diff --git a/modules/video_output/decklink.cpp b/modules/video_output/decklink.cpp
index 597807d163..e212152a61 100644
--- a/modules/video_output/decklink.cpp
+++ b/modules/video_output/decklink.cpp
@@ -436,17 +436,16 @@ static picture_t * CreateNoSignalPicture(vlc_object_t *p_this, const video_forma
         return NULL;
     }
 
-    video_format_t in, dummy;
-    video_format_Init(&dummy, 0);
+    video_format_t in;
     video_format_Init(&in, 0);
     video_format_Setup(&in, 0,
                        fmt->i_width, fmt->i_height,
                        fmt->i_width, fmt->i_height, 1, 1);
 
-    picture_t *png = image_ReadUrl(img, psz_file, &dummy, &in);
+    picture_t *png = image_ReadUrl(img, psz_file, &in);
     if (png)
     {
-        video_format_Clean(&dummy);
+        video_format_t dummy;
         video_format_Copy(&dummy, fmt);
         p_pic = image_Convert(img, png, &in, &dummy);
         if(!video_format_IsSimilar(&dummy, fmt))
@@ -455,10 +454,10 @@ static picture_t * CreateNoSignalPicture(vlc_object_t *p_this, const video_forma
             p_pic = NULL;
         }
         picture_Release(png);
+        video_format_Clean(&dummy);
     }
     image_HandlerDelete(img);
     video_format_Clean(&in);
-    video_format_Clean(&dummy);
 
     return p_pic;
 }
diff --git a/src/misc/image.c b/src/misc/image.c
index 8a841a7189..e987c98bcf 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -63,7 +63,7 @@ static picture_t *ImageRead( image_handler_t *, block_t *,
                              const video_format_t *, const uint8_t *, size_t,
                              video_format_t * );
 static picture_t *ImageReadUrl( image_handler_t *, const char *,
-                                const video_format_t *, video_format_t * );
+                                video_format_t * );
 static block_t *ImageWrite( image_handler_t *, picture_t *,
                             const video_format_t *, const video_format_t * );
 static int ImageWriteUrl( image_handler_t *, picture_t *,
@@ -273,7 +273,6 @@ static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
 }
 
 static picture_t *ImageReadUrl( image_handler_t *p_image, const char *psz_url,
-                                const video_format_t *p_fmt_in,
                                 video_format_t *p_fmt_out )
 {
     block_t *p_block;
@@ -301,22 +300,18 @@ static picture_t *ImageReadUrl( image_handler_t *p_image, const char *psz_url,
         goto error;
 
     video_format_t fmtin;
-    video_format_Init( &fmtin, p_fmt_in->i_chroma );
-    video_format_Copy( &fmtin, p_fmt_in );
+    video_format_Init( &fmtin, 0 ); /* no chroma, the MIME type of the picture will be used */
 
+    char *psz_mime = stream_MimeType( p_stream );
+    if( psz_mime != NULL )
+    {
+        fmtin.i_chroma = image_Mime2Fourcc( psz_mime );
+        free( psz_mime );
+    }
     if( !fmtin.i_chroma )
     {
-        char *psz_mime = stream_MimeType( p_stream );
-        if( psz_mime != NULL )
-        {
-            fmtin.i_chroma = image_Mime2Fourcc( psz_mime );
-            free( psz_mime );
-        }
-        if( !fmtin.i_chroma )
-        {
-           /* Try to guess format from file name */
-           fmtin.i_chroma = image_Ext2Fourcc( psz_url );
-        }
+       /* Try to guess format from file name */
+       fmtin.i_chroma = image_Ext2Fourcc( psz_url );
     }
     vlc_stream_Delete( p_stream );
 
diff --git a/src/video_output/vout_spuregion_helper.h b/src/video_output/vout_spuregion_helper.h
index 451b911915..c547d3a6f4 100644
--- a/src/video_output/vout_spuregion_helper.h
+++ b/src/video_output/vout_spuregion_helper.h
@@ -66,16 +66,13 @@ static inline subpicture_region_t *
 spuregion_CreateFromPicture( vlc_object_t *p_this, video_format_t *p_fmt,
                              const char *psz_uri )
 {
-    video_format_t fmt_in;
-    video_format_Init( &fmt_in, 0 );
-
     picture_t *p_pic = NULL;
     int i_flags = p_this->obj.flags;
     p_this->obj.flags |= OBJECT_FLAGS_NOINTERACT|OBJECT_FLAGS_QUIET;
     image_handler_t *p_image = image_HandlerCreate( p_this );
     if( p_image )
     {
-        p_pic = image_ReadUrl( p_image, psz_uri, &fmt_in, p_fmt );
+        p_pic = image_ReadUrl( p_image, psz_uri, p_fmt );
         image_HandlerDelete( p_image );
     }
     p_this->obj.flags = i_flags;



More information about the vlc-commits mailing list