[vlc-devel] [PATCH 31/31] avcodec: split the calls to decoder_UpdateVideoFormat()

Steve Lhomme robux4 at ycbcr.xyz
Fri Jul 5 16:20:10 CEST 2019


First get the device, create the VA if any, then settle the video output.

After that we can pass the video context created by the VA to the video output.
---
 modules/codec/avcodec/video.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 9949c2e01e..b96137ad71 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -375,7 +375,7 @@ static int lavc_UpdateVideoFormat(decoder_t *dec, AVCodecContext *ctx,
         dec->fmt_out.video.mastering = dec->fmt_in.video.mastering;
     dec->fmt_out.video.lighting = dec->fmt_in.video.lighting;
 
-    return decoder_UpdateVideoFormat(dec);
+    return decoder_UpdateDecoderDevice(dec);
 }
 
 static bool chroma_compatible(vlc_fourcc_t a, vlc_fourcc_t b)
@@ -1247,7 +1247,8 @@ static int DecodeBlock( decoder_t *p_dec, block_t **pp_block )
              * then picture buffer can be allocated. */
             if (p_sys->p_va == NULL
              && lavc_UpdateVideoFormat(p_dec, p_context, p_context->pix_fmt,
-                                       p_context->pix_fmt) == 0)
+                                       p_context->pix_fmt) == 0
+             && decoder_UpdateVideoOutput(p_dec) == 0)
                 p_pic = decoder_NewPicture(p_dec);
 
             if( !p_pic )
@@ -1597,7 +1598,8 @@ static int lavc_GetFrame(struct AVCodecContext *ctx, AVFrame *frame, int flags)
         /* Most unaccelerated decoders do not call get_format(), so we need to
          * 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))
+        if (lavc_UpdateVideoFormat(dec, ctx, ctx->pix_fmt, ctx->pix_fmt) ||
+            decoder_UpdateVideoOutput(dec))
         {
             post_mt(sys);
             return -1;
@@ -1755,6 +1757,18 @@ no_reuse:
             continue; /* Unsupported codec profile or such */
         }
 
+        if (decoder_UpdateVideoOutput(p_dec))
+        {
+            if (p_dec->vctx_out)
+            {
+                vlc_video_context_Release(p_dec->vctx_out);
+                p_dec->vctx_out = NULL;
+            }
+            vlc_va_Delete(va, &p_context->hwaccel_context);
+            wait_mt(p_sys);
+            continue; /* Unsupported codec profile or such */
+        }
+
         p_sys->p_va = va;
         p_sys->pix_fmt = hwfmt;
         p_context->draw_horiz_band = NULL;
-- 
2.17.1



More information about the vlc-devel mailing list