From f21d6e18bc3f7fb9021b853544caf979bf87bc74 Mon Sep 17 00:00:00 2001 From: Krunal Patel Date: Tue, 5 Apr 2022 17:11:20 +0530 Subject: [PATCH] frontend/va: Create decoder once the max_references is updated Issue: When a video is decoded where the max_references is updated the decoder keeps using same old value. This results into green patches and decoding is not proper. Root Cause: The max_references is updated only once when the instance is created for the first time. Fix: Added a check along with the context->decoder to check if the context->templat.max_references has changed. If yes, then we go ahead and create the decoder again. Reviewed-by: Leo Liu Signed-off-by: Krunal Patel Part-of: --- src/gallium/frontends/va/picture_h264.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/va/picture_h264.c b/src/gallium/frontends/va/picture_h264.c index c63b914a3c9..9e44a3387e5 100755 --- a/src/gallium/frontends/va/picture_h264.c +++ b/src/gallium/frontends/va/picture_h264.c @@ -131,7 +131,11 @@ void vlVaHandlePictureParameterBufferH264(vlVaDriver *drv, vlVaContext *context, h264->pic_fields.bits.field_pic_flag && (h264->CurrPic.flags & VA_PICTURE_H264_BOTTOM_FIELD) != 0; - if (!context->decoder && context->desc.h264.num_ref_frames > 0) + if (context->decoder && (context->templat.max_references != context->desc.h264.num_ref_frames)) { + context->templat.max_references = MIN2(context->desc.h264.num_ref_frames, 16); + context->decoder->destroy(context->decoder); + context->decoder = NULL; + } else if (!context->decoder && context->desc.h264.num_ref_frames > 0) context->templat.max_references = MIN2(context->desc.h264.num_ref_frames, 16); for (i = 0; i < context->templat.max_references; ++i) {