[vlc-devel] [PATCH 09/10] avcodec: va: let the VA module set the output i_chroma

Steve Lhomme robux4 at ycbcr.xyz
Wed Dec 18 15:53:12 CET 2019


lavc_UpdateVideoFormat() is only called for the VA module just before the VA
opened, in which case the VA sets it's actual i_chroma. No need to set it
afterwards.
---
 modules/codec/avcodec/video.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 920eace59d5..9e4a8867b8a 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -360,7 +360,7 @@ static int lavc_UpdateVideoFormat(decoder_t *dec, AVCodecContext *ctx,
     if (fmt == swfmt)
         i_chroma = fmt_out.i_chroma;
     else
-        i_chroma = vlc_va_GetChroma(fmt, swfmt);
+        i_chroma = 0;
     es_format_Change(&dec->fmt_out, VIDEO_ES, i_chroma);
     dec->fmt_out.video = fmt_out;
     dec->fmt_out.video.i_chroma = i_chroma;
@@ -1742,7 +1742,6 @@ no_reuse:
 
         if (!vlc_va_MightDecode(hwfmt, swfmt))
             continue; /* Unknown brand of hardware acceleration */
-        p_dec->fmt_out.video.i_chroma = vlc_va_GetChroma(hwfmt, swfmt);
         if (p_context->width == 0 || p_context->height == 0)
         {   /* should never happen */
             msg_Err(p_dec, "unspecified video dimensions");
@@ -1756,6 +1755,7 @@ no_reuse:
             continue; /* Unsupported brand of hardware acceleration */
         vlc_mutex_unlock(&p_sys->lock);
 
+        p_dec->fmt_out.video.i_chroma = 0; // make sure the va sets its output chroma
         vlc_video_context *vctx_out;
         vlc_va_t *va = vlc_va_New(VLC_OBJECT(p_dec), p_context, hwfmt, src_desc,
                                   &p_dec->fmt_in, init_device,
@@ -1765,7 +1765,9 @@ no_reuse:
         vlc_mutex_lock(&p_sys->lock);
         if (va == NULL)
             continue; /* Unsupported codec profile or such */
+        assert(p_dec->fmt_out.video.i_chroma != 0);
         assert(vctx_out != NULL);
+        p_dec->fmt_out.i_codec = p_dec->fmt_out.video.i_chroma;
 
         if (decoder_UpdateVideoOutput(p_dec, vctx_out))
         {
-- 
2.17.1



More information about the vlc-devel mailing list