diff options
author | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2015-07-28 11:34:52 +0200 |
---|---|---|
committer | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2015-08-19 14:05:32 +0200 |
commit | 8813d55fa5978660d9f4e7dbe1f50da9922be08d (patch) | |
tree | 900c2a41e37416643968aca5f36f3dc288114480 /libavcodec | |
parent | babd340f584988446ef578e7dbc7064b19804f81 (diff) | |
download | ffmpeg-8813d55fa5978660d9f4e7dbe1f50da9922be08d.tar.gz |
vaapi: fix usage of invalid buffer ids.
Invalid buffer ids are defined by VA_INVALID_ID. Use that through out
vaapi_*.c support files now that we have private data initialized and
managed by libavcodec. Previously, the only requirement for the public
vaapi_context struct was to be zero-initialized.
This fixes support for 3rdparty VA drivers that strictly conform to
the API whereby an invalid buffer id is VA_INVALID_ID and the first
valid buffer id can actually be zero.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/vaapi.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/libavcodec/vaapi.c b/libavcodec/vaapi.c index 5dc43e1d14..e716721162 100644 --- a/libavcodec/vaapi.c +++ b/libavcodec/vaapi.c @@ -35,9 +35,9 @@ static void destroy_buffers(VADisplay display, VABufferID *buffers, unsigned int { unsigned int i; for (i = 0; i < n_buffers; i++) { - if (buffers[i]) { + if (buffers[i] != VA_INVALID_ID) { vaDestroyBuffer(display, buffers[i]); - buffers[i] = 0; + buffers[i] = VA_INVALID_ID; } } } @@ -55,6 +55,11 @@ int ff_vaapi_context_init(AVCodecContext *avctx) vactx->display = user_vactx->display; vactx->config_id = user_vactx->config_id; vactx->context_id = user_vactx->context_id; + + vactx->pic_param_buf_id = VA_INVALID_ID; + vactx->iq_matrix_buf_id = VA_INVALID_ID; + vactx->bitplane_buf_id = VA_INVALID_ID; + return 0; } @@ -68,18 +73,18 @@ int ff_vaapi_render_picture(FFVAContext *vactx, VASurfaceID surface) VABufferID va_buffers[3]; unsigned int n_va_buffers = 0; - if (!vactx->pic_param_buf_id) + if (vactx->pic_param_buf_id == VA_INVALID_ID) return 0; vaUnmapBuffer(vactx->display, vactx->pic_param_buf_id); va_buffers[n_va_buffers++] = vactx->pic_param_buf_id; - if (vactx->iq_matrix_buf_id) { + if (vactx->iq_matrix_buf_id != VA_INVALID_ID) { vaUnmapBuffer(vactx->display, vactx->iq_matrix_buf_id); va_buffers[n_va_buffers++] = vactx->iq_matrix_buf_id; } - if (vactx->bitplane_buf_id) { + if (vactx->bitplane_buf_id != VA_INVALID_ID) { vaUnmapBuffer(vactx->display, vactx->bitplane_buf_id); va_buffers[n_va_buffers++] = vactx->bitplane_buf_id; } @@ -119,7 +124,7 @@ int ff_vaapi_commit_slices(FFVAContext *vactx) return -1; vactx->slice_buf_ids = slice_buf_ids; - slice_param_buf_id = 0; + slice_param_buf_id = VA_INVALID_ID; if (vaCreateBuffer(vactx->display, vactx->context_id, VASliceParameterBufferType, vactx->slice_param_size, @@ -128,7 +133,7 @@ int ff_vaapi_commit_slices(FFVAContext *vactx) return -1; vactx->slice_count = 0; - slice_data_buf_id = 0; + slice_data_buf_id = VA_INVALID_ID; if (vaCreateBuffer(vactx->display, vactx->context_id, VASliceDataBufferType, vactx->slice_data_size, @@ -147,7 +152,7 @@ static void *alloc_buffer(FFVAContext *vactx, int type, unsigned int size, uint3 { void *data = NULL; - *buf_id = 0; + *buf_id = VA_INVALID_ID; if (vaCreateBuffer(vactx->display, vactx->context_id, type, size, 1, NULL, buf_id) == VA_STATUS_SUCCESS) vaMapBuffer(vactx->display, *buf_id, &data); |