From 6e4ad3070f0a573fa2687a65b088fd429c9cbbd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 28 Aug 2026 18:10:46 +0300 Subject: [PATCH] fix(av1): un-swap enable_interintra_compound/enable_jnt_comp at the decode_stream call site lane-comppin r10 (session-killed right after the fix compiled; orchestrator ran the pin and commits). ROOT CAUSE of the 10-round compound-drift hunt: decode_stream passed enable_interintra_compound and enable_jnt_comp to decode_inter_frame_tile_with_cdfs in each other's parameter slots -- two adjacent same-typed bools, so the compiler was silent. Every stream whose sequence header set the two bits DIFFERENTLY gated the interintra read on the jnt_comp bit (and compound_idx gating on the interintra bit): an extra or missing symbol read, then silent bit-drift for the rest of the tile. Streams with both bits equal decoded exactly -- which is why the gates only flaked on some aomenc content and every earlier localization pointed at a different downstream symbol. VERIFIED: pin sb128-compound-refs-flake.obu now decodes 24/24 frames byte-exact (was: frame 1+ all-plane drift accumulating to delta 60). Also in this commit: EC_AV1_SEQDUMP + remaining EC_AV1_TELL range checkpoints (env-gated instrumentation, inert when unset). class: adjacent-same-typed-args -- a call site passing N same-typed flags positionally can swap a pair without any compiler or roundtrip-test signal (our own encoder does not exercise the decode_stream path's flag plumbing); range-ladder bisection + the r9 compare-range-not-tell rule found it. --- crates/ec-av1-syntax/src/sequence.rs | 17 +++++++++++++++++ crates/ec-av1/src/decode.rs | 24 ++++++++++++++++++++++++ crates/ec-av1/src/stream.rs | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/crates/ec-av1-syntax/src/sequence.rs b/crates/ec-av1-syntax/src/sequence.rs index cf9fad83..d29a9e2b 100644 --- a/crates/ec-av1-syntax/src/sequence.rs +++ b/crates/ec-av1-syntax/src/sequence.rs @@ -372,6 +372,23 @@ impl SequenceHeader { seq.enable_restoration = r.read_bit()?; seq.color_config = read_color_config(r, seq_profile)?; seq.film_grain_params_present = r.read_bit()?; + if std::env::var_os("EC_AV1_SEQDUMP").is_some() { + eprintln!( + "SEQDUMP profile={seq_profile} still={still_picture} reduced={reduced_still_picture_header} \ + timing_present={} op_cnt={} idc0={} level0={} frame_width_bits={frame_width_bits} \ + frame_height_bits={frame_height_bits} max_w={max_frame_width} max_h={max_frame_height} \ + frame_id_present={frame_id_numbers_present_flag} use_128={} filter_intra={} edge_filter={} \ + interintra={} masked={} warped={} dual_filter={} order_hint={} jnt_comp={} ref_frame_mvs={}", + timing_info.is_some(), + seq.operating_points.len(), + seq.operating_points.first().map_or(0, |o| o.idc), + seq.operating_points.first().map_or(0, |o| o.seq_level_idx), + use_128x128_superblock, enable_filter_intra, enable_intra_edge_filter, + seq.enable_interintra_compound, seq.enable_masked_compound, + seq.enable_warped_motion, seq.enable_dual_filter, seq.enable_order_hint, + seq.enable_jnt_comp, seq.enable_ref_frame_mvs + ); + } Ok(seq) } diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index b5c0feed..104669db 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -628,6 +628,12 @@ fn read_coeffs( eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}"); } let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; + if std::env::var_os("EC_AV1_TELL").is_some() { + eprintln!( + "TELL label=post_txb_skip ctx={skip_ctx} all_zero={} tell={} range={}", + all_zero as u8, dec.debug_bitpos(), dec.debug_state().0 + ); + } if trace { eprintln!("TRACE all_zero ctx={skip_ctx} value={}", all_zero as i32); } @@ -5434,6 +5440,12 @@ fn decode_inter_block( )); } } + if std::env::var_os("EC_AV1_TELL").is_some() { + eprintln!( + "TELL mi_row={mi_row} mi_col={mi_col} label=post_interintra tell={} range={}", + dec.debug_bitpos(), dec.debug_state().0 + ); + } // lane-motionmode round 1: `read_motion_mode` (spec 5.11.24; // libaom `decodemv.c` read_inter_block_mode_info, ~1520-1528), // placed right after MV assignment and before the switchable @@ -5476,6 +5488,12 @@ fn decode_inter_block( OBMC_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); } } + if std::env::var_os("EC_AV1_TELL").is_some() { + eprintln!( + "TELL mi_row={mi_row} mi_col={mi_col} label=post_motion_mode eligible={} tell={} range={}", + motion_mode_eligible as u8, dec.debug_bitpos(), dec.debug_state().0 + ); + } // spec `get_ref_filter_type`: a neighbour's own filter only feeds // this block's switchable_interp context when that neighbour coded // the SAME reference frame this block is about to read -- a @@ -5513,6 +5531,12 @@ fn decode_inter_block( ); block_filter = resolved_filter; globalmv_for_lf = is_globalmv; + if std::env::var_os("EC_AV1_TELL").is_some() { + eprintln!( + "TELL mi_row={mi_row} mi_col={mi_col} label=post_interp_filter tell={} range={}", + dec.debug_bitpos(), dec.debug_state().0 + ); + } if std::env::var_os("EC_AV1_TRACE").is_some() { eprintln!( "EC_TRACE mi_row={mi_row} mi_col={mi_col} skip={} is_inter=1 mv=({},{}) is_new_mv={is_new_mv} bsize={side} ref={ref_frame} filter={:?} motion_mode_eligible={} obmc_selected={} tell={}", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 8f9da435..ae3719d0 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -382,8 +382,8 @@ pub fn decode_stream(data: &[u8]) -> Result> { tpl_field.as_ref(), header.reference_select, enable_masked_compound, - enable_interintra_compound, enable_jnt_comp, + enable_interintra_compound, header.skip_mode_present, header.skip_mode_frame, header.reduced_tx_set,