diff options
-rw-r--r-- | engines/sci/console.cpp | 52 | ||||
-rw-r--r-- | engines/sci/engine/kvideo.cpp | 72 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/state.h | 15 |
4 files changed, 31 insertions, 110 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 28ed12275f..42a87ce44e 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -265,60 +265,23 @@ void Console::preEnter() { _engine->pauseEngine(true); } -extern void playVideo(Video::VideoDecoder *videoDecoder, VideoState videoState); +extern void playVideo(Video::VideoDecoder &videoDecoder); void Console::postEnter() { if (!_videoFile.empty()) { - Video::VideoDecoder *videoDecoder = 0; - -#ifdef ENABLE_SCI32 - bool duckMode = false; -#endif + Common::ScopedPtr<Video::VideoDecoder> videoDecoder; if (_videoFile.hasSuffix(".seq")) { - videoDecoder = new SEQDecoder(_videoFrameDelay); -#ifdef ENABLE_SCI32 - } else if (_videoFile.hasSuffix(".vmd")) { - videoDecoder = new Video::AdvancedVMDDecoder(); - } else if (_videoFile.hasSuffix(".duk")) { - duckMode = true; - videoDecoder = new Video::AVIDecoder(); -#endif + videoDecoder.reset(new SEQDecoder(_videoFrameDelay)); } else if (_videoFile.hasSuffix(".avi")) { - videoDecoder = new Video::AVIDecoder(); + videoDecoder.reset(new Video::AVIDecoder()); } else { warning("Unrecognized video type"); } if (videoDecoder && videoDecoder->loadFile(_videoFile)) { _engine->_gfxCursor->kernelHide(); - -#ifdef ENABLE_SCI32 - // Duck videos are 16bpp, so we need to change pixel formats - int oldWidth = g_system->getWidth(); - int oldHeight = g_system->getHeight(); - if (duckMode) { - Common::List<Graphics::PixelFormat> formats; - formats.push_back(videoDecoder->getPixelFormat()); - initGraphics(640, 480, formats); - - if (g_system->getScreenFormat().bytesPerPixel != videoDecoder->getPixelFormat().bytesPerPixel) - error("Could not switch screen format for the duck video"); - } -#endif - - VideoState emptyState; - emptyState.reset(); - emptyState.fileName = _videoFile; - emptyState.flags = kDoubled; // always allow the videos to be double sized - playVideo(videoDecoder, emptyState); - -#ifdef ENABLE_SCI32 - // Switch back to 8bpp if we played a duck video - if (duckMode) - initGraphics(oldWidth, oldHeight); -#endif - + playVideo(*videoDecoder); _engine->_gfxCursor->kernelShow(); } else warning("Could not play video %s\n", _videoFile.c_str()); @@ -2045,7 +2008,7 @@ bool Console::cmdPicVisualize(int argc, const char **argv) { bool Console::cmdPlayVideo(int argc, const char **argv) { if (argc < 2) { - debugPrintf("Plays a SEQ, AVI, VMD, RBT or DUK video.\n"); + debugPrintf("Plays a SEQ or AVI video.\n"); debugPrintf("Usage: %s <video file name> <delay>\n", argv[0]); debugPrintf("The video file name should include the extension\n"); debugPrintf("Delay is only used in SEQ videos and is measured in ticks (default: 10)\n"); @@ -2055,8 +2018,7 @@ bool Console::cmdPlayVideo(int argc, const char **argv) { Common::String filename = argv[1]; filename.toLowercase(); - if (filename.hasSuffix(".seq") || filename.hasSuffix(".avi") || filename.hasSuffix(".vmd") || - filename.hasSuffix(".rbt") || filename.hasSuffix(".duk")) { + if (filename.hasSuffix(".seq") || filename.hasSuffix(".avi")) { _videoFile = filename; _videoFrameDelay = (argc == 2) ? 10 : atoi(argv[2]); return cmdExit(0, 0); diff --git a/engines/sci/engine/kvideo.cpp b/engines/sci/engine/kvideo.cpp index 5851b015aa..03ed698f17 100644 --- a/engines/sci/engine/kvideo.cpp +++ b/engines/sci/engine/kvideo.cpp @@ -50,17 +50,14 @@ namespace Sci { -void playVideo(Video::VideoDecoder *videoDecoder, VideoState videoState) { - if (!videoDecoder) - return; - - videoDecoder->start(); +void playVideo(Video::VideoDecoder &videoDecoder) { + videoDecoder.start(); Common::SpanOwner<SciSpan<byte> > scaleBuffer; - byte bytesPerPixel = videoDecoder->getPixelFormat().bytesPerPixel; - uint16 width = videoDecoder->getWidth(); - uint16 height = videoDecoder->getHeight(); - uint16 pitch = videoDecoder->getWidth() * bytesPerPixel; + byte bytesPerPixel = videoDecoder.getPixelFormat().bytesPerPixel; + uint16 width = videoDecoder.getWidth(); + uint16 height = videoDecoder.getHeight(); + uint16 pitch = videoDecoder.getWidth() * bytesPerPixel; uint16 screenWidth = g_sci->_gfxScreen->getDisplayWidth(); uint16 screenHeight = g_sci->_gfxScreen->getDisplayHeight(); uint32 numPixels; @@ -70,7 +67,7 @@ void playVideo(Video::VideoDecoder *videoDecoder, VideoState videoState) { height *= 2; pitch *= 2; numPixels = width * height * bytesPerPixel; - scaleBuffer->allocate(numPixels, videoState.fileName + " scale buffer"); + scaleBuffer->allocate(numPixels, "video scale buffer"); } uint16 x = (screenWidth - width) / 2; @@ -78,27 +75,27 @@ void playVideo(Video::VideoDecoder *videoDecoder, VideoState videoState) { bool skipVideo = false; - if (videoDecoder->hasDirtyPalette()) { - const byte *palette = videoDecoder->getPalette(); + if (videoDecoder.hasDirtyPalette()) { + const byte *palette = videoDecoder.getPalette(); g_system->getPaletteManager()->setPalette(palette, 0, 255); } - while (!g_engine->shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) { - if (videoDecoder->needsUpdate()) { - const Graphics::Surface *frame = videoDecoder->decodeNextFrame(); + while (!g_engine->shouldQuit() && !videoDecoder.endOfVideo() && !skipVideo) { + if (videoDecoder.needsUpdate()) { + const Graphics::Surface *frame = videoDecoder.decodeNextFrame(); if (frame) { if (scaleBuffer) { const SciSpan<const byte> input((const byte *)frame->getPixels(), frame->w * frame->h * bytesPerPixel); // TODO: Probably should do aspect ratio correction in KQ6 - g_sci->_gfxScreen->scale2x(input, *scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel); + g_sci->_gfxScreen->scale2x(input, *scaleBuffer, videoDecoder.getWidth(), videoDecoder.getHeight(), bytesPerPixel); g_system->copyRectToScreen(scaleBuffer->getUnsafeDataAt(0, pitch * height), pitch, x, y, width, height); } else { g_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, width, height); } - if (videoDecoder->hasDirtyPalette()) { - const byte *palette = videoDecoder->getPalette(); + if (videoDecoder.hasDirtyPalette()) { + const byte *palette = videoDecoder.getPalette(); g_system->getPaletteManager()->setPalette(palette, 0, 255); } @@ -116,8 +113,6 @@ void playVideo(Video::VideoDecoder *videoDecoder, VideoState videoState) { g_system->delayMillis(10); } - - delete videoDecoder; } reg_t kShowMovie(EngineState *s, int argc, reg_t *argv) { @@ -130,9 +125,9 @@ reg_t kShowMovie(EngineState *s, int argc, reg_t *argv) { uint16 screenWidth = g_system->getWidth(); uint16 screenHeight = g_system->getHeight(); - Video::VideoDecoder *videoDecoder = 0; + Common::ScopedPtr<Video::VideoDecoder> videoDecoder; - if (argv[0].getSegment() != 0) { + if (argv[0].isPointer()) { Common::String filename = s->_segMan->getString(argv[0]); if (g_sci->getPlatform() == Common::kPlatformMacintosh) { @@ -147,19 +142,18 @@ reg_t kShowMovie(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } - videoDecoder = new Video::QuickTimeDecoder(); + videoDecoder.reset(new Video::QuickTimeDecoder()); if (!videoDecoder->loadFile(filename)) error("Could not open '%s'", filename.c_str()); } else { // DOS SEQ // SEQ's are called with no subops, just the string and delay // Time is specified as ticks - videoDecoder = new SEQDecoder(argv[1].toUint16()); + videoDecoder.reset(new SEQDecoder(argv[1].toUint16())); if (!videoDecoder->loadFile(filename)) { warning("Failed to open movie file %s", filename.c_str()); - delete videoDecoder; - videoDecoder = 0; + videoDecoder.reset(); } } } else { @@ -170,28 +164,10 @@ reg_t kShowMovie(EngineState *s, int argc, reg_t *argv) { switch (argv[0].toUint16()) { case 0: { Common::String filename = s->_segMan->getString(argv[1]); - - if (filename.equalsIgnoreCase("gk2a.avi")) { - // HACK: Switch to 16bpp graphics for Indeo3. - // The only known movie to do use this codec is the GK2 demo trailer - // If another video turns up that uses Indeo, we may have to add a better - // check. - initGraphics(screenWidth, screenHeight, nullptr); - - if (g_system->getScreenFormat().bytesPerPixel == 1) { - warning("This video requires >8bpp color to be displayed, but could not switch to RGB color mode"); - return NULL_REG; - } - } - - videoDecoder = new Video::AVIDecoder(); - + videoDecoder.reset(new Video::AVIDecoder()); if (!videoDecoder->loadFile(filename.c_str())) { warning("Failed to open movie file %s", filename.c_str()); - delete videoDecoder; - videoDecoder = 0; - } else { - s->_videoState.fileName = filename; + videoDecoder.reset(); } break; } @@ -201,13 +177,13 @@ reg_t kShowMovie(EngineState *s, int argc, reg_t *argv) { } if (videoDecoder) { - playVideo(videoDecoder, s->_videoState); + playVideo(*videoDecoder); // HACK: Switch back to 8bpp if we played a true color video. // We also won't be copying the screen to the SCI screen... if (g_system->getScreenFormat().bytesPerPixel != 1) initGraphics(screenWidth, screenHeight); - else if (getSciVersion() < SCI_VERSION_2) { + else { g_sci->_gfxScreen->kernelSyncWithFramebuffer(); g_sci->_gfxPalette16->kernelSyncScreenPalette(); } diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index 343a9496b3..f1c656688c 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -117,8 +117,6 @@ void EngineState::reset(bool isRestoring) { scriptStepCounter = 0; scriptGCInterval = GC_INTERVAL; - - _videoState.reset(); } void EngineState::speedThrottler(uint32 neededSleep) { diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index 21c9a1fe9a..a299d89446 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -83,18 +83,6 @@ enum VideoFlags { kStretch = 1 << 8 }; -struct VideoState { - Common::String fileName; - uint16 x; - uint16 y; - uint16 flags; - - void reset() { - fileName = ""; - x = y = flags = 0; - } -}; - /** * Trace information about a VM function call. */ @@ -212,9 +200,6 @@ public: uint16 _memorySegmentSize; byte _memorySegment[kMemorySegmentMax]; - // TODO: Excise video code from the state manager - VideoState _videoState; - /** * Resets the engine state. */ |