Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Hassan Hany via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: "U-DESKTOP-70DF2U5\\GIGABYT" <hassanhanyrashad@gmail.com>
Subject: [FFmpeg-devel] [PATCH] apng: fix rgb24 blending bug for non-alpha frames
Date: Fri,  2 Jan 2026 13:29:32 +0200
Message-ID: <20260102112935.1842-1-hassanhanyrashad@gmail.com> (raw)

From: "U-DESKTOP-70DF2U5\\GIGABYT" <hassanhanyrashad@gmail.com>

Delta frame optimization in APNG encoder caused gray bars for RGB24 frames.
This patch disables delta optimization for non-alpha frames, ensuring correct
rendering. Delta optimization is preserved for RGBA frames.

Fixes: trac Ticket #9602

Signed-off-by: U-DESKTOP-70DF2U5\GIGABYT <hassanhanyrashad@gmail.com>
---
This bug caused visible artifacts such as gray bars in non-alpha 
pixel formats such as RGB24 or GRAY. This patch disabled delta frame
optimization only for non alpha channels. the output size increased
from 512kb to 1.1mb on the test sample but correctness was restored
and the relevant APNG FATE tests were ran and no regression occurred
 libavcodec/pngenc.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index e627bf83fc..3e46363b00 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -39,7 +39,7 @@
 #include "libavutil/opt.h"
 #include "libavutil/rational.h"
 #include "libavutil/stereo3d.h"
-
+#include "libavutil/pixdesc.h"
 #include <zlib.h>
 
 #define IOBUF_SIZE 4096
@@ -894,6 +894,19 @@ static int apng_encode_frame(AVCodecContext *avctx, const AVFrame *pict,
         best_fctl_chunk->blend_op = APNG_BLEND_OP_SOURCE;
         return encode_frame(avctx, pict);
     }
+    
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pict->format);
+        
+    if(!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)){
+         best_fctl_chunk->width = pict->width;
+         best_fctl_chunk->height = pict->height;
+         best_fctl_chunk->x_offset = 0;
+         best_fctl_chunk->y_offset = 0;
+         best_fctl_chunk->blend_op = APNG_BLEND_OP_SOURCE;
+         best_fctl_chunk->dispose_op = APNG_DISPOSE_OP_NONE;
+          return encode_frame(avctx, pict);
+         } 
+    
 
     diffFrame = av_frame_alloc();
     if (!diffFrame)
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

             reply	other threads:[~2026-01-02 11:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-02 11:29 Hassan Hany via ffmpeg-devel [this message]
2026-01-05 16:12 ` [FFmpeg-devel] " Michael Niedermayer via ffmpeg-devel
2026-01-06 14:15   ` hassan hany via ffmpeg-devel
2026-01-08  2:33     ` Michael Niedermayer via ffmpeg-devel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260102112935.1842-1-hassanhanyrashad@gmail.com \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=hassanhanyrashad@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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