image: remove the source video_format parameter from image_ReadUrl()
authorSteve Lhomme <robux4@ycbcr.xyz>
Thu, 7 Feb 2019 15:13:24 +0000 (16:13 +0100)
committerSteve Lhomme <robux4@ycbcr.xyz>
Thu, 7 Feb 2019 15:35:59 +0000 (16:35 +0100)
It's always an empty video format with an 0 chroma. The format will be known
from the MIME type or the file probing.

12 files changed:
include/vlc_image.h
modules/access/screen/screen.c
modules/gui/skins2/src/file_bitmap.cpp
modules/spu/logo.c
modules/spu/rss.c
modules/stream_out/sdi/DBMSDIOutput.cpp
modules/video_filter/alphamask.c
modules/video_filter/blendbench.c
modules/video_filter/erase.c
modules/video_output/decklink.cpp
src/misc/image.c
src/video_output/vout_spuregion_helper.h

index 1b917d0..fafe0fb 100644 (file)
@@ -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 )
index 12dcc5a..bfe4296 100644 (file)
@@ -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 )
index d89bb69..b7b4859 100644 (file)
@@ -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;
 
index 82223df..bff4bfe 100644 (file)
@@ -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 );
 
index bd70b0e..a41fc96 100644 (file)
@@ -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 )
     {
index 5bbbcdf..d54d2ce 100644 (file)
@@ -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;
 }
index a928459..7268496 100644 (file)
@@ -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 );
 }
index f204fd6..a2c4d35 100644 (file)
@@ -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 )
index b71f90a..91a6b7b 100644 (file)
@@ -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 )
     {
index 597807d..e212152 100644 (file)
@@ -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;
 }
index 8a841a7..e987c98 100644 (file)
@@ -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 );
 
index 451b911..c547d3a 100644 (file)
@@ -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;