From 629aa1c03d9e82eff0444f3498738bfcdc629d16 Mon Sep 17 00:00:00 2001 From: Francois Cartegnie Date: Mon, 19 Nov 2018 13:25:22 +0100 Subject: [PATCH] vlc_image: constify ImageReadUrl parameter --- include/vlc_image.h | 2 +- src/misc/image.c | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/vlc_image.h b/include/vlc_image.h index 5e91c6532e..dc44cb4319 100644 --- a/include/vlc_image.h +++ b/include/vlc_image.h @@ -42,7 +42,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 *, - video_format_t *, video_format_t * ); + const 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 *, diff --git a/src/misc/image.c b/src/misc/image.c index 8e9f6fa3a9..8467dc93e7 100644 --- a/src/misc/image.c +++ b/src/misc/image.c @@ -64,7 +64,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 *, - video_format_t *, video_format_t * ); + const 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 *, @@ -277,7 +277,7 @@ 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, - video_format_t *p_fmt_in, + const video_format_t *p_fmt_in, video_format_t *p_fmt_out ) { block_t *p_block; @@ -304,24 +304,30 @@ static picture_t *ImageReadUrl( image_handler_t *p_image, const char *psz_url, if( p_block == NULL ) goto error; - if( !p_fmt_in->i_chroma ) + video_format_t fmtin; + video_format_Init( &fmtin, p_fmt_in->i_chroma ); + video_format_Copy( &fmtin, p_fmt_in ); + + if( !fmtin.i_chroma ) { char *psz_mime = stream_MimeType( p_stream ); if( psz_mime != NULL ) { - p_fmt_in->i_chroma = image_Mime2Fourcc( psz_mime ); + 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 ); + } } } vlc_stream_Delete( p_stream ); - if( !p_fmt_in->i_chroma ) - { - /* Try to guess format from file name */ - p_fmt_in->i_chroma = image_Ext2Fourcc( psz_url ); - } - p_pic = ImageRead( p_image, p_block, p_fmt_in, NULL, 0, p_fmt_out ); + p_pic = ImageRead( p_image, p_block, &fmtin, NULL, 0, p_fmt_out ); + + video_format_Clean( &fmtin ); return p_pic; error: -- 2.11.4.GIT