[vlc-devel] [PATCH 1/2] picture: allow a NULL video_format_t in picture_Setup

Steve Lhomme robux4 at videolabs.io
Wed Jul 12 16:53:36 CEST 2017


The one from the picture will be used. That will avoid silly mistakes.
---
 include/vlc_picture.h | 2 ++
 src/misc/picture.c    | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/vlc_picture.h b/include/vlc_picture.h
index e25374634f..eb75bb937a 100644
--- a/include/vlc_picture.h
+++ b/include/vlc_picture.h
@@ -223,6 +223,8 @@ VLC_API int picture_Export( vlc_object_t *p_obj, block_t **pp_image, video_forma
  * It will return VLC_EGENERIC if the core does not understand the requested
  * format.
  *
+ * If the video_format_t is NULL, the one from the picture_t will be used.
+ *
  * It can be useful to get the properties of planes.
  */
 VLC_API int picture_Setup( picture_t *, const video_format_t * );
diff --git a/src/misc/picture.c b/src/misc/picture.c
index 59d0aaa359..73a3ef7074 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -149,6 +149,8 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
 
     p_picture->i_nb_fields = 2;
 
+    if ( fmt == NULL )
+        fmt = &p_picture->format;
     video_format_Setup( &p_picture->format, fmt->i_chroma, fmt->i_width, fmt->i_height,
                         fmt->i_visible_width, fmt->i_visible_height,
                         fmt->i_sar_num, fmt->i_sar_den );
@@ -225,7 +227,7 @@ picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_r
     p_picture->format = fmt;
 
     /* Make sure the real dimensions are a multiple of 16 */
-    if( picture_Setup( p_picture, &fmt ) )
+    if( picture_Setup( p_picture, NULL ) )
     {
         free( p_picture );
         return NULL;
-- 
2.12.1



More information about the vlc-devel mailing list