[Libav-user] Understanding planar data arrangement in AVFrame

Nicolas George nicolas.george at normalesup.org
Mon May 6 15:10:55 CEST 2013

Le septidi 17 floréal, an CCXXI, Pradeep Karosiya a écrit :
> I'm trying to encode raw audio samples. Though encoding is working fine. I'm
> not able to understand some of the field of AVFrame specially related to
> planar data.
> Can someone explain what is the different between data and extended_data in
> AVFrame and how they are use during encoding. 

data serves when there are at most 8 channels, extended_data serves when
there are more using a mallocated array of pointers. If in doubt, use
extended_data, since it will always be a valid pointer, either to a
mallocated or just to data.

> I got the linesize which says that it contains the size of each channel. 
> But how the raw samples are stored in this structure.

One after the other. Just cast the pointer to an arithmetic type of the
correct size: "samples = (int16_t *)extended_data[channel]" for S16, etc.

> Also do I need explicitly free memory buffers allocated during encoding?

Depends how they were allocated. Using refcounted buffers is the preferred
method nowadays.


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130506/0bf1520b/attachment.asc>

More information about the Libav-user mailing list