[vlc-devel] [PATCH 21/26] decoder: allow decoders to set their output vlc_video_context

Steve Lhomme robux4 at ycbcr.xyz
Fri Sep 20 16:28:51 CEST 2019


---
 include/vlc_codec.h         |  3 +++
 src/input/decoder_helpers.c | 14 ++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index bd13a024207..098ffb21760 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -111,6 +111,9 @@ struct decoder_t
     /* Output format of decoder/packetizer */
     es_format_t         fmt_out;
 
+    /* Video context used by picture coming out of the decoder */
+    struct vlc_video_context  *vctx_out;
+
     /* Tell the decoder if it is allowed to drop frames */
     bool                b_frame_drop_allowed;
 
diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
index e12fd836a3d..0e23f11fd6b 100644
--- a/src/input/decoder_helpers.c
+++ b/src/input/decoder_helpers.c
@@ -51,6 +51,12 @@ void decoder_Init( decoder_t *p_dec, const es_format_t *restrict p_fmt )
 
 void decoder_Clean( decoder_t *p_dec )
 {
+    if ( p_dec->vctx_out )
+    {
+        vlc_video_context_Release( p_dec->vctx_out );
+        p_dec->vctx_out = NULL;
+    }
+
     if ( p_dec->p_module != NULL )
     {
         module_unneed(p_dec, p_dec->p_module);
@@ -106,6 +112,14 @@ int decoder_UpdateVideoOutput( decoder_t *dec )
                   dec->cbs->video.format_update == NULL) )
         return -1;
 
+#ifndef NDEBUG
+    if (dec->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 );
 }
 
-- 
2.17.1



More information about the vlc-devel mailing list