Bodmer / TJpg_Decoder

Jpeg decoder library based on Tiny JPEG Decompressor
Other
228 stars 43 forks source link

JPG Decoder not correctly decoding. height is always 0 #34

Closed moefear85 closed 2 years ago

moefear85 commented 2 years ago

I've tried several images from the web, as well as frames captured directly with the esp32-cam module, directly in jpeg format (no conversion). All images have dimensions 320x240. Yet TJpg_Decoder always returns 320 for the width correctly, but always returns 0 for the height. The images are always noise, with general features recognizable that resemble the original image.

P.S: I'm using esp-idf directly. I included a CMakeLists.txt file in the src folder to make it directly usable as a component. I also did the same for tft_espi (which itself works great).

I've tried with master & with 1.0.2

Bodmer commented 2 years ago

It sounds like a byte swap problem for the rendering. Try putting tft.setSwapBytes(true); // Also try false In your sketch setup() .

Does a sketch example work OK?

Provide an example image.

I am working away so it will be 2 weeks before I can investigate.

Bodmer commented 2 years ago

I assume this has been resolved. I am not able to help without further information.

moefear85 commented 2 years ago

Hi Sorry it took so long to respond... I should have mentioned earlier that I already tried setSwapBytes() both with true and false, as well as so many other possibilities that I've exhausted. Is really noone else experiencing anything similar?

To be honest, I was hoping you, knowing the internals of the code very well, might have a clue as to how/why the decoder would be able to detect the width correctly, but not the height. Given faint outlines are recognizable, it seems lower coefficients of the FFT are being processed, but not higher frequency ones.

No offense, I really appreciate your software, especially tft_espi (very fast, only one that supports parallel, I've even taken first steps to expose it to micropython). But given that nothing worked, I eventually moved to JPEGDEC. I modified the callback that draws to the tft so that it accepts data from JPEGDEC, and it is working flawlessly. But again, with the same data, the same sources of images, TJpg_Decoder simply fails to properly decode the image. There might be some extremely subtle difference in what I'm doing for each library that would matter, but I just can't see what it would be. I paid especial attention not to commit any off-by-1 errors when reading/writing any buffers, but I can't guarantee nothing is slipping my mind.

I'll try a sketch example later. Worth mentioning though, I'm working in esp-idf, not Arduino, but I import Arduino-as-Component. I created a CMakeLists.txt file for tft_espi so I can also import that in esp-idf.

Bodmer commented 2 years ago

Post an example image that fails.

Bodmer commented 2 years ago

I have upgraded the library master to use the latest decoder engine. However the decoding process has not changed significantly. Also check your compiler optimisation settings are not having an effect, I tend to use Os as the optimisation level.