1#ifdef USE_ESP32_CAMERA_JPEG_ENCODER
7static const char *
const TAG =
"camera_encoder";
30 ESP_LOGE(TAG,
"Failed to expand output buffer.");
35 ESP_LOGD(TAG,
"Output buffer expanded (%u -> %u).", current_size, this->
output_->
get_max_size());
45 "ESP32 Camera JPEG Encoder:\n"
56 if (index +
len > buffer_length) {
61 std::memcpy(&buffer[index], data,
len);
69 return PIXFORMAT_GRAYSCALE;
71 return PIXFORMAT_RGB565;
74 return PIXFORMAT_RGB888;
77 return PIXFORMAT_GRAYSCALE;
Interface for a generic buffer that stores image data.
virtual size_t get_data_length()=0
Returns the length of the buffer in bytes.
virtual uint8_t * get_data_buffer()=0
Returns a pointer to the buffer's data.
Interface for an encoder buffer supporting resizing and variable-length data.
virtual size_t get_max_size() const =0
Returns total allocated buffer size.
virtual uint8_t * get_data() const =0
Returns a pointer to the buffer data.
virtual bool set_buffer_size(size_t size)=0
Sets logical buffer size, reallocates if needed.
Encoder that uses the software-based JPEG implementation from Espressif's esp32-camera component.
camera::EncoderBuffer * output_
camera::EncoderError encode_pixels(camera::CameraImageSpec *spec, camera::Buffer *pixels) override
ESP32CameraJPEGEncoder(uint8_t quality, camera::EncoderBuffer *output)
Constructs a ESP32CameraJPEGEncoder instance.
void dump_config() override
size_t buffer_expand_size_
pixformat_t to_internal_(camera::PixelFormat format)
static size_t callback_(void *arg, size_t index, const void *data, size_t len)
bool out_of_output_memory_
EncoderError
Result codes from the encoder used to control camera pipeline flow.
@ ENCODER_ERROR_RETRY_FRAME
Retry current frame, after buffer growth or for incremental encoding.
@ ENCODER_ERROR_SUCCESS
Encoding succeeded, continue pipeline normally.
@ ENCODER_ERROR_CONFIGURATION
Fatal config error, shut down pipeline.
@ ENCODER_ERROR_SKIP_FRAME
Skip current frame, try again on next frame.
PixelFormat
Enumeration of different pixel formats.
@ PIXEL_FORMAT_RGB565
16-bit RGB (5-6-5).
@ PIXEL_FORMAT_GRAYSCALE
8-bit grayscale.
@ PIXEL_FORMAT_BGR888
RGB pixel data in 8-bit format, stored as B, G, R (1 byte each).
Specification of a caputured camera image.