aboutsummaryrefslogtreecommitdiff
path: root/engines/made/pmvplayer.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2009-01-13 20:36:52 +0000
committerFilippos Karapetis2009-01-13 20:36:52 +0000
commit0ecaa8c4fde83a74065300e719a478fcb9ab246a (patch)
treec7baf7a0dee57fd3daa666a025e2a696643d436a /engines/made/pmvplayer.cpp
parent305954d34a612f14bdaad2cda9f982498f4f7066 (diff)
downloadscummvm-rg350-0ecaa8c4fde83a74065300e719a478fcb9ab246a.tar.gz
scummvm-rg350-0ecaa8c4fde83a74065300e719a478fcb9ab246a.tar.bz2
scummvm-rg350-0ecaa8c4fde83a74065300e719a478fcb9ab246a.zip
- 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 svn-id: r35849
Diffstat (limited to 'engines/made/pmvplayer.cpp')
-rw-r--r--engines/made/pmvplayer.cpp39
1 files changed, 27 insertions, 12 deletions
diff --git a/engines/made/pmvplayer.cpp b/engines/made/pmvplayer.cpp
index 3cf35baf9c..da506e8a28 100644
--- a/engines/made/pmvplayer.cpp
+++ b/engines/made/pmvplayer.cpp
@@ -48,12 +48,28 @@ void PmvPlayer::play(const char *filename) {
uint32 chunkType, chunkSize;
readChunk(chunkType, chunkSize); // "MOVE"
- readChunk(chunkType, chunkSize); // "MHED"
+ if (chunkType != MKID_BE('MOVE')) {
+ warning("Unexpected PMV video header, expected 'MOVE'");
+ delete _fd;
+ return;
+ }
- // TODO: Evaluate header
+ readChunk(chunkType, chunkSize); // "MHED"
+ if (chunkType != MKID_BE('MHED')) {
+ warning("Unexpected PMV video header, expected 'MHED'");
+ delete _fd;
+ return;
+ }
uint frameDelay = _fd->readUint16LE();
- _fd->skip(10);
+ 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 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 @@ void PmvPlayer::play(const char *filename) {
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 @@ void PmvPlayer::play(const char *filename) {
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 @@ void PmvPlayer::play(const char *filename) {
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