diff options
author | Julien Isorce <[email protected]> | 2017-07-25 15:31:28 +0100 |
---|---|---|
committer | Julien Isorce <[email protected]> | 2017-08-14 13:40:19 +0100 |
commit | 91d93aa62162f98d6377e5c796b63faa263f2c18 (patch) | |
tree | 9df67ea3d8fcbbe7eff793363585a79591a9974f /src/gallium/state_trackers/va/picture.c | |
parent | 3d8da1f678e196af619d74845f7d5f564ce40ea3 (diff) |
st/va: change frame_idx from array to hash table
The picture_id was assumed to be a frame number so in 0-31.
But the vaapi client gstreamer-vaapi uses the surfaces handles
as identifier which are unsigned int.
This bug can happen when using a lot of vaapi surfaces within
the same process. Indeed Mesa/st/va increments a counter for the
surface ID: mesa/util/u_handle_table.c::handle_table_add which
starts from 0 and incremented by 1 at each call.
So creating more than 32 surfaces was a problem.
The following bug contains a test that reproduces the problem
by running a couple of vaapih264enc in the same process. The
above also explains why there was no pb when running them in
separated processes.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102006
Signed-off-by: Julien Isorce <[email protected]>
Tested-by: Tomas Rataj <[email protected]>
Acked-by: Christian König <[email protected]>
Reviewed-and-tested-by: Boyuan Zhang <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/va/picture.c')
-rw-r--r-- | src/gallium/state_trackers/va/picture.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c index 20fe75085b9..338e0902d65 100644 --- a/src/gallium/state_trackers/va/picture.c +++ b/src/gallium/state_trackers/va/picture.c @@ -427,7 +427,10 @@ handleVAEncPictureParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlV PIPE_USAGE_STREAM, coded_buf->size); context->coded_buf = coded_buf; - context->desc.h264enc.frame_idx[h264->CurrPic.picture_id] = h264->frame_num; + util_hash_table_set(context->desc.h264enc.frame_idx, + UINT_TO_PTR(h264->CurrPic.picture_id), + UINT_TO_PTR(h264->frame_num)); + if (context->desc.h264enc.is_idr) context->desc.h264enc.picture_type = PIPE_H264_ENC_PICTURE_TYPE_IDR; else @@ -455,11 +458,13 @@ handleVAEncSliceParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlVaB for (int i = 0; i < 32; i++) { 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 = context->desc.h264enc.frame_idx[h264->RefPicList0[i].picture_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))); } 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 = context->desc.h264enc.frame_idx[h264->RefPicList1[i].picture_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))); } } |