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 | |
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')
-rw-r--r-- | engines/zvision/animation_control.cpp | 2 | ||||
-rw-r--r-- | engines/zvision/rlf_animation.cpp | 31 | ||||
-rw-r--r-- | engines/zvision/rlf_animation.h | 11 |
3 files changed, 24 insertions, 20 deletions
diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp index 3f9a2e9cc7..5b35a4a468 100644 --- a/engines/zvision/animation_control.cpp +++ b/engines/zvision/animation_control.cpp @@ -94,7 +94,7 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) { return false; } - const Graphics::Surface *frame = _animation.rlf->getNextFrame(); + const Graphics::Surface *frame = _animation.rlf->decodeNextFrame(); // Animation frames for PANORAMAs are transposed, so un-transpose them RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState(); 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++; diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h index b0f7ee204e..35916de6cb 100644 --- a/engines/zvision/rlf_animation.h +++ b/engines/zvision/rlf_animation.h @@ -92,7 +92,7 @@ public: /** * Returns the pixel data of the frame specified. It will try to use - * getNextFrame() if possible. If not, it uses seekToFrame() to + * decodeNextFrame() if possible. If not, it uses seekToFrame() to * update the internal Surface and then returns a pointer to it. * This function requires _stream = false * @@ -101,19 +101,18 @@ public: */ const Graphics::Surface *getFrameData(uint frameNumber); /** - * Returns the pixel data of the next frame. It is up to the user to - * check if the next frame is valid before calling this. + * Returns the pixel data of current frame and go to next. It is up to the user to + * check if the current frame is valid before calling this. * IE. Use endOfAnimation() * * @return A pointer to the pixel data. Do NOT delete this. */ - const Graphics::Surface *getNextFrame(); - + const Graphics::Surface *decodeNextFrame(); /** * @return Is the currentFrame is the last frame in the animation? */ bool endOfAnimation() { - return _currentFrame == (int)_frameCount - 1; + return _currentFrame == (int)_frameCount; } private: |