summaryrefslogtreecommitdiff
path: root/meta-openvuplus/recipes-multimedia/gstreamer/gst-plugins-bad-0.10.23/0003-mpegpsdemux_speedup.diff.patch
blob: 48647cf349f0efbda2e953ec77994f924cfa8f18 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
From 9fce0ed5dd37daa6d98d0a4aaed05faafb2e6771 Mon Sep 17 00:00:00 2001
From: Andreas Oberritter <obi@opendreambox.org>
Date: Wed, 21 Mar 2012 15:55:42 +0100
Subject: [PATCH 3/3] mpegpsdemux_speedup.diff

---
 gst/mpegdemux/gstmpegdemux.c |   52 +++++++++++++++++++++++++++++++++++++-----
 gst/mpegdemux/gstmpegdemux.h |    4 +++
 2 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/gst/mpegdemux/gstmpegdemux.c b/gst/mpegdemux/gstmpegdemux.c
index 8359285..35a7ee9 100644
--- a/gst/mpegdemux/gstmpegdemux.c
+++ b/gst/mpegdemux/gstmpegdemux.c
@@ -285,7 +285,10 @@ gst_flups_demux_reset (GstFluPSDemux * demux)
     if (stream != NULL) {
       if (stream->pad)
         gst_element_remove_pad (GST_ELEMENT_CAST (demux), stream->pad);
-
+      if (stream->buf)
+        free(stream->buf);
+      if (stream->meta_buf)
+        gst_buffer_unref(stream->meta_buf);
       g_free (stream);
       demux->streams[i] = NULL;
     }
@@ -415,6 +418,15 @@ gst_flups_demux_create_stream (GstFluPSDemux * demux, gint id, gint stream_type)
   stream->type = stream_type;
   stream->pad = gst_pad_new_from_template (template, name);
   stream->segment_thresh = threshold;
+
+  if (threshold == VIDEO_SEGMENT_THRESHOLD) {
+    stream->buf = malloc(64*1024);
+    stream->buf_pos = 0;
+    stream->meta_buf = gst_buffer_new();
+  }
+  else
+    stream->buf = 0;
+
   gst_pad_set_event_function (stream->pad,
       GST_DEBUG_FUNCPTR (gst_flups_demux_src_event));
   gst_pad_set_query_function (stream->pad,
@@ -466,6 +478,7 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
   GstFlowReturn result;
   guint64 timestamp;
   guint size;
+  gboolean sent = FALSE;
 
   if (stream == NULL)
     goto no_stream;
@@ -568,11 +581,38 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
   demux->next_pts = G_MAXUINT64;
   demux->next_dts = G_MAXUINT64;
 
-  result = gst_pad_push (stream->pad, buf);
-  GST_DEBUG_OBJECT (demux, "pushed stream id 0x%02x type 0x%02x, time: %"
-      GST_TIME_FORMAT ", size %d. result: %s",
-      stream->id, stream->type, GST_TIME_ARGS (timestamp),
-      size, gst_flow_get_name (result));
+  if (stream->buf && stream->buf_pos && (timestamp != GST_CLOCK_TIME_NONE || stream->buf_pos+size > 64*1024)) {
+    GstBuffer *tmp = gst_buffer_new_and_alloc(stream->buf_pos);
+    gst_buffer_copy_metadata(tmp, stream->meta_buf, GST_BUFFER_COPY_ALL);
+    GST_BUFFER_SIZE(tmp) = stream->buf_pos;
+    memcpy(GST_BUFFER_DATA(tmp), stream->buf, stream->buf_pos);
+    result = gst_pad_push (stream->pad, tmp);
+    GST_DEBUG_OBJECT (demux, "pushed stream id 0x%02x type 0x%02x, time: %"
+        GST_TIME_FORMAT ", size %d. result: %s",
+        stream->id, stream->type, GST_TIME_ARGS (timestamp),
+        stream->buf_pos, gst_flow_get_name (result));
+    stream->buf_pos = 0;
+    sent = TRUE;
+  }
+
+  if (!stream->buf || size > 64*1024) {
+    result = gst_pad_push (stream->pad, buf);
+    GST_DEBUG_OBJECT (demux, "pushed stream id 0x%02x type 0x%02x, time: %"
+        GST_TIME_FORMAT ", size %d. result: %s",
+        stream->id, stream->type, GST_TIME_ARGS (timestamp),
+        size, gst_flow_get_name (result));
+  }
+  else {
+    if (!stream->buf_pos)
+      gst_buffer_copy_metadata(stream->meta_buf, buf, GST_BUFFER_COPY_ALL);
+
+    memcpy(stream->buf + stream->buf_pos, GST_BUFFER_DATA(buf), size);
+    stream->buf_pos += size;
+    gst_buffer_unref(buf);
+
+    if (!sent)
+      result = GST_FLOW_OK;
+  }
 
   return result;
 
diff --git a/gst/mpegdemux/gstmpegdemux.h b/gst/mpegdemux/gstmpegdemux.h
index 6cf7aed..5977578 100644
--- a/gst/mpegdemux/gstmpegdemux.h
+++ b/gst/mpegdemux/gstmpegdemux.h
@@ -92,6 +92,10 @@ struct _GstFluPSStream
   gboolean discont;
   gboolean notlinked;
   gboolean need_segment;
+
+  GstBuffer *meta_buf;
+  unsigned char *buf;
+  size_t buf_pos;
 };
 
 struct _GstFluPSDemux
-- 
1.7.5.4