[vlc-devel] [PATCH 08/10] avcodec: va: move the hw chroma setting out of lavc_GetVideoFormat()

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


We set it in lavc_UpdateVideoFormat() but not in ffmpeg_GetFormat() where
lavc_GetVideoFormat() is also called because it's already set each time a va
is tested.
---
 modules/codec/avcodec/video.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index ddd8bbc1e24..920eace59d5 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -160,8 +160,6 @@ static int lavc_GetVideoFormat(decoder_t *dec, video_format_t *restrict fmt,
 
         avcodec_align_dimensions2(ctx, &width, &height, aligns);
     }
-    else /* hardware decoding */
-        fmt->i_chroma = vlc_va_GetChroma(pix_fmt, sw_pix_fmt);
 
     if( width == 0 || height == 0 || width > 8192 || height > 8192 ||
         width < ctx->width || height < ctx->height )
@@ -358,8 +356,14 @@ static int lavc_UpdateVideoFormat(decoder_t *dec, AVCodecContext *ctx,
     fmt_out.p_palette = dec->fmt_out.video.p_palette;
     dec->fmt_out.video.p_palette = NULL;
 
-    es_format_Change(&dec->fmt_out, VIDEO_ES, fmt_out.i_chroma);
+    vlc_fourcc_t i_chroma;
+    if (fmt == swfmt)
+        i_chroma = fmt_out.i_chroma;
+    else
+        i_chroma = vlc_va_GetChroma(fmt, swfmt);
+    es_format_Change(&dec->fmt_out, VIDEO_ES, i_chroma);
     dec->fmt_out.video = fmt_out;
+    dec->fmt_out.video.i_chroma = i_chroma;
     dec->fmt_out.video.orientation = dec->fmt_in.video.orientation;
     dec->fmt_out.video.projection_mode = dec->fmt_in.video.projection_mode;
     dec->fmt_out.video.multiview_mode = dec->fmt_in.video.multiview_mode;
-- 
2.17.1



More information about the vlc-devel mailing list