Skip to content

Commit

Permalink
VIDEO: Begin removing some of the deprecated functions from VideoDecoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hoops committed Aug 16, 2012
1 parent 7294a1c commit 9e7f0e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 70 deletions.
40 changes: 5 additions & 35 deletions video/video_decoder.cpp
Expand Up @@ -34,7 +34,10 @@
namespace Video {

VideoDecoder::VideoDecoder() {
reset();
_startTime = 0;
_pauseLevel = 0;
_audioVolume = Audio::Mixer::kMaxChannelVolume;
_audioBalance = 0;
}

bool VideoDecoder::loadFile(const Common::String &filename) {
Expand Down Expand Up @@ -74,7 +77,7 @@ void VideoDecoder::pauseVideo(bool pause) {
pauseVideoIntern(true);
} else if (_pauseLevel == 0) {
pauseVideoIntern(false);
addPauseTime(g_system->getMillis() - _pauseStartTime);
_startTime += (g_system->getMillis() - _pauseStartTime);
}
}

Expand Down Expand Up @@ -701,41 +704,8 @@ void AdvancedVideoDecoder::startAudioLimit(const Audio::Timestamp &limit) {
///////////////// DEPRECATED /////////////////
//////////////////////////////////////////////

void VideoDecoder::reset() {
_curFrame = -1;
_startTime = 0;
_pauseLevel = 0;
_audioVolume = Audio::Mixer::kMaxChannelVolume;
_audioBalance = 0;
}

bool VideoDecoder::endOfVideo() const {
return !isVideoLoaded() || (getCurFrame() >= (int32)getFrameCount() - 1);
}

void VideoDecoder::setSystemPalette() {
g_system->getPaletteManager()->setPalette(getPalette(), 0, 256);
}

uint32 FixedRateVideoDecoder::getTimeToNextFrame() const {
if (endOfVideo() || _curFrame < 0)
return 0;

uint32 elapsedTime = getTime();
uint32 nextFrameStartTime = getFrameBeginTime(_curFrame + 1);

// If the time that the next frame should be shown has past
// the frame should be shown ASAP.
if (nextFrameStartTime <= elapsedTime)
return 0;

return nextFrameStartTime - elapsedTime;
}

uint32 FixedRateVideoDecoder::getFrameBeginTime(uint32 frame) const {
Common::Rational beginTime = frame * 1000;
beginTime /= getFrameRate();
return beginTime.toInt();
}

} // End of namespace Video
37 changes: 2 additions & 35 deletions video/video_decoder.h
Expand Up @@ -124,7 +124,7 @@ class VideoDecoder {
* Returns the current frame number of the video.
* @return the last frame decoded by the video
*/
virtual int32 getCurFrame() const { return _curFrame; }
virtual int32 getCurFrame() const = 0;

/**
* Returns the number of frames in the video.
Expand Down Expand Up @@ -173,7 +173,7 @@ class VideoDecoder {
* Returns if the video has finished playing or not.
* @return true if the video has finished playing or if none is loaded, false otherwise
*/
virtual bool endOfVideo() const;
virtual bool endOfVideo() const = 0;

/**
* Pause or resume the video. This should stop/resume any audio playback
Expand Down Expand Up @@ -228,25 +228,13 @@ class VideoDecoder {
virtual void setBalance(int8 balance);

protected:
/**
* Resets _curFrame and _startTime. Should be called from every close() function.
* @note This function is now deprecated. There is no replacement.
*/
void reset();

/**
* Actual implementation of pause by subclasses. See pause()
* for details.
* @note This function is now deprecated. There is no replacement.
*/
virtual void pauseVideoIntern(bool pause) {}

/**
* Add the time the video has been paused to maintain sync
* @note This function is now deprecated. There is no replacement.
*/
virtual void addPauseTime(uint32 ms) { _startTime += ms; }

/**
* Reset the pause start time (which should be called when seeking)
*/
Expand All @@ -264,7 +252,6 @@ class VideoDecoder {
*/
virtual void updateBalance() {}

int32 _curFrame; // This variable is now deprecated.
int32 _startTime;

// FIXME: These are protected until the new API takes over this one
Expand Down Expand Up @@ -797,26 +784,6 @@ class AdvancedVideoDecoder : public VideoDecoder {
void startAudioLimit(const Audio::Timestamp &limit);
};

/**
* A VideoDecoder wrapper that implements getTimeToNextFrame() based on getFrameRate().
* @note This class is now deprecated. Use AdvancedVideoDecoder instead.
*/
class FixedRateVideoDecoder : public virtual VideoDecoder {
public:
uint32 getTimeToNextFrame() const;

protected:
/**
* Return the frame rate in frames per second.
* This returns a Rational because videos can have rates that are not integers and
* there are some videos with frame rates < 1.
*/
virtual Common::Rational getFrameRate() const = 0;

private:
uint32 getFrameBeginTime(uint32 frame) const;
};

} // End of namespace Video

#endif

0 comments on commit 9e7f0e4

Please sign in to comment.