forge
Explore
Log in

Don't you dare go Hollow

wip(av1): range-state ladder FALSIFIES r8's partition-CDF-skew theory; real

Browse files at this commit

056185da446c49b8804d56285b2038292a049debAhmet Kaan GümüşParent: 206379a
divergence narrowed to block(0,0)'s own tail (interintra/motion_mode/
interp_filter/coeffs). Round 9, capped at budget.

STEP 1 (the r8 caveat, resolved): dumped od_ec_dec's tell-offset math from
libaom entdec.c by hand -- od_ec_dec_init's own refill loop leaves
od_ec_dec_tell() at 1 immediately after init for this stream's tile
(3 bytes pulled into the window: cnt goes -15->-7->1->9, bptr advances 3,
tell = 3*8-9+(-14) = 1), while our SymbolDecoder::new's debug_bitpos()
sits at 15 after its own init read (f(15) always advances self.bit by 15).
That is a CONSTANT 14-bit baseline difference between the two tell()
implementations, not a per-symbol cost -- confirmed by measuring it at
FOUR independent checkpoints (post_is_inter, post_ref_frame,
post_assign_mv, each for two different blocks): every one showed exactly
tell_ours - tell_aomdec = 14. r8's "~15 more bits for the same two
partition symbols" was 100% tell-baseline accounting, not a CDF skew.
CLOSES the partition_w64/partition_w32 CDF-forwarding suspect from r8's
handoff -- no further investigation needed there.

STEP 2 (range-state ladder, the real proof): added `range=` to every TELL
checkpoint on both sides (ours: msac debug_state().0, decode.rs
block_entry/post_is_inter/post_ref_frame/post_assign_mv, new tile_init and
block_end checkpoints; aomdec: r->ec.rng on the mirrored decodemv.c TELL
lines, EC_PART, and the existing per-block EC_TOK line in
decodeframe.c's parse_decode_block, rebuilt at
/tmp/libaom-src/build/decoder-debug/aomdec). Range is representation-
independent (unlike tell/value, which differ by each decoder's own window
convention) so an exact range match is a hard sync proof, not a units
coincidence.

Result for the pin's frame-1 tile, block mi(0,0) (decode-order frame 1,
first real leaf, LAST_FRAME single-ref inter):
  tile_init:      ours range=32768  aomdec range=32768  MATCH
  post_is_inter:  ours range=54894  aomdec range=54894  MATCH
  post_ref_frame: ours range=52050  aomdec range=52050  MATCH
  post_assign_mv: ours range=50720  aomdec range=50720  MATCH  <- exact
  block_end:      ours range=33843  aomdec range=37806  MISMATCH

Every read up through and including assign_mv (partition x2, skip_mode,
skip, intra_inter, ref_frame, the whole MV/DRL path) is bit-for-bit,
range-for-range identical to aomdec on this stream. The FIRST real
divergence is strictly between post_assign_mv and block_end of THIS SAME
block -- i.e. inside decode_inter_block's tail: interintra gate/wedge,
motion_mode (OBMC/warped), interp_filter, or the block's own plane
coefficient decode (txb_skip/tx_type/coeffs for luma+chroma). It is NOT
a later block, NOT a CDF-forwarding artifact, and NOT (per r8, already
closed) the interintra eligibility gate's *logic* -- but the interintra
READ itself, motion_mode, interp_filter, and first-txb_skip are all now
back in scope as the concrete next checkpoints since the "same-value
skewed-cost" theory that ruled interintra out is dead.

Class for memory: `instrument-measures-itself` kin -- two independently-
implemented tell()/bit-position counters can disagree by a fixed
accounting constant (od_ec's window-refill bookkeeping vs a straight
consumed-bit counter) with zero relationship to real desync; RANGE is the
comparable quantity across two independent arithmetic-coder
implementations, TELL is not, unless first proven to share a baseline.

NEXT (round 10): checkpoint range after each of interintra-read,
motion_mode-read, interp_filter-read, and first txb_skip-read for block
mi(0,0) specifically (both sides -- aomdec's read_interintra_mode /
read_motion_mode / read_ref_mv_idx... / av1_read_frame_reference_mode
equivalents in decodemv.c, and decodetxb.c's very first coeffs call);
first range mismatch among those four names the element. TELL_AV1
checkpoints already left in place for all of block_entry/post_is_inter/
post_ref_frame/post_assign_mv/block_end (ours) and the mirrored
decodemv.c + decodeframe.c prints (aomdec, both range-augmented, rebuild
with `make -j12 aomdec` in /tmp/libaom-src/build/decoder-debug).

Repro: EC_AV1_TELL=1 EC_AV1_PIN=<pin> EC_AV1_PIN_N=24 cargo test -p ec-av1
--release --lib scratch_isolate_pinned_mismatch -- --ignored --nocapture
aomdec side: EC_AV1_TELL=1 /tmp/libaom-src/build/decoder-debug/aomdec
--codec=av1 -o /tmp/out.yuv <pin>.obu 2>&1 | grep -E "^TELL|^EC_PART|^EC_TOK"
(frame 1's block is the SECOND "bsize=15" cycle in the trace)
crates/ec-av1/src/decode.rsmodified+30 -8
@@ -4662,8 +4662,8 @@ fn decode_inter_block(
4662 4662
4663 if std::env::var_os("EC_AV1_TELL").is_some() {4663 if std::env::var_os("EC_AV1_TELL").is_some() {
4664 eprintln!(4664 eprintln!(
4665- "TELL mi_row={} mi_col={} label=block_entry side={side} tell={}",4665+ "TELL mi_row={} mi_col={} label=block_entry side={side} tell={} range={}",
4666- r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos()4666+ r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().0
4667 );4667 );
4668 }4668 }
4669 let skip_mode_ctx =4669 let skip_mode_ctx =
@@ -4697,8 +4697,8 @@ fn decode_inter_block(
4697 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;4697 let is_inter = skip_mode || dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1;
4698 if std::env::var_os("EC_AV1_TELL").is_some() {4698 if std::env::var_os("EC_AV1_TELL").is_some() {
4699 eprintln!(4699 eprintln!(
4700- "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={}",4700+ "TELL mi_row={} mi_col={} label=post_is_inter skip_mode={skip_mode} skip={skip} is_inter={is_inter} tell={} range={}",
4701- r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos()4701+ r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().0
4702 );4702 );
4703 }4703 }
4704 4704
@@ -5293,8 +5293,8 @@ fn decode_inter_block(
5293 if std::env::var_os("EC_AV1_TELL").is_some() {5293 if std::env::var_os("EC_AV1_TELL").is_some() {
5294 let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize);5294 let (mi_row, mi_col) = (r * SUB_MI as usize, c * SUB_MI as usize);
5295 eprintln!(5295 eprintln!(
5296- "TELL mi_row={mi_row} mi_col={mi_col} label=post_ref_frame ref={ref_frame} tell={}",5296+ "TELL mi_row={mi_row} mi_col={mi_col} label=post_ref_frame ref={ref_frame} tell={} range={}",
5297- dec.debug_bitpos()5297+ dec.debug_bitpos(), dec.debug_state().0
5298 );5298 );
5299 }5299 }
5300 // round 4-9 (lane-av1golden..lane-av1golden7): GOLDEN_FRAME's own5300 // round 4-9 (lane-av1golden..lane-av1golden7): GOLDEN_FRAME's own
@@ -5409,8 +5409,8 @@ fn decode_inter_block(
5409 };5409 };
5410 if std::env::var_os("EC_AV1_TELL").is_some() {5410 if std::env::var_os("EC_AV1_TELL").is_some() {
5411 eprintln!(5411 eprintln!(
5412- "TELL mi_row={mi_row} mi_col={mi_col} label=post_assign_mv tell={}",5412+ "TELL mi_row={mi_row} mi_col={mi_col} label=post_assign_mv tell={} range={}",
5413- dec.debug_bitpos()5413+ dec.debug_bitpos(), dec.debug_state().0
5414 );5414 );
5415 }5415 }
5416 // lane-sb128 r4: `interintra` (spec 5.11.24; libaom5416 // lane-sb128 r4: `interintra` (spec 5.11.24; libaom
@@ -5834,6 +5834,18 @@ fn decode_inter_block(
5834 )?;5834 )?;
5835 }5835 }
5836 }5836 }
5837+ // lane-comppin r9: end-of-block checkpoint -- everything between
5838+ // post_assign_mv and here (interintra, motion_mode, interp_filter, then
5839+ // every plane's coeffs) is unproven; a range mismatch here vs aomdec's
5840+ // equivalent post-content point (added at the matching call site)
5841+ // narrows the ladder to this block's own tail instead of the next
5842+ // block's partition read.
5843+ if std::env::var_os("EC_AV1_TELL").is_some() {
5844+ eprintln!(
5845+ "TELL mi_row={} mi_col={} label=block_end tell={} range={}",
5846+ r * SUB_MI as usize, c * SUB_MI as usize, dec.debug_bitpos(), dec.debug_state().0
5847+ );
5848+ }
5837 neighbours.record(at, side, mode_for_tx, &[luma_grid, u_grid, v_grid]);5849 neighbours.record(at, side, mode_for_tx, &[luma_grid, u_grid, v_grid]);
5838 neighbours.record_inter(at, side, skip, is_inter, ref_frame_for_lf, block_filter, skip_mode);5850 neighbours.record_inter(at, side, skip, is_inter, ref_frame_for_lf, block_filter, skip_mode);
5839 if let Some((ref1, group_idx, idx)) = compound_ctx {5851 if let Some((ref1, group_idx, idx)) = compound_ctx {
@@ -6962,6 +6974,16 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
6962 6974
6963 let mut cdfs = initial_cdfs.unwrap_or_else(|| Cdfs::new(q_ctx_of(base_q_idx)));6975 let mut cdfs = initial_cdfs.unwrap_or_else(|| Cdfs::new(q_ctx_of(base_q_idx)));
6964 let mut dec = SymbolDecoder::new(data);6976 let mut dec = SymbolDecoder::new(data);
6977+ // lane-comppin r9: tile-entry range, the earliest point comparable
6978+ // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the
6979+ // first ladder rung before any symbol (partition or otherwise) is read.
6980+ if std::env::var_os("EC_AV1_TELL").is_some() {
6981+ eprintln!(
6982+ "TELL label=tile_init tell={} range={}",
6983+ dec.debug_bitpos(),
6984+ dec.debug_state().0
6985+ );
6986+ }
6965 let mut neighbours = Neighbours::new(6987 let mut neighbours = Neighbours::new(
6966 cols as usize * 2,6988 cols as usize * 2,
6967 rows as usize * 2,6989 rows as usize * 2,