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

Julien Isorce julien.isorce at gmail.com
Thu Nov 19 01:37:57 PST 2015


st/va was completely missing parsing of:
VAPictureParameterBufferH264.ReferenceFrames[16]

Signed-off-by: Julien Isorce <j.isorce at samsung.com>
---
 src/gallium/state_trackers/va/picture.c | 76 +++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c
index 9d4d1a8..1259a88 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -97,6 +97,8 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *
    vlVaSurface *surf_forward;
    vlVaSurface *surf_backward;
    unsigned int i;
+   /* Solution 1 */
+   unsigned int top_or_bottom_field;
    static const uint8_t default_intra_quant_matrix[64] = { 0 };
    static const uint8_t default_non_intra_quant_matrix[64] = { 0 };
 
@@ -193,8 +195,82 @@ handlePictureParameterBuffer(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *
          h264->pic_fields.bits.deblocking_filter_control_present_flag;
       context->desc.h264.pps->redundant_pic_cnt_present_flag =
          h264->pic_fields.bits.redundant_pic_cnt_present_flag;
+
+      /* Solution 1 */
+      context->desc.h264.bottom_field_flag =
+         h264->pic_fields.bits.field_pic_flag &&
+         (h264->CurrPic.flags & VA_PICTURE_H264_BOTTOM_FIELD) != 0;
+      /* Solution 2 */
+      /*context->desc.h264.bottom_field_flag =
+         !!(h264->CurrPic.flags & VA_PICTURE_H264_BOTTOM_FIELD);*/
+
       /*reference_pic_flag*/
+      context->desc.h264.is_reference = h264->pic_fields.bits.reference_pic_flag;
       context->desc.h264.frame_num = h264->frame_num;
+
+      for (i = 0; i < context->decoder->max_references; ++i) {
+         if ((h264->ReferenceFrames[i].flags & VA_PICTURE_H264_INVALID) ||
+             (h264->ReferenceFrames[i].picture_id == VA_INVALID_SURFACE)) {
+            context->desc.h264.ref[i] = NULL;
+            context->desc.h264.frame_num_list[i] = 0;
+            context->desc.h264.is_long_term[i] = 0;
+            context->desc.h264.top_is_reference[i] = 0;
+            context->desc.h264.bottom_is_reference[i] = 0;
+            context->desc.h264.field_order_cnt_list[i][0] = 0;
+            context->desc.h264.field_order_cnt_list[i][1] = 0;
+            break;
+         }
+         getReferenceFrame(drv, h264->ReferenceFrames[i].picture_id, &context->desc.h264.ref[i]);
+         context->desc.h264.frame_num_list[i] = h264->ReferenceFrames[i].frame_idx;
+
+         /* Solution 1 */
+         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;
+         /* Solution 2 */
+         /*context->desc.h264.is_long_term[i] = (h264->ReferenceFrames[i].flags &
+            VA_PICTURE_H264_LONG_TERM_REFERENCE) != 0;
+         if ((h264->ReferenceFrames[i].flags &
+            (VA_PICTURE_H264_TOP_FIELD | VA_PICTURE_H264_BOTTOM_FIELD)) == 0) {
+            context->desc.h264.top_is_reference[i]  = 1;
+            context->desc.h264.bottom_is_reference[i] = 1;
+         } else {
+            context->desc.h264.top_is_reference[i] =
+               (h264->ReferenceFrames[i].flags & VA_PICTURE_H264_TOP_FIELD) != 0;
+            context->desc.h264.bottom_is_reference[i] =
+               (h264->ReferenceFrames[i].flags & VA_PICTURE_H264_BOTTOM_FIELD) != 0;
+         }
+         context->desc.h264.field_order_cnt_list[i][0] =
+            h264->ReferenceFrames[i].TopFieldOrderCnt;
+         context->desc.h264.field_order_cnt_list[i][1] =
+            h264->ReferenceFrames[i].BottomFieldOrderCnt;*/
+      }
+
+      /* Make sure remaining elements are clean */
+      for (; i < 16; ++i) {
+         context->desc.h264.ref[i] = NULL;
+         context->desc.h264.frame_num_list[i] = 0;
+         context->desc.h264.is_long_term[i] = 0;
+         context->desc.h264.top_is_reference[i] = 0;
+         context->desc.h264.bottom_is_reference[i] = 0;
+         context->desc.h264.field_order_cnt_list[i][0] = 0;
+         context->desc.h264.field_order_cnt_list[i][1] = 0;
+      }
       break;
 
    case PIPE_VIDEO_FORMAT_VC1:
-- 
1.9.1



More information about the mesa-dev mailing list