mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-30 13:08:07 -06:00
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.