Commits
2026-08-28
feat(av1): compound CONV_BUF blend + distance-weight assign, not wired yetAhmet Kaan Gümüş · 181a784
feat(av1): compound CONV_BUF blend + distance-weight assign, not wired yet mc.rs: predict_compound_intermediate (round_1=7, no clip, mirrors libaom's COMPOUND_ROUND1_BITS path) and combine_compound (spec 7.11.3.15 weighted average, shift = InterPostRound + DIST_PRECISION_BITS) -- pinned against a whole-pel identity case that round-trips exactly through both stages. compound.rs (new): dist_wtd_comp_weight_assign, a pure port of libaom's av1_dist_wtd_comp_weight_assign (quant_dist_weight/quant_dist_lookup_table search), tested standalone against hand-worked order-hint cases. Neither is wired into decode.rs yet -- comp_group_idx/compound_idx reads, Neighbours compound_idx tracking, and the reconstruction call sites are still open (see HANDOFF).
wip(av1): temporal MV projection math (spec 7.9/7.10.2.8), not yet wiredAhmet Kaan Gümüş · 916263c
wip(av1): temporal MV projection math (spec 7.9/7.10.2.8), not yet wired New crate::motion_field module: MotionField (per-frame saved 8x8 MV grid + order-hint bookkeeping), setup_motion_field (av1_setup_motion_field's LAST/BWDREF/ALTREF2/ALTREF/LAST2 selection + motion_field_projection's distance-scaled projection into a TplField), and add_tpl_ref_mv (the per-query-block second projection). All ported from libaom av1/common/mvref_common.c, unit-tested against hand-checked distance/ projection arithmetic. mvstack::find_mv_stack_with_sign_bias gains an Option<TplArgs> parameter: when Some, folds temporal candidates into the stack at libaom's real insertion point (after the row/col/top-right REF_CAT_LEVEL boost, before the corner probe) and derives zero_mv_ctx (GLOBALMV_OFFSET) from them; None (every existing caller today) reproduces the prior always-0 exact behaviour bit for bit -- all 13 existing mvstack unit tests still pass unmodified. NOT DONE: decode_inter_block's only call site still passes tpl: None (see its own TODO), and nothing in decode_inter_frame_tile_with_cdfs or stream::decode_stream builds a per-DPB-slot MotionField or calls setup_motion_field -- so decode::tmv_hits() reads 0 against any real stream, and no temporal-MV gate exists yet. See ledger DELTA for the precise remaining wiring.
feat(av1): implement spec 7.18.3 film grain synthesis, flip the refusalAhmet Kaan Gümüş · 84e41d9
feat(av1): implement spec 7.18.3 film grain synthesis, flip the refusal Port the AR-filtered grain template generation, piecewise-linear scaling LUT, and 32x32/16x16 tiled overlap-blend application from libaom's reference synthesis (crates/ec-av1/src/film_grain.rs), wired into decode_stream's frame-finalize path so the reference bank keeps the clean pre-grain decode (spec 7.18.3.1) while only the caller's output picture carries grain. Header parsing (ec-av1-syntax FilmGrainParams, load_grain_params ref-slot forwarding) was already spec-complete -- no changes needed there. Replaces the apply_grain refusal with a pixel-exact gate against ffmpeg's own AV1 decoder on the pinned aomenc fixture (frame 0, the span the original mismatch was traced to; later frames in that fixture hit an unrelated pre-existing GOLDEN_FRAME MC gap, out of this lane's scope), plus an aomenc multi-seed sweep gate that skips gracefully when aomenc is unavailable.
2026-08-27
feat(av1dec): public decode_stream OBU walker, bench decode row, NEARMV liftAhmet Kaan Gümüş · 16b0ce0
feat(av1dec): public decode_stream OBU walker, bench decode row, NEARMV lift decode_stream(&[u8]) walks a raw AV1 stream via ec-av1-syntax's Av1Parser, extracts each Frame OBU's header + tile payload and dispatches to the existing decode_key_frame_tile/decode_inter_frame_tile, threading a single-slot DPB -- the first real entry point that does not need Encoded's pub(crate) fields. ec-bench's av1 row now times decode_stream instead of reporting "no decoder present". decode_inter_block also reconstructs NEARMV (mvstack already carries the second stack candidate), tested by hand-driving a symbol stream since this crate's own encoder never chooses that mode.
feat(av1): begin a software key-frame decoder (round 1)Ahmet Kaan Gümüş · e6eadb9
feat(av1): begin a software key-frame decoder (round 1) Promotes msac's test-only SymbolDecoder to a real, non-test decoder (the inverse of SymbolEncoder, already spec-derived and roundtrip tested), and adds crates/ec-av1/src/decode.rs: a from-spec reader that mirrors tile.rs's sb_coeff_key_frame_tile symbol order (partition tree through 64x64/32x32/16x16, coefficient base/base-range/EOB/Golomb/sign syntax, CDF adaptation) without importing from tile.rs, which a sibling lane is editing concurrently. Round 1 scope: key frames only, DC_PRED blocks only, unskipped, and frames a whole number of 64x64 superblocks -- everything else refuses with a named error rather than miscoding. Within that scope, real encoder output (encode_key_frame_with_modes forced to DC_PRED, two sizes, real quantised AC/DC residual) decodes byte-exact against the encoder's own reconstruction. Encoded gains three pub(crate) fields (tile, mi_cols, mi_rows, base_q_idx) so a decoder test can reach the raw tile payload without re-deriving it from the OBU stream. Deferred to round 2: non-DC_PRED intra modes (needs the directional edge-reach plumbing), inter frames, skipped blocks, and the partial-superblock/gathered-CDF true-edge path.
2026-08-26
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.feat(av1): diamond/log integer + half/quarter-pel motion searchAhmet Kaan Gümüş · 5986059
feat(av1): diamond/log integer + half/quarter-pel motion search Adds crates/ec-av1/src/motion.rs: a log/diamond integer-pel search over one reference plane through mc::predict, refined by one half-pel then one quarter-pel round. Cost is SAD + lambda * mv_bits, where mv_bits prices the MV residual (joint/class/bit/fraction/hp) by interval-narrowing through encode::symbol_bits against the cdf::MV_* tables, matching the tile writer's own convention rather than a per-entry probability lookup. SEARCH_INITIAL_STEP_PEL=8 landed from a three-way sweep (4/8/16) recorded in motion.rs's own inline test. SAD chosen over SSE per a doc-comment measurement.
Merge branch 'lane-av1-mvstack': spec-7.10.2 MV stack, single-ref reductionAhmet Kaan Gümüş · 402402fBrowse files
feat(av1): MV prediction stack (spec 7.10.2, single-ref reduction)Ahmet Kaan Gümüş · ec98d16
feat(av1): MV prediction stack (spec 7.10.2, single-ref reduction) find_mv_stack scans row-above/col-left/top-right neighbours over a block's whole 4x4-mi span, dedupes into a weighted RefStackMv, and derives NearestMv/NearMv/PredMv plus NewMv/RefMv/ZeroMv/DRL contexts. Compound refs, temporal MV projection and bit-exact context tables are deliberately out of scope until a consumer needs them.
feat(av1): sub-pel motion compensation (spec 7.11.3, EIGHTTAP regular)Ahmet Kaan Gümüş · 082d993
feat(av1): sub-pel motion compensation (spec 7.11.3, EIGHTTAP regular) Two-stage separable 8-tap filter, InterRound0=3/InterRound1=11 for 8-bit non-compound per spec 7.11.3.2, edge samples clamped rather than read out of range. Not yet wired into encode.rs (later lane).
feat(av1): the tile adapts its CDFs as it writesAhmet Kaan Gümüş · 8a54f53
feat(av1): the tile adapts its CDFs as it writes AV1's symbol decoder updates every non-literal CDF it reads, so an encoder that leaves `disable_cdf_update` off has to keep the same state and update it in the same order. This adds that state and writes the key frame's tile through it. Tables the decoder keeps one copy of are one copy here too: a 64x64 luma transform reads the 32x32 base-range rows, both luma sets share one DC sign and one 1024-position end-of-block table, and both chroma sets share their own sign table. The gathered partition CDF an edge superblock reads is built for the read and thrown away, so nothing adapts there. The coefficient rate term still prices against the defaults: the mode search runs before the tile is written, so the adapted state does not exist yet. BD-rate against the same encoder with adaptation off, over a three-point ladder: -3.52% on a 1080p film frame, -5.63% on a screen capture, -11.25% on the test card. The ffmpeg/dav1d roundtrips are the gate -- a decoder adapting its own tables desyncs the moment the order or the sharing differs.
2026-08-25
feat(av1): seven intra modes, picked per block by rate-distortionAhmet Kaan Gümüş · 4331d17
feat(av1): seven intra modes, picked per block by rate-distortion The predictors of spec 7.11.2 that read no further than the row above and the column left of a block -- DC, V, H, SMOOTH, SMOOTH_V, SMOOTH_H and PAETH -- with the edge construction that fills a missing side from the side that exists. Each 32x32 luma block now codes under all seven and keeps the one whose squared error and estimated rate come out cheapest; chroma stays DC, which is the mode the tile writer codes for it. The weight on rate was swept over three real clips and two synthetic pictures at six values; 0.05 step-squared per bit is the best point on every one. Against DC alone it saves 11.5% of the rate on screen capture, 7.8% on the test card and 59.5% on a picture that runs one way. Against libaom the gap at matched size on a film frame narrows from 2.4 dB to 2.0 dB. Every mode is gated forced over a whole picture, with ffmpeg's reconstruction equal sample for sample, and striped pictures gate the search on picking the direction the picture runs -- a transposed predictor passes every symmetric test.
feat(av1): encode a key-frame pictureAhmet Kaan Gümüş · a4fb030
feat(av1): encode a key-frame picture DC intra prediction over the reconstruction, the forward transform and quantizer, and the tile writer, joined into an encoder that takes a planar 4:2:0 picture and produces a stream. Blocks are 32x32 luma and 16x16 chroma, coded in the order a decoder walks a superblock's quadrants. The gate is an equality: ffmpeg's decode of the stream matches the encoder's own reconstruction sample for sample, on every plane, for test cards at three sizes and for a frame of real video. Prediction reads the reconstruction, so a single sample of drift would spread through every block below and to the right of it. At q_idx 100 a 640x352 film frame costs 32 366 bytes at 39.26 dB, which is about 2.4 dB behind libaom at the same rate -- the size of what is not implemented yet: one block size, one transform type, DC prediction only, no rate-distortion decision, no CDF adaptation.
feat(av1): dequantization and the inverse DCTAhmet Kaan Gümüş · 6a83833
feat(av1): dequantization and the inverse DCT An encoder that cannot say what the decoder will show cannot choose coefficients by what they cost against what they are worth. This adds the decode-side arithmetic to ec-av1: the dequantizer of spec 7.12.3 and the inverse DCT of 7.13, written from the specification's own butterfly stage list so that one network serves every size from 4 to 64. The gate is agreement with a real decoder, sample for sample: two key frames whose first block carries coefficients from DC to the far corner decode under ffmpeg to exactly 128 plus the residual this code computes, over all 1024 and 4096 samples. Beneath that sit the two tables of decoder-pinned DC residuals the tile tests already carried, all 28 levels of each, plus structural gates for the transpose, the sign rounding, and the row shifts of the four sizes the frame syntax cannot reach. Mutation-checked: a cosine table entry off by one, and an 8x8 row shift off by one, each fail a named test.
feat(av1): first frame that a real decoder decodesAhmet Kaan Gümüş · 304ec65
feat(av1): first frame that a real decoder decodes A tile payload writer for the one block coding the encoder can produce so far: a key frame whose every superblock is one skipped 64x64 DC-predicted block. Four symbols per superblock — the partition, the skip flag and the two intra modes — with the frame header turning off everything that would add syntax the writer does not code yet (CDEF, loop restoration, filter intra, screen content tools, transform size selection, CDF adaptation). The default CDF tables of spec section 9.4 arrive with it, in the same orientation the symbol coder reads: the partition, skip, key-frame luma mode and CFL-free chroma mode tables, which is what this syntax touches. Gated end to end rather than by roundtrip: the stream is handed to ffmpeg and every sample of the decoded frame must be 128, which is what a DC prediction with no neighbours and no residual produces. Any desync between our arithmetic coder and dav1d's shows up as a decode failure or a sample that is not mid-grey, with no metric in between to hide it. Frames that are not a whole number of superblocks are refused by name: a partial superblock forces the partition syntax down the block tree.
feat(av1): symbol coder for tile payloadsAhmet Kaan Gümüş · a580965
feat(av1): symbol coder for tile payloads AV1 specifies only the decoding process for its multi-symbol arithmetic coder, so the writer is derived as the inverse of section 8.2: it narrows the same interval decode_symbol tracks and flushes the shortest prefix that pins the interval down whatever bytes follow. CDF adaptation follows section 8.3.2, and CDFs are stored in the specification's own orientation (cumulative, 1 << 15 total, counter in the last entry) so the code reads against the spec text rather than against a decoder's internal complement. Covers the adaptive multi-symbol write, the fixed-CDF write, and L(n) literals; the flush handles carry propagation through the precarry buffer. Gated by a decoder written separately from the section 8.2 pseudocode: alphabets of 2..=16 symbols roundtrip over 4000 adaptive symbols each, 2000 mixed-width literals roundtrip, a 3000-item interleaving of both roundtrips, and a 1-in-256 stream is asserted to cost under a quarter bit per symbol so a backwards interval narrowing cannot pass. This is the primitive every AV1 tile payload is written through; the OBU writers so far cover only the headers around it.
feat(av1): write the key-frame header OBUAhmet Kaan Gümüş · e203345
feat(av1): write the key-frame header OBU The inverse of `ec_av1_syntax`'s `parse_uncompressed_header`, for the subset a stateless encoder emits: a shown key frame in a sequence with no decoder model, no frame id numbers and no still-picture shortcut. It covers tile info (uniform spacing), quantization, segmentation, delta q and delta lf, loop filter, CDEF, loop restoration, transform mode and the reduced transform set, plus `frame_obu` to carry the header and a tile group in one OBU. Two of the codings are not the value they look like and are spelled out here: the restoration type is remapped (None 0, Switchable 1, Wiener 2, Sgrproj 3, not the enum's discriminant) and a CDEF secondary strength of 4 is coded as 3. Everything outside the subset is refused by name rather than written wrong: a superres denominator other than 8, film grain synthesis, frame id numbers, decoder model timing, `show_existing_frame`, any non-key or hidden frame, and non-uniform tile spacing. The tests parse back every stream they write through `Av1Parser` and compare the whole `FrameHeader`, including the derived fields the format never codes (the header's own bit length, the tile start ramps, the segmentation id range), across a one-tile frame, a four-tile-column frame, a segmented frame with delta q and delta lf, and a frame using loop restoration.
2026-08-24
feat(ec-av1): OBU header/framing writer + sequence-header writerAhmet Kaan Gümüş · 4cb83b2
feat(ec-av1): OBU header/framing writer + sequence-header writer Bit-exact inverse writers of the parsers in ec-av1-syntax: obu.rs: - obu_type_code: ObuType -> 4-bit code (inverse of ObuType::from_code) - write_obu_header: writes OBU header (spec 5.3.2), forbidden/reserved bits 0 - wrap_obu: frames payload as low-overhead OBU (header + leb128 size + payload) - temporal_delimiter: the two-byte 0x12 0x00 temporal-unit marker sequence.rs: - write_sequence_header: full sequence-header payload (spec 5.5.1) - write_color_config: color_config() inverse (spec 5.5.2) - sequence_header_obu: wraps the payload as a SequenceHeader OBU Supported subset only (unsupported configs return Error::unsupported): - reduced_still_picture_header == false (still-image header not implemented) - no timing_info - no decoder_model_info - exactly one operating point Roundtrip tests: write -> parse back -> assert equality for both OBU headers (plain + extension) and sequence headers; wrapped OBU leb128 size asserted to match payload length; temporal delimiter asserted to be [0x12, 0x00]. Gates: cargo test --release -p ec-av1 (13 passed), cargo clippy --release -p ec-av1 --all-targets (clean), cargo fmt.