VIDEO: Fix FLIC looping

Thanks to salty-horse for finding this. Also, use Common::Rational directly to hold the frame rate to avoid rounding.

svn-id: r51516
This commit is contained in:
Matthew Hoops 2010-07-30 20:35:09 +00:00
parent 75b5ac38fb
commit 8e705bb2e2
2 changed files with 8 additions and 9 deletions

View File

@ -71,9 +71,8 @@ bool FlicDecoder::load(Common::SeekableReadStream &stream) {
_fileStream->readUint16LE(); // flags
// Note: The normal delay is a 32-bit integer (dword), whereas the overriden delay is a 16-bit integer (word)
// frameDelay is the FLIC "speed", in milliseconds. Our frameDelay is calculated in 1/100 ms, so we convert it here
uint32 frameDelay = 100 * _fileStream->readUint32LE();
_frameRate = 100 * 1000 / frameDelay;
// the frame delay is the FLIC "speed", in milliseconds.
_frameRate = Common::Rational(1000, _fileStream->readUint32LE());
_fileStream->seek(80);
_offsetFrame1 = _fileStream->readUint32LE();
@ -209,10 +208,10 @@ Surface *FlicDecoder::decodeNextFrame() {
chunkCount = _fileStream->readUint16LE();
// Note: The overriden delay is a 16-bit integer (word), whereas the normal delay is a 32-bit integer (dword)
// frameDelay is the FLIC "speed", in milliseconds. Our frameDelay is calculated in 1/100 ms, so we convert it here
// the frame delay is the FLIC "speed", in milliseconds.
uint16 newFrameDelay = _fileStream->readUint16LE(); // "speed", in milliseconds
if (newFrameDelay > 0)
_frameRate = 1000 / newFrameDelay;
_frameRate = Common::Rational(1000, newFrameDelay);
_fileStream->readUint16LE(); // reserved, always 0
uint16 newWidth = _fileStream->readUint16LE();
@ -268,15 +267,15 @@ Surface *FlicDecoder::decodeNextFrame() {
_curFrame++;
if (_curFrame == 0)
_startTime = g_system->getMillis();
// If we just processed the ring frame, set the next frame
if (_curFrame == (int32)_frameCount) {
_curFrame = 0;
_fileStream->seek(_offsetFrame2);
}
if (_curFrame == 0)
_startTime = g_system->getMillis();
return _surface;
}

View File

@ -91,7 +91,7 @@ private:
Common::SeekableReadStream *_fileStream;
Surface *_surface;
uint32 _frameCount;
uint32 _frameRate;
Common::Rational _frameRate;
Common::List<Common::Rect> _dirtyRects;
};