[vlc-commits] mmal/deinterlace: Do not filter the same picture twice
Julian Scheel
git at videolan.org
Fri Jun 5 15:37:16 CEST 2015
vlc | branch: master | Julian Scheel <julian at jusst.de> | Wed Jun 3 09:50:36 2015 +0200| [c92f24312c5674c9a32185da417ae5bdbf426276] | committer: Jean-Baptiste Kempf
mmal/deinterlace: Do not filter the same picture twice
If the same picture, containing the same buffer header without being
re-acquired in the meantime, is sent to image_fx twice it will portentially
cause a double free within the mmal core as it destroys the internal
refcounting. Use the same guarding mechanism which is already in place in
mmal/vout to ensure this is not happening at any point.
Signed-off-by: Julian Scheel <julian at jusst.de>
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c92f24312c5674c9a32185da417ae5bdbf426276
---
modules/hw/mmal/deinterlace.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/modules/hw/mmal/deinterlace.c b/modules/hw/mmal/deinterlace.c
index d158b71..0a56a94 100644
--- a/modules/hw/mmal/deinterlace.c
+++ b/modules/hw/mmal/deinterlace.c
@@ -337,16 +337,22 @@ static picture_t *deinterlace(filter_t *filter, picture_t *picture)
buffer->pts = picture->date;
buffer->cmd = 0;
- vlc_mutex_lock(&sys->buffer_cond_mutex);
- status = mmal_port_send_buffer(sys->input, buffer);
- if (status != MMAL_SUCCESS) {
- msg_Err(filter, "Failed to send buffer to input port (status=%"PRIx32" %s)",
- status, mmal_status_to_string(status));
+ if (!picture->p_sys->displayed) {
+ vlc_mutex_lock(&sys->buffer_cond_mutex);
+ status = mmal_port_send_buffer(sys->input, buffer);
+ if (status != MMAL_SUCCESS) {
+ msg_Err(filter, "Failed to send buffer to input port (status=%"PRIx32" %s)",
+ status, mmal_status_to_string(status));
+ picture_Release(picture);
+ } else {
+ picture->p_sys->displayed = true;
+ atomic_fetch_add(&sys->input_in_transit, 1);
+ vlc_cond_signal(&sys->buffer_cond);
+ }
+ vlc_mutex_unlock(&sys->buffer_cond_mutex);
} else {
- atomic_fetch_add(&sys->input_in_transit, 1);
- vlc_cond_signal(&sys->buffer_cond);
+ picture_Release(picture);
}
- vlc_mutex_unlock(&sys->buffer_cond_mutex);
/*
* Send output buffers
More information about the vlc-commits
mailing list