Skip to content

Commit

Permalink
Fix one frame missing
Browse files Browse the repository at this point in the history
As mStartFrame and mEndFrame was counted from 0 and totalFrame() was
calculated as a difference, there were always one frame missing and
the animation rescaled. This patch adds one to the total frames count.
As there is 0.01 subtract (copied from android implementation, needed
for some resources where frame no is non-whole number), added +2.

issue: Samsung#527
  • Loading branch information
mmaciola committed Sep 14, 2022
1 parent 30f300d commit 4e5a00d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lottie/lottiemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ class Composition : public Object {
{
return long(frameAtPos(timeInSec / duration()));
}
size_t totalFrame() const { return mEndFrame - mStartFrame; }
long frameDuration() const { return mEndFrame - mStartFrame - 1; }
size_t totalFrame() const { return mEndFrame - mStartFrame + 2; }
long frameDuration() const { return mEndFrame - mStartFrame; }
float frameRate() const { return mFrameRate; }
size_t startFrame() const { return mStartFrame; }
size_t endFrame() const { return mEndFrame; }
Expand Down
4 changes: 2 additions & 2 deletions src/lottie/lottieparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ void LottieParserImpl::parseComposition()
} else if (0 == strcmp(key, "ip")) {
comp->mStartFrame = GetDouble();
} else if (0 == strcmp(key, "op")) {
comp->mEndFrame = GetDouble();
comp->mEndFrame = GetDouble() - 0.01f;
} else if (0 == strcmp(key, "fr")) {
comp->mFrameRate = GetDouble();
} else if (0 == strcmp(key, "assets")) {
Expand Down Expand Up @@ -699,7 +699,7 @@ void LottieParserImpl::parseComposition()
resolveLayerRefs();
comp->setStatic(comp->mRootLayer->isStatic());
comp->mRootLayer->mInFrame = comp->mStartFrame;
comp->mRootLayer->mOutFrame = comp->mEndFrame;
comp->mRootLayer->mOutFrame = comp->mEndFrame + 2;

mComposition = sharedComposition;
}
Expand Down

0 comments on commit 4e5a00d

Please sign in to comment.