diff options
Diffstat (limited to 'libavcodec/bmp.c')
-rw-r--r-- | libavcodec/bmp.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c index f438d10613..419c3fa197 100644 --- a/libavcodec/bmp.c +++ b/libavcodec/bmp.c @@ -2,20 +2,20 @@ * BMP image format decoder * Copyright (c) 2005 Mans Rullgard * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -92,7 +92,8 @@ static int bmp_decode_frame(AVCodecContext *avctx, } switch(ihsize){ - case 40: // windib v3 + case 40: // windib + case 56: // windib v3 case 64: // OS/2 v2 case 108: // windib v4 case 124: // windib v5 @@ -115,7 +116,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, depth = bytestream_get_le16(&buf); - if(ihsize == 40) + if(ihsize == 40 || ihsize == 64 || ihsize == 56) comp = bytestream_get_le32(&buf); else comp = BMP_RGB; @@ -154,7 +155,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, rgb[2] = 0; } - avctx->pix_fmt = PIX_FMT_BGR24; + avctx->pix_fmt = PIX_FMT_BGRA; break; case 24: avctx->pix_fmt = PIX_FMT_BGR24; @@ -205,7 +206,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, dsize = buf_size - hsize; /* Line size in file multiple of 4 */ - n = ((avctx->width * depth) / 8 + 3) & ~3; + n = ((avctx->width * depth + 31) / 8) & ~3; if(n * avctx->height > dsize && comp != BMP_RLE4 && comp != BMP_RLE8){ av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n", @@ -243,7 +244,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, buf = buf0 + 14 + ihsize; //palette location if((hsize-ihsize-14) < (colors << 2)){ // OS/2 bitmap, 3 bytes per palette entry for(i = 0; i < colors; i++) - ((uint32_t*)p->data[1])[i] = bytestream_get_le24(&buf); + ((uint32_t*)p->data[1])[i] = (0xff<<24) | bytestream_get_le24(&buf); }else{ for(i = 0; i < colors; i++) ((uint32_t*)p->data[1])[i] = bytestream_get_le32(&buf); @@ -319,7 +320,13 @@ static int bmp_decode_frame(AVCodecContext *avctx, dst[0] = src[rgb[2]]; dst[1] = src[rgb[1]]; dst[2] = src[rgb[0]]; - dst += 3; +/* The Microsoft documentation states: + * "The high byte in each DWORD is not used." + * Both GIMP and ImageMagick store the alpha transparency value + * in the high byte for 32bit bmp files. + */ + dst[3] = src[3]; + dst += 4; src += 4; } |