[Libav-user] Handling of 24 bit audio in libav* and libswresample

Paul B Mahol onemda at gmail.com
Tue Jun 4 13:34:43 CEST 2013

On 6/4/13, Hendrik Schreiber <hs at tagtraum.com> wrote:
> Hello everybody:
> I'm working on a little (java) library for decoding audio using
> FFmpeg/libav* and have some questions regarding the handling of 24 bit
> audio.
> 1. (SHIFTING) When decoding, 24bit audio is apparently shifted, i.e. 24bit
> become 32bit, as there is no 24bit AVSampleFormat. Am I right to assume that
> the data is shifted toward the most significant byte? I.e. the most
> significant 3 bytes are the same as the original 24bit?
> Or is the most significant byte simply "sign-extended" and the three least
> significant bytes are the original 24bit?
> 2. (SWRESAMPLE) I'm using libswresample to, well, resample data, get rid of
> planar formats etc. It's working great. libswresample also accepts
> AVSampleFormat parameters for input and output format. This implies that it
> does not support any conversion to true 24bit, represented by 3 bytes.
> Correct?
> 3. (CODEC) What is the recommend way to produce 24bit audio? After decoding
> (and potentially resampling), should I use the corresponding codec (e.g.
> AV_CODEC_ID_PCM_S24LE) to produce the data in the format I'm interested in?
> Or is there another, better way?

There should be dithering applied, see output_sample_bits option.

> Thanks in advance.
> -hendrik
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user

More information about the Libav-user mailing list