aboutsummaryrefslogtreecommitdiff
path: root/graphics/video
diff options
context:
space:
mode:
authorSven Hesse2010-08-08 00:56:29 +0000
committerSven Hesse2010-08-08 00:56:29 +0000
commitd081c2e20f5eb5c55de4aa6722b9ae1f57648425 (patch)
tree24675f909157e2f5d3e121f106f8d2b8ffaf0c81 /graphics/video
parent1f630094268a76fd73e7a1f01e725aef2aa61e8e (diff)
downloadscummvm-rg350-d081c2e20f5eb5c55de4aa6722b9ae1f57648425.tar.gz
scummvm-rg350-d081c2e20f5eb5c55de4aa6722b9ae1f57648425.tar.bz2
scummvm-rg350-d081c2e20f5eb5c55de4aa6722b9ae1f57648425.zip
VIDEO: Move the frame calculation out of seek()
svn-id: r51897
Diffstat (limited to 'graphics/video')
-rw-r--r--graphics/video/coktel_decoder.cpp73
-rw-r--r--graphics/video/coktel_decoder.h2
2 files changed, 27 insertions, 48 deletions
diff --git a/graphics/video/coktel_decoder.cpp b/graphics/video/coktel_decoder.cpp
index e79ea8c45d..414ea2c72b 100644
--- a/graphics/video/coktel_decoder.cpp
+++ b/graphics/video/coktel_decoder.cpp
@@ -47,6 +47,28 @@ CoktelDecoder::CoktelDecoder(Audio::Mixer &mixer, Audio::Mixer::SoundType soundT
CoktelDecoder::~CoktelDecoder() {
}
+bool CoktelDecoder::evaluateSeekFrame(int32 &frame, int whence) const {
+ if (!isVideoLoaded())
+ // Nothing to do
+ return false;
+
+ // Find the frame to which to seek
+ if (whence == SEEK_CUR)
+ frame += _curFrame;
+ else if (whence == SEEK_END)
+ frame = _frameCount - frame - 1;
+ else if (whence == SEEK_SET)
+ frame--;
+ else
+ return false;
+
+ if ((frame < -1) || (frame >= ((int32) _frameCount)))
+ // Out of range
+ return false;
+
+ return true;
+}
+
void CoktelDecoder::setSurfaceMemory(void *mem, uint16 width, uint16 height, uint8 bpp) {
freeSurface();
@@ -488,22 +510,7 @@ PreIMDDecoder::~PreIMDDecoder() {
}
bool PreIMDDecoder::seek(int32 frame, int whence, bool restart) {
- if (!isVideoLoaded())
- // Nothing to do
- return false;
-
- // Find the frame to which to seek
- if (whence == SEEK_CUR)
- frame += _curFrame;
- else if (whence == SEEK_END)
- frame = _frameCount - frame - 1;
- else if (whence == SEEK_SET)
- frame--;
- else
- return false;
-
- if ((frame < -1) || (((uint32) frame) >= _frameCount))
- // Out of range
+ if (!evaluateSeekFrame(frame, whence))
return false;
if (frame == _curFrame)
@@ -693,22 +700,7 @@ IMDDecoder::~IMDDecoder() {
}
bool IMDDecoder::seek(int32 frame, int whence, bool restart) {
- if (!isVideoLoaded())
- // Nothing to do
- return false;
-
- // Find the frame to which to seek
- if (whence == SEEK_CUR)
- frame += _curFrame;
- else if (whence == SEEK_END)
- frame = _frameCount - frame - 1;
- else if (whence == SEEK_SET)
- frame--;
- else
- return false;
-
- if ((frame < -1) || (frame >= ((int32) _frameCount)))
- // Out of range
+ if (!evaluateSeekFrame(frame, whence))
return false;
if (frame == _curFrame)
@@ -1325,22 +1317,7 @@ VMDDecoder::~VMDDecoder() {
}
bool VMDDecoder::seek(int32 frame, int whence, bool restart) {
- if (!isVideoLoaded())
- // Nothing to do
- return false;
-
- // Find the frame to which to seek
- if (whence == SEEK_CUR)
- frame += _curFrame;
- else if (whence == SEEK_END)
- frame = _frameCount - frame - 1;
- else if (whence == SEEK_SET)
- frame--;
- else
- return false;
-
- if ((frame < -1) || (((uint32) frame) >= _frameCount))
- // Out of range
+ if (!evaluateSeekFrame(frame, whence))
return false;
if (frame == _curFrame)
diff --git a/graphics/video/coktel_decoder.h b/graphics/video/coktel_decoder.h
index 435f289c2c..5b5c8f163a 100644
--- a/graphics/video/coktel_decoder.h
+++ b/graphics/video/coktel_decoder.h
@@ -171,6 +171,8 @@ protected:
Audio::QueuingAudioStream *_audioStream;
Audio::SoundHandle _audioHandle;
+ bool evaluateSeekFrame(int32 &frame, int whence) const;
+
// Surface management
bool hasSurface();
void createSurface();