[Scummvm-cvs-logs] SF.net SVN: scummvm:[46786] scummvm/trunk

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Thu Dec 31 01:37:40 CET 2009


Revision: 46786
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46786&view=rev
Author:   mthreepwood
Date:     2009-12-31 00:37:40 +0000 (Thu, 31 Dec 2009)

Log Message:
-----------
Remove the getBeginOffset() hack from Common::SeekableReadStream and introduce QTPlayer::setChunkBeginOffset() to allow specifying what offset to use.

Modified Paths:
--------------
    scummvm/trunk/common/stream.h
    scummvm/trunk/engines/mohawk/file.cpp
    scummvm/trunk/engines/mohawk/file.h
    scummvm/trunk/engines/mohawk/mohawk.cpp
    scummvm/trunk/engines/mohawk/mohawk.h
    scummvm/trunk/engines/mohawk/video/qt_player.cpp
    scummvm/trunk/engines/mohawk/video/qt_player.h
    scummvm/trunk/engines/mohawk/video/video.cpp

Modified: scummvm/trunk/common/stream.h
===================================================================
--- scummvm/trunk/common/stream.h	2009-12-31 00:06:28 UTC (rev 46785)
+++ scummvm/trunk/common/stream.h	2009-12-31 00:37:40 UTC (rev 46786)
@@ -388,13 +388,6 @@
 	 * err() or eos() to determine whether an exception occurred.
 	 */
 	virtual String readLine();
-
-	/**
-	 * Return the beginning offset in the stream, which defaults to 0.
-	 *
-	 * @return the beginning offset of the stream
-	 */
-	virtual uint32 getBeginOffset() { return 0; }
 };
 
 
@@ -454,7 +447,6 @@
 
 	virtual int32 pos() const { return _pos - _begin; }
 	virtual int32 size() const { return _end - _begin; }
-	virtual uint32 getBeginOffset() { return _begin; }
 
 	virtual bool seek(int32 offset, int whence = SEEK_SET);
 };

Modified: scummvm/trunk/engines/mohawk/file.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/file.cpp	2009-12-31 00:06:28 UTC (rev 46785)
+++ scummvm/trunk/engines/mohawk/file.cpp	2009-12-31 00:37:40 UTC (rev 46786)
@@ -179,6 +179,18 @@
 	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 @@
 
 }
 
+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");

Modified: scummvm/trunk/engines/mohawk/file.h
===================================================================
--- scummvm/trunk/engines/mohawk/file.h	2009-12-31 00:06:28 UTC (rev 46785)
+++ scummvm/trunk/engines/mohawk/file.h	2009-12-31 00:37:40 UTC (rev 46786)
@@ -184,6 +184,7 @@
 	
 	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 @@
 	
 	void open(Common::SeekableReadStream *stream);
 	Common::SeekableReadStream *getRawData(uint32 tag, uint16 id);
+	uint32 getOffset(uint32 tag, uint16 id);
 	
 private:
 	struct OldType {

Modified: scummvm/trunk/engines/mohawk/mohawk.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/mohawk.cpp	2009-12-31 00:06:28 UTC (rev 46785)
+++ scummvm/trunk/engines/mohawk/mohawk.cpp	2009-12-31 00:37:40 UTC (rev 46786)
@@ -90,7 +90,6 @@
 			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 @@
 	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

Modified: scummvm/trunk/engines/mohawk/mohawk.h
===================================================================
--- scummvm/trunk/engines/mohawk/mohawk.h	2009-12-31 00:06:28 UTC (rev 46785)
+++ scummvm/trunk/engines/mohawk/mohawk.h	2009-12-31 00:37:40 UTC (rev 46786)
@@ -88,8 +88,9 @@
 	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();
 

Modified: scummvm/trunk/engines/mohawk/video/qt_player.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/video/qt_player.cpp	2009-12-31 00:06:28 UTC (rev 46785)
+++ scummvm/trunk/engines/mohawk/video/qt_player.cpp	2009-12-31 00:37:40 UTC (rev 46786)
@@ -45,6 +45,7 @@
 
 QTPlayer::QTPlayer() : Video() {
 	_audStream = NULL;
+	_beginOffset = 0;
 }
 
 QTPlayer::~QTPlayer() {
@@ -897,10 +898,10 @@
 		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++) {

Modified: scummvm/trunk/engines/mohawk/video/qt_player.h
===================================================================
--- scummvm/trunk/engines/mohawk/video/qt_player.h	2009-12-31 00:06:28 UTC (rev 46785)
+++ scummvm/trunk/engines/mohawk/video/qt_player.h	2009-12-31 00:37:40 UTC (rev 46786)
@@ -84,19 +84,30 @@
 	 * @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 @@
 	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);

Modified: scummvm/trunk/engines/mohawk/video/video.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/video/video.cpp	2009-12-31 00:06:28 UTC (rev 46785)
+++ scummvm/trunk/engines/mohawk/video/video.cpp	2009-12-31 00:37:40 UTC (rev 46786)
@@ -507,9 +507,12 @@
 		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 @@
 			
 			// 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;


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