diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mohawk/file.cpp | 24 | ||||
-rw-r--r-- | engines/mohawk/file.h | 2 | ||||
-rw-r--r-- | engines/mohawk/mohawk.cpp | 10 | ||||
-rw-r--r-- | engines/mohawk/mohawk.h | 3 | ||||
-rw-r--r-- | engines/mohawk/video/qt_player.cpp | 5 | ||||
-rw-r--r-- | engines/mohawk/video/qt_player.h | 25 | ||||
-rw-r--r-- | engines/mohawk/video/video.cpp | 15 |
7 files changed, 69 insertions, 15 deletions
diff --git a/engines/mohawk/file.cpp b/engines/mohawk/file.cpp index 31d9188feb..ee1ba71936 100644 --- a/engines/mohawk/file.cpp +++ b/engines/mohawk/file.cpp @@ -179,6 +179,18 @@ bool MohawkFile::hasResource(uint32 tag, uint16 id) { return (getIdIndex(typeIndex, id) >= 0); } +uint32 MohawkFile::getOffset(uint32 tag, uint16 id) { + assert(_mhk); + + int16 typeIndex = getTypeIndex(tag); + assert(typeIndex >= 0); + + int16 idIndex = getIdIndex(typeIndex, id); + assert(idIndex >= 0); + + return _fileTable[_types[typeIndex].resTable.entries[idIndex].index - 1].offset; +} + Common::SeekableReadStream *MohawkFile::getRawData(uint32 tag, uint16 id) { if (!_mhk) error ("MohawkFile::getRawData - No File in Use"); @@ -296,6 +308,18 @@ void OldMohawkFile::open(Common::SeekableReadStream *stream) { } +uint32 OldMohawkFile::getOffset(uint32 tag, uint16 id) { + assert(_mhk); + + int16 typeIndex = getTypeIndex(tag); + assert(typeIndex >= 0); + + int16 idIndex = getIdIndex(typeIndex, id); + assert(idIndex >= 0); + + return _types[typeIndex].resTable.entries[idIndex].offset; +} + Common::SeekableReadStream *OldMohawkFile::getRawData(uint32 tag, uint16 id) { if (!_mhk) error ("OldMohawkFile::getRawData - No File in Use"); diff --git a/engines/mohawk/file.h b/engines/mohawk/file.h index 2a498d0e03..ede68f723d 100644 --- a/engines/mohawk/file.h +++ b/engines/mohawk/file.h @@ -184,6 +184,7 @@ public: bool hasResource(uint32 tag, uint16 id); virtual Common::SeekableReadStream *getRawData(uint32 tag, uint16 id); + virtual uint32 getOffset(uint32 tag, uint16 id); protected: Common::SeekableReadStream *_mhk; @@ -222,6 +223,7 @@ public: void open(Common::SeekableReadStream *stream); Common::SeekableReadStream *getRawData(uint32 tag, uint16 id); + uint32 getOffset(uint32 tag, uint16 id); private: struct OldType { diff --git a/engines/mohawk/mohawk.cpp b/engines/mohawk/mohawk.cpp index 147c242a6a..08b7b82e02 100644 --- a/engines/mohawk/mohawk.cpp +++ b/engines/mohawk/mohawk.cpp @@ -90,7 +90,6 @@ Common::SeekableReadStream *MohawkEngine::getRawData(uint32 tag, uint16 id) { return _mhk[i]->getRawData(tag, id); error ("Could not find a \'%s\' resource with ID %04x", tag2str(tag), id); - return 0; } @@ -102,4 +101,13 @@ bool MohawkEngine::hasResource(uint32 tag, uint16 id) { return false; } +uint32 MohawkEngine::getResourceOffset(uint32 tag, uint16 id) { + for (uint32 i = 0; i < _mhk.size(); i++) + if (_mhk[i]->hasResource(tag, id)) + return _mhk[i]->getOffset(tag, id); + + error ("Could not find a \'%s\' resource with ID %04x", tag2str(tag), id); + return 0; +} + } // End of namespace Mohawk diff --git a/engines/mohawk/mohawk.h b/engines/mohawk/mohawk.h index c8c16da3c0..8b00777226 100644 --- a/engines/mohawk/mohawk.h +++ b/engines/mohawk/mohawk.h @@ -88,8 +88,9 @@ public: Sound *_sound; VideoManager *_video; - Common::SeekableReadStream *getRawData(uint32, uint16); + Common::SeekableReadStream *getRawData(uint32 tag, uint16 id); bool hasResource(uint32 tag, uint16 id); + uint32 getResourceOffset(uint32 tag, uint16 id); void pauseGame(); diff --git a/engines/mohawk/video/qt_player.cpp b/engines/mohawk/video/qt_player.cpp index 9df5a3c930..20fc8c1aa4 100644 --- a/engines/mohawk/video/qt_player.cpp +++ b/engines/mohawk/video/qt_player.cpp @@ -45,6 +45,7 @@ namespace Mohawk { QTPlayer::QTPlayer() : Video() { _audStream = NULL; + _beginOffset = 0; } QTPlayer::~QTPlayer() { @@ -897,10 +898,10 @@ int QTPlayer::readSTCO(MOVatom atom) { return -1; for (uint32 i = 0; i < st->chunk_count; i++) { - // WORKAROUND/HACK: The offsets in Riven videos (aka inside the Mohawk archives themselves) + // WORKAROUND/HACK: The offsets in Riven videos (ones inside the Mohawk archives themselves) // have offsets relative to the archive and not the video. This is quite nasty. We subtract // the initial offset of the stream to get the correct value inside of the stream. - st->chunk_offsets[i] = _fd->readUint32BE() - _fd->getBeginOffset(); + st->chunk_offsets[i] = _fd->readUint32BE() - _beginOffset; } for (uint32 i = 0; i < _numStreams; i++) { diff --git a/engines/mohawk/video/qt_player.h b/engines/mohawk/video/qt_player.h index c40c291767..14aea31ded 100644 --- a/engines/mohawk/video/qt_player.h +++ b/engines/mohawk/video/qt_player.h @@ -84,19 +84,30 @@ public: * @param stream the stream to load */ bool loadFile(Common::SeekableReadStream* stream); - - /** - * Get a packet of A/V data - */ - //VideoPacket getNextPacket(); /** * Close a QuickTime encoded video file */ void closeFile(); + /** + * Returns the downscale mode of the video + * @return the downscale mode of the video + */ ScaleMode getScaleMode(); + + /** + * Returns the palette of the video + * @return the palette of the video + */ byte *getPalette() { return _palette; } + + /** + * Set the beginning offset of the video so we can modify the offsets in the stco + * atom of videos inside the Mohawk archives + * @param the beginning offset of the video + */ + void setChunkBeginOffset(uint32 offset) { _beginOffset = offset; } protected: // This is the file handle from which data is read from. It can be the actual file handle or a decompressed stream. @@ -215,10 +226,12 @@ protected: Common::SeekableReadStream *getNextFramePacket(); void resetInternal(); uint32 getFrameDuration(uint32 frame); + + QueuedAudioStream *_audStream; int8 _videoStreamIndex; int8 _audioStreamIndex; uint _curAudioChunk; - QueuedAudioStream *_audStream; + uint32 _beginOffset; int readDefault(MOVatom atom); int readLeaf(MOVatom atom); diff --git a/engines/mohawk/video/video.cpp b/engines/mohawk/video/video.cpp index f13445d072..d6c6cbcec1 100644 --- a/engines/mohawk/video/video.cpp +++ b/engines/mohawk/video/video.cpp @@ -507,9 +507,12 @@ void VideoManager::playMovie(uint16 id) { if (_mlstRecords[i].code == id) { warning("STUB: Play tMOV %d (non-blocking) at (%d, %d)", _mlstRecords[i].movieID, _mlstRecords[i].left, _mlstRecords[i].top); return; // TODO: This will do a lot of things wrong if enabled right now ;) + QTPlayer *qtPlayer = new QTPlayer(); + qtPlayer->setChunkBeginOffset(_vm->getResourceOffset(ID_TMOV, _mlstRecords[i].movieID)); + qtPlayer->loadFile(_vm->getRawData(ID_TMOV, _mlstRecords[i].movieID)); + VideoEntry entry; - entry.video = new QTPlayer(); - entry->loadFile(_vm->getRawData(ID_TMOV, _mlstRecords[i].movieID)); + entry.video = qtPlayer; entry.x = _mlstRecords[i].left; entry.y = _mlstRecords[i].top; entry.id = _mlstRecords[i].movieID; @@ -529,10 +532,12 @@ void VideoManager::playMovieBlocking(uint16 id) { // TODO: See if a non-blocking movie has been activated with the same id, // and if so, block input until that movie is finished. - + QTPlayer *qtPlayer = new QTPlayer(); + qtPlayer->setChunkBeginOffset(_vm->getResourceOffset(ID_TMOV, _mlstRecords[i].movieID)); + qtPlayer->loadFile(_vm->getRawData(ID_TMOV, _mlstRecords[i].movieID)); + VideoEntry entry; - entry.video = new QTPlayer(); - entry->loadFile(_vm->getRawData(ID_TMOV, _mlstRecords[i].movieID)); + entry.video = qtPlayer; entry.x = _mlstRecords[i].left; entry.y = _mlstRecords[i].top; entry.id = _mlstRecords[i].movieID; |