Open ThomasHabets opened 1 year ago
Thanks for reporting this.
I have updated the example in the readme, the variable source_block_size
was used for 2 different purposes, so I have modified that.
The source_block_length parameter should actually be the total size of your block (3684 bytes)
let source_block = decoder.decode(3684);
I have added a new automatic test with your use-case. See
https://github.com/ypo/raptor/blob/dc1bfa27f8a51a7363cca1609aa3ee110ccac1fd/tests/raptor.rs#L152
Sorry I can't share code (out of my control), but here's a description. Hopefully reproducible from my description. I'm working on getting the code approved for release.
Versions
What I was doing
I took the example code:
And I set the
source_data
to be 3684 bytes (a random example file), andmax_source_symbols
to 19 (chosen in order to get ~200 byte chunks, which is a requirement to me).This produced a bunch of 194 byte chunks.
When decoding (I took example from the same place):
I set
encoding_symbol_length
to 194 and source_block_size = 19 (per above), and ran it. It almost works perfectly. First of all of course the file is two bytes too big. I expected this, since 19*194 is 3686. I expected two null bytes at the end, though, which would be truncatable. But what actually happens is that the two extra null bytes are one each at the end of the last two blocks. That is, one at position 3686, and one at position 3492 (194 bytes earlier).This seems like a bug to me. Surely giving non-multiple input should still produce the correct output?
Workaround
I successfully worked around this by padding the input itself to 3686 bytes. Not sure if it needs to be a multiple of 194 or 19. After doing that a simple truncation to 3684 produces perfect output.