bitbank2 / JPEGDEC

An optimized JPEG decoder for Arduino
Apache License 2.0
366 stars 47 forks source link

Trying to reduce the size of JPEGIMAGE structure #15

Closed rgomezwap closed 3 years ago

rgomezwap commented 3 years ago

Hi,

I have started using the JPEGDEC library. I use ESP32 hardware and ESP_IDF SDK. It has been easy to implement with the current documentation. Everything works well. In my case I need to balance the decoding speed with the memory used. I have modified the MAX_BUFFERED_PIXELS value to (16 * 8) and it is slower but it still works. And I have tried to lower the JPEG_FILE_BUF_SIZE value below 2048, but decoding fails. Can you help me with the minimum values of the buffers of the JPEGIMAGE structure to reduce the size.

Thanks

bitbank2 commented 3 years ago

What is the maximum amount of RAM you can spare?

rgomezwap commented 3 years ago

In the original source code the JPEGIMAGE structure occupies about 17,000 bytes. I have reduced it to 14,000 bytes. It would be great to work with 10,000 bytes at the cost of speed, if possible. JPEG images are always in FLASH memory that is mapped as normal memory, so I try to avoid intermediate read buffers as in the case of SD files.

bitbank2 commented 3 years ago

I use the pixel buffer during the creation of the Huffman tables and for the dithering option. I also use the file buffer during the parsing of the JPEG header info. It would be difficult to shrink them beyond the limits imposed by this re-use. There is another Arduino JPEG library that uses less RAM, but it's slower.