Mesa (staging/21.2): gallium/va: don't use key=NULL in hash tables

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 30 17:14:47 UTC 2021


Module: Mesa
Branch: staging/21.2
Commit: ce0e8e022d316df67800ddfd6b7a603d8dcca9c6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ce0e8e022d316df67800ddfd6b7a603d8dcca9c6

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Mon Jul 26 15:47:24 2021 +0200

gallium/va: don't use key=NULL in hash tables

Add 1 to the key index otherwise we hit the following assert
in hash_table_insert:

   assert(!key_pointer_is_reserved(ht, key));

Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12105>
(cherry picked from commit 2ea88d7cea070c3288c252064cae9236bd462646)

---

 .pick_status.json                           | 2 +-
 src/gallium/frontends/va/picture_h264_enc.c | 6 +++---
 src/gallium/frontends/va/picture_hevc_enc.c | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 6916371142d..d157243ee78 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -49,7 +49,7 @@
         "description": "gallium/va: don't use key=NULL in hash tables",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/frontends/va/picture_h264_enc.c b/src/gallium/frontends/va/picture_h264_enc.c
index 4dfeecccef7..7dad5a5b9d1 100644
--- a/src/gallium/frontends/va/picture_h264_enc.c
+++ b/src/gallium/frontends/va/picture_h264_enc.c
@@ -53,7 +53,7 @@ vlVaHandleVAEncPictureParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *cont
    context->coded_buf = coded_buf;
 
    _mesa_hash_table_insert(context->desc.h264enc.frame_idx,
-		       UINT_TO_PTR(h264->CurrPic.picture_id),
+		       UINT_TO_PTR(h264->CurrPic.picture_id + 1),
 		       UINT_TO_PTR(h264->frame_num));
 
    if (h264->pic_fields.bits.idr_pic_flag == 1)
@@ -84,12 +84,12 @@ vlVaHandleVAEncSliceParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *contex
       if (h264->RefPicList0[i].picture_id != VA_INVALID_ID) {
          if (context->desc.h264enc.ref_idx_l0 == VA_INVALID_ID)
             context->desc.h264enc.ref_idx_l0 = PTR_TO_UINT(util_hash_table_get(context->desc.h264enc.frame_idx,
-									       UINT_TO_PTR(h264->RefPicList0[i].picture_id)));
+									       UINT_TO_PTR(h264->RefPicList0[i].picture_id + 1)));
       }
       if (h264->RefPicList1[i].picture_id != VA_INVALID_ID && h264->slice_type == 1) {
          if (context->desc.h264enc.ref_idx_l1 == VA_INVALID_ID)
             context->desc.h264enc.ref_idx_l1 = PTR_TO_UINT(util_hash_table_get(context->desc.h264enc.frame_idx,
-									       UINT_TO_PTR(h264->RefPicList1[i].picture_id)));
+									       UINT_TO_PTR(h264->RefPicList1[i].picture_id + 1)));
       }
    }
 
diff --git a/src/gallium/frontends/va/picture_hevc_enc.c b/src/gallium/frontends/va/picture_hevc_enc.c
index 74857461764..17bc252ae5e 100644
--- a/src/gallium/frontends/va/picture_hevc_enc.c
+++ b/src/gallium/frontends/va/picture_hevc_enc.c
@@ -83,7 +83,7 @@ vlVaHandleVAEncPictureParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *cont
    context->desc.h265enc.pic.constrained_intra_pred_flag = h265->pic_fields.bits.constrained_intra_pred_flag;
 
    _mesa_hash_table_insert(context->desc.h265enc.frame_idx,
-                       UINT_TO_PTR(h265->decoded_curr_pic.picture_id),
+                       UINT_TO_PTR(h265->decoded_curr_pic.picture_id + 1),
                        UINT_TO_PTR(context->desc.h265enc.frame_num));
 
    return VA_STATUS_SUCCESS;
@@ -102,12 +102,12 @@ vlVaHandleVAEncSliceParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *contex
       if (h265->ref_pic_list0[i].picture_id != VA_INVALID_ID) {
          if (context->desc.h265enc.ref_idx_l0 == VA_INVALID_ID)
             context->desc.h265enc.ref_idx_l0 = PTR_TO_UINT(util_hash_table_get(context->desc.h265enc.frame_idx,
-                                               UINT_TO_PTR(h265->ref_pic_list0[i].picture_id)));
+                                               UINT_TO_PTR(h265->ref_pic_list0[i].picture_id + 1)));
       }
       if (h265->ref_pic_list1[i].picture_id != VA_INVALID_ID && h265->slice_type == 1) {
          if (context->desc.h265enc.ref_idx_l1 == VA_INVALID_ID)
             context->desc.h265enc.ref_idx_l1 = PTR_TO_UINT(util_hash_table_get(context->desc.h265enc.frame_idx,
-                                               UINT_TO_PTR(h265->ref_pic_list1[i].picture_id)));
+                                               UINT_TO_PTR(h265->ref_pic_list1[i].picture_id + 1)));
       }
    }
 



More information about the mesa-commit mailing list