[Ffmpeg-devel] [PATCH] CRYO APC demuxer

Michael Niedermayer michaelni
Sat Apr 7 14:27:41 CEST 2007


Hi

On Sat, Apr 07, 2007 at 03:01:38PM +0300, Anssi Hannula wrote:
> Hi!
> 
> Attached is a patch implementing a demuxer for CRYO APC, a simple audio
> format using ADPCM encoding.

[...]

> Index: libavcodec/adpcm.c
> ===================================================================
> --- libavcodec/adpcm.c	(revision 8638)
> +++ libavcodec/adpcm.c	(working copy)
> @@ -603,10 +603,16 @@
>      }
>  
>      c->channel = 0;
> -    c->status[0].predictor = c->status[1].predictor = 0;
>      c->status[0].step_index = c->status[1].step_index = 0;
>      c->status[0].step = c->status[1].step = 0;
>  
> +    if (avctx->extradata && avctx->extradata_size == 2 * sizeof(int)) {

this check is too unspecific it could very well be triggered for other codecs
too


> +        c->status[0].predictor = ((int*)avctx->extradata)[0];
> +        c->status[1].predictor = ((int*)avctx->extradata)[1];

not portable

[...]
> +    if (p->buf[0] == 'C' && p->buf[1] == 'R' &&
> +        p->buf[2] == 'Y' && p->buf[3] == 'O' &&
> +        p->buf[4] == '_' && p->buf[5] == 'A' &&
> +        p->buf[6] == 'P' && p->buf[7] == 'C')

a check based on AV_RL/B32() and MKTAG() would be simpler


[...]
> +    if (!st->codec->extradata) {
> +        if (st->codec)
> +             av_free(st->codec);

the if() is useless


> +        av_free(st);
> +        return AVERROR_NOMEM;
> +    }
> +    /* initial predictor values for adpcm decoder */
> +    ((int *)st->codec->extradata)[0] = get_le32(pb);
> +    ((int *)st->codec->extradata)[1] = get_le32(pb);

extradata must not contain anything in native endianness, just think what
happens if its stored and transferred to a big endian system ...

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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070407/8f8d3c7d/attachment.pgp>



More information about the ffmpeg-devel mailing list