From aa2d41701d14a651c23c4e2a4c5098a300f2235f Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 29 Nov 2012 15:50:43 -0500 Subject: VIDEO: Allow AVI frame rate to be overriden with a constant Required for sword1/sword2 MPEG videos --- video/avi_decoder.cpp | 24 +++++++++++++++++++----- video/avi_decoder.h | 3 +++ 2 files changed, 22 insertions(+), 5 deletions(-) (limited to 'video') diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp index 32238eca4e..ff728a8437 100644 --- a/video/avi_decoder.cpp +++ b/video/avi_decoder.cpp @@ -91,7 +91,20 @@ static uint16 getStreamType(uint32 tag) { return tag & 0xffff; } -AVIDecoder::AVIDecoder(Audio::Mixer::SoundType soundType) : _soundType(soundType) { +AVIDecoder::AVIDecoder(Audio::Mixer::SoundType soundType) : _frameRateOverride(0), _soundType(soundType) { + initCommon(); +} + +AVIDecoder::AVIDecoder(const Common::Rational &frameRateOverride, Audio::Mixer::SoundType soundType) + : _frameRateOverride(frameRateOverride), _soundType(soundType) { + initCommon(); +} + +AVIDecoder::~AVIDecoder() { + close(); +} + +void AVIDecoder::initCommon() { _decodedHeader = false; _foundMovieList = false; _fileStream = 0; @@ -99,10 +112,6 @@ AVIDecoder::AVIDecoder(Audio::Mixer::SoundType soundType) : _soundType(soundType memset(&_header, 0, sizeof(_header)); } -AVIDecoder::~AVIDecoder() { - close(); -} - void AVIDecoder::runHandle(uint32 tag) { assert(_fileStream); if (_fileStream->eos()) @@ -214,6 +223,11 @@ void AVIDecoder::handleStreamHeader() { uint32 startPos = _fileStream->pos(); if (sHeader.streamType == ID_VIDS) { + if (_frameRateOverride != 0) { + sHeader.rate = _frameRateOverride.getNumerator(); + sHeader.scale = _frameRateOverride.getDenominator(); + } + BitmapInfoHeader bmInfo; bmInfo.size = _fileStream->readUint32LE(); bmInfo.width = _fileStream->readUint32LE(); diff --git a/video/avi_decoder.h b/video/avi_decoder.h index bc870eac33..1652614bd8 100644 --- a/video/avi_decoder.h +++ b/video/avi_decoder.h @@ -56,6 +56,7 @@ class Codec; class AVIDecoder : public VideoDecoder { public: AVIDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType); + AVIDecoder(const Common::Rational &frameRateOverride, Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType); virtual ~AVIDecoder(); bool loadStream(Common::SeekableReadStream *stream); @@ -222,6 +223,8 @@ private: bool _decodedHeader, _foundMovieList; Audio::Mixer::SoundType _soundType; + Common::Rational _frameRateOverride; + void initCommon(); void runHandle(uint32 tag); void handleList(); -- cgit v1.2.3