diff options
author | Sven Hesse | 2010-08-08 00:57:27 +0000 |
---|---|---|
committer | Sven Hesse | 2010-08-08 00:57:27 +0000 |
commit | b13afba0536d16c3e37a2a887d582d9eeb42c8d1 (patch) | |
tree | 9403f027ddf51673b5a8c22762062a960c656547 /graphics/video/coktel_decoder.cpp | |
parent | 41f5d7812836f3c60532802780d93d5545b2258d (diff) | |
download | scummvm-rg350-b13afba0536d16c3e37a2a887d582d9eeb42c8d1.tar.gz scummvm-rg350-b13afba0536d16c3e37a2a887d582d9eeb42c8d1.tar.bz2 scummvm-rg350-b13afba0536d16c3e37a2a887d582d9eeb42c8d1.zip |
VIDEO: Implement embedded file handling for VMDs
svn-id: r51899
Diffstat (limited to 'graphics/video/coktel_decoder.cpp')
-rw-r--r-- | graphics/video/coktel_decoder.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/graphics/video/coktel_decoder.cpp b/graphics/video/coktel_decoder.cpp index fac32e55ff..864904f252 100644 --- a/graphics/video/coktel_decoder.cpp +++ b/graphics/video/coktel_decoder.cpp @@ -204,6 +204,10 @@ void CoktelDecoder::disableSound() { _audioStream = 0; } +bool CoktelDecoder::hasEmbeddedFiles() const { + return false; +} + bool CoktelDecoder::hasEmbeddedFile(const Common::String &fileName) const { return false; } @@ -1814,6 +1818,55 @@ PixelFormat VMDDecoder::getPixelFormat() const { 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 |