[vlc-commits] vlc_image: add extradata as codec parameter

Francois Cartegnie git at videolan.org
Mon Nov 19 14:04:49 CET 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Nov 19 13:21:13 2018 +0100| [f3e7b79981501b560b7b1e20c3a5354aa0b53680] | committer: Francois Cartegnie

vlc_image: add extradata as codec parameter

some pics are now based on h264/hevc/av1 and
require extradata for the decoder.

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

 include/vlc_image.h |  6 ++++--
 src/misc/image.c    | 26 ++++++++++++++++++++------
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/include/vlc_image.h b/include/vlc_image.h
index 2b308fd0e5..5e91c6532e 100644
--- a/include/vlc_image.h
+++ b/include/vlc_image.h
@@ -39,7 +39,8 @@ extern "C" {
 struct image_handler_t
 {
     picture_t * (*pf_read)      ( image_handler_t *, block_t *,
-                                  const video_format_t *, video_format_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 * );
     block_t * (*pf_write)       ( image_handler_t *, picture_t *,
@@ -64,7 +65,8 @@ VLC_API image_handler_t * image_HandlerCreate( vlc_object_t * ) VLC_USED;
 #define image_HandlerCreate( a ) image_HandlerCreate( VLC_OBJECT(a) )
 VLC_API void image_HandlerDelete( image_handler_t * );
 
-#define image_Read( a, b, c, d ) a->pf_read( a, b, c, d )
+#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_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 )
diff --git a/src/misc/image.c b/src/misc/image.c
index beca4e190c..8e9f6fa3a9 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -61,7 +61,8 @@ static inline struct decoder_owner *dec_get_owner( decoder_t *p_dec )
 }
 
 static picture_t *ImageRead( image_handler_t *, block_t *,
-                             const video_format_t *, video_format_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 * );
 static block_t *ImageWrite( image_handler_t *, picture_t *,
@@ -72,7 +73,8 @@ static int ImageWriteUrl( image_handler_t *, picture_t *,
 static picture_t *ImageConvert( image_handler_t *, picture_t *,
                                 const video_format_t *, video_format_t * );
 
-static decoder_t *CreateDecoder( image_handler_t *, const video_format_t * );
+static decoder_t *CreateDecoder( image_handler_t *, const video_format_t *,
+                                 const uint8_t *, size_t );
 static void DeleteDecoder( decoder_t * );
 static encoder_t *CreateEncoder( vlc_object_t *, const video_format_t *,
                                  const video_format_t * );
@@ -140,6 +142,7 @@ static void ImageQueueVideo( decoder_t *p_dec, picture_t *p_pic )
 
 static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
                              const video_format_t *p_fmt_in,
+                             const uint8_t *p_extra, size_t i_extra,
                              video_format_t *p_fmt_out )
 {
     picture_t *p_pic = NULL;
@@ -155,7 +158,8 @@ static picture_t *ImageRead( image_handler_t *p_image, block_t *p_block,
     /* Start a decoder */
     if( !p_image->p_dec )
     {
-        p_image->p_dec = CreateDecoder( p_image, p_fmt_in );
+        p_image->p_dec = CreateDecoder( p_image, p_fmt_in,
+                                        p_extra, i_extra );
         if( !p_image->p_dec )
         {
             block_Release(p_block);
@@ -317,7 +321,7 @@ static picture_t *ImageReadUrl( image_handler_t *p_image, const char *psz_url,
         p_fmt_in->i_chroma = image_Ext2Fourcc( psz_url );
     }
 
-    p_pic = ImageRead( p_image, p_block, p_fmt_in, p_fmt_out );
+    p_pic = ImageRead( p_image, p_block, p_fmt_in, NULL, 0, p_fmt_out );
 
     return p_pic;
 error:
@@ -670,7 +674,8 @@ static picture_t *video_new_buffer( decoder_t *p_dec )
     return picture_NewFromFormat( &p_dec->fmt_out.video );
 }
 
-static decoder_t *CreateDecoder( image_handler_t *p_image, const video_format_t *fmt )
+static decoder_t *CreateDecoder( image_handler_t *p_image, const video_format_t *fmt,
+                                 const uint8_t *p_extra, size_t i_extra )
 {
     decoder_t *p_dec;
     struct decoder_owner *p_owner;
@@ -683,6 +688,15 @@ static decoder_t *CreateDecoder( image_handler_t *p_image, const video_format_t
 
     p_dec->p_module = NULL;
     es_format_InitFromVideo( &p_dec->fmt_in, fmt );
+    if( i_extra )
+    {
+        p_dec->fmt_in.p_extra = malloc( i_extra );
+        if( p_dec->fmt_in.p_extra )
+        {
+            memcpy( p_dec->fmt_in.p_extra, p_extra, i_extra );
+            p_dec->fmt_in.i_extra = i_extra;
+        }
+    }
     es_format_Init( &p_dec->fmt_out, VIDEO_ES, 0 );
     p_dec->b_frame_drop_allowed = false;
 
@@ -705,7 +719,7 @@ static decoder_t *CreateDecoder( image_handler_t *p_image, const video_format_t
                  (char*)&p_dec->fmt_in.i_codec );
 
         DeleteDecoder( p_dec );
-        return NULL;
+        p_dec = NULL;
     }
 
     return p_dec;



More information about the vlc-commits mailing list