src.nth.io/

summaryrefslogtreecommitdiff
path: root/main/jpeg_decoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'main/jpeg_decoder.h')
-rw-r--r--main/jpeg_decoder.h30
1 files changed, 22 insertions, 8 deletions
diff --git a/main/jpeg_decoder.h b/main/jpeg_decoder.h
index e8a8504..495b1a5 100644
--- a/main/jpeg_decoder.h
+++ b/main/jpeg_decoder.h
@@ -19,20 +19,34 @@ esp_err_t jpeg_decoder_init(void);
bool jpeg_decoder_try_lock(uint32_t timeout_ms);
void jpeg_decoder_unlock(void);
-// Pointer to the input scratch buffer (PSRAM, DMA-aligned). Capacity =
-// JPEG_DECODER_MAX_INPUT_BYTES. Caller fills before calling decode.
+// Pointer to the built-in input scratch buffer (PSRAM, DMA-aligned).
+// Capacity = JPEG_DECODER_MAX_INPUT_BYTES. Owned by the decoder.
+// http_api's snapshot path fills this and decodes from it. The stream
+// server allocates its own buffers via jpeg_decoder_alloc_input_buffer.
void *jpeg_decoder_input_buffer(void);
-// Decode the JPEG sitting in the input buffer into the caller-provided
-// out_buf (must be at least out_cap bytes, ≥ 800*480*3 for a full
-// panel-sized frame). Bytes land in BGR memory order so the DSI engine
-// + TC358762 + Pi panel render channels correctly. Reports image
-// width/height in pixels.
+// Allocate an additional DMA-aligned PSRAM input buffer suitable for
+// jpeg_decoder_decode. Capacity reported via *out_cap. Returned pointer
+// is owned by the caller and never freed — call once per buffer at
+// init time. NULL on failure.
+//
+// Used by the stream server to maintain a ping-pong ring of body
+// buffers between its recv task and its decode/paint task — recv
+// fills one buffer while decode processes another, no memcpy on
+// handoff.
+void *jpeg_decoder_alloc_input_buffer(size_t *out_cap);
+
+// Decode the JPEG sitting in in_buf into the caller-provided out_buf
+// (must be at least out_cap bytes, ≥ 800*480*3 for a full panel-sized
+// frame). Bytes land in BGR memory order so the DSI engine + TC358762
+// + Pi panel render channels correctly. Reports image width/height
+// in pixels.
//
// In the /frame hot path the caller passes display_back_buffer() so
// the hardware decoder writes pixels straight into the panel's back
// framebuffer with zero intermediate copies.
-esp_err_t jpeg_decoder_decode(size_t jpeg_len,
+esp_err_t jpeg_decoder_decode(void *in_buf,
+ size_t jpeg_len,
void *out_buf,
size_t out_cap,
uint16_t *out_width,