qtdemux: fix conditions for end of segment in reverse playback
authorMathieu Duponchelle <mathieu@centricular.com>
Tue, 9 Jul 2019 21:12:45 +0000 (23:12 +0200)
committerMathieu Duponchelle <mduponchelle1@gmail.com>
Tue, 9 Jul 2019 21:21:20 +0000 (21:21 +0000)
The time_position field of the stream is offset by the media_start
of its QtDemuxSegment compared to the start of the GstSegment of
the demuxer, take it into account when making comparisons.

gst/isomp4/qtdemux.c

index 8e03d6a..f7994b8 100644 (file)
@@ -6305,8 +6305,16 @@ gst_qtdemux_loop_state_movie (GstQTDemux * qtdemux)
     stream = QTDEMUX_NTH_STREAM (qtdemux, i);
     position = stream->time_position;
 
+    if (!GST_CLOCK_TIME_IS_VALID (position))
+      continue;
+
+    if (stream->segment_index != -1) {
+      QtDemuxSegment *segment = &stream->segments[stream->segment_index];
+      position += segment->media_start;
+    }
+
     /* position of -1 is EOS */
-    if (position != GST_CLOCK_TIME_NONE && position < min_time) {
+    if (position < min_time) {
       min_time = position;
       target_stream = stream;
     }