[Scummvm-git-logs] scummvm master -> 4702681be2f5a1e3655f01dfb285e653400b3601

sev- sev at scummvm.org
Sat Apr 7 10:03:53 CEST 2018


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4702681be2 IMAGE: Explicitly initialize CinePak codebooks


Commit: 4702681be2f5a1e3655f01dfb285e653400b3601
    https://github.com/scummvm/scummvm/commit/4702681be2f5a1e3655f01dfb285e653400b3601
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2018-04-07T10:03:50+02:00

Commit Message:
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.

Changed paths:
    image/codecs/cinepak.cpp
    image/codecs/cinepak.h


diff --git a/image/codecs/cinepak.cpp b/image/codecs/cinepak.cpp
index f356e87..1c477c8 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;
 
diff --git a/image/codecs/cinepak.h b/image/codecs/cinepak.h
index 4efb119..3b0fe47 100644
--- a/image/codecs/cinepak.h
+++ b/image/codecs/cinepak.h
@@ -94,6 +94,7 @@ private:
 	byte *_colorMap;
 	DitherType _ditherType;
 
+	void initializeCodebook(uint16 strip, byte codebookType);
 	void loadCodebook(Common::SeekableReadStream &stream, uint16 strip, byte codebookType, byte chunkID, uint32 chunkSize);
 	void decodeVectors(Common::SeekableReadStream &stream, uint16 strip, byte chunkID, uint32 chunkSize);
 





More information about the Scummvm-git-logs mailing list