From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id BCCF34C611 for ; Mon, 4 Aug 2025 06:38:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 0EBA668C069; Mon, 4 Aug 2025 09:38:23 +0300 (EEST) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id B3D81687B97 for ; Mon, 4 Aug 2025 09:38:16 +0300 (EEST) Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-76b36e6b9ddso3236010b3a.1 for ; Sun, 03 Aug 2025 23:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754289494; x=1754894294; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=NEGVVr+OrPxjBgXsuVKKSTg3cu63/vlI8CRD85g7lKA=; b=N2WpflMZyCT7mHgwwMJmQFGDsSqW0tQkxMvA6PhQASQQXaiyBZ5zLdj0OA9gzAvPs5 1hdmJoC+AdGTJBOETwWf78jlG2Fhu4Jptj7RKc0LGjb6eq4VFY6M0+MMSVIEzG8tBt3n pxMUp32j5jesH8CdUXiuo49FUP14S4QtqZor4+ZsMtKAut+Efh/rJbEzbXmQPVWD8EkK I6j0Nv0007JVgt/BXCDAJ3VCF2dlh43vRJjXBs020p1oNy3dKAlC0m1W385LvZm9nywt Bhr4NC08671sZsyG8HNl9MheRYozWkQPmVuTERCh8XDJy0Z0s9s7maFRbGiEQKrwyls3 dfgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754289494; x=1754894294; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NEGVVr+OrPxjBgXsuVKKSTg3cu63/vlI8CRD85g7lKA=; b=vGVa3QQscpFOg0b8Ju33DL4Www7olpOKG1WrpKSSAnYMQVHVwF1Y3HfsUCLNgntABw snrmlICbKnulnigO+16/z9RXfkV28yakfqyczrB5kVr/7NOTb5KreyQjOcs0YxgKaSj1 ymlEG4Q51llvk7QBzWHhTIwKD9QhcmPrJhXu/xySRIMjKCxmd7I35NGnhD2tGfJf9hfh c5HOB40CL6uV8ndKSfrseJTZqKR+OkSQjA3sNkNUpleBDZPwpxbw+nczaoHwOCWmoYYq 3/hDzjEfVlSA4x1hg2LqjqssqsgPvbHR76R9oVm92SDR4YkF78x4Ed4S/ZDMAd5o/fV3 m5hQ== X-Gm-Message-State: AOJu0YwI//Tve0Cj0ItuXxn8YErN5+cWz2i/WMQHIQb0+3LP/xYhjpTM THIdvJWAxtRIvImcNLIBS9IPxyj95Vi92qYPIKBcOE29ulhk/2smQlcEDb11 X-Gm-Gg: ASbGncvHmK9SjyByM517Kg7tiLnCJruXWxxlzUDI5n1qvxYlKbuwL68SWlvK16m0HKk 4w7nXDJqtliBXfAWa8UPRRj2V7TZT9OrnBtbMSIqLRFIFjjwLcmJKlfHTLLen2Imd0A8MhMRWxE ApXRY3Fhig+lJQlUCvej8vU7g7oXO4210kpxX1gdWQAYa3Q+izHmKkT8N8LV2tAfekhisDCcVl7 oeKtPzjspcBcMT0GDhpLvIOK7VVoabqJlYQEpaoXG7Epqz40eDT7fljXi0fwS4DFqWHv0jxHg8w HQogvCxIKbhridhRRuyfDDxN14DcHhWRIMtr3MxluFtAx1cpS9mydkodzJ6fFNH8MNvu+9/+flS SJ30V2IjIEPavb7yCCdJs0zpKySLYp06vXutdWVrGi7+UZKE7WwI= X-Google-Smtp-Source: AGHT+IFBC0bWJ7C+bfPlFbZcIpjt1gNjhHSPPRRAmWIB4ZCBYyY3KUOoHimXgJpSHahYqE/SJS1hBQ== X-Received: by 2002:aa7:88c6:0:b0:76b:f8f5:2801 with SMTP id d2e1a72fcca58-76bf8f53dfcmr6036450b3a.17.1754289494500; Sun, 03 Aug 2025 23:38:14 -0700 (PDT) Received: from JH-WORKSTATION.localdomain ([220.123.92.122]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-76bccfd0e78sm9590128b3a.99.2025.08.03.23.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Aug 2025 23:38:14 -0700 (PDT) From: devjeonghwan To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Aug 2025 15:37:43 +0900 Message-Id: <20250804063743.11814-1-dev.parkjeonghwan@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/apngdec: allow other chunks between fcTL and fdAT/IDAT X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: devjeonghwan Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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. Signed-off-by: devjeonghwan --- 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".