From 05ad3343bfa22f7e27529cc8e48c00b3d569faf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 6 Dec 2011 12:47:12 +0100 Subject: [PATCH] omxvideodec: Use correct timestamp, duration and filled length for the EOS buffers --- omx/gstomxvideodec.c | 14 ++++++++++++++ omx/gstomxvideodec.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index eb4c21cc63..a50d958c4a 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -899,6 +899,7 @@ gst_omx_video_dec_start (GstBaseVideoDecoder * decoder) self = GST_OMX_VIDEO_DEC (decoder); + self->last_upstream_ts = 0; self->eos = FALSE; self->downstream_flow_ret = GST_FLOW_OK; ret = @@ -1243,6 +1244,7 @@ gst_omx_video_dec_reset (GstBaseVideoDecoder * decoder) gst_omx_port_set_flushing (self->out_port, FALSE); /* Start the srcpad loop again */ + self->last_upstream_ts = 0; self->eos = FALSE; self->downstream_flow_ret = GST_FLOW_OK; gst_pad_start_task (GST_BASE_VIDEO_CODEC_SRC_PAD (self), @@ -1383,11 +1385,13 @@ gst_omx_video_dec_handle_frame (GstBaseVideoDecoder * decoder, buf->omx_buf->nTimeStamp = gst_util_uint64_scale (timestamp + timestamp_offset, OMX_TICKS_PER_SECOND, GST_SECOND); + self->last_upstream_ts = timestamp + timestamp_offset; } if (duration != GST_CLOCK_TIME_NONE) { buf->omx_buf->nTickCount = gst_util_uint64_scale (buf->omx_buf->nFilledLen, duration, GST_BUFFER_SIZE (frame->sink_buffer)); + self->last_upstream_ts += duration; } if (offset == 0) { @@ -1482,6 +1486,11 @@ gst_omx_video_dec_finish (GstBaseVideoDecoder * decoder) * the EOS buffer arrives on the output port. */ acq_ret = gst_omx_port_acquire_buffer (self->in_port, &buf); if (acq_ret == GST_OMX_ACQUIRE_BUFFER_OK) { + buf->omx_buf->nFilledLen = 0; + buf->omx_buf->nTimeStamp = + gst_util_uint64_scale (self->last_upstream_ts, OMX_TICKS_PER_SECOND, + GST_SECOND); + buf->omx_buf->nTickCount = 0; buf->omx_buf->nFlags |= OMX_BUFFERFLAG_EOS; gst_omx_port_release_buffer (self->in_port, buf); GST_DEBUG_OBJECT (self, "Sent EOS to the component"); @@ -1532,6 +1541,11 @@ gst_omx_video_dec_drain (GstOMXVideoDec * self) g_mutex_lock (self->drain_lock); self->draining = TRUE; + buf->omx_buf->nFilledLen = 0; + buf->omx_buf->nTimeStamp = + gst_util_uint64_scale (self->last_upstream_ts, OMX_TICKS_PER_SECOND, + GST_SECOND); + buf->omx_buf->nTickCount = 0; buf->omx_buf->nFlags |= OMX_BUFFERFLAG_EOS; gst_omx_port_release_buffer (self->in_port, buf); GST_DEBUG_OBJECT (self, "Waiting until component is drained"); diff --git a/omx/gstomxvideodec.h b/omx/gstomxvideodec.h index afbd4db2cf..661957ac5a 100644 --- a/omx/gstomxvideodec.h +++ b/omx/gstomxvideodec.h @@ -59,6 +59,8 @@ struct _GstOMXVideoDec * the first buffer */ gboolean started; + GstClockTime last_upstream_ts; + /* Draining state */ GMutex *drain_lock; GCond *drain_cond;