aboutsummaryrefslogtreecommitdiff
path: root/graphics/video/avi_decoder.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2010-05-17 21:59:05 +0000
committerMatthew Hoops2010-05-17 21:59:05 +0000
commitc7fa1074fbc55e9e519f9c7e08dea9603af22e61 (patch)
tree502ce42530df3ea513eebf7096dfc72bf05a3dd7 /graphics/video/avi_decoder.cpp
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 'graphics/video/avi_decoder.cpp')
-rw-r--r--graphics/video/avi_decoder.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/graphics/video/avi_decoder.cpp b/graphics/video/avi_decoder.cpp
index fe5999328e..1e0fb389b3 100644
--- a/graphics/video/avi_decoder.cpp
+++ b/graphics/video/avi_decoder.cpp
@@ -213,8 +213,7 @@ bool AviDecoder::loadFile(const char *fileName) {
_decodedHeader = false;
// Seek to the first frame
- _videoInfo.currentFrame = 0;
-
+ _videoInfo.currentFrame = -1;
// Read chunks until we have decoded the header
while (!_decodedHeader)
@@ -379,14 +378,11 @@ Surface *AviDecoder::getNextFrame() {
}
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 @@ bool AviDecoder::decodeNextFrame() {
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 @@ int32 AviDecoder::getAudioLag() {
return 0;
int32 frameDelay = getFrameDelay();
- int32 videoTime = _videoInfo.currentFrame * frameDelay;
+ int32 videoTime = (_videoInfo.currentFrame + 1) * frameDelay;
int32 audioTime;
if (!_audStream) {