[FFmpeg-devel] [PATCH] HAM6/HAM8 support for IFF demuxer/decoder

Martin Storsjö martin
Wed May 5 15:26:48 CEST 2010

On Wed, 5 May 2010, Sebastian Vater wrote:

> Martin Storsj? a ?crit :
> > Here, you're making the extradata format totally dependent on the layout 
> > of the IffExtraContext struct. If you upgrade libavcodec to another 
> > version, where this struct has changed, things will break. Implementations 
> > on different architectures with different endianess, word lengths or 
> > struct packings will have incompatible extradata formats. You should be 
> > able to do the demuxing on one machine and the decoding (given codec 
> > parameters, AVPackets and extradata) on a completely different machine.
> >
> > Therefore, the extradata format for a codec should be fixed and 
> > well-defined, since it is part of the external interface for anybody using 
> > libavcodec (which is a whole lot more than just libavformat and ffmpeg.c).
> >
> > So instead of using a struct for that, manually pack and unpack the values 
> > that you need into a few bytes that you've allocated and kept track of. 
> > Try to make sure that you won't need to change the format, to keep 
> > compatibility.
> >   
> Do you have good sample on how to use extradata the proper way?

I don't know of any that does exactly this, off-hand, but whenever you use 
sizeof(IffExtraContext), use a fixed size, e.g. 4 or 8 or however much you 
think will be enough, and then e.g. use extradata[0] as one field, 
extradata[1] as another one, etc. Or if you need fields larger than one 
byte, use AV_WB16/AV_RB16 etc for writing/reading. Or if you want to store 
flags, pack them as single bits in one of the bytes.

// Martin

More information about the ffmpeg-devel mailing list