From 8f182d5e72cbbdc2f7bf537a0707a72b5ca984fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 29 May 2015 15:10:31 +0200 Subject: [PATCH] vl: cleanup video buffer private when the decoder is destroyed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- src/gallium/auxiliary/vl/vl_mpeg12_decoder.c | 24 ++++++++++++++++++++++++ src/gallium/auxiliary/vl/vl_mpeg12_decoder.h | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c index 8579460..a3ad6e6 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c @@ -84,6 +84,9 @@ static const unsigned const_empty_block_mask_420[3][2][2] = { struct video_buffer_private { + struct list_head list; + struct pipe_video_buffer *video_buffer; + struct pipe_sampler_view *sampler_view_planes[VL_NUM_COMPONENTS]; struct pipe_surface *surfaces[VL_MAX_SURFACES]; @@ -99,6 +102,8 @@ destroy_video_buffer_private(void *private) struct video_buffer_private *priv = private; unsigned i; + list_del(&priv->list); + for (i = 0; i < VL_NUM_COMPONENTS; ++i) pipe_sampler_view_reference(&priv->sampler_view_planes[i], NULL); @@ -126,6 +131,9 @@ get_video_buffer_private(struct vl_mpeg12_decoder *dec, struct pipe_video_buffer priv = CALLOC_STRUCT(video_buffer_private); + list_add(&priv->list, &dec->buffer_privates); + priv->video_buffer = buf; + sv = buf->get_sampler_view_planes(buf); for (i = 0; i < VL_NUM_COMPONENTS; ++i) if (sv[i]) @@ -141,6 +149,18 @@ get_video_buffer_private(struct vl_mpeg12_decoder *dec, struct pipe_video_buffer return priv; } +static void +free_video_buffer_privates(struct vl_mpeg12_decoder *dec) +{ + struct video_buffer_private *priv, *next; + + LIST_FOR_EACH_ENTRY_SAFE(priv, next, &dec->buffer_privates, list) { + struct pipe_video_buffer *buf = priv->video_buffer; + + vl_video_buffer_set_associated_data(buf, &dec->base, NULL, NULL); + } +} + static bool init_zscan_buffer(struct vl_mpeg12_decoder *dec, struct vl_mpeg12_buffer *buffer) { @@ -464,6 +484,8 @@ vl_mpeg12_destroy(struct pipe_video_codec *decoder) assert(decoder); + free_video_buffer_privates(dec); + /* Asserted in softpipe_delete_fs_state() for some reason */ dec->context->bind_vs_state(dec->context, NULL); dec->context->bind_fs_state(dec->context, NULL); @@ -1187,6 +1209,8 @@ vl_create_mpeg12_decoder(struct pipe_context *context, if (!init_pipe_state(dec)) goto error_pipe_state; + list_inithead(&dec->buffer_privates); + return &dec->base; error_pipe_state: diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h index 2a60405..505dd67 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h @@ -30,6 +30,8 @@ #include "pipe/p_video_codec.h" +#include "util/list.h" + #include "vl_mpeg12_bitstream.h" #include "vl_zscan.h" #include "vl_idct.h" @@ -77,6 +79,8 @@ struct vl_mpeg12_decoder unsigned current_buffer; struct vl_mpeg12_buffer *dec_buffers[4]; + + struct list_head buffer_privates; }; struct vl_mpeg12_buffer -- 1.9.1