Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
FLAC
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Encoding and decoding === [[File:FLAC_1.5.0_screenshot.webp|thumb|250x250px|Screenshot of <code>flac</code> command-line software]] The FLAC encoding algorithm consists of multiple stages. In the first stage, the input audio is split into blocks. If the audio [[stereo|contains multiple channels]], each channel is encoded separately as a subblock. The encoder then tries to find a good mathematical approximation of the block, either by fitting a simple [[polynomial]], or through general [[linear predictive coding]]. A description of the approximation, which is only a few bytes in length, is then written. Finally, the difference between the approximation and the input, called residual, is encoded using [[Rice coding]]. In many cases, a description of the approximation and the encoded residual takes up less space than using [[pulse-code modulation]].<ref name="format-about"/> The decoding process is the reverse of encoding. The compressed residual is first decoded.<ref>{{cite web |title=stream_decoder.c |url=https://gitlab.xiph.org/xiph/flac/-/blob/a2fe43f64e7ce8057fb274c64996568d69b301b8/src/libFLAC/stream_decoder.c |website=libFLAC |access-date=19 February 2022 |ref=libflac_stream_decoder}}</ref><ref>[[#libflac_stream_decoder|libFLAC/stream_decoder.c]], line 2734.</ref> 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.<ref>{{cite web |title=lpc.c |url=https://gitlab.xiph.org/xiph/flac/-/blob/a2fe43f64e7ce8057fb274c64996568d69b301b8/src/libFLAC/lpc.c |website=libFLAC |access-date=19 February 2022 |ref=libflac_lpc}}</ref><ref>[[#libflac_lpc|libFLAC/lpc.c]], lines 813β820.</ref> As FLAC [[lossless compression|compresses losslessly]], the decoded waveform is identical to the waveform before encoding. For two-channel stereo, the encoder may choose to [[joint stereo|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.<ref>{{Cite web |title=FLAC Format Specification |url=https://xiph.org/flac/format.html |access-date=19 February 2022 |website=FLAC}}</ref> Even though the [[reference implementation|reference encoder]] uses a single block size for the whole stream,<ref name="format-about"/> FLAC allows the block size in samples to vary per block.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)