Skip to content

Commit 6591f26

Browse files
feat(esp_jpeg): Add configuration option for working buffer size
1 parent b118925 commit 6591f26

File tree

6 files changed

+44
-3
lines changed

6 files changed

+44
-3
lines changed

esp_jpeg/CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## 1.2.0
2+
3+
- Added option to define working buffer size
4+
5+
## 1.1.0
6+
7+
- Added support for decoding images without Huffman tables
8+
- Fixed undefined configuration options from Kconfig
9+
10+
## 1.0.5~3
11+
12+
- Added option to swap output color bytes regardless of JD_FORMAT
13+
14+
## 1.0.4
15+
16+
- Added ROM implementation support for ESP32-C6
17+
18+
## 1.0.2
19+
20+
- Fixed compiler warnings
21+
22+
## 1.0.1
23+
24+
- Fixed: exclude ESP32-C2 from list of ROM implementations
25+
26+
## 1.0.0
27+
28+
- Initial version

esp_jpeg/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# JPEG Decoder: TJpgDec - Tiny JPEG Decompressor
22

33
[![Component Registry](https://components.espressif.com/components/espressif/esp_jpeg/badge.svg)](https://components.espressif.com/components/espressif/esp_jpeg)
4+
![maintenance-status](https://img.shields.io/badge/maintenance-actively--developed-brightgreen.svg)
45

56
TJpgDec is a lightweight JPEG image decompressor optimized for embedded systems with minimal memory consumption.
67

@@ -25,6 +26,7 @@ On some microcontrollers, TJpgDec is available in ROM and will be used by defaul
2526
- Pixel format options: RGB888, RGB565
2627
- Selectable scaling ratios: 1/1, 1/2, 1/4, or 1/8 (chosen at decompression)
2728
- Option to swap the first and last bytes of color values
29+
- Size of Tjpgd working buffer: Adjustable to optimize performance or memory usage, allowing increases for handling complex formats or reductions to conserve memory
2830

2931
## TJpgDec in ROM
3032

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This file was generated using idf.py save-defconfig. It can be edited manually.
2+
# Espressif IoT Development Framework (ESP-IDF) 5.5.0 Project Minimal Configuration
3+
#
4+
CONFIG_TOUCH_SUPPRESS_DEPRECATE_WARN=y

esp_jpeg/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.1.0"
1+
version: "1.2.0"
22
description: "JPEG Decoder: TJpgDec"
33
url: https://github.com/espressif/idf-extra-components/tree/master/esp_jpeg/
44
dependencies:

esp_jpeg/include/jpeg_decoder.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ typedef struct esp_jpeg_image_cfg_s {
4848
uint8_t swap_color_bytes: 1; /*!< Swap first and last color bytes */
4949
} flags;
5050

51+
struct {
52+
size_t working_buffer_size; /*!< Size of working memory for the decoder. Set to 0 for default value.
53+
Default size is 3.1kB or 65kB if JD_FASTDECODE == 2
54+
Tjpgd does not use dynamic allocation, se we pass this buffer to Tjpgd that uses it as scratchpad */
55+
} advanced;
56+
5157
struct {
5258
uint32_t read; /*!< Internal count of read bytes */
5359
} priv;

esp_jpeg/jpeg_decoder.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ esp_err_t esp_jpeg_decode(esp_jpeg_image_cfg_t *cfg, esp_jpeg_image_output_t *im
7979
assert(cfg != NULL);
8080
assert(img != NULL);
8181

82-
workbuf = heap_caps_malloc(JPEG_WORK_BUF_SIZE, MALLOC_CAP_DEFAULT);
82+
const size_t workbuf_size = cfg->advanced.working_buffer_size ? cfg->advanced.working_buffer_size : JPEG_WORK_BUF_SIZE;
83+
workbuf = heap_caps_malloc(workbuf_size, MALLOC_CAP_DEFAULT);
8384
ESP_GOTO_ON_FALSE(workbuf, ESP_ERR_NO_MEM, err, TAG, "no mem for JPEG work buffer");
8485

8586
cfg->priv.read = 0;
8687

8788
/* Prepare image */
88-
res = jd_prepare(&JDEC, jpeg_decode_in_cb, workbuf, JPEG_WORK_BUF_SIZE, cfg);
89+
res = jd_prepare(&JDEC, jpeg_decode_in_cb, workbuf, workbuf_size, cfg);
8990
ESP_GOTO_ON_FALSE((res == JDR_OK), ESP_FAIL, err, TAG, "Error in preparing JPEG image! %d", res);
9091

9192
uint8_t scale_div = jpeg_get_div_by_scale(cfg->out_scale);

0 commit comments

Comments
 (0)