From 69a1e8ac3677a6f634264e16cf4d94be6c770c7b Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 28 Nov 2012 19:34:09 -0500 Subject: SWORD1: Add back MPEG-2 video support --- engines/sword1/animation.cpp | 56 +++++++++++++++++++++++++++----------------- engines/sword1/animation.h | 3 ++- 2 files changed, 36 insertions(+), 23 deletions(-) (limited to 'engines') diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index 206bd68b07..79ec060bc1 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 d0c61f5eb3..2c51a74f71 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 { -- cgit v1.2.3 From 15a4d52ef7c55d2c004979244ea6e823ac33fe18 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 28 Nov 2012 19:51:03 -0500 Subject: SWORD2: Add back MPEG-2 video support --- engines/sword2/animation.cpp | 55 +++++++++++++++++++++++++++----------------- engines/sword2/animation.h | 3 ++- 2 files changed, 36 insertions(+), 22 deletions(-) (limited to 'engines') diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp index 00260f789a..713120ad43 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 b2a243b2ca..8669bdc8d8 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 { -- cgit v1.2.3