[Scummvm-cvs-logs] SF.net SVN: scummvm:[35849] scummvm/trunk/engines/made/pmvplayer.cpp
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Tue Jan 13 21:36:52 CET 2009
Revision: 35849
http://scummvm.svn.sourceforge.net/scummvm/?rev=35849&view=rev
Author: thebluegr
Date: 2009-01-13 20:36:52 +0000 (Tue, 13 Jan 2009)
Log Message:
-----------
- PMV video headers are evaluated correctly now
- PMV video is now stopped correctly if the end of the video has been reached. Removed a relevant hack, which was caused due to an invalid memory read
Modified Paths:
--------------
scummvm/trunk/engines/made/pmvplayer.cpp
Modified: scummvm/trunk/engines/made/pmvplayer.cpp
===================================================================
--- scummvm/trunk/engines/made/pmvplayer.cpp 2009-01-13 19:29:55 UTC (rev 35848)
+++ scummvm/trunk/engines/made/pmvplayer.cpp 2009-01-13 20:36:52 UTC (rev 35849)
@@ -48,12 +48,28 @@
uint32 chunkType, chunkSize;
readChunk(chunkType, chunkSize); // "MOVE"
+ if (chunkType != MKID_BE('MOVE')) {
+ warning("Unexpected PMV video header, expected 'MOVE'");
+ delete _fd;
+ return;
+ }
+
readChunk(chunkType, chunkSize); // "MHED"
+ if (chunkType != MKID_BE('MHED')) {
+ warning("Unexpected PMV video header, expected 'MHED'");
+ delete _fd;
+ return;
+ }
- // TODO: Evaluate header
+ uint frameDelay = _fd->readUint16LE();
+ int unk;
+ _fd->skip(4); // always 0?
+ unk = _fd->readByte();
+ debug(2, "%i");
+ unk = _fd->readByte();
+ debug(2, "%i");
+ _fd->skip(4); // always 0?
- uint frameDelay = _fd->readUint16LE();
- _fd->skip(10);
uint soundFreq = _fd->readUint16LE();
// Note: There seem to be weird sound frequencies in PMV videos.
// Not sure why, but leaving those original frequencies intact
@@ -63,13 +79,10 @@
if (soundFreq == 11127) soundFreq = 11025;
if (soundFreq == 22254) soundFreq = 22050;
- int unk;
-
for (int i = 0; i < 22; i++) {
unk = _fd->readUint16LE();
debug(2, "%i ", unk);
}
- debug(2, "\n");
_mixer->stopAll();
@@ -87,7 +100,7 @@
uint32 soundStartTime = 0, skipFrames = 0;
- uint32 frameNum;
+ uint32 frameNum, bytesRead;
uint16 width, height, cmdOffs, pixelOffs, maskOffs, lineSize;
// TODO: Sound can still be a little choppy. A bug in the decoder or -
@@ -100,32 +113,34 @@
int32 frameTime = _vm->_system->getMillis();
readChunk(chunkType, chunkSize);
+ if (chunkType != MKID_BE('MFRM')) {
+ warning("Unknown chunk type");
+ }
if (_fd->eos())
break;
frameData = new byte[chunkSize];
- _fd->read(frameData, chunkSize);
+ bytesRead = _fd->read(frameData, chunkSize);
+ if (bytesRead < chunkSize || _fd->eos())
+ break;
+
soundChunkOfs = READ_LE_UINT32(frameData + 8);
palChunkOfs = READ_LE_UINT32(frameData + 16);
// Handle audio
if (soundChunkOfs) {
-
audioData = frameData + soundChunkOfs - 8;
chunkSize = READ_LE_UINT16(audioData + 4);
chunkCount = READ_LE_UINT16(audioData + 6);
debug(1, "chunkCount = %d; chunkSize = %d; total = %d\n", chunkCount, chunkSize, chunkCount * chunkSize);
- if (chunkCount > 50) break; // FIXME: this is a hack
-
soundSize = chunkCount * chunkSize;
soundData = new byte[soundSize];
decompressSound(audioData + 8, soundData, chunkSize, chunkCount);
_audioStream->queueBuffer(soundData, soundSize);
-
}
// Handle palette
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