edith_codecs
Clone
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
av1safe-cdef: whole-frame CDEF without par::Shared
Outcome
par::Shared is no longer used by the whole-frame CDEF pass. The three
planes and the wrote byte map are carved into per-band &mut slices with
split_at_mut, and each band's cdef_band writes only through its own
slices. The unsafe blocks and #[allow(unsafe_code)] in
post_filter.rs::cdef_rows are gone. Output is unchanged.
Approach
par.rs(additive only):carve_ranges(element ranges to disjoint&mut [T], viasplit_at_mut) andrun_bands_with(likerun_bands, but each band gets its own payload).run_bands,run_bands_mut, andBatchare untouched.cdef_rowscomputes, per plane, element ranges per band: bandkowns plane rows from its first mi row ((mi*4) >> ss_y) to the next band's first row. The last band runs to the end of the buffer. This covers the padded tail whenmi_rowsis odd, since the trailing 8x8 block writes 4 rows pastmi_rows*4. Thewrotemap is carved the same way by unit row (mi/2).cdef_bandtakes aCdefBandDst(the band's three plane slices, each slice's first row, thewroteslice and its first unit row) plus a[CdefPlaneGeom; 3](stride, true width, true height). Reads stay on thesrc_*snapshots with absolute coordinates. Writes indexdst[oy - row0], and thewroteindex ismi_r/2 - wrote_row0.cdef_filter_block(cdef.rs) takes&mut [u16]andstrideinstead of&mut PlaneBuf. The SIMD and scalar kernels are untouched; they already indexdstfromoy, so passingoy - row0is enough.
Write-hazard check (task item 3)
The kernels (cdef_filter_block_scalar, cdef_simd::filter_block_avx2) never
read dst. Each writes exactly rows oy..oy+bh and columns ox..ox+bw.
Non-final bands are aligned to 2 mi (8 luma rows, 4 chroma rows), so every
block a band writes lies inside its own rows. The only overflow is the
trailing odd mi row of the frame, which the last band's slice covers. No
write reaches the neighbour band's rows, so no edge-row snapshot was needed.
Files
crates/ec-av1/src/par.rs(addedcarve_ranges,run_bands_with)crates/ec-av1/src/decode/post_filter.rs(cdef_rowsrewritten)crates/ec-av1/src/decode/replay.rs(cdef_band,CdefBandDst,CdefPlaneGeom)crates/ec-av1/src/decode/cdef.rs(cdef_filter_blocksignature)
Remaining unsafe
None in the CDEF pass. grep -n 'Shared\|unsafe' on post_filter.rs and
replay.rs returns nothing. par::Shared still exists for its other users.
cdef_simd.rs (the AVX2 kernel) is outside this task and was not changed.
Tests (server, EC_MEMGUARD_MAX=12G EC_AV1_AOM_DIR=... EC_REQUIRE_FIXTURES=1, --test-threads=4)
- Targeted:
filter_stage_bytes_do_not_depend_on_the_thread_count1/0; thecdef-named lib tests 10 passed, 0 failed, 2 ignored (run alone). --test aom_conformance: 1 passed, 0 failed.- Full gate (
cargo clippy -p ec-av1 --all-targets -- -D warningsclean, thencargo test --release -p ec-av1 --no-fail-fast): lib 817 passed, 0 failed, 49 ignored; aom_conformance 1/0; fuzz_regressions 5/0; real_library 0/0 (1 ignored); worker_panic 2/0; yuv422_dav1d 1/0; doctests 0. Total 826 passed, 0 failed, 50 ignored. The lib count is 817, which matches the base commit 4a2682cd. The 818 in the common notes predates the nopipe merge.
Bench (decode_bench, t1080.obu, default threads, host a, 3 alternating runs)
| run | base secs | lane secs |
|---|---|---|
| 1 | 16.933 | 19.214 |
| 2 | 18.629 | 16.358 |
| 3 | 14.078 | 16.679 |
| median | 16.933 | 16.679 |
Lane median is 1.5% faster than base (fps medians 17.72 base, 17.99 lane). The spread within each tree is about +-20%, so the difference is noise and there is no regression beyond the 3% threshold.