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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Thu Nov 11 20:22:57 CET 2010


Revision: 54210
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54210&view=rev
Author:   thebluegr
Date:     2010-11-11 19:22:56 +0000 (Thu, 11 Nov 2010)

Log Message:
-----------
SCI: Some video related changes

- Now playVideo() is used when playing videos from the console (reducing
code duplication)
- Added support for 16bpp scaling in scale2x, so that the 16-bit color
Duck videos are scaled correctly

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/engine/kvideo.cpp
    scummvm/trunk/engines/sci/graphics/screen.cpp
    scummvm/trunk/engines/sci/graphics/screen.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2010-11-11 19:20:26 UTC (rev 54209)
+++ scummvm/trunk/engines/sci/console.cpp	2010-11-11 19:22:56 UTC (rev 54210)
@@ -226,6 +226,8 @@
 	_engine->pauseEngine(true);
 }
 
+extern void playVideo(Graphics::VideoDecoder *videoDecoder);
+
 void Console::postEnter() {
 	if (!_videoFile.empty()) {
 		Graphics::VideoDecoder *videoDecoder = 0;
@@ -270,37 +272,8 @@
 			}
 #endif
 
-			uint16 x = (g_system->getWidth() - videoDecoder->getWidth()) / 2;
-			uint16 y = (g_system->getHeight() - videoDecoder->getHeight()) / 2;
-			bool skipVideo = false;
+			playVideo(videoDecoder);
 
-			if (videoDecoder->hasDirtyPalette())
-				videoDecoder->setSystemPalette();
-
-			while (!g_engine->shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {
-				if (videoDecoder->needsUpdate()) {
-					Graphics::Surface *frame = videoDecoder->decodeNextFrame();
-					if (frame) {
-						g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
-
-						if (videoDecoder->hasDirtyPalette())
-							videoDecoder->setSystemPalette();
-
-						g_system->updateScreen();
-					}
-				}
-
-				Common::Event event;
-				while (g_system->getEventManager()->pollEvent(event)) {
-					if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP)
-						skipVideo = true;
-				}
-
-				g_system->delayMillis(10);
-			}
-		
-			delete videoDecoder;
-
 #ifdef ENABLE_SCI32
 			// Switch back to 8bpp if we played a duck video
 			if (duckMode)

Modified: scummvm/trunk/engines/sci/engine/kvideo.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kvideo.cpp	2010-11-11 19:20:26 UTC (rev 54209)
+++ scummvm/trunk/engines/sci/engine/kvideo.cpp	2010-11-11 19:22:56 UTC (rev 54210)
@@ -44,16 +44,18 @@
 		return;
 
 	byte *scaleBuffer = 0;
+	byte bytesPerPixel = videoDecoder->getPixelFormat().bytesPerPixel;
 	uint16 width = videoDecoder->getWidth();
 	uint16 height = videoDecoder->getHeight();
+	uint16 pitch = videoDecoder->getWidth() * bytesPerPixel;
 	uint16 screenWidth = g_system->getWidth();
 	uint16 screenHeight = g_system->getHeight();
 
 	if (screenWidth == 640 && width <= 320 && height <= 240) {
-		assert(videoDecoder->getPixelFormat().bytesPerPixel == 1);
 		width *= 2;
 		height *= 2;
-		scaleBuffer = new byte[width * height];
+		pitch *= 2;
+		scaleBuffer = new byte[width * height * bytesPerPixel];
 	}
 
 	uint16 x = (screenWidth - width) / 2;
@@ -69,8 +71,8 @@
 			if (frame) {
 				if (scaleBuffer) {
 					// TODO: Probably should do aspect ratio correction in e.g. GK1 Windows 
-					g_sci->_gfxScreen->scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight());
-					g_system->copyRectToScreen(scaleBuffer, width, x, y, width, height);
+					g_sci->_gfxScreen->scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);
+					g_system->copyRectToScreen(scaleBuffer, pitch, x, y, width, height);
 				} else
 					g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, width, height);
 

Modified: scummvm/trunk/engines/sci/graphics/screen.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/screen.cpp	2010-11-11 19:20:26 UTC (rev 54209)
+++ scummvm/trunk/engines/sci/graphics/screen.cpp	2010-11-11 19:22:56 UTC (rev 54210)
@@ -654,20 +654,41 @@
 	copyToScreen();
 }
 
-void GfxScreen::scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight) {
+void GfxScreen::scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel) {
+	assert(bytesPerPixel == 1 || bytesPerPixel == 2);
 	const int newWidth = srcWidth * 2;
+	const int pitch = newWidth * bytesPerPixel;
 	const byte *srcPtr = src;
 
-	for (int y = 0; y < srcHeight; y++) {
-		for (int x = 0; x < srcWidth; x++) {
-			const byte color = *srcPtr++;
-			dst[0] = color;
-			dst[1] = color;
-			dst[newWidth] = color;
-			dst[newWidth + 1] = color;
-			dst += 2;
+	if (bytesPerPixel == 1) {
+		for (int y = 0; y < srcHeight; y++) {
+			for (int x = 0; x < srcWidth; x++) {
+				const byte color = *srcPtr++;
+				dst[0] = color;
+				dst[1] = color;
+				dst[newWidth] = color;
+				dst[newWidth + 1] = color;
+				dst += 2;
+			}
+			dst += newWidth;
 		}
-		dst += newWidth;
+	} else if (bytesPerPixel == 2) {
+		for (int y = 0; y < srcHeight; y++) {
+			for (int x = 0; x < srcWidth; x++) {
+				const byte color = *srcPtr++;
+				const byte color2 = *srcPtr++;
+				dst[0] = color;
+				dst[1] = color2;
+				dst[2] = color;
+				dst[3] = color2;
+				dst[pitch] = color;
+				dst[pitch + 1] = color2;
+				dst[pitch + 2] = color;
+				dst[pitch + 3] = color2;
+				dst += 4;
+			}
+			dst += pitch;
+		}
 	}
 }
 

Modified: scummvm/trunk/engines/sci/graphics/screen.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/screen.h	2010-11-11 19:20:26 UTC (rev 54209)
+++ scummvm/trunk/engines/sci/graphics/screen.h	2010-11-11 19:22:56 UTC (rev 54210)
@@ -109,7 +109,7 @@
 	void getPalette(Palette *pal);
 	void setPalette(Palette *pal);
 
-	void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight);
+	void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel = 1);
 
 	void adjustToUpscaledCoordinates(int16 &y, int16 &x);
 	void adjustBackUpscaledCoordinates(int16 &y, int16 &x);


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