[Libav-user] Understanding AVFrame::linesize (Audio)

Whiz Kid whizkid667 at gmail.com
Fri Dec 4 13:49:25 CET 2015

As per the doucmentation of AVFrame, for audio, lineSize is size in bytes
of each plane and only linesize[0] may be set. But however, am unsure
whether lineszie[0] is holding per plane buffer size or is it the complete
buffer size and we have to divide it by no of channels to get per plane
buffer size.

For Example, when I call int data_size = av_samples_get_buffer_size(NULL,
iDesiredNoOfChannels, iAudioSamples, (AVSampleFormat)iDesiredFormat, 0) ;
For iDesiredNoOfChannels = 2, iAudioSamples = 1024 & iDesiredFormat =
AV_SAMPLE_FMT_FLTP data_size=8192. Pretty straightforward, as each sample
is 4 bytes and since there are 2 channels total memory will be (1024 * 4 *
2) bytes. As such lineSize[0] should be 4096 for planar audio. data[0] &
data[1] should be each of size 4096. However, pFrame->lineSize[0] is giving
8192. So to get the size per plane, I have to do pFrame->lineSize[0] /
pFrame->channels. Isn't this behaviour different from what the
documentation suggests or is my understanding of the documentaion wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20151204/12d5dd4c/attachment.html>

More information about the Libav-user mailing list