[Scummvm-git-logs] scummvm master -> 9b0c049e83dfedb6a0e85d4e29f0ffc1e1cdfbc3

AndywinXp noreply at scummvm.org
Tue Jul 2 21:09:23 UTC 2024


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:
9b0c049e83 SCUMM: SMUSH: Fix color banding issues


Commit: 9b0c049e83dfedb6a0e85d4e29f0ffc1e1cdfbc3
    https://github.com/scummvm/scummvm/commit/9b0c049e83dfedb6a0e85d4e29f0ffc1e1cdfbc3
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-07-02T23:09:19+02:00

Commit Message:
SCUMM: SMUSH: Fix color banding issues

Fixes the main issue of #15026:
"SCUMM: DIG: Color depth issues & artifacting
in some shots in SMUSH videos".

Verified from FT, DIG and COMI disassemblies.

Changed paths:
    engines/scumm/smush/smush_player.cpp
    engines/scumm/smush/smush_player.h


diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp
index fd9d6acc066..7cf0591373a 100644
--- a/engines/scumm/smush/smush_player.cpp
+++ b/engines/scumm/smush/smush_player.cpp
@@ -248,6 +248,10 @@ SmushPlayer::SmushPlayer(ScummEngine_v7 *scumm, IMuseDigital *imuseDigital, Insa
 	_pauseStartTime = 0;
 	_pauseTime = 0;
 
+	memset(_pal, 0, sizeof(byte));
+	memset(_deltaPal, 0, sizeof(int16));
+	memset(_shiftedDeltaPal, 0, sizeof(int32));
+
 	for (int i = 0; i < 4; i++)
 		_iactTable[i] = 0;
 
@@ -699,36 +703,31 @@ void SmushPlayer::readPalette(byte *out, Common::SeekableReadStream &in) {
 	in.read(out, 0x300);
 }
 
-static byte delta_color(byte org_color, int16 delta_color) {
-	int t = (org_color * 129 + delta_color) / 128;
-	return CLIP(t, 0, 255);
-}
-
 void SmushPlayer::handleDeltaPalette(int32 subSize, Common::SeekableReadStream &b) {
 	debugC(DEBUG_SMUSH, "SmushPlayer::handleDeltaPalette()");
 
-	if (subSize == 0x300 * 3 + 4) {
+	b.readUint16LE();
+	uint16 xpalCommand = b.readUint16LE();
 
+	if (xpalCommand == 256) {
 		b.readUint16LE();
-		b.readUint16LE();
-
-		for (int i = 0; i < 0x300; i++) {
-			_deltaPal[i] = b.readUint16LE();
+		for (int i = 0; i < 768; ++i) {
+			_shiftedDeltaPal[i] += _deltaPal[i];
+			
+			_pal[i] = CLIP(_shiftedDeltaPal[i] >> 7, 0, 255);
 		}
-		readPalette(_pal, b);
+
 		setDirtyColors(0, 255);
-	} else if (subSize == 6) {
+	} else {
+		for (int j = 0; j < 768; ++j) {
+			_shiftedDeltaPal[j] = _pal[j] << 7;
+			_deltaPal[j] = b.readUint16LE();
+		}
 
-		b.readUint16LE();
-		b.readUint16LE();
-		b.readUint16LE();
+		if (xpalCommand == 512)
+			readPalette(_pal, b);
 
-		for (int i = 0; i < 0x300; i++) {
-			_pal[i] = delta_color(_pal[i], _deltaPal[i]);
-		}
 		setDirtyColors(0, 255);
-	} else {
-		error("SmushPlayer::handleDeltaPalette() Wrong size for DeltaPalette");
 	}
 }
 
diff --git a/engines/scumm/smush/smush_player.h b/engines/scumm/smush/smush_player.h
index de1d1c65dc8..557203d9776 100644
--- a/engines/scumm/smush/smush_player.h
+++ b/engines/scumm/smush/smush_player.h
@@ -130,6 +130,7 @@ private:
 	Insane *_insane;
 	int32 _nbframes;
 	int16 _deltaPal[0x300];
+	int32 _shiftedDeltaPal[0x300];
 	byte _pal[0x300];
 	SmushFont *_sf[5];
 	StringResource *_strings;




More information about the Scummvm-git-logs mailing list