ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
jpeg_encoder.h
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef USE_ESP32_VARIANT_ESP32P4
6
7#include <driver/jpeg_encode.h>
8
9namespace esphome::mipi_csi {
10
13 public:
17 JpegEncoder(jpeg_enc_input_format_t input_format, jpeg_down_sampling_type_t sub_sample, uint8_t quality) {
18 this->config_.src_type = input_format;
19 this->config_.sub_sample = sub_sample;
20 this->config_.image_quality = quality;
21 }
22
28 bool init(uint16_t width, uint16_t height, size_t frame_size);
29
34 size_t encode(const uint8_t *frame, size_t frame_length);
35
37 uint8_t *get_output_buffer() const { return this->output_; }
38 uint8_t get_quality() const { return this->config_.image_quality; }
39
40 protected:
41 jpeg_encoder_handle_t engine_{nullptr};
42 jpeg_encode_cfg_t config_{};
43 uint8_t *output_{nullptr};
44 size_t output_size_{0};
45};
46
47} // namespace esphome::mipi_csi
48
49#endif
ESP32-P4 hardware JPEG encoder with one output buffer: one encoded frame at a time.
jpeg_encoder_handle_t engine_
uint8_t * get_output_buffer() const
Returns the buffer holding the most recently encoded image.
bool init(uint16_t width, uint16_t height, size_t frame_size)
Allocates the encoder engine and its output buffer.
size_t encode(const uint8_t *frame, size_t frame_length)
Encodes one frame into the internal output buffer.
JpegEncoder(jpeg_enc_input_format_t input_format, jpeg_down_sampling_type_t sub_sample, uint8_t quality)