Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
FLAC
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
FLAC
(section)
Add topic