GRIM/SMUSH: Fix looping videos

This commit is contained in:
Einar Johan Trøan Sømåen 2012-12-31 13:02:46 +01:00
parent 88305a022e
commit 2472cc83a3
3 changed files with 12 additions and 4 deletions

View File

@ -323,10 +323,16 @@ void SmushDecoder::handleFRME(Common::SeekableReadStream *stream, uint32 size) {
delete memStream;
}
bool SmushDecoder::rewind() {
return seekToFrame(0);
}
bool SmushDecoder::seek(const Audio::Timestamp &time) { // FIXME: This will be off by a second or two right now.
int32 wantedFrame = (uint32)((time.msecs() / 1000.0f) * _videoTrack->getFrameRate().toDouble());
warning("Seek to time: %d, frame: %d", time.msecs(), wantedFrame);
warning("Current frame: %d", _videoTrack->getCurFrame());
if (wantedFrame != 0) {
warning("Seek to time: %d, frame: %d", time.msecs(), wantedFrame);
warning("Current frame: %d", _videoTrack->getCurFrame());
}
uint32 tag;
int32 size;
@ -338,7 +344,7 @@ bool SmushDecoder::seek(const Audio::Timestamp &time) { // FIXME: This will be o
_file->seek(_startPos, SEEK_SET);
}
int curFrame = -1;
int curFrame = 0;
while (curFrame < wantedFrame) {
tag = _file->readUint32BE();
if (tag == MKTAG('A', 'N', 'N', 'O')) {
@ -594,5 +600,4 @@ bool SmushDecoder::SmushAudioTrack::seek(const Audio::Timestamp &time) {
}
} // end of namespace Grim

View File

@ -46,7 +46,9 @@ public:
int getX() const { return _videoTrack->_x; }
int getY() const { return _videoTrack->_y; }
void setLooping(bool l);
bool isRewindable() const { return true; }
bool isSeekable() const { return true; }
bool rewind();
bool seek(const Audio::Timestamp &time);
bool loadStream(Common::SeekableReadStream *stream);
protected:

View File

@ -65,6 +65,7 @@ void SmushPlayer::handleFrame() {
return;
} else {
_smushDecoder->rewind(); // This doesnt handle if looping fails.
_smushDecoder->start();
}
}
}