[vlc-devel] [PATCH 24/30] decoder: optionally pass a vlc_video_context in decoder_UpdateVideoOutput()

Steve Lhomme robux4 at ycbcr.xyz
Wed Sep 25 15:31:13 CEST 2019


---
 include/vlc_codec.h                  |  4 ++--
 modules/codec/avcodec/video.c        |  6 +++---
 modules/stream_out/mosaic_bridge.c   |  4 ++--
 modules/stream_out/transcode/video.c |  2 +-
 src/input/decoder.c                  |  5 +++--
 src/input/decoder_helpers.c          | 14 +++++++++++---
 src/misc/image.c                     |  3 ++-
 7 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index 8d2680f1965..80c9cd4817b 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -50,7 +50,7 @@ struct decoder_owner_callbacks
         struct
         {
             int         (*hold_device)( decoder_t *, vlc_decoder_device ** );
-            int         (*format_update)( decoder_t * );
+            int         (*format_update)( decoder_t *, vlc_video_context * );
 
             /* cf. decoder_NewPicture, can be called from any decoder thread */
             picture_t*  (*buffer_new)( decoder_t * );
@@ -289,7 +289,7 @@ VLC_API int decoder_HoldDecoderDevice( decoder_t *dec, vlc_decoder_device **pp_d
  *
  * @return 0 if the video output was set up successfully, -1 otherwise.
  */
-VLC_API int decoder_UpdateVideoOutput( decoder_t *dec );
+VLC_API int decoder_UpdateVideoOutput( decoder_t *dec, vlc_video_context *vctx_out );
 
 /**
  * Updates the video output format.
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 851385cc8dc..15284026a0f 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1249,7 +1249,7 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             if (p_sys->p_va == NULL
              && lavc_UpdateVideoFormat(p_dec, p_context, p_context->pix_fmt,
                                        p_context->pix_fmt, NULL) == 0
-             && decoder_UpdateVideoOutput(p_dec) == 0)
+             && decoder_UpdateVideoOutput(p_dec, NULL) == 0)
                 p_pic = decoder_NewPicture(p_dec);
 
             if( !p_pic )
@@ -1598,7 +1598,7 @@ static int lavc_GetFrame(struct AVCodecContext *ctx, AVFrame *frame, int flags)
          * update the output video format here. The MT semaphore must be held
          * to protect p_dec->fmt_out. */
         if (lavc_UpdateVideoFormat(dec, ctx, ctx->pix_fmt, ctx->pix_fmt, NULL) ||
-            decoder_UpdateVideoOutput(dec))
+            decoder_UpdateVideoOutput(dec, NULL))
         {
             post_mt(sys);
             return -1;
@@ -1748,7 +1748,7 @@ no_reuse:
             continue; /* Unsupported codec profile or such */
         }
 
-        if (decoder_UpdateVideoOutput(p_dec))
+        if (decoder_UpdateVideoOutput(p_dec, NULL))
         {
             vlc_va_Delete(va);
             p_context->hwaccel_context = NULL;
diff --git a/modules/stream_out/mosaic_bridge.c b/modules/stream_out/mosaic_bridge.c
index 0018e02c926..a7ee45edc9a 100644
--- a/modules/stream_out/mosaic_bridge.c
+++ b/modules/stream_out/mosaic_bridge.c
@@ -84,7 +84,7 @@ static void  Del( sout_stream_t *, void * );
 static int   Send( sout_stream_t *, void *, block_t * );
 
 static void decoder_queue_video( decoder_t *p_dec, picture_t *p_pic );
-inline static int video_update_format_decoder( decoder_t *p_dec );
+inline static int video_update_format_decoder( decoder_t *p_dec, vlc_video_context * );
 inline static picture_t *video_new_buffer_filter( filter_t * );
 static void video_update_format( video_format_t *, es_format_t * );
 
@@ -572,7 +572,7 @@ static int Send( sout_stream_t *p_stream, void *id, block_t *p_buffer )
     return ret == VLCDEC_SUCCESS ? VLC_SUCCESS : VLC_EGENERIC;
 }
 
-inline static int video_update_format_decoder( decoder_t *p_dec )
+inline static int video_update_format_decoder( decoder_t *p_dec, vlc_video_context *vctx )
 {
     struct decoder_owner *p_owner = dec_get_owner( p_dec );
     video_update_format( &p_owner->video, &p_dec->fmt_out );
diff --git a/modules/stream_out/transcode/video.c b/modules/stream_out/transcode/video.c
index 59c159ea459..04f749a9906 100644
--- a/modules/stream_out/transcode/video.c
+++ b/modules/stream_out/transcode/video.c
@@ -70,7 +70,7 @@ static void debug_format( sout_stream_t *p_stream, const es_format_t *fmt )
              fmt->video.orientation );
 }
 
-static int video_update_format_decoder( decoder_t *p_dec )
+static int video_update_format_decoder( decoder_t *p_dec, vlc_video_context *vctx )
 {
     struct decoder_owner *p_owner = dec_get_owner( p_dec );
     sout_stream_id_sys_t *id = p_owner->id;
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 78fba8197c8..f433d01a6c3 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -460,7 +460,7 @@ static void FixDisplayFormat(decoder_t *p_dec, video_format_t *fmt)
     video_format_AdjustColorSpace( fmt );
 }
 
-static int ModuleThread_UpdateVideoFormat( decoder_t *p_dec )
+static int ModuleThread_UpdateVideoFormat( decoder_t *p_dec, vlc_video_context *vctx_out )
 {
     struct decoder_owner *p_owner = dec_get_owner( p_dec );
 
@@ -1149,8 +1149,9 @@ static void ModuleThread_QueueVideo( decoder_t *p_dec, picture_t *p_pic )
     ModuleThread_UpdateStatVideo( p_owner, success != VLC_SUCCESS );
 }
 
-static int thumbnailer_update_format( decoder_t *p_dec )
+static int thumbnailer_update_format( decoder_t *p_dec, vlc_video_context *vctx_out )
 {
+    VLC_UNUSED(vctx_out);
     p_dec->fmt_out.video.i_chroma = p_dec->fmt_out.i_codec;
     return 0;
 }
diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
index 4fb6bf4d8c9..40fdd98fef9 100644
--- a/src/input/decoder_helpers.c
+++ b/src/input/decoder_helpers.c
@@ -80,7 +80,7 @@ int decoder_UpdateVideoFormat( decoder_t *dec )
 {
     int res = decoder_HoldDecoderDevice( dec, NULL );
     if (res == 0)
-        res = decoder_UpdateVideoOutput( dec );
+        res = decoder_UpdateVideoOutput( dec, NULL );
     return res;
 }
 
@@ -96,14 +96,22 @@ int decoder_HoldDecoderDevice( decoder_t *dec, vlc_decoder_device **pp_dec_dev )
     return dec->cbs->video.hold_device( dec, pp_dec_dev );
 }
 
-int decoder_UpdateVideoOutput( decoder_t *dec )
+int decoder_UpdateVideoOutput( decoder_t *dec, vlc_video_context *vctx_out )
 {
     vlc_assert( dec->fmt_in.i_cat == VIDEO_ES && dec->cbs != NULL );
     if ( unlikely(dec->fmt_in.i_cat != VIDEO_ES || dec->cbs == NULL ||
                   dec->cbs->video.format_update == NULL) )
         return -1;
 
-    return dec->cbs->video.format_update( dec );
+#ifndef NDEBUG
+    if (vctx_out == NULL)
+    {
+        const vlc_chroma_description_t *dsc =
+            vlc_fourcc_GetChromaDescription( dec->fmt_out.video.i_chroma );
+        assert( dsc != NULL && dsc->plane_count != 0 );
+    }
+#endif
+    return dec->cbs->video.format_update( dec, vctx_out );
 }
 
 picture_t *decoder_NewPicture( decoder_t *dec )
diff --git a/src/misc/image.c b/src/misc/image.c
index dabb2f1468c..60a4ca43c2b 100644
--- a/src/misc/image.c
+++ b/src/misc/image.c
@@ -656,8 +656,9 @@ vlc_fourcc_t image_Mime2Fourcc( const char *psz_mime )
     return 0;
 }
 
-static int video_update_format( decoder_t *p_dec )
+static int video_update_format( decoder_t *p_dec, vlc_video_context *vctx_out )
 {
+    VLC_UNUSED(vctx_out);
     p_dec->fmt_out.video.i_chroma = p_dec->fmt_out.i_codec;
     return 0;
 }
-- 
2.17.1



More information about the vlc-devel mailing list