From 9dd6bd3815c5c8ae6c04a805bb30dee9ff836403 Mon Sep 17 00:00:00 2001 From: Yuri Konotopov Date: Sat, 25 Sep 2021 19:39:07 +0400 Subject: [PATCH] Do not initiate VA buffers destroy from server side. Client must use vaDestroyBuffer to destroy buffers. Fixes: https://github.com/xtknight/vdpau-va-driver-vp9/issues/13 Signed-off-by: Yuri Konotopov --- src/vdpau_buffer.c | 46 ---------------------------------------------- src/vdpau_buffer.h | 14 -------------- src/vdpau_decode.c | 23 +---------------------- src/vdpau_video.c | 11 ----------- src/vdpau_video.h | 3 --- 5 files changed, 1 insertion(+), 96 deletions(-) diff --git a/src/vdpau_buffer.c b/src/vdpau_buffer.c index f7883df..5f2bde7 100644 --- a/src/vdpau_buffer.c +++ b/src/vdpau_buffer.c @@ -28,28 +28,6 @@ #define DEBUG 1 #include "debug.h" -// Destroy dead VA buffers -void -destroy_dead_va_buffers( - vdpau_driver_data_t *driver_data, - object_context_p obj_context -) -{ - object_buffer_p obj_buffer; - unsigned int i; - - if (obj_context->dead_buffers_count < 1) - return; - - ASSERT(obj_context->dead_buffers); - for (i = 0; i < obj_context->dead_buffers_count; i++) { - obj_buffer = VDPAU_BUFFER(obj_context->dead_buffers[i]); - ASSERT(obj_buffer); - destroy_va_buffer(driver_data, obj_buffer); - } - obj_context->dead_buffers_count = 0; -} - // Create VA buffer object object_buffer_p create_va_buffer( @@ -104,30 +82,6 @@ destroy_va_buffer( object_heap_free(&driver_data->buffer_heap, (object_base_p)obj_buffer); } -// Schedule VA buffer object for destruction -void -schedule_destroy_va_buffer( - vdpau_driver_data_p driver_data, - object_buffer_p obj_buffer -) -{ - object_context_p obj_context = VDPAU_CONTEXT(obj_buffer->va_context); - if (!obj_context) - return; - - realloc_buffer( - (void **)&obj_context->dead_buffers, - &obj_context->dead_buffers_count_max, - 16 + obj_context->dead_buffers_count, - sizeof(*obj_context->dead_buffers) - ); - - ASSERT(obj_context->dead_buffers); - obj_context->dead_buffers[obj_context->dead_buffers_count] = obj_buffer->base.id; - obj_context->dead_buffers_count++; - obj_buffer->delayed_destroy = 1; -} - // vaCreateBuffer VAStatus vdpau_CreateBuffer( diff --git a/src/vdpau_buffer.h b/src/vdpau_buffer.h index 20581e5..58b8ecf 100644 --- a/src/vdpau_buffer.h +++ b/src/vdpau_buffer.h @@ -36,13 +36,6 @@ struct object_buffer { unsigned int delayed_destroy : 1; }; -// Destroy dead VA buffers -void -destroy_dead_va_buffers( - vdpau_driver_data_t *driver_data, - object_context_p obj_context -) attribute_hidden; - // Create VA buffer object object_buffer_p create_va_buffer( @@ -60,13 +53,6 @@ destroy_va_buffer( object_buffer_p obj_buffer ) attribute_hidden; -// Schedule VA buffer object for destruction -void -schedule_destroy_va_buffer( - vdpau_driver_data_p driver_data, - object_buffer_p obj_buffer -) attribute_hidden; - // vaCreateBuffer VAStatus vdpau_CreateBuffer( diff --git a/src/vdpau_decode.c b/src/vdpau_decode.c index 233a1a3..357a04b 100644 --- a/src/vdpau_decode.c +++ b/src/vdpau_decode.c @@ -1565,7 +1565,6 @@ vdpau_BeginPicture( return VA_STATUS_ERROR_UNKNOWN; } - destroy_dead_va_buffers(driver_data, obj_context); return VA_STATUS_SUCCESS; } @@ -1607,24 +1606,7 @@ vdpau_RenderPicture( if (!translate_buffer(driver_data, obj_context, obj_buffer)) return VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE; - /* Release any buffer that is not VASliceDataBuffer */ - /* VASliceParameterBuffer is also needed to check for start_codes */ - switch (obj_buffer->type) { - case VASliceParameterBufferType: - case VASliceDataBufferType: - schedule_destroy_va_buffer(driver_data, obj_buffer); - break; - case VAPictureParameterBufferType: - /* Preserve VAPictureParameterBufferMPEG4 */ - if (obj_context->vdp_codec == VDP_CODEC_MPEG4) { - schedule_destroy_va_buffer(driver_data, obj_buffer); - break; - } - /* fall-through */ - default: - destroy_va_buffer(driver_data, obj_buffer); - break; - } + buffers[i] = VA_INVALID_BUFFER; } @@ -1703,8 +1685,5 @@ vdpau_EndPicture( /* XXX: assume we are done with rendering right away */ obj_context->current_render_target = VA_INVALID_SURFACE; - /* Release pending buffers */ - destroy_dead_va_buffers(driver_data, obj_context); - return va_status; } diff --git a/src/vdpau_video.c b/src/vdpau_video.c index bc82e09..c74a656 100644 --- a/src/vdpau_video.c +++ b/src/vdpau_video.c @@ -545,12 +545,6 @@ VAStatus vdpau_DestroyContext(VADriverContextP ctx, VAContextID context) obj_context->vdp_decoder = VDP_INVALID_HANDLE; } - destroy_dead_va_buffers(driver_data, obj_context); - if (obj_context->dead_buffers) { - free(obj_context->dead_buffers); - obj_context->dead_buffers = NULL; - } - if (obj_context->render_targets) { for (i = 0; i < obj_context->num_render_targets; i++) { object_surface_p obj_surface; @@ -569,8 +563,6 @@ VAStatus vdpau_DestroyContext(VADriverContextP ctx, VAContextID context) obj_context->picture_height = 0; obj_context->num_render_targets = 0; obj_context->flags = 0; - obj_context->dead_buffers_count = 0; - obj_context->dead_buffers_count_max = 0; object_heap_free(&driver_data->context_heap, (object_base_p)obj_context); return VA_STATUS_SUCCESS; @@ -629,9 +621,6 @@ vdpau_CreateContext( obj_context->max_ref_frames = -1; obj_context->render_targets = (VASurfaceID *) calloc(num_render_targets, sizeof(VASurfaceID)); - obj_context->dead_buffers = NULL; - obj_context->dead_buffers_count = 0; - obj_context->dead_buffers_count_max = 0; obj_context->vdp_codec = get_VdpCodec(vdp_profile); obj_context->vdp_profile = vdp_profile; obj_context->vdp_decoder = VDP_INVALID_HANDLE; diff --git a/src/vdpau_video.h b/src/vdpau_video.h index 8f363a9..236e80c 100644 --- a/src/vdpau_video.h +++ b/src/vdpau_video.h @@ -55,9 +55,6 @@ struct object_context { int flags; int max_ref_frames; VASurfaceID *render_targets; - VABufferID *dead_buffers; - uint32_t dead_buffers_count; - uint32_t dead_buffers_count_max; void *last_pic_param; void *last_slice_params; unsigned int last_slice_params_count;