7#include "TinyJPEGDecoder.h"
69 bool isValid(
const uint8_t *data,
size_t len)
override {
70 return len >= 2 && data[0] == 0xFF && data[1] == 0xD8;
83 LOGW(
"MJPEGDecoder: unsupported VideoFormat %d - only RGB565",
115 bool begin()
override {
return true; }
121 size_t write(
const uint8_t *data,
size_t len)
override {
141 if (
pos == 0)
return;
146 uint16_t w = 0, h = 0;
149 LOGE(
"MJPEGDecoder: could not determine JPEG size");
159 LOGE(
"MJPEGDecoder: frame buffer allocation failed");
180 bool isKeyFrame(
const uint8_t *data,
size_t len)
override {
return true; }
197 static bool onBlock(tinyjpeg::TinyJPEGDecoder &decoder, int16_t x,
198 int16_t y, uint16_t w, uint16_t h, uint16_t *data) {
199 return static_cast<MJPEGDecoder *
>(decoder.getUserData())
209 bool writeBlock(int16_t x, int16_t y, uint16_t w, uint16_t h,
211 if (x < 0 || y < 0)
return true;
214 if ((uint32_t)x >= max_x || (uint32_t)y >= max_y)
return true;
215 uint32_t win_w = std::min((uint32_t)w, max_x - (uint32_t)x);
216 uint32_t win_h = std::min((uint32_t)h, max_y - (uint32_t)y);
218 for (uint32_t row = 0; row < win_h; row++) {
219 memcpy(dst + ((uint32_t)y + row) * max_x + (uint32_t)x,
220 data + row * w, win_w *
sizeof(uint16_t));
#define LOGW(...)
Definition AudioLoggerIDF.h:29
#define LOGE(...)
Definition AudioLoggerIDF.h:30
virtual size_t write(const uint8_t *data, size_t len)
Definition Arduino.h:120
VideoFormat
Video codec/pixel-format identifier, shared by two unrelated uses: the (single) video stream of a con...
Definition VideoOutput.h:29