[vlc-devel] [PATCH 6/8] avcodec: video: allow initializing the codec format when it's known early

Steve Lhomme robux4 at videolabs.io
Fri May 5 18:42:22 CEST 2017


---
 modules/codec/avcodec/video.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index fc28055b2e..773d9cb664 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -340,7 +340,7 @@ static int lavc_CopyPicture(decoder_t *dec, picture_t *pic, AVFrame *frame)
     return VLC_SUCCESS;
 }
 
-static int OpenVideoCodec( decoder_t *p_dec )
+static int OpenVideoCodec( decoder_t *p_dec, enum PixelFormat pix_fmt, int profile, int level )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
     int ret;
@@ -363,9 +363,9 @@ static int OpenVideoCodec( decoder_t *p_dec )
     p_sys->p_context->coded_height = p_dec->fmt_in.video.i_height;
 
     p_sys->p_context->bits_per_coded_sample = p_dec->fmt_in.video.i_bits_per_pixel;
-    p_sys->pix_fmt = AV_PIX_FMT_NONE;
-    p_sys->profile = -1;
-    p_sys->level = -1;
+    p_sys->pix_fmt = pix_fmt;
+    p_sys->profile = profile;
+    p_sys->level = level;
 
     post_mt( p_sys );
     ret = ffmpeg_OpenCodec( p_dec );
@@ -438,6 +438,8 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
 {
     decoder_sys_t *p_sys;
     int i_val;
+    enum PixelFormat hwfmt = AV_PIX_FMT_NONE;
+    int i_profile = -1, i_level = -1;
 
     /* Allocate the memory needed to store the decoder's structure */
     if( ( p_dec->p_sys = p_sys = calloc( 1, sizeof(decoder_sys_t) ) ) == NULL )
@@ -584,7 +586,7 @@ int InitVideoDec( decoder_t *p_dec, AVCodecContext *p_context,
     ffmpeg_InitCodec( p_dec );
 
     /* ***** Open the codec ***** */
-    if( OpenVideoCodec( p_dec ) < 0 )
+    if( OpenVideoCodec( p_dec, hwfmt, i_profile, i_level ) < 0 )
     {
         vlc_sem_destroy( &p_sys->sem_mt );
         free( p_sys );
@@ -777,7 +779,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
     {
         ffmpeg_InitCodec( p_dec );
         if( p_sys->b_delayed_open )
-            OpenVideoCodec( p_dec );
+            OpenVideoCodec( p_dec, AV_PIX_FMT_NONE, -1, -1 );
     }
 
     p_block = pp_block ? *pp_block : NULL;
-- 
2.12.1



More information about the vlc-devel mailing list