[FFmpeg-cvslog] r15922 - trunk/libavcodec/bmp.c

Michael Niedermayer michaelni
Tue Nov 25 00:15:26 CET 2008


On Mon, Nov 24, 2008 at 11:53:13AM +0100, kostya wrote:
> Author: kostya
> Date: Mon Nov 24 11:53:13 2008
> New Revision: 15922
> 
> Log:
> Add known BMP header sizes.
> 
> Now 11B*.bmp from samples repository can be decoded.
> 
> 
> Modified:
>    trunk/libavcodec/bmp.c
> 
> Modified: trunk/libavcodec/bmp.c
> ==============================================================================
> --- trunk/libavcodec/bmp.c	(original)
> +++ trunk/libavcodec/bmp.c	Mon Nov 24 11:53:13 2008
> @@ -85,13 +85,19 @@ static int bmp_decode_frame(AVCodecConte
>          return -1;
>      }
>  
> -    if (ihsize == 40) {
> +    switch(ihsize){
> +    case  40: // windib v3
> +    case  64: // OS/2 v2
> +    case 108: // windib v4
> +    case 124: // windib v5
>          width = bytestream_get_le32(&buf);
>          height = bytestream_get_le32(&buf);
> -    } else if (ihsize == 12) {
> +        break;
> +    case  12: // OS/2 v1
>          width  = bytestream_get_le16(&buf);
>          height = bytestream_get_le16(&buf);
> -    } else {
> +        break;
> +    default:
>          av_log(avctx, AV_LOG_ERROR, "unsupported BMP file, patch welcome\n");
>          return -1;
>      }

you can do this will less crap

width  = bytestream_get_le32(&buf);
height = bytestream_get_le32(&buf);
if(width > 65536U){ 
    buf -= 8;
    width  = bytestream_get_le16(&buf);
    height = bytestream_get_le16(&buf);
}

being one option
using the planes or depth values later is an option too
or you can just try all variant until one passes the validity checks
hardcosing header sizes really is fragile


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/attachments/20081125/be9a4afb/attachment.pgp>



More information about the ffmpeg-cvslog mailing list