From 1bf69c8f69988f11d78a411ffbc35ba0565d7f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 20 Dec 2012 19:30:38 +0100 Subject: [PATCH] omxvideodec: Set the OMX buffer nFilledLength field properly --- omx/gstomxvideodec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 29fc693edc..cf343780d7 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -1192,7 +1192,7 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, GstOMXVideoDecClass *klass; GstOMXBuffer *buf; GstBuffer *codec_data = NULL; - guint offset = 0; + guint offset = 0, size; GstClockTime timestamp, duration, timestamp_offset = 0; self = GST_OMX_VIDEO_DEC (decoder); @@ -1226,7 +1226,8 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, } } - while (offset < gst_buffer_get_size (frame->input_buffer)) { + size = gst_buffer_get_size (frame->input_buffer); + while (offset < size) { /* 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 */ @@ -1292,6 +1293,8 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, /* Copy the buffer content in chunks of size as requested * by the port */ + buf->omx_buf->nFilledLen = + MIN (size - offset, buf->omx_buf->nAllocLen - buf->omx_buf->nOffset); gst_buffer_extract (frame->input_buffer, offset, buf->omx_buf->pBuffer + buf->omx_buf->nOffset, buf->omx_buf->nFilledLen); @@ -1299,9 +1302,7 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, /* Interpolate timestamps if we're passing the buffer * in multiple chunks */ if (offset != 0 && duration != GST_CLOCK_TIME_NONE) { - timestamp_offset = - gst_util_uint64_scale (offset, duration, - gst_buffer_get_size (frame->input_buffer)); + timestamp_offset = gst_util_uint64_scale (offset, duration, size); } if (timestamp != GST_CLOCK_TIME_NONE) { @@ -1312,8 +1313,7 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, } if (duration != GST_CLOCK_TIME_NONE) { buf->omx_buf->nTickCount = - gst_util_uint64_scale (buf->omx_buf->nFilledLen, duration, - gst_buffer_get_size (frame->input_buffer)); + gst_util_uint64_scale (buf->omx_buf->nFilledLen, duration, size); self->last_upstream_ts += duration; }