From 799665c9baa169ee6979bb4d4545029ada10ac8e Mon Sep 17 00:00:00 2001 From: Ruijing Dong Date: Tue, 16 May 2023 11:47:09 -0400 Subject: [PATCH] frontends/va: remove private member and update target buffer use update_decoder_target to update the target buffer to let decoder obtain correct reference frame. remove the previous logic which failed to update reference info in time. fixes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8996 fixes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8387 Cc: mesa-stable Reviewed-by: Sil Vilerino Reviewed-by: Boyuan Zhang Signed-off-by: Ruijing Dong Part-of: --- src/gallium/frontends/va/picture_h264.c | 19 ------------------- src/gallium/frontends/va/surface.c | 6 +++--- src/gallium/frontends/va/va_private.h | 1 - src/gallium/include/pipe/p_video_state.h | 7 ------- 4 files changed, 3 insertions(+), 30 deletions(-) diff --git a/src/gallium/frontends/va/picture_h264.c b/src/gallium/frontends/va/picture_h264.c index 8f334d3..62d94b5 100644 --- a/src/gallium/frontends/va/picture_h264.c +++ b/src/gallium/frontends/va/picture_h264.c @@ -30,23 +30,9 @@ #include "util/u_handle_table.h" #include "va_private.h" -static void vlVaGetPastReferenceFrame(vlVaDriver *drv, VASurfaceID surface_id, - struct pipe_video_buffer **ref_frame) -{ - vlVaSurface *surf = handle_table_get(drv->htab, surface_id); - if (surf) { - *ref_frame = surf->obsolete_buf; - surf->obsolete_buf = NULL; - } - else - *ref_frame = NULL; -} - static void resetReferencePictureDesc(struct pipe_h264_picture_desc *h264, unsigned int i) { - struct h264_private *private = h264->priv; - h264->ref[i] = NULL; h264->frame_num_list[i] = 0; h264->is_long_term[i] = 0; @@ -54,21 +40,17 @@ static void resetReferencePictureDesc(struct pipe_h264_picture_desc *h264, h264->bottom_is_reference[i] = 0; h264->field_order_cnt_list[i][0] = 0; h264->field_order_cnt_list[i][1] = 0; - - private->past_ref[i] = NULL; } void vlVaHandlePictureParameterBufferH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf) { VAPictureParameterBufferH264 *h264 = buf->data; - struct h264_private *private = &context->h264; unsigned int top_or_bottom_field; bool is_ref; unsigned i; assert(buf->size >= sizeof(VAPictureParameterBufferH264) && buf->num_elements == 1); context->desc.h264.slice_count = 0; - context->desc.h264.priv = private; /*CurrPic*/ context->desc.h264.field_order_cnt[0] = h264->CurrPic.TopFieldOrderCnt; context->desc.h264.field_order_cnt[1] = h264->CurrPic.BottomFieldOrderCnt; @@ -148,7 +130,6 @@ void vlVaHandlePictureParameterBufferH264(vlVaDriver *drv, vlVaContext *context, } vlVaGetReferenceFrame(drv, h264->ReferenceFrames[i].picture_id, &context->desc.h264.ref[i]); - vlVaGetPastReferenceFrame(drv, h264->ReferenceFrames[i].picture_id, &private->past_ref[i]); context->desc.h264.frame_num_list[i] = h264->ReferenceFrames[i].frame_idx; top_or_bottom_field = h264->ReferenceFrames[i].flags & diff --git a/src/gallium/frontends/va/surface.c b/src/gallium/frontends/va/surface.c index 88e09a6..49f9016 100644 --- a/src/gallium/frontends/va/surface.c +++ b/src/gallium/frontends/va/surface.c @@ -1525,7 +1525,6 @@ vlVaExportSurfaceHandle(VADriverContextP ctx, struct u_rect src_rect, dst_rect; surf->templat.interlaced = false; - surf->obsolete_buf = surf->buffer; ret = vlVaHandleSurfaceAllocate(drv, surf, &surf->templat, NULL, 0); if (ret != VA_STATUS_SUCCESS) { @@ -1542,10 +1541,11 @@ vlVaExportSurfaceHandle(VADriverContextP ctx, interlaced, surf->buffer, &src_rect, &dst_rect, VL_COMPOSITOR_WEAVE); + if (interlaced->codec && interlaced->codec->update_decoder_target) + interlaced->codec->update_decoder_target(interlaced->codec, interlaced, surf->buffer); interlaced->destroy(interlaced); - } else - surf->obsolete_buf = NULL; + } surfaces = surf->buffer->get_surfaces(surf->buffer); diff --git a/src/gallium/frontends/va/va_private.h b/src/gallium/frontends/va/va_private.h index 891a7c5..1bde522 100644 --- a/src/gallium/frontends/va/va_private.h +++ b/src/gallium/frontends/va/va_private.h @@ -364,7 +364,6 @@ typedef struct { unsigned int slice_header_size; } mjpeg; - struct h264_private h264; struct vl_deint_filter *deint; vlVaBuffer *coded_buf; int target_id; diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h index ac64d63..1e29c06 100644 --- a/src/gallium/include/pipe/p_video_state.h +++ b/src/gallium/include/pipe/p_video_state.h @@ -375,10 +375,6 @@ struct pipe_h264_pps int8_t second_chroma_qp_index_offset; }; -struct h264_private { - struct pipe_video_buffer *past_ref[16]; -}; - struct pipe_h264_picture_desc { struct pipe_picture_desc base; @@ -405,9 +401,6 @@ struct pipe_h264_picture_desc struct pipe_video_buffer *ref[16]; - /* using private as a parameter name conflicts with C++ keywords */ - void *priv; - struct { bool slice_info_present; -- 2.7.4