Open shannondec opened 3 weeks ago
The memory management method in esp_new_jpeg
has some differences compared to esp_jpeg
.
Please provide details on the remaining system memory and image parameters at the time of the error.
ESP_LOGI("SYS", "Internal free heap size: %ld bytes", esp_get_free_internal_heap_size());
ESP_LOGI("SYS", "PSRAM free heap size: %ld bytes", esp_get_free_heap_size() - esp_get_free_internal_heap_size());
ESP_LOGI("SYS", "Total free heap size: %ld bytes", esp_get_free_heap_size());
typedef struct jpeg_info {
int width;
int height;
jpeg_pixel_format_t src_type;
jpeg_subsampling_t subsampling;
uint8_t quality;
jpeg_rotate_t rotate;
bool task_enable;
uint8_t hfm_task_priority;
uint8_t hfm_task_core;
} jpeg_enc_config_t;
1.The remaining system memory before jpeg_enc_open:
I (23553) SYS: Internal free heap size: 71907 bytes
I (23553) SYS: PSRAM free heap size: 4522297 bytes
I (23553) SYS: Total free heap size: 4594204 bytes
E (23553) JPEG_ENC: JPEG allocate memory failed, line 604
E (23553) JPEG_ENC: JPEG encoder open fail. line 72
E (23553) to_jpg_new: jpeg_enc_open error: -1
I also found that the jpeg_enc_handle_t *jpeg_enc memory was not freed when the error was returned.
2.The jpeg_enc_config_t parameter: fb->width is 1600, fb->height is 1200.
jpeg_enc_config_t jpeg_enc_cfg =
{
.width = fb->width,
.height = fb->height,
.src_type = JPEG_PIXEL_FORMAT_RGB888,
.subsampling = JPEG_SUBSAMPLE_420,
.quality = 80,
.rotate = JPEG_ROTATE_0D,
.task_enable = false,
.hfm_task_priority = 13,
.hfm_task_core = 1,
};
Thank you for the feedback. We've identified the issue and will fix it in an upcoming update.
The issue has been fixed in commit 891d0b0. Thank you for your feedback.
Ok, I'll try the new version.
Checklist
How often does this bug occurs?
always
Expected behavior
jpeg_enc_open shouldn't use a lot of memory on esp32-s3 with 8MB PSRAM.
Actual behavior (suspected bug)
When using JPEG_ENC_OPEN with the ESP32-CAMERA, an error occurs when the camera resolution is above FRAMESIZE_VGA, memory allocation fails.
Error logs or terminal output
Steps to reproduce the behavior
Using older versions jpeg encoder of the esp_codec library is no problem.
Project release version
v5.3.1,v5.0
System architecture
Intel/AMD 64-bit (modern PC, older Mac)
Operating system
Windows
Operating system version
win11
Shell
Bash
Additional context
No response