Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add option to customize JPEG mode frame size in menuconfig #667

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,33 @@ menu "Camera configuration"
Maximum value of DMA buffer
Larger values may fail to allocate due to insufficient contiguous memory blocks, and smaller value may cause DMA interrupt to be too frequent.

choice CAMERA_JPEG_MODE_FRAME_SIZE_OPTION
prompt "JPEG mode frame size option"
default CAMERA_JPEG_MODE_FRAME_SIZE_AUTO
help
Select whether to use automatic calculation for JPEG mode frame size or specify a custom value.

config CAMERA_JPEG_MODE_FRAME_SIZE_AUTO
bool "Use automatic calculation (width * height / 5)"
help
Use the default calculation for JPEG mode frame size.
Note: In very low resolutions like QQVGA, the default calculation tends to result in insufficient buffer size.

config CAMERA_JPEG_MODE_FRAME_SIZE_CUSTOM
bool "Specify custom frame size"
help
Specify a custom frame size in bytes for JPEG mode.

endchoice

config CAMERA_JPEG_MODE_FRAME_SIZE
int "Custom JPEG mode frame size (bytes)"
default 8192
depends on CAMERA_JPEG_MODE_FRAME_SIZE_CUSTOM
help
This option sets the custom frame size in JPEG mode.
Specify the desired buffer size in bytes.

config CAMERA_CONVERTER_ENABLED
bool "Enable camera RGB/YUV converter"
depends on IDF_TARGET_ESP32S3
Expand Down
4 changes: 4 additions & 0 deletions driver/cam_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,11 @@ esp_err_t cam_config(const camera_config_t *config, framesize_t frame_size, uint
cam_obj->height = resolution[frame_size].height;

if(cam_obj->jpeg_mode){
#ifdef CONFIG_CAMERA_JPEG_MODE_FRAME_SIZE_AUTO
cam_obj->recv_size = cam_obj->width * cam_obj->height / 5;
#else
cam_obj->recv_size = CONFIG_CAMERA_JPEG_MODE_FRAME_SIZE;
#endif
cam_obj->fb_size = cam_obj->recv_size;
} else {
cam_obj->recv_size = cam_obj->width * cam_obj->height * cam_obj->in_bytes_per_pixel;
Expand Down