[Scummvm-cvs-logs] scummvm master -> 88ba96aa3cb76c7d251a60f32d41f415a40b3dc4

bluegr bluegr at gmail.com
Tue Dec 30 11:57:01 CET 2014


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
88ba96aa3c ZVISION: Fix an off-by-one error in the RLF decoder


Commit: 88ba96aa3cb76c7d251a60f32d41f415a40b3dc4
    https://github.com/scummvm/scummvm/commit/88ba96aa3cb76c7d251a60f32d41f415a40b3dc4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-30T12:55:52+02:00

Commit Message:
ZVISION: Fix an off-by-one error in the RLF decoder

A regression from 7f61a09478. 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

Changed paths:
    engines/zvision/video/rlf_decoder.cpp
    engines/zvision/video/rlf_decoder.h



diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp
index 6e2000f..db598a2 100644
--- a/engines/zvision/video/rlf_decoder.cpp
+++ b/engines/zvision/video/rlf_decoder.cpp
@@ -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;
 }
 
diff --git a/engines/zvision/video/rlf_decoder.h b/engines/zvision/video/rlf_decoder.h
index 740f3fd..8b8cbae 100644
--- a/engines/zvision/video/rlf_decoder.h
+++ b/engines/zvision/video/rlf_decoder.h
@@ -46,7 +46,7 @@ private:
 		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 @@ private:
 		Frame *_frames;
 		Common::Array<uint> _completeFrames;
 
-		int _curFrame;
+		int _displayedFrame;
 		Graphics::Surface _currentFrameBuffer;
 		uint32 _frameBufferByteSize;
 






More information about the Scummvm-git-logs mailing list