The crop kept 3 px of halo, which makes the blur exact inside a box, but the
lag-1 correlation also reads the right neighbour's high-pass residual — one
column outside the box, still polluted by the crop edge when another box
covers it (adjacent boxes are the norm with a step of size/2). The size
estimate drifted by ~5e-5 in the parity test; a 4 px halo removes it.
The parity test now holds std to 1e-6 and size to 1e-7 (was 5 % for size),
and the boxed statistics still cost 1.8 / 3.1 ms at 1080p / 4K.
The sample-box search rescanned every candidate box and the grain statistics
blurred the whole image three times per layer, although Match Grain only reads
the 80 sample boxes (~6.5k pixels). On a 4K frame that analysis was ~90 % of
the effect.
- measure the statistics from small crops around each box (3 px halo, the
Gaussian's support), deduplicating overlapping boxes so the sums match the
previous masked version;
- search the candidate box rows in parallel (the sort is a total order, so the
chosen boxes are unchanged);
- compute the "own" boxes and stats only when Compensate for Existing Noise is
on, and clone the frame for Preview composition only in Preview mode;
- run Plane::transpose/map_rows on the calling thread for small planes: the
rayon dispatch dominated per-box crops (240 blurs of ~15x15).
Release, Ryzen Threadripper 1920X, noisy source / flat target, defaults, best
of 4 (1080p / 4K):
- grain statistics: 151/463 ms -> 1.2/2.8 ms
- sample boxes (source): 43/179 ms -> 16/71 ms
- end to end: 266/1416 ms -> 99/465 ms (Compensate 50 %: 392/1830 -> 104/482)
Tests: the boxed statistics match the masked ones (overlapping and corner
boxes, alpha holes), plus the existing Match Grain/Remove Grain suites.
- render --progress with a piped stderr writes well-formed
`progress <done> <total> <elapsed> <left|->` lines, one per change, and
the same render without the flag writes none.
- A template's Media Replacement control takes {"path"|"file"|"media": …},
is found by name ignoring case, and a path that cannot be imported fails
with an error naming the control and the path.