Streaming JPEG input for the same preprocessing used by live frames. More...
#include "inference_jpeg.h"#include "jpeg_marker_guard.h"#include <stdio.h>#include <jpeglib.h>#include <math.h>#include <setjmp.h>#include <string.h>#include <sys/stat.h>
Go to the source code of this file.
Data Structures | |
| struct | jpeg_reader |
| Caller-owned codec/error state that remains valid across decoder longjmp exits. More... | |
Functions | |
| static void | jpeg_failure (j_common_ptr codec) |
| Convert libjpeg's fatal callback into a failed input instead of terminating the CAM worker. | |
| static void | jpeg_message (j_common_ptr codec, int level) |
| Check JPEG marker bounds ahead of normal codec diagnostics. | |
| static bool | decode_jpeg (struct jpeg_reader *reader, struct inference_context *context) |
| Fill a bound input tensor; ignore partial tensor/transform contents after any failure. | |
| bool | inference_jpeg_prepare (struct inference_context *context, const char *filename, char *error, size_t capacity) |
| Stream a JPEG into an open context's single declared image input. | |
Detailed Description
Streaming JPEG input for the same preprocessing used by live frames.
Application scratch is two rows, not a decoded full-resolution RGB image; libjpeg's internal allocations remain separate from this bounded workspace.
Definition in file inference_jpeg.c.
Function Documentation
◆ decode_jpeg()
|
static |
Fill a bound input tensor; ignore partial tensor/transform contents after any failure.
Definition at line 66 of file inference_jpeg.c.
◆ inference_jpeg_prepare()
| bool inference_jpeg_prepare | ( | struct inference_context * | context, |
| const char * | filename, | ||
| char * | error, | ||
| size_t | capacity ) |
Stream a JPEG into an open context's single declared image input.
- Parameters
-
context Exclusive model owner; input storage and transform are written in place. filename Readable regular JPEG, immutable throughout decoding. error Caller-owned diagnostic buffer, cleared on success. capacity Available bytes in error, including its terminator.
- Returns
- True for complete, warning-free decoding and supported preprocessing.
- Warning
- On failure discard the partially written tensor and transform; do not run inference.
Definition at line 167 of file inference_jpeg.c.
◆ jpeg_failure()
|
static |
Convert libjpeg's fatal callback into a failed input instead of terminating the CAM worker.
Definition at line 47 of file inference_jpeg.c.
◆ jpeg_message()
|
static |
Check JPEG marker bounds ahead of normal codec diagnostics.
- Parameters
-
codec Decoder carrying the borrowed jpeg_reader in client_data. level libjpeg diagnostic level.
Preserve the original handler for accepted messages so the inference wrapper can still observe codec warnings.
Definition at line 58 of file inference_jpeg.c.