From a064b7bc0b38268b14d52755d8d3747db28240ae Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 3 Oct 2011 18:47:25 -0400 Subject: VIDEO: Fix Cinepak variant detection --- video/codecs/cinepak.cpp | 8 ++++++-- 1 file 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) { -- cgit v1.2.3