From 3a55b076c9609962c8d3b71ae5aadcae4a3212e2 Mon Sep 17 00:00:00 2001 From: Yannis Guyon Date: Tue, 29 Jul 2025 12:52:38 +0000 Subject: [PATCH] Fix comment in anim_encode for key frame candidate Change-Id: I12804097a5ea5025cb4a019a247371db761dab66 --- src/mux/anim_encode.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/mux/anim_encode.c b/src/mux/anim_encode.c index 66ccbb8c..574edc2b 100644 --- a/src/mux/anim_encode.c +++ b/src/mux/anim_encode.c @@ -1262,13 +1262,16 @@ static int CacheFrame(WebPAnimEncoder* const enc, // Note: We need '>=' below because when kmin and kmax are both zero, // count_since_key_frame will always be > kmax. if (enc->count_since_key_frame >= enc->options.kmax) { - // Force the next frame to be a key frame. - enc->best_delta = DELTA_INFINITY; - // Flush all encoded frames. - enc->flush_count = enc->count - 1; + // Start a new sequence of kmin sub-frames, followed by (kmax-kmin) + // candidate frames. Exactly one of these candidate frames will end up + // as a key-frame in the output encoded animation. enc->count_since_key_frame = 0; + enc->best_delta = DELTA_INFINITY; + // Freeze the previous candidate, whether it is a key-frame or not. enc->prev_candidate_undecided = 0; enc->keyframe = KEYFRAME_NONE; + // Flush all previous frames. + enc->flush_count = enc->count - 1; } if (!enc->prev_candidate_undecided) { enc->prev_rect =