[Scummvm-git-logs] scummvm master -> 25ae67b8703cd96e89bf083a06bceca770da1436

dreammaster dreammaster at scummvm.org
Mon Sep 11 01:32:40 CEST 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
25ae67b870 TITANIC: Created custom stream reader to fix bad y222.avi header


Commit: 25ae67b8703cd96e89bf083a06bceca770da1436
    https://github.com/scummvm/scummvm/commit/25ae67b8703cd96e89bf083a06bceca770da1436
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-09-10T19:32:26-04:00

Commit Message:
TITANIC: Created custom stream reader to fix bad y222.avi header

Changed paths:
    engines/titanic/support/avi_surface.cpp
    engines/titanic/support/avi_surface.h


diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp
index bddbb98..a817f49 100644
--- a/engines/titanic/support/avi_surface.cpp
+++ b/engines/titanic/support/avi_surface.cpp
@@ -55,8 +55,15 @@ AVISurface::AVISurface(const CResourceKey &key) : _movieName(key.getString()) {
 
 	// Create a decoder
 	_decoder = new AVIDecoder();
-	if (!_decoder->loadFile(_movieName))
+
+	// Load the video into it
+	if (_movieName == "y222.avi") {
+		// The y222.avi is the bells animation for the music room.
+		// It needs on the fly fixing for the video header
+		_decoder->loadStream(new y222());
+	} else if (!_decoder->loadFile(_movieName)) {
 		error("Could not open video - %s", key.getString().c_str());
+	}
 
 	_streamCount = _decoder->getTransparencyTrack() ? 2 : 1;
 
@@ -532,4 +539,28 @@ uint AVISurface::getBitDepth() const {
 	return _decoder->getVideoTrack(0).getBitCount();
 }
 
+/*------------------------------------------------------------------------*/
+
+y222::y222() {
+	_innerStream = new File();
+	_innerStream->open("y222.avi");
+}
+
+y222::~y222() {
+	delete _innerStream;
+}
+
+uint32 y222::read(void *dataPtr, uint32 dataSize) {
+	int32 currPos = pos();
+	uint32 bytesRead = _innerStream->read(dataPtr, dataSize);
+
+	if (currPos <= 48 && (currPos + bytesRead) >= 52) {
+		byte *framesP = (byte *)dataPtr + (48 - currPos);
+		if (READ_LE_UINT32(framesP) == 1)
+			WRITE_LE_UINT32(framesP, 1085);
+	}
+
+	return bytesRead;
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/support/avi_surface.h b/engines/titanic/support/avi_surface.h
index cb2e562..03f8f24 100644
--- a/engines/titanic/support/avi_surface.h
+++ b/engines/titanic/support/avi_surface.h
@@ -23,6 +23,7 @@
 #ifndef TITANIC_AVI_SURFACE_H
 #define TITANIC_AVI_SURFACE_H
 
+#include "common/stream.h"
 #include "video/avi_decoder.h"
 #include "graphics/managed_surface.h"
 #include "titanic/core/resource_key.h"
@@ -41,6 +42,37 @@ enum MovieFlag {
 	MOVIE_WAIT_FOR_FINISH = 0x10	// Let finish before playing next movie for object
 };
 
+/**
+ * This implements a special read stream for the y222.avi video
+ * that fixes that totalFrames field of the header from it's
+ * incorrect value of 1 to a correct 1085.
+ */
+class y222 : virtual public Common::SeekableReadStream {
+private:
+	File *_innerStream;
+public:
+	y222();
+	virtual ~y222();
+
+	virtual uint32 read(void *dataPtr, uint32 dataSize);
+	virtual bool eos() const { return _innerStream->eos(); }
+	virtual int32 pos() const { return _innerStream->pos(); }
+	virtual int32 size() const { return _innerStream->size(); }
+	virtual bool seek(int32 offset, int whence = SEEK_SET) {
+		return _innerStream->seek(offset, whence);
+	}
+	virtual bool skip(uint32 offset) {
+		return _innerStream->skip(offset);
+	}
+	virtual char *readLine(char *s, size_t bufSize) {
+		return _innerStream->readLine(s, bufSize);
+	}
+	virtual Common::String readLine() {
+		return _innerStream->readLine();
+	}
+};
+
+
 class AVIDecoder : public Video::AVIDecoder {
 public:
 	AVIDecoder() {}





More information about the Scummvm-git-logs mailing list