[Flac-dev] Re: FLAC support for floating point

Brian Willoughby brianw at sounds.wa.com
Sat Mar 31 13:48:38 PDT 2007


Hi Josh,

The short version of this message is that float support would  
necessarily be very restricted, and thus I agree that flac should not  
support float by default.  Tools could be created based on libFLAC,  
but there would be some significant caveats, and nothing would  
perform any different than converting from float to integer outside  
flac.  It might be more convenient (and faster) to handle it with one  
tool, though.


The long version:

float to integer is still lossy unless you take into consideration  
that the lost precision cannot be used at the DAC stage.  Even with  
audio data in the standard +/- 1.0 range, half of that range will  
have finer resolution than 24-bit integer.  In other words, all  
samples in the +/- 0.5 range will have one or more fractional bits  
which cannot be represented in 24-bit fixed point integer.  It's  
debatable whether these fractional bits are important, since they  
cannot be converted to analog with current technology, but they are  
lost.  If you don't dither when converting to 24-bit int, they might  
cause (barely) audible quantization noise.

The exception to the above would be when the source material is 24- 
bit integer that has not been processed while in float format,  
because integer to float to integer is lossless for 24-bit audio.

Regarding your idea, you cannot store even the standard float audio  
range in a 24-bit integer without loss because you're losing the  
exponent, and all numbers are normalized.  Any audio created in float  
format is going to have fractional bits that would be lost when  
converted to 24-bit integer.  e.g. a sample value of -1 has an  
exponent of 1 and all bits match the 24-bit integer (there happen to  
be 23 zero bits).  Samples between -1 and +1 have an exponent of 0.5  
and there is an extra fractional bit in the floating point  
representation that would be lost when converted to 24-bit integer.   
Samples between -0.5 and +0.5 have two fractional bits, and so one  
with -0.25 to +0.25 etc.  I'm not sure I have these exactly right,  
but I hope that I'm illustrating what happen in float because of the  
fact that values are always normalized according to the most  
significant one bit.  Any processing done in floating point is going  
to create all kinds of fractional values that would be lost in fixed  
point.

Brian Willoughby
Sound Consulting


On Mar 31, 2007, at 07:41, Josh Green wrote:
The point was also that 32 bit float data can be stored
in 24 bit without loss of precision, provided that the audio is between
+/- 1.0 since the mantissa of 32 bit float data is 23 bits plus the
implicit 1 digit.

Now that I think about it though, while indeed the range of floating
point numbers could be stored in 24 bit integer, perhaps the scale would
be wrong when assuming its 24 bit integers.  As long as the decoding
side understood that, it could be reproduced as floating point again,
but that would require a special decoder or change to the FLAC format,
as you mentioned.  Just kicking around ideas.
Regards,

	Josh Green






More information about the Flac-dev mailing list