From 1f630094268a76fd73e7a1f01e725aef2aa61e8e Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sun, 8 Aug 2010 00:56:04 +0000 Subject: [PATCH] VIDEO/GOB: Stubb VMDDecoder svn-id: r51896 --- engines/gob/videoplayer.cpp | 6 +- graphics/video/coktel_decoder.cpp | 96 +++++++++++++++++++++++++++++++ graphics/video/coktel_decoder.h | 31 ++++++++++ 3 files changed, 129 insertions(+), 4 deletions(-) diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp index 427130935e8..22434687555 100644 --- a/engines/gob/videoplayer.cpp +++ b/engines/gob/videoplayer.cpp @@ -679,11 +679,9 @@ Graphics::CoktelDecoder *VideoPlayer::openVideo(const Common::String &file, Prop else if (properties.type == kVideoTypePreIMD) video = new Graphics::PreIMDDecoder(properties.width, properties.height, *_vm->_mixer, Audio::Mixer::kSFXSoundType); else if (properties.type == kVideoTypeVMD) - warning("TODO: VMD"); - //_video = new Graphics::Vmd(_vm->_video->_palLUT); + video = new Graphics::VMDDecoder(*_vm->_mixer, Audio::Mixer::kSFXSoundType); else if (properties.type == kVideoTypeRMD) - warning("TODO: RMD"); - //_video = new Graphics::Vmd(_vm->_video->_palLUT); + video = new Graphics::VMDDecoder(*_vm->_mixer, Audio::Mixer::kSFXSoundType); else warning("Couldn't open video \"%s\": Invalid video Type", fileName.c_str()); diff --git a/graphics/video/coktel_decoder.cpp b/graphics/video/coktel_decoder.cpp index 8e8c6f9e938..e79ea8c45d7 100644 --- a/graphics/video/coktel_decoder.cpp +++ b/graphics/video/coktel_decoder.cpp @@ -1314,6 +1314,102 @@ PixelFormat IMDDecoder::getPixelFormat() const { return PixelFormat::createFormatCLUT8(); } + +VMDDecoder::VMDDecoder(Audio::Mixer &mixer, Audio::Mixer::SoundType soundType) : CoktelDecoder(mixer, soundType), + _stream(0), _videoBuffer(0), _videoBufferSize(0) { + +} + +VMDDecoder::~VMDDecoder() { + close(); +} + +bool VMDDecoder::seek(int32 frame, int whence, bool restart) { + if (!isVideoLoaded()) + // Nothing to do + return false; + + // Find the frame to which to seek + if (whence == SEEK_CUR) + frame += _curFrame; + else if (whence == SEEK_END) + frame = _frameCount - frame - 1; + else if (whence == SEEK_SET) + frame--; + else + return false; + + if ((frame < -1) || (((uint32) frame) >= _frameCount)) + // Out of range + return false; + + if (frame == _curFrame) + // Nothing to do + return true; + + // TODO + + return true; +} + +bool VMDDecoder::load(Common::SeekableReadStream &stream) { + close(); + + _stream = &stream; + + _stream->seek(0); + + warning("TODO: VMDDecoder::load()"); + + return false; +} + +void VMDDecoder::close() { + reset(); + + CoktelDecoder::close(); + + delete _stream; + + delete[] _videoBuffer; + + _stream = 0; + + _videoBuffer = 0; + _videoBufferSize = 0; +} + +bool VMDDecoder::isVideoLoaded() const { + return _stream != 0; +} + +Surface *VMDDecoder::decodeNextFrame() { + if (!isVideoLoaded() || endOfVideo()) + return 0; + + createSurface(); + + processFrame(); + renderFrame(); + + if (_curFrame == 0) + _startTime = g_system->getMillis(); + + return &_surface; +} + +void VMDDecoder::processFrame() { + _curFrame++; +} + +// Just a simple blit +void VMDDecoder::renderFrame() { +} + +PixelFormat VMDDecoder::getPixelFormat() const { + return PixelFormat::createFormatCLUT8(); +} + } // End of namespace Graphics #endif // GRAPHICS_VIDEO_COKTELDECODER_H diff --git a/graphics/video/coktel_decoder.h b/graphics/video/coktel_decoder.h index 646e55b0bce..435f289c2c1 100644 --- a/graphics/video/coktel_decoder.h +++ b/graphics/video/coktel_decoder.h @@ -324,6 +324,37 @@ private: void emptySoundSlice(bool hasNextCmd); }; +class VMDDecoder : public CoktelDecoder { +public: + VMDDecoder(Audio::Mixer &mixer, Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType); + ~VMDDecoder(); + + bool seek(int32 frame, int whence = SEEK_SET, bool restart = false); + + + // VideoDecoder interface + + bool load(Common::SeekableReadStream &stream); + void close(); + + bool isVideoLoaded() const; + + Surface *decodeNextFrame(); + + PixelFormat getPixelFormat() const; + +private: + Common::SeekableReadStream *_stream; + + // Buffer for processed frame data + byte *_videoBuffer; + uint32 _videoBufferSize; + + // Frame decoding + void processFrame(); + void renderFrame(); +}; + } // End of namespace Graphics #endif // GRAPHICS_VIDEO_COKTELDECODER_H