Protection from attempting to do SIMD rans encoding on small data#137
Merged
Conversation
daviesrob
reviewed
Jun 26, 2025
Comment on lines
+1394
to
+1398
| free(packed); | ||
| return rans_compress_to_4x16(orig_in, orig_in_size, | ||
| out, out_size, | ||
| orig_order & ~(RANS_ORDER_X32 | | ||
| RANS_ORDER_SIMD_AUTO)); |
Member
There was a problem hiding this comment.
This works, but wouldn't it be simpler to just drop X32 mode and carry on:
do_simd = 0;
out[0] &= ~RANS_ORDER_X32;so that you avoid having to re-do all the RLE / packing work? (And the same below...)
c35d339 to
eddb896
Compare
Collaborator
Author
|
Also added some test data to demonstrate the SIMD issue. |
dfcc6ad to
f77342d
Compare
We can't just change do_simd as we may then have a combination of SIMD (pack or rle-meta) and non-SIMD (rle-meta or rle-data). So instead we remove the ability to do SIMD. This only happens when we have large blocks of data that enable SIMD mode which then turn out to be heavily compressible after PACK or RLE to yield a small sub-stream which isn't SIMD compressible.
f77342d to
448b1b9
Compare
Member
|
Fixed a minor white-space change... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We can't just change do_simd as we may then have a combination of SIMD (pack or rle-meta) and non-SIMD (rle-meta or rle-data). So instead we remove the ability to do SIMD and call again.
This only happens when we have large blocks of data that enable SIMD mode which then turn out to be heavily compressible after PACK or RLE to yield a small sub-stream which isn't SIMD compressible.