diff options
author | Matthew Hoops | 2011-01-11 17:27:31 +0000 |
---|---|---|
committer | Matthew Hoops | 2011-01-11 17:27:31 +0000 |
commit | 3bb5a9fe719a666fe85300831e570e6b375d612e (patch) | |
tree | b47c75678dc3f6920b158d982b0a6599954f8f10 /graphics | |
parent | 0089d3b338819ca28ba9100ba61d344be86057b3 (diff) | |
download | scummvm-rg350-3bb5a9fe719a666fe85300831e570e6b375d612e.tar.gz scummvm-rg350-3bb5a9fe719a666fe85300831e570e6b375d612e.tar.bz2 scummvm-rg350-3bb5a9fe719a666fe85300831e570e6b375d612e.zip |
VIDEO: Add a SeekableVideoDecoder class
svn-id: r55202
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/video/video_decoder.cpp | 12 | ||||
-rw-r--r-- | graphics/video/video_decoder.h | 72 |
2 files changed, 81 insertions, 3 deletions
diff --git a/graphics/video/video_decoder.cpp b/graphics/video/video_decoder.cpp index da3aae2821..d1d3445c38 100644 --- a/graphics/video/video_decoder.cpp +++ b/graphics/video/video_decoder.cpp @@ -121,4 +121,16 @@ uint32 FixedRateVideoDecoder::getFrameBeginTime(uint32 frame) const { return beginTime.toInt(); } +VideoTimestamp::VideoTimestamp() : _units(0), _scale(1) { +} + +VideoTimestamp::VideoTimestamp(uint units, uint scale) : _units(units), _scale(scale) { + assert(_scale); +} + +uint VideoTimestamp::getUnitsInScale(uint scale) const { + assert(scale); + return (_scale == scale) ? _units : _units * scale / _scale; +} + } // End of namespace Graphics diff --git a/graphics/video/video_decoder.h b/graphics/video/video_decoder.h index 437d7a41d6..3d24572818 100644 --- a/graphics/video/video_decoder.h +++ b/graphics/video/video_decoder.h @@ -23,8 +23,8 @@ * */ -#ifndef GRAPHICS_VIDEO_PLAYER_H -#define GRAPHICS_VIDEO_PLAYER_H +#ifndef GRAPHICS_VIDEO_DECODER_H +#define GRAPHICS_VIDEO_DECODER_H #include "common/events.h" #include "common/list.h" @@ -177,7 +177,7 @@ protected: virtual void addPauseTime(uint32 ms) { _startTime += ms; } int32 _curFrame; - uint32 _startTime; + int32 _startTime; private: uint32 _pauseLevel; @@ -214,6 +214,72 @@ public: virtual void rewind() = 0; }; +/** + * A simple video timestamp that holds time according to a specific scale. + * + * The scale is in terms of 1/x. For example, if you set units to 1 and the scale to + * 1000, the timestamp will hold the value of 1/1000s or 1ms. + */ +class VideoTimestamp { +public: + VideoTimestamp(); + VideoTimestamp(uint units, uint scale = 1000); + + /** + * Get the units in terms of _scale + */ + uint getUnits() const { return _units; } + + /** + * Get the scale of this timestamp + */ + uint getScale() const { return _scale; } + + /** + * Get the value of the units in terms of the specified scale + */ + uint getUnitsInScale(uint scale) const; + + // TODO: Simple comparisons (<, <=, >, >=, ==, !=) + +private: + uint _units, _scale; +}; + +/** + * A VideoDecoder that can seek to a frame or point in time. + */ +class SeekableVideoDecoder : public virtual RewindableVideoDecoder { +public: + /** + * Seek to the frame specified + * If seekToFrame(0) is called, frame 0 will be decoded next in decodeNextFrame() + */ + virtual void seekToFrame(uint32 frame) = 0; + + /** + * Seek to the time specified + * + * This will round to the previous frame showing. If the time would happen to + * land while a frame is showing, this function will seek to the beginning of that + * frame. In other words, there is *no* subframe accuracy. This may change in a + * later revision of the API. + */ + virtual void seekToTime(VideoTimestamp time) = 0; + + /** + * Seek to the frame specified (in ms) + * + * See seekToTime(VideoTimestamp) + */ + void seekToTime(uint32 time) { seekToTime(VideoTimestamp(time)); } + + /** + * Implementation of RewindableVideoDecoder::rewind() + */ + virtual void rewind() { seekToTime(0); } +}; + } // End of namespace Graphics #endif |