qtmux: Allow up to 1 trak timescale unit of lateness in prefill mode

For 59.94 FPS, it's common to set 60000 as timescale. For that
timescale, if the audio is late by as little as 0:00:00.000016666
(definitely less than one audio sample), lateness gets rounded to 1.
Added a safeguard that allows lateness up to 1 sample with the specific
trak's timescale, to make sure that values less than e.g. one audio
sample won't break the prefill mode. What will happen in this case is
that the audio will get squeezed back to the video's timestamp, which in
practice means that the audio will be 0.000016666 seconds early (with
the patch).

https://bugzilla.gnome.org/show_bug.cgi?id=797133
This commit is contained in:
Vivia Nikolaidou 2018-09-12 17:24:00 +03:00
parent 43c5db3c72
commit 94f8603411

View file

@ -3454,13 +3454,18 @@ gst_qt_mux_update_edit_lists (GstQTMux * qtmux)
has_gap = (qtpad->first_ts > (qtmux->first_ts + qtpad->dts_adjustment));
if (has_gap) {
GstClockTime diff;
GstClockTime diff, trak_lateness;
diff = qtpad->first_ts - (qtmux->first_ts + qtpad->dts_adjustment);
lateness = gst_util_uint64_scale_round (diff,
qtmux->timescale, GST_SECOND);
/* Allow up to 1 trak timescale unit of lateness, Such a small
* timestamp/duration can't be represented by the trak-specific parts
* of the headers anyway, so it's irrelevantly small */
trak_lateness = gst_util_uint64_scale (diff,
atom_trak_get_timescale (qtpad->trak), GST_SECOND);
if (lateness > 0) {
if (lateness > 0 && trak_lateness > 0) {
GST_DEBUG_OBJECT (qtmux,
"Pad %s is a late stream by %" GST_TIME_FORMAT,
GST_PAD_NAME (qtpad->collect.pad), GST_TIME_ARGS (diff));