TJpgDec is a generic JPEG image decompressor that is highly optimized for small embedded systems. It works with very low memory consumption.
Some microcontrollers have TJpg decoder in ROM, it is used, if there is. [^1] Using ROM code can be disabled in menuconfig.
[^1]: NOTE: When the ROM decoder is used, the configuration can't be changed. The configuration is fixed.
Compilation configuration:
Runtime configuration:
Some microcontrollers have TJpg decoder in ROM. It is used as default, but it can be disabled in menuconfig. Then there will be used code saved in this component.
Advantages:
Disadvantages:
In this table are examples of speed decoding JPEG image with this configuration:
ROM used | JD_SZBUF | JD_FORMAT | JD_USE_SCALE | JD_TBLCLIP | JD_FASTDECODE | RAM buffer | Flash size | Approx. time |
---|---|---|---|---|---|---|---|---|
YES | 512 | RGB888 | 1 | 1 | 0 | 3.1 kB | 0 kB | 52 ms |
NO | 512 | RGB888 | 1 | 1 | 0 | 3.1 kB | 5 kB | 50 ms |
NO | 512 | RGB888 | 1 | 0 | 0 | 3.1 kB | 4 kB | 68 ms |
NO | 512 | RGB888 | 1 | 1 | 1 | 3.1 kB | 5 kB | 50 ms |
NO | 512 | RGB888 | 1 | 0 | 1 | 3.1 kB | 4 kB | 62 ms |
NO | 512 | RGB888 | 1 | 1 | 2 | 65.5 kB | 5.5 kB | 46 ms |
NO | 512 | RGB888 | 1 | 0 | 2 | 65.5 kB | 4.5 kB | 59 ms |
NO | 512 | RGB565 | 1 | 1 | 0 | 5 kB | 5 kB | 60 ms |
NO | 512 | RGB565 | 1 | 1 | 1 | 5 kB | 5 kB | 59 ms |
NO | 512 | RGB565 | 1 | 1 | 2 | 65.5 kB | 5.5 kB | 56 ms |
Packages from this repository are uploaded to Espressif's component service.
You can add them to your project via idf.py add-dependancy
, e.g.
idf.py add-dependency esp_jpeg==1.0.0
Alternatively, you can create idf_component.yml
. More is in Espressif's documentation.
Here is example of usage. This calling is blocking.
esp_jpeg_image_cfg_t jpeg_cfg = {
.indata = (uint8_t *)jpeg_img_buf,
.indata_size = jpeg_img_buf_size,
.outbuf = out_img_buf,
.outbuf_size = out_img_buf_size,
.out_format = JPEG_IMAGE_OUT_FORMAT_RGB565,
.out_scale = JPEG_IMAGE_SCALE_0,
.flags = {
.swap_color_bytes = 1,
}
};
esp_jpeg_image_output_t outimg;
esp_jpeg_decode(&jpeg_cfg, &outimg);
Copy to Clipboard
idf.py add-dependency "espressif/esp_jpeg^1.0.5"
Copy to Clipboard
Copy to Clipboard