This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new 202b7d29e8 avcodec/pngenc: disable background disposal for non-alpha 
formats
202b7d29e8 is described below

commit 202b7d29e8a15f55ce742c25340aef77733204f8
Author:     Hassan Hany <[email protected]>
AuthorDate: Thu Jan 8 21:04:52 2026 +0200
Commit:     James Almer <[email protected]>
CommitDate: Sun Jan 11 00:47:17 2026 +0000

    avcodec/pngenc: disable background disposal for non-alpha formats
---
 libavcodec/pngenc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index e627bf83fc..82a9d5b835 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -37,9 +37,9 @@
 #include "libavutil/mastering_display_metadata.h"
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 #include "libavutil/rational.h"
 #include "libavutil/stereo3d.h"
-
 #include <zlib.h>
 
 #define IOBUF_SIZE 4096
@@ -885,6 +885,7 @@ static int apng_encode_frame(AVCodecContext *avctx, const 
AVFrame *pict,
     size_t best_bytestream_size = SIZE_MAX;
     APNGFctlChunk last_fctl_chunk = *best_last_fctl_chunk;
     APNGFctlChunk fctl_chunk = *best_fctl_chunk;
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pict->format);
 
     if (avctx->frame_num == 0) {
         best_fctl_chunk->width = pict->width;
@@ -919,7 +920,10 @@ static int apng_encode_frame(AVCodecContext *avctx, const 
AVFrame *pict,
         // 0: APNG_DISPOSE_OP_NONE
         // 1: APNG_DISPOSE_OP_BACKGROUND
         // 2: APNG_DISPOSE_OP_PREVIOUS
-
+        if (last_fctl_chunk.dispose_op == APNG_DISPOSE_OP_BACKGROUND) {
+            if (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA))
+                continue;
+        }
         for (fctl_chunk.blend_op = 0; fctl_chunk.blend_op < 2; 
++fctl_chunk.blend_op) {
             // 0: APNG_BLEND_OP_SOURCE
             // 1: APNG_BLEND_OP_OVER

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to