av1graincensus: census the grained picture, and cover uninit_plane's unsafe
census_unwritten_final runs in stream.rs before apply_grain, and
apply_grain is the one stage after it that allocates a NEW picture:
film_grain::uninit_plane, Vec::with_capacity + set_len, no fill.
lanes/unwritten-dep.report.md sections 6 and 8 both decline to claim
anything about that buffer, so the picture the caller actually receives
was unmeasured.
- decode.rs: census_unwritten_grained at apply_grain's return, with its
own GRAINED_UNWRITTEN_SAMPLES / GRAINED_CENSUS_SCANNED pair. The
scanned/found pairing is the same one the other two censuses use, so a
build with the call deleted cannot pass. census_sentinels is now the
shared counting body, returning None when the fill is off, so neither
caller can publish a meaningless zero. plane_poison and
plane_sentinel_on become pub(crate) so the fill and the count cannot
disagree about the value or the predicate.
- film_grain.rs: uninit_plane fills with that poison when
plane_sentinel_on(). Counting == poison over ambient garbage is not a
census -- a hole survives with probability ~1/65536, not always. With
the sentinel off, every shipped build, the allocation is still
with_capacity + set_len, so the documented corner-cut is untouched.
Both returns of apply_grain census, so the property is the function's
rather than one branch's.
- stream.rs: the gate, a synthetic control counting 5 rather than the
pre-grain arm's 7 (so reading the wrong counter reds), and per-fixture
scanned > 0, which is reachable only by grain having run.
Measured 0 unwritten on s422_grain_160x128, grain_cdef_lr_128x128 and
reelb_arf_witness. Mutations: deleting the call reds via scanned > 0; one
sentinel sample forced into a grained picture reds with exactly 3, the
fixture's 3 grained frames.
Class sweep, same lane: with copy_clean_rows neutered the census stays
correctly 0 -- the noise overwrites every sample it reads -- so it cannot
see a READ of uninitialised memory. That gate had no grain fixture at
all, leaving uninit_plane's unsafe uncovered; s422_grain_160x128 is added
and proven to bite (allocdet goes red on the same mutation, 0xDEAD vs
0xBEEF).
Report: lanes/av1graincensus.report.md