diff options
author | Paul Gilbert | 2017-09-03 19:52:48 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-09-03 19:52:48 -0400 |
commit | e72a1d7c46a352e9d8d7850212275eee78cf4c39 (patch) | |
tree | ba75d00e78923f245cb4b7849edd6fd36a8fad70 /video | |
parent | 22e24d7c0b78801d813294718d6a320fd46fc8d9 (diff) | |
download | scummvm-rg350-e72a1d7c46a352e9d8d7850212275eee78cf4c39.tar.gz scummvm-rg350-e72a1d7c46a352e9d8d7850212275eee78cf4c39.tar.bz2 scummvm-rg350-e72a1d7c46a352e9d8d7850212275eee78cf4c39.zip |
VIDEO: Simplify AVIDecoder reverse playback special handling
Diffstat (limited to 'video')
-rw-r--r-- | video/avi_decoder.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp index 13b2c98994..ea10b95f5a 100644 --- a/video/avi_decoder.cpp +++ b/video/avi_decoder.cpp @@ -130,20 +130,35 @@ bool AVIDecoder::isSeekable() const { } const Graphics::Surface *AVIDecoder::decodeNextFrame() { - // When playing in reverse, we need to seek to the correct prior frame AVIVideoTrack *track = nullptr; bool isReversed = false; + int frameNum; + + // Check whether the video is playing in revese for (int idx = _videoTracks.size() - 1; idx >= 0; --idx) { track = static_cast<AVIVideoTrack *>(_videoTracks[idx].track); isReversed |= track->isReversed(); } if (isReversed) { - Audio::Timestamp time = track->getFrameTime(getCurFrame()); - seekIntern(time); + // For reverse mode we need to keep seeking to just before the + // desired frame prior to actually decoding a frame + frameNum = getCurFrame(); + seekIntern(track->getFrameTime(frameNum)); + } + + // Decode the next frame + const Graphics::Surface *frame = VideoDecoder::decodeNextFrame(); + + if (isReversed) { + // In reverse mode, set next frame to be the prior frame number + for (int idx = _videoTracks.size() - 1; idx >= 0; --idx) { + track = static_cast<AVIVideoTrack *>(_videoTracks[idx].track); + track->setCurFrame(frameNum - 1); + } } - return VideoDecoder::decodeNextFrame(); + return frame; } const Graphics::Surface *AVIDecoder::decodeNextTransparency() { @@ -746,7 +761,7 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) { seekTransparencyFrame(frame); // Set the video track's frame - videoTrack->setCurFrame(videoTrack->isReversed() ? frame : frame - 1); + videoTrack->setCurFrame(frame - 1); // Set the video track's search offset to the right spot _videoTracks[0].chunkSearchOffset = _indexEntries[frameIndex].offset; @@ -788,7 +803,7 @@ void AVIDecoder::seekTransparencyFrame(int frame) { } } - transTrack->setCurFrame((int)frame - 1); + transTrack->setCurFrame(frame - 1); } byte AVIDecoder::getStreamIndex(uint32 tag) { |