From 9b9600a50f10cdc5dcfc1d43c0ff27a5728a98ef Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sun, 1 Oct 2017 09:51:41 +0200 Subject: VIDEO: Express VideoDecoder::endOfVideo using easier to understand logic --- video/video_decoder.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'video') diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp index 980138c13e..6e408ba3d3 100644 --- a/video/video_decoder.cpp +++ b/video/video_decoder.cpp @@ -293,9 +293,14 @@ uint32 VideoDecoder::getTimeToNextFrame() const { } bool VideoDecoder::endOfVideo() const { - for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) - if (!(*it)->endOfTrack() && (!isPlaying() || (*it)->getTrackType() != Track::kTrackTypeVideo || !_endTimeSet || ((VideoTrack *)*it)->getNextFrameStartTime() < (uint)_endTime.msecs())) + for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) { + const Track *track = *it; + + bool videoEndTimeReached = _endTimeSet && track->getTrackType() == Track::kTrackTypeVideo && ((const VideoTrack *)track)->getNextFrameStartTime() >= (uint)_endTime.msecs(); + bool endReached = track->endOfTrack() || (isPlaying() && videoEndTimeReached); + if (!endReached) return false; + } return true; } @@ -910,9 +915,17 @@ bool VideoDecoder::hasFramesLeft() const { // This is similar to endOfVideo(), except it doesn't take Audio into account (and returns true if not the end of the video) // This is only used for needsUpdate() atm so that setEndTime() works properly // And unlike endOfVideoTracks(), this takes into account _endTime - for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) - if ((*it)->getTrackType() == Track::kTrackTypeVideo && !(*it)->endOfTrack() && (!isPlaying() || !_endTimeSet || ((VideoTrack *)*it)->getNextFrameStartTime() < (uint)_endTime.msecs())) + for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) { + if ((*it)->getTrackType() != Track::kTrackTypeVideo) + continue; + + const VideoTrack *track = (const VideoTrack *)*it; + + bool videoEndTimeReached = _endTimeSet && track->getNextFrameStartTime() >= (uint)_endTime.msecs(); + bool endReached = track->endOfTrack() || (isPlaying() && videoEndTimeReached); + if (!endReached) return true; + } return false; } -- cgit v1.2.3