FLAC is a lossless encoding of
linear pulse-code modulation data.
File structure A FLAC file consists of the
magic number fLaC,
metadata, and encoded audio. The description of the mathematical approximation is then used to calculate a waveform. The result is formed by adding the residual and the calculated waveform. As FLAC
compresses losslessly, the decoded waveform is identical to the waveform before encoding. For two-channel stereo, the encoder may choose to
joint-encode the audio. The channels are transformed into a side channel, which is the difference between the two input channels, and a mid channel, the sum of the two input channels. In place of a mid channel, the left channel or the right channel may be encoded instead, which is sometimes more space-efficient. Even though the
reference encoder uses a single block size for the whole stream, FLAC is optimized for decoding speed at the expense of encoding speed. A benchmark has shown that, while there is little variation in decoding speed as compression level increases, beyond the default compression level 5, the encoding process takes up considerably more time with little space saved compared to level 5.
Implementation Alongside the format, the FLAC project also contains a
free and open-source reference implementation of FLAC called libFLAC. libFLAC contains facilities to encode and decode FLAC data and to manipulate the metadata of FLAC files. libFLAC++, an
object-oriented wrapper around libFLAC for
C++, and the
command-line programs flac and metaflac, are also part of the reference implementation. The FLAC format, along with libFLAC, are not known to be covered by any
patents, and anyone is free to write their own implementations of FLAC. == Comparison to other formats ==