From ee78825eaef2c5fffac7d6c5526fe18cec6b3eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alicia=20Boya=20Garc=C3=ADa?= Date: Sat, 31 Mar 2018 17:19:03 +0200 Subject: [PATCH] qtdemux: fix buggy duration in edits with duration=0 in fragmented files without a mehd https://bugzilla.gnome.org/show_bug.cgi?id=794858 --- gst/isomp4/qtdemux.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index 76bab967e8..a7c4ddc334 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -9476,21 +9476,20 @@ qtdemux_parse_segments (GstQTDemux * qtdemux, QtDemuxStream * stream, /* time and duration expressed in global timescale */ segment->time = stime; - /* add non scaled values so we don't cause roundoff errors */ - if (duration || media_start == GST_CLOCK_TIME_NONE) { + if (duration != 0 || empty_edit) { + /* edge case: empty edits with duration=zero are treated here. + * (files should not have these anyway). */ + + /* add non scaled values so we don't cause roundoff errors */ time += duration; stime = QTTIME_TO_GSTTIME (qtdemux, time); segment->duration = stime - segment->time; } else { /* zero duration does not imply media_start == media_stop - * but, only specify media_start.*/ - stime = QTTIME_TO_GSTTIME (qtdemux, qtdemux->duration); - if (GST_CLOCK_TIME_IS_VALID (stime) && !empty_edit - && stime >= media_start) { - segment->duration = stime - media_start; - } else { - segment->duration = GST_CLOCK_TIME_NONE; - } + * but, only specify media_start. The edit ends with the track. */ + stime = segment->duration = GST_CLOCK_TIME_NONE; + /* Don't allow more edits after this one. */ + n_segments = segment_number + 1; } segment->stop_time = stime; @@ -9498,7 +9497,8 @@ qtdemux_parse_segments (GstQTDemux * qtdemux, QtDemuxStream * stream, /* media_time expressed in stream timescale */ if (!empty_edit) { segment->media_start = media_start; - segment->media_stop = segment->media_start + segment->duration; + segment->media_stop = GST_CLOCK_TIME_IS_VALID (segment->duration) + ? segment->media_start + segment->duration : GST_CLOCK_TIME_NONE; media_segments_count++; } else { segment->media_start = GST_CLOCK_TIME_NONE;