summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrique Ocaña González <eocanha@igalia.com>2016-10-24 16:56:31 +0000
committerSebastian Dröge <sebastian@centricular.com>2016-12-05 11:05:50 +0200
commita2adb7e305ab2d0a04f2b9549fead89f539fd623 (patch)
tree52f089bcee21f5690d772ed707d8651d6b534878
parent235d243dee04d8260774c524a985f58bf20ed61f (diff)
qtdemux: Use the tfdt decode time on byte streams when it's significantly different than the time in the last sample
We consider there's a sifnificant difference when it's larger than on second or than half the duration of the last processed fragment in case the latter is larger. https://bugzilla.gnome.org/show_bug.cgi?id=754230
-rw-r--r--gst/isomp4/qtdemux.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c
index 13b3620cd..c2cafa84e 100644
--- a/gst/isomp4/qtdemux.c
+++ b/gst/isomp4/qtdemux.c
@@ -95,6 +95,8 @@
#define STREAM_IS_EOS(s) (s->time_position == GST_CLOCK_TIME_NONE)
+#define ABSDIFF(x, y) ( (x) > (y) ? ((x) - (y)) : ((y) - (x)) )
+
GST_DEBUG_CATEGORY (qtdemux_debug);
typedef struct _QtDemuxSegment QtDemuxSegment;
@@ -251,6 +253,7 @@ struct _QtDemuxStream
guint32 n_samples_moof; /* sample count in a moof */
guint64 duration_moof; /* duration in timescale of a moof, used for figure out
* the framerate of fragmented format stream */
+ guint64 duration_last_moof;
guint32 offset_in_sample; /* Offset in the current sample, used for
* streams which have got exceedingly big
@@ -1845,6 +1848,7 @@ _create_stream (void)
stream->n_samples_moof = 0;
stream->duration_moof = 0;
stream->alignment = 1;
+ stream->duration_last_moof = 0;
g_queue_init (&stream->protection_scheme_event_queue);
return stream;
}
@@ -2377,6 +2381,7 @@ gst_qtdemux_stream_flush_samples_data (GstQTDemux * qtdemux,
stream->n_samples_moof = 0;
stream->duration_moof = 0;
+ stream->duration_last_moof = 0;
}
static void
@@ -3122,6 +3127,25 @@ qtdemux_parse_trun (GstQTDemux * qtdemux, GstByteReader * trun,
stream->samples[stream->n_samples - 1].timestamp +
stream->samples[stream->n_samples - 1].duration;
+ /* If this is a GST_FORMAT_BYTES stream and there's a significant
+ * difference (1 sec.) between decode_ts and timestamp, prefer the
+ * former */
+ if (!qtdemux->upstream_format_is_time
+ && ABSDIFF (decode_ts, timestamp) >
+ MAX (stream->duration_last_moof / 2,
+ GSTTIME_TO_QTSTREAMTIME (stream, GST_SECOND))) {
+ GST_INFO_OBJECT (qtdemux,
+ "decode_ts (%" GST_TIME_FORMAT ") and timestamp (%" GST_TIME_FORMAT
+ ") are significantly different (more than %" GST_TIME_FORMAT
+ "), using decode_ts",
+ GST_TIME_ARGS (QTSTREAMTIME_TO_GSTTIME (stream, decode_ts)),
+ GST_TIME_ARGS (QTSTREAMTIME_TO_GSTTIME (stream, timestamp)),
+ GST_TIME_ARGS (QTSTREAMTIME_TO_GSTTIME (stream,
+ MAX (stream->duration_last_moof / 2,
+ GSTTIME_TO_QTSTREAMTIME (stream, GST_SECOND)))));
+ timestamp = decode_ts;
+ }
+
gst_ts = QTSTREAMTIME_TO_GSTTIME (stream, timestamp);
GST_INFO_OBJECT (qtdemux, "first sample ts %" GST_TIME_FORMAT
" (extends previous samples)", GST_TIME_ARGS (gst_ts));
@@ -3788,6 +3812,7 @@ qtdemux_parse_moof (GstQTDemux * qtdemux, const guint8 * buffer, guint length,
/* initialise moof sample data */
stream->n_samples_moof = 0;
+ stream->duration_last_moof = stream->duration_moof;
stream->duration_moof = 0;
/* Track Run node */