omxvideodec: Implement no-empty-eos-buffer hack, as in omxvideoenc.

Conflicts:

	omx/gstomxvideodec.c
This commit is contained in:
George Kiagiadakis 2012-04-30 23:20:24 +00:00 committed by Sebastian Dröge
parent 4aa3fa8a0d
commit 7ca067be28
2 changed files with 119 additions and 85 deletions

View file

@ -21,6 +21,7 @@
#ifndef __GST_OMX_H__
#define __GST_OMX_H__
#include <gmodule.h>
#include <gst/gst.h>
#include <string.h>
#include <OMX_Core.h>

View file

@ -498,6 +498,7 @@ done:
static void
gst_omx_video_dec_loop (GstOMXVideoDec * self)
{
GstOMXVideoDecClass *klass;
GstOMXPort *port = self->out_port;
GstOMXBuffer *buf = NULL;
GstVideoFrameState *frame;
@ -506,6 +507,8 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
GstClockTimeDiff deadline;
gboolean is_eos;
klass = GST_OMX_VIDEO_DEC_GET_CLASS (self);
acq_return = gst_omx_port_acquire_buffer (port, &buf);
if (acq_return == GST_OMX_ACQUIRE_BUFFER_ERROR) {
goto component_error;
@ -566,8 +569,9 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
return;
}
g_assert (acq_return == GST_OMX_ACQUIRE_BUFFER_OK && buf != NULL);
g_assert (acq_return == GST_OMX_ACQUIRE_BUFFER_OK);
if (buf) {
GST_DEBUG_OBJECT (self, "Handling buffer: 0x%08x %lu", buf->omx_buf->nFlags,
buf->omx_buf->nTimeStamp);
@ -606,7 +610,8 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
GST_ERROR_OBJECT (self, "No corresponding frame found");
outbuf =
gst_base_video_decoder_alloc_src_buffer (GST_BASE_VIDEO_DECODER (self));
gst_base_video_decoder_alloc_src_buffer (GST_BASE_VIDEO_DECODER
(self));
if (!gst_omx_video_dec_fill_buffer (self, buf, outbuf)) {
gst_buffer_unref (outbuf);
@ -633,8 +638,8 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
if (!gst_omx_video_dec_fill_buffer (self, buf, frame->src_buffer)) {
gst_buffer_replace (&frame->src_buffer, NULL);
flow_ret =
gst_base_video_decoder_finish_frame (GST_BASE_VIDEO_DECODER (self),
frame);
gst_base_video_decoder_finish_frame (GST_BASE_VIDEO_DECODER
(self), frame);
gst_omx_port_release_buffer (self->out_port, buf);
goto invalid_buffer;
}
@ -660,12 +665,18 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
}
g_mutex_unlock (self->drain_lock);
} else {
GST_DEBUG_OBJECT (self, "Finished frame: %s", gst_flow_get_name (flow_ret));
GST_DEBUG_OBJECT (self, "Finished frame: %s",
gst_flow_get_name (flow_ret));
}
gst_omx_port_release_buffer (port, buf);
self->downstream_flow_ret = flow_ret;
} else {
g_assert ((klass->cdata.hacks & GST_OMX_HACK_NO_EMPTY_EOS_BUFFER));
GST_BASE_VIDEO_CODEC_STREAM_LOCK (self);
flow_ret = GST_FLOW_EOS;
}
if (flow_ret != GST_FLOW_OK)
goto flow_error;
@ -1311,10 +1322,12 @@ static GstFlowReturn
gst_omx_video_dec_finish (GstBaseVideoDecoder * decoder)
{
GstOMXVideoDec *self;
GstOMXVideoDecClass *klass;
GstOMXBuffer *buf;
GstOMXAcquireBufferReturn acq_ret;
self = GST_OMX_VIDEO_DEC (decoder);
klass = GST_OMX_VIDEO_DEC_GET_CLASS (self);
GST_DEBUG_OBJECT (self, "Sending EOS to the component");
@ -1325,6 +1338,18 @@ gst_omx_video_dec_finish (GstBaseVideoDecoder * decoder)
}
self->eos = TRUE;
if ((klass->cdata.hacks & GST_OMX_HACK_NO_EMPTY_EOS_BUFFER)) {
GST_WARNING_OBJECT (self, "Component does not support empty EOS buffers");
/* Insert a NULL into the queue to signal EOS */
g_mutex_lock (self->out_port->port_lock);
g_queue_push_tail (self->out_port->pending_buffers, NULL);
g_cond_broadcast (self->out_port->port_cond);
g_mutex_unlock (self->out_port->port_lock);
return GST_BASE_VIDEO_DECODER_FLOW_DROPPED;
}
/* Make sure to release the base class stream lock, otherwise
* _loop() can't call _finish_frame() and we might block forever
* because no input buffers are released */
@ -1355,11 +1380,14 @@ gst_omx_video_dec_finish (GstBaseVideoDecoder * decoder)
static GstFlowReturn
gst_omx_video_dec_drain (GstOMXVideoDec * self)
{
GstOMXVideoDecClass *klass;
GstOMXBuffer *buf;
GstOMXAcquireBufferReturn acq_ret;
GST_DEBUG_OBJECT (self, "Draining component");
klass = GST_OMX_VIDEO_DEC_GET_CLASS (self);
if (!self->started) {
GST_DEBUG_OBJECT (self, "Component not started yet");
return GST_FLOW_OK;
@ -1372,6 +1400,11 @@ gst_omx_video_dec_drain (GstOMXVideoDec * self)
return GST_FLOW_OK;
}
if ((klass->cdata.hacks & GST_OMX_HACK_NO_EMPTY_EOS_BUFFER)) {
GST_WARNING_OBJECT (self, "Component does not support empty EOS buffers");
return GST_FLOW_OK;
}
/* Make sure to release the base class stream lock, otherwise
* _loop() can't call _finish_frame() and we might block forever
* because no input buffers are released */