diff options
author | Paul B Mahol <onemda@gmail.com> | 2012-01-09 23:12:40 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2012-01-10 18:00:37 +0000 |
commit | a6839c4e60635685aac95b81bb9782e06502121a (patch) | |
tree | cee24de21d2c9a5c2c4c96ff85f328b6695fe932 | |
parent | 93d49cba7f96f3c578275c5df5b3f2191711e17a (diff) | |
download | ffmpeg-a6839c4e60635685aac95b81bb9782e06502121a.tar.gz |
bmpdec: support for rgb444 with bitfields compression
Do not display garbage for invalid/unsupported bitfields values.
-rw-r--r-- | libavcodec/bmp.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c index 9a5c244644..bfa70bceb1 100644 --- a/libavcodec/bmp.c +++ b/libavcodec/bmp.c @@ -163,8 +163,18 @@ static int bmp_decode_frame(AVCodecContext *avctx, case 16: if(comp == BMP_RGB) avctx->pix_fmt = PIX_FMT_RGB555; - if(comp == BMP_BITFIELDS) - avctx->pix_fmt = rgb[1] == 0x07E0 ? PIX_FMT_RGB565 : PIX_FMT_RGB555; + else if (comp == BMP_BITFIELDS) { + if (rgb[0] == 0xF800 && rgb[1] == 0x07E0 && rgb[2] == 0x001F) + avctx->pix_fmt = PIX_FMT_RGB565; + else if (rgb[0] == 0x7C00 && rgb[1] == 0x03E0 && rgb[2] == 0x001F) + avctx->pix_fmt = PIX_FMT_RGB555; + else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F) + avctx->pix_fmt = PIX_FMT_RGB444; + else { + av_log(avctx, AV_LOG_ERROR, "Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]); + return AVERROR(EINVAL); + } + } break; case 8: if(hsize - ihsize - 14 > 0) |