From 9c0a4a27bac71eb3fffbd1b272c55df6beebec90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 12 Sep 2026 09:01:19 +0300 Subject: [PATCH] fix(av1): the raw-tile inter decode wrapper takes the frame's own reduced_tx_set instead of guessing true -- the widened inter search made the bit chroma-relevant (a screen GOP's inter luma takes V_DCT and the chroma inheritance reduces against this exact bit, so the GOP round-trip tests desynced and surfaced the empty-ref-slot refusal), Encoded carries the bit and the GOP and key-frame tile tests pass it; encoder output is byte-identical (witnesses re-run at 8143/8211 bytes), the three tests plus pins are green and the full three-lane suite reads 592 passed / 0 failed --- crates/ec-av1/src/decode.rs | 35 +++++++++++++++---- crates/ec-av1/src/encode.rs | 13 ++++++- crates/ec-av1/src/stream.rs | 7 ++-- lanes/intertx.report.md | 68 +++++++++++++++++++++++++++++++++++-- 4 files changed, 112 insertions(+), 11 deletions(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 547ef621..023dbbbe 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -34443,6 +34443,10 @@ pub(crate) fn decode_inter_frame_tile( interp_fixed: Option, enable_dual_filter: bool, reference_select: bool, + // lane-intertx: this frame header's own `reduced_tx_set` (spec 5.9.2) -- + // see [`decode_inter_frame_tile_lr`]'s parameter. Same stale-header + // class as `tx_select` below. + reduced_tx_set: bool, // This frame header's `tx_mode == TxMode::Select`: `Encoded::tx_select`. // Hard-coding `false` here desynced at the first `tx_depth` symbol once // inter frames coded Select by default (class: test asserts against a @@ -34463,7 +34467,7 @@ pub(crate) fn decode_inter_frame_tile( decode_inter_frame_tile_lr( data, mi_cols, mi_rows, base_q_idx, frame_width, frame_height, refpix, cdef, loop_filter, allow_high_precision_mv, force_integer_mv, interp_fixed, - enable_dual_filter, reference_select, tx_select, + enable_dual_filter, reference_select, reduced_tx_set, tx_select, &LoopRestorationParams::default(), initial_cdfs, NO_SIGN_BIAS, false, // `enable_filter_intra`: as the `false`s beside it, this convenience // entry names a stream written without the sequence bit (lane-fintra). @@ -34489,6 +34493,15 @@ pub(crate) fn decode_inter_frame_tile_lr( interp_fixed: Option, enable_dual_filter: bool, reference_select: bool, + // lane-intertx: this frame header's own `reduced_tx_set` (spec 5.9.2). + // The wrapper used to hard-code `true` ("the tests all code the reduced + // sets") -- true until the widened inter search put 1-D/DTT types on + // `reduced_tx_set = 0` frames' inter luma, whose CHROMA then inherits + // the type against this very bit + // ([`reduce_inherited_chroma_tx_type`]): guessing `true` mis-derives + // every inherited chroma type and desyncs the tile (class: test asserts + // against a stale header, next instance). + reduced_tx_set: bool, tx_select: bool, lr: &LoopRestorationParams, initial_cdfs: Option, @@ -34546,9 +34559,9 @@ pub(crate) fn decode_inter_frame_tile_lr( interp_fixed, enable_dual_filter, reference_select, - // lane-txi: this wrapper's callers are the decoder's own tests, which - // all code the reduced sets. - true, + // lane-intertx: this frame's own bit, not the hardcoded `true` -- + // see the parameter's note above. + reduced_tx_set, tx_select, lr, initial_cdfs, @@ -38784,6 +38797,9 @@ mod tests { Some(mc::InterpFilterKind::Regular), false, false, + // The fixture's own implied header codes the reduced sets (the + // wrapper's old hardcoded value). + true, false, None, false, @@ -39277,6 +39293,12 @@ mod tests { // `false` (stale-header class -- a `reference_select` stream // reads a `comp_mode` symbol this decode would skip). crate::encode::reference_select(), + // lane-intertx: this frame's own `reduced_tx_set` -- the + // bit the chroma inheritance reduces against. The wrapper + // used to guess `true`, which mis-derived every inherited + // chroma type on a screen frame's widened inter blocks + // (stale-header class). + frame.reduced_tx_set, frame.tx_select, &frame.loop_restoration, Some(frame.start_cdfs.0.clone()), @@ -39619,9 +39641,10 @@ mod tests { // The encoder's own `reference_select` (spec 5.9.22): these // GOP round trips decode a tile the ENCODER wrote, so the // header bit must be the one it wrote, not a hard-coded - // `false` (stale-header class -- a `reference_select` stream - // reads a `comp_mode` symbol this decode would skip). crate::encode::reference_select(), + // lane-intertx: the frame's own `reduced_tx_set` -- see the + // first GOP round trip's note. + frame.reduced_tx_set, frame.tx_select, &frame.loop_restoration, Some(frame.start_cdfs.0.clone()), diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index a79a890f..d7f7a60c 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -1797,6 +1797,7 @@ pub(crate) fn crop_encoded(encoded: &Encoded, width: usize, height: usize) -> En tx_select: encoded.tx_select, switchable_motion_mode: encoded.switchable_motion_mode, screen: encoded.screen, + reduced_tx_set: encoded.reduced_tx_set, start_cdfs: encoded.start_cdfs.clone(), next_cdfs: encoded.next_cdfs.clone(), loop_filter: encoded.loop_filter, @@ -1883,6 +1884,14 @@ pub struct Encoded { /// palette-mode symbols under it, so a raw tile decode that guessed /// `false` would desync at the first block (same class as `tx_select`). pub(crate) screen: bool, + /// This frame header's own `reduced_tx_set` (spec 5.9.2) -- the bit that + /// picks the inter `tx_type` alphabets AND, on an inter block, the + /// allowance the chroma transform's inherited type reduces against + /// ([`crate::decode::reduce_inherited_chroma_tx_type`]). A raw tile + /// decode that guesses `true` here mis-derives every inherited chroma + /// type on a `reduced_tx_set = 0` frame (lane-intertx; same class as + /// `tx_select`/`screen` above). + pub(crate) reduced_tx_set: bool, /// This frame header's chosen loop restoration parameters, threaded for /// the same reason as `loop_filter` -- and doubly so: the per-unit /// filters themselves are coded in `tile`, so a decode of it under a @@ -8873,6 +8882,7 @@ pub(crate) fn encode_key_frame_inner( // A key frame codes no inter block, so no motion_mode symbol. switchable_motion_mode: false, screen, + reduced_tx_set: header.reduced_tx_set, next_cdfs: start_cdfs.clone(), start_cdfs, loop_filter: header.loop_filter, @@ -12609,7 +12619,7 @@ pub(crate) fn encode_inter_frame( // `Cdfs` then reads for every luma `tx_type` symbol. header.reduced_tx_set = !wide_tx_set(screen); // lane-intertx, desync (a): the frame context this value is read back - // through ( [`decode::reduce_inherited_chroma_tx_type`] inside + // through ([`decode::reduce_inherited_chroma_tx_type`] inside // `recode_inter_chroma`, and every inter decode helper the search's own // trial decode shares) must carry THIS frame's bit, not whatever the // previous frame's trial decode last left in the shared cell -- a stale @@ -14110,6 +14120,7 @@ pub(crate) fn encode_inter_frame( tx_select, switchable_motion_mode, screen, + reduced_tx_set: header.reduced_tx_set, start_cdfs, next_cdfs, loop_filter: header.loop_filter, diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 86e285a9..8ff94030 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -3035,8 +3035,11 @@ pub(crate) mod tests { &encoded.cdef, &encoded.loop_filter, encoded.tx_select, - // Our own encoder always writes `reduced_tx_set: true`. - true, + // lane-intertx: the frame's own `reduced_tx_set` -- a screen + // key frame at preset 0 codes the wider intra alphabets, so + // the old hardcoded `true` (ours "always" wrote true) is a + // stale-header bug waiting for the first screen fixture. + encoded.reduced_tx_set, // `allow_screen_content_tools` off the frame the encoder // actually wrote: a screen-content picture codes two palette // symbols per intra block, and a raw tile decode that guessed diff --git a/lanes/intertx.report.md b/lanes/intertx.report.md index c1cc5487..74e56387 100644 --- a/lanes/intertx.report.md +++ b/lanes/intertx.report.md @@ -1,7 +1,7 @@ # lane-intertx — the inter tx-type search on film (chroma inheritance made honest) -Base: `810d8972` (charter). Fix commit: `9af60b4d`. Report commit: this one. -Disposition: **stays-off** — the `InterTxSearch::All` lever does NOT ship +Base: `810d8972` (charter). Fix commit: `9af60b4d`. Regression fix + report +commit: this one. Disposition: **stays-off** (`crate::speed::TX_TYPE_SEARCH_INTER` keeps `Screen` at presets 0-6; the keep rule's deciding column fails at best -0.1 against the required -0.5), but the lane's correctness work is real and committed: the chroma inheritance desync @@ -192,3 +192,67 @@ ok, both pins byte-identical. + tests compile warning-free; the three tx witnesses; the pin test) and project-wide validation stays with the main agent. `FLIPADST` family and the 1-D ADSTs remain unoffered (the standing lane-txi deferral). + +## 7. Regression caught by the merge tier: the raw-tile decode wrapper's +## stale `reduced_tx_set` + +Main's regression tier caught three `decode::tests` failures on the lane +HEAD (`a_gop_round_trips_bit_exact_against_the_encoder_reconstruction`, +`an_odd_size_gop_round_trips_bit_exact_against_the_encoder_reconstruction`, +`ffmpeg_and_this_decoder_agree_on_a_gop`), all refusing with "a reference +frame selected with no picture at this frame's own ref_frame_idx slot". + +Root cause (class: **test asserts against a stale header** -- the wrapper's +own parameter docs document five prior instances of exactly this class): +`decode::decode_inter_frame_tile_lr`, the raw-tile decode helper the GOP +round-trip tests use, hard-coded `reduced_tx_set: true` +(`decode.rs:34552` at the fix commit's parent) with the comment "this +wrapper's callers are the decoder's own tests, which all code the reduced +sets". True until this lane: no inter block ever inherited a non-`DCT_DCT` +chroma type. With the widened inter search live, a screen-detected GOP at +the default preset codes `reduced_tx_set = 0` frames whose inter luma takes +`V_DCT` (the traces show the first inter block at (0,0) 16x16 winning +exactly that), and the chroma inheritance reduces the inherited type +against the very bit the wrapper guessed: the test's decode derived +`DCT_DCT` from `inh=Some(V_DCT)` at chroma 8x8 where the writer coded +`V_DCT`, desynced, and the garbage symbols eventually read a ref_frame_idx +that names an empty slot -- the named refusal is downstream noise, the +first divergence is the chroma type. + +Fix (this commit): the wrapper takes the frame's own +`reduced_tx_set: bool` (placed before `tx_select`, mirroring the plural +fn), `Encoded` carries the bit (`encode.rs`, the `screen`/`tx_select` +pattern), the GOP tests and the key-frame tile test (`stream.rs`, whose +"our own encoder always writes `reduced_tx_set: true`" comment had the +same latent stale-header bug) pass the honest value. + +Why the gates and witnesses did not see it: every production decode path +(`stream.rs`'s parser, `decode_stream`, ffmpeg) reads the bit off the wire +honestly -- the gates' three-way exactness and all witnesses ride those. +Only the raw-tile test helper guessed. + +Encoder output is UNCHANGED by the fix: the diff touches the `Encoded` +metadata struct, the test-facing decode wrappers and one test call -- no +writer or search code (tile.rs is not in the fix diff at all), and the +three witnesses code byte-identical streams after it (8143 / 8211 bytes, +same census). The server-1 BD tables in sections 2-4 remain valid; no gate +re-run needed. + +EVIDENCE: ~/.cache/intertx/regression-repro.log | the three tests on the +unfixed lane HEAD | 3 failed, all with the named refusal. +EVIDENCE: ~/.cache/intertx/regression-fix.log | the three tests + the pin +test after the fix | 4 passed. +EVIDENCE: ~/.cache/intertx/witness-rerun.log | all three tx witnesses +re-run after the fix | byte-identical streams (8143 / 8211 bytes), ok. + +## 8. Full suite and workspace check (post-fix) + +Three-lane lib suite LOCALLY on the fix commit, `--release --lib`: +`--skip stream::` 348 passed / 0 failed; `stream:: --skip 10bit` 202 +passed / 0 failed; `10bit` 42 passed / 0 failed -- **592 passed, 0 +failed**. `timeout 900 cargo check --workspace --all-targets -j4`: 0 +ec-av1 warnings (the 25 workspace warnings are ec-opus's, pre-existing). + +EVIDENCE: ~/.cache/intertx/suite-lane1.log | --skip stream:: | 348 passed. +EVIDENCE: ~/.cache/intertx/suite-lane2.log | stream:: --skip 10bit | 202 passed. +EVIDENCE: ~/.cache/intertx/suite-lane3.log | 10bit | 42 passed.