summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-12-04 12:26:47 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2009-12-04 12:26:47 +0100
commit05f46051805819901cd5022f193b35c5fb3f9e11 (patch)
treef57f4591218882bd0c5cfe29b66f0c5d47e958f3
parent8bbe0d126a3532409af24a46cf4c43558c7196b4 (diff)
theoradec: don't fail on bogus granulepos
Do some additional checks on the granulpos timestamp before using it for calculating the duration because oggdemux generates wrong granulepos now. Fixes seeking somewhat again.
-rw-r--r--ext/theora/theoradec.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/theora/theoradec.c b/ext/theora/theoradec.c
index 04d31fa8a..24345194f 100644
--- a/ext/theora/theoradec.c
+++ b/ext/theora/theoradec.c
@@ -700,6 +700,12 @@ theora_dec_sink_event (GstPad * pad, GstEvent * event)
if (format != GST_FORMAT_TIME)
goto newseg_wrong_format;
+ GST_DEBUG_OBJECT (dec,
+ "newsegment: update %d, rate %g, arate %g, start %" GST_TIME_FORMAT
+ ", stop %" GST_TIME_FORMAT ", time %" GST_TIME_FORMAT,
+ update, rate, arate, GST_TIME_ARGS (start), GST_TIME_ARGS (stop),
+ GST_TIME_ARGS (time));
+
/* now configure the values */
gst_segment_set_newsegment_full (&dec->segment, update,
rate, arate, format, start, stop, time);
@@ -1258,9 +1264,15 @@ theora_handle_data_packet (GstTheoraDec * dec, ogg_packet * packet,
GST_BUFFER_OFFSET_END (out) = dec->frame_nr;
if (dec->granulepos != -1) {
gint64 cf = _theora_granule_frame (dec, dec->granulepos) + 1;
+ guint64 endtime;
+
+ endtime = gst_util_uint64_scale_int (cf * GST_SECOND,
+ dec->info.fps_denominator, dec->info.fps_numerator);
- GST_BUFFER_DURATION (out) = gst_util_uint64_scale_int (cf * GST_SECOND,
- dec->info.fps_denominator, dec->info.fps_numerator) - outtime;
+ if (endtime > outtime)
+ GST_BUFFER_DURATION (out) = endtime - outtime;
+ else
+ GST_BUFFER_DURATION (out) = GST_CLOCK_TIME_NONE;
} else {
GST_BUFFER_DURATION (out) =
gst_util_uint64_scale_int (GST_SECOND, dec->info.fps_denominator,