[Ffmpeg-devel] Does FLAC decoder support 24-bit files?

Mike Melanson mike
Tue Oct 25 22:03:41 CEST 2005

Dave Chapman wrote:
> Just to clarify, my question was about the FLAC decoder itself, rather
> than ffmpeg.  I've built my own decoder around the flac.c file - using
> my own FLAC parser and the bare minimum of support functions from ffmpeg
> (namely the bitreading and golomb routines).
> So I'm simply asking if flac.c itself (which decodes the data into
> 32-bit ints) is known to be able to handle 24-bit audio.

	A quick tour through the flac.c source code indicates that it is aware 
of 20- and 24-bit depths (in addition to 8, 12, and 16); this is 
evidenced by sample_size_table[]. While the data is decoded an array of 
signed 32-bit numbers (int32_t *decoded[MAX_CHANNELS]), the final 
samples are stuffed into signed 16-bit numbers in flac_decode_frame(). I 
imagine that the truncating behavior is not correct in this case.

	If you are in the hacking mood, you could try modifying the relevant 
code starting around line 722 ("switch(s->decorrelation)"). Find the 
channel case that represents your files and if s->curr_bps is 20 or 24, 
appropriately reduce of the precision of the samples from s->decoded[][].

	...I think...
	-Mike Melanson

More information about the ffmpeg-devel mailing list