aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorColin Snover2017-10-04 13:23:44 -0500
committerColin Snover2017-12-01 18:48:35 -0600
commit57db3f7535458504f308ea76e87167cf7ee95371 (patch)
treec73da99294cebdd56e47bda374c626b94525eeee /engines/sci/engine
parentf9f5692e0388e06af5c51d2937f07f28175652c2 (diff)
downloadscummvm-rg350-57db3f7535458504f308ea76e87167cf7ee95371.tar.gz
scummvm-rg350-57db3f7535458504f308ea76e87167cf7ee95371.tar.bz2
scummvm-rg350-57db3f7535458504f308ea76e87167cf7ee95371.zip
SCI: Partially clean up SCI16 video playback code
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/kvideo.cpp72
-rw-r--r--engines/sci/engine/state.cpp2
-rw-r--r--engines/sci/engine/state.h15
3 files changed, 24 insertions, 65 deletions
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.
*/