forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

vp9gates.report.md6.1 KiBHistoryRawDownload

lane-vp9gates — ec-vp9 ready for edith as its software VP9 decoder

Base: 95bc8a76 (main). Branch lane/vp9gates. Worktree ~/.cache/wt/vp9gates.

Changes

  1. Dead code removed (each verified unused by grep over crates/ec-vp9 and by the compiler):
    • read_partition (src/modes.rs), no callers.
    • TM_PRED (src/tables/mod.rs), no uses.
    • #![allow(dead_code)] in src/tables/gen_tables.rs. Removing it exposed two unused tables, COEF_CON_TREE and PT_ENERGY_CLASS, which are deleted.
    • Dead parameters of read_intra_frame_mode_info (partition_probs, x_mis, y_mis) removed, with the single call site updated.
  2. Cargo.toml [workspace.dependencies]: added ec-vp8 and ec-vp9 in the existing format (ec-vp9-syntax was already present).
  3. Input-reachable panics:
    • New compressed_header_slice helper in src/decode.rs. The compressed-header slices (three sites) were indexed with sizes read from the frame and could panic on a truncated frame. They now return Error::corrupt.
    • Tile-data start (data after the compressed header) now uses frame.get(..) and returns Error::corrupt when out of range.
    • Left as is, because the guard is local and the code cannot fail: the 4-byte try_into().unwrap() reads in decode.rs (tile sizes, guarded by ensure) and stream.rs (IVF demux, guarded by the loop bound). The expect("frame scratch") and expect("inter walk state") take/restore invariants are unchanged; the new no-panic test exercises them and found no violation.
    • All unwrap/expect/panic! sites in #[cfg(test)] code (bool encoder, stack_budget, superframe tests) are out of scope.
    • Full audit of every slice index in the ~10k lines is NOT done. The no-panic test below is the evidence for input safety, not a proof.
  4. Clippy clean. Mechanical fixes: Box re-assignment (*self.ctx = ...), operator precedence parentheses, div_ceil, unnecessary cast, assert!(!..), inlined format argument, as_chunks, if let for single-arm match, &f to f, for fr in. Structural lints are allowed crate-wide in src/lib.rs with a reason comment: too_many_arguments, type_complexity, needless_range_loop, neg_multiply, collapsible_if, ptr_arg. These mirror libvpx argument lists and spec index loops, and rewriting byte-exact kernels was out of scope.
  5. Marked superseded: lanes/vp9inter.report.md and lanes/vp9hbd.report.md now begin with the SUPERSEDED line.
  6. New test crates/ec-vp9/tests/no_panic.rs: truncated_and_corrupted_streams_never_panic. It uses the crate's committed tests/data/*.ivf (11 files), a fixed-seed xorshift generator (seed 0x5EED_00F0_0009), 24 container truncations and 24 container corruptions per file, and 24 frame-level mutations (truncation or byte corruption) on each of the first 3 frames after a valid prefix. Every panic is collected with its case label and reported together.

Verify

Run via scripts/remote-run.sh vp9gates -- ....

  • cargo clippy -p ec-vp9 -p ec-vp9-syntax --all-targets -- -D warnings: exit 0 (clean).
  • cargo test -p ec-vp9 -p ec-vp9-syntax --release --no-fail-fast: 60 passed, 12 failed. Baseline on 95bc8a76 (same command): 59 passed, 12 failed. The diff of per-test results is only the new test truncated_and_corrupted_streams_never_panic ... ok. The 12 failing tests are identical on main and on this branch:
    • dump_probe::diff_stats, keyframe_exact (2: keyframes_match_ffmpeg, lossless_64_matches_ffmpeg), and scratch_bool, scratch_err, scratch_hdr, scratch_hdr2, scratch_hdr3, scratch_lfdump, scratch_lossless, scratch_sweep, scratch_tok (9 scratch harnesses).
    • Cause on the server: ~/fixtures/vp9/ does not exist on the hosts (ls ~/fixtures on host a shows no vp9 directory), so fixtures/vp9/*.ivf reads fail with NotFound. The local primary checkout has fixtures/vp9/. This is an environment gap, not a code regression. Fixing it needs the server fixtures synced; I did not change the hosts.
  • The new no_panic test passes on this seed with zero panics (about 9 s in release).

Left

  • Fixture-dependent tests (above) need fixtures/vp9/ on the server to be green.
  • Full slice-index audit of decode.rs, inter.rs, mc.rs, loopfilter.rs for input reachability is not done. The no-panic test samples it; a fuzz pass would go further.
  • decode_syntax doc says "decode still refuses inter frames", which contradicts the inter path in decode. decode_stream doc mentions vp9 inter refusals for "lane-ineligible" frames. Both docs look stale; not edited here.
  • Debug env hooks (EC_VP9_FORCE_UH, EC_VP9_FORCE_HSZ, trace gates) are read in the decode path; they can change header sizes. Left in place.

Public API for edith (summary)

Entry points:

  • ec_vp9::decode::Decoder: new() / Default, decode(&mut self, frame: &[u8]) -> Result<Option<Picture>> (one frame or one superframe chunk; Some when shown), decode_syntax(&mut self, frame: &[u8]) -> Result<()> (syntax harness), and last_frame_blocks(&self) -> usize.
  • ec_vp9::stream::decode_stream(data: &[u8]) -> Result<Vec<Picture>> and decode_stream_with(data, sink: FnMut(&Picture, usize, u64) -> Result<()>) for whole IVF (DKIF/VP90) streams.

Frame type: ec_vp9::decode::Picture with y, u, v: Vec<Sample> (cropped planes), width, height: u16, stride, uv_stride: usize, bit_depth: u8, subsampling_x, subsampling_y: u8. Sample = u16 for every depth.

Errors: ec_vp9::{Error, Result} (re-exported from ec_core).

Supported (per crate docs and decode_one):

  • Profiles 0-3. Profile 3 reserved-zero bit is enforced (corrupt otherwise).
  • Bit depth 8, 10, 12. Other depths are Error::unsupported.
  • Subsampling 4:2:0, 4:2:2, 4:4:0, 4:4:4.
  • Keyframes, intra-only frames, inter frames (MC, residual, loop filter, 8-slot DPB), scaled references, show_existing_frame, odd dimensions.

Not verified here: edith wiring. Nothing in edith is changed by this lane.

Commit

lane/vp9gates: ec-vp9 dead code, checked slices, clippy clean, no-panic test