In this article
Output format and input subsampling jointly define channel layout; treating every decoded image as a tightly packed color array can corrupt allocation and indexing.
Begin with parsed component metadata
An image loader assumes every decoded JPEG becomes a tightly packed color image and allocates from full-image dimensions alone. Native output can instead preserve a subsampled layout, and planar color output separates channels. The image-information guide documents retrieving components, subsampling and their extents. Retain those results with the requested output format before constructing destination buffers or passing storage to a downstream GPU kernel.
Treat output selection as a layout contract
The decoding guide distinguishes native, luma-only, planar and interleaved outputs. The number and arrangement of destination channels follow that selection and, for native output, the source subsampling. A pointer to the first channel does not automatically describe every other channel or imply that the next pixel is laid out as the downstream model expects. Preserve the channel arrangement explicitly at the interface boundary.
Keep pitch separate from logical width
The destination descriptor carries channel pointers and pitches. Allocate each required channel with its supported shape and row stride, then carry that stride into consumers instead of reconstructing it from the image width. A correct allocation can still be read incorrectly when a preprocessing kernel ignores its layout. Test the interface using visibly distinct channel values so that an accidental planar-versus-interleaved interpretation cannot hide behind a nearly uniform image.
Check support before interpreting a failed decode
The format and architecture reference describes supported subsampling and hardware capabilities. Parsed input metadata is not proof that the selected decoder configuration can process that input. Preserve failure status separately from allocation errors and from a successful decode with incorrectly interpreted output. Avoid silently changing the requested layout without updating the consumer’s expectation and associated diagnostic record.
Validate batches per destination image
A batch can contain different component shapes, so build and verify every destination descriptor against its own image metadata and selected format. Do not reuse the first image’s allocation assumptions merely because the decoder call accepts an array. The existing image-coordinate guide and byte-pitch guide provide context. A useful decoding contract preserves per-image format, component extents, channel arrangement and pitch, keeping decode success distinct from correctly delivered model pixels.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.