[Scummvm-cvs-logs] SF.net SVN: scummvm:[52594] scummvm/trunk/graphics/video

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Mon Sep 6 17:15:59 CEST 2010


Revision: 52594
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52594&view=rev
Author:   mthreepwood
Date:     2010-09-06 15:15:59 +0000 (Mon, 06 Sep 2010)

Log Message:
-----------
VIDEO: Apply patch #3057924 with some changes

Patch #3057924 is "QuickTimeDecoder: Scaling x and y separately". Thanks to kreegee for the patch and fuzzie for fixing a couple bugs with it.

Modified Paths:
--------------
    scummvm/trunk/graphics/video/qt_decoder.cpp
    scummvm/trunk/graphics/video/qt_decoder.h

Modified: scummvm/trunk/graphics/video/qt_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/qt_decoder.cpp	2010-09-06 14:59:13 UTC (rev 52593)
+++ scummvm/trunk/graphics/video/qt_decoder.cpp	2010-09-06 15:15:59 UTC (rev 52594)
@@ -67,6 +67,8 @@
 	_numStreams = 0;
 	_fd = 0;
 	_scaledSurface = 0;
+	_scaleFactorX = 1;
+	_scaleFactorY = 1;
 	_dirtyPalette = false;
 	_resFork = new Common::MacResManager();
 
@@ -82,14 +84,14 @@
 	if (_videoStreamIndex < 0)
 		return 0;
 
-	return _streams[_videoStreamIndex]->width / getScaleMode();
+	return (Common::Rational(_streams[_videoStreamIndex]->width) / getScaleFactorX()).toInt();
 }
 
 uint16 QuickTimeDecoder::getHeight() const {
 	if (_videoStreamIndex < 0)
 		return 0;
 
-	return _streams[_videoStreamIndex]->height / getScaleMode();
+	return (Common::Rational(_streams[_videoStreamIndex]->height) / getScaleFactorY()).toInt();
 }
 
 uint32 QuickTimeDecoder::getFrameCount() const {
@@ -113,13 +115,20 @@
 	return _streams[_videoStreamIndex]->codec_tag;
 }
 
-ScaleMode QuickTimeDecoder::getScaleMode() const {
+Common::Rational QuickTimeDecoder::getScaleFactorX() const {
 	if (_videoStreamIndex < 0)
-		return kScaleNormal;
+		return 1;
 
-	return (ScaleMode)(_scaleMode * _streams[_videoStreamIndex]->scaleMode);
+	return (_scaleFactorX * _streams[_videoStreamIndex]->scaleFactorX);
 }
 
+Common::Rational QuickTimeDecoder::getScaleFactorY() const {
+	if (_videoStreamIndex < 0)
+		return 1;
+
+	return (_scaleFactorY * _streams[_videoStreamIndex]->scaleFactorY);
+}
+
 uint32 QuickTimeDecoder::getFrameDuration() {
 	if (_videoStreamIndex < 0)
 		return 0;
@@ -231,14 +240,14 @@
 }
 
 Surface *QuickTimeDecoder::scaleSurface(Surface *frame) {
-	if (getScaleMode() == kScaleNormal)
+	if (getScaleFactorX() == 1 && getScaleFactorY() == 1)
 		return frame;
 
 	assert(_scaledSurface);
 
-	for (uint32 j = 0; j < _scaledSurface->h; j++)
-		for (uint32 k = 0; k < _scaledSurface->w; k++)
-			memcpy(_scaledSurface->getBasePtr(k, j), frame->getBasePtr(k * getScaleMode(), j * getScaleMode()), frame->bytesPerPixel);
+	for (int32 j = 0; j < _scaledSurface->h; j++)
+		for (int32 k = 0; k < _scaledSurface->w; k++)
+			memcpy(_scaledSurface->getBasePtr(k, j), frame->getBasePtr((k * getScaleFactorX()).toInt() , (j * getScaleFactorY()).toInt()), frame->bytesPerPixel);
 
 	return _scaledSurface;
 }
@@ -376,7 +385,7 @@
 	if (_videoStreamIndex >= 0) {
 		_videoCodec = createCodec(getCodecTag(), getBitsPerPixel());
 
-		if (getScaleMode() != kScaleNormal) {
+		if (getScaleFactorX() != 1 || getScaleFactorY() != 1) {
 			// We have to initialize the scaled surface
 			_scaledSurface = new Surface();
 			_scaledSurface->create(getWidth(), getHeight(), getPixelFormat().bytesPerPixel);
@@ -593,18 +602,12 @@
 	uint32 yMod = _fd->readUint32BE();
 	_fd->skip(16);
 
-	if (xMod != yMod)
-		error("X and Y resolution modifiers differ");
+	_scaleFactorX = Common::Rational(0x10000, xMod);
+	_scaleFactorY = Common::Rational(0x10000, yMod);
 
-	if (xMod == 0x8000)
-		_scaleMode = kScaleHalf;
-	else if (xMod == 0x4000)
-		_scaleMode = kScaleQuarter;
-	else
-		_scaleMode = kScaleNormal;
+	_scaleFactorX.debugPrint(1, "readMVHD(): scaleFactorX =");
+	_scaleFactorY.debugPrint(1, "readMVHD(): scaleFactorY =");
 
-	debug(1, "readMVHD(): scaleMode = %d", (int)_scaleMode);
-
 	_fd->readUint32BE(); // preview time
 	_fd->readUint32BE(); // preview duration
 	_fd->readUint32BE(); // poster time
@@ -688,18 +691,12 @@
 	uint32 yMod = _fd->readUint32BE();
 	_fd->skip(16);
 
-	if (xMod != yMod)
-		error("X and Y resolution modifiers differ");
+	st->scaleFactorX = Common::Rational(0x10000, xMod);
+	st->scaleFactorY = Common::Rational(0x10000, yMod);
 
-	if (xMod == 0x8000)
-		st->scaleMode = kScaleHalf;
-	else if (xMod == 0x4000)
-		st->scaleMode = kScaleQuarter;
-	else
-		st->scaleMode = kScaleNormal;
+	st->scaleFactorX.debugPrint(1, "readTKHD(): scaleFactorX =");
+	st->scaleFactorY.debugPrint(1, "readTKHD(): scaleFactorY =");
 
-	debug(1, "readTKHD(): scaleMode = %d", (int)_scaleMode);
-
 	// these are fixed-point, 16:16
 	// uint32 tkWidth = _fd->readUint32BE() >> 16; // track width
 	// uint32 tkHeight = _fd->readUint32BE() >> 16; // track height

Modified: scummvm/trunk/graphics/video/qt_decoder.h
===================================================================
--- scummvm/trunk/graphics/video/qt_decoder.h	2010-09-06 14:59:13 UTC (rev 52593)
+++ scummvm/trunk/graphics/video/qt_decoder.h	2010-09-06 15:15:59 UTC (rev 52594)
@@ -36,6 +36,7 @@
 
 #include "common/scummsys.h"
 #include "common/queue.h"
+#include "common/rational.h"
 
 #include "graphics/video/video_decoder.h"
 #include "graphics/video/codecs/codec.h"
@@ -50,11 +51,6 @@
 
 namespace Graphics {
 
-enum ScaleMode {
-	kScaleNormal = 1,
-	kScaleHalf = 2,
-	kScaleQuarter = 4
-};
 
 class QuickTimeDecoder : public RewindableVideoDecoder {
 public:
@@ -217,7 +213,8 @@
 		uint32 nb_frames;
 		uint32 duration;
 		uint32 start_time;
-		ScaleMode scaleMode;
+		Common::Rational scaleFactorX;
+		Common::Rational scaleFactorY;
 	};
 
 	const ParseTable *_parseTable;
@@ -230,7 +227,8 @@
 	MOVStreamContext *_partial;
 	uint32 _numStreams;
 	int _ni;
-	ScaleMode _scaleMode;
+	Common::Rational _scaleFactorX;
+	Common::Rational _scaleFactorY;
 	MOVStreamContext *_streams[20];
 	byte _palette[256 * 3];
 	bool _dirtyPalette;
@@ -260,7 +258,8 @@
 
 	Surface *_scaledSurface;
 	Surface *scaleSurface(Surface *frame);
-	ScaleMode getScaleMode() const;
+	Common::Rational getScaleFactorX() const;
+	Common::Rational getScaleFactorY() const;
 
 	void pauseVideoIntern(bool pause);
 


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