From 53072a001ad615377144a1e9ed38f4664496fc8c Mon Sep 17 00:00:00 2001 From: Kazunori Kobayashi Date: Thu, 13 Jun 2013 12:08:04 +0900 Subject: [PATCH 07/14] omxvideodec: remove the data packets left queued in the VideoDecoder class This change is required when the data packets split from a frame are queued in VideoDecoder class. The VideoDecoder class only takes account into frame to frame decoding, so subsequent packets aren't cleared from the queue in the VideoDecoder class. These should be removed before the test to determine if the remaining data in the queue is needed to be dropped. --- omx/gstomxvideodec.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 1bdac85..e8c276b 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -949,6 +949,39 @@ _find_nearest_frame (GstOMXVideoDec * self, GstOMXBuffer * buf) } if (best_id) { + /* This processing is required when the data packets split from a frame + * are queued in VideoDecoder class. The VideoDecoder class takes account + * into frame to frame decoding, so the subsequent packets are left queued. + * These should be removed before the test to determine if the remaining + * data in the queue is needed to be dropped. + */ + for (l = frames; l; l = l->next) { + GstVideoCodecFrame *tmp; + BufferIdentification *id; + + tmp = l->data; + id = gst_video_codec_frame_get_user_data (tmp); + + /* This happens for frames that were just added but + * which were not passed to the component yet. Ignore + * them here! + */ + if (!id) + continue; + + if (id->timestamp == best_timestamp && l != best_l) { + GstVideoCodecFrame *removal; + + removal = gst_video_decoder_get_frame (GST_VIDEO_DECODER (self), + tmp->system_frame_number); + gst_video_decoder_release_frame (GST_VIDEO_DECODER (self), removal); + } + } + + g_list_foreach (frames, (GFunc) gst_video_codec_frame_unref, NULL); + g_list_free (frames); + frames = gst_video_decoder_get_frames (GST_VIDEO_DECODER (self)); + for (l = frames; l && l != best_l; l = l->next) { GstVideoCodecFrame *tmp = l->data; BufferIdentification *id = gst_video_codec_frame_get_user_data (tmp); -- 1.8.1.2