[FFmpeg-devel] [PATCH] IRCAM Sound Format demuxer
Michael Niedermayer
michaelni
Wed Apr 21 15:53:20 CEST 2010
On Tue, Apr 20, 2010 at 01:03:33PM -0500, Daniel Verkamp wrote:
[...]
> +static const uint32_t be_tags[] = {
> + 0x64A30200, // Sun (native)
> + 0x64A30400, // NeXT
> + 0x0001A364, // VAX
> + 0x0003A364, // MIPS (SGI)
> +};
> +
> +static const uint32_t le_tags[] = {
> + 0x64A30100, // VAX (native)
> + 0x64A30300, // MIPS (DECstation)
> + 0x0002A364, // Sun
> +};
> +
> +static int identify(uint32_t tag)
> +{
> + int i;
> +
> + for (i = 0; i < FF_ARRAY_ELEMS(be_tags); i++)
> + if (be_tags[i] == tag)
> + return 1;
> +
> + for (i = 0; i < FF_ARRAY_ELEMS(le_tags); i++)
> + if (le_tags[i] == tag)
> + return 0;
isnt a
if(t=a ||t=b || ...
simpler?
> +
> + return -1;
> +}
> +
> +static enum CodecID get_codec(uint32_t tag, int be)
> +{
> + const AVCodecTag *tags = be ? be_codec_tags : le_codec_tags;
> + enum CodecID codec_id = ff_codec_get_id(tags, tag);
> + if (codec_id == CODEC_ID_NONE)
> + codec_id = ff_codec_get_id(generic_codec_tags, tag);
> + return codec_id;
> +}
> +
> +static int probe(AVProbeData *p)
> +{
> + unsigned char *buf = p->buf;
> + int be, channels, sample_rate;
> + uint32_t tag;
> +
> + if (p->buf_size <= 16)
> + return 0;
> +
> + be = identify(AV_RB32(buf));
> + if (be < 0)
> + return 0;
> +
> + if (be) {
> + sample_rate = av_int2flt(AV_RB32(buf + 4));
> + channels = AV_RB32(buf + 8);
> + tag = AV_RB32(buf + 12);
> + } else {
> + sample_rate = av_int2flt(AV_RL32(buf + 4));
> + channels = AV_RL32(buf + 8);
> + tag = AV_RL32(buf + 12);
> + }
> +
> + if (sample_rate <= 0 || channels <= 0 || channels > 256)
> + return 0;
> +
> + tag = be ? AV_RB32(buf + 12) : AV_RL32(buf + 12);
a read_r32(uint8_t *, int endianness)
seems usefull here (iam not sure if we have something like this already)
> + if (get_codec(tag, be) == CODEC_ID_NONE)
> + return 0;
this isnt nice
someone might want to demux even unknown codecs
[..]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- 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/20100421/71b81dfc/attachment.pgp>
More information about the ffmpeg-devel
mailing list