[Mesa-dev] [PATCH v2 2/2] st/va: also retrieve reference frames info for h264

Christian König christian.koenig at amd.com
Wed Nov 25 01:52:39 PST 2015


On 25.11.2015 10:13, Julien Isorce wrote:
> From: Julien Isorce <julien.isorce at gmail.com>
>
> Other hardwares than AMD require to parse:
> VAPictureParameterBufferH264.ReferenceFrames[16]
>
> Signed-off-by: Julien Isorce <j.isorce at samsung.com>

Reviewed-by: Christian König <christian.koenig at amd.com>

> ---
>   src/gallium/state_trackers/va/picture_h264.c | 53 ++++++++++++++++++++++++++++
>   1 file changed, 53 insertions(+)
>
> diff --git a/src/gallium/state_trackers/va/picture_h264.c b/src/gallium/state_trackers/va/picture_h264.c
> index e9a8825..f811add 100644
> --- a/src/gallium/state_trackers/va/picture_h264.c
> +++ b/src/gallium/state_trackers/va/picture_h264.c
> @@ -29,9 +29,24 @@
>   #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;
> +}
> +
>   VAStatus 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,10 +106,48 @@ VAStatus vlVaHandlePictureParameterBufferH264(vlVaDriver *drv, vlVaContext *cont
>         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);
> +
>      /* Create the decoder once max_references is known. */
>      if (!context->decoder) {
>         if (!context->target)



More information about the mesa-dev mailing list