bitbank2 / JPEGDEC

An optimized JPEG decoder suitable for microcontrollers and PCs.
Apache License 2.0
389 stars 46 forks source link

Seeing artifacts when using new cropping feature. #78

Closed andrewleek-droplab closed 3 months ago

andrewleek-droplab commented 3 months ago

Describe the bug Im attempting to utilized the new cropping feature but am getting artifacts on the right side of the lcd. The image size is 400x296, and I am trying to crop it down to 320x240.

To Reproduce Here is the code i am using: if (jpeg.openRAM((uint8_t *)fb->buf, fb->len, drawMCUs)) { jpeg.setPixelType(RGB565_BIG_ENDIAN); // The SPI LCD wants the 16-bit pixels in big-endian order jpeg.setCropArea(0,0,320,240); jpeg.decode(0,0,0); jpeg.close(); }

Expected behavior It should show a clean image without artifacting.

Image file you're having trouble with Attached is an image of what i am seeing. cropping_artifacts

Additional context Additionally I have set the crop area to (80,56,320,240) and the image displayed correctly, without artifacting.

bitbank2 commented 3 months ago

Can you share your whole test program?

bitbank2 commented 3 months ago

Never mind; I'm able to reproduce it. Will have a fix soon.

bitbank2 commented 3 months ago

ok, I pushed a fix; please give it a try.

andrewleek-droplab commented 3 months ago

Well that fixed the artifacting, but now the fps has dropped from around 17 to 10.

bitbank2 commented 3 months ago

Well that fixed the artifacting, but now the fps has dropped from around 17 to 10.

The cropping + variable number of MCUs per JPEGDraw call becomes quite complex, so I changed it to output a single MCU at a time. This feature was tested for full framebuffer output, that's why I missed the problem with JPEGDraw. I can take another pass to try to improve the speed again.

bitbank2 commented 3 months ago

ok, I added some more logic to maximize the number of MCUs emitted per JPEGDraw call even when cropping. Please give it a try.

bitbank2 commented 3 months ago

I'm calling this fixed

andrewleek-droplab commented 2 months ago

Pardon the delay. Yes I can confirm this is fixed.

Thank you so much!