diff options
author | Paul Gilbert | 2017-09-10 19:32:26 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-09-10 19:32:26 -0400 |
commit | 25ae67b8703cd96e89bf083a06bceca770da1436 (patch) | |
tree | 17ff7f205c81071d9c3c72d9b8610ff50ad62e28 /engines/titanic/support | |
parent | 66150ee064ebeb5faf3a941136a8cd7256a89f7a (diff) | |
download | scummvm-rg350-25ae67b8703cd96e89bf083a06bceca770da1436.tar.gz scummvm-rg350-25ae67b8703cd96e89bf083a06bceca770da1436.tar.bz2 scummvm-rg350-25ae67b8703cd96e89bf083a06bceca770da1436.zip |
TITANIC: Created custom stream reader to fix bad y222.avi header
Diffstat (limited to 'engines/titanic/support')
-rw-r--r-- | engines/titanic/support/avi_surface.cpp | 33 | ||||
-rw-r--r-- | engines/titanic/support/avi_surface.h | 32 |
2 files changed, 64 insertions, 1 deletions
diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp index bddbb9808e..a817f492c1 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 cb2e562d54..03f8f24cfe 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() {} |