[FFmpeg-cvslog] avcodec/apng: Add partial support for blending with PAL8 pixel format

Donny Yang git at videolan.org
Mon Jun 8 16:37:19 CEST 2015


ffmpeg | branch: master | Donny Yang <work at kota.moe> | Tue Jun  2 15:49:27 2015 +0000| [130a6c04a4660e77d5eaf2e84e9fe751e091449b] | committer: Michael Niedermayer

avcodec/apng: Add partial support for blending with PAL8 pixel format

Currently restricted to blending pixels that only contain either
0 or 255 in their alpha components

Signed-off-by: Donny Yang <work at kota.moe>
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=130a6c04a4660e77d5eaf2e84e9fe751e091449b
---

 libavcodec/pngdec.c |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 88b0152..ceda383 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -897,7 +897,8 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s,
 
     if (s->blend_op == APNG_BLEND_OP_OVER &&
         avctx->pix_fmt != AV_PIX_FMT_RGBA &&
-        avctx->pix_fmt != AV_PIX_FMT_GRAY8A) {
+        avctx->pix_fmt != AV_PIX_FMT_GRAY8A &&
+        avctx->pix_fmt != AV_PIX_FMT_PAL8) {
         avpriv_request_sample(avctx, "Blending with pixel format %s",
                               av_get_pix_fmt_name(avctx->pix_fmt));
         return AVERROR_PATCHWELCOME;
@@ -948,6 +949,11 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s,
                     foreground_alpha = foreground[1];
                     background_alpha = background[1];
                     break;
+
+                case AV_PIX_FMT_PAL8:
+                    foreground_alpha = s->palette[foreground[0]] >> 24;
+                    background_alpha = s->palette[background[0]] >> 24;
+                    break;
                 }
 
                 if (foreground_alpha == 0)
@@ -958,6 +964,13 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s,
                     continue;
                 }
 
+                if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
+                    // TODO: Alpha blending with PAL8 will likely need the entire image converted over to RGBA first
+                    avpriv_request_sample(avctx, "Alpha blending palette samples");
+                    background[0] = foreground[0];
+                    continue;
+                }
+
                 output_alpha = foreground_alpha + FAST_DIV255((255 - foreground_alpha) * background_alpha);
 
                 for (b = 0; b < s->bpp - 1; ++b) {



More information about the ffmpeg-cvslog mailing list