Add optional FLAC compression #76
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! I added the ability for the encoder to optionally choose a prediction method for better compression. I'm not sure the API is great but it seems to work and allows this library to produce files smaller than their input, see the Results at the end.
Bonus: The change in
frame.go
may be inappropriate for this PR but it fixes an out-of-index error I was getting inwav2flac
on all files.How
Added an opt-in prediction analysis pass.
Encoder
now has a boolean fieldAnalysisEnabled
(helperEnablePredictionAnalysis(true)
).PredVerbatim
and chooses the smallest of:analyseFixed()
picks the best order and Rice-k.libFLAC exposes a range of parameters to tune the encoding process. This PR introduces one knob to try to pick the best prediction method.
Results
Here's what I got when enabling prediction analysis on various audio files:
There's an expected increase in encoding resources:
The new
enc_benchmark_test.go
created these results.Review
I'm open to feedback or questions, or if more tests are needed. I have no personal need for this, just thought it would be fun to try to enhance things a bit.