summaryrefslogtreecommitdiffstats
path: root/common/recipes-multimedia/gstreamer/gstreamer1.0-omx/0007-omxvideodec-remove-the-data-packets-left-queued-in-t.patch
blob: 15d2478224b12a581b20a1f3129dac4072bf27ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
From 53072a001ad615377144a1e9ed38f4664496fc8c Mon Sep 17 00:00:00 2001
From: Kazunori Kobayashi <kkobayas@igel.co.jp>
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