Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoding JPEG with SIMD #3

Closed
modi12jin opened this issue Sep 24, 2023 · 8 comments
Closed

Decoding JPEG with SIMD #3

modi12jin opened this issue Sep 24, 2023 · 8 comments

Comments

@modi12jin
Copy link

@cgreening JPEG decoding with SIMD, currently the whole frame, cannot be partial, there will be more in the future

The only thing that needs attention is that the buffer must be 16-byte aligned. I tested 320240 with a box and it took an average of 42 ms to decode RGB565. The performance on Arduino is really not good. I remember that decoding 800480 under IDF took less than 50ms.

JPEGDEC seems to be 68ms

https://github.com/esp-arduino-libs/ESP32_JPEG/blob/master/examples/DecodeTest/DecodeTest.ino

@modi12jin modi12jin reopened this Sep 27, 2023
@cgreening
Copy link
Contributor

I'll take a look.

@cgreening
Copy link
Contributor

It's very fast - but unfortunately it doesn't seem to work with all image sizes.

It works ok with the 320x240 image and a 160x120 image. But doesn't seem to work with some other size. Any idea what could be going on?

@cgreening
Copy link
Contributor

It looks like the width has to be a multiple of 16 for some reason.

@cgreening
Copy link
Contributor

Some pretty interesting results.

Library Decode+Draw Time Decode Time
Bodmer/JPEGDecoder 117ms 109ms
bitbank2/JPEGDEC 38ms 32ms
ESP32_JPEG 33ms 17ms

What can we conclude....

The ESP32 based decoding is really fast. But, the limiting factor is the DMA transfer to draw the image. Which is why we get a similar time for decode+draw to the JPEGDEC library.

The JPEGDEC library interleaves decoding and drawing, so while it's drawing one section of the image using DMA it's decoding the next section.

The ESP32_JPEG would use about half the CPU time so it's still quite interesting.

My only problem is the need to have the width of the image a multiple of 16 which doesn't seem to match what the header says is possible.

@modi12jin
Copy link
Author

modi12jin commented Sep 27, 2023

@cgreening You are right, 16-byte alignment is indeed required. Only the whole frame, not parts.

Partial decoding will be available in the near future. This is the information I got from the official

If you want to use it in IDF, you can refer to this link
https://github.com/espressif/esp-dev-kits/tree/master/esp32-s3-lcd-ev-board%2Fexamples%2Fusb_camera_lcd%2Fcomponents%2Fesp_jpeg

Chen Liang test video
https://x.com/moononournation/status/1705953255979888696?s=20

https://github.com/moononournation/ESP32-S3-BOX-3/tree/main/ImgViewerMjpeg_SIMD

The perfect combination of SIMD full screen decoding + RGB screen

Questions I asked before JPEGDEC
bitbank2/JPEGDEC#56

As an aside, SIMD can be used to speed up some LVGL drawing processes.
espressif/esp-bsp#154

@modi12jin
Copy link
Author

modi12jin commented Sep 30, 2023

@cgreening Thanks for the explainer video! I got the news that ESP32_JPEG will add relevant usage instructions, such as 16-byte alignment issues

@modi12jin modi12jin reopened this Sep 30, 2023
@modi12jin modi12jin reopened this Jan 22, 2024
@modi12jin
Copy link
Author

@cgreening The JPEGDEC author has an update on this issue
https://bitbanksoftware.blogspot.com/2024/01/surprise-esp32-s3-has-few-simd.html?m=1

@modi12jin
Copy link
Author

@cgreening This is jpeg SIMD decoding, which is now partially supported. Sir, you can try it and see how it works

7_20231124_jpeg_block_decoder_esp32s3.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants