# JPEG-LS deferred and extended frame geometry

SOF55 normally supplies both dimensions. LSE4 supplies extended dimensions with two, three or four unsigned bytes per field, in network byte order. Encoders emit the smallest required LSE4 width for extended dimensions and keep the ordinary SOF55 representation through 65,535. When the first scan provides a deferred height, DNL or an immediately following LSE4 finishes the geometry. Native and the SDK expose the resolved dimensions before delivering rows. [T.87 C.2.2, C.2.4.1.4 and C.2.6](https://www.itu.int/rec/T-REC-T.87-199806-I/en)

Pass `defer_height=true` to the MoonBit encoder or `deferHeight: true` to the SDK or Worker. The Native equivalent is `encode-planar --dnl`. The encoder takes the actual input height and writes DNL after the first scan. If a positive SOF value may be superseded by DNL, use `allow_height_redefinition=true`, SDK and Worker `allowHeightRedefinition: true`, or Native `--allow-height-redefinition`. The default known-height decode streams rows immediately and checks a matching optional DNL.

The decoder retains at most 32 MiB from the unresolved first scan plus one 4 KiB staging block. It then replays entropy with resolved geometry, revalidates RST state and padding, and delivers real component rows. Native inspection exposes `deferredScanPeakBytes`. The default axis limit is 65,535. Use `Limits`, Native `--max-width` and `--max-height`, or SDK `limits` to raise the application limit. Valid values outside configured dimensions, sample capacity, or staging limits return `ResourceLimit`. Malformed values and displaced or inconsistent markers are rejected according to their syntax.

The extended geometry suite covers 65,535×1, 65,536×1, 1×65,536 and 1×100,000 with direct CharLS Wasm 0.10.0. The DNL suite covers 16-, 24-, and 32-bit counts, positive SOF redefinition, and late LSE4. Pinned CharLS development directly decodes applicable multiple-scan cases. Other DNL cases use fixed independently constructed syntax and reference checks of their entropy. HP 1.00 does not accept deferred-height frames. Annex C checks cover actual FF marker offsets, entropy-end offsets, interscan APPn/COM and adjacent LSE3 across FF fill. [M5 fixtures](../scripts/m5-cross-feature-references.json)

```sh
node sdk/build.mjs
node scripts/verify_deferred_height.mjs --native-exe _build/native/release/build/cmd/moonjls/moonjls.exe
node scripts/verify_extended_dimensions.mjs --native-exe _build/native/release/build/cmd/moonjls/moonjls.exe
node scripts/verify_part1_interactions.mjs --native-exe _build/native/release/build/cmd/moonjls/moonjls.exe
```
