Skip to content

Commit

Permalink
Add option to customize JPEG mode frame size in menuconfig (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
maruta committed Jul 16, 2024
1 parent 2829692 commit 7aa37d4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
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

0 comments on commit 7aa37d4

Please sign in to comment.