Skip to content
Permalink
Browse files

ZVISION: Add a hack to set the correct frame delay for RLF videos

Also, use Common::Rational to avoid using floating point math
  • Loading branch information
bluegr committed Dec 24, 2014
1 parent 6afeec1 commit 9948d3ca16ceff79dd3ccf6dde5024de04470f08
Showing with 14 additions and 2 deletions.
  1. +14 −2 engines/zvision/scripting/sidefx/animation_node.cpp
@@ -39,8 +39,20 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S
_mask(mask),
_animation(NULL) {

_animation = engine->loadAnimation(fileName);
_frmDelay = 1000.0 / _animation->getDuration().framerate();
if (fileName.hasSuffix(".rlf")) {
// HACK: Read the frame delay directly
Common::File *tmp = engine->getSearchManager()->openFile(fileName);
if (tmp) {
tmp->seek(176, SEEK_SET);
_frmDelay = tmp->readUint32LE() / 10;
delete tmp;
}

_animation = engine->loadAnimation(fileName);
} else {
_animation = engine->loadAnimation(fileName);
_frmDelay = Common::Rational(1000, _animation->getDuration().framerate()).toInt();
}

if (frate > 0)
_frmDelay = 1000.0 / frate;

4 comments on commit 9948d3c

@Marisa-Chan

This comment has been minimized.

Copy link
Contributor

@Marisa-Chan Marisa-Chan replied Dec 24, 2014

This is too much dirty

@clone2727

This comment has been minimized.

Copy link
Contributor

@clone2727 clone2727 replied Dec 24, 2014

Why don't you make _frmDelay a Common::Rational instead so you don't truncate the data?

@Marisa-Chan

This comment has been minimized.

Copy link
Contributor

@Marisa-Chan Marisa-Chan replied Dec 24, 2014

hmmm, I see problem related to FixedRateVideoTrack class that can't get correct framerate from getDuration() timestamp because it's return only timestamp without real framerate information, because it's constructs timestamp(0, 264, 125) for 32 frame-length rlf-file with 66msec per frame (15 fps)

This is bacause:

Audio::Timestamp VideoDecoder::FixedRateVideoTrack::getFrameTime(uint frame) const {  // frame = 32
    Common::Rational frameRate = getFrameRate(); // frameRate = 1000/66 = 15.151515152

    if (frameRate == frameRate.toInt()) // 15.151515152 != 15
        return Audio::Timestamp(0, frame, frameRate.toInt()); //this will construct normal timestamp with real framerate, but not in this case!!

    Common::Rational time = frameRate.getInverse() * frame;  // and this converts it to
    return Audio::Timestamp(0, time.getNumerator(), time.getDenominator()); //  264 frames and 125 as rate.
}
@clone2727

This comment has been minimized.

Copy link
Contributor

@clone2727 clone2727 replied Dec 24, 2014

@Marisa-Chan Nice catch! I'll write up a fix.

EDIT: The fix is in bed5325

Please sign in to comment.
You can’t perform that action at this time.