From 945103a43c9a15a4a9a07765197b0551593b4236 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sun, 8 Aug 2010 01:02:19 +0000 Subject: VIDEO/GOB: Implement and use CoktelDecoder::getFrameCoords() svn-id: r51909 --- graphics/video/coktel_decoder.cpp | 36 ++++++++++++++++++++++++++++++++++++ graphics/video/coktel_decoder.h | 7 +++++++ 2 files changed, 43 insertions(+) (limited to 'graphics/video') diff --git a/graphics/video/coktel_decoder.cpp b/graphics/video/coktel_decoder.cpp index 4af11c3f1a..9d056da48d 100644 --- a/graphics/video/coktel_decoder.cpp +++ b/graphics/video/coktel_decoder.cpp @@ -205,6 +205,10 @@ void CoktelDecoder::disableSound() { _audioStream = 0; } +bool CoktelDecoder::getFrameCoords(int16 frame, int16 &x, int16 &y, int16 &width, int16 &height) { + return false; +} + bool CoktelDecoder::hasEmbeddedFiles() const { return false; } @@ -2332,6 +2336,38 @@ PixelFormat VMDDecoder::getPixelFormat() const { return PixelFormat::createFormatCLUT8(); } +bool VMDDecoder::getPartCoords(int16 frame, PartType type, int16 &x, int16 &y, int16 &width, int16 &height) { + if (frame >= ((int32) _frameCount)) + return false; + + Frame &f = _frames[frame]; + + // Look for a part matching the requested type, stopping at a separator + Part *part = 0; + for (int i = 0; i < _partsPerFrame; i++) { + Part &p = f.parts[i]; + + if ((p.type == kPartTypeSeparator) || (p.type == type)) { + part = &p; + break; + } + } + + if (!part) + return false; + + x = part->left; + y = part->top; + width = part->right - part->left + 1; + height = part->bottom - part->top + 1; + + return true; +} + +bool VMDDecoder::getFrameCoords(int16 frame, int16 &x, int16 &y, int16 &width, int16 &height) { + return getPartCoords(frame, kPartTypeVideo, x, y, width, height); +} + bool VMDDecoder::hasEmbeddedFiles() const { return !_files.empty(); } diff --git a/graphics/video/coktel_decoder.h b/graphics/video/coktel_decoder.h index 408523ff48..60fdb57123 100644 --- a/graphics/video/coktel_decoder.h +++ b/graphics/video/coktel_decoder.h @@ -98,6 +98,9 @@ public: void enableSound(); void disableSound(); + /** Return the coordinates of the specified frame. */ + bool getFrameCoords(int16 frame, int16 &x, int16 &y, int16 &width, int16 &height); + /** Return whether that video has any embedded files. */ virtual bool hasEmbeddedFiles() const; @@ -340,6 +343,8 @@ public: bool seek(int32 frame, int whence = SEEK_SET, bool restart = false); + bool getFrameCoords(int16 frame, int16 &x, int16 &y, int16 &width, int16 &height); + bool hasEmbeddedFiles() const; bool hasEmbeddedFile(const Common::String &fileName) const; Common::MemoryReadStream *getEmbeddedFile(const Common::String &fileName) const; @@ -480,6 +485,8 @@ private: // Sound decompression byte *deDPCM (const byte *data, uint32 &size, int32 init[2]); byte *deADPCM(const byte *data, uint32 &size, int32 init, int32 index); + + bool getPartCoords(int16 frame, PartType type, int16 &x, int16 &y, int16 &width, int16 &height); }; } // End of namespace Graphics -- cgit v1.2.3