From 45714cee101dc2c8a093404e49a46278523e94f5 Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Mon, 19 Oct 2026 13:13:05 +0200 Subject: [PATCH] avformat/webp_anim_dec: fix keyframe flag when seeking The keyframe flag was only being set when looping, and not when seeking back. Use ctx->first_anmf_offset to detect first keyframe instead of trying to count cur_frame. --- libavformat/webp_anim_dec.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavformat/webp_anim_dec.c b/libavformat/webp_anim_dec.c index e81deea6c8..6cd90b3315 100644 --- a/libavformat/webp_anim_dec.c +++ b/libavformat/webp_anim_dec.c @@ -61,7 +61,7 @@ typedef struct WebPAnimDemuxContext { /* * variables for the key frame detection */ - int cur_frame; ///< number of frames of the current animation file + int64_t first_anmf_offset; int vp8x_flags; int has_iccp; @@ -70,8 +70,6 @@ typedef struct WebPAnimDemuxContext { int has_xmp; int usebgcolor; - - int64_t first_anmf_offset; } WebPAnimDemuxContext; /** @@ -253,7 +251,6 @@ static int webp_anim_read_packet(AVFormatContext *s, AVPacket *pkt) if (avio_feof(pb)) { if (!ctx->ignore_loop && (ctx->loop_count == 0 || ++ctx->cur_loop < ctx->loop_count)) { - ctx->cur_frame = 0; ret = avio_seek(pb, ctx->first_anmf_offset, SEEK_SET); if (ret < 0) return ret; @@ -273,7 +270,7 @@ static int webp_anim_read_packet(AVFormatContext *s, AVPacket *pkt) if (ret < 0) return ret; pkt->pos = offset; - if (!ctx->cur_frame++) + if (offset == ctx->first_anmf_offset) pkt->flags |= AV_PKT_FLAG_KEY; pkt->pts = AV_NOPTS_VALUE; pkt->dts = AV_NOPTS_VALUE;