[Scummvm-cvs-logs] SF.net SVN: scummvm:[53298] scummvm/trunk/engines/sword25/fmv

sev at users.sourceforge.net sev at users.sourceforge.net
Wed Oct 13 01:22:24 CEST 2010


Revision: 53298
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53298&view=rev
Author:   sev
Date:     2010-10-12 23:22:24 +0000 (Tue, 12 Oct 2010)

Log Message:
-----------
SWORD25: Implement playback. Blitting is TODO.

Modified Paths:
--------------
    scummvm/trunk/engines/sword25/fmv/movieplayer.cpp
    scummvm/trunk/engines/sword25/fmv/theora_decoder.cpp
    scummvm/trunk/engines/sword25/fmv/theora_decoder.h

Modified: scummvm/trunk/engines/sword25/fmv/movieplayer.cpp
===================================================================
--- scummvm/trunk/engines/sword25/fmv/movieplayer.cpp	2010-10-12 23:22:01 UTC (rev 53297)
+++ scummvm/trunk/engines/sword25/fmv/movieplayer.cpp	2010-10-12 23:22:24 UTC (rev 53298)
@@ -54,7 +54,7 @@
 	_decoder = new TheoraDecoder();
 }
 
-bool MoviePlayer::LoadMovie(const Common::String &filename, unsigned int Z) {
+bool MoviePlayer::LoadMovie(const Common::String &filename, unsigned int z) {
 	Common::SeekableReadStream *in = Kernel::GetInstance()->GetPackage()->GetStream(filename);
 
 	if (!in) {
@@ -62,11 +62,15 @@
 		return false;
 	}
 
+	debug(2, "LoadMovie(%s, %d)", filename.c_str(), z);
+
 	if (!_decoder->load(in)) {
 		BS_LOG_ERRORLN("Could not load movie file \"%s\".", filename.c_str());
 		return false;
 	}
 
+	warning("STUB: MoviePlayer::LoadMovie(). Z is not handled");
+
 	return true;
 }
 
@@ -77,22 +81,30 @@
 }
 
 bool MoviePlayer::Play() {
+	_decoder->pauseVideo(false);
+
 	return true;
 }
 
 bool MoviePlayer::Pause() {
+	_decoder->pauseVideo(true);
+
 	return true;
 }
 
 void MoviePlayer::Update() {
+	if (!_decoder->isVideoLoaded())
+		return;
+
+	Graphics::Surface *surface = _decoder->decodeNextFrame();
 }
 
 bool MoviePlayer::IsMovieLoaded() {
-	return true;
+	return _decoder->isVideoLoaded();
 }
 
 bool MoviePlayer::IsPaused() {
-	return true;
+	return _decoder->isPaused();
 }
 
 float MoviePlayer::GetScaleFactor() {
@@ -103,7 +115,7 @@
 }
 
 double MoviePlayer::GetTime() {
-	return 1.0;
+	return (double)_decoder->getElapsedTime() / 1000.0;
 }
 
 

Modified: scummvm/trunk/engines/sword25/fmv/theora_decoder.cpp
===================================================================
--- scummvm/trunk/engines/sword25/fmv/theora_decoder.cpp	2010-10-12 23:22:01 UTC (rev 53297)
+++ scummvm/trunk/engines/sword25/fmv/theora_decoder.cpp	2010-10-12 23:22:24 UTC (rev 53298)
@@ -60,11 +60,21 @@
 	_soundType = soundType;
 	_audStream = 0;
 	_audHandle = new Audio::SoundHandle();
+
+	_theoraDecode = 0;
+	_theoraSetup = 0;
+
+	_curFrame = 0;
+
+	_audiobuf = (ogg_int16_t *)calloc(AUDIOFD_FRAGSIZE, sizeof(ogg_int16_t));
+
+	reset();
 }
 
 TheoraDecoder::~TheoraDecoder() {
 	close();
 	delete _audHandle;
+	free(_audiobuf);
 }
 
 void TheoraDecoder::queuePage(ogg_page *page) {
@@ -81,7 +91,7 @@
 
 	ogg_sync_wrote(&_oggSync, bytes);
 
-	return(bytes);
+	return bytes;
 }
 
 bool TheoraDecoder::load(Common::SeekableReadStream *stream) {
@@ -209,6 +219,36 @@
 			debug(1, "  Frame content is %dx%d with offset (%d,%d).",
 			      _theoraInfo.frame_width, _theoraInfo.frame_height, _theoraInfo.pic_x, _theoraInfo.pic_y);
 
+		switch (_theoraInfo.colorspace){
+		case TH_CS_UNSPECIFIED:
+			/* nothing to report */
+			break;;
+		case TH_CS_ITU_REC_470M:
+			debug(1, "  encoder specified ITU Rec 470M (NTSC) color.");
+			break;
+		case TH_CS_ITU_REC_470BG:
+			debug(1, "  encoder specified ITU Rec 470BG (PAL) color.");
+			break;
+		default:
+			debug(1, "warning: encoder specified unknown colorspace (%d).", _theoraInfo.colorspace);
+			break;
+		}
+
+		debug(1, "Encoded by %s", _theoraComment.vendor);
+		if (_theoraComment.comments) {
+			debug(1, "theora comment header:");
+			for (int i = 0; i < _theoraComment.comments; i++) {
+				if (_theoraComment.user_comments[i]) {
+					int len = _theoraComment.comment_lengths[i];
+					char *value = (char *)malloc(len + 1);
+					memcpy(value, _theoraComment.user_comments[i], len);
+					value[len] = '\0';
+					debug(1, "\t%s", value);
+					free(value);
+				}
+			}
+		}
+
 		th_decode_ctl(_theoraDecode, TH_DECCTL_GET_PPLEVEL_MAX, &_ppLevelMax, sizeof(_ppLevelMax));
 		_ppLevel = _ppLevelMax;
 		th_decode_ctl(_theoraDecode, TH_DECCTL_SET_PPLEVEL, &_ppLevel, sizeof(_ppLevel));
@@ -220,7 +260,9 @@
 		th_comment_clear(&_theoraComment);
 	}
 
+
 	th_setup_free(_theoraSetup);
+	_theoraSetup = 0;
 
 	if (_vorbisPacket) {
 		vorbis_synthesis_init(&_vorbisDSP, &_vorbisInfo);
@@ -241,9 +283,8 @@
 	}
 
 	_surface = new Graphics::Surface();
+	_surface->create(_theoraInfo.frame_width, _theoraInfo.frame_height, 4);
 
-	_surface->create(_theoraInfo.frame_width, _theoraInfo.frame_height, 3);
-
 	return true;
 }
 
@@ -258,12 +299,15 @@
 		if (_mixer)
 			_mixer->stopHandle(*_audHandle);
 		_audStream = 0;
+		_vorbisPacket = 0;
 	}
 	if (_theoraPacket) {
 		ogg_stream_clear(&_theoraOut);
 		th_decode_free(_theoraDecode);
 		th_comment_clear(&_theoraComment);
 		th_info_clear(&_theoraInfo);
+		_theoraDecode = 0;
+		_theoraPacket = 0;
 	}
 
 	if (!_fileStream)
@@ -406,6 +450,7 @@
 
 void TheoraDecoder::reset() {
 	VideoDecoder::reset();
+
 	if (_fileStream)
 		_fileStream->seek(0);
 
@@ -416,8 +461,15 @@
 	_audiobufFill = 0;
 	_audiobufReady = false;
 	_audiobufGranulePos = 0;
+
+	_curFrame = 0;
 }
 
+bool TheoraDecoder::endOfVideo() const {
+	return !isVideoLoaded();
+}
+
+
 uint32 TheoraDecoder::getElapsedTime() const {
 	if (_audStream && _mixer)
 		return _mixer->getSoundElapsedTime(*_audHandle);

Modified: scummvm/trunk/engines/sword25/fmv/theora_decoder.h
===================================================================
--- scummvm/trunk/engines/sword25/fmv/theora_decoder.h	2010-10-12 23:22:01 UTC (rev 53297)
+++ scummvm/trunk/engines/sword25/fmv/theora_decoder.h	2010-10-12 23:22:24 UTC (rev 53298)
@@ -68,6 +68,10 @@
 	bool isVideoLoaded() const {
 		return _fileStream != 0;
 	}
+	bool isPaused() const {
+		return (VideoDecoder::isPaused() || !isVideoLoaded());
+	}
+
 	uint16 getWidth() const {
 		return _surface->w;
 	}
@@ -75,14 +79,18 @@
 		return _surface->h;
 	}
 	uint32 getFrameCount() const {
-		return _frameCount;
+		// It is not possible to get frame count easily
+		// I.e. seeking is required
+		assert(0);
 	}
 	Graphics::PixelFormat getPixelFormat() const {
-		return Graphics::PixelFormat(3, 8, 8, 8, 0, 0, 0, 0, 0);
+		return Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24);
 	}
 
 	uint32 getElapsedTime() const;
 
+	bool endOfVideo() const;
+
 protected:
 	Common::Rational getFrameRate() const {
 		return _frameRate;


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