[FFmpeg-soc] BFI Decoder

Sisir Koppaka sisir.koppaka at gmail.com
Thu Apr 17 07:45:13 CEST 2008


On Thu, Apr 17, 2008 at 2:31 AM, Michael Niedermayer <michaelni at gmx.at>
wrote:

> On Thu, Apr 17, 2008 at 01:59:08AM +0530, Sisir Koppaka wrote:
>
> [...]
> > static int bfi_decode_init(AVCodecContext * avctx)
> > {
> >     BFIContext *bfi = avctx->priv_data;
> >     bfi->frame.reference = 1;
> >     bfi->frame.buffer_hints =
> >         FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_READABLE |
> >         FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
> >     avctx->pix_fmt = PIX_FMT_PAL8;
>
> >     bfi->frame.data[0] = NULL;
>
> things are 0 by default
>
Removed that line...

>
>
> [...]
> >     while (dst != frame_end) {
> >         byte = *buf++;
> >         code = byte >> 6;
> >         length = byte & ~0xC0;
> >         switch (code) {
> >         case 0:                //Normal Chain
> >             if (length == 0) {
> >                 length = bytestream_get_le16(&buf);
> >             }
> >             bytestream_get_buffer(&buf, dst, length);
>
> exploitable
>
Fixed.

>
>
> [...]
> >         case 2:                //Skip Chain
> >             if (length == 0) {
> >                 length = bytestream_get_le16(&buf);
> >             }
> >             if (length == 0)
> >                 goto finish;
> >             dst += length;
> >             av_log(NULL,AV_LOG_INFO, "\n[DECODER] Skip Chain.");
> >             break;
> >         case 3:                //Fill Chain
>
> >             if (length == 0) {
> >                 length = bytestream_get_le16(&buf);
> >             }
>
> duplicate code
>
Refactored the length and offset setting parts to outisde the switch.

>
>
> [...]
> >     while(height--)
> >     {
> >         memcpy(dst, src, avctx->width);
> >         src += avctx->width;
> >         dst += wrap_to_next_line + avctx->width;
> >     }
>
> this can be simplified
>
I redefined wrap to linesize and now, dst += wrap_to_next_line...was that
the only simplification you intended or are there some more?
-----------------
Sisir Koppaka



More information about the FFmpeg-soc mailing list