From 7654b2036268bb56f3b08b88858f2a9e4862b056 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 22 Jul 2012 14:11:11 -0400 Subject: VIDEO: Merge the three Fixed* VideoTrack classes Avoids diamond inheritance, which makes it impossible to downcast without rtti --- engines/sci/video/seq_decoder.h | 2 +- video/video_decoder.cpp | 4 ++-- video/video_decoder.h | 30 +++++------------------------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/engines/sci/video/seq_decoder.h b/engines/sci/video/seq_decoder.h index 75d7ce6c3d..82254990d6 100644 --- a/engines/sci/video/seq_decoder.h +++ b/engines/sci/video/seq_decoder.h @@ -48,7 +48,7 @@ public: bool loadStream(Common::SeekableReadStream *stream); private: - class SEQVideoTrack : public FixedDurationVideoTrack { + class SEQVideoTrack : public FixedRateVideoTrack { public: SEQVideoTrack(Common::SeekableReadStream *stream, uint frameDelay); ~SEQVideoTrack(); diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp index b2fcdda04c..ad176da73b 100644 --- a/video/video_decoder.cpp +++ b/video/video_decoder.cpp @@ -400,11 +400,11 @@ uint32 AdvancedVideoDecoder::FixedRateVideoTrack::getNextFrameStartTime() const return time.toInt(); } -bool AdvancedVideoDecoder::FixedLengthVideoTrack::endOfTrack() const { +bool AdvancedVideoDecoder::FixedRateVideoTrack::endOfTrack() const { return getCurFrame() >= (getFrameCount() - 1); } -Audio::Timestamp AdvancedVideoDecoder::FixedDurationVideoTrack::getDuration() const { +Audio::Timestamp AdvancedVideoDecoder::FixedRateVideoTrack::getDuration() const { // Since Audio::Timestamp doesn't support a fractional frame rate, we're currently // just converting to milliseconds. Common::Rational time = getFrameCount() * 1000; diff --git a/video/video_decoder.h b/video/video_decoder.h index 2a5eebfc60..efc8f7a37d 100644 --- a/video/video_decoder.h +++ b/video/video_decoder.h @@ -499,13 +499,17 @@ protected: /** * A VideoTrack that is played at a constant rate. + * + * If the frame count is unknown, you must override endOfTrack(). */ - class FixedRateVideoTrack : public virtual VideoTrack { + class FixedRateVideoTrack : public VideoTrack { public: FixedRateVideoTrack() {} virtual ~FixedRateVideoTrack() {} + virtual bool endOfTrack() const; uint32 getNextFrameStartTime() const; + virtual Audio::Timestamp getDuration() const; protected: /** @@ -514,30 +518,6 @@ protected: virtual Common::Rational getFrameRate() const = 0; }; - /** - * A VideoTrack with a known frame count that can be reliably - * used to figure out if the track has finished. - */ - class FixedLengthVideoTrack : public virtual VideoTrack { - public: - FixedLengthVideoTrack() {} - virtual ~FixedLengthVideoTrack() {} - - bool endOfTrack() const; - }; - - /** - * A FixedRateVideoTrack and FixedLengthVideoTrack that implements the getDuration() - * function. - */ - class FixedDurationVideoTrack : public FixedRateVideoTrack, public FixedLengthVideoTrack { - public: - FixedDurationVideoTrack() {} - virtual ~FixedDurationVideoTrack() {} - - virtual Audio::Timestamp getDuration() const; - }; - /** * An abstract representation of an audio track. */ -- cgit v1.2.3