[Libav-user] Converting audio sample buffer format

Brad O'Hearne brado at bighillsoftware.com
Tue Feb 26 20:26:07 CET 2013

On Feb 26, 2013, at 11:51 AM, Paul B Mahol <onemda at gmail.com> wrote:
> Planar is used if sample_fmt is set to planar one - in this case for
> every channel, channel samples are stored in separate buffer eg.
> p->data[X] where X is channel number.
> Interleaved use only p->data[0] and every channel sample comes one
> after another.
> Samples are always considered to be in native endiannes (you need to
> do swapping on your own)

Paul -- hey great, this is a good start for me. So if I am understanding you correctly: 

*** Channel layout

1) Planar 
channel 1 = data[0]
channel 2 = data[channel 1 data length]

2) Interleaved
channel 1, sample 1 = data[0]
channel 2, sample 1 = data[channel 1 sample length]

Follow up question -- if I have 2 channels in play, is there a 1:1 relationship between channel 1 and channel 2 samples? In other words, for every channel 1 sample will there be a channel 2 sample? (Obviously effects buffer lengths and interleaving). 

If this is so....perhaps you can expound a little more on how AV_SAMPLE_FMT_S16 is laid out (think I know, just want to confirm).

Thx for your help....


More information about the Libav-user mailing list