mirror of
https://github.com/esphome/esphome.git
synced 2026-09-19 02:58:38 +00:00
Add JPEG encoder support via new camera_encoder component (#9459)
Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: J. Nick Koston <nick@home-assistant.io> Co-authored-by: J. Nick Koston <nick+github@koston.org>
This commit is contained in:
co-authored by
J. Nick Koston
J. Nick Koston
J. Nick Koston
parent
983b3cb879
commit
e29f0ee7f8
@@ -0,0 +1,23 @@
|
||||
#include "encoder_buffer_impl.h"
|
||||
|
||||
namespace esphome::camera_encoder {
|
||||
|
||||
bool EncoderBufferImpl::set_buffer_size(size_t size) {
|
||||
if (size > this->capacity_) {
|
||||
uint8_t *p = this->allocator_.reallocate(this->data_, size);
|
||||
if (p == nullptr)
|
||||
return false;
|
||||
|
||||
this->data_ = p;
|
||||
this->capacity_ = size;
|
||||
}
|
||||
this->size_ = size;
|
||||
return true;
|
||||
}
|
||||
|
||||
EncoderBufferImpl::~EncoderBufferImpl() {
|
||||
if (this->data_ != nullptr)
|
||||
this->allocator_.deallocate(this->data_, this->capacity_);
|
||||
}
|
||||
|
||||
} // namespace esphome::camera_encoder
|
||||
Reference in New Issue
Block a user