[Scummvm-git-logs] scummvm master -> b8f52246a8d050008da0c91fd690e674887973d5

bluegr noreply at scummvm.org
Mon May 5 13:27:19 UTC 2025


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

Summary:
a996f6bd3f IMAGE: Fix dithering 8bpp images when the container owns the palette
b8f52246a8 VIDEO: Fix checking dirty palettes in QuickTime videos


Commit: a996f6bd3f0055daa176c3420172a4b17b6fb2c4
    https://github.com/scummvm/scummvm/commit/a996f6bd3f0055daa176c3420172a4b17b6fb2c4
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-05-05T16:27:16+03:00

Commit Message:
IMAGE: Fix dithering 8bpp images when the container owns the palette

Changed paths:
    image/codecs/dither.cpp
    image/codecs/dither.h
    video/qt_decoder.cpp


diff --git a/image/codecs/dither.cpp b/image/codecs/dither.cpp
index b0480cac49e..f8ddda46dd8 100644
--- a/image/codecs/dither.cpp
+++ b/image/codecs/dither.cpp
@@ -51,7 +51,7 @@ inline uint16 makeQuickTimeDitherColor(byte r, byte g, byte b) {
 
 DitherCodec::DitherCodec(Codec *codec, DisposeAfterUse::Flag disposeAfterUse)
   : _codec(codec), _disposeAfterUse(disposeAfterUse), _dirtyPalette(false),
-    _forcedDitherPalette(0), _ditherTable(0), _ditherFrame(0) {
+    _forcedDitherPalette(0), _ditherTable(0), _ditherFrame(0), _srcPalette(nullptr) {
 }
 
 DitherCodec::~DitherCodec() {
@@ -114,8 +114,7 @@ const Graphics::Surface *DitherCodec::decodeFrame(Common::SeekableReadStream &st
 	if (!frame || _forcedDitherPalette.empty())
 		return frame;
 
-	// TODO: Handle palettes that are owned by the container instead of the codec
-	const byte *curPalette = _codec->getPalette();
+	const byte *curPalette = _codec->containsPalette() ? _codec->getPalette() : _srcPalette;
 
 	if (frame->format.isCLUT8() && curPalette) {
 		// This should always be true, but this is for sanity
diff --git a/image/codecs/dither.h b/image/codecs/dither.h
index b4aef09c049..d3a163161ba 100644
--- a/image/codecs/dither.h
+++ b/image/codecs/dither.h
@@ -45,6 +45,11 @@ public:
 	void setDither(DitherType type, const byte *palette) override;
 	void setCodecAccuracy(CodecAccuracy accuracy) override;
 
+	/**
+	 * Specify the source palette when dithering from CLUT8 to CLUT8.
+	 */
+	void setPalette(const byte *palette) { _srcPalette = palette; }
+
 	/**
 	 * Create a dither table, as used by QuickTime codecs.
 	 */
@@ -53,6 +58,7 @@ public:
 private:
 	DisposeAfterUse::Flag _disposeAfterUse;
 	Codec *_codec;
+	const byte *_srcPalette;
 
 	Graphics::Surface *_ditherFrame;
 	Graphics::Palette _forcedDitherPalette;
diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp
index 980cd8a0777..5cee66a7df0 100644
--- a/video/qt_decoder.cpp
+++ b/video/qt_decoder.cpp
@@ -863,24 +863,27 @@ const Graphics::Surface *QuickTimeDecoder::VideoTrackHandler::bufferNextFrame()
 		return 0;
 	}
 
+	// Check if the video description has been updated
+	const byte *palette = entry->_palette.data();
+	if (palette != _curPalette) {
+		_curPalette = palette;
+		_dirtyPalette = true;
+	}
+
+	// Update the palette used when dithering
+	Image::DitherCodec *ditherCodec = dynamic_cast<Image::DitherCodec *>(entry->_videoCodec);
+	if (ditherCodec && _dirtyPalette) {
+		ditherCodec->setPalette(_curPalette);
+		_dirtyPalette = false;
+	}
+
 	const Graphics::Surface *frame = entry->_videoCodec->decodeFrame(*frameData);
 	delete frameData;
 
-	// Update the palette
+	// The codec palette takes priority over the container one
 	if (entry->_videoCodec->containsPalette()) {
-		// The codec itself contains a palette
-		if (entry->_videoCodec->hasDirtyPalette()) {
-			_curPalette = entry->_videoCodec->getPalette();
-			_dirtyPalette = true;
-		}
-	} else {
-		// Check if the video description has been updated
-		const byte *palette = entry->_palette.data();
-
-		if (palette != _curPalette) {
-			_curPalette = palette;
-			_dirtyPalette = true;
-		}
+		_curPalette = entry->_videoCodec->getPalette();
+		_dirtyPalette = entry->_videoCodec->hasDirtyPalette();
 	}
 
 	return frame;


Commit: b8f52246a8d050008da0c91fd690e674887973d5
    https://github.com/scummvm/scummvm/commit/b8f52246a8d050008da0c91fd690e674887973d5
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-05-05T16:27:16+03:00

Commit Message:
VIDEO: Fix checking dirty palettes in QuickTime videos

Changed paths:
    video/qt_decoder.h


diff --git a/video/qt_decoder.h b/video/qt_decoder.h
index 8ff79a683c6..f3b3e1d667e 100644
--- a/video/qt_decoder.h
+++ b/video/qt_decoder.h
@@ -345,7 +345,7 @@ private:
 		const Graphics::Surface *decodeNextFrame();
 		Audio::Timestamp getFrameTime(uint frame) const;
 		const byte *getPalette() const;
-		bool hasDirtyPalette() const { return _curPalette; }
+		bool hasDirtyPalette() const { return _dirtyPalette; }
 		bool setReverse(bool reverse);
 		bool isReversed() const { return _reversed; }
 		bool canDither() const;




More information about the Scummvm-git-logs mailing list