mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
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
This commit is contained in:
parent
23f4cd0c4e
commit
69fc488392
1 changed files with 25 additions and 0 deletions
|
@ -95,6 +95,8 @@
|
||||||
|
|
||||||
#define STREAM_IS_EOS(s) (s->time_position == GST_CLOCK_TIME_NONE)
|
#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);
|
GST_DEBUG_CATEGORY (qtdemux_debug);
|
||||||
|
|
||||||
typedef struct _QtDemuxSegment QtDemuxSegment;
|
typedef struct _QtDemuxSegment QtDemuxSegment;
|
||||||
|
@ -251,6 +253,7 @@ struct _QtDemuxStream
|
||||||
guint32 n_samples_moof; /* sample count in a moof */
|
guint32 n_samples_moof; /* sample count in a moof */
|
||||||
guint64 duration_moof; /* duration in timescale of a moof, used for figure out
|
guint64 duration_moof; /* duration in timescale of a moof, used for figure out
|
||||||
* the framerate of fragmented format stream */
|
* the framerate of fragmented format stream */
|
||||||
|
guint64 duration_last_moof;
|
||||||
|
|
||||||
guint32 offset_in_sample; /* Offset in the current sample, used for
|
guint32 offset_in_sample; /* Offset in the current sample, used for
|
||||||
* streams which have got exceedingly big
|
* streams which have got exceedingly big
|
||||||
|
@ -1842,6 +1845,7 @@ _create_stream (void)
|
||||||
stream->protection_scheme_info = NULL;
|
stream->protection_scheme_info = NULL;
|
||||||
stream->n_samples_moof = 0;
|
stream->n_samples_moof = 0;
|
||||||
stream->duration_moof = 0;
|
stream->duration_moof = 0;
|
||||||
|
stream->duration_last_moof = 0;
|
||||||
g_queue_init (&stream->protection_scheme_event_queue);
|
g_queue_init (&stream->protection_scheme_event_queue);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
@ -2374,6 +2378,7 @@ gst_qtdemux_stream_flush_samples_data (GstQTDemux * qtdemux,
|
||||||
|
|
||||||
stream->n_samples_moof = 0;
|
stream->n_samples_moof = 0;
|
||||||
stream->duration_moof = 0;
|
stream->duration_moof = 0;
|
||||||
|
stream->duration_last_moof = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -3119,6 +3124,25 @@ qtdemux_parse_trun (GstQTDemux * qtdemux, GstByteReader * trun,
|
||||||
stream->samples[stream->n_samples - 1].timestamp +
|
stream->samples[stream->n_samples - 1].timestamp +
|
||||||
stream->samples[stream->n_samples - 1].duration;
|
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_ts = QTSTREAMTIME_TO_GSTTIME (stream, timestamp);
|
||||||
GST_INFO_OBJECT (qtdemux, "first sample ts %" GST_TIME_FORMAT
|
GST_INFO_OBJECT (qtdemux, "first sample ts %" GST_TIME_FORMAT
|
||||||
" (extends previous samples)", GST_TIME_ARGS (gst_ts));
|
" (extends previous samples)", GST_TIME_ARGS (gst_ts));
|
||||||
|
@ -3785,6 +3809,7 @@ qtdemux_parse_moof (GstQTDemux * qtdemux, const guint8 * buffer, guint length,
|
||||||
|
|
||||||
/* initialise moof sample data */
|
/* initialise moof sample data */
|
||||||
stream->n_samples_moof = 0;
|
stream->n_samples_moof = 0;
|
||||||
|
stream->duration_last_moof = stream->duration_moof;
|
||||||
stream->duration_moof = 0;
|
stream->duration_moof = 0;
|
||||||
|
|
||||||
/* Track Run node */
|
/* Track Run node */
|
||||||
|
|
Loading…
Reference in a new issue