-
Notifications
You must be signed in to change notification settings - Fork 36
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
RLE code might be wrong #3
Comments
Can you provide an input that can exploit that? I'm not seeing what you say sorry, I might be too tired. |
This is what I get:
Result
Then, looking at the output stream, I see many missed opportunities to compress, ideal with the decoder expectations would be:
If the first bytes in the input picture are not repeating at least 4 times, then the first byte in the output stream is wrong. TLDR: I'm not sure about the line |
So let me get this clear: You are just saying that the compressor is not optimal, but it works, right? |
First question, yes it works suboptimal. The first test I give it was with quasi random picture, and it failed but because it overflowed, but the error was between the keyboard and the chair. |
There is no escape code in the RLE encoding code in PHP if the "pixel/color" to be encoded has a value higher than 0x80 and happens only once. In that case, the PHP code will output the pixel -as-is-. However, when decoding, it'll be skipped because it'll be seen as "RLE length" code, and will repeat the next pixel (pix & 0x7F) times.
Also, to speed up the PHP image encoding code, it'll be better to preallocate the output array and access it with iterators, instead of constantly growing it.
The text was updated successfully, but these errors were encountered: