Am 14.06.2016 um 22:14 schrieb Boyuan Zhang:
Signed-off-by: Boyuan Zhang <boyuan.zh...@amd.com>

We need to find an interface that works both for OpenMAX as well as VA-API and not implement a separate interface for each state tracker.

So I would suggest to implement the logic to provide the reference picture list in OpenMAX and switch over to using something general here.

Regards,
Christian.

---
  src/gallium/drivers/radeon/radeon_vce.c | 52 +++++++++++++++++++++++++++++++--
  1 file changed, 49 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_vce.c 
b/src/gallium/drivers/radeon/radeon_vce.c
index 549d999..0ff07eb 100644
--- a/src/gallium/drivers/radeon/radeon_vce.c
+++ b/src/gallium/drivers/radeon/radeon_vce.c
@@ -139,6 +139,48 @@ static void sort_cpb(struct rvce_encoder *enc)
        }
  }
+/**
+ * sort l0 and l1 based on reference picture list
+ */
+static void sort_cpb_by_ref_list(struct rvce_encoder *enc)
+{
+       struct rvce_cpb_slot *i, *l0 = NULL, *l1 = NULL;
+       struct list_head *current = &enc->cpb_slots;
+
+       for (int j = 0 ; j < 32 ; j++) {
+               if ((enc->pic.ref_pic_list_0[j] == 0xFFFFFFFF) &&
+                       (enc->pic.ref_pic_list_1[j] == 0xFFFFFFFF))
+                       break;
+               LIST_FOR_EACH_ENTRY(i, &enc->cpb_slots, list) {
+                       if (i->frame_num == enc->pic.ref_pic_list_0[j])
+                               l0 = i;
+
+                       if (i->frame_num == enc->pic.ref_pic_list_1[j])
+                               l1 = i;
+
+                       if (enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_P 
&&
+                               l0)
+                               break;
+
+                       if (enc->pic.picture_type == PIPE_H264_ENC_PICTURE_TYPE_B 
&&
+                               l0 && l1)
+                               break;
+               }
+
+               if (l0) {
+                       LIST_DEL(&l0->list);
+                       LIST_ADD(&l0->list, current);
+                       current = current->next;
+               }
+
+               if (l1) {
+                       LIST_DEL(&l1->list);
+                       LIST_ADD(&l1->list, current);
+                       current = current->next;
+               }
+       }
+}
+
  static void get_rate_control_param(struct rvce_encoder *enc, struct 
pipe_h264_enc_picture_desc *pic)
  {
        enc->pic.rc.rc_method = pic->rate_ctrl.rate_ctrl_method;
@@ -444,9 +486,13 @@ static void rvce_begin_frame(struct pipe_video_codec 
*encoder,
        if (pic->picture_type == PIPE_H264_ENC_PICTURE_TYPE_IDR)
                reset_cpb(enc);
        else if (pic->picture_type == PIPE_H264_ENC_PICTURE_TYPE_P ||
-                pic->picture_type == PIPE_H264_ENC_PICTURE_TYPE_B)
-               sort_cpb(enc);
-       
+                pic->picture_type == PIPE_H264_ENC_PICTURE_TYPE_B) {
+               if (pic->has_ref_pic_list)
+                       sort_cpb_by_ref_list(enc);
+               else
+                       sort_cpb(enc);
+       }
+
        if (!enc->stream_handle) {
                struct rvid_buffer fb;
                enc->stream_handle = rvid_alloc_stream_handle();

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to