Skip to content

Fix integer overflow during unfolding of the rice residual#61

Merged
mewmew merged 1 commit intomewkiz:masterfrom
MarkKremer:master
Oct 24, 2023
Merged

Fix integer overflow during unfolding of the rice residual#61
mewmew merged 1 commit intomewkiz:masterfrom
MarkKremer:master

Conversation

@MarkKremer
Copy link
Copy Markdown
Collaborator

@ktmf01
Copy link
Copy Markdown

ktmf01 commented Oct 24, 2023

This is additionally documented here: https://www.ietf.org/archive/id/draft-ietf-cellar-flac-12.html#name-rice-coding

When folding (i.e., zig-zag encoding) the residual sample values, no extra bits are needed when the absolute value of each residual sample is first stored in an unsigned data type of the size of the last step, then doubled, and then has one subtracted depending on whether the residual sample was positive or negative. Many implementations, however, choose to require one extra bit of data type size so zig-zag encoding can happen in one step and without a cast instead of the procedure described in the previous sentence.

edit: uhh, I just realize this is for encoding. For decoding it is a little different.

@mewmew
Copy link
Copy Markdown
Member

mewmew commented Oct 24, 2023

Wonderful! Thanks @MarkKremer for the fix and @ktmf01 for the docs : )

This is truly open source at its finest!

Cheers,
Robin

@mewmew
Copy link
Copy Markdown
Member

mewmew commented Oct 24, 2023

The v1.0.9 release has now been tagged.

Very happy to see that the audio samples of the IETF test cases are now correctly decoded by mewkiz/flac.

Cheerful regards,
Henry & Robin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants