From c425ca5566a6bd22fe4d38e7b46d82582ce29de9 Mon Sep 17 00:00:00 2001 From: Satyajit Sahu Date: Wed, 24 Jun 2020 16:01:01 +0530 Subject: [PATCH] frontends/va: Handle dynamic resolution/SVC for VP9 VP9 allows frame to use another resolution frame as reference frames so updating the resolution for decoder when there is a resolution change. Signed-off-by: Satyajit Sahu Reviewed-by: Leo Liu Part-of: --- src/gallium/frontends/va/picture.c | 14 ++++++++++---- src/gallium/frontends/va/picture_vp9.c | 8 ++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/gallium/frontends/va/picture.c b/src/gallium/frontends/va/picture.c index d292594590c..d529a2b2833 100644 --- a/src/gallium/frontends/va/picture.c +++ b/src/gallium/frontends/va/picture.c @@ -109,8 +109,10 @@ static VAStatus handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf) { VAStatus vaStatus = VA_STATUS_SUCCESS; + enum pipe_video_format format = + u_reduce_video_profile(context->templat.profile); - switch (u_reduce_video_profile(context->templat.profile)) { + switch (format) { case PIPE_VIDEO_FORMAT_MPEG12: vlVaHandlePictureParameterBufferMPEG12(drv, context, buf); break; @@ -145,9 +147,6 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer * /* Create the decoder once max_references is known. */ if (!context->decoder) { - enum pipe_video_format format = - u_reduce_video_profile(context->templat.profile); - if (!context->target) return VA_STATUS_ERROR_INVALID_CONTEXT; @@ -168,6 +167,13 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer * context->needs_begin_frame = true; } + if (format == PIPE_VIDEO_FORMAT_VP9) { + context->decoder->width = + context->desc.vp9.picture_parameter.frame_width; + context->decoder->height = + context->desc.vp9.picture_parameter.frame_height; + } + return vaStatus; } diff --git a/src/gallium/frontends/va/picture_vp9.c b/src/gallium/frontends/va/picture_vp9.c index b5aca9a513c..8ee7f0107da 100644 --- a/src/gallium/frontends/va/picture_vp9.c +++ b/src/gallium/frontends/va/picture_vp9.c @@ -81,8 +81,12 @@ void vlVaHandlePictureParameterBufferVP9(vlVaDriver *drv, vlVaContext *context, context->desc.vp9.picture_parameter.bit_depth = vp9->bit_depth; - for (i = 0 ; i < NUM_VP9_REFS ; i++) - vlVaGetReferenceFrame(drv, vp9->reference_frames[i], &context->desc.vp9.ref[i]); + for (i = 0 ; i < NUM_VP9_REFS ; i++) { + if (vp9->pic_fields.bits.frame_type == 0) + context->desc.vp9.ref[i] = NULL; + else + vlVaGetReferenceFrame(drv, vp9->reference_frames[i], &context->desc.vp9.ref[i]); + } if (!context->decoder && !context->templat.max_references) context->templat.max_references = NUM_VP9_REFS; -- 2.30.2