Skip to content

Commit 7aa37d4

Browse files
authored
Add option to customize JPEG mode frame size in menuconfig (#667)
1 parent 2829692 commit 7aa37d4

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Kconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,33 @@ menu "Camera configuration"
179179
Maximum value of DMA buffer
180180
Larger values may fail to allocate due to insufficient contiguous memory blocks, and smaller value may cause DMA interrupt to be too frequent.
181181

182+
choice CAMERA_JPEG_MODE_FRAME_SIZE_OPTION
183+
prompt "JPEG mode frame size option"
184+
default CAMERA_JPEG_MODE_FRAME_SIZE_AUTO
185+
help
186+
Select whether to use automatic calculation for JPEG mode frame size or specify a custom value.
187+
188+
config CAMERA_JPEG_MODE_FRAME_SIZE_AUTO
189+
bool "Use automatic calculation (width * height / 5)"
190+
help
191+
Use the default calculation for JPEG mode frame size.
192+
Note: In very low resolutions like QQVGA, the default calculation tends to result in insufficient buffer size.
193+
194+
config CAMERA_JPEG_MODE_FRAME_SIZE_CUSTOM
195+
bool "Specify custom frame size"
196+
help
197+
Specify a custom frame size in bytes for JPEG mode.
198+
199+
endchoice
200+
201+
config CAMERA_JPEG_MODE_FRAME_SIZE
202+
int "Custom JPEG mode frame size (bytes)"
203+
default 8192
204+
depends on CAMERA_JPEG_MODE_FRAME_SIZE_CUSTOM
205+
help
206+
This option sets the custom frame size in JPEG mode.
207+
Specify the desired buffer size in bytes.
208+
182209
config CAMERA_CONVERTER_ENABLED
183210
bool "Enable camera RGB/YUV converter"
184211
depends on IDF_TARGET_ESP32S3

driver/cam_hal.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,11 @@ esp_err_t cam_config(const camera_config_t *config, framesize_t frame_size, uint
374374
cam_obj->height = resolution[frame_size].height;
375375

376376
if(cam_obj->jpeg_mode){
377+
#ifdef CONFIG_CAMERA_JPEG_MODE_FRAME_SIZE_AUTO
377378
cam_obj->recv_size = cam_obj->width * cam_obj->height / 5;
379+
#else
380+
cam_obj->recv_size = CONFIG_CAMERA_JPEG_MODE_FRAME_SIZE;
381+
#endif
378382
cam_obj->fb_size = cam_obj->recv_size;
379383
} else {
380384
cam_obj->recv_size = cam_obj->width * cam_obj->height * cam_obj->in_bytes_per_pixel;

0 commit comments

Comments
 (0)