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

Michael Niedermayer michaelni
Tue Nov 25 23:43:53 CET 2008


On Tue, Nov 25, 2008 at 09:05:08AM +0200, Kostya wrote:
> On Tue, Nov 25, 2008 at 12:15:26AM +0100, Michael Niedermayer wrote:
> > 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
> > hardcasing header sizes really is fragile
>  
> The question is where such BMP can come from. While your solution is robust
> and pretty, it does not allow catching BMPs with unexpected header sizes.

well if your goal is to collect rare bmps, then not supporting cases you dont
have yet is likely a good idea
i had not considered that

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you really think that XML is the answer, then you definitly missunderstood
the question -- Attila Kinali
-------------- 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/45761a4d/attachment.pgp>



More information about the ffmpeg-cvslog mailing list