bitbank2 / JPEGDEC

An optimized JPEG decoder for Arduino

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to "pause" and "resume" decoding?

C47D opened this issue · comments

Hi,

We were using tjpgd as JPEG decoder on a LVGL project and wondered if we could use JPEGDEC instead. Currently we decode the whole image in one step, but we have to dynamically allocate memory for the decoded image data. So I wonder if it's possible to pause the decoding of the image by returning an specific value on the draw callback, and then continue the decoding afterwards, this would allow is to allocate memory only for some MCUs and not the whole image.

I'm not well versed on JPEG decompressing but as far as I understand (correct me if I'm wrong) we would need to store the DC offset of the previous MCU to decompress the next one, so my question is pausing and resuming the decoding is possible?

The code can't be paused in its current form, but your particular case doesn't sound like it needs that. When you open the file, you have full knowledge of the image size and subsampling option. If you're interested in capturing a small window of the image, you know how much memory to allocate because you're choosing the window size. You can tell my library to deliver a single MCU at a time (setMaxOutputSize(1)) and then your draw code will just save the ones that it wants. Each draw call includes the x/y position of the MCU on the main image. Does that make sense? The possible MCU sizes decoded are: 8x8, 16x8, 8x16 and 16x16 (depending on the subsampling option).