aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMatthew Hoops2010-05-17 21:59:05 +0000
committerMatthew Hoops2010-05-17 21:59:05 +0000
commitc7fa1074fbc55e9e519f9c7e08dea9603af22e61 (patch)
tree502ce42530df3ea513eebf7096dfc72bf05a3dd7 /engines
parentea84abf5880f0af2642dd3de08a6d9c6f7f88426 (diff)
downloadscummvm-rg350-c7fa1074fbc55e9e519f9c7e08dea9603af22e61.tar.gz
scummvm-rg350-c7fa1074fbc55e9e519f9c7e08dea9603af22e61.tar.bz2
scummvm-rg350-c7fa1074fbc55e9e519f9c7e08dea9603af22e61.zip
Change VideoDecoder::getCurFrame() to mean the last frame drawn instead of the next frame to draw. This is patch 1 from patch #2963496 (VideoDecoder Rewrite).
svn-id: r49063
Diffstat (limited to 'engines')
-rw-r--r--engines/agos/animation.cpp22
-rw-r--r--engines/sci/video/seq_decoder.cpp6
-rw-r--r--engines/sci/video/vmd_decoder.cpp6
-rw-r--r--engines/scumm/he/animation_he.cpp3
-rw-r--r--engines/scumm/he/script_v100he.cpp2
-rw-r--r--engines/scumm/he/script_v90he.cpp2
-rw-r--r--engines/sword1/animation.cpp6
-rw-r--r--engines/sword2/animation.cpp2
8 files changed, 26 insertions, 23 deletions
diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp
index 8155bfb8d9..eccb51c732 100644
--- a/engines/agos/animation.cpp
+++ b/engines/agos/animation.cpp
@@ -272,7 +272,7 @@ void MoviePlayerDXA::playVideo() {
_vm->clearSurfaces();
}
- while (getCurFrame() < getFrameCount() && !_skipMovie && !_vm->shouldQuit())
+ while (!endOfVideo() && !_skipMovie && !_vm->shouldQuit())
handleNextFrame();
}
@@ -318,18 +318,18 @@ void MoviePlayerDXA::startSound() {
}
void MoviePlayerDXA::nextFrame() {
- if (_bgSoundStream && _vm->_mixer->isSoundHandleActive(_bgSound) && (_vm->_mixer->getSoundElapsedTime(_bgSound) * getFrameRate()) / 1000 < (uint32)getCurFrame()) {
+ if (_bgSoundStream && _vm->_mixer->isSoundHandleActive(_bgSound) && (_vm->_mixer->getSoundElapsedTime(_bgSound) * getFrameRate()) / 1000 <= (uint32)getCurFrame()) {
copyFrameToBuffer(_vm->getBackBuf(), 465, 222, _vm->_screenWidth);
return;
}
- if (_vm->_interactiveVideo == TYPE_LOOPING && getCurFrame() == getFrameCount()) {
+ if (_vm->_interactiveVideo == TYPE_LOOPING && endOfVideo()) {
_fileStream->seek(_videoInfo.firstframeOffset);
- _videoInfo.currentFrame = 0;
+ _videoInfo.currentFrame = -1;
startSound();
}
- if (getCurFrame() < getFrameCount()) {
+ if (!endOfVideo()) {
decodeNextFrame();
if (_vm->_interactiveVideo == TYPE_OMNITV) {
copyFrameToBuffer(_vm->getBackBuf(), 465, 222, _vm->_screenWidth);
@@ -370,10 +370,10 @@ bool MoviePlayerDXA::processFrame() {
copyFrameToBuffer((byte *)screen->pixels, (_vm->_screenWidth - getWidth()) / 2, (_vm->_screenHeight - getHeight()) / 2, _vm->_screenWidth);
_vm->_system->unlockScreen();
- if ((_bgSoundStream == NULL) || ((int)(_mixer->getSoundElapsedTime(_bgSound) * getFrameRate()) / 1000 < getCurFrame() + 1)) {
+ if ((_bgSoundStream == NULL) || ((int)(_mixer->getSoundElapsedTime(_bgSound) * getFrameRate()) / 1000 <= getCurFrame())) {
if (_bgSoundStream && _mixer->isSoundHandleActive(_bgSound)) {
- while (_mixer->isSoundHandleActive(_bgSound) && (_mixer->getSoundElapsedTime(_bgSound) * getFrameRate()) / 1000 < (uint32)getCurFrame()) {
+ while (_mixer->isSoundHandleActive(_bgSound) && (_mixer->getSoundElapsedTime(_bgSound) * getFrameRate()) / 1000 <= (uint32)getCurFrame()) {
_vm->_system->delayMillis(10);
}
// In case the background sound ends prematurely, update
@@ -421,7 +421,7 @@ bool MoviePlayerSMK::load() {
}
void MoviePlayerSMK::playVideo() {
- while (getCurFrame() < getFrameCount() && !_skipMovie && !_vm->shouldQuit())
+ while (!endOfVideo() && !_skipMovie && !_vm->shouldQuit())
handleNextFrame();
}
@@ -440,12 +440,12 @@ void MoviePlayerSMK::handleNextFrame() {
}
void MoviePlayerSMK::nextFrame() {
- if (_vm->_interactiveVideo == TYPE_LOOPING && getCurFrame() == getFrameCount()) {
+ if (_vm->_interactiveVideo == TYPE_LOOPING && endOfVideo()) {
_fileStream->seek(_videoInfo.firstframeOffset);
- _videoInfo.currentFrame = 0;
+ _videoInfo.currentFrame = -1;
}
- if (getCurFrame() < getFrameCount()) {
+ if (!endOfVideo()) {
decodeNextFrame();
if (_vm->_interactiveVideo == TYPE_OMNITV) {
copyFrameToBuffer(_vm->getBackBuf(), 465, 222, _vm->_screenWidth);
diff --git a/engines/sci/video/seq_decoder.cpp b/engines/sci/video/seq_decoder.cpp
index ef2622704d..ccce873a15 100644
--- a/engines/sci/video/seq_decoder.cpp
+++ b/engines/sci/video/seq_decoder.cpp
@@ -61,7 +61,7 @@ bool SeqDecoder::loadFile(const char *fileName, int frameDelay) {
return false;
// Seek to the first frame
- _videoInfo.currentFrame = 0;
+ _videoInfo.currentFrame = -1;
_videoInfo.width = SCREEN_WIDTH;
_videoInfo.height = SCREEN_HEIGHT;
@@ -129,6 +129,8 @@ bool SeqDecoder::decodeNextFrame() {
_fileStream->seek(offset);
+ _videoInfo.currentFrame++;
+
if (_videoInfo.currentFrame == 0)
_videoInfo.startTime = g_system->getMillis();
@@ -151,7 +153,7 @@ bool SeqDecoder::decodeNextFrame() {
delete[] buf;
}
- return ++_videoInfo.currentFrame < _videoInfo.frameCount;
+ return !endOfVideo();
}
#define WRITE_TO_BUFFER(n) \
diff --git a/engines/sci/video/vmd_decoder.cpp b/engines/sci/video/vmd_decoder.cpp
index 4e56e51054..9e95521ebb 100644
--- a/engines/sci/video/vmd_decoder.cpp
+++ b/engines/sci/video/vmd_decoder.cpp
@@ -75,7 +75,7 @@ bool VMDDecoder::loadFile(const char *fileName) {
_videoInfo.frameCount = _vmdDecoder->getFramesCount();
_videoInfo.frameRate = _vmdDecoder->getFrameRate();
_videoInfo.frameDelay = _videoInfo.frameRate * 100;
- _videoInfo.currentFrame = 0;
+ _videoInfo.currentFrame = -1;
_videoInfo.firstframeOffset = 0; // not really necessary for VMDs
if (_vmdDecoder->hasExtraData())
@@ -103,6 +103,8 @@ void VMDDecoder::closeFile() {
}
bool VMDDecoder::decodeNextFrame() {
+ _videoInfo.currentFrame++;
+
if (_videoInfo.currentFrame == 0)
_videoInfo.startTime = g_system->getMillis();
@@ -113,7 +115,7 @@ bool VMDDecoder::decodeNextFrame() {
setPalette(_palette);
}
- return ++_videoInfo.currentFrame < _videoInfo.frameCount;
+ return !endOfVideo();
}
void VMDDecoder::getPalette() {
diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp
index 11d7e87f34..5bd60d32e3 100644
--- a/engines/scumm/he/animation_he.cpp
+++ b/engines/scumm/he/animation_he.cpp
@@ -128,9 +128,8 @@ void MoviePlayer::handleNextFrame() {
_vm->markRectAsDirty(kMainVirtScreen, imageRect);
}
- if (getCurFrame() == getFrameCount()) {
+ if (endOfVideo())
closeFile();
- }
}
void MoviePlayer::setPalette(byte *pal) {
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index b304454e19..e32409fe85 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -2937,7 +2937,7 @@ void ScummEngine_v100he::o100_getVideoData() {
break;
case 73:
pop();
- push(_moviePlay->getCurFrame());
+ push(_moviePlay->endOfVideo() ? -1 : (_moviePlay->getCurFrame() + 1));
break;
case 84:
pop();
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index cff34412bd..091bf5027b 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -1464,7 +1464,7 @@ void ScummEngine_v90he::o90_getVideoData() {
break;
case 52: // Get current frame
pop();
- push(_moviePlay->getCurFrame());
+ push(_moviePlay->endOfVideo() ? -1 : (_moviePlay->getCurFrame() + 1));
break;
case 63: // Get image number
pop();
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp
index 1c1f6dcf4e..221a20ba45 100644
--- a/engines/sword1/animation.cpp
+++ b/engines/sword1/animation.cpp
@@ -179,7 +179,7 @@ void MoviePlayer::play() {
void MoviePlayer::performPostProcessing(byte *screen) {
if (!_movieTexts.empty()) {
- if (_decoder->getCurFrame() == _movieTexts[0]->_startFrame) {
+ if (_decoder->getCurFrame() + 1 == _movieTexts[0]->_startFrame) {
_textMan->makeTextSprite(2, (uint8 *)_movieTexts[0]->_text, 600, LETTER_COL);
FrameHeader *frame = _textMan->giveSpriteData(2);
@@ -188,7 +188,7 @@ void MoviePlayer::performPostProcessing(byte *screen) {
_textX = 320 - _textWidth / 2;
_textY = 420 - _textHeight;
}
- if (_decoder->getCurFrame() == _movieTexts[0]->_endFrame) {
+ if (_decoder->getCurFrame() + 1 == _movieTexts[0]->_endFrame) {
_textMan->releaseText(2, false);
delete _movieTexts.remove_at(0);
}
@@ -256,7 +256,7 @@ int32 DXADecoderWithSound::getAudioLag() {
return 0;
int32 frameDelay = getFrameDelay();
- int32 videoTime = _videoInfo.currentFrame * frameDelay;
+ int32 videoTime = (_videoInfo.currentFrame + 1) * frameDelay;
int32 audioTime;
const Audio::Timestamp ts = _mixer->getElapsedTime(*_bgSoundHandle);
diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp
index 6c13f03f00..1c5c2e5f8c 100644
--- a/engines/sword2/animation.cpp
+++ b/engines/sword2/animation.cpp
@@ -240,7 +240,7 @@ void MoviePlayer::drawTextObject(uint32 index, byte *screen) {
void MoviePlayer::performPostProcessing(byte *screen) {
MovieText *text;
- int frame = _decoder->getCurFrame();
+ int frame = _decoder->getCurFrame() + 1;
if (_currentMovieText < _numMovieTexts) {
text = &_movieTexts[_currentMovieText];