-
Notifications
You must be signed in to change notification settings - Fork 2.3k
decodecorpus #1664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
decodecorpus #1664
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
734eff7
enable repeat mode on rle
ephiepark c7c1ba3
Fix a constraint stricter than the spec
ephiepark 36d0bc2
Merge pull request #5 from ephiepark/decodecorpus
ephiepark 01e8384
Add test case for short bistream
ephiepark 9f4d71f
Merge pull request #6 from ephiepark/decodecorpus
ephiepark 2830952
reflect code review comments
ephiepark 01f5b5d
Merge pull request #7 from ephiepark/decodecorpus
ephiepark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1184,6 +1184,68 @@ static int basicUnitTests(U32 seed, double compressibility) | |
| } | ||
| DISPLAYLEVEL(3, "OK \n"); | ||
|
|
||
| /* Small Sequence Section bug */ | ||
| DISPLAYLEVEL(3, "test%3i : decompress blocks with small sequences section : ", testNb++); | ||
| { /* This test consists of 3 blocks. Each block has one sequence. | ||
| The sequence has literal length of 10, match length of 10 and offset of 10. | ||
| The sequence value and compression mode for the blocks are following: | ||
| The order of values are ll, ml, of. | ||
| - First block : (10, 7, 13) (rle, rle, rle) | ||
| - size of sequences section: 6 bytes (1 byte for nbSeq, 1 byte for encoding mode, 3 bytes for rle, 1 byte bitstream) | ||
| - Second block : (10, 7, 1) (repeat, repeat, rle) | ||
| - size of sequences section: 4 bytes (1 byte for nbSeq, 1 byte for encoding mode, 1 bytes for rle, 1 byte bitstream) | ||
| - Third block : (10, 7, 1) (repeat, repeat, repeat) | ||
| - size of sequences section: 3 bytes (1 byte for nbSeq, 1 byte for encoding mode, 1 byte bitstream) */ | ||
|
|
||
| unsigned char compressed[] = { | ||
| 0x28, 0xb5, 0x2f, 0xfd, 0x24, 0x3c, 0x35, 0x01, 0x00, 0xf0, 0x85, 0x08, | ||
| 0xc2, 0xc4, 0x70, 0xcf, 0xd7, 0xc0, 0x96, 0x7e, 0x4c, 0x6b, 0xa9, 0x8b, | ||
| 0xbc, 0xc5, 0xb6, 0xd9, 0x7f, 0x4c, 0xf1, 0x05, 0xa6, 0x54, 0xef, 0xac, | ||
| 0x69, 0x94, 0x89, 0x1c, 0x03, 0x44, 0x0a, 0x07, 0x00, 0xb4, 0x04, 0x80, | ||
| 0x40, 0x0a, 0xa4 | ||
| }; | ||
| unsigned int compressedSize = 51; | ||
| unsigned char decompressed[] = { | ||
| 0x85, 0x08, 0xc2, 0xc4, 0x70, 0xcf, 0xd7, 0xc0, 0x96, 0x7e, 0x85, 0x08, | ||
| 0xc2, 0xc4, 0x70, 0xcf, 0xd7, 0xc0, 0x96, 0x7e, 0x4c, 0x6b, 0xa9, 0x8b, | ||
| 0xbc, 0xc5, 0xb6, 0xd9, 0x7f, 0x4c, 0x4c, 0x6b, 0xa9, 0x8b, 0xbc, 0xc5, | ||
| 0xb6, 0xd9, 0x7f, 0x4c, 0xf1, 0x05, 0xa6, 0x54, 0xef, 0xac, 0x69, 0x94, | ||
| 0x89, 0x1c, 0xf1, 0x05, 0xa6, 0x54, 0xef, 0xac, 0x69, 0x94, 0x89, 0x1c | ||
| }; | ||
| unsigned int decompressedSize = 60; | ||
|
|
||
| ZSTD_DStream* const zds = ZSTD_createDStream(); | ||
| if (zds==NULL) goto _output_error; | ||
|
|
||
| CHECK_Z( ZSTD_initDStream(zds) ); | ||
| inBuff.src = compressed; | ||
| inBuff.size = compressedSize; | ||
| inBuff.pos = 0; | ||
| outBuff.dst = decodedBuffer; | ||
| outBuff.size = CNBufferSize; | ||
| outBuff.pos = 0; | ||
|
|
||
| while (inBuff.pos < inBuff.size) { | ||
| CHECK_Z( ZSTD_decompressStream(zds, &outBuff, &inBuff) ); | ||
| } | ||
|
|
||
| { XXH64_state_t xxhStateIn, xxhStateOut; | ||
|
||
| U32 checkIn, checkOut; | ||
| XXH64_reset(&xxhStateIn, 0); | ||
| XXH64_reset(&xxhStateOut, 0); | ||
|
|
||
| XXH64_update(&xxhStateIn, decompressed, decompressedSize); | ||
| XXH64_update(&xxhStateOut, outBuff.dst, outBuff.pos); | ||
|
|
||
| checkIn = (U32)XXH64_digest(&xxhStateIn); | ||
| checkOut = (U32)XXH64_digest(&xxhStateOut); | ||
| CHECK(checkIn != checkOut, "Checksum does not match"); | ||
| } | ||
|
|
||
| ZSTD_freeDStream(zds); | ||
| } | ||
| DISPLAYLEVEL(3, "OK \n"); | ||
|
|
||
| DISPLAYLEVEL(3, "test%3i : dictionary + uncompressible block + reusing tables checks offset table validity: ", testNb++); | ||
| { ZSTD_CDict* const cdict = ZSTD_createCDict_advanced( | ||
| dictionary.start, dictionary.filled, | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it's slightly stronger than
CHECK_Z():presuming the frame is complete (is it ?), you want a return value
0, to indicate that the decoder has reached the end of frame. You also want to ensure it has consumed the entire input (inBuff.pos == inBuff.compressedSize).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's a complete frame.