[Scummvm-cvs-logs] SF.net SVN: scummvm:[51899] scummvm/trunk/graphics/video
drmccoy at users.sourceforge.net
drmccoy at users.sourceforge.net
Sun Aug 8 02:57:27 CEST 2010
Revision: 51899
http://scummvm.svn.sourceforge.net/scummvm/?rev=51899&view=rev
Author: drmccoy
Date: 2010-08-08 00:57:27 +0000 (Sun, 08 Aug 2010)
Log Message:
-----------
VIDEO: Implement embedded file handling for VMDs
Modified Paths:
--------------
scummvm/trunk/graphics/video/coktel_decoder.cpp
scummvm/trunk/graphics/video/coktel_decoder.h
Modified: scummvm/trunk/graphics/video/coktel_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/coktel_decoder.cpp 2010-08-08 00:56:58 UTC (rev 51898)
+++ scummvm/trunk/graphics/video/coktel_decoder.cpp 2010-08-08 00:57:27 UTC (rev 51899)
@@ -204,6 +204,10 @@
_audioStream = 0;
}
+bool CoktelDecoder::hasEmbeddedFiles() const {
+ return false;
+}
+
bool CoktelDecoder::hasEmbeddedFile(const Common::String &fileName) const {
return false;
}
@@ -1814,6 +1818,55 @@
return PixelFormat::createFormatCLUT8();
}
+bool VMDDecoder::hasEmbeddedFiles() const {
+ return !_files.empty();
+}
+
+bool VMDDecoder::hasEmbeddedFile(const Common::String &fileName) const {
+ for (Common::Array<File>::const_iterator file = _files.begin(); file != _files.end(); ++file)
+ if (!file->name.compareToIgnoreCase(fileName))
+ return true;
+
+ return false;
+}
+
+Common::MemoryReadStream *VMDDecoder::getEmbeddedFile(const Common::String &fileName) const {
+ const File *file = 0;
+
+ for (Common::Array<File>::const_iterator it = _files.begin(); it != _files.end(); ++it)
+ if (!it->name.compareToIgnoreCase(fileName)) {
+ file = &*it;
+ break;
+ }
+
+ if (!file)
+ return 0;
+
+ if ((file->size - 20) != file->realSize) {
+ warning("VMDDecoder::getEmbeddedFile(): Sizes for \"%s\" differ! (%d, %d)",
+ fileName.c_str(), (file->size - 20), file->realSize);
+ return 0;
+ }
+
+ if (!_stream->seek(file->offset)) {
+ warning("VMDDecoder::getEmbeddedFile(): Can't seek to offset %d to (file \"%s\")",
+ file->offset, fileName.c_str());
+ return 0;
+ }
+
+ byte *data = (byte *) malloc(file->realSize);
+ if (_stream->read(data, file->realSize) != file->realSize) {
+ free(data);
+ warning("VMDDecoder::getEmbeddedFile(): Couldn't read %d bytes (file \"%s\")",
+ file->realSize, fileName.c_str());
+ }
+
+ Common::MemoryReadStream *stream =
+ new Common::MemoryReadStream(data, file->realSize, DisposeAfterUse::YES);
+
+ return stream;
+}
+
} // End of namespace Graphics
#endif // GRAPHICS_VIDEO_COKTELDECODER_H
Modified: scummvm/trunk/graphics/video/coktel_decoder.h
===================================================================
--- scummvm/trunk/graphics/video/coktel_decoder.h 2010-08-08 00:56:58 UTC (rev 51898)
+++ scummvm/trunk/graphics/video/coktel_decoder.h 2010-08-08 00:57:27 UTC (rev 51899)
@@ -98,6 +98,9 @@
void enableSound();
void disableSound();
+ /** Return whether that video has any embedded files. */
+ virtual bool hasEmbeddedFiles() const;
+
/** Return whether that embedded file exists. */
virtual bool hasEmbeddedFile(const Common::String &fileName) const;
@@ -336,7 +339,11 @@
bool seek(int32 frame, int whence = SEEK_SET, bool restart = false);
+ bool hasEmbeddedFiles() const;
+ bool hasEmbeddedFile(const Common::String &fileName) const;
+ Common::MemoryReadStream *getEmbeddedFile(const Common::String &fileName) const;
+
// VideoDecoder interface
bool load(Common::SeekableReadStream &stream);
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