Commits
Commits on
cbbd6e2ef6acafb00aeb55e460423f024126f90fFiltered to crates/ec-av1/src/encoder.rsClear filter2026-09-06
perf(av1): band the encoder's frame-level filter stage across the tile workersAhmet Kaan Gümüş · 996b587
perf(av1): band the encoder's frame-level filter stage across the tile workers The per-tile search leaves every core idle for the rest of the frame. The filter stage now bands itself across the same workers: `par::override_filter_threads` (thread-local, so nothing outside this span changes) puts the deblock and CDEF replays, the capture decode's own filter chain and the loop-restoration passes on the decoder's existing band split, the per-64 SSE gets a unit-row band of its own (`unit_sse_rows`, partial u64 sums), and a candidate's ~6 MB plane copies come off a recycled buffer pool -- a fresh Vec per copy was 12.6% of a 1080p frame's wall in page faults alone -- banded when the buffer is already the right length. Gated by `filter_stage_bytes_do_not_depend_on_the_thread_count` (one tile, a cropping size, 1 vs 2/4/8 threads) and by `unit_sse_matches_the_naive_sum` at 2/4/8 bands.
perf(av1): the filter search's replay now covers cropped framesAhmet Kaan Gümüş · 8a4a771
perf(av1): the filter search's replay now covers cropped frames The encoder scores ~30 deblock/CDEF candidates per frame by replaying the loop filters on one captured reconstruction (`decode::FilterReplay`), but the capture demanded `frame == plane` dimensions -- and no export size meets that: 1080 and 1608 both pad to a superblock row. Every candidate at those sizes fell through to a full re-decode of the frame, which the new per-stage breakdown measures at 57% of a 1080p frame's wall. The capture now also fires on a cropped frame and the replay finishes with the decoder's own cropped return path (crop + wide-margin stash), so it is still exactly the decode it stands in for. 1920x1080, 8 frames, 4x2 tiles, 8 tile threads: 6.75s -> 2.63s (1.19 -> 3.05 fps); filter search 57.2% -> 27.6% of wall. Adds `par::timer`/`EC_AV1_STAGE_TIMES` (off by default: one relaxed atomic load per stage per frame) and `encoder::tests::filter_stage_wall_*`, plus `filter_replay_codes_the_same_stream_as_a_full_decode` at a cropping size.
test(av1): wall tables for the per-tile search at 1080p and 4K, with a librav1e referenceAhmet Kaan Gümüş · c69113cBrowse files
merge: lane-av1tiles with main ac6e60b4 (compound prediction)Ahmet Kaan Gümüş · e6c05e0
merge: lane-av1tiles with main ac6e60b4 (compound prediction) The per-tile jobs arm the compound lane's new thread-locals (arm_reference_select / arm_order_hints) on their own workers.
test(av1): tile BD-cost knob for the gate and a 1080p tile/thread wall tableAhmet Kaan Gümüş · ebca9e8
test(av1): tile BD-cost knob for the gate and a 1080p tile/thread wall table EC_AV1_TILES in a test build lets the BD gate code the same ladder under a tile grid; the 1080p wall table shows tile threads buy nothing yet -- the per-tile ENTROPY write is a few percent of the frame, the search is still whole-frame and single-threaded.
feat(av1): a frame's tiles are written in parallel on the crate's own poolAhmet Kaan Gümüş · 1878642
feat(av1): a frame's tiles are written in parallel on the crate's own pool EC_AV1_TILE_THREADS workers (default 1) take bands of the frame's tiles; each tile is written from the frame's own starting tables into its own slot, so the bytes never depend on the thread count -- pinned by tile_bytes_do_not_depend_on_the_thread_count at 2x1/1x2/2x2/4x2.
feat(av1): the encoder writes multi-tile frames, sample-exact at every layoutAhmet Kaan Gümüş · a01d142
feat(av1): the encoder writes multi-tile frames, sample-exact at every layout Uniform tile spacing (spec 5.9.15), one tile group OBU with per-tile sizes, context_update_tile_id on the largest tile, and per-tile CDF / LR-reference / neighbour-band / MV-grid resets mirroring the decoder's own tile loop. The writer's availability answers are tile-relative now (the intra_inter and tx-size contexts asked mi_row > 0 and coded a tile's first row against a neighbour the decoder does not have). EncoderConfig gains tile_cols_log2/tile_rows_log2 (default 0/0, byte-identical to the one-tile stream); ec-bench takes EC_AV1_TILES=<cols>:<rows>.
wip(av1): multi-tile writer, snapshot at the agent cap (may not compile)Ahmet Kaan Gümüş · 252b2d1Browse files
feat(av1): reference_select frames -- the comp_mode symbol and its skip-mode header gateAhmet Kaan Gümüş · 14a71ba
feat(av1): reference_select frames -- the comp_mode symbol and its skip-mode header gate The frame-header writer refused reference_select outright; it now writes the bit, and with it spec 5.9.22's skip_mode_present gate (skipModeAllowed mirrored from ec-av1-syntax's own read_skip_mode_params, off the per-reference order hints the encoder now hands the header from its DPB). Every inter block of a reference_select frame codes a comp_mode symbol at mvstack::reference_mode_ctx's context -- the writer side of decode.rs read_comp_mode -- and every block still names SINGLE, so the only stream change is that one symbol per block. Armed by EC_AV1_COMPOUND=1 in a test build; off by default until compound candidates exist to pay for the bit.
feat(av1): the encoder writes multi-tile frames (uniform spacing, per-tile CDF/LR/neighbour reset)Ahmet Kaan Gümüş · b8332ebBrowse files
docs(av1): post-merge pyramid sweep, why it ships off and what unblocks itAhmet Kaan Gümüş · 51ea72dBrowse files
fix(av1): the encoder's filter-search re-decode ignored ref_frame_sign_biasAhmet Kaan Gümüş · 28f2d42
fix(av1): the encoder's filter-search re-decode ignored ref_frame_sign_bias decode_inter_frame_tile_lr hard-coded NO_SIGN_BIAS, so the trial decode of a pyramid leaf reading its group's backward hidden ALTREF built different MV stacks than the writer and desynced into 'a reference frame selected with no picture at this frame's own ref_frame_idx slot'.
docs(av1): pin the pyramid QP-offset sweep and why the pyramid ships offAhmet Kaan Gümüş · 006a259Browse files
feat(av1): target-bitrate rate mode, per-level rate loop and an EC_AV1_PYRAMID knob on ec-benchAhmet Kaan Gümüş · 4d40670Browse files
test(av1): pyramid round trip through both decoders, per-reference hit counter, pyramid arm in the BD gateAhmet Kaan Gümüş · f025ec8Browse files
feat(av1): a two-level frame pyramid in the encoder facadeAhmet Kaan Gümüş · d496905
feat(av1): a two-level frame pyramid in the encoder facade Hidden ALTREF coded ahead of its display position and re-output by a show_existing_frame header, per-level quantizer offsets, a per-level rate loop and packet dts/level. The flat one-in-one-out path is untouched.
feat(av1): ALTREF as the frame two back, on an alternating slotAhmet Kaan Gümüş · 9310981
feat(av1): ALTREF as the frame two back, on an alternating slot Frame n refreshes slot 0 for odd n and slot 2 for even n, so the frame two back is still intact in the very slot this one is about to overwrite (read before write): ref_frame_idx names it as ALTREF_FRAME, LAST names the other slot, GOLDEN stays on slot 1. inter_frame_headers_slots is the header builder that takes the three slots apart; the five-argument inter_frame_headers keeps its old read-and-write-one-slot meaning for the hand-built fixtures. The RD prices each extra reference's two search-free modes from a slice, so LAST/GOLDEN/ALTREF share one code path. ALTREF is picked for 337/405/1793 blocks per ladder. BD-rate vs libaom 127.3/153.4/83.0 -> 126.5/152.9/80.9, vs rav1e 78.6/105.7/18.3 -> 77.9/105.5/17.6; wall 7.8/7.1/7.8 -> 8.0/7.2/7.7 s. ffmpeg decodes every stream sample-exact.
feat(av1): a real GOLDEN reference beside LASTAhmet Kaan Gümüş · 2f069ae
feat(av1): a real GOLDEN reference beside LAST The key frame refreshes all eight DPB slots and every inter frame only slot 0, so slot 1 still holds the key frame however long the GOP runs: inter_frame_headers now points ref_frame_idx[3] (GOLDEN_FRAME) at it, the encoder carries that picture through encode_sequence and Av1Encoder, and the 32x32 inter RD prices GOLDEN's two search-free modes (NEARESTMV off its own mv stack, GLOBALMV) beside LAST's whole mode set. No second motion search -- that stage owns the wall -- and one trial set per distinct (reference, vector) pair, so the added modes mostly reuse work. The trial decode of the filter search and the two GOP tests take the golden plane at RefPix index 4 (the array is keyed by reference NAME, not by DPB slot). GOLDEN is picked for 50%/56%/37% of inter blocks. BD-rate vs libaom 133.7/162.3/83.8 -> 127.3/153.4/83.0, vs rav1e 84.7/113.1/18.0 -> 78.6/105.7/18.3; wall 10.1/9.5/9.4 -> 7.8/7.1/7.8 s. ffmpeg decodes every stream sample-exact (ffmpeg_and_this_decoder_agree_on_a_gop).
feat(av1): carry the CDF state across frames (spec 7.20)Ahmet Kaan Gümüş · e161916
feat(av1): carry the CDF state across frames (spec 7.20)
Inter frames now leave `disable_frame_end_update_cdf` off, so each one
stores its end-of-tile tables with the counts reset and the next frame's
writer starts from them -- the encoder mirrors `stream::stored_cdfs_for`
exactly, and the key frame keeps the bit set, so what it stores is the
defaults it started from and the first inter frame is unchanged.
`sb_coeff_{key,inter}_frame_tile_cdfs` are the writers that take and leave
the caller's `Cdfs`; the old entry points wrap them with a fresh one.
`Encoded` carries `start_cdfs`/`next_cdfs`, `Av1Encoder` carries the state
between `encode` calls, and `decode_inter_frame_tile` takes an
`initial_cdfs` -- the same threading the frame's `tx_select` bit needed,
third instance of that class, and the three GOP tests (one of which checks
ffmpeg against us) now pass the frame's own start state.
BD-rate vs libaom 210.1/218.7/167.4 -> 202.6/206.6/159.0, vs rav1e
151.8/164.7/72.7 -> 144.5/153.2/65.9; wall unchanged at 7.9/7.4/7.6 s.2026-09-04
refactor(av1): FrameCtx stays crate-private -- public signatures back to what they wereAhmet Kaan Gümüş · 1c71b70
refactor(av1): FrameCtx stays crate-private -- public signatures back to what they were The FrameCtx refactor threaded `&crate::decode::FrameCtx` through 21 `pub fn` signatures, which put a `pub(crate)` type in the crate's public API: external callers of `Av1Encoder::encode` stopped compiling (tools/ec-bench). `Av1Encoder` now owns its `FrameCtx` -- one per stream, not per frame, since the inter-frame inheritance guards carry state across frames -- so `encode` takes `(&mut self, picture)` again. `encode_key_frame`, `encode_key_frame_with_modes` and `encode_sequence` keep their old public signatures as wrappers over `pub(crate) *_with_ctx` inners that make the context. The other 14 helpers that gained the parameter (intra/mc/warp/motion predictors, `decode_key_frame_tile`) have no caller outside the crate and become `pub(crate)`. `Av1Encoder` is still `Send` (compile-time assert), but owning cells makes it `!Sync`; nothing in the workspace shares one by reference.
refactor(av1): the 38 per-frame decode-state thread_locals become one FrameCtxAhmet Kaan Gümüş · b9a9498
refactor(av1): the 38 per-frame decode-state thread_locals become one FrameCtx Every per-frame/per-stream decode state in ec-av1 lived in a thread_local! static, so a decode was a function of the calling THREAD's history rather than of the bitstream, and a worker thread saw empty state -- the blocker for frame-parallel decoding. All 38 (SB128, BIT_DEPTH, SUPERRES, CDEF_*, DELTA_Q_*/DELTA_LF_*, CURRENT_Q_IDX, QUANT_DELTAS, the 9 SEG* maps, TX_SELECT_INTER, REDUCED_TX_SET_INTER, ENABLE_FILTER_INTRA_INTER, PALETTE_PRED, INTRABC_*, LUMA_TX_TYPE, INTRA_IN_INTER_MODE, INTER_STRIP_CHROMA, INTER_LAST_MC, ENABLE_EDGE_FILTER, LAST_FRAME_WIDE_MARGIN, REACH_SB_PX, GRAIN_BIT_DEPTH) are now fields of decode::FrameCtx, owned by decode_stream_with and threaded as `fctx: &FrameCtx` down the decode call graph (~1200 call sites). The fields keep the Cell/RefCell interior mutability the statics had, so every read/write site is byte-identical and this is a pure ownership move; Cell/RefCell also make FrameCtx !Sync on purpose -- one context per decoding thread, never shared. The scratch pools, gate hit counters and trace switches stay thread_local by design.
2026-09-01
fix(av1): have_ffmpeg() SKIPped green under EC_AV1_REQUIRE_AOMENC=1Ahmet Kaan Gümüş · 91c1335
fix(av1): have_ffmpeg() SKIPped green under EC_AV1_REQUIRE_AOMENC=1 Every real-aomenc gate opens `if !have_ffmpeg() || !have_aomenc()`, and only have_aomenc() asserted under the require flag -- have_ffmpeg() is evaluated first and short-circuits, so a machine without ffmpeg printed SKIP and the whole 20-gate batch reported green with the require flag set (class gate-skips-on-its-own-failure). have_ffmpeg() now mirrors have_aomenc(): absence panics when EC_AV1_REQUIRE_FFMPEG=1 or EC_AV1_REQUIRE_AOMENC=1 is set (an aomenc gate decodes its stream through ffmpeg, so requiring the oracle implies requiring ffmpeg). Applied to all five copies of the helper (stream/tile/decode/encode/encoder test modules), which had the same silent-false shape.
2026-08-30
2026-08-27
feat(av1): a quality/size targeting surface over base_q_idxAhmet Kaan Gümüş · a55d2ef
feat(av1): a quality/size targeting surface over base_q_idx
RateTarget::{QIndex,Quality,BytesPerFrame} on Av1Encoder::with_rate_target,
additive alongside the existing EncoderConfig::base_q_idx path. Quality
maps to base_q_idx via the calibration sweep's linear fit; BytesPerFrame
steers it with a clamped proportional controller (no accumulated debt, so
no windup class to bound). Calibration sweep test records the curve.2026-08-26
wip(av1): write the true display size as frame_width/height, not the padded oneAhmet Kaan Gümüş · 6b1cdcc
wip(av1): write the true display size as frame_width/height, not the padded one Frame headers now carry the picture's true (unpadded) size as frame_width/frame_height, with mi_cols/mi_rows derived from that true size via spec compute_image_size (2*((w+7)>>3)) instead of the padded picture's width/4 -- mirroring rav1e/libaom, so a decoder crops to the true size instead of the coded (padded-to-32/64) one. render_width/render_height come out equal to frame_width/frame_height, so render_and_frame_size_different is false and no render_size bits are written. tile.rs: check_blocks no longer requires mi_cols/mi_rows to be an exact multiple of the 32x32 block grid (a true size need not be); a new block_grid() ceiling-divides mi_cols/mi_rows into the block-column/row count actually coded, shared by sb_coeff_key_frame_tile, split_coeff_key_frame_tile and (now) encode_key_frame_inner's own block/superblock generation loop, which used to derive its cols/rows straight from the padded picture's width -- it must agree with the tile writer's own count exactly. KNOWN REGRESSION, not yet root-caused: three existing round-trip tests that used a size not a whole 32x32 (or, for the facade, 64x64) block now fail ffmpeg/dav1d decode with "Invalid data found" (an_854x480_picture_round_ trips_through_its_padding, a_frame_round_trips_at_its_own_size at 1920x1080/ 640x352/1280x720, sequence_round_trips_at_a_non_multiple_size at 160x96). Reasoned through the cols/rows/has_cols/has_rows arithmetic by hand for the BLOCK(32)-alignment case and it should be invariant (true mi_cols/mi_rows land in the same (padded-8, padded] window that keeps every BLOCK_MI(8)- aligned threshold's comparison unchanged) -- confirmed by an EC_RNG-gated rng-per-symbol trace (temporary, reverted) diverging from aomdec's own trace from the very first symbol, which does not match that reasoning and was not resolved before the turn budget ran out. The three tests' own assertions were updated to expect the new true-size ffprobe/decode behaviour (that part is not in question); the decode failure itself is the open defect. Not attempted: sb_coeff_inter_frame_tile has no has_cols/has_rows-style partial-superblock handling at all (always PARTITION_SPLIT, always 4 quadrants) -- a true size that isn't a 64x64 (SUPERBLOCK) multiple needs that ported from the key-frame writer before an inter/multi-frame stream can use a true, non-superblock-aligned size. The facade's key-frame path already regresses today for the same underlying reason before inter frames are even reached.
feat(av1): streaming encoder facade with configurable colour (I11)Ahmet Kaan Gümüş · f421d98
feat(av1): streaming encoder facade with configurable colour (I11)
Av1Encoder is the one-in-one-out surface edith_replica's engine will call
in place of rav1e: EncoderConfig{width,height,base_q_idx,gop,colour} in,
encode(&Picture) -> Packet{data,key,order} out, gop-cadenced key frames
predicting inter frames from the previous reconstruction like
encode_sequence already did. encode_key_frame_inner/encode_inter_frame
are now shared (pub(crate)) between encode_sequence and the facade
instead of being duplicated. The sequence header's colour_config is wired
to Colour::{Bt709Limited,Bt601Limited,Unspecified} (spec 5.5.2's CICP
triple + range), replacing the hardcoded "unspecified" -- verified against
ffprobe.