[Scummvm-cvs-logs] SF.net SVN: scummvm:[51850] scummvm/trunk

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sun Aug 8 02:33:59 CEST 2010


Revision: 51850
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51850&view=rev
Author:   drmccoy
Date:     2010-08-08 00:33:59 +0000 (Sun, 08 Aug 2010)

Log Message:
-----------
VIDEO: Stub a VideoDecoder-like CoktelDecoder

This creates a new CoktelDecoder class using the VideoDecoder
interface, which will eventually become the new way to decode
PreIMD, IMD and VMD videos.
Since the VideoPlayer in gob is not yet ready for this, we're
disabling all video playback in the gob engine for now.

Modified Paths:
--------------
    scummvm/trunk/engines/gob/demos/demoplayer.cpp
    scummvm/trunk/engines/gob/inter_v6.cpp
    scummvm/trunk/engines/gob/mult_v2.cpp
    scummvm/trunk/engines/gob/scenery.cpp
    scummvm/trunk/engines/gob/videoplayer.cpp
    scummvm/trunk/engines/gob/videoplayer.h
    scummvm/trunk/graphics/module.mk

Added Paths:
-----------
    scummvm/trunk/graphics/video/coktel_decoder.cpp
    scummvm/trunk/graphics/video/coktel_decoder.h

Modified: scummvm/trunk/engines/gob/demos/demoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/demos/demoplayer.cpp	2010-08-08 00:33:13 UTC (rev 51849)
+++ scummvm/trunk/engines/gob/demos/demoplayer.cpp	2010-08-08 00:33:59 UTC (rev 51850)
@@ -155,8 +155,8 @@
 	int16 x = _rebase0 ? 0 : -1;
 	int16 y = _rebase0 ? 0 : -1;
 	if (_vm->_vidPlayer->primaryOpen(file, x, y)) {
-		bool videoSupportsDouble =
-			((_vm->_vidPlayer->getFeatures() & Graphics::CoktelVideo::kFeaturesSupportsDouble) != 0);
+		bool videoSupportsDouble = false;
+			//((_vm->_vidPlayer->getFeatures() & Graphics::CoktelDecoder::kFeaturesSupportsDouble) != 0);
 
 		if (_autoDouble) {
 			int16 defX = _rebase0 ? 0 : _vm->_vidPlayer->getDefaultX();
@@ -215,7 +215,7 @@
 }
 
 void DemoPlayer::playVideoDoubled() {
-	Common::String fileNameOpened = _vm->_vidPlayer->getFileName();
+	Common::String fileNameOpened = _vm->_vidPlayer->getPrimaryFileName();
 	_vm->_vidPlayer->primaryClose();
 
 	int16 x = _rebase0 ? 0 : -1;
@@ -223,10 +223,10 @@
 	if (_vm->_vidPlayer->primaryOpen(fileNameOpened.c_str(), x, y,
 				VideoPlayer::kFlagScreenSurface)) {
 
-		for (int i = 0; i < _vm->_vidPlayer->getFramesCount(); i++) {
+		for (int i = 0; i < _vm->_vidPlayer->getFrameCount(); i++) {
 			_vm->_vidPlayer->playFrame(i);
 
-			Graphics::CoktelVideo::State state = _vm->_vidPlayer->getState();
+			Graphics::CoktelDecoder::State state;// = _vm->_vidPlayer->getState();
 
 			int16 w = state.right - state.left + 1;
 			int16 h = state.bottom - state.top + 1;

Modified: scummvm/trunk/engines/gob/inter_v6.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v6.cpp	2010-08-08 00:33:13 UTC (rev 51849)
+++ scummvm/trunk/engines/gob/inter_v6.cpp	2010-08-08 00:33:59 UTC (rev 51850)
@@ -231,7 +231,7 @@
 			return false;
 		}
 
-		int16 framesCount = _vm->_vidPlayer->getFramesCount(vmdSlot);
+		int16 framesCount = _vm->_vidPlayer->getFrameCount(vmdSlot);
 
 		for (int i = 0; i < framesCount; i++) {
 			_vm->_vidPlayer->slotPlay(vmdSlot);

Modified: scummvm/trunk/engines/gob/mult_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/mult_v2.cpp	2010-08-08 00:33:13 UTC (rev 51849)
+++ scummvm/trunk/engines/gob/mult_v2.cpp	2010-08-08 00:33:59 UTC (rev 51850)
@@ -737,7 +737,7 @@
 	if (animData.animation < 0) {
 		if ((animObj.videoSlot > 0) &&
 		    (_vm->_vidPlayer->getCurrentFrame(animObj.videoSlot - 1) <
-		      _vm->_vidPlayer->getFramesCount(animObj.videoSlot - 1))) {
+		      _vm->_vidPlayer->getFrameCount(animObj.videoSlot - 1))) {
 			animData.newCycle = 0;
 			return;
 		}
@@ -1139,7 +1139,7 @@
 		palFrame = 0;
 
 	if (lastFrame == -1)
-		lastFrame = _vm->_vidPlayer->getFramesCount() - 1;
+		lastFrame = _vm->_vidPlayer->getFrameCount() - 1;
 
 	baseFrame = startFrame % (lastFrame - palFrame + 1);
 	_vm->_vidPlayer->primaryPlay(baseFrame + palFrame, baseFrame + palFrame, 0,

Modified: scummvm/trunk/engines/gob/scenery.cpp
===================================================================
--- scummvm/trunk/engines/gob/scenery.cpp	2010-08-08 00:33:13 UTC (rev 51849)
+++ scummvm/trunk/engines/gob/scenery.cpp	2010-08-08 00:33:59 UTC (rev 51850)
@@ -616,8 +616,8 @@
 			return;
 		}
 
-		if (frame >= _vm->_vidPlayer->getFramesCount(obj.videoSlot - 1))
-			frame = _vm->_vidPlayer->getFramesCount(obj.videoSlot - 1) - 1;
+		if (frame >= _vm->_vidPlayer->getFrameCount(obj.videoSlot - 1))
+			frame = _vm->_vidPlayer->getFrameCount(obj.videoSlot - 1) - 1;
 
 		// Seek to frame
 		if (_vm->_vidPlayer->getCurrentFrame(obj.videoSlot - 1) < 256) {
@@ -632,10 +632,12 @@
 				_vm->_vidPlayer->slotPlay(obj.videoSlot - 1);
 		}
 
+		/*
 		// Subtitle
 		Graphics::CoktelVideo::State state = _vm->_vidPlayer->getState(obj.videoSlot - 1);
 		if (state.flags & Graphics::CoktelVideo::kStateSpeech)
 			_vm->_draw->printTotText(state.speechId);
+		*/
 
 		destX  = 0;
 		destY  = 0;

Modified: scummvm/trunk/engines/gob/videoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.cpp	2010-08-08 00:33:13 UTC (rev 51849)
+++ scummvm/trunk/engines/gob/videoplayer.cpp	2010-08-08 00:33:59 UTC (rev 51850)
@@ -40,130 +40,17 @@
 
 const char *VideoPlayer::_extensions[] = { "IMD", "IMD", "VMD", "RMD", "SMD" };
 
-VideoPlayer::Video::Video(GobEngine *vm) : _vm(vm), _stream(0), _video(0) {
-}
+VideoPlayer::VideoPlayer(GobEngine *vm) : _vm(vm), _primaryVideo(0),
+	_ownSurf(false), _backSurf(false), _needBlit(false),
+	_noCursorSwitch(false), _woodruffCohCottWorkaround(false) {
 
-VideoPlayer::Video::~Video() {
-	close();
+	for (int i = 0; i < kVideoSlotCount; i++)
+		_videoSlots[i] = 0;
 }
 
-bool VideoPlayer::Video::open(const char *fileName, Type which, int16 width, int16 height) {
-	close();
-
-	int16 handle = _vm->_dataIO->openData(fileName);
-
-	if (handle < 0) {
-		warning("Couldn't open video \"%s\": No such file", fileName);
-		return false;
-	}
-
-	_stream = _vm->_dataIO->openAsStream(handle, true);
-
-	if (which == kVideoTypeIMD) {
-		_video = new Graphics::Imd();
-	} else if (which == kVideoTypePreIMD) {
-		_video = new Graphics::PreImd(width, height);
-	} else if (which == kVideoTypeVMD) {
-		_video = new Graphics::Vmd(_vm->_video->_palLUT);
-	} else if (which == kVideoTypeRMD) {
-		_video = new Graphics::Vmd(_vm->_video->_palLUT);
-	} else {
-		warning("Couldn't open video \"%s\": Invalid video Type", fileName);
-		close();
-		return false;
-	}
-
-	if (!_video->load(_stream)) {
-		warning("While loading video \"%s\"", fileName);
-		close();
-		return false;
-	}
-
-	_fileName = fileName;
-
-	_defaultX = _video->getX();
-	_defaultY = _video->getY();
-
-	return true;
-}
-
-void VideoPlayer::Video::close() {
-	delete _video;
-	delete _stream;
-
-	_video = 0;
-	_stream = 0;
-	_fileName.clear();
-	memset(&_state, 0, sizeof(Graphics::CoktelVideo::State));
-	_defaultX = _defaultY = 0;
-}
-
-bool VideoPlayer::Video::isOpen() const {
-	return (_video != 0);
-}
-
-const char *VideoPlayer::Video::getFileName() const {
-	return _fileName.c_str();
-}
-
-Graphics::CoktelVideo *VideoPlayer::Video::getVideo() {
-	return _video;
-}
-
-const Graphics::CoktelVideo *VideoPlayer::Video::getVideo() const {
-	return _video;
-}
-
-uint32 VideoPlayer::Video::getFeatures() const {
-	return _video->getFeatures();
-}
-
-Graphics::CoktelVideo::State VideoPlayer::Video::getState() const {
-	return _state;
-}
-
-int16 VideoPlayer::Video::getDefaultX() const {
-	return _defaultX;
-}
-
-int16 VideoPlayer::Video::getDefaultY() const {
-	return _defaultY;
-}
-
-bool VideoPlayer::Video::hasExtraData(const char *fileName) const {
-	if (!_video)
-		return false;
-
-	return _video->hasExtraData(fileName);
-}
-
-Common::MemoryReadStream *VideoPlayer::Video::getExtraData(const char *fileName) {
-	if (!_video)
-		return 0;
-
-	return _video->getExtraData(fileName);
-}
-
-Graphics::CoktelVideo::State VideoPlayer::Video::nextFrame() {
-	if (_video)
-		_state = _video->nextFrame();
-
-	return _state;
-}
-
-
-VideoPlayer::VideoPlayer(GobEngine *vm) : _vm(vm) {
-	_primaryVideo = new Video(vm);
-	_ownSurf = false;
-	_backSurf = false;
-	_needBlit = false;
-	_noCursorSwitch = false;
-	_woodruffCohCottWorkaround = false;
-}
-
 VideoPlayer::~VideoPlayer() {
 	delete _primaryVideo;
-	for (uint i = 0; i < _videoSlots.size(); i++)
+	for (int i = 0; i < kVideoSlotCount; i++)
 		delete _videoSlots[i];
 }
 
@@ -224,6 +111,39 @@
 	return true;
 }
 
+Graphics::CoktelDecoder *VideoPlayer::openVideo(const char *fileName, Type which, uint16 width, uint16 height) {
+	Common::SeekableReadStream *stream = _vm->_dataIO->getDataStream(fileName);
+	if (!stream)
+		return 0;
+
+	Graphics::CoktelDecoder *video = 0;
+	if (which == kVideoTypeIMD)
+		warning("TODO: IMD");
+		//_video = new Graphics::Imd();
+	else if (which == kVideoTypePreIMD)
+		video = new Graphics::PreIMDDecoder(width, height, *_vm->_mixer, Audio::Mixer::kSFXSoundType);
+	else if (which == kVideoTypeVMD)
+		warning("TODO: VMD");
+		//_video = new Graphics::Vmd(_vm->_video->_palLUT);
+	else if (which == kVideoTypeRMD)
+		warning("TODO: RMD");
+		//_video = new Graphics::Vmd(_vm->_video->_palLUT);
+	else
+		warning("Couldn't open video \"%s\": Invalid video Type", fileName);
+
+	if (!video) {
+		delete stream;
+		return 0;
+	}
+
+	if (!video->load(*stream)) {
+		delete video;
+		return 0;
+	}
+
+	return video;
+}
+
 bool VideoPlayer::primaryOpen(const char *videoFile, int16 x, int16 y,
 		int32 flags, Type which, int16 width, int16 height) {
 
@@ -234,10 +154,14 @@
 	if (!findFile(fileName, which))
 		return false;
 
-	if (scumm_strnicmp(_primaryVideo->getFileName(), fileName, strlen(fileName))) {
-		if (!_primaryVideo->open(fileName, which, width, height))
+	if (scumm_strnicmp(_primaryFileName.c_str(), fileName, strlen(fileName))) {
+		primaryClose();
+
+		if (!(_primaryVideo = openVideo(fileName, which, (uint16) width, (uint16) height)))
 			return false;
 
+		_primaryFileName = fileName;
+
 		// WORKAROUND: In some rare cases, the cursor should still be
 		// displayed while a video is playing.
 		_noCursorSwitch = false;
@@ -269,8 +193,8 @@
 				_backSurf = false;
 
 				surf = _vm->_video->initSurfDesc(_vm->_global->_videoMode,
-						_primaryVideo->getVideo()->getWidth(),
-						_primaryVideo->getVideo()->getHeight(), 0);
+						_primaryVideo->getWidth(),
+						_primaryVideo->getHeight(), 0);
 				_vm->_draw->_spritesArray[x] = surf;
 
 				x = 0;
@@ -286,24 +210,25 @@
 				surf = _vm->_draw->_spritesArray[_backSurf ? 21 : 20];
 			}
 
+			/*
 			_primaryVideo->getVideo()->setVideoMemory(surf->getVidMem(),
 					surf->getWidth(), surf->getHeight());
+			*/
 
 		} else
-			_primaryVideo->getVideo()->setVideoMemory();
+			;//_primaryVideo->getVideo()->setVideoMemory();
 
 		_needBlit = ((flags & kFlagUseBackSurfaceContent) != 0) && ((flags & kFlagFrontSurface) != 0);
-
-		_primaryVideo->getVideo()->enableSound(*_vm->_mixer);
 	}
 
-	if (!_primaryVideo->isOpen())
+	if (!_primaryVideo)
 		return false;
 
-	_primaryVideo->getVideo()->setFrameRate(_vm->_util->getFrameRate());
-	_primaryVideo->getVideo()->setXY(x, y);
-	WRITE_VAR(7, _primaryVideo->getVideo()->getFramesCount());
+	//_primaryVideo->getVideo()->setFrameRate(_vm->_util->getFrameRate());
+	//_primaryVideo->getVideo()->setXY(x, y);
 
+	WRITE_VAR(7, _primaryVideo->getFrameCount());
+
 	return true;
 }
 
@@ -311,16 +236,16 @@
 		uint16 palCmd, int16 palStart, int16 palEnd,
 		int16 palFrame, int16 endFrame, bool fade, int16 reverseTo, bool forceSeek) {
 
-	if (!_primaryVideo->isOpen())
+	if (!_primaryVideo)
 		return false;
 
-	Graphics::CoktelVideo &video = *(_primaryVideo->getVideo());
+	Graphics::CoktelDecoder &video = *_primaryVideo;
 
 	breakKey = 27;
 	if (startFrame < 0)
-		startFrame = video.getCurrentFrame();
+		startFrame = video.getCurFrame();
 	if (lastFrame < 0)
-		lastFrame = video.getFramesCount() - 1;
+		lastFrame = video.getFrameCount() - 1;
 	if (palFrame < 0)
 		palFrame = startFrame;
 	if (endFrame < 0)
@@ -328,12 +253,14 @@
 	palCmd &= 0x3F;
 
 	int16 realStartFrame = startFrame;
-	if (video.getCurrentFrame() != startFrame) {
-		if (!forceSeek && (video.getFeatures() & Graphics::CoktelVideo::kFeaturesSound))
-			startFrame = video.getCurrentFrame();
+	/*
+	if (video.getCurFrame() != startFrame) {
+		if (!forceSeek && (video.getFeatures() & Graphics::CoktelDecoder::kFeaturesSound))
+			startFrame = video.getCurFrame();
 		else
-			video.seekFrame(startFrame);
+			video.seek(startFrame);
 	}
+	*/ video.seek(startFrame);
 
 	_vm->_draw->_showCursor = _noCursorSwitch ? 3 : 0;
 
@@ -357,17 +284,17 @@
 			fade = false;
 		}
 
-		if (!_noCursorSwitch)
-			video.waitEndFrame();
+		/*if (!_noCursorSwitch)
+			video.waitEndFrame();*/
 		startFrame++;
 	}
 
 	evalBgShading(video);
 
 	if (reverseTo >= 0) {
-		int16 toFrame = video.getFramesCount() - reverseTo;
-		for (int i = video.getCurrentFrame(); i >= toFrame; i--) {
-			video.seekFrame(i, SEEK_SET, true);
+		int16 toFrame = video.getFrameCount() - reverseTo;
+		for (int i = video.getCurFrame(); i >= toFrame; i--) {
+			video.seek(i, SEEK_SET, true);
 
 			bool b = doPlay(i, breakKey, 0, 0, 0, 0, 0);
 			evalBgShading(video);
@@ -377,8 +304,8 @@
 				memset((char *)_vm->_draw->_vgaPalette, 0, 768);
 			}
 
-			if (!_noCursorSwitch)
-				video.waitEndFrame();
+			/*if (!_noCursorSwitch)
+				video.waitEndFrame();*/
 		}
 	}
 
@@ -388,11 +315,19 @@
 }
 
 void VideoPlayer::primaryClose() {
-	_primaryVideo->close();
+	delete _primaryVideo;
+	_primaryVideo = 0;
+
+	_primaryFileName.clear();
 }
 
 int VideoPlayer::slotOpen(const char *videoFile, Type which, int16 width, int16 height) {
-	Video *video = new Video(_vm);
+	int slot = getNextFreeSlot();
+	if (slot == -1)
+		return -1;
+
+	Graphics::CoktelDecoder *&video = _videoSlots[slot];
+
 	char fileName[256];
 
 	strncpy0(fileName, videoFile, 250);
@@ -402,59 +337,49 @@
 		return -1;
 	}
 
-	if (!video->open(fileName, which, width, height)) {
-		delete video;
+	if (!(video = openVideo(fileName, which, width, height)))
 		return -1;
-	}
 
-	video->getVideo()->setVideoMemory();
-	video->getVideo()->enableSound(*_vm->_mixer);
+	//video->getVideo()->setVideoMemory();
+	//video->getVideo()->enableSound(*_vm->_mixer);
 
-	int slot = getNextFreeSlot();
+	WRITE_VAR(7, video->getFrameCount());
 
-	_videoSlots[slot] = video;
-
-	WRITE_VAR(7, video->getVideo()->getFramesCount());
-
 	return slot;
 }
 
 int VideoPlayer::getNextFreeSlot() {
-	uint slot;
+	for (int i = 0; i < kVideoSlotCount; i++)
+		if (!_videoSlots[i])
+			return i;
 
-	for (slot = 0; slot < _videoSlots.size(); slot++)
-		if (!_videoSlots[slot])
-			break;
-
-	if (slot == _videoSlots.size())
-		_videoSlots.push_back(0);
-
-	return slot;
+	warning("VideoPlayer::getNextFreeSlot(): No free video slot");
+	return -1;
 }
 
 void VideoPlayer::slotPlay(int slot, int16 frame) {
-	if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot])
+	if ((slot < 0) || (slot >= kVideoSlotCount) || !_videoSlots[slot])
 		return;
 
-	Graphics::CoktelVideo &video = *(_videoSlots[slot]->getVideo());
+	Graphics::CoktelDecoder &video = *_videoSlots[slot];
 
 	if (frame < 0)
-		frame = video.getCurrentFrame();
+		frame = video.getCurFrame();
 
-	if (frame >= video.getFramesCount())
+	if (((uint16) frame) >= video.getFrameCount())
 		return;
 
-	if (video.getCurrentFrame() != frame)
-		video.seekFrame(frame);
+	if (video.getCurFrame() != frame)
+		video.seek(frame);
 
-	_videoSlots[slot]->nextFrame();
+	//_videoSlots[slot]->nextFrame();
 	WRITE_VAR(11, frame);
 
 	evalBgShading(video);
 }
 
 void VideoPlayer::slotClose(int slot) {
-	if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot])
+	if ((slot < 0) || (slot >= kVideoSlotCount) || !_videoSlots[slot])
 		return;
 
 	delete _videoSlots[slot];
@@ -465,147 +390,147 @@
 		uint16 left, uint16 top, uint16 width, uint16 height,
 		uint16 x, uint16 y, uint16 pitch, int16 transp) {
 
-	if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot])
+	if ((slot < 0) || (slot >= kVideoSlotCount) || !_videoSlots[slot])
 		return;
 
-	_videoSlots[slot]->getVideo()->copyCurrentFrame(dest,
-			left, top, width, height, x, y, pitch, transp);
+	/*_videoSlots[slot]->getVideo()->copyCurrentFrame(dest,
+			left, top, width, height, x, y, pitch, transp);*/
 }
 
 void VideoPlayer::slotCopyPalette(int slot, int16 palStart, int16 palEnd) {
-	if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot])
+	if ((slot < 0) || (slot >= kVideoSlotCount) || !_videoSlots[slot])
 		return;
 
-	copyPalette(*(_videoSlots[slot]->getVideo()), palStart, palEnd);
+	//copyPalette(*(_videoSlots[slot]->getVideo()), palStart, palEnd);
 }
 
 void VideoPlayer::slotWaitEndFrame(int slot, bool onlySound) {
-	Video *video = getVideoBySlot(slot);
+	Graphics::CoktelDecoder *video = getVideoBySlot(slot);
 
 	if (video) {
-		Graphics::CoktelVideo &cVideo = *video->getVideo();
+		/*
+		Graphics::CoktelDecoder &cVideo = *video->getVideo();
 
-		if (!onlySound || (cVideo.getFeatures() & Graphics::CoktelVideo::kFeaturesSound))
+		if (!onlySound || (cVideo.getFeatures() & Graphics::CoktelDecoder::kFeaturesSound))
 			cVideo.waitEndFrame();
+		*/
 	}
 }
 
 bool VideoPlayer::slotIsOpen(int slot) const {
-	if ((slot >= 0) && (((uint) slot) < _videoSlots.size()) && _videoSlots[slot])
+	if ((slot < 0) || (slot >= kVideoSlotCount) || !_videoSlots[slot])
 		return true;
 
 	return false;
 }
 
 void VideoPlayer::slotSetDoubleMode(int slot, bool doubleMode) {
-	Video *video = getVideoBySlot(slot);
+	/*
+	Graphics::CoktelDecoder *video = getVideoBySlot(slot);
 
 	if (video)
 		video->getVideo()->setDoubleMode(doubleMode);
+	*/
 }
 
-const VideoPlayer::Video *VideoPlayer::getVideoBySlot(int slot) const {
+const Graphics::CoktelDecoder *VideoPlayer::getVideoBySlot(int slot) const {
 	if (slot < 0) {
-		if (_primaryVideo->isOpen())
+		if (_primaryVideo)
 			return _primaryVideo;
-	} else if (((uint) slot) < _videoSlots.size() && _videoSlots[slot])
+	} else if ((slot < kVideoSlotCount) && _videoSlots[slot])
 		return _videoSlots[slot];
 
 	return 0;
 }
 
-VideoPlayer::Video *VideoPlayer::getVideoBySlot(int slot) {
+Graphics::CoktelDecoder *VideoPlayer::getVideoBySlot(int slot) {
 	if (slot < 0) {
-		if (_primaryVideo->isOpen())
+		if (_primaryVideo)
 			return _primaryVideo;
-	} else if (((uint) slot) < _videoSlots.size() && _videoSlots[slot])
+	} else if ((slot < kVideoSlotCount) && _videoSlots[slot])
 		return _videoSlots[slot];
 
 	return 0;
 }
 
-const char *VideoPlayer::getFileName(int slot) const {
-	const Video *video = getVideoBySlot(slot);
-
-	if (video)
-		return video->getFileName();
-
-	return "";
+const Common::String &VideoPlayer::getPrimaryFileName() const {
+	return _primaryFileName;
 }
 
 uint16 VideoPlayer::getFlags(int slot) const {
-	const Video *video = getVideoBySlot(slot);
+	const Graphics::CoktelDecoder *video = getVideoBySlot(slot);
 
 	if (video)
-		return video->getVideo()->getFlags();
+		return 0;//return video->getVideo()->getFlags();
 
 	return 0;
 }
 
-int16 VideoPlayer::getFramesCount(int slot) const {
-	const Video *video = getVideoBySlot(slot);
+int16 VideoPlayer::getFrameCount(int slot) const {
+	const Graphics::CoktelDecoder *video = getVideoBySlot(slot);
 
 	if (video)
-		return video->getVideo()->getFramesCount();
+		return video->getFrameCount();
 
 	return 0;
 }
 
 int16 VideoPlayer::getCurrentFrame(int slot) const {
-	const Video *video = getVideoBySlot(slot);
+	const Graphics::CoktelDecoder *video = getVideoBySlot(slot);
 
 	if (video)
-		return video->getVideo()->getCurrentFrame();
+		return video->getCurFrame();
 
 	return 0;
 }
 
 int16 VideoPlayer::getWidth(int slot) const {
-	const Video *video = getVideoBySlot(slot);
+	const Graphics::CoktelDecoder *video = getVideoBySlot(slot);
 
 	if (video)
-		return video->getVideo()->getWidth();
+		return video->getWidth();
 
 	return 0;
 }
 
 int16 VideoPlayer::getHeight(int slot) const {
-	const Video *video = getVideoBySlot(slot);
+	const Graphics::CoktelDecoder *video = getVideoBySlot(slot);
 
 	if (video)
-		return video->getVideo()->getHeight();
+		return video->getHeight();
 
 	return 0;
 }
 
 int16 VideoPlayer::getDefaultX(int slot) const {
-	const Video *video = getVideoBySlot(slot);
+	const Graphics::CoktelDecoder *video = getVideoBySlot(slot);
 
 	if (video)
-		return video->getDefaultX();
+		return 0;//return video->getDefaultX();
 
 	return 0;
 }
 
 int16 VideoPlayer::getDefaultY(int slot) const {
-	const Video *video = getVideoBySlot(slot);
+	const Graphics::CoktelDecoder *video = getVideoBySlot(slot);
 
 	if (video)
-		return video->getDefaultY();
+		return 0;//return video->getDefaultY();
 
 	return 0;
 }
 
 uint32 VideoPlayer::getFeatures(int slot) const {
-	const Video *video = getVideoBySlot(slot);
+	const Graphics::CoktelDecoder *video = getVideoBySlot(slot);
 
 	if (video)
-		return video->getFeatures();
+		return 0;//return video->getFeatures();
 
 	return 0;
 }
 
-Graphics::CoktelVideo::State VideoPlayer::getState(int slot) const {
+void VideoPlayer::getState(int slot) const {
+	/*
 	const Video *video = getVideoBySlot(slot);
 	Graphics::CoktelVideo::State state;
 
@@ -613,22 +538,23 @@
 		state = video->getState();
 
 	return state;
+	*/
 }
 
 bool VideoPlayer::hasExtraData(const char *fileName, int slot) const {
-	const Video *video = getVideoBySlot(slot);
+	const Graphics::CoktelDecoder *video = getVideoBySlot(slot);
 
 	if (video)
-		return video->hasExtraData(fileName);
+		return false;//return video->hasExtraData(fileName);
 
 	return false;
 }
 
 Common::MemoryReadStream *VideoPlayer::getExtraData(const char *fileName, int slot) {
-	Video *video = getVideoBySlot(slot);
+	Graphics::CoktelDecoder *video = getVideoBySlot(slot);
 
 	if (video)
-		return video->getExtraData(fileName);
+		return 0;//return video->getExtraData(fileName);
 
 	return 0;
 }
@@ -640,15 +566,14 @@
 	if (!_primaryVideo)
 		return;
 
-	Video &video = *_primaryVideo;
-	Graphics::CoktelVideo &cVideo = *video.getVideo();
+	Graphics::CoktelDecoder &video = *_primaryVideo;
 
-	if (cVideo.getCurrentFrame() != frame)
-		cVideo.seekFrame(frame);
+	if (video.getCurFrame() != frame)
+		video.seek(frame);
 	if (palFrame < 0)
 		palFrame = 0;
 	if (endFrame < 0)
-		endFrame = cVideo.getFramesCount() - 1;
+		endFrame = video.getFrameCount() - 1;
 
 
 	bool modifiedPal = false;
@@ -658,7 +583,7 @@
 		_vm->_draw->_applyPal = true;
 
 		if (palCmd >= 4)
-			copyPalette(cVideo, palStart, palEnd);
+			copyPalette(video, palStart, palEnd);
 	}
 
 	if (modifiedPal && (palCmd == 8) && !_backSurf)
@@ -668,7 +593,7 @@
 	if (_needBlit)
 		_vm->_draw->forceBlit();
 
-	Graphics::CoktelVideo::State state = video.nextFrame();
+	Graphics::CoktelDecoder::State state;// = video.nextFrame();
 	WRITE_VAR(11, frame);
 
 	if (_woodruffCohCottWorkaround && (frame == 32)) {
@@ -689,14 +614,16 @@
 		_vm->_video->dirtyRectsAll();
 	}
 
-	if ((state.flags & Graphics::CoktelVideo::kStatePalette) && (palCmd > 1)) {
-		copyPalette(cVideo, palStart, palEnd);
+	/*
+	if ((state.flags & Graphics::CoktelDecoder::kStatePalette) && (palCmd > 1)) {
+		copyPalette(video, palStart, palEnd);
 
 		if (!_backSurf)
 			_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
 		else
 			_vm->_draw->_applyPal = true;
 	}
+	*/
 
 	if (modifiedPal && (palCmd == 8) && _backSurf)
 		_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
@@ -713,9 +640,11 @@
 			_vm->_video->retrace();
 	}
 
+	/*
 	// Subtitle
-	if (state.flags & Graphics::CoktelVideo::kStateSpeech)
+	if (state.flags & Graphics::CoktelDecoder::kStateSpeech)
 		_vm->_draw->printTotText(state.speechId);
+	*/
 
 	if (modifiedPal && ((palCmd == 2) || (palCmd == 4)))
 		_vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0);
@@ -730,7 +659,7 @@
 	_vm->_util->processInput();
 
 	if (_vm->shouldQuit()) {
-		_primaryVideo->getVideo()->disableSound();
+		//_primaryVideo->getVideo()->disableSound();
 		return true;
 	}
 
@@ -740,9 +669,9 @@
 
 		_vm->_inter->storeKey(_vm->_util->checkKey());
 		if (VAR(0) == (unsigned) breakKey) {
-			_primaryVideo->getVideo()->disableSound();
+			//_primaryVideo->getVideo()->disableSound();
 			// Seek to the last frame. Some scripts depend on that.
-			_primaryVideo->getVideo()->seekFrame(endFrame, SEEK_SET, true);
+			_primaryVideo->seek(endFrame, SEEK_SET, true);
 			return true;
 		}
 	}
@@ -750,37 +679,45 @@
 	return false;
 }
 
-void VideoPlayer::copyPalette(Graphics::CoktelVideo &video, int16 palStart, int16 palEnd) {
-	if (!(video.getFeatures() & Graphics::CoktelVideo::kFeaturesPalette))
+void VideoPlayer::copyPalette(Graphics::CoktelDecoder &video, int16 palStart, int16 palEnd) {
+	/*
+	if (!(video.getFeatures() & Graphics::CoktelDecoder::kFeaturesPalette))
 		return;
+	*/
 
 	if (palStart < 0)
 		palStart = 0;
 	if (palEnd < 0)
 		palEnd = 255;
 
+	/*
 	memcpy(((char *)(_vm->_global->_pPaletteDesc->vgaPal)) + palStart * 3,
 			video.getPalette() + palStart * 3,
 			(palEnd - palStart + 1) * 3);
+	*/
 }
 
 void VideoPlayer::writeVideoInfo(const char *videoFile, int16 varX, int16 varY,
 		int16 varFrames, int16 varWidth, int16 varHeight) {
 
 	if (primaryOpen(videoFile)) {
-		int16 x, y, width, height;
+		int16 x = -1, y = -1, width = -1, height = -1;
 
+		/*
 		x = _primaryVideo->getVideo()->getX();
 		y = _primaryVideo->getVideo()->getY();
 		width = _primaryVideo->getVideo()->getWidth();
 		height = _primaryVideo->getVideo()->getHeight();
+		*/
 
+		/*
 		if (VAR_OFFSET(varX) == 0xFFFFFFFF)
 			_primaryVideo->getVideo()->getFrameCoords(1, x, y, width, height);
+		*/
 
 		WRITE_VAR_OFFSET(varX, x);
 		WRITE_VAR_OFFSET(varY, y);
-		WRITE_VAR_OFFSET(varFrames, _primaryVideo->getVideo()->getFramesCount());
+		WRITE_VAR_OFFSET(varFrames, _primaryVideo->getFrameCount());
 		WRITE_VAR_OFFSET(varWidth, width);
 		WRITE_VAR_OFFSET(varHeight, height);
 
@@ -794,11 +731,13 @@
 	}
 }
 
-void VideoPlayer::evalBgShading(Graphics::CoktelVideo &video) {
+void VideoPlayer::evalBgShading(Graphics::CoktelDecoder &video) {
+	/*
 	if (video.isSoundPlaying())
 		_vm->_sound->bgShade();
 	else
 		_vm->_sound->bgUnshade();
+	*/
 }
 
 } // End of namespace Gob

Modified: scummvm/trunk/engines/gob/videoplayer.h
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.h	2010-08-08 00:33:13 UTC (rev 51849)
+++ scummvm/trunk/engines/gob/videoplayer.h	2010-08-08 00:33:59 UTC (rev 51850)
@@ -29,7 +29,7 @@
 #include "common/array.h"
 #include "common/str.h"
 
-#include "graphics/video/coktelvideo/coktelvideo.h"
+#include "graphics/video/coktel_decoder.h"
 
 #include "gob/util.h"
 
@@ -88,16 +88,16 @@
 
 	bool slotIsOpen(int slot) const;
 
-	const char *getFileName(int slot = -1) const;
+	const Common::String &getPrimaryFileName() const;
 	uint16 getFlags(int slot = -1) const;
-	int16 getFramesCount(int slot = -1) const;
+	int16 getFrameCount(int slot = -1) const;
 	int16 getCurrentFrame(int slot = -1) const;
 	int16 getWidth(int slot = -1) const;
 	int16 getHeight(int slot = -1) const;
 	int16 getDefaultX(int slot = -1) const;
 	int16 getDefaultY(int slot = -1) const;
 
-	Graphics::CoktelVideo::State getState(int slot = -1) const;
+	void getState(int slot = -1) const;
 	uint32 getFeatures(int slot = -1) const;
 
 	bool hasExtraData(const char *fileName, int slot = -1) const;
@@ -107,47 +107,17 @@
 			int16 varFrames, int16 varWidth, int16 varHeight);
 
 private:
-	class Video {
-		public:
-			Video(GobEngine *vm);
-			~Video();
+	static const int kVideoSlotCount = 32;
 
-			bool open(const char *fileName, Type which, int16 width, int16 height);
-			void close();
-
-			bool isOpen() const;
-
-			const char *getFileName() const;
-			Graphics::CoktelVideo *getVideo();
-			const Graphics::CoktelVideo *getVideo() const;
-
-			Graphics::CoktelVideo::State getState() const;
-			uint32 getFeatures() const;
-
-			int16 getDefaultX() const;
-			int16 getDefaultY() const;
-
-			bool hasExtraData(const char *fileName) const;
-			Common::MemoryReadStream *getExtraData(const char *fileName);
-
-			Graphics::CoktelVideo::State nextFrame();
-
-		private:
-			GobEngine *_vm;
-
-			Common::String _fileName;
-			DataStream *_stream;
-			Graphics::CoktelVideo *_video;
-			Graphics::CoktelVideo::State _state;
-			int16 _defaultX, _defaultY;
-	};
-
 	static const char *_extensions[];
 
 	GobEngine *_vm;
 
-	Common::Array<Video *> _videoSlots;
-	Video *_primaryVideo;
+	Graphics::CoktelDecoder *_primaryVideo;
+	Graphics::CoktelDecoder *_videoSlots[kVideoSlotCount];
+
+	Common::String _primaryFileName;
+
 	bool _ownSurf;
 	bool _backSurf;
 	bool _needBlit;
@@ -157,16 +127,18 @@
 
 	bool findFile(char *fileName, Type &which);
 
-	const Video *getVideoBySlot(int slot = -1) const;
-	Video *getVideoBySlot(int slot = -1);
+	const Graphics::CoktelDecoder *getVideoBySlot(int slot = -1) const;
+	Graphics::CoktelDecoder *getVideoBySlot(int slot = -1);
 
 	int getNextFreeSlot();
 
-	void copyPalette(Graphics::CoktelVideo &video, int16 palStart = -1, int16 palEnd = -1);
+	void copyPalette(Graphics::CoktelDecoder &video, int16 palStart = -1, int16 palEnd = -1);
 	bool doPlay(int16 frame, int16 breakKey,
 			uint16 palCmd, int16 palStart, int16 palEnd,
 			int16 palFrame, int16 endFrame, bool noRetrace = false);
-	void evalBgShading(Graphics::CoktelVideo &video);
+	void evalBgShading(Graphics::CoktelDecoder &video);
+
+	Graphics::CoktelDecoder *openVideo(const char *fileName, Type which, uint16 width, uint16 height);
 };
 
 } // End of namespace Gob

Modified: scummvm/trunk/graphics/module.mk
===================================================================
--- scummvm/trunk/graphics/module.mk	2010-08-08 00:33:13 UTC (rev 51849)
+++ scummvm/trunk/graphics/module.mk	2010-08-08 00:33:59 UTC (rev 51850)
@@ -23,6 +23,7 @@
 	VectorRenderer.o \
 	VectorRendererSpec.o \
 	video/avi_decoder.o \
+	video/coktel_decoder.o \
 	video/dxa_decoder.o \
 	video/flic_decoder.o \
 	video/mpeg_player.o \

Added: scummvm/trunk/graphics/video/coktel_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/coktel_decoder.cpp	                        (rev 0)
+++ scummvm/trunk/graphics/video/coktel_decoder.cpp	2010-08-08 00:33:59 UTC (rev 51850)
@@ -0,0 +1,105 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "graphics/video/coktel_decoder.h"
+
+#ifdef GRAPHICS_VIDEO_COKTELDECODER_H
+
+namespace Graphics {
+
+CoktelDecoder::State::State() : left(0), top(0), right(0), bottom(0), flags(0), speechId(0) {
+}
+
+
+CoktelDecoder::CoktelDecoder(Audio::Mixer &mixer, Audio::Mixer::SoundType soundType) :
+	_mixer(&mixer), _soundType(soundType), _width(0), _height(0), _frameCount(0), _paletteDirty(false) {
+
+	memset(_palette, 0, 768);
+}
+
+CoktelDecoder::~CoktelDecoder() {
+}
+
+uint16 CoktelDecoder::getWidth() const {
+	return _width;
+}
+
+uint16 CoktelDecoder::getHeight() const {
+	return _height;
+}
+
+uint32 CoktelDecoder::getFrameCount() const {
+	return _frameCount;
+}
+
+byte *CoktelDecoder::getPalette() {
+	return _palette;
+}
+
+bool CoktelDecoder::hasDirtyPalette() const {
+	return _paletteDirty;
+}
+
+Common::Rational CoktelDecoder::getFrameRate() const {
+	return _frameRate;
+}
+
+
+PreIMDDecoder::PreIMDDecoder(uint16 width, uint16 height,
+	Audio::Mixer &mixer, Audio::Mixer::SoundType soundType) : CoktelDecoder(mixer, soundType) {
+
+	_width  = width;
+	_height = height;
+}
+
+PreIMDDecoder::~PreIMDDecoder() {
+}
+
+bool PreIMDDecoder::seek(uint32 frame, int whence, bool restart) {
+	return false;
+}
+
+bool PreIMDDecoder::load(Common::SeekableReadStream &stream) {
+	return false;
+}
+
+void PreIMDDecoder::close() {
+}
+
+bool PreIMDDecoder::isVideoLoaded() const {
+	return false;
+}
+
+Surface *PreIMDDecoder::decodeNextFrame() {
+	return 0;
+}
+
+PixelFormat PreIMDDecoder::getPixelFormat() const {
+	return PixelFormat::createFormatCLUT8();
+}
+
+} // End of namespace Graphics
+
+#endif // GRAPHICS_VIDEO_COKTELDECODER_H


Property changes on: scummvm/trunk/graphics/video/coktel_decoder.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: scummvm/trunk/graphics/video/coktel_decoder.h
===================================================================
--- scummvm/trunk/graphics/video/coktel_decoder.h	                        (rev 0)
+++ scummvm/trunk/graphics/video/coktel_decoder.h	2010-08-08 00:33:59 UTC (rev 51850)
@@ -0,0 +1,119 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+// Currently, only GOB and SCI32 games play IMDs and VMDs, so skip compiling if GOB and SCI32 is disabled.
+#if !(defined(ENABLE_GOB) || defined(ENABLE_SCI32) || defined(DYNAMIC_MODULES))
+
+// Do not compile the CoktelDecoder code
+
+#else
+
+#ifndef GRAPHICS_VIDEO_COKTELDECODER_H
+#define GRAPHICS_VIDEO_COKTELDECODER_H
+
+#include "graphics/video/video_decoder.h"
+
+#include "sound/mixer.h"
+
+namespace Graphics {
+
+class CoktelDecoder : public FixedRateVideoDecoder {
+public:
+	struct State {
+		/** Left-most value of the updated rectangle. */
+		int16 left;
+		/** Top-most value of the updated rectangle. */
+		int16 top;
+		/** Right-most value of the updated rectangle. */
+		int16 right;
+		/** Bottom-most value of the updated rectangle. */
+		int16 bottom;
+		/** Set accordingly to what was done. */
+		uint32 flags;
+		/** The id of the spoken words. */
+		uint16 speechId;
+
+		State();
+	};
+
+	CoktelDecoder(Audio::Mixer &mixer,
+			Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
+	~CoktelDecoder();
+
+	virtual bool seek(uint32 frame, int whence = SEEK_SET, bool restart = false) = 0;
+
+	// VideoDecoder interface
+
+	uint16 getWidth()  const;
+	uint16 getHeight() const;
+
+	uint32 getFrameCount() const;
+
+	byte *getPalette();
+	bool  hasDirtyPalette() const;
+
+protected:
+	Audio::Mixer *_mixer;
+	Audio::Mixer::SoundType _soundType;
+
+	uint16 _width;
+	uint16 _height;
+
+	uint32 _frameCount;
+
+	byte _palette[768];
+	bool _paletteDirty;
+
+	Common::Rational _frameRate;
+
+	// FixedRateVideoDecoder interface
+	Common::Rational getFrameRate() const;
+};
+
+class PreIMDDecoder : public CoktelDecoder {
+public:
+	PreIMDDecoder(uint16 width, uint16 height, Audio::Mixer &mixer,
+			Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
+	~PreIMDDecoder();
+
+	bool seek(uint32 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;
+};
+
+} // End of namespace Graphics
+
+#endif // GRAPHICS_VIDEO_COKTELDECODER_H
+
+#endif // Engine and dynamic plugins guard


Property changes on: scummvm/trunk/graphics/video/coktel_decoder.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native


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