Permalink
Browse files
ZVISION: Fix an off-by-one error in the RLF decoder
A regression from 7f61a09 . The current frame is the currently
displayed frame, not the frame that should be displayed next. Thanks to
clone2727 and Marisa-Chan for the explanation and fixes
Loading branch information
Showing
2 changed files
with
10 additions
and
10 deletions .
+8
−8
engines/zvision/video/rlf_decoder.cpp
+2
−2
engines/zvision/video/rlf_decoder.h
@@ -56,7 +56,7 @@ RLFDecoder::RLFVideoTrack::RLFVideoTrack(Common::SeekableReadStream *stream)
_height(0 ),
_frameTime(0 ),
_frames(0 ),
_curFrame (-1 ),
_displayedFrame (-1 ),
_frameBufferByteSize(0 ) {
if (!readHeader ()) {
@@ -161,11 +161,11 @@ bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) {
uint frame = getFrameAtTime (time );
assert (frame < (int )_frameCount);
if ((uint )_curFrame == frame)
if ((uint )_displayedFrame == frame)
return true ;
int closestFrame = _curFrame ;
int distance = (int )frame - _curFrame ;
int closestFrame = _displayedFrame ;
int distance = (int )frame - closestFrame ;
if (distance < 0 ) {
for (uint i = 0 ; i < _completeFrames.size (); ++i) {
@@ -189,18 +189,18 @@ bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) {
applyFrameToCurrent (i);
}
_curFrame = frame;
_displayedFrame = frame - 1 ;
return true ;
}
const Graphics::Surface *RLFDecoder::RLFVideoTrack::decodeNextFrame () {
if (_curFrame = = (int )_frameCount)
if (_displayedFrame > = (int )_frameCount)
return NULL ;
applyFrameToCurrent (_curFrame);
_displayedFrame++;
applyFrameToCurrent (_displayedFrame);
_curFrame++;
return &_currentFrameBuffer;
}
@@ -46,7 +46,7 @@ class RLFDecoder : public Video::VideoDecoder {
uint16 getWidth () const { return _width; }
uint16 getHeight () const { return _height; }
Graphics::PixelFormat getPixelFormat () const { return Graphics::PixelFormat (2 , 5 , 5 , 5 , 0 , 10 , 5 , 0 , 0 ); /* RGB 555 */ }
int getCurFrame () const { return _curFrame ; }
int getCurFrame () const { return _displayedFrame ; }
int getFrameCount () const { return _frameCount; }
const Graphics::Surface *decodeNextFrame ();
bool isSeekable () const { return true ; }
@@ -121,7 +121,7 @@ class RLFDecoder : public Video::VideoDecoder {
Frame *_frames;
Common::Array<uint > _completeFrames;
int _curFrame ;
int _displayedFrame ;
Graphics::Surface _currentFrameBuffer;
uint32 _frameBufferByteSize;
Toggle all file notes