diff options
author | Marisa-Chan | 2013-11-07 17:06:25 +0700 |
---|---|---|
committer | Marisa-Chan | 2013-11-07 17:06:25 +0700 |
commit | 7bd57a9ad6bfa551ce2fb605b71fa78e38c5fe88 (patch) | |
tree | 6e8c0542fd8378c3aca7933261b73801031b66f8 /engines/zvision/rlf_animation.cpp | |
parent | b635fab6e663b0fac154d4fa75d221db4aabb1f5 (diff) | |
download | scummvm-rg350-7bd57a9ad6bfa551ce2fb605b71fa78e38c5fe88.tar.gz scummvm-rg350-7bd57a9ad6bfa551ce2fb605b71fa78e38c5fe88.tar.bz2 scummvm-rg350-7bd57a9ad6bfa551ce2fb605b71fa78e38c5fe88.zip |
ZVISION: Make rlf animation logic equivalent to video decoder methods.
Diffstat (limited to 'engines/zvision/rlf_animation.cpp')
-rw-r--r-- | engines/zvision/rlf_animation.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp index 795167e572..dab32aed17 100644 --- a/engines/zvision/rlf_animation.cpp +++ b/engines/zvision/rlf_animation.cpp @@ -43,7 +43,7 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream) _height(0), _frameTime(0), _frames(0), - _currentFrame(-1), + _currentFrame(0), _frameBufferByteSize(0) { if (!_file.open(fileName)) { warning("RLF animation file %s could not be opened", fileName.c_str()); @@ -157,8 +157,11 @@ void RlfAnimation::seekToFrame(int frameNumber) { assert(!_stream); assert(frameNumber < (int)_frameCount || frameNumber >= -1); - if (frameNumber == -1) { - _currentFrame = -1; + if (_currentFrame == frameNumber) + return; + + if (frameNumber < 0) { + _currentFrame = 0; return; } @@ -166,13 +169,15 @@ void RlfAnimation::seekToFrame(int frameNumber) { int distance = (int)frameNumber - _currentFrame; for (uint i = 0; i < _completeFrames.size(); ++i) { int newDistance = (int)frameNumber - (int)(_completeFrames[i]); - if (newDistance > 0 && (closestFrame == -1 || newDistance < distance)) { + if (newDistance < 0) + break; + if (newDistance > 0 && newDistance < distance) { closestFrame = _completeFrames[i]; distance = newDistance; } } - for (int i = closestFrame; i <= frameNumber; ++i) { + for (int i = closestFrame; i < frameNumber; ++i) { applyFrameToCurrent(i); } @@ -184,24 +189,24 @@ const Graphics::Surface *RlfAnimation::getFrameData(uint frameNumber) { assert(frameNumber < _frameCount); // Since this method is so expensive, first check to see if we can use - // getNextFrame() it's cheap. - if ((int)frameNumber == _currentFrame) { + // decodeNextFrame() it's cheap. + if ((int)frameNumber == _currentFrame - 1) { return &_currentFrameBuffer; - } else if (_currentFrame + 1 == (int)frameNumber) { - return getNextFrame(); + } else if (_currentFrame == (int)frameNumber) { + return decodeNextFrame(); } seekToFrame(frameNumber); - return &_currentFrameBuffer; + return decodeNextFrame(); } -const Graphics::Surface *RlfAnimation::getNextFrame() { - assert(_currentFrame + 1 < (int)_frameCount); +const Graphics::Surface *RlfAnimation::decodeNextFrame() { + assert(_currentFrame < (int)_frameCount); if (_stream) { applyFrameToCurrent(readNextFrame()); } else { - applyFrameToCurrent(_currentFrame + 1); + applyFrameToCurrent(_currentFrame); } _currentFrame++; |