summaryrefslogtreecommitdiffstats
path: root/gst/mpegdemux/gstmpegdemux.c
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2008-10-08 10:21:20 +0000
committerSebastian Dröge <slomo@circular-chaos.org>2008-10-08 10:21:20 +0000
commit453b704a09ce4fbbd3e82a613c81a58c8a70712c (patch)
treeec2483555f9960411dac419f555ae280e7b106d3 /gst/mpegdemux/gstmpegdemux.c
parenta1b977dc8b3fe18c63cc7edbe2cefd38351b172c (diff)
downloadgst-plugins-bad-453b704a09ce4fbbd3e82a613c81a58c8a70712c.tar.gz
gst-plugins-bad-453b704a09ce4fbbd3e82a613c81a58c8a70712c.tar.bz2
gst-plugins-bad-453b704a09ce4fbbd3e82a613c81a58c8a70712c.zip
gst/mpegdemux/gstmpegdemux.c: Prevent a division by zero if last mux rate was zero.
Original commit message from CVS: * gst/mpegdemux/gstmpegdemux.c: (gst_flups_demux_send_data), (gst_flups_demux_parse_pack_start): Prevent a division by zero if last mux rate was zero. If we're going to send a NEWSEGMENT event but the segment start and the current buffer timestamp differ by more than a second we will start the NEWSEGMENT at the buffer timestamp. This fixes playback of the tv2-1_25.mpg file, which has 0 as first SCR but the first PTS are around 1 hour and 40 minutes. Fixes bug #553755.
Diffstat (limited to 'gst/mpegdemux/gstmpegdemux.c')
-rw-r--r--gst/mpegdemux/gstmpegdemux.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/gst/mpegdemux/gstmpegdemux.c b/gst/mpegdemux/gstmpegdemux.c
index 6859a4f6..409336e9 100644
--- a/gst/mpegdemux/gstmpegdemux.c
+++ b/gst/mpegdemux/gstmpegdemux.c
@@ -442,12 +442,22 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
if (stream == NULL)
goto no_stream;
+ /* timestamps */
+ if (demux->next_pts != G_MAXUINT64)
+ timestamp = MPEGTIME_TO_GSTTIME (demux->next_pts);
+ else
+ timestamp = GST_CLOCK_TIME_NONE;
+
/* discont */
if (stream->need_segment) {
gint64 time, start, stop;
GstEvent *newsegment;
start = demux->base_time + demux->src_segment.start;
+ if (timestamp != GST_CLOCK_TIME_NONE &&
+ GST_CLOCK_DIFF (start, timestamp) > GST_SECOND)
+ start = timestamp;
+
if (demux->src_segment.stop != -1)
stop = demux->base_time + demux->src_segment.stop;
else
@@ -481,12 +491,6 @@ gst_flups_demux_send_data (GstFluPSDemux * demux, GstFluPSStream * stream,
stream->need_segment = FALSE;
}
- /* timestamps */
- if (demux->next_pts != G_MAXUINT64)
- timestamp = MPEGTIME_TO_GSTTIME (demux->next_pts);
- else
- timestamp = GST_CLOCK_TIME_NONE;
-
/* OK, sent new segment now prepare the buffer for sending */
/* caps */
gst_buffer_set_caps (buf, GST_PAD_CAPS (stream->pad));
@@ -1123,7 +1127,7 @@ gst_flups_demux_parse_pack_start (GstFluPSDemux * demux)
/* adjustment of the SCR */
if (demux->current_scr != G_MAXUINT64) {
gint64 diff;
- guint64 old_scr, old_mux_rate, bss, adjust;
+ guint64 old_scr, old_mux_rate, bss, adjust = 0;
/* keep SCR of the previous packet */
old_scr = demux->current_scr;
@@ -1137,7 +1141,9 @@ gst_flups_demux_parse_pack_start (GstFluPSDemux * demux)
/* estimate the new SCR using the previous one according the notes
on point 2.5.2.2 of the ISO/IEC 13818-1 document */
- adjust = (bss * CLOCK_FREQ) / old_mux_rate;
+ if (old_mux_rate != 0)
+ adjust = (bss * CLOCK_FREQ) / old_mux_rate;
+
if (demux->sink_segment.rate >= 0.0)
demux->next_scr = old_scr + adjust;
else