* [FFmpeg-devel] [PATCH] Signed-off-by: devjeonghwan <dev.parkjeonghwan@gmail.com>
@ 2025-08-04 6:30 devjeonghwan
2025-08-04 6:51 ` 박정환
0 siblings, 1 reply; 2+ messages in thread
From: devjeonghwan @ 2025-08-04 6:30 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: devjeonghwan
avformat/apngdec: allow other chunks between fcTL and fdAT/IDAT
The APNG demuxer incorrectly assumed that fcTL chunks must be
immediately followed by fdAT or IDAT chunks. Per PNG specification
section 14.3.2, ancillary chunks may appear in any order relative
to other ancillary chunks.
This change allows intermediate chunks (like tEXt) between fcTL
and frame data chunks, fixing playback of APNG files with metadata.
Fixes #11012.
---
libavformat/apngdec.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
index d0005046c1..a21878b246 100644
--- a/libavformat/apngdec.c
+++ b/libavformat/apngdec.c
@@ -344,14 +344,27 @@ static int apng_read_packet(AVFormatContext *s, AVPacket *pkt)
if ((ret = decode_fctl_chunk(s, ctx, pkt)) < 0)
return ret;
- /* fcTL must precede fdAT or IDAT */
+ /* fcTL may be followed by other chunks before fdAT or IDAT */
len = avio_rb32(pb);
tag = avio_rl32(pb);
- if (len > 0x7fffffff ||
- tag != MKTAG('f', 'd', 'A', 'T') &&
- tag != MKTAG('I', 'D', 'A', 'T'))
+ if (len > 0x7fffffff)
return AVERROR_INVALIDDATA;
+ /* check for empty frame */
+ if (tag == MKTAG('f', 'c', 'T', 'L') ||
+ tag == MKTAG('I', 'E', 'N', 'D')) {
+ size = 38; /* size of fcTL chunk and its header */
+ if ((ret = avio_seek(pb, -46, SEEK_CUR)) < 0 ||
+ (ret = av_append_packet(pb, pkt, size)) < 0)
+ return ret;
+
+ if (ctx->is_key_frame)
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ pkt->pts = pkt->dts = AV_NOPTS_VALUE;
+ pkt->duration = ctx->pkt_duration;
+ return ret;
+ }
+
size = 38 /* fcTL */ + 8 /* len, tag */ + len + 4 /* crc */;
if (size > INT_MAX)
return AVERROR(EINVAL);
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Signed-off-by: devjeonghwan <dev.parkjeonghwan@gmail.com>
2025-08-04 6:30 [FFmpeg-devel] [PATCH] Signed-off-by: devjeonghwan <dev.parkjeonghwan@gmail.com> devjeonghwan
@ 2025-08-04 6:51 ` 박정환
0 siblings, 0 replies; 2+ messages in thread
From: 박정환 @ 2025-08-04 6:51 UTC (permalink / raw)
To: ffmpeg-devel
Please ignore this patch due to incorrect patch subject format.
The correct patch to review is:
"[FFmpeg-devel] avformat/apngdec: allow other chunks between fcTL and
fdAT/IDAT"
Sorry for the confusion.
2025년 8월 4일 (월) 오후 3:32, devjeonghwan <dev.parkjeonghwan@gmail.com>님이 작성:
> avformat/apngdec: allow other chunks between fcTL and fdAT/IDAT
>
> The APNG demuxer incorrectly assumed that fcTL chunks must be
> immediately followed by fdAT or IDAT chunks. Per PNG specification
> section 14.3.2, ancillary chunks may appear in any order relative
> to other ancillary chunks.
>
> This change allows intermediate chunks (like tEXt) between fcTL
> and frame data chunks, fixing playback of APNG files with metadata.
>
> Fixes #11012.
> ---
> libavformat/apngdec.c | 21 +++++++++++++++++----
> 1 file changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
> index d0005046c1..a21878b246 100644
> --- a/libavformat/apngdec.c
> +++ b/libavformat/apngdec.c
> @@ -344,14 +344,27 @@ static int apng_read_packet(AVFormatContext *s,
> AVPacket *pkt)
> if ((ret = decode_fctl_chunk(s, ctx, pkt)) < 0)
> return ret;
>
> - /* fcTL must precede fdAT or IDAT */
> + /* fcTL may be followed by other chunks before fdAT or IDAT */
> len = avio_rb32(pb);
> tag = avio_rl32(pb);
> - if (len > 0x7fffffff ||
> - tag != MKTAG('f', 'd', 'A', 'T') &&
> - tag != MKTAG('I', 'D', 'A', 'T'))
> + if (len > 0x7fffffff)
> return AVERROR_INVALIDDATA;
>
> + /* check for empty frame */
> + if (tag == MKTAG('f', 'c', 'T', 'L') ||
> + tag == MKTAG('I', 'E', 'N', 'D')) {
> + size = 38; /* size of fcTL chunk and its header */
> + if ((ret = avio_seek(pb, -46, SEEK_CUR)) < 0 ||
> + (ret = av_append_packet(pb, pkt, size)) < 0)
> + return ret;
> +
> + if (ctx->is_key_frame)
> + pkt->flags |= AV_PKT_FLAG_KEY;
> + pkt->pts = pkt->dts = AV_NOPTS_VALUE;
> + pkt->duration = ctx->pkt_duration;
> + return ret;
> + }
> +
> size = 38 /* fcTL */ + 8 /* len, tag */ + len + 4 /* crc */;
> if (size > INT_MAX)
> return AVERROR(EINVAL);
> --
> 2.34.1
>
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-04 6:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-04 6:30 [FFmpeg-devel] [PATCH] Signed-off-by: devjeonghwan <dev.parkjeonghwan@gmail.com> devjeonghwan
2025-08-04 6:51 ` 박정환
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git