diff options
author | Torbjörn Andersson | 2018-03-25 07:37:49 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2018-04-07 10:03:50 +0200 |
commit | 4702681be2f5a1e3655f01dfb285e653400b3601 (patch) | |
tree | 1859cf57d95d46094104f3fa61f7a7195f0c9e8e /image/codecs/cinepak.cpp | |
parent | 7f6d431fe301d52d927f4c5b00bc43701c41a2de (diff) | |
download | scummvm-rg350-4702681be2f5a1e3655f01dfb285e653400b3601.tar.gz scummvm-rg350-4702681be2f5a1e3655f01dfb285e653400b3601.tar.bz2 scummvm-rg350-4702681be2f5a1e3655f01dfb285e653400b3601.zip |
IMAGE: Explicitly initialize CinePak codebooks
Starship Titanic produces lots of "uninitialized value" warnings
at the very beginning of the game, when turning right. This is
because in the very first movie frame it uses codebooks that have
not been loaded. Explicitly set their data to 0 to guarantee
consistent behavior.
Diffstat (limited to 'image/codecs/cinepak.cpp')
-rw-r--r-- | image/codecs/cinepak.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/image/codecs/cinepak.cpp b/image/codecs/cinepak.cpp index f356e87971..1c477c82d5 100644 --- a/image/codecs/cinepak.cpp +++ b/image/codecs/cinepak.cpp @@ -405,8 +405,13 @@ const Graphics::Surface *CinepakDecoder::decodeFrame(Common::SeekableReadStream _curFrame.height = stream.readUint16BE(); _curFrame.stripCount = stream.readUint16BE(); - if (!_curFrame.strips) + if (!_curFrame.strips) { _curFrame.strips = new CinepakStrip[_curFrame.stripCount]; + for (uint16 i = 0; i < _curFrame.stripCount; i++) { + initializeCodebook(i, 1); + initializeCodebook(i, 4); + } + } debug(4, "Cinepak Frame: Width = %d, Height = %d, Strip Count = %d", _curFrame.width, _curFrame.height, _curFrame.stripCount); @@ -499,6 +504,19 @@ const Graphics::Surface *CinepakDecoder::decodeFrame(Common::SeekableReadStream return _curFrame.surface; } +void CinepakDecoder::initializeCodebook(uint16 strip, byte codebookType) { + CinepakCodebook *codebook = (codebookType == 1) ? _curFrame.strips[strip].v1_codebook : _curFrame.strips[strip].v4_codebook; + + for (uint16 i = 0; i < 256; i++) { + memset(codebook[i].y, 0, 4); + codebook[i].u = 0; + codebook[i].v = 0; + + if (_ditherType == kDitherTypeQT) + ditherCodebookQT(strip, codebookType, i); + } +} + void CinepakDecoder::loadCodebook(Common::SeekableReadStream &stream, uint16 strip, byte codebookType, byte chunkID, uint32 chunkSize) { CinepakCodebook *codebook = (codebookType == 1) ? _curFrame.strips[strip].v1_codebook : _curFrame.strips[strip].v4_codebook; |