You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: codec correctness fixes split out of the pixel-correctness test PR
Second-round fixes found by the pixel-correctness suite (#72), split out
so that PR stays a pure test/CI change. First-round fixes (12-bit decode
path, codecFactory instance cleanup, openjpeg decoder guards and
BufferStream bounds) are already in #71 — this PR carries only what the
test branch itself introduced, each fix together with the tests that
fail without it (verified against wasm rebuilt from the fixes branch's
C++ with CI's emsdk 3.1.74 image):
- openjpeg: J2KEncoder throws on setup/compress failure instead of
silently returning, with the encoded buffer zeroed (callers previously
read back a garbage pre-sized allocation as a successful encode);
frees codec/stream/image on every exit path (repeated encodes grew the
wasm heap monotonically); sizes the output buffer with headroom so
clamped writes surface as errors instead of truncation. Pinned by the
encoder-failure-throw tests, the encode/delete heap-stability test,
and both dicom-codec J2K round-trips (encode .90 and transcode
.80->.90), which fail byte-exactness without this rework.
- openjphjs: HTJ2KEncoder rounds bytesPerPixel UP; bitsPerSample/8
truncated to 1 for 9..15-bit samples, halving the row stride so every
row after the first was read from the wrong offset (12-bit encodes
corrupted). Pinned by the 12-bit encoder round-trip.
- libjpeg-turbo-12bit: fail closed on multi-component input — forcing
JCS_GRAYSCALE on a color 12-bit JPEG silently discards chroma and
reports componentCount=1. Pinned by the multi-component rejection
test; also adds the CodSpeed bench and its package script.
- dicom-codec: adaptImageInfo preserves planarConfiguration
(decode8Planar was unreachable; PlanarConfiguration=1 RLE silently
produced interleaved output). Pinned by the planar RLE test.
- little-endian/big-endian: 32-bit pixel data decodes to
Uint32Array/Int32Array per pixelRepresentation with Float32Array only
as the no-pixelRepresentation fallback (review feedback from
wayfarer3130, matching cornerstone3D's decodeLittleEndian); 32-bit
views realign to 4-byte boundaries (the old offset % 2 check threw a
RangeError at offset % 4 == 2); big-endian gains 1-bit passthrough
and byte-swapped 32-bit support. Same typing fix applied to
dicom-codec's littleEndian getPixelData.
0 commit comments