[Scummvm-cvs-logs] SF.net SVN: scummvm: [31944] scummvm/trunk/engines/made/pmvplayer.cpp
john_doe at users.sourceforge.net
john_doe at users.sourceforge.net
Thu May 8 13:17:38 CEST 2008
Revision: 31944
http://scummvm.svn.sourceforge.net/scummvm/?rev=31944&view=rev
Author: john_doe
Date: 2008-05-08 04:17:38 -0700 (Thu, 08 May 2008)
Log Message:
-----------
Possibly fixed the sound stuttering in the PMV videos and added frame skipping based on the Gob engine's IMD/VMD player.
Modified Paths:
--------------
scummvm/trunk/engines/made/pmvplayer.cpp
Modified: scummvm/trunk/engines/made/pmvplayer.cpp
===================================================================
--- scummvm/trunk/engines/made/pmvplayer.cpp 2008-05-08 09:05:44 UTC (rev 31943)
+++ scummvm/trunk/engines/made/pmvplayer.cpp 2008-05-08 11:17:38 UTC (rev 31944)
@@ -54,8 +54,8 @@
_fd->skip(10);
uint soundFreq = _fd->readUint16LE();
// FIXME: weird frequencies... (11127 or 22254)
- //if (soundFreq == 11127) soundFreq = 11025;
- //if (soundFreq == 22254) soundFreq = 22050;
+ if (soundFreq == 11127) soundFreq = 11025;
+ if (soundFreq == 22254) soundFreq = 22050;
int unk;
@@ -78,6 +78,8 @@
uint32 palSize = 0;
byte *frameData, *audioData, *soundData, *palData, *imageData;
bool firstTime = true;
+
+ uint32 soundStartTime, skipFrames;
uint32 frameNum;
uint16 width, height, cmdOffs, pixelOffs, maskOffs, lineSize;
@@ -89,6 +91,8 @@
while (!_abort && !_fd->eof()) {
+ int32 frameTime = _vm->_system->getMillis();
+
readChunk(chunkType, chunkSize);
if (_fd->eof())
@@ -104,7 +108,7 @@
if (chunkCount > 50) break; // FIXME: this is a hack
- debug(2, "chunkCount = %d; chunkSize = %d\n", chunkCount, chunkSize);
+ debug(1, "chunkCount = %d; chunkSize = %d; total = %d\n", chunkCount, chunkSize, chunkCount * chunkSize);
soundSize = chunkCount * chunkSize;
soundData = new byte[soundSize];
@@ -117,6 +121,7 @@
palData = frameData + palChunkOfs - 8;
palSize = READ_LE_UINT32(palData + 4);
decompressPalette(palData + 8, _paletteRGB, palSize);
+ _vm->_screen->setRGBPalette(_paletteRGB);
}
// Handle video
@@ -142,21 +147,31 @@
if (firstTime) {
_mixer->playInputStream(Audio::Mixer::kPlainSoundType, &_audioStreamHandle, _audioStream);
+ soundStartTime = g_system->getMillis();
+ skipFrames = 0;
firstTime = false;
}
- _vm->_screen->setRGBPalette(_paletteRGB);
handleEvents();
updateScreen();
- frameCount++;
-
delete[] frameData;
- while (_mixer->getSoundElapsedTime(_audioStreamHandle) < frameCount * frameDelay) {
- _vm->_system->delayMillis(10);
- }
+ if (skipFrames == 0) {
+ int32 waitTime = (frameCount * frameDelay) -
+ (g_system->getMillis() - soundStartTime) - (_vm->_system->getMillis() - frameTime);
+ if (waitTime < 0) {
+ skipFrames = -waitTime / frameDelay;
+ warning("Video A/V sync broken, skipping %d frame(s)", skipFrames + 1);
+ } else if (waitTime > 0)
+ g_system->delayMillis(waitTime);
+
+ } else
+ skipFrames--;
+
+ frameCount++;
+
}
_audioStream->finish();
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