[Scummvm-cvs-logs] scummvm master -> 279c9f78412d9053a60b53b70b5e770159a2aa92

clone2727 clone2727 at gmail.com
Sat Jul 6 00:28:56 CEST 2013


This automated email contains information about 10 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e5e467f5a1 CONFIGURE: Add libmpeg2 as an optional dependency again
36bc47df44 VIDEO: Add an MPEG 1/2 decoder
0b81e59d0a VIDEO: Update AVI code for parsing sword1/sword2 MPEG-2 files
f39c9d58bd VIDEO: Hook up MPEG decoder to AVI
aa2d41701d VIDEO: Allow AVI frame rate to be overriden with a constant
69a1e8ac36 SWORD1: Add back MPEG-2 video support
15a4d52ef7 SWORD2: Add back MPEG-2 video support
1ff09c581b VIDEO: Mark AVIDecoder as being used by sword1/sword2
4ed1bc3a57 CONFIGURE: Make the libmpeg2 properly require 0.4.0
279c9f7841 Merge pull request #343 from clone2727/mpeg2-avi


Commit: e5e467f5a1dffde7f4371a7c585351188677f746
    https://github.com/scummvm/scummvm/commit/e5e467f5a1dffde7f4371a7c585351188677f746
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-06-19T20:58:03-07:00

Commit Message:
CONFIGURE: Add libmpeg2 as an optional dependency again

Changed paths:
    configure



diff --git a/configure b/configure
index dbd78d3..41d96fb 100755
--- a/configure
+++ b/configure
@@ -113,6 +113,7 @@ _seq_midi=auto
 _sndio=auto
 _timidity=auto
 _zlib=auto
+_mpeg2=auto
 _sparkle=auto
 _png=auto
 _theoradec=auto
@@ -924,6 +925,9 @@ Optional Libraries:
   --with-zlib-prefix=DIR   Prefix where zlib is installed (optional)
   --disable-zlib           disable zlib (compression) support [autodetect]
 
+  --with-mpeg2-prefix=DIR  Prefix where libmpeg2 is installed (optional)
+  --enable-mpeg2           enable mpeg2 codec for cutscenes [autodetect]
+
   --with-opengl-prefix=DIR Prefix where OpenGL (ES) is installed (optional)
   --disable-opengl         disable OpenGL (ES) support [autodetect]
 
@@ -1004,6 +1008,8 @@ for ac_option in $@; do
 	--disable-sparkle)        _sparkle=no     ;;
 	--enable-nasm)            _nasm=yes       ;;
 	--disable-nasm)           _nasm=no        ;;
+	--enable-mpeg2)           _mpeg2=yes      ;;
+	--disable-mpeg2)          _mpeg2=no       ;;
 	--disable-png)            _png=no         ;;
 	--enable-png)             _png=yes        ;;
 	--disable-theoradec)      _theoradec=no   ;;
@@ -1043,6 +1049,11 @@ for ac_option in $@; do
 		FLUIDSYNTH_CFLAGS="-I$arg/include"
 		FLUIDSYNTH_LIBS="-L$arg/lib"
 		;;
+	--with-mpeg2-prefix=*)
+		arg=`echo $ac_option | cut -d '=' -f 2`
+		MPEG2_CFLAGS="-I$arg/include"
+		MPEG2_LIBS="-L$arg/lib"
+		;;
 	--with-alsa-prefix=*)
 		arg=`echo $ac_option | cut -d '=' -f 2`
 		ALSA_CFLAGS="-I$arg/include"
@@ -3461,6 +3472,49 @@ define_in_config_if_yes "$_zlib" 'USE_ZLIB'
 echo "$_zlib"
 
 #
+# Check for LibMPEG2
+#
+echocheck "libmpeg2 >= 0.3.2"
+if test "$_mpeg2" = auto ; then
+	_mpeg2=no
+	cat > $TMPC << EOF
+typedef signed $type_1_byte int8_t;
+typedef signed $type_2_byte int16_t;
+typedef signed $type_4_byte int32_t;
+
+typedef unsigned $type_1_byte uint8_t;
+typedef unsigned $type_2_byte uint16_t;
+typedef unsigned $type_4_byte uint32_t;
+
+#include <mpeg2dec/mpeg2.h>
+int main(void) {
+	/* mpeg2_state_t first appears in 0.4.0 */
+	mpeg2_state_t state;
+
+		#ifdef MPEG2_RELEASE
+		if (MPEG2_RELEASE >= MPEG2_VERSION(0, 3, 2))
+			return 0;
+	#endif
+	return 1;
+}
+EOF
+
+	if test -n "$_host"; then
+		# don't execute while cross compiling
+		cc_check $MPEG2_CFLAGS $MPEG2_LIBS -lmpeg2 && _mpeg2=yes
+	else
+		cc_check_no_clean $MPEG2_CFLAGS $MPEG2_LIBS -lmpeg2 && $TMPO$HOSTEXEEXT && _mpeg2=yes
+		cc_check_clean
+	fi
+fi
+if test "$_mpeg2" = yes ; then
+	INCLUDES="$INCLUDES $MPEG2_CFLAGS"
+	LIBS="$LIBS $MPEG2_LIBS -lmpeg2"
+fi
+define_in_config_if_yes "$_mpeg2" 'USE_MPEG2'
+echo "$_mpeg2"
+
+#
 # Check for Sparkle if updates support is enabled
 #
 echocheck "Sparkle"


Commit: 36bc47df446f1580edf15a407228579291196b4a
    https://github.com/scummvm/scummvm/commit/36bc47df446f1580edf15a407228579291196b4a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-06-19T20:59:04-07:00

Commit Message:
VIDEO: Add an MPEG 1/2 decoder

Changed paths:
  A video/codecs/mpeg.cpp
  A video/codecs/mpeg.h
    video/module.mk



diff --git a/video/codecs/mpeg.cpp b/video/codecs/mpeg.cpp
new file mode 100644
index 0000000..cb3c63f
--- /dev/null
+++ b/video/codecs/mpeg.cpp
@@ -0,0 +1,107 @@
+/* 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.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/stream.h"
+#include "common/system.h"
+#include "common/textconsole.h"
+#include "graphics/surface.h"
+#include "graphics/yuv_to_rgb.h"
+
+#include "video/codecs/mpeg.h"
+
+namespace Video {
+
+MPEGDecoder::MPEGDecoder() : Codec() {
+	_pixelFormat = g_system->getScreenFormat();
+	_surface = 0;
+
+	_mpegDecoder = mpeg2_init();
+
+	if (!_mpegDecoder)
+		error("Could not initialize libmpeg2");
+
+	_mpegInfo = mpeg2_info(_mpegDecoder);
+}
+
+MPEGDecoder::~MPEGDecoder() {
+	mpeg2_close(_mpegDecoder);
+
+	if (_surface) {
+		_surface->free();
+		delete _surface;
+	}
+}
+
+const Graphics::Surface *MPEGDecoder::decodeImage(Common::SeekableReadStream *stream) {
+	uint32 framePeriod;
+	decodePacket(stream, framePeriod);
+	return _surface;
+}
+
+bool MPEGDecoder::decodePacket(Common::SeekableReadStream *packet, uint32 &framePeriod, Graphics::Surface *dst) {			
+	// Decode as much as we can out of this packet
+	uint32 size = 0xFFFFFFFF;
+	mpeg2_state_t state;
+	bool foundFrame = false;
+	framePeriod = 0;
+
+	do {
+		state = mpeg2_parse(_mpegDecoder);
+
+		switch (state) {
+		case STATE_BUFFER:
+			size = packet->read(_buffer, BUFFER_SIZE);
+			mpeg2_buffer(_mpegDecoder, _buffer, _buffer + size);
+			break;
+		case STATE_SLICE:
+		case STATE_END:
+			if (_mpegInfo->display_fbuf) {
+				foundFrame = true;
+				const mpeg2_sequence_t *sequence = _mpegInfo->sequence;
+
+				framePeriod += sequence->frame_period;
+
+				if (!dst) {
+					// If no destination is specified, use our internal storage
+					if (!_surface) {
+						_surface = new Graphics::Surface();
+						_surface->create(sequence->picture_width, sequence->picture_height, _pixelFormat);
+					}
+
+					dst = _surface;
+				}
+
+				YUVToRGBMan.convert420(dst, Graphics::YUVToRGBManager::kScaleITU, _mpegInfo->display_fbuf->buf[0],
+						_mpegInfo->display_fbuf->buf[1], _mpegInfo->display_fbuf->buf[2], sequence->picture_width,
+						sequence->picture_height, sequence->width, sequence->chroma_width);
+			}
+			break;
+		default:
+			break;
+		}
+	} while (size != 0);
+
+	return foundFrame;
+}
+
+} // End of namespace Video
diff --git a/video/codecs/mpeg.h b/video/codecs/mpeg.h
new file mode 100644
index 0000000..0082844
--- /dev/null
+++ b/video/codecs/mpeg.h
@@ -0,0 +1,98 @@
+/* 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.
+ *
+ */
+
+#ifdef USE_MPEG2
+
+#ifndef VIDEO_CODECS_MPEG_H
+#define VIDEO_CODECS_MPEG_H
+
+#include "video/codecs/codec.h"
+#include "graphics/pixelformat.h"
+
+#if defined(__PLAYSTATION2__)
+	typedef uint8 uint8_t;
+	typedef uint16 uint16_t;
+	typedef uint32 uint32_t;
+#elif defined(_WIN32_WCE)
+	typedef signed char int8_t;
+	typedef signed short int16_t;
+	typedef unsigned char uint8_t;
+	typedef unsigned short uint16_t;
+#elif defined(_MSC_VER)
+	typedef signed char int8_t;
+	typedef signed short int16_t;
+	typedef unsigned char uint8_t;
+	typedef unsigned short uint16_t;
+	#if !defined(SDL_COMPILEDVERSION) || (SDL_COMPILEDVERSION < 1210)
+	typedef signed long int32_t;
+	typedef unsigned long uint32_t;
+	#endif
+#else
+#	include <inttypes.h>
+#endif
+
+extern "C" {
+	#include <mpeg2dec/mpeg2.h>
+}
+
+namespace Common {
+class SeekableReadStream;
+}
+
+namespace Graphics {
+struct Surface;
+}
+
+namespace Video {
+
+// MPEG 1/2 video decoder
+
+class MPEGDecoder : public Codec {
+public:
+	MPEGDecoder();
+	~MPEGDecoder();
+
+	// Codec interface
+	const Graphics::Surface *decodeImage(Common::SeekableReadStream *stream);
+	Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; }
+
+	// MPEGPSDecoder call
+	bool decodePacket(Common::SeekableReadStream *packet, uint32 &framePeriod, Graphics::Surface *dst = 0);
+
+private:
+	Graphics::PixelFormat _pixelFormat;
+	Graphics::Surface *_surface;
+
+	enum {
+		BUFFER_SIZE = 4096
+	};
+
+	byte _buffer[BUFFER_SIZE];
+	mpeg2dec_t *_mpegDecoder;
+	const mpeg2_info_t *_mpegInfo;
+};
+
+} // End of namespace Video
+
+#endif // VIDEO_CODECS_MPEG_H
+
+#endif // USE_MPEG2
diff --git a/video/module.mk b/video/module.mk
index 287e14c..a491947 100644
--- a/video/module.mk
+++ b/video/module.mk
@@ -31,5 +31,10 @@ MODULE_OBJS += \
 	theora_decoder.o
 endif
 
+ifdef USE_MPEG2
+MODULE_OBJS += \
+	codecs/mpeg.o
+endif
+
 # Include common rules
 include $(srcdir)/rules.mk


Commit: 0b81e59d0ad5955c82c26817d6a3260242e794e4
    https://github.com/scummvm/scummvm/commit/0b81e59d0ad5955c82c26817d6a3260242e794e4
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-06-19T21:02:32-07:00

Commit Message:
VIDEO: Update AVI code for parsing sword1/sword2 MPEG-2 files

Changed paths:
    video/avi_decoder.cpp
    video/avi_decoder.h



diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp
index 6fe9c77..8553642 100644
--- a/video/avi_decoder.cpp
+++ b/video/avi_decoder.cpp
@@ -64,8 +64,8 @@ namespace Video {
 #define ID_VEDT MKTAG('v','e','d','t')
 #define ID_IDX1 MKTAG('i','d','x','1')
 #define ID_STRD MKTAG('s','t','r','d')
-#define ID_00AM MKTAG('0','0','A','M')
 //#define ID_INFO MKTAG('I','N','F','O')
+#define ID_ISFT MKTAG('I','S','F','T')
 
 // Codec tags
 #define ID_RLE  MKTAG('R','L','E',' ')
@@ -75,6 +75,7 @@ namespace Video {
 #define ID_CVID MKTAG('c','v','i','d')
 #define ID_IV32 MKTAG('i','v','3','2')
 #define ID_DUCK MKTAG('D','U','C','K')
+#define ID_MPG2 MKTAG('m','p','g','2')
 
 static byte char2num(char c) {
 	c = tolower((byte)c);
@@ -91,6 +92,7 @@ static uint16 getStreamType(uint32 tag) {
 
 AVIDecoder::AVIDecoder(Audio::Mixer::SoundType soundType) : _soundType(soundType) {
 	_decodedHeader = false;
+	_foundMovieList = false;
 	_fileStream = 0;
 	memset(&_ixInfo, 0, sizeof(_ixInfo));
 	memset(&_header, 0, sizeof(_header));
@@ -137,6 +139,7 @@ void AVIDecoder::runHandle(uint32 tag) {
 	case ID_STRD: // Extra stream info, safe to ignore
 	case ID_VEDT: // Unknown, safe to ignore
 	case ID_JUNK: // Alignment bytes, should be ignored
+	case ID_ISFT: // Metadata, safe to ignore
 		{
 		uint32 junkSize = _fileStream->readUint32LE();
 		_fileStream->skip(junkSize + (junkSize & 1)); // Alignment
@@ -165,6 +168,13 @@ void AVIDecoder::handleList() {
 
 	debug(0, "Found LIST of type %s", tag2str(listType));
 
+	if (listType == ID_MOVI) {
+		// Found the 'movi' list
+		// We're done parsing everything
+		_foundMovieList = true;
+		return;
+	}
+
 	while ((_fileStream->pos() - curPos) < listSize)
 		runHandle(_fileStream->readUint32BE());
 
@@ -263,26 +273,24 @@ bool AVIDecoder::loadStream(Common::SeekableReadStream *stream) {
 
 	_fileStream = stream;
 	_decodedHeader = false;
+	_foundMovieList = false;
 
 	// Read chunks until we have decoded the header
-	while (!_decodedHeader)
+	while (!_decodedHeader && _fileStream->pos() < _fileStream->size())
 		runHandle(_fileStream->readUint32BE());
 
-	uint32 nextTag = _fileStream->readUint32BE();
-
-	// Throw out any JUNK section
-	if (nextTag == ID_JUNK) {
-		runHandle(ID_JUNK);
-		nextTag = _fileStream->readUint32BE();
+	if (_fileStream->pos() >= _fileStream->size()) {
+		warning("Failed to find AVI header");
+		return false;
 	}
 
-	// Ignore the 'movi' LIST
-	if (nextTag == ID_LIST) {
-		_fileStream->readUint32BE(); // Skip size
-		if (_fileStream->readUint32BE() != ID_MOVI)
-			error("Expected 'movi' LIST");
-	} else {
-		error("Expected 'movi' LIST");
+	// Then read until we find the movie list
+	while (!_foundMovieList && _fileStream->pos() < _fileStream->size())
+		runHandle(_fileStream->readUint32BE());
+
+	if (_fileStream->pos() >= _fileStream->size()) {
+		warning("Failed to find AVI 'movi' LIST");
+		return false;
 	}
 
 	return true;
@@ -294,6 +302,7 @@ void AVIDecoder::close() {
 	delete _fileStream;
 	_fileStream = 0;
 	_decodedHeader = false;
+	_foundMovieList = false;
 
 	delete[] _ixInfo.indices;
 	memset(&_ixInfo, 0, sizeof(_ixInfo));
@@ -428,6 +437,9 @@ Codec *AVIDecoder::AVIVideoTrack::createCodec() {
 	case ID_DUCK:
 		return new TrueMotion1Decoder(_bmInfo.width, _bmInfo.height);
 #endif
+	case ID_MPG2:
+		warning("Unhandled MPEG-2 codec in AVI file");
+		break;
 	default:
 		warning("Unknown/Unhandled compression format \'%s\'", tag2str(_vidsHeader.streamHandler));
 	}
diff --git a/video/avi_decoder.h b/video/avi_decoder.h
index 34a67f4..bc870ea 100644
--- a/video/avi_decoder.h
+++ b/video/avi_decoder.h
@@ -219,7 +219,7 @@ private:
 	AVIHeader _header;
 
 	Common::SeekableReadStream *_fileStream;
-	bool _decodedHeader;
+	bool _decodedHeader, _foundMovieList;
 
 	Audio::Mixer::SoundType _soundType;
 


Commit: f39c9d58bddc558a3322137684190983ea403d52
    https://github.com/scummvm/scummvm/commit/f39c9d58bddc558a3322137684190983ea403d52
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-06-19T21:02:50-07:00

Commit Message:
VIDEO: Hook up MPEG decoder to AVI

Changed paths:
    video/avi_decoder.cpp



diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp
index 8553642..32238ec 100644
--- a/video/avi_decoder.cpp
+++ b/video/avi_decoder.cpp
@@ -36,6 +36,7 @@
 // Video Codecs
 #include "video/codecs/cinepak.h"
 #include "video/codecs/indeo3.h"
+#include "video/codecs/mpeg.h"
 #include "video/codecs/msvideo1.h"
 #include "video/codecs/msrle.h"
 #include "video/codecs/truemotion1.h"
@@ -437,9 +438,10 @@ Codec *AVIDecoder::AVIVideoTrack::createCodec() {
 	case ID_DUCK:
 		return new TrueMotion1Decoder(_bmInfo.width, _bmInfo.height);
 #endif
+#ifdef USE_MPEG2
 	case ID_MPG2:
-		warning("Unhandled MPEG-2 codec in AVI file");
-		break;
+		return new MPEGDecoder();
+#endif
 	default:
 		warning("Unknown/Unhandled compression format \'%s\'", tag2str(_vidsHeader.streamHandler));
 	}


Commit: aa2d41701d14a651c23c4e2a4c5098a300f2235f
    https://github.com/scummvm/scummvm/commit/aa2d41701d14a651c23c4e2a4c5098a300f2235f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-06-19T21:04:37-07:00

Commit Message:
VIDEO: Allow AVI frame rate to be overriden with a constant

Required for sword1/sword2 MPEG videos

Changed paths:
    video/avi_decoder.cpp
    video/avi_decoder.h



diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp
index 32238ec..ff728a8 100644
--- a/video/avi_decoder.cpp
+++ b/video/avi_decoder.cpp
@@ -91,7 +91,20 @@ static uint16 getStreamType(uint32 tag) {
 	return tag & 0xffff;
 }
 
-AVIDecoder::AVIDecoder(Audio::Mixer::SoundType soundType) : _soundType(soundType) {
+AVIDecoder::AVIDecoder(Audio::Mixer::SoundType soundType) : _frameRateOverride(0), _soundType(soundType) {
+	initCommon();
+}
+
+AVIDecoder::AVIDecoder(const Common::Rational &frameRateOverride, Audio::Mixer::SoundType soundType)
+		: _frameRateOverride(frameRateOverride), _soundType(soundType) {
+	initCommon();
+}
+
+AVIDecoder::~AVIDecoder() {
+	close();
+}
+
+void AVIDecoder::initCommon() {
 	_decodedHeader = false;
 	_foundMovieList = false;
 	_fileStream = 0;
@@ -99,10 +112,6 @@ AVIDecoder::AVIDecoder(Audio::Mixer::SoundType soundType) : _soundType(soundType
 	memset(&_header, 0, sizeof(_header));
 }
 
-AVIDecoder::~AVIDecoder() {
-	close();
-}
-
 void AVIDecoder::runHandle(uint32 tag) {
 	assert(_fileStream);
 	if (_fileStream->eos())
@@ -214,6 +223,11 @@ void AVIDecoder::handleStreamHeader() {
 	uint32 startPos = _fileStream->pos();
 
 	if (sHeader.streamType == ID_VIDS) {
+		if (_frameRateOverride != 0) {
+			sHeader.rate = _frameRateOverride.getNumerator();
+			sHeader.scale = _frameRateOverride.getDenominator();
+		}
+
 		BitmapInfoHeader bmInfo;
 		bmInfo.size = _fileStream->readUint32LE();
 		bmInfo.width = _fileStream->readUint32LE();
diff --git a/video/avi_decoder.h b/video/avi_decoder.h
index bc870ea..1652614 100644
--- a/video/avi_decoder.h
+++ b/video/avi_decoder.h
@@ -56,6 +56,7 @@ class Codec;
 class AVIDecoder : public VideoDecoder {
 public:
 	AVIDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
+	AVIDecoder(const Common::Rational &frameRateOverride, Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
 	virtual ~AVIDecoder();
 
 	bool loadStream(Common::SeekableReadStream *stream);
@@ -222,6 +223,8 @@ private:
 	bool _decodedHeader, _foundMovieList;
 
 	Audio::Mixer::SoundType _soundType;
+	Common::Rational _frameRateOverride;
+	void initCommon();
 
 	void runHandle(uint32 tag);
 	void handleList();


Commit: 69a1e8ac3677a6f634264e16cf4d94be6c770c7b
    https://github.com/scummvm/scummvm/commit/69a1e8ac3677a6f634264e16cf4d94be6c770c7b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-06-20T16:49:28-07:00

Commit Message:
SWORD1: Add back MPEG-2 video support

Changed paths:
    engines/sword1/animation.cpp
    engines/sword1/animation.h



diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp
index 206bd68..79ec060 100644
--- a/engines/sword1/animation.cpp
+++ b/engines/sword1/animation.cpp
@@ -37,7 +37,14 @@
 
 #include "gui/message.h"
 
+#ifdef USE_MPEG2
+#include "video/avi_decoder.h"
+#endif
+
+#ifdef USE_ZLIB
 #include "video/dxa_decoder.h"
+#endif
+
 #include "video/psx_decoder.h"
 #include "video/smk_decoder.h"
 
@@ -176,27 +183,26 @@ bool MoviePlayer::load(uint32 id) {
 		break;
 	case kVideoDecoderPSX:
 		filename = Common::String::format("%s.str", (_vm->_systemVars.isDemo) ? sequenceList[id] : sequenceListPSX[id]);
+		break;
+	case kVideoDecoderMP2:
+		filename = Common::String::format("%s.mp2", sequenceList[id]);
+		break;
+	}
 
-		// Need to switch to true color
+	// Need to switch to true color for PSX/MP2 videos
+	if (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2)
 		initGraphics(g_system->getWidth(), g_system->getHeight(), true, 0);
 
-		// Need to load here in case it fails in which case we'd need
-		// to go back to paletted mode
-		if (_decoder->loadFile(filename)) {
-			_decoder->start();
-			return true;
-		} else {
+	if (!_decoder->loadFile(filename)) {
+		// Go back to 8bpp color
+		if (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2)
 			initGraphics(g_system->getWidth(), g_system->getHeight(), true);
-			return false;
-		}
-		break;
-	}
 
-	if (!_decoder->loadFile(filename))
 		return false;
+	}
 
-	// For DXA, also add the external sound file
-	if (_decoderType == kVideoDecoderDXA)
+	// For DXA/MP2, also add the external sound file
+	if (_decoderType == kVideoDecoderDXA || _decoderType == kVideoDecoderMP2)
 		_decoder->addStreamFileTrack(sequenceList[id]);
 
 	_decoder->start();
@@ -224,9 +230,9 @@ void MoviePlayer::play() {
 }
 
 void MoviePlayer::performPostProcessing(byte *screen) {
-	// TODO: We don't support the PSX stream videos yet
+	// TODO: We don't support displaying these in true color yet,
 	// nor using the PSX fonts to display subtitles.
-	if (_vm->isPsx())
+	if (_vm->isPsx() || _decoderType == kVideoDecoderMP2)
 		return;
 
 	if (!_movieTexts.empty()) {
@@ -414,20 +420,19 @@ bool MoviePlayer::playVideo() {
 		_vm->_system->delayMillis(10);
 	}
 
-	if (_decoderType == kVideoDecoderPSX) {
-		// Need to jump back to paletted color
+	// Need to jump back to paletted color
+	if (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2)
 		initGraphics(g_system->getWidth(), g_system->getHeight(), true);
-	}
 
 	return !_vm->shouldQuit() && !skipped;
 }
 
 uint32 MoviePlayer::getBlackColor() {
-	return (_decoderType == kVideoDecoderPSX) ? g_system->getScreenFormat().RGBToColor(0x00, 0x00, 0x00) : _black;
+	return (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2) ? g_system->getScreenFormat().RGBToColor(0x00, 0x00, 0x00) : _black;
 }
 
 uint32 MoviePlayer::findTextColor() {
-	if (_decoderType == kVideoDecoderPSX) {
+	if (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2) {
 		// We're in true color mode, so return the actual colors
 		switch (_textColor) {
 		case 1:
@@ -547,9 +552,16 @@ MoviePlayer *makeMoviePlayer(uint32 id, SwordEngine *vm, Text *textMan, ResMan *
 	filename = Common::String::format("%s.mp2", sequenceList[id]);
 
 	if (Common::File::exists(filename)) {
-		GUI::MessageDialog dialog(_("MPEG2 cutscenes are no longer supported"), _("OK"));
+#ifdef USE_MPEG2
+		// HACK: Old ScummVM builds ignored the AVI frame rate field and forced the video
+		// to be played back at 12fps.
+		Video::VideoDecoder *aviDecoder = new Video::AVIDecoder(12);
+		return new MoviePlayer(vm, textMan, resMan, system, aviDecoder, kVideoDecoderMP2);
+#else
+		GUI::MessageDialog dialog(_("MPEG-2 cutscenes found but ScummVM has been built without MPEG-2"), _("OK"));
 		dialog.runModal();
 		return 0;
+#endif
 	}
 
 	if (!vm->isPsx() || scumm_stricmp(sequenceList[id], "enddemo") != 0) {
diff --git a/engines/sword1/animation.h b/engines/sword1/animation.h
index d0c61f5..2c51a74 100644
--- a/engines/sword1/animation.h
+++ b/engines/sword1/animation.h
@@ -41,7 +41,8 @@ namespace Sword1 {
 enum DecoderType {
 	kVideoDecoderDXA = 0,
 	kVideoDecoderSMK = 1,
-	kVideoDecoderPSX = 2
+	kVideoDecoderPSX = 2,
+	kVideoDecoderMP2 = 3
 };
 
 class MovieText {


Commit: 15a4d52ef7c55d2c004979244ea6e823ac33fe18
    https://github.com/scummvm/scummvm/commit/15a4d52ef7c55d2c004979244ea6e823ac33fe18
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-06-20T16:55:00-07:00

Commit Message:
SWORD2: Add back MPEG-2 video support

Changed paths:
    engines/sword2/animation.cpp
    engines/sword2/animation.h



diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp
index 00260f7..713120a 100644
--- a/engines/sword2/animation.cpp
+++ b/engines/sword2/animation.cpp
@@ -42,7 +42,14 @@
 
 #include "gui/message.h"
 
+#ifdef USE_MPEG2
+#include "video/avi_decoder.h"
+#endif
+
+#ifdef USE_ZLIB
 #include "video/dxa_decoder.h"
+#endif
+
 #include "video/smk_decoder.h"
 #include "video/psx_decoder.h"
 
@@ -88,26 +95,26 @@ bool MoviePlayer::load(const char *name) {
 		break;
 	case kVideoDecoderPSX:
 		filename = Common::String::format("%s.str", name);
+		break;
+	case kVideoDecoderMP2:
+		filename = Common::String::format("%s.mp2", name);
+		break;
+	}
 
-		// Need to switch to true color
-		initGraphics(640, 480, true, 0);
+	// Need to switch to true color for PSX/MP2 videos
+	if (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2)
+		initGraphics(g_system->getWidth(), g_system->getHeight(), true, 0);
 
-		// Need to load here in case it fails in which case we'd need
-		// to go back to paletted mode
-		if (_decoder->loadFile(filename)) {
-			_decoder->start();
-			return true;
-		} else {
-			initGraphics(640, 480, true);
-			return false;
-		}
-	}
+	if (!_decoder->loadFile(filename)) {
+		// Go back to 8bpp color
+		if (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2)
+			initGraphics(g_system->getWidth(), g_system->getHeight(), true);
 
-	if (!_decoder->loadFile(filename))
 		return false;
+	}
 
-	// For DXA, also add the external sound file
-	if (_decoderType == kVideoDecoderDXA)
+	// For DXA/MP2, also add the external sound file
+	if (_decoderType == kVideoDecoderDXA || _decoderType == kVideoDecoderMP2)
 		_decoder->addStreamFileTrack(name);
 
 	_decoder->start();
@@ -136,10 +143,9 @@ void MoviePlayer::play(MovieText *movieTexts, uint32 numMovieTexts, uint32 leadI
 		_vm->_sound->stopSpeech();
 	}
 
-	if (_decoderType == kVideoDecoderPSX) {
-		// Need to jump back to paletted color
+	// Need to jump back to paletted color
+	if (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2)
 		initGraphics(640, 480, true);
-	}
 }
 
 void MoviePlayer::openTextObject(uint32 index) {
@@ -378,11 +384,11 @@ bool MoviePlayer::playVideo() {
 }
 
 uint32 MoviePlayer::getBlackColor() {
-	return (_decoderType == kVideoDecoderPSX) ? g_system->getScreenFormat().RGBToColor(0x00, 0x00, 0x00) : _black;
+	return (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2) ? g_system->getScreenFormat().RGBToColor(0x00, 0x00, 0x00) : _black;
 }
 
 uint32 MoviePlayer::getWhiteColor() {
-	return (_decoderType == kVideoDecoderPSX) ? g_system->getScreenFormat().RGBToColor(0xFF, 0xFF, 0xFF) : _white;
+	return (_decoderType == kVideoDecoderPSX || _decoderType == kVideoDecoderMP2) ? g_system->getScreenFormat().RGBToColor(0xFF, 0xFF, 0xFF) : _white;
 }
 
 void MoviePlayer::drawFramePSX(const Graphics::Surface *frame) {
@@ -446,9 +452,16 @@ MoviePlayer *makeMoviePlayer(const char *name, Sword2Engine *vm, OSystem *system
 	filename = Common::String::format("%s.mp2", name);
 
 	if (Common::File::exists(filename)) {
-		GUI::MessageDialog dialog(_("MPEG2 cutscenes are no longer supported"), _("OK"));
+#ifdef USE_MPEG2
+		// HACK: Old ScummVM builds ignored the AVI frame rate field and forced the video
+		// to be played back at 12fps.
+		Video::AVIDecoder *aviDecoder = new Video::AVIDecoder(12);
+		return new MoviePlayer(vm, system, aviDecoder, kVideoDecoderMP2);
+#else
+		GUI::MessageDialog dialog(_("MPEG-2 cutscenes found but ScummVM has been built without MPEG-2 support"), _("OK"));
 		dialog.runModal();
 		return NULL;
+#endif
 	}
 
 	// The demo tries to play some cutscenes that aren't there, so make those warnings more discreet.
diff --git a/engines/sword2/animation.h b/engines/sword2/animation.h
index b2a243b..8669bdc 100644
--- a/engines/sword2/animation.h
+++ b/engines/sword2/animation.h
@@ -40,7 +40,8 @@ namespace Sword2 {
 enum DecoderType {
 	kVideoDecoderDXA = 0,
 	kVideoDecoderSMK = 1,
-	kVideoDecoderPSX = 2
+	kVideoDecoderPSX = 2,
+	kVideoDecoderMP2 = 3
 };
 
 struct MovieText {


Commit: 1ff09c581b72c9bc6b71e7b6b6aa676f9af6cecf
    https://github.com/scummvm/scummvm/commit/1ff09c581b72c9bc6b71e7b6b6aa676f9af6cecf
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-06-20T16:56:39-07:00

Commit Message:
VIDEO: Mark AVIDecoder as being used by sword1/sword2

Changed paths:
    video/avi_decoder.h



diff --git a/video/avi_decoder.h b/video/avi_decoder.h
index 1652614..6082232 100644
--- a/video/avi_decoder.h
+++ b/video/avi_decoder.h
@@ -52,6 +52,8 @@ class Codec;
  *
  * Video decoder used in engines:
  *  - sci
+ *  - sword1
+ *  - sword2
  */
 class AVIDecoder : public VideoDecoder {
 public:


Commit: 4ed1bc3a57e0160eb0b395c2a363151700216d04
    https://github.com/scummvm/scummvm/commit/4ed1bc3a57e0160eb0b395c2a363151700216d04
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-07-01T18:33:10-07:00

Commit Message:
CONFIGURE: Make the libmpeg2 properly require 0.4.0

Changed paths:
    configure



diff --git a/configure b/configure
index 41d96fb..eedd83e 100755
--- a/configure
+++ b/configure
@@ -3474,7 +3474,7 @@ echo "$_zlib"
 #
 # Check for LibMPEG2
 #
-echocheck "libmpeg2 >= 0.3.2"
+echocheck "libmpeg2 >= 0.4.0"
 if test "$_mpeg2" = auto ; then
 	_mpeg2=no
 	cat > $TMPC << EOF
@@ -3486,16 +3486,19 @@ typedef unsigned $type_1_byte uint8_t;
 typedef unsigned $type_2_byte uint16_t;
 typedef unsigned $type_4_byte uint32_t;
 
+extern "C" {
 #include <mpeg2dec/mpeg2.h>
+}
+
 int main(void) {
+	#if MPEG2_RELEASE < MPEG2_VERSION(0, 4, 0)
+	#error libmpeg2 version too low
+	#endif
+
 	/* mpeg2_state_t first appears in 0.4.0 */
 	mpeg2_state_t state;
 
-		#ifdef MPEG2_RELEASE
-		if (MPEG2_RELEASE >= MPEG2_VERSION(0, 3, 2))
-			return 0;
-	#endif
-	return 1;
+	return 0;
 }
 EOF
 


Commit: 279c9f78412d9053a60b53b70b5e770159a2aa92
    https://github.com/scummvm/scummvm/commit/279c9f78412d9053a60b53b70b5e770159a2aa92
Author: clone2727 (clone2727 at gmail.com)
Date: 2013-07-05T15:28:06-07:00

Commit Message:
Merge pull request #343 from clone2727/mpeg2-avi

Add back support for sword1/2 MPEG-2 cutscenes

Changed paths:
  A video/codecs/mpeg.cpp
  A video/codecs/mpeg.h
    configure
    engines/sword1/animation.cpp
    engines/sword1/animation.h
    engines/sword2/animation.cpp
    engines/sword2/animation.h
    video/avi_decoder.cpp
    video/avi_decoder.h
    video/module.mk









More information about the Scummvm-git-logs mailing list