summaryrefslogtreecommitdiff
path: root/libavcodec/bmp.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-09-10 16:06:14 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2015-09-10 16:36:47 +0200
commitaec340c533293d6230573aaf3fe22a74e5454b99 (patch)
treedda9f6a3fd8114f56e3597bbef4e11a5e30033a6 /libavcodec/bmp.c
parent319898bba254105aad2bd50233c3c2867f73695a (diff)
downloadffmpeg-aec340c533293d6230573aaf3fe22a74e5454b99.tar.gz
avcodec/bmp: Analyze BGRA files alpha channel to choose pixel format
BGRA BMPs commonly do contain an all transparent alpha channel Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/bmp.c')
-rw-r--r--libavcodec/bmp.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c
index 42270da6e7..3019d01016 100644
--- a/libavcodec/bmp.c
+++ b/libavcodec/bmp.c
@@ -337,6 +337,20 @@ static int bmp_decode_frame(AVCodecContext *avctx,
return AVERROR_INVALIDDATA;
}
}
+ if (avctx->pix_fmt == AV_PIX_FMT_BGRA) {
+ for (i = 0; i < avctx->height; i++) {
+ int j;
+ uint8_t *ptr = p->data[0] + p->linesize[0]*i + 3;
+ for (j = 0; j < avctx->width; j++) {
+ if (ptr[4*j])
+ break;
+ }
+ if (j < avctx->width)
+ break;
+ }
+ if (i == avctx->height)
+ avctx->pix_fmt = p->format = AV_PIX_FMT_BGR0;
+ }
*got_frame = 1;