Problem: a 4096 x 2160 12-bit lossless-JPEG CinemaDNG frame took about
50 ms (tiles) to 115 ms (one strip) on 16 threads and about 200 ms on
one, too slow for smooth 4K playback, and every frame was developed at
full size even for small monitors and proxies.
Fix, without changing the output (f32 bit patterns compared):
- Lossless JPEG: one 13-bit lookup gives a code and its difference
bits together; the bit reader takes eight bytes at once when they
hold no 0xFF; per-predictor line loops.
- Tiles decode in parallel by bands straight into place; a single
strip covering the image is used without a copy.
- Normalisation: without black-level deltas, a lookup table per
CFA / black-level site replaces the per-sample float arithmetic
(each entry computed by the same expression).
- Demosaic, crop and colour run row by row from the normalised plane
(no padded copy, no RGB intermediate), with 5 x 5 windows sliding
along the five mirrored rows; the bilinear (Fast) Bayer demosaic
sums in the reference order.
- ProcessOptions::target_size now develops Bayer, LinearRaw and mono
pictures at 1/2, 1/4 or 1/8 size (the smallest covering the
target) by averaging each colour over the blocks, without demosaic.
The first version is kept as `reference` (feature `writer`, tests and
benchmarks only): tests/equivalence.rs checks identical raw samples and
developed bits over all Bayer phases, both qualities, odd crops,
active areas, linearisation, black deltas, codes above the bit depth,
LinearRaw, mono, other CFAs and tiny pictures; examples/bench.rs times
both interleaved at 1/4/16 threads. Best of 9 under load ~12: tiles
2.5x (1 thread) to 2.9x (16), one strip 2.1-2.6x; half size 3-4x.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>