[FFmpeg-devel] [PATCH] IFF PBM/ILBM decoder

Michael Niedermayer michaelni
Thu Jan 28 21:06:43 CET 2010


On Wed, Jan 27, 2010 at 10:46:14PM +1100, pross at xvid.org wrote:
> Hi, the war against Electronic Arts formats continues.
> 
> samples: /Mplayer/incoming/lbm
>          http://samples.mplayerhq.hu/image-samples/ASH.LBM
> 
> Some identing cleanup is required after applying this patch.
> 
> -- Peter
> (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)

[..]
[...]
> +/**
> + * Interleaved memcpy
> + */
> +static void imemcpy(uint8_t *dst, const uint8_t *buf, int x, int bps, int plane, int length)

const buf

[...]
> +static int decode_frame_byterun1(AVCodecContext *avctx,
> +                            void *data, int *data_size,
> +                            AVPacket *avpkt)
> +{
> +    AVFrame *frame = avctx->priv_data;
> +    const uint8_t *buf = avpkt->data;
> +    int buf_size = avpkt->size;
> +    const uint8_t *buf_end = buf+buf_size;
> +    int planewidth = avctx->width / avctx->bits_per_coded_sample;
> +    int y, plane, x;
> +
> +    if (avctx->reget_buffer(avctx, frame) < 0){
> +        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
> +        return -1;
> +    }
> +

> +    for(y = 0; y < avctx->height ; y++ ) {
> +        uint8_t *row = &frame->data[0][ y*frame->linesize[0] ];
> +        if (avctx->codec_tag == MKTAG('I','L','B','M')) { //interleaved
> +            memset(row, 0, avctx->width);
> +            for (plane = 0; plane < avctx->bits_per_coded_sample; plane++) {
> +                for(x = 0; x < planewidth && buf < buf_end; ) {
> +                    char value = *buf++;
> +                    int length;
> +                    if (value >= 0) {
> +                        length = value + 1;
> +                        imemcpy(row, buf, x, avctx->bits_per_coded_sample, plane, FFMIN(length, buf_end-buf));
> +                        buf += length;
> +                    } else if (value > -128) {
> +                        length = -value + 1;
> +                        imemset(row, *buf++, x, avctx->bits_per_coded_sample, plane, length);

these look like they are missing output buffer size checks

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

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- 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-devel/attachments/20100128/cdc7f545/attachment.pgp>



More information about the ffmpeg-devel mailing list