feat: add encoded JPEG/PNG image input - #2
Merged
Merged
Conversation
luojiyin1987
force-pushed
the
feat/encoded-image-input
branch
from
July 14, 2026 10:41
a6dde57 to
183bf43
Compare
luojiyin1987
marked this pull request as draft
July 14, 2026 10:58
luojiyin1987
marked this pull request as ready for review
July 14, 2026 11:04
Contributor
|
Looks good overall! Could we add one non-blank JPEG/PNG test comparing |
Contributor
Author
|
add non-blank JPEG/PNG test , @eric8810 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue
Closes #1
What
Adds
recognizeEncoded()to the Node.js adapter so callers can pass in-memory JPEG or PNG bytes directly instead of decoding images into raw pixels first.The native C++ Core boundary remains unchanged and continues to accept decoded pixel buffers only.
Changes
Encoded image decoder
Adds
bindings/node/src/encoded_image.{hpp,cpp}using a pinnedstb_imagerevision with:STB_IMAGE_STATICmalloc,realloc, andfreemaxWidth,maxHeight, andmaxPixelsmaxTemporaryBytesresource_limit_exceededDecoded images are emitted as RGB8 and passed into the existing Core raw-pixel API, which performs the existing RGB-to-BGR conversion.
Node.js adapter
Adds:
Encoded requests reuse the existing:
AbortSignalcancellation behaviorThe JavaScript thread validates and snapshots the encoded byte view but does not parse or decode the image. Format, dimensions, pixel count, and decoder memory limits are validated on the engine worker thread.
Because encoded metadata is validated after admission, a malformed or oversized encoded image may return
queue_fullwhen the engine is already at capacity. This is an intentional API contract that avoids synchronous and duplicated image parsing on the JavaScript thread.Timing
Adds:
For raw-pixel input,
decodeis0.For encoded input, decoder duration is reported in microseconds and included in
timingUs.total.Build and release metadata
stbdependency metadata and cache support.stbonly when the Node adapter or fuzzers are enabled.Documentation
Updates:
Supported formats
Supported:
Not supported:
Safety and resource limits
The decoder:
Uint8Array, andSharedArrayBuffer-backed inputsresource_limit_exceededThe encoded-byte snapshot remains subject to
maxPendingInputBytes. Decoder memory and Core inference memory are independently constrained bymaxTemporaryBytes.Tests
Adds coverage for:
queue_fullprioritytimingUs.decode === 0Test plan
Also validate: