From 8e705bb2e26f0900416e5649b869ee43706eeee5 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Fri, 30 Jul 2010 20:35:09 +0000 Subject: 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 --- graphics/video/flic_decoder.cpp | 15 +++++++-------- graphics/video/flic_decoder.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'graphics') diff --git a/graphics/video/flic_decoder.cpp b/graphics/video/flic_decoder.cpp index b07e369cd8..524e157269 100644 --- a/graphics/video/flic_decoder.cpp +++ b/graphics/video/flic_decoder.cpp @@ -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; } diff --git a/graphics/video/flic_decoder.h b/graphics/video/flic_decoder.h index 60d68889a2..60f4e3472c 100644 --- a/graphics/video/flic_decoder.h +++ b/graphics/video/flic_decoder.h @@ -91,7 +91,7 @@ private: Common::SeekableReadStream *_fileStream; Surface *_surface; uint32 _frameCount; - uint32 _frameRate; + Common::Rational _frameRate; Common::List _dirtyRects; }; -- cgit v1.2.3