Fix one frame missing (#529) 39/281439/1
authorMichal Maciola <71131832+mmaciola@users.noreply.github.com>
Mon, 19 Sep 2022 02:03:23 +0000 (04:03 +0200)
committerjykeon <jykeon@samsung.com>
Mon, 19 Sep 2022 04:59:46 +0000 (13:59 +0900)
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.

issue: #527
Change-Id: I82f7d85ba6f932b2e47a4be68bf91dcc97da5b0a

src/lottie/lottieitem.cpp
src/lottie/lottiemodel.h
src/lottie/lottieparser.cpp

index cb1bc2cdd629b02f9eb25ce1f01b082323b6331a..4cd22e4c5f3c1aa709b7a3487e5a4182c9bbdd65 100644 (file)
@@ -443,7 +443,7 @@ VMatrix renderer::Layer::matrix(int frameNo) const
 bool renderer::Layer::visible() const
 {
     return (frameNo() >= mLayerData->inFrame() &&
-            frameNo() < mLayerData->outFrame());
+            frameNo() <= mLayerData->outFrame());
 }
 
 void renderer::Layer::preprocess(const VRect &clip)
index 3e0430853744d5be76d0f13e52afef5e30a18981..745571e2c2a5775623c4efa1756db018c47ef159 100644 (file)
@@ -539,8 +539,8 @@ public:
     {
         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 + 1; }
+    long   frameDuration() const { return mEndFrame - mStartFrame; }
     float  frameRate() const { return mFrameRate; }
     size_t startFrame() const { return mStartFrame; }
     size_t endFrame() const { return mEndFrame; }
index 83be17e3930d6e5dfff33358d89394c856d1c1b0..e14fd5c1c7eb98072d03236de791de28f90cd203 100644 (file)
@@ -665,9 +665,9 @@ void LottieParserImpl::parseComposition()
         } else if (0 == strcmp(key, "h")) {
             comp->mSize.setHeight(GetInt());
         } else if (0 == strcmp(key, "ip")) {
-            comp->mStartFrame = GetDouble();
+            comp->mStartFrame = std::lround(GetDouble());
         } else if (0 == strcmp(key, "op")) {
-            comp->mEndFrame = GetDouble();
+            comp->mEndFrame = std::lround(GetDouble());
         } else if (0 == strcmp(key, "fr")) {
             comp->mFrameRate = GetDouble();
         } else if (0 == strcmp(key, "assets")) {