[Scummvm-cvs-logs] SF.net SVN: scummvm:[49063] scummvm/trunk
mthreepwood at users.sourceforge.net
mthreepwood at users.sourceforge.net
Mon May 17 23:59:06 CEST 2010
Revision: 49063
http://scummvm.svn.sourceforge.net/scummvm/?rev=49063&view=rev
Author: mthreepwood
Date: 2010-05-17 21:59:05 +0000 (Mon, 17 May 2010)
Log Message:
-----------
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).
Modified Paths:
--------------
scummvm/trunk/engines/agos/animation.cpp
scummvm/trunk/engines/sci/video/seq_decoder.cpp
scummvm/trunk/engines/sci/video/vmd_decoder.cpp
scummvm/trunk/engines/scumm/he/animation_he.cpp
scummvm/trunk/engines/scumm/he/script_v100he.cpp
scummvm/trunk/engines/scumm/he/script_v90he.cpp
scummvm/trunk/engines/sword1/animation.cpp
scummvm/trunk/engines/sword2/animation.cpp
scummvm/trunk/graphics/video/avi_decoder.cpp
scummvm/trunk/graphics/video/dxa_decoder.cpp
scummvm/trunk/graphics/video/flic_decoder.cpp
scummvm/trunk/graphics/video/smk_decoder.cpp
scummvm/trunk/graphics/video/video_player.cpp
scummvm/trunk/graphics/video/video_player.h
Modified: scummvm/trunk/engines/agos/animation.cpp
===================================================================
--- scummvm/trunk/engines/agos/animation.cpp 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/engines/agos/animation.cpp 2010-05-17 21:59:05 UTC (rev 49063)
@@ -272,7 +272,7 @@
_vm->clearSurfaces();
}
- while (getCurFrame() < getFrameCount() && !_skipMovie && !_vm->shouldQuit())
+ while (!endOfVideo() && !_skipMovie && !_vm->shouldQuit())
handleNextFrame();
}
@@ -318,18 +318,18 @@
}
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 @@
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 @@
}
void MoviePlayerSMK::playVideo() {
- while (getCurFrame() < getFrameCount() && !_skipMovie && !_vm->shouldQuit())
+ while (!endOfVideo() && !_skipMovie && !_vm->shouldQuit())
handleNextFrame();
}
@@ -440,12 +440,12 @@
}
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);
Modified: scummvm/trunk/engines/sci/video/seq_decoder.cpp
===================================================================
--- scummvm/trunk/engines/sci/video/seq_decoder.cpp 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/engines/sci/video/seq_decoder.cpp 2010-05-17 21:59:05 UTC (rev 49063)
@@ -61,7 +61,7 @@
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 @@
_fileStream->seek(offset);
+ _videoInfo.currentFrame++;
+
if (_videoInfo.currentFrame == 0)
_videoInfo.startTime = g_system->getMillis();
@@ -151,7 +153,7 @@
delete[] buf;
}
- return ++_videoInfo.currentFrame < _videoInfo.frameCount;
+ return !endOfVideo();
}
#define WRITE_TO_BUFFER(n) \
Modified: scummvm/trunk/engines/sci/video/vmd_decoder.cpp
===================================================================
--- scummvm/trunk/engines/sci/video/vmd_decoder.cpp 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/engines/sci/video/vmd_decoder.cpp 2010-05-17 21:59:05 UTC (rev 49063)
@@ -75,7 +75,7 @@
_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 @@
}
bool VMDDecoder::decodeNextFrame() {
+ _videoInfo.currentFrame++;
+
if (_videoInfo.currentFrame == 0)
_videoInfo.startTime = g_system->getMillis();
@@ -113,7 +115,7 @@
setPalette(_palette);
}
- return ++_videoInfo.currentFrame < _videoInfo.frameCount;
+ return !endOfVideo();
}
void VMDDecoder::getPalette() {
Modified: scummvm/trunk/engines/scumm/he/animation_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/animation_he.cpp 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/engines/scumm/he/animation_he.cpp 2010-05-17 21:59:05 UTC (rev 49063)
@@ -128,9 +128,8 @@
_vm->markRectAsDirty(kMainVirtScreen, imageRect);
}
- if (getCurFrame() == getFrameCount()) {
+ if (endOfVideo())
closeFile();
- }
}
void MoviePlayer::setPalette(byte *pal) {
Modified: scummvm/trunk/engines/scumm/he/script_v100he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v100he.cpp 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/engines/scumm/he/script_v100he.cpp 2010-05-17 21:59:05 UTC (rev 49063)
@@ -2937,7 +2937,7 @@
break;
case 73:
pop();
- push(_moviePlay->getCurFrame());
+ push(_moviePlay->endOfVideo() ? -1 : (_moviePlay->getCurFrame() + 1));
break;
case 84:
pop();
Modified: scummvm/trunk/engines/scumm/he/script_v90he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v90he.cpp 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/engines/scumm/he/script_v90he.cpp 2010-05-17 21:59:05 UTC (rev 49063)
@@ -1464,7 +1464,7 @@
break;
case 52: // Get current frame
pop();
- push(_moviePlay->getCurFrame());
+ push(_moviePlay->endOfVideo() ? -1 : (_moviePlay->getCurFrame() + 1));
break;
case 63: // Get image number
pop();
Modified: scummvm/trunk/engines/sword1/animation.cpp
===================================================================
--- scummvm/trunk/engines/sword1/animation.cpp 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/engines/sword1/animation.cpp 2010-05-17 21:59:05 UTC (rev 49063)
@@ -179,7 +179,7 @@
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 @@
_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 @@
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);
Modified: scummvm/trunk/engines/sword2/animation.cpp
===================================================================
--- scummvm/trunk/engines/sword2/animation.cpp 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/engines/sword2/animation.cpp 2010-05-17 21:59:05 UTC (rev 49063)
@@ -240,7 +240,7 @@
void MoviePlayer::performPostProcessing(byte *screen) {
MovieText *text;
- int frame = _decoder->getCurFrame();
+ int frame = _decoder->getCurFrame() + 1;
if (_currentMovieText < _numMovieTexts) {
text = &_movieTexts[_currentMovieText];
Modified: scummvm/trunk/graphics/video/avi_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/avi_decoder.cpp 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/graphics/video/avi_decoder.cpp 2010-05-17 21:59:05 UTC (rev 49063)
@@ -213,9 +213,8 @@
_decodedHeader = false;
// Seek to the first frame
- _videoInfo.currentFrame = 0;
+ _videoInfo.currentFrame = -1;
-
// Read chunks until we have decoded the header
while (!_decodedHeader)
runHandle(_fileStream->readUint32BE());
@@ -379,14 +378,11 @@
}
bool AviDecoder::decodeNextFrame() {
- if (_videoInfo.currentFrame == 0)
- _videoInfo.startTime = g_system->getMillis();
-
Surface *surface = NULL;
- uint32 curFrame = _videoInfo.currentFrame;
+ int32 curFrame = _videoInfo.currentFrame;
- while (!surface && _videoInfo.currentFrame < _videoInfo.frameCount && !_fileStream->eos())
+ while (!surface && !endOfVideo() && !_fileStream->eos())
surface = getNextFrame();
if (curFrame == _videoInfo.currentFrame) {
@@ -397,7 +393,10 @@
if (surface)
memcpy(_videoFrameBuffer, surface->pixels, _header.width * _header.height);
- return _videoInfo.currentFrame < _videoInfo.frameCount;
+ if (_videoInfo.currentFrame == 0)
+ _videoInfo.startTime = g_system->getMillis();
+
+ return !endOfVideo();
}
int32 AviDecoder::getAudioLag() {
@@ -405,7 +404,7 @@
return 0;
int32 frameDelay = getFrameDelay();
- int32 videoTime = _videoInfo.currentFrame * frameDelay;
+ int32 videoTime = (_videoInfo.currentFrame + 1) * frameDelay;
int32 audioTime;
if (!_audStream) {
Modified: scummvm/trunk/graphics/video/dxa_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/dxa_decoder.cpp 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/graphics/video/dxa_decoder.cpp 2010-05-17 21:59:05 UTC (rev 49063)
@@ -56,7 +56,7 @@
_frameSize = 0;
_videoInfo.frameCount = 0;
- _videoInfo.currentFrame = 0;
+ _videoInfo.currentFrame = -1;
_videoInfo.frameRate = 0;
_videoInfo.frameDelay = 0;
@@ -159,7 +159,7 @@
// Read the sound header
_soundTag = _fileStream->readUint32BE();
- _videoInfo.currentFrame = 0;
+ _videoInfo.currentFrame = -1;
_videoInfo.firstframeOffset = _fileStream->pos();
@@ -484,6 +484,8 @@
bool DXADecoder::decodeNextFrame() {
uint32 tag;
+ _videoInfo.currentFrame++;
+
if (_videoInfo.currentFrame == 0)
_videoInfo.startTime = g_system->getMillis();
@@ -557,7 +559,7 @@
break;
}
- return ++_videoInfo.currentFrame < _videoInfo.frameCount;
+ return !endOfVideo();
}
} // End of namespace Graphics
Modified: scummvm/trunk/graphics/video/flic_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/flic_decoder.cpp 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/graphics/video/flic_decoder.cpp 2010-05-17 21:59:05 UTC (rev 49063)
@@ -86,7 +86,7 @@
_paletteChanged = false;
// Seek to the first frame
- _videoInfo.currentFrame = 0;
+ _videoInfo.currentFrame = -1;
_fileStream->seek(_offsetFrame1);
return true;
}
@@ -195,9 +195,6 @@
#define FRAME_TYPE 0xF1FA
bool FlicDecoder::decodeNextFrame() {
- if (_videoInfo.currentFrame == 0)
- _videoInfo.startTime = g_system->getMillis();
-
// Read chunk
uint32 frameSize = _fileStream->readUint32LE();
uint16 frameType = _fileStream->readUint16LE();
@@ -222,6 +219,9 @@
_videoInfo.height = newHeight;
_videoInfo.currentFrame++;
+
+ if (_videoInfo.currentFrame == 0)
+ _videoInfo.startTime = g_system->getMillis();
}
break;
default:
@@ -261,12 +261,12 @@
}
// If we just processed the ring frame, set the next frame
- if (_videoInfo.currentFrame == _videoInfo.frameCount + 1) {
+ if (_videoInfo.currentFrame == (int32)_videoInfo.frameCount + 1) {
_videoInfo.currentFrame = 1;
_fileStream->seek(_offsetFrame2);
}
- return _videoInfo.currentFrame < _videoInfo.frameCount;
+ return !endOfVideo();
}
void FlicDecoder::reset() {
Modified: scummvm/trunk/graphics/video/smk_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/smk_decoder.cpp 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/graphics/video/smk_decoder.cpp 2010-05-17 21:59:05 UTC (rev 49063)
@@ -368,7 +368,7 @@
return 0;
int32 frameDelay = getFrameDelay();
- int32 videoTime = _videoInfo.currentFrame * frameDelay;
+ int32 videoTime = (_videoInfo.currentFrame + 1) * frameDelay;
int32 audioTime;
if (!_audioStream) {
@@ -396,7 +396,7 @@
return false;
// Seek to the first frame
- _videoInfo.currentFrame = 0;
+ _videoInfo.currentFrame = -1;
_header.signature = _fileStream->readUint32BE();
// No BINK support available
@@ -535,6 +535,8 @@
uint32 startPos = _fileStream->pos();
+ _videoInfo.currentFrame++;
+
if (_videoInfo.currentFrame == 0)
_videoInfo.startTime = g_system->getMillis();
@@ -749,7 +751,7 @@
free(_frameData);
- return ++_videoInfo.currentFrame < _videoInfo.frameCount;
+ return !endOfVideo();
}
void SmackerDecoder::queueCompressedBuffer(byte *buffer, uint32 bufferSize,
Modified: scummvm/trunk/graphics/video/video_player.cpp
===================================================================
--- scummvm/trunk/graphics/video/video_player.cpp 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/graphics/video/video_player.cpp 2010-05-17 21:59:05 UTC (rev 49063)
@@ -39,6 +39,7 @@
VideoDecoder::VideoDecoder() : _fileStream(0) {
_curFrameBlack = 0;
_curFrameWhite = 255;
+ _videoInfo.currentFrame = -1;
}
VideoDecoder::~VideoDecoder() {
@@ -56,13 +57,11 @@
return _videoInfo.height;
}
-int32 VideoDecoder::getCurFrame() {
- if (!_fileStream)
- return -1;
+int32 VideoDecoder::getCurFrame() const {
return _videoInfo.currentFrame;
}
-int32 VideoDecoder::getFrameCount() {
+int32 VideoDecoder::getFrameCount() const {
if (!_fileStream)
return 0;
return _videoInfo.frameCount;
@@ -152,7 +151,11 @@
g_system->setPalette(videoPalette, 0, 256);
}
+bool VideoDecoder::endOfVideo() const {
+ return !isVideoLoaded() || getCurFrame() >= (int32)getFrameCount() - 1;
+}
+
/*
* VideoPlayer
*/
@@ -192,7 +195,7 @@
int frameX = (g_system->getWidth() - _decoder->getWidth()) / 2;
int frameY = (g_system->getHeight() - _decoder->getHeight()) / 2;
- while (_decoder->getCurFrame() < _decoder->getFrameCount() && !_skipVideo) {
+ while (!_decoder->endOfVideo() && !_skipVideo) {
processVideoEvents(stopEvents);
uint32 startTime = 0;
Modified: scummvm/trunk/graphics/video/video_player.h
===================================================================
--- scummvm/trunk/graphics/video/video_player.h 2010-05-17 20:57:36 UTC (rev 49062)
+++ scummvm/trunk/graphics/video/video_player.h 2010-05-17 21:59:05 UTC (rev 49063)
@@ -60,13 +60,13 @@
* Returns the current frame number of the video
* @return the current frame number of the video
*/
- virtual int32 getCurFrame();
+ virtual int32 getCurFrame() const;
/**
* Returns the amount of frames in the video
* @return the amount of frames in the video
*/
- virtual int32 getFrameCount();
+ virtual int32 getFrameCount() const;
/**
* Returns the frame rate of the video
@@ -108,7 +108,7 @@
/**
* Returns if a video file is loaded or not
*/
- bool isVideoLoaded() { return (_fileStream != NULL); }
+ bool isVideoLoaded() const { return (_fileStream != NULL); }
/**
* Set RGB palette, based on current frame
@@ -158,6 +158,11 @@
*/
virtual bool decodeNextFrame() = 0;
+ /**
+ * Returns if the video is finished or not
+ */
+ virtual bool endOfVideo() const;
+
protected:
struct {
uint32 width;
@@ -166,7 +171,7 @@
int32 frameRate;
int32 frameDelay; // 1/100 ms (to avoid rounding errors)
uint32 firstframeOffset;
- uint32 currentFrame;
+ int32 currentFrame;
uint32 startTime;
} _videoInfo;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list