[Scummvm-cvs-logs] scummvm master -> 219d4293119989831f0bc0df095617305e0a0e1e

lordhoto lordhoto at gmail.com
Sun Dec 21 15:58:54 CET 2014


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:
200b05246c AUDIO: Wrap around in the Timestamp constructor
219d429311 Merge pull request #550 from bgK/timestamp-overflow


Commit: 200b05246c3e90e61fe6d2e21507b0b936d0ff2b
    https://github.com/scummvm/scummvm/commit/200b05246c3e90e61fe6d2e21507b0b936d0ff2b
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2014-12-20T19:38:18+01:00

Commit Message:
AUDIO: Wrap around in the Timestamp constructor

The "making of" video in the Xbox version of Myst III is
unusually long. VideoDecoder::FixedRateVideoTrack::getFrameTime
would trigger an overflow.

Changed paths:
    audio/timestamp.cpp
    test/audio/timestamp.h



diff --git a/audio/timestamp.cpp b/audio/timestamp.cpp
index 1ce9716..6375281 100644
--- a/audio/timestamp.cpp
+++ b/audio/timestamp.cpp
@@ -39,12 +39,10 @@ Timestamp::Timestamp(uint ms, uint fr) {
 Timestamp::Timestamp(uint s, uint frames, uint fr) {
 	assert(fr > 0);
 
-	_secs = s;
+	_secs = s + (frames / fr);
 	_framerateFactor = 1000 / Common::gcd<uint>(1000, fr);
 	_framerate = fr * _framerateFactor;
-	_numFrames = frames * _framerateFactor;
-
-	normalize();
+	_numFrames = (frames % fr) * _framerateFactor;
 }
 
 Timestamp Timestamp::convertToFramerate(uint newFramerate) const {
diff --git a/test/audio/timestamp.h b/test/audio/timestamp.h
index ca56e34..ec42a55 100644
--- a/test/audio/timestamp.h
+++ b/test/audio/timestamp.h
@@ -2,6 +2,8 @@
 
 #include "audio/timestamp.h"
 
+#include <limits.h>
+
 class TimestampTestSuite : public CxxTest::TestSuite
 {
 	public:
@@ -238,4 +240,15 @@ class TimestampTestSuite : public CxxTest::TestSuite
 		TS_ASSERT_EQUALS(c.numberOfFrames(), 11025);
 		TS_ASSERT_EQUALS(c.totalNumberOfFrames(), 33075);
 	}
+
+	void test_no_overflow() {
+		// The constructor should not overflow and give incoherent values
+		const Audio::Timestamp a = Audio::Timestamp(0, UINT_MAX, 1000);
+
+		int secs = UINT_MAX / 1000;
+		int frames = UINT_MAX % 1000;
+
+		TS_ASSERT_EQUALS(a.secs(), secs);
+		TS_ASSERT_EQUALS(a.numberOfFrames(), frames);
+	}
 };


Commit: 219d4293119989831f0bc0df095617305e0a0e1e
    https://github.com/scummvm/scummvm/commit/219d4293119989831f0bc0df095617305e0a0e1e
Author: Johannes Schickel (lordhoto at gmail.com)
Date: 2014-12-21T15:58:01+01:00

Commit Message:
Merge pull request #550 from bgK/timestamp-overflow

AUDIO: Wrap around in the Timestamp constructor

Changed paths:
    audio/timestamp.cpp
    test/audio/timestamp.h









More information about the Scummvm-git-logs mailing list