[Libav-user] Sample format questions

Brad O'Hearne brado at bighillsoftware.com
Tue Mar 26 19:02:40 CET 2013


On Mar 26, 2013, at 10:29 AM, Paul B Mahol <onemda at gmail.com> wrote:

Thx for the reply!

> sample format is set by decoder to what sample format decoder outputs its data,
> similar apply for encoder input.

Yes, I'm actually encoding, but point taken. Sample format is by the encoder, true. However, in my scenario I have an intermediate step prior to getting to the encoder. I am receiving a sample buffer from QTKit capture which is in a different sample format than the encoder is looking for. In my case, the audio encoder is adpm_swf (I am encoding video and audio to an FLV video file). adpm_swf is looking for a sample format of AV_SAMPLE_FMT_S16, which is not the format being received from capture. The format I am receiving from capture is 

Linear PCM, 32 bit little-endian floating point, 2 channels, 44100 

So I have to resample the decompressed audio sample received from capture so that it is in a format of AV_SAMPLE_FMT_S16 before passing it to the encoder. Coming in from QTKit, it obviously knows nothing about Libav constants. I have all of the necessary attributes on the sample buffer, which I want to use to have Libav deliver the proper sample format without me hardcoding it (which it is now, I'm using AV_SAMPLE_FMT_FLT). However, for some reason, the audio when encoded is garbage, so I'm trying to verify the entire processing pipeline, eliminating assumptions. One assumption I've made is the sample format, another is the endianness -- I'm interested in functions to return each. Does such a function exist for returning what sample format should be used, given linear/planar, bytes/endianness, channels, etc.?

> any planar sample format with more than 1 channel is not interleaved.

Does it follow then that any linear format with more than one channel IS interleaved? 

> As already mentioned data is always in native endian, its decoder
> responsibility....

Is there a function that returns what endianness the sample format is presently using (and I'm not looking for a function or doc that specifies something along the lines of "native" here -- I'm looking for the specific endianness so that I can verify that it is indeed native. 

Thanks, 

Brad


More information about the Libav-user mailing list