[Scummvm-cvs-logs] SF.net SVN: scummvm:[49154] scummvm/trunk/engines

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Sun May 23 13:16:10 CEST 2010


Revision: 49154
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49154&view=rev
Author:   eriktorbjorn
Date:     2010-05-23 11:16:10 +0000 (Sun, 23 May 2010)

Log Message:
-----------
Another video player regression: When the palette changes, look up the
lightest/darkest available colours to use as white/black for the subtitles. It
is possible that we could get away with fixed values for Broken Sword 2, since
it has always had subtitles. But for Broken Sword 1, subtitles is a ScummVM
addition, and we can't.

Modified Paths:
--------------
    scummvm/trunk/engines/sword1/animation.cpp
    scummvm/trunk/engines/sword1/animation.h
    scummvm/trunk/engines/sword2/animation.cpp
    scummvm/trunk/engines/sword2/animation.h

Modified: scummvm/trunk/engines/sword1/animation.cpp
===================================================================
--- scummvm/trunk/engines/sword1/animation.cpp	2010-05-23 10:50:14 UTC (rev 49153)
+++ scummvm/trunk/engines/sword1/animation.cpp	2010-05-23 11:16:10 UTC (rev 49154)
@@ -23,7 +23,6 @@
  *
  */
 
-
 #include "common/file.h"
 #include "sword1/sword1.h"
 #include "sword1/animation.h"
@@ -72,6 +71,9 @@
 	_bgSoundStream = NULL;
 	_decoderType = decoderType;
 	_decoder = decoder;
+
+	_white = 255;
+	_black = 0;
 }
 
 MoviePlayer::~MoviePlayer() {
@@ -254,9 +256,35 @@
 			if (frame)
 				_vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
 
-			if (_decoder->hasDirtyPalette())
+			if (_decoder->hasDirtyPalette()) {
 				_decoder->setSystemPalette();
 
+				uint32 maxWeight = 0;
+				uint32 minWeight = 0xFFFFFFFF;
+				uint32 weight;
+				byte r, g, b;
+				
+				byte *palette = _decoder->getPalette();
+
+				for (int i = 0; i < 256; i++) {
+					r = *palette++;
+					g = *palette++;
+					b = *palette++;
+
+					weight = 3 * r * r + 6 * g * g + 2 * b * b;
+
+					if (weight >= maxWeight) {
+						maxWeight = weight;
+						_white = i;
+					}
+
+					if (weight <= minWeight) {
+						minWeight = weight;
+						_black = i;
+					}
+				}
+			}
+
 			Graphics::Surface *screen = _vm->_system->lockScreen();
 			performPostProcessing((byte *)screen->pixels);
 			_vm->_system->unlockScreen();
@@ -275,11 +303,11 @@
 }
 
 byte MoviePlayer::findBlackPalIndex() {
-	return 0;
+	return _black;
 }
 
 byte MoviePlayer::findWhitePalIndex() {
-	return 0xff;
+	return _white;
 }
 
 DXADecoderWithSound::DXADecoderWithSound(Audio::Mixer *mixer, Audio::SoundHandle *bgSoundHandle)

Modified: scummvm/trunk/engines/sword1/animation.h
===================================================================
--- scummvm/trunk/engines/sword1/animation.h	2010-05-23 10:50:14 UTC (rev 49153)
+++ scummvm/trunk/engines/sword1/animation.h	2010-05-23 11:16:10 UTC (rev 49154)
@@ -85,6 +85,7 @@
 	OSystem *_system;
 	Common::Array<MovieText *> _movieTexts;
 	int _textX, _textY, _textWidth, _textHeight;
+	byte _white, _black;
 	DecoderType _decoderType;
 
 	Graphics::VideoDecoder *_decoder;

Modified: scummvm/trunk/engines/sword2/animation.cpp
===================================================================
--- scummvm/trunk/engines/sword2/animation.cpp	2010-05-23 10:50:14 UTC (rev 49153)
+++ scummvm/trunk/engines/sword2/animation.cpp	2010-05-23 11:16:10 UTC (rev 49154)
@@ -51,6 +51,9 @@
 	_bgSoundStream = NULL;
 	_decoderType = decoderType;
 	_decoder = decoder;
+
+	_white = 255;
+	_black = 0;
 }
 
 MoviePlayer:: ~MoviePlayer() {
@@ -280,9 +283,35 @@
 			if (frame)
 				_vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
 
-			if (_decoder->hasDirtyPalette())
+			if (_decoder->hasDirtyPalette()) {
 				_decoder->setSystemPalette();
 
+				uint32 maxWeight = 0;
+				uint32 minWeight = 0xFFFFFFFF;
+				uint32 weight;
+				byte r, g, b;
+				
+				byte *palette = _decoder->getPalette();
+
+				for (int i = 0; i < 256; i++) {
+					r = *palette++;
+					g = *palette++;
+					b = *palette++;
+
+					weight = 3 * r * r + 6 * g * g + 2 * b * b;
+
+					if (weight >= maxWeight) {
+						maxWeight = weight;
+						_white = i;
+					}
+
+					if (weight <= minWeight) {
+						minWeight = weight;
+						_black = i;
+					}
+				}
+			}
+
 			Graphics::Surface *screen = _vm->_system->lockScreen();
 			performPostProcessing((byte *)screen->pixels);
 			_vm->_system->unlockScreen();
@@ -301,11 +330,11 @@
 }
 
 byte MoviePlayer::findBlackPalIndex() {
-	return 0;
+	return _black;
 }
 
 byte MoviePlayer::findWhitePalIndex() {
-	return 0xff;
+	return _white;
 }
 
 DXADecoderWithSound::DXADecoderWithSound(Audio::Mixer *mixer, Audio::SoundHandle *bgSoundHandle)

Modified: scummvm/trunk/engines/sword2/animation.h
===================================================================
--- scummvm/trunk/engines/sword2/animation.h	2010-05-23 10:50:14 UTC (rev 49153)
+++ scummvm/trunk/engines/sword2/animation.h	2010-05-23 11:16:10 UTC (rev 49154)
@@ -87,6 +87,7 @@
 	uint32 _currentMovieText;
 	byte *_textSurface;
 	int _textX, _textY;
+	byte _white, _black;
 	DecoderType _decoderType;
 
 	Graphics::VideoDecoder *_decoder;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list