summaryrefslogtreecommitdiff
path: root/libavcodec/pngdec.c
diff options
context:
space:
mode:
authorDonny Yang <work@kota.moe>2015-06-02 15:49:25 +0000
committerMichael Niedermayer <michaelni@gmx.at>2015-06-08 15:44:22 +0200
commit0ab1c46fe07ff9637ddc67b9b2270a73f1391c9b (patch)
tree2d597c3c89c3c8e25279ade14afeaaeeeba75ba0 /libavcodec/pngdec.c
parented09bb3782e23c12a110469bf6e794f7ce8687e9 (diff)
avcodec/apng: Add blending support for non-alpha pixel formats
Signed-off-by: Donny Yang <work@kota.moe> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pngdec.c')
-rw-r--r--libavcodec/pngdec.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index a70a7f599b..fa69c87732 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -58,6 +58,7 @@ typedef struct PNGDecContext {
int channels;
int bits_per_pixel;
int bpp;
+ int has_trns;
uint8_t *image_buf;
int image_linesize;
@@ -732,6 +733,8 @@ static int decode_trns_chunk(AVCodecContext *avctx, PNGDecContext *s,
}
bytestream2_skip(&s->gb, 4); /* crc */
+ s->has_trns = 1;
+
return 0;
}
@@ -848,6 +851,18 @@ static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s,
s->dispose_op = APNG_DISPOSE_OP_BACKGROUND;
}
+ if (s->dispose_op == APNG_BLEND_OP_OVER && !s->has_trns && (
+ avctx->pix_fmt == AV_PIX_FMT_RGB24 ||
+ avctx->pix_fmt == AV_PIX_FMT_RGB48BE ||
+ avctx->pix_fmt == AV_PIX_FMT_PAL8 ||
+ avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
+ avctx->pix_fmt == AV_PIX_FMT_GRAY16BE ||
+ avctx->pix_fmt == AV_PIX_FMT_MONOBLACK
+ )) {
+ // APNG_DISPOSE_OP_OVER is the same as APNG_DISPOSE_OP_SOURCE when there is no alpha channel
+ s->dispose_op = APNG_BLEND_OP_SOURCE;
+ }
+
return 0;
}