forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on 84fa44cfe66f76e22181d4ff8bc06ef6ea78db07Filtered to crates/ec-vp8/src/lib.rsClear filter

2026-09-12

ec-vp8: restore shared avx2 probe after idct revertAhmet Kaan Gümüş · 7ffca32
ec-vp8: restore shared avx2 probe after idct revert

The revert of 4d6a9f27 also dropped lib.rs's avx2_supported(), which
mc.rs's six-tap/bilinear kernels import since 79e13d22.
Revert "ec-vp8 perf: idct_add_into -- fused strided reconstruct + AVX2 kernel"Ahmet Kaan Gümüş · bb830d8
Revert "ec-vp8 perf: idct_add_into -- fused strided reconstruct + AVX2 kernel"

This reverts commit 4d6a9f2729070667f54554f1489603e0d29d0824.
ec-vp8 perf: idct_add_into -- fused strided reconstruct + AVX2 kernelAhmet Kaan Gümüş · abc2cab
ec-vp8 perf: idct_add_into -- fused strided reconstruct + AVX2 kernel

idct_add_into (28% of the post-MC-decode profile) now runs through
transform::idct_add_strided: the prediction gather, the transform, the
clamp-add and the strided stores in one function, with an explicit
std::arch::x86_64 AVX2 kernel dispatched off a shared LazyLock probe and
the scalar path kept as the libvpx transcription and lane-for-lane
oracle.

The kernel preserves the module's precision contract in full: the
butterflies are the scalar i32 arithmetic lane-parallel (products exact,
|i16 * 35468| < 2^31), and the only narrowing points are the oracle's
short stores -- pass one's tmp and pass two's residual -- implemented as
low-16-bit truncations via shuffle_epi8, never saturation. Coefficients
transpose to column groups (rows woven by unpack_epi16), pass one's
store-pattern transpose hands row groups to pass two, and the final
clamp is explicit max 0 / min 255 in i32 before a saturating pack that
never fires beyond the clamp. The equivalence test pushes coefficients
to the i16 rails precisely because the network is exact for every input.

Witness suite: 58 lib (new: simd-vs-scalar equivalence over rails +
random, four stride shapes) + 4 header_parse + 4 keyframe_exact + 3
stream_exact, byte-exact, debug and release. Zero warnings.
ec-vp8 perf: per-bool env lookups were 46% of decode profileAhmet Kaan Gümüş · 1a98a0f
ec-vp8 perf: per-bool env lookups were 46% of decode profile

std::env::var_os ran per bool read (bool.rs read_bool) and per MB
(decode.rs reconstruct) — each call takes std's ENV lock and allocates;
perf showed 46% of samples in getenv/__strlen. OnceLock::get_or_init
was no better (closure re-entry still hit the env path). Now both flags
resolve once per process into an AtomicU8 (relaxed load-only hot path).

Before -> after (decode MP/s): gop-160x96 32->82, clip-obs 51->122,
altref 16->55, gop-1280x720 137->211, big-obs-2560x1320 121->175
(35.7 -> 51.9 fps). Full witness suite byte-exact green.
ec-vp8 M4: public whole-stream API (ec-av1 decode_stream shape)Ahmet Kaan Gümüş · 93dee5c
ec-vp8 M4: public whole-stream API (ec-av1 decode_stream shape)

stream::decode_stream(IVF bytes) -> Result<Vec<Picture>> collects every
shown picture; stream::decode_stream_with hands each picture to a sink
(picture, decode_idx, IVF pts) the moment it exists. Hidden frames
(show_frame == 0) update the reference state and produce no sink call.
Container envelope (DKIF magic, VP80 fourcc, framing arithmetic) is
validated as ec_core::Error variants, not panics. Picture gains Clone.

Witness tests/stream_exact.rs: decode_stream byte-exact vs ffmpeg on
ALL 12 IVF fixtures (every frame, all planes) + malformed-container
errors. Suite: 55 lib + 4 header_parse + 4 keyframe_exact + 2
stream_exact, zero rustc warnings.
ec-vp8 M3 WIP: full inter-frame pipeline decodes; walled on one mode-record divergenceAhmet Kaan Gümüş · 10ef9be
ec-vp8 M3 WIP: full inter-frame pipeline decodes; walled on one mode-record divergence

Lands: inter mode/MV parse (prob_intra/last/gf, mv_ref census port of
libvpx read_mb_modes_mv incl. the dead CNT_SPLITMV merge, SPLITMV with
mbsplit leader/fill tables, NEAREST/NEAR clamps, NEW/SPLIT best-MV
deltas), chroma MV derivation (round-half-away mv/2 whole-MB; sum/8
SPLITMV), motion compensation in new mc.rs (6-tap luma + bilinear
chroma + 32px border extension; 6 unit tests plus 31,000-case
differential fuzz vs verbatim libvpx filter.c/extend.c - byte-identical;
chroma whole-MB path re-clamps unconditionally per reconinter.c:336),
reference buffer management in libvpx swap_frame_buffers order
(copy_arf, copy_gf, refresh_gf, refresh_arf, refresh_last), entropy
save/restore gated on refresh_entropy (probs only, like libvpx fc/lfc),
persisted segment map, inter LF levels with ref/mode deltas and
skip_lf inner-edge rule, EC_VP8_TRACE B-line per-read tracing in
BoolDecoder mirroring scripts/vp8ref_model.py.

State: inter frames decode end-to-end with no desync error; gop frame 1
matches ffmpeg 51% (frame 0 100%), diverging from MB(0,5) rightward -
one remaining mode-record/token divergence. Next: diff the B streams
(python3 scripts/vp8ref_model.py vs EC_VP8_TRACE=1) to localize it;
the python model still needs the inter-frame header/mode extension.

Suite: 55 lib (incl. 6 mc) + 4 header_parse + webp witness green;
keyframe_exact 1/3 (2 cases need the M3 fix to pass).
ec-vp8 M2 WIP: full key-frame decode pipeline (tokens/intra/transform/loopfilter/reconstruct) — unit tests 100% green, ffmpeg exactness witnesses RED (luma bug)Ahmet Kaan Gümüş · 5b0ae03
ec-vp8 M2 WIP: full key-frame decode pipeline (tokens/intra/transform/loopfilter/reconstruct) — unit tests 100% green, ffmpeg exactness witnesses RED (luma bug)

- tokens.rs: RFC 6386 sec 13 coefficient decoding (GetCoeffs port: bands,
  3-context model, EOB-skip-after-zero, dequant-on-write, Y2-first block
  order, dixie skip-MB context reset with Y2 preservation).
- modes.rs: all mode/MV trees + tables (kf/inter ymode, bmode, uv,
  mv_ref, sub_mv_ref, SPLITMV partitions with RFC enum-value indexing).
- decode.rs: per-row pipeline (modes -> tokens -> reconstruct), bordered
  planes (127/129), above-right synthesis, B_PRED interleaved
  predict+residual (reconstructed-pixel chaining), Y2 WHT DC override,
  per-MB LF level (dixie double-clamp), LF post-pass via loopfilter.
- loopfilter.rs + intra.rs + transform.rs: subagent kernels, rustc-verified
  vs libvpx C (differential fuzz: 400k IDCT/WHT vectors, 20k intra streams,
  dixie-table-exact LF limits).
- FIX along the way: per-MB-row token left-context reset (dixie
  reset_row_context) was missing.
- tests/keyframe_exact.rs: ffmpeg byte-compare witnesses — FAILING: single
  16x16 black q0 frame decodes chroma exact but luma ~99-130 vs 16 (B_PRED
  MB, coeffs plausible); suspected in luma pred/apply path, NOT yet
  localized. Debug: EC_VP8_DEBUG=1 dump + examples/dbg_first.
- 49 lib + 4 header tests green; zero warnings in lib.
ec-vp8 M1: bool arithmetic decoder, frame tag + full first-partition header parsing, RFC-transcribed tablesAhmet Kaan Gümüş · 5233d88
ec-vp8 M1: bool arithmetic decoder, frame tag + full first-partition header parsing, RFC-transcribed tables

- bool.rs: RFC 6386 section 7.3 decoder (read_bool/literal/signed_literal/
  maybe_signed/prob7/tree incl. the EOB-skipping token-tree form), plus a
  test-only reference bool encoder; round-trip tests at probability
  extremes, long LCG streams, literals to 19 bits, tree paths.
- frame.rs: 3-byte LE frame tag, key-frame start code + dimensions/scaling,
  MB geometry.
- header.rs: complete partition-1 header in dixie field order — colour
  space/clamping, segmentation (with cross-frame state), loop filter
  type/level/sharpness/deltas, token partition size table, quant indices,
  reference refresh/copies/sign-bias, coefficient probability updates,
  mb_no_skip_coeff, inter prob_intra/last/gf + ymode/uv/MV probability
  updates. PersistedState carries entropy/segmentation/filter deltas
  across frames and resets at key frames.
- tables.rs: GENERATED verbatim from the RFC text by
  scripts/extract_vp8_tables.py (element counts asserted): default + update
  coefficient probs, kf_bmode_prob, coeff_bands, dequant lookups, Pcat1-6
  (sentinel kept), default + update MV probs.
- scripts/gen_vp8_fixtures.sh: libvpx-encoded IVF witnesses (6 sizes/q,
  60-frame GOP, 8-token-partition vector via local vpxenc, WebP still).
- Witness: real vpxenc/ffmpeg-produced streams parse with exact tiling of
  partition sizes, correct dims (incl. 76x52 non-MB-aligned), 8 partitions;
  VP8-in-WebP still decodes its header. 12 tests green, zero warnings.