[Scummvm-git-logs] scummvm master -> 72423657e2a4f46d35726a5bb4371c4d1ec4b1bc

dreammaster dreammaster at scummvm.org
Sat Jul 1 23:41:05 CEST 2017


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

Summary:
372610a907 TITANIC: Refactor out _isReversed from AVI Surface
72423657e2 TITANIC: Fix service lift indicator when going down floors


Commit: 372610a907a0498b8dc0a7a85f205a2121fe77c6
    https://github.com/scummvm/scummvm/commit/372610a907a0498b8dc0a7a85f205a2121fe77c6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-07-01T17:32:42-04:00

Commit Message:
TITANIC: Refactor out _isReversed from AVI Surface

Changed paths:
    engines/titanic/support/avi_surface.cpp
    engines/titanic/support/avi_surface.h


diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp
index 97cc68f..7bfd614 100644
--- a/engines/titanic/support/avi_surface.cpp
+++ b/engines/titanic/support/avi_surface.cpp
@@ -30,6 +30,8 @@
 
 namespace Titanic {
 
+#define DEFAULT_FPS 15.0
+
 Video::AVIDecoder::AVIVideoTrack &AVIDecoder::getVideoTrack(uint idx) {
 	assert(idx < _videoTracks.size());
 	AVIVideoTrack *track = static_cast<AVIVideoTrack *>(_videoTracks[idx].track);
@@ -48,7 +50,6 @@ AVISurface::AVISurface(const CResourceKey &key) : _movieName(key.getString()) {
 	// correct detection of when range playbacks have finished
 	_currentFrame = -1;
 	_priorFrame = -1;
-	_isReversed = false;
 
 	// Create a decoder
 	_decoder = new AVIDecoder(Audio::Mixer::kPlainSoundType);
@@ -59,7 +60,7 @@ AVISurface::AVISurface(const CResourceKey &key) : _movieName(key.getString()) {
 
 	_soundManager = nullptr;
 	_hasAudio = false;
-	_frameRate = 0.0;
+	_frameRate = DEFAULT_FPS;
 }
 
 AVISurface::~AVISurface() {
@@ -108,7 +109,6 @@ bool AVISurface::play(int startFrame, int endFrame, int initialFrame, uint flags
 
 	if (_movieRangeInfo.size() == 1) {
 		// First play call, so start the movie playing
-		setReversed(info->_isReversed);
 		return startAtFrame(initialFrame);
 	} else {
 		return true;
@@ -137,8 +137,13 @@ bool AVISurface::startAtFrame(int frameNumber) {
 	if (frameNumber == -1)
 		// Default to starting frame of first movie range
 		frameNumber = _movieRangeInfo.front()->_startFrame;
-	if (_isReversed && frameNumber == (int)_decoder->getFrameCount())
-		--frameNumber;
+
+	if (frameNumber > _movieRangeInfo.front()->_endFrame) {
+		if (!isReversed())
+			setFrameRate(-DEFAULT_FPS);
+		if (frameNumber == (int)_decoder->getFrameCount())
+			--frameNumber;
+	}
 
 	// Start the playback
 	_decoder->start();
@@ -147,18 +152,18 @@ bool AVISurface::startAtFrame(int frameNumber) {
 	seekToFrame(frameNumber);
 
 	// If we're in reverse playback, set the decoder to play in reverse
-	if (_isReversed) {
+	if (isReversed())
 		_decoder->setReverse(true);
-		_decoder->setRate(Common::Rational(-1));
-	}
+	setFrameRate(_frameRate);
 
+	// Render the first frame
 	renderFrame();
 
 	return true;
 }
 
 void AVISurface::seekToFrame(uint frameNumber) {
-	if (_isReversed && frameNumber == _decoder->getFrameCount())
+	if (isReversed() && frameNumber == _decoder->getFrameCount())
 		--frameNumber;
 
 	if ((int)frameNumber != _currentFrame) {
@@ -172,17 +177,13 @@ void AVISurface::seekToFrame(uint frameNumber) {
 	}
 }
 
-void AVISurface::setReversed(bool isReversed) {
-	_isReversed = isReversed;
-}
-
 bool AVISurface::handleEvents(CMovieEventList &events) {
 	if (!isPlaying())
 		return true;
 
 	CMovieRangeInfo *info = _movieRangeInfo.front();
 	_priorFrame = _currentFrame;
-	_currentFrame += _isReversed ? -1 : 1;
+	_currentFrame += isReversed() ? -1 : 1;
 
 	int newFrame = _currentFrame;
 	if ((info->_isReversed && newFrame < info->_endFrame) ||
@@ -201,7 +202,7 @@ bool AVISurface::handleEvents(CMovieEventList &events) {
 				// Not empty, so move onto new first one
 				info = _movieRangeInfo.front();
 				newFrame = info->_startFrame;
-				setReversed(info->_isReversed);
+				setFrameRate(1.0);
 			}
 		}
 	}
@@ -348,8 +349,8 @@ bool AVISurface::isNextFrame() {
 		return _decoder->getTimeToNextFrame() == 0;
 
 	// We're at the end of the video, so we need to manually
-	// keep track of frame delays. Hardcoded at the moment for 15FPS
-	const uint FRAME_TIME = 1000 / 15;
+	// keep track of frame delays.
+	const uint FRAME_TIME = 1000 / DEFAULT_FPS;
 	uint32 currTime = g_system->getMillis();
 	if (currTime >= (_priorFrameTime + FRAME_TIME)) {
 		_priorFrameTime = currTime;
@@ -438,16 +439,17 @@ bool AVISurface::addEvent(int *frameNumber, CGameObject *obj) {
 }
 
 void AVISurface::setFrameRate(double rate) {
-	// Assert that the decoder is already playing, since otherwise setting
-	// the decoder rate would prematurely start playback
-	assert(_decoder->isPlaying());
-
-	// Convert rate from fps to relative to 1.0 (normal speed)
-	const int PRECISION = 10000;
-	double playRate = rate / 15.0;	// Standard 15 FPS
-	Common::Rational pRate((int)(playRate * PRECISION), PRECISION);
+	if (!_decoder->isPlaying()) {
+		// Store the new frame rate
+		_frameRate = rate;
+	} else {
+		// Convert rate from fps to relative to 1.0 (normal speed)
+		const int PRECISION = 10000;
+		double playRate = rate / DEFAULT_FPS;
+		Common::Rational pRate((int)(playRate * PRECISION), PRECISION);
 
-	_decoder->setRate(pRate);
+		_decoder->setRate(pRate);
+	}
 }
 
 Graphics::ManagedSurface *AVISurface::getSecondarySurface() {
diff --git a/engines/titanic/support/avi_surface.h b/engines/titanic/support/avi_surface.h
index 5e7e5d4..b7afac3 100644
--- a/engines/titanic/support/avi_surface.h
+++ b/engines/titanic/support/avi_surface.h
@@ -74,7 +74,7 @@ private:
 	int _streamCount;
 	Graphics::ManagedSurface *_movieFrameSurface[2];
 	Graphics::ManagedSurface *_framePixels;
-	bool _isReversed;
+	double _frameRate;
 	int _currentFrame, _priorFrame;
 	uint32 _priorFrameTime;
 	Common::String _movieName;
@@ -105,18 +105,12 @@ protected:
 	bool startAtFrame(int frameNumber);
 
 	/**
-	 * Sets whether the movie is playing in reverse
-	 */
-	void setReversed(bool isReversed);
-
-	/**
 	 * Seeks to a given frame number in the video
 	 */
 	virtual void seekToFrame(uint frameNumber);
 public:
 	CSoundManager *_soundManager;
 	bool _hasAudio;
-	double _frameRate;
 public:
 	AVISurface(const CResourceKey &key);
 	virtual ~AVISurface();
@@ -229,6 +223,11 @@ public:
 	 * Returns the pixel depth of the movie in bits
 	 */
 	uint getBitDepth() const;
+
+	/**
+	 * Returns true if the movie is to play backwards
+	 */
+	bool isReversed() const { return _frameRate < 0.0; }
 };
 
 } // End of namespace Titanic


Commit: 72423657e2a4f46d35726a5bb4371c4d1ec4b1bc
    https://github.com/scummvm/scummvm/commit/72423657e2a4f46d35726a5bb4371c4d1ec4b1bc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-07-01T17:40:51-04:00

Commit Message:
TITANIC: Fix service lift indicator when going down floors

Changed paths:
    engines/titanic/game/service_elevator_window.cpp
    engines/titanic/support/avi_surface.cpp


diff --git a/engines/titanic/game/service_elevator_window.cpp b/engines/titanic/game/service_elevator_window.cpp
index 887fd3d..84c4d7e 100644
--- a/engines/titanic/game/service_elevator_window.cpp
+++ b/engines/titanic/game/service_elevator_window.cpp
@@ -70,16 +70,16 @@ bool CServiceElevatorWindow::ServiceElevatorFloorChangeMsg(CServiceElevatorFloor
 		int count = clip->_endFrame - clip->_startFrame;
 		int startFrame = clip->_startFrame + count * FACTORS[msg->_startFloor] / 100;
 		int endFrame = clip->_startFrame + count * FACTORS[msg->_endFloor] / 100;
+
 		double rate = (startFrame < endFrame ? 1.0 : -1.0) * count / fps;
+		setMovieFrameRate(rate);
 
 		if (_notifyFlag) {
 			// Service elevator indicator
 			playMovie(startFrame, endFrame, MOVIE_NOTIFY_OBJECT);
-			setMovieFrameRate(rate);
 		} else {
 			// Background outside elevator
 			playMovie(startFrame, endFrame, 0);
-			setMovieFrameRate(rate);
 
 			if (_intoSpace)
 				playClip("Into Space");
diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp
index 7bfd614..810c0ec5 100644
--- a/engines/titanic/support/avi_surface.cpp
+++ b/engines/titanic/support/avi_surface.cpp
@@ -149,6 +149,7 @@ bool AVISurface::startAtFrame(int frameNumber) {
 	_decoder->start();
 
 	// Seek to the starting frame
+	_currentFrame = -1;
 	seekToFrame(frameNumber);
 
 	// If we're in reverse playback, set the decoder to play in reverse





More information about the Scummvm-git-logs mailing list