From e483cba9f5ff45395fdb1cd40a796799707eb1e0 Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Thu, 26 Nov 2015 08:30:30 +0000 Subject: [PATCH] st/va: also retrieve reference frames info for h264 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Other hardwares than AMD require to parse: VAPictureParameterBufferH264.ReferenceFrames[16] Signed-off-by: Julien Isorce Reviewed-by: Christian König --- src/gallium/state_trackers/va/picture_h264.c | 52 ++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/gallium/state_trackers/va/picture_h264.c b/src/gallium/state_trackers/va/picture_h264.c index f6e5b70ebcc..acbfe5d61ed 100644 --- a/src/gallium/state_trackers/va/picture_h264.c +++ b/src/gallium/state_trackers/va/picture_h264.c @@ -29,9 +29,23 @@ #include "util/u_video.h" #include "va_private.h" +static void resetReferencePictureDesc(struct pipe_h264_picture_desc *h264, + unsigned int i) +{ + h264->ref[i] = NULL; + h264->frame_num_list[i] = 0; + h264->is_long_term[i] = 0; + h264->top_is_reference[i] = 0; + h264->bottom_is_reference[i] = 0; + h264->field_order_cnt_list[i][0] = 0; + h264->field_order_cnt_list[i][1] = 0; +} + void vlVaHandlePictureParameterBufferH264(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf) { VAPictureParameterBufferH264 *h264 = buf->data; + unsigned int top_or_bottom_field; + unsigned i; assert(buf->size >= sizeof(VAPictureParameterBufferH264) && buf->num_elements == 1); /*CurrPic*/ @@ -91,9 +105,47 @@ void vlVaHandlePictureParameterBufferH264(vlVaDriver *drv, vlVaContext *context, h264->pic_fields.bits.redundant_pic_cnt_present_flag; /*reference_pic_flag*/ context->desc.h264.frame_num = h264->frame_num; + context->desc.h264.is_reference = h264->pic_fields.bits.reference_pic_flag; + context->desc.h264.bottom_field_flag = + 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) context->templat.max_references = MIN2(context->desc.h264.num_ref_frames, 16); + + for (i = 0; i < context->templat.max_references; ++i) { + if ((h264->ReferenceFrames[i].flags & VA_PICTURE_H264_INVALID) || + (h264->ReferenceFrames[i].picture_id == VA_INVALID_SURFACE)) { + resetReferencePictureDesc(&context->desc.h264, i); + break; + } + + vlVaGetReferenceFrame(drv, h264->ReferenceFrames[i].picture_id, &context->desc.h264.ref[i]); + context->desc.h264.frame_num_list[i] = h264->ReferenceFrames[i].frame_idx; + + top_or_bottom_field = h264->ReferenceFrames[i].flags & + (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD); + context->desc.h264.is_long_term[i] = (h264->ReferenceFrames[i].flags & + (VA_PICTURE_H264_SHORT_TERM_REFERENCE | + VA_PICTURE_H264_LONG_TERM_REFERENCE)) != + VA_PICTURE_H264_SHORT_TERM_REFERENCE; + context->desc.h264.top_is_reference[i] = + !context->desc.h264.is_long_term[i] || + !!(h264->ReferenceFrames[i].flags & VA_PICTURE_H264_TOP_FIELD); + context->desc.h264.bottom_is_reference[i] = + !context->desc.h264.is_long_term[i] || + !!(h264->ReferenceFrames[i].flags & VA_PICTURE_H264_BOTTOM_FIELD); + context->desc.h264.field_order_cnt_list[i][0] = + top_or_bottom_field != VA_PICTURE_H264_BOTTOM_FIELD ? + h264->ReferenceFrames[i].TopFieldOrderCnt: INT_MAX; + context->desc.h264.field_order_cnt_list[i][1] = + top_or_bottom_field != VA_PICTURE_H264_TOP_FIELD ? + h264->ReferenceFrames[i].BottomFieldOrderCnt: INT_MAX; + } + + /* Make sure remaining elements are clean */ + for (; i < 16; ++i) + resetReferencePictureDesc(&context->desc.h264, i); } void vlVaHandleIQMatrixBufferH264(vlVaContext *context, vlVaBuffer *buf) -- 2.30.2