Skip to content

Commit

Permalink
VIDEO: Allow AVI frame rate to be overriden with a constant
Browse files Browse the repository at this point in the history
Required for sword1/sword2 MPEG videos
  • Loading branch information
Matthew Hoops committed Jun 20, 2013
1 parent f39c9d5 commit aa2d417
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
24 changes: 19 additions & 5 deletions video/avi_decoder.cpp
Expand Up @@ -91,18 +91,27 @@ 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;
memset(&_ixInfo, 0, sizeof(_ixInfo));
memset(&_header, 0, sizeof(_header));
}

AVIDecoder::~AVIDecoder() {
close();
}

void AVIDecoder::runHandle(uint32 tag) {
assert(_fileStream);
if (_fileStream->eos())
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions video/avi_decoder.h
Expand Up @@ -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);
Expand Down Expand Up @@ -222,6 +223,8 @@ class AVIDecoder : public VideoDecoder {
bool _decodedHeader, _foundMovieList;

Audio::Mixer::SoundType _soundType;
Common::Rational _frameRateOverride;
void initCommon();

void runHandle(uint32 tag);
void handleList();
Expand Down

0 comments on commit aa2d417

Please sign in to comment.