diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2015-01-26 20:19:17 +0100 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2015-01-27 21:29:42 +0100 |
commit | d96090e7b633e16ca7e3c355c63f42e7d924fc6a (patch) | |
tree | e3abf10abaaa810af0ca465247875441530580fc /libavcodec/bmp.c | |
parent | d3d4d98764ea18b3f192ea92b13ee075263b4387 (diff) |
Support BMP files that do not properly align lines.
Quite a few programs missed that detail of the spec
(including old versions of FFmpeg I believe) and when
we would otherwise fail anyway it seems worth a try
to use a simple byte-aligned stride instead.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavcodec/bmp.c')
-rw-r--r-- | libavcodec/bmp.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c index 458fd0c768..a35ed1ac1e 100644 --- a/libavcodec/bmp.c +++ b/libavcodec/bmp.c @@ -215,9 +215,13 @@ static int bmp_decode_frame(AVCodecContext *avctx, 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", - dsize, n * avctx->height); - return AVERROR_INVALIDDATA; + n = (avctx->width * depth + 7) / 8; + if (n * avctx->height > dsize) { + av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n", + dsize, n * avctx->height); + return AVERROR_INVALIDDATA; + } + av_log(avctx, AV_LOG_ERROR, "data size too small, assuming missing line alignment\n"); } // RLE may skip decoding some picture areas, so blank picture before decoding |