aboutsummaryrefslogtreecommitdiff
path: root/video/codecs/cinepak.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'video/codecs/cinepak.cpp')
-rw-r--r--video/codecs/cinepak.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/video/codecs/cinepak.cpp b/video/codecs/cinepak.cpp
index c8b23dfc3f..c197e0cc35 100644
--- a/video/codecs/cinepak.cpp
+++ b/video/codecs/cinepak.cpp
@@ -73,7 +73,8 @@ CinepakDecoder::~CinepakDecoder() {
const Graphics::Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream *stream) {
_curFrame.flags = stream->readByte();
- _curFrame.length = (stream->readByte() << 16) + stream->readUint16BE();
+ _curFrame.length = (stream->readByte() << 16);
+ _curFrame.length |= stream->readUint16BE();
_curFrame.width = stream->readUint16BE();
_curFrame.height = stream->readUint16BE();
_curFrame.stripCount = stream->readUint16BE();
@@ -86,8 +87,11 @@ const Graphics::Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream
// Borrowed from FFMPEG. This should cut out the extra data Cinepak for Sega has (which is useless).
// The theory behind this is that this is here to confuse standard Cinepak decoders. But, we won't let that happen! ;)
if (_curFrame.length != (uint32)stream->size()) {
- if (stream->readUint16BE() == 0xFE00)
+ uint16 temp = stream->readUint16BE();
+ if (temp == 0xFE00)
stream->readUint32BE();
+ else if (temp != _curFrame.width)
+ stream->seek(-2, SEEK_CUR);
}
if (!_curFrame.surface) {