forge
Explore
Log in

Don't you dare go Hollow

Get_tx_size_context's inter-neighbour override read a SUB-cell index into two mi-granular bands

Browse files at this commit

9fbdab4f85e57fda9942544d4b649d33349dc898Ahmet Kaan GümüşParent: fd8e31a
  • fix
    • get_tx_size_context's inter-neighbour override read a SUB-cell index into two mi-granular bands
Show full message
fix(av1): get_tx_size_context's inter-neighbour override read a SUB-cell index into two mi-granular bands

`tx_size_context_txfm`/`_rect` implement libaom `get_tx_size_context`
(pred_common.h): when the above/left neighbour is an INTER block its BLOCK
size, not its transform-context band, decides the `tx_depth` CDF row. Both
copies indexed `above_inter`/`left_inter` with `mi_c / (SUB / MI)` /
`mi_r / (SUB / MI)`, but those two bands are mi-granular everywhere else they
are written (`record_inter_rect_mi`) and read (`intra_inter_ctx`) -- so the
override consulted a neighbour four mi columns/rows away and, at the first
intra block right of an inter one, read tx_depth off ctx 0 where libaom has
ctx 1. Same value, different interval: the tile desynced from there.

MEASURED on the r2 handoff's pinned stream (10-bit 192x128, md5
50ea2b42423f1c8b4eed9fa48c4775a6): the aomdec `EC_ISTEP name=tx_depth` ladder
was 85 of 147 elements and first diverged at mi(24,24) ctx 0 vs 1; it is now
147/147 identical and the stream decodes pixel-exact.

Consequence for the gate: with a correct decode that stream contains ZERO
intra HORZ/VERT strips in an inter frame -- r1/r2's "firing" counters were
read off our own desynced decode (class counter-from-refused-stream). 90
probe encodes over the old 192x128 / min=max=32 geometry produce no strip at
all, so the gate moves to the merged unsplit-strip gate's geometry (96x96,
min 16 / max 64, cq sweep down to 4) where aomenc does split intra strips.
Both arms are now GREEN with zero named refusals: 8-bit 6 counted-exact
attempts (depth1=9, depth2=1), 10-bit 2 counted-exact.

`EC_SPLITSTRIP` now prints EVERY intra strip with its depth, not only the
split ones -- a source that codes no strip at all and one that codes only
unsplit strips were indistinguishable through it.
crates/ec-av1/src/decode.rsmodified+16 -9
@@ -6555,11 +6555,12 @@ fn decode_intra_rect_in_inter(
65556555 v[depth.min(2)] += 1;
65566556 h.set(v);
65576557 });
6558- if std::env::var_os("EC_SPLITSTRIP").is_some() {
6559- eprintln!(
6560- "EC_SPLITSTRIP mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} depth={depth}"
6561- );
6562- }
6558+ }
6559+ // lane-intrasplit r3: print EVERY intra strip with its depth, not only the
6560+ // split ones -- a `depth=0`-only stream is a witness gap in the SOURCE, and
6561+ // the two are indistinguishable when the diagnostic fires on splits alone.
6562+ if std::env::var_os("EC_SPLITSTRIP").is_some() {
6563+ eprintln!("EC_SPLITSTRIP mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} depth={depth}");
65636564 }
65646565 let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth);
65656566 let modes = RectStripModes {
@@ -11584,10 +11585,10 @@ fn tx_size_context_txfm_rect(
1158411585 let has_left = mi_c > n.tile_col0_mi;
1158511586 let mut above = usize::from(n.above_txfm[mi_c]) >= own_w;
1158611587 let mut left = usize::from(n.left_txfm[mi_r]) >= own_h;
11587- if has_above && n.above_inter[mi_c / (SUB / MI)] {
11588+ if has_above && n.above_inter[mi_c] {
1158811589 above = n.above_side_mi[mi_c] >= own_w;
1158911590 }
11590- if has_left && n.left_inter[mi_r / (SUB / MI)] {
11591+ if has_left && n.left_inter[mi_r] {
1159111592 left = n.left_side_mi[mi_r] >= own_h;
1159211593 }
1159311594 match (has_above, has_left) {
@@ -11598,15 +11599,21 @@ fn tx_size_context_txfm_rect(
1159811599 }
1159911600 }
1160011601
11602+/// lane-intrasplit r3: `above_inter`/`left_inter` are mi-granular bands (they
11603+/// are written and read everywhere else with a raw mi index); the SUB-cell
11604+/// division this pair used read a cell four blocks away, so the inter-neighbour
11605+/// override above fired on the wrong neighbour -- the first divergence of the
11606+/// 10-bit gate's stream was exactly this (`tx_depth` ctx 0 where libaom has 1,
11607+/// at the intra block right of an inter one).
1160111608 fn tx_size_context_txfm(n: &Neighbours, (mi_r, mi_c): (usize, usize), side: usize) -> usize {
1160211609 let has_above = mi_r > n.tile_row0_mi;
1160311610 let has_left = mi_c > n.tile_col0_mi;
1160411611 let mut above = usize::from(n.above_txfm[mi_c]) >= side;
1160511612 let mut left = usize::from(n.left_txfm[mi_r]) >= side;
11606- if has_above && n.above_inter[mi_c / (SUB / MI)] {
11613+ if has_above && n.above_inter[mi_c] {
1160711614 above = n.above_side_mi[mi_c] >= side;
1160811615 }
11609- if has_left && n.left_inter[mi_r / (SUB / MI)] {
11616+ if has_left && n.left_inter[mi_r] {
1161011617 left = n.left_side_mi[mi_r] >= side;
1161111618 }
1161211619 match (has_above, has_left) {
crates/ec-av1/src/stream.rsmodified+13 -4
@@ -5533,7 +5533,16 @@ mod tests {
55335533 eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display());
55345534 return;
55355535 }
5536- let (width, height, frame_count) = (192usize, 128usize, 8usize);
5536+ // lane-intrasplit r3, MEASURED (probe3, 20 attempts x 2 depths): at
5537+ // 192x128 with `--min/--max-partition-size=32` a correctly decoded
5538+ // stream contains ZERO intra HORZ/VERT strips in an inter frame -- the
5539+ // r1/r2 "firing" counters were read off our own desynced decode (class
5540+ // counter-from-refused-stream). The merged unsplit-strip gate's own
5541+ // geometry (96x96, min 16 / max 64) is the one that makes aomenc's RD
5542+ // pick intra strips here, and at `--enable-tx-size-search=1` it splits
5543+ // their transforms: 10-bit attempt 0 = 8 strips, 3 split; 8-bit
5544+ // attempt 0 = 5 strips, 1 split.
5545+ let (width, height, frame_count) = (96usize, 96usize, 8usize);
55375546 let mut refusals = Vec::new();
55385547 let mut uncounted_exact = 0u32;
55395548 let mut counted_exact = 0u32;
@@ -5547,7 +5556,7 @@ mod tests {
55475556 // 1..4, and the quantiser with it (a hard-cut overlay source at
55485557 // cpu-used=0 stopped 38/40 attempts on other lanes' refusals).
55495558 let cpu = attempt % 5;
5550- let cq = [30u32, 20, 12, 63][((attempt / 5) % 4) as usize];
5559+ let cq = [30u32, 20, 12, 4][((attempt / 5) % 4) as usize];
55515560 // A FAST ZOOM: consecutive frames share almost no content, so
55525561 // aomenc's RD codes blocks INTRA inside INTER frames
55535562 // (`--kf-min-dist` forbids a new key frame) -- the only way a
@@ -5636,8 +5645,8 @@ mod tests {
56365645 "--enable-intrabc=0",
56375646 "--enable-cfl-intra=0",
56385647 "--enable-ref-frame-mvs=0",
5639- "--min-partition-size=32",
5640- "--max-partition-size=32",
5648+ "--min-partition-size=16",
5649+ "--max-partition-size=64",
56415650 // Per-arm overrides go LAST (aomenc keeps the last
56425651 // occurrence of a repeated --enable-* flag): this gate
56435652 // needs the rect partitions the strip lives in and the