Allow custom JPEG frame buffer sizes#850
Conversation
|
frame size and buffer size are two very different things. If you want to be able to set a custom frame buffer size, then that should be a separate option in the camera config. |
Hello, |
Would you mean I can add a new paraneter |
|
frame_size represents the resolution of the image, frame buffer size is the size that the image with that resolution will take. It depends on the frame_format what that size would be, and for JPEG is a middle ground number that is not too big, but would fit 99% of the images with the given resolution. |
Yes. Maybe name it |
Thank you. Will do shortly. I will renew this PR after that. Thanks again! |
Hi there, |
Summary
Add an optional
camera_config_t.jpeg_buffer_sizefield for overriding the frame buffer allocation size in JPEG mode.When
jpeg_buffer_sizeis0, the existing automatic or Kconfig-based buffer sizing behavior is preserved.Motivation
JPEG output size depends on image content, sensor quality settings, and compression efficiency. The existing automatic allocation derives the buffer size from the selected resolution, which can create large jumps between adjacent frame size presets.
For example, with the automatic
/ 5sizing rule:On devices without PSRAM, the smaller allocation may not fit some JPEG frames, while the next allocation may require more contiguous internal memory than the application can provide.
A measured intermediate value such as 128 KiB can be sufficient for the expected JPEG output while leaving enough internal memory for networking, HTTP, MQTT, and the rest of the application.
What changed
size_t jpeg_buffer_sizetocamera_config_t.0preserves the existing automatic orCONFIG_CAMERA_JPEG_MODE_FRAME_SIZEbehavior.frame_sizeremains aframesize_tand continues to represent image resolution.Example
This captures UXGA images while allocating a 128 KiB JPEG frame buffer.
Compatibility
Existing behavior is unchanged when
jpeg_buffer_sizeis0.Aggregate and designated initializers that omit the new trailing field initialize it to zero, preserving the previous allocation behavior.
Validation
git diff --check.codespellon the changed files.esp_camera.candcam_hal.c.