Missing data in compressed stream
Raphael-Boichot opened this issue · comments
Hello again.
So, I'm using the library on Pi Pico to record the stream from a camera to SD card. For some reason I need to upscale images between 2x and 10x and I deal with that during encoding. I can process pretty large images.
What I get is confusing. On the same run, continuously recording, I can get perfect images like this :
Or completely broken images like these:
Broken images have always too short uncompressed data compared to WIDTH*HEIGHT.
I've checked the image with https://www.nayuki.io/page/png-file-chunk-inspector and the error is always the same, but data can be more or less damaged.
Do you have an idea of what could be the error and side question: can I bound the memory usage during the call ? I indeed suspect memory issues even I I have plenty of memory left after compiling (about 60 extra kB).
I'll take a look
OK, I got the issue: when png.addLine(ucLine) is repeated several times with the same data, the code has unexpected output. Here's a minimal code to reproduce the bug :
code.txt
It appears only at certain resolutions and for certain compressing levels
After some more tests, I think this is an issue with the filesystem or some variable initialization. The first image is always good whatever the used parameters and the issue appears always after consecutive recordings.
Looks like something is not initialized again at the end of conversion/writing. If I soft reboot the Pi pico, first image is good again.
Problem fixed: incompatibility between PNGenc and my TFT library