Skip to content

Commit 3ffc6ed

Browse files
committed
feat(lcd): Updated the lv_decoder component and the corresponding examples
1 parent 947efcc commit 3ffc6ed

File tree

69 files changed

+5015
-845
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+5015
-845
lines changed

.gitlab/ci/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,8 +1332,7 @@ build_components_display_tools_esp_lv_decoder_test_apps:
13321332
- .rules:build:components_display_tools_esp_lv_decoder_test_apps
13331333
parallel:
13341334
matrix:
1335-
- IMAGE: espressif/idf:release-v5.1
1336-
- IMAGE: espressif/idf:release-v5.0
1335+
- IMAGE: espressif/idf:release-v5.3
13371336
variables:
13381337
EXAMPLE_DIR: components/display/tools/esp_lv_decoder/test_apps
13391338

.gitlab/ci/target_test.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ variables:
22
# There is no target-test-env-v4.4
33
DOCKER_TARGET_TEST_v5_0_ENV_IMAGE: "$CI_DOCKER_REGISTRY/target-test-env-v5.0:3"
44
DOCKER_TARGET_TEST_v5_1_ENV_IMAGE: "$CI_DOCKER_REGISTRY/target-test-env-v5.1:1"
5+
DOCKER_TARGET_TEST_v5_3_ENV_IMAGE: "$CI_DOCKER_REGISTRY/target-test-env-v5.3:1"
56
DOCKER_TARGET_TEST_v5_4_ENV_IMAGE: "$CI_DOCKER_REGISTRY/target-test-env-v5.4:2"
67

78
.test_template: &test_template
@@ -535,19 +536,19 @@ components_test_esp_lv_decoder:
535536
optional: false
536537
parallel:
537538
matrix:
538-
- IDF_TARGET: esp32
539-
IDF_VERSION: "5.1"
540-
ENV_TAG: generic
541539
- IDF_TARGET: esp32c3
542-
IDF_VERSION: "5.1"
540+
IDF_VERSION: "5.3"
543541
ENV_TAG: generic
544542
- IDF_TARGET: esp32s3
545-
IDF_VERSION: "5.1"
543+
IDF_VERSION: "5.3"
544+
ENV_TAG: generic
545+
- IDF_TARGET: esp32p4
546+
IDF_VERSION: "5.3"
546547
ENV_TAG: generic
547548
tags:
548549
- ${IDF_TARGET}
549550
- ${ENV_TAG}
550-
image: $DOCKER_TARGET_TEST_v5_1_ENV_IMAGE
551+
image: $DOCKER_TARGET_TEST_v5_3_ENV_IMAGE
551552
variables:
552553
TEST_TARGET: ${IDF_TARGET}
553554
TEST_FOLDER: components/display/tools/esp_lv_decoder

components/.build-rules.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ components/display/lcd_touch/esp_lcd_touch_st7123/test_apps:
203203

204204
components/display/tools/esp_lv_decoder/test_apps:
205205
enable:
206-
- if: IDF_TARGET in ["esp32","esp32s2","esp32s3"] and (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 0)
207-
- if: IDF_TARGET in ["esp32","esp32s2","esp32s3","esp32c3","esp32c6", "esp32p4"] and (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 1)
206+
- if: IDF_TARGET in ["esp32s3","esp32c3", "esp32p4"] and (IDF_VERSION_MAJOR == 5 and IDF_VERSION_MINOR == 3)
208207

209208
components/expander/io_expander/mcp23017/test_apps:
210209
enable:

components/display/tools/esp_lv_decoder/CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# ChangeLog
22

3-
## v0.1.2~1 (2025-08-13)
3+
## v0.3.0 (2025-09-12)
44

5-
* Support all target.
5+
* Adapted PJPG format for parsing transparency scenarios
6+
* Added hardware JPEG support
7+
* Integrated compatibility with LVGL v9
8+
9+
## v0.2.0 (2025-04-08)
10+
11+
* Added support for LVGL v9 JPG format.
612

713
## v0.1.2 (2024-10-18)
814

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,68 @@
11
idf_component_register(
2-
SRCS "esp_lv_decoder.c"
32
INCLUDE_DIRS "include"
43
PRIV_INCLUDE_DIRS "priv_include"
54
)
65

7-
include(package_manager)
8-
cu_pkg_define_version(${CMAKE_CURRENT_LIST_DIR})
6+
# Get LVGL version
7+
idf_build_get_property(build_components BUILD_COMPONENTS)
8+
if(lvgl IN_LIST build_components)
9+
set(lvgl_name lvgl) # Local component
10+
set(lvgl_ver $ENV{LVGL_VERSION}) # Get the version from env variable (set from LVGL v9.2)
11+
else()
12+
set(lvgl_name lvgl__lvgl) # Managed component
13+
idf_component_get_property(lvgl_ver ${lvgl_name} COMPONENT_VERSION) # Get the version from esp-idf build system
14+
endif()
15+
16+
if("${lvgl_ver}" STREQUAL "")
17+
message("Could not determine LVGL version, assuming v9.x")
18+
endif()
19+
20+
# Select folder by LVGL version
21+
set(ADD_LIBS "")
22+
message(STATUS "LVGL version: ${lvgl_ver}")
23+
if(lvgl_ver VERSION_LESS "9.0.0")
24+
message(VERBOSE "Compiling decoder for LVGL8")
25+
set(DECODER_FOLDER "lvgl8")
26+
list(APPEND ADD_LIBS idf::esp_mm)
27+
else()
28+
message(VERBOSE "Compiling decoder for LVGL9")
29+
set(DECODER_FOLDER "lvgl9")
30+
list(APPEND ADD_LIBS idf::esp_mm)
31+
endif()
32+
33+
set(DECODER_PARH "src/${DECODER_FOLDER}")
34+
35+
if("espressif__esp_new_jpeg" IN_LIST build_components)
36+
list(APPEND ADD_LIBS idf::espressif__esp_new_jpeg)
37+
endif()
38+
if("esp_new_jpeg" IN_LIST build_components)
39+
list(APPEND ADD_LIBS idf::esp_new_jpeg)
40+
endif()
41+
42+
if("espressif__libpng" IN_LIST build_components)
43+
list(APPEND ADD_LIBS idf::espressif__libpng)
44+
endif()
45+
if("libpng" IN_LIST build_components)
46+
list(APPEND ADD_LIBS idf::libpng)
47+
endif()
48+
49+
if(${target} STREQUAL "esp32p4")
50+
list(APPEND ADD_LIBS idf::esp_driver_jpeg)
51+
endif()
52+
53+
# Here we create the real lvgl_docoder_lib
54+
add_library(lvgl_docoder_lib STATIC
55+
${DECODER_PARH}/esp_lv_decoder.c
56+
${ADD_SRCS}
57+
)
58+
target_include_directories(lvgl_docoder_lib PUBLIC "include")
59+
target_include_directories(lvgl_docoder_lib PRIVATE "priv_include")
60+
target_link_libraries(lvgl_docoder_lib PUBLIC
61+
idf::${lvgl_name}
62+
)
63+
target_link_libraries(lvgl_docoder_lib PRIVATE
64+
${ADD_LIBS}
65+
)
66+
67+
# Finally, link the lvgl_docoder_lib its esp-idf interface library
68+
target_link_libraries(${COMPONENT_LIB} INTERFACE lvgl_docoder_lib)

components/display/tools/esp_lv_decoder/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,57 @@ The [esp_mmap_assets](https://components.espressif.com/components/espressif/esp_
122122
Completed navi_53.jpg -> navi_53.sqoi
123123
```
124124

125+
### Converting PNG to PJPG
126+
#### CMake
127+
```c
128+
spiffs_create_partition_assets(
129+
my_spiffs_partition
130+
my_folder
131+
FLASH_IN_PROJECT
132+
MMAP_FILE_SUPPORT_FORMAT ".png"
133+
MMAP_SUPPORT_PJPG)
134+
```
135+
#### Output log
136+
```c
137+
[x/xx] Move and Pack assets...
138+
--support_format: ['.png']
139+
--support_spng: False
140+
--support_sjpg: False
141+
--support_qoi: False
142+
--support_pjpg: True
143+
--support_raw: False
144+
Completed example.png -> example.pjpg
145+
```
146+
125147
### Initialization
126148
```c
127149
esp_lv_decoder_handle_t decoder_handle = NULL;
128150
esp_lv_decoder_init(&decoder_handle); //Initialize this after lvgl starts
129151
```
152+
153+
Notes:
154+
- PJPG is produced by packing two baseline JPEG streams (RGB and Alpha) behind a small custom header. The tool automatically invokes an internal converter (`png_processor.py`).
155+
- A guard may skip PJPG for very small images to avoid overhead (default threshold is 128x128). You will see a log like: "Skip PJPG for small image ...".
156+
157+
### Hardware JPEG / PJPG: Usage Notes and Limitations
158+
159+
- General
160+
- Hardware acceleration is used only when available and enabled. If unavailable, software decoding is used transparently.
161+
- File and in-memory (C array) sources are both supported.
162+
163+
- Standard JPEG (JPG/JPEG)
164+
- Hardware path is taken only when both width and height are multiples of 16 and at least 64 pixels. Otherwise, software decoding is used.
165+
- Output color format follows the default display: RGB565 or RGB888.
166+
- For best compatibility, use baseline (non‑progressive) JPEG. Progressive JPEG may not be supported by the hardware decoder and can fall back to software or fail depending on ESP-IDF version.
167+
168+
- PJPG (PNG with Alpha -> PJPG)
169+
- Output color format is `LV_COLOR_FORMAT_RGB565A8` (packed RGB565 + 8‑bit Alpha plane).
170+
- For best performance, use images with width and height aligned to 16 pixels. If not aligned, the decoder internally decodes into an aligned buffer and copies/crops back, which adds extra RAM usage and time.
171+
- The Alpha plane is decoded as an 8‑bit grayscale JPEG stream.
172+
173+
- Split formats (SJPG/SPNG/SQOI)
174+
- These split containers are decoded slice‑by‑slice for low RAM usage, so LVGL zoom/rotate are not supported. PJPG is not a split format; LVGL can post‑process the fully decoded buffer as usual (subject to LVGL performance/memory constraints).
175+
176+
- Memory and alignment details
177+
- Decoder output buffers are allocated with 128‑byte alignment to cooperate with caches and, when present, the hardware JPEG engine. Unaligned image sizes may require temporary aligned buffers during hardware decoding.
178+

components/display/tools/esp_lv_decoder/idf_component.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1-
version: "0.1.2~1"
1+
version: "0.3.0"
2+
targets:
3+
- esp32
4+
- esp32s2
5+
- esp32s3
6+
- esp32p4
7+
- esp32c2
8+
- esp32c3
9+
- esp32c5
10+
- esp32c6
211
description: Decoding images in LVGL for multiple formats (PNG, SPNG, JPG, SJPG, QOI, SQOI) using optimized libraries for fast and efficient rendering.
312
url: https://github.com/espressif/esp-iot-solution/tree/master/components/display/tools/esp_lv_decoder
413
issues: https://github.com/espressif/esp-iot-solution/issues
514
repository: https://github.com/espressif/esp-iot-solution.git
615
documentation: https://docs.espressif.com/projects/esp-iot-solution/en/latest/display/tools/esp_lv_decoder.html
716
dependencies:
8-
idf: ">=4.4"
17+
idf: ">=5.3"
918
espressif/libpng:
1019
version: "1.*"
1120
espressif/esp_new_jpeg:
1221
version: 0.5.*
1322
lvgl/lvgl:
14-
version: ^8
15-
cmake_utilities: "0.*"
23+
version: ">=8,<10"
1624
examples:
1725
- path: ../../../../examples/hmi/perf_benchmark
1826
sbom:

components/display/tools/esp_lv_decoder/include/esp_lv_decoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#pragma once
7+
#include "sdkconfig.h"
8+
9+
#ifndef ESP_LV_ENABLE_HW_JPEG
10+
#if defined(CONFIG_SOC_JPEG_DECODE_SUPPORTED) && CONFIG_SOC_JPEG_DECODE_SUPPORTED
11+
#define ESP_LV_ENABLE_HW_JPEG 1
12+
#else
13+
#define ESP_LV_ENABLE_HW_JPEG 0
14+
#endif
15+
#endif
16+
17+
#ifndef ESP_LV_ENABLE_PJPG
18+
#if ESP_LV_ENABLE_HW_JPEG
19+
#define ESP_LV_ENABLE_PJPG 1
20+
#else
21+
#define ESP_LV_ENABLE_PJPG 0
22+
#endif
23+
#endif

0 commit comments

Comments
 (0)