gallium/va: don't use key=NULL in hash tables
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Mon, 26 Jul 2021 13:47:24 +0000 (15:47 +0200)
committerPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Fri, 30 Jul 2021 08:24:16 +0000 (10:24 +0200)
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@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12105>

src/gallium/frontends/va/picture_h264_enc.c
src/gallium/frontends/va/picture_hevc_enc.c

index ba67f6e..18890ae 100644 (file)
@@ -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)));
       }
    }
 
index 7485746..17bc252 100644 (file)
@@ -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)));
       }
    }