[Libav-user] Audio conversion from planar to non-planar formats

Hendrik Leppkes h.leppkes at gmail.com
Wed Jun 26 09:02:51 CEST 2013

On Wed, Jun 26, 2013 at 8:01 AM, Taha Ansari <mtaha.ansari at gmail.com> wrote:
> Hi!
> I am working on audio conversion. Looking at different example online, I
> have been successfully able to convert FLTP format to S16. To my
> understanding, FLTP is planar, with values in floating range: -1.0 to +1.0.
> This converts to S16 just fine. Now, I want to convert audio coming from
> S16P format to S16 format.
> Because of initial success with planar to S16 (FLTP to S16), I assume I am
> interpreting planar data correctly, but, when I convert from S16P to S16, I
> get lots of artifacts in destination audio (noise is not clear, and is
> faster than original track).
> I am requesting could anyone kindly guide me on how to do successful
> conversion from S16P to S16 formats? I am simply amazed how such an
> apparently simple task is taking me forever, but still gets me nowhere.
> Thanks in advance @all!

Here, have some (pseudo) code:

int16_t *dst = av_malloc(frame->channels * frame->nb_samples * 2);
int16_t **src = (int16_t **)frame->extended_data;
for (int i = 0; i < frame->nb_samples; i++) {
  for (int ch = 0; ch < frame->channels; ch++) {
    dst[i * frame->channels + ch] = src[ch][i];

More information about the Libav-user mailing list