Files
effectcraft/crates
Camille Moine a05d97a0e9 effects: speed up Match Grain's CPU analysis
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.
2026-10-19 20:44:32 +02:00
..
2026-10-18 09:37:06 -04:00
2026-10-18 09:35:35 -04:00
…
2026-10-18 09:35:35 -04:00
2026-10-18 09:35:32 -04:00
2026-10-18 09:35:33 -04:00
…
2026-10-18 09:35:34 -04:00
…
2026-10-18 09:35:35 -04:00
2026-10-18 09:36:05 -04:00
2026-10-18 09:35:33 -04:00
2026-10-18 11:12:44 -04:00