From 20d3992214f74cee5b49e0d96ba7aa37c9cb05df Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Fri, 24 May 2024 23:35:13 +0200 Subject: [PATCH] lottie: fix interpolation issue Handled the case of different numbers of points in consecutive frames. This case can occur due to erroneous data or as a consequence of changing the path from closed to open and vice versa. @Issue: https://github.com/thorvg/thorvg/issues/2287 --- src/loaders/lottie/tvgLottieProperty.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/loaders/lottie/tvgLottieProperty.h b/src/loaders/lottie/tvgLottieProperty.h index 6070be52..40f1eacb 100644 --- a/src/loaders/lottie/tvgLottieProperty.h +++ b/src/loaders/lottie/tvgLottieProperty.h @@ -544,7 +544,10 @@ struct LottiePathSet : LottieProperty else { frame = frames->data + _bsearch(frames, frameNo); if (mathEqual(frame->no, frameNo)) path = &frame->value; - else { + else if (frame->value.ptsCnt != (frame + 1)->value.ptsCnt) { + path = &frame->value; + TVGLOG("LOTTIE", "Different numbers of points in consecutive frames - interpolation omitted."); + } else { t = (frameNo - frame->no) / ((frame + 1)->no - frame->no); if (frame->interpolator) t = frame->interpolator->progress(t); if (frame->hold) path = &(frame + ((t < 1.0f) ? 0 : 1))->value;