forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-t900' (0e80dea1): intrabc blocks follow the inter tx-size rule under TX_MODE_SELECT (skipped reads no symbol, unskipped reads the var-tx tree); intra path publishes txfm contexts under allow_intrabc; 128-root screen-strip refusal lifted with an edge-forced screen witness

Browse files at this commit

74077108861b92e95b0b549019c3ccc23973040bAhmet Kaan GümüşParent: 63370ce0b83527
crates/ec-av1/fixtures/intra128_in_inter_screen_witness.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+153 -33
@@ -2005,6 +2005,23 @@ pub(crate) fn reset_intrabc_hits() {
20052005 INTRABC_HITS.with(|c| c.set(0));
20062006 }
20072007
2008+thread_local! {
2009+ /// lane-t900 r32: intrabc blocks whose transform size came off the INTER
2010+ /// var-tx partition tree (unskipped, `TX_MODE_SELECT`) -- the capability
2011+ /// that replaced the refusal "an intrabc block under TxMode::Select".
2012+ static INTRABC_VARTX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
2013+}
2014+
2015+/// Current value of [`INTRABC_VARTX_HITS`].
2016+pub(crate) fn intrabc_vartx_hits() -> usize {
2017+ INTRABC_VARTX_HITS.with(|c| c.get())
2018+}
2019+
2020+/// Zeroes [`INTRABC_VARTX_HITS`] (gate tests call this before a decode).
2021+pub(crate) fn reset_intrabc_vartx_hits() {
2022+ INTRABC_VARTX_HITS.with(|c| c.set(0));
2023+}
2024+
20082025 /// Records one coded block into [`INTRABC_MI_GRID`]: every block contributes
20092026 /// its size (libaom's `scan_row_mbmi` advances `processed_rows` off any
20102027 /// candidate's `bsize`, ref-match or not), an intrabc one also its DV as an
@@ -8102,12 +8119,12 @@ fn decode_intra_rect_in_inter(
81028119 // reference holds (a fresh smooth ramp) in exactly those two bands of an
81038120 // inter frame and the encoder codes those forced halves INTRA.
81048121 if bw.max(bh) == 128 {
8105- if allow_screen_content_tools {
8106- return Err(unsupported(
8107- "a HORZ/VERT intra strip in a screen-content frame (palette syntax \
8108- is consumed for square blocks only)",
8109- ));
8110- }
8122+ // lane-t900 r32: no screen-content refusal here. `av1_allow_palette`
8123+ // rejects every footprint with a 128-pixel side (`bw > 64 || bh > 64`,
8124+ // enumerated by `no_block_footprint_with_a_128_pixel_side_can_carry_\
8125+ // palette_syntax`), so a 128-root half consumes no palette syntax and
8126+ // a screen-content frame's half is syntactically identical to the
8127+ // non-screen one this arm already decodes byte-exact.
81118128 if coeff_trace_on() {
81128129 // lane-t900 r16: which decode-order frame this arm fires in --
81138130 // interleaved with the `EC_COEFF_FRAME` markers, this is what
@@ -11920,15 +11937,6 @@ fn decode_block(
1192011937 PALETTE_TILE_LEFT_HITS.with(|c| c.set(c.get() + 1));
1192111938 }
1192211939 let intrabc_dv = fctx.intrabc_dv.with(|c| c.take());
11923- // libaom `parse_decode_block`: an intrabc block is `inter_block_tx`, so
11924- // under `TX_MODE_SELECT` its transform size comes from the inter var-tx
11925- // partition tree (`read_var_tx_size`), a syntax element this decoder has
11926- // nowhere -- reading the intra `tx_depth` symbol instead would desync.
11927- if intrabc_dv.is_some() && tx_select && !skip {
11928- return Err(unsupported(
11929- "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)",
11930- ));
11931- }
1193211940 // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED`
1193311941 // (13) predicts as `DC_PRED` with the [`cfl_scaled`] nudge carrying the
1193411942 // actual chroma-from-luma correlation, same as this decoder always did.
@@ -11956,7 +11964,59 @@ fn decode_block(
1195611964 // transform size -- 64 even for the 64x64 corner-scanned case, spec
1195711965 // 5.11.40); `coeff_tx_side` is the actual coded coefficient grid's side,
1195811966 // which only differs from it at that one corner case.
11959- let (logical_tx, coeff_tx_side) = if tx_select {
11967+ // lane-t900 r32: spec 5.11.16 `read_block_tx_size` gates the `tx_depth`
11968+ // symbol on `allowSelect = !skip || !is_inter`, and libaom's
11969+ // `is_inter_block` counts an INTRABC block (`blockd.h:373`). So a SKIPPED
11970+ // intrabc block reads NO tx-size symbol at all -- it takes
11971+ // `maxRectTxSize` -- while every ordinary skipped intra block does read
11972+ // one. Reading it anyway consumed a symbol libaom never wrote and desynced
11973+ // the tile from that block on (class `equal-range-means-unread`).
11974+ // lane-t900 r32: and an UNSKIPPED one reads the inter var-tx partition
11975+ // tree instead (`read_var_tx_size`), the same syntax the inter block path
11976+ // has always read -- libaom's `parse_decode_block` dispatches on
11977+ // `is_inter_block`, so both branches of `read_block_tx_size` treat an
11978+ // intrabc block as inter.
11979+ let intrabc_skip_tx = intrabc_dv.is_some() && skip;
11980+ let intrabc_vartx = intrabc_dv.is_some() && tx_select && !skip;
11981+ let intrabc_leaves = if intrabc_vartx {
11982+ let max_tx = side.min(64);
11983+ // `max_block_wide`/`max_block_high`: the frame's own mi grid
11984+ // (`av1_calc_mi_size`, 8-px aligned), so a block hanging over the
11985+ // right/bottom edge reads no split symbol for the units outside it.
11986+ let mi_cols = 2 * y.true_width.div_ceil(8);
11987+ let mi_rows = 2 * y.true_height.div_ceil(8);
11988+ let side_mi = side / MI;
11989+ let max_w_mi = side_mi.min(mi_cols.saturating_sub(mi_c));
11990+ let max_h_mi = side_mi.min(mi_rows.saturating_sub(mi_r));
11991+ let mut leaves = Vec::new();
11992+ for row in (0..side_mi).step_by(max_tx / MI) {
11993+ for col in (0..side_mi).step_by(max_tx / MI) {
11994+ read_var_tx_size(
11995+ dec, cdfs, neighbours, (mi_r, mi_c), side,
11996+ (max_w_mi, max_h_mi), (max_tx, max_tx), 0, row, col, &mut leaves,
11997+ );
11998+ }
11999+ }
12000+ INTRABC_VARTX_HITS.with(|c| c.set(c.get() + 1));
12001+ // The luma reconstruct loop below is a UNIFORM grid of one square
12002+ // transform (the intra `tx_depth` shape), so a tree that resolved to
12003+ // mixed leaf sizes is refused by name rather than reconstructed at the
12004+ // wrong stride.
12005+ let uniform = leaves
12006+ .first()
12007+ .is_some_and(|f| leaves.iter().all(|l| (l.2, l.3) == (f.2, f.3) && l.2 == l.3));
12008+ if !uniform {
12009+ return Err(unsupported(
12010+ "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes",
12011+ ));
12012+ }
12013+ Some(leaves[0].2)
12014+ } else {
12015+ None
12016+ };
12017+ let (logical_tx, coeff_tx_side) = if let Some(tx) = intrabc_leaves {
12018+ (tx, if tx == 64 { 32 } else { tx })
12019+ } else if tx_select && !intrabc_skip_tx {
1196012020 let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side, None);
1196112021 (resolved, if resolved == 64 { 32 } else { resolved })
1196212022 } else {
@@ -12010,9 +12070,6 @@ fn decode_block(
1201012070 );
1201112071 (yb, ub, vb)
1201212072 });
12013- if let Some((yb, _, _)) = &intrabc_bufs {
12014- set_palette_pred(yb.clone(), fctx);
12015- }
1201612073 // A palette-Y block's own prediction is the reconstructed colour-index
1201712074 // map, not `predict()`'s edge-based one -- [`PALETTE_PRED`] carries it
1201812075 // to [`PlaneBuf::reconstruct`]'s next call rather than threading a
@@ -12027,6 +12084,16 @@ fn decode_block(
1202712084 .map(|&idx| py.colors[idx as usize])
1202812085 .collect()
1202912086 });
12087+ // lane-t900 r32: the intrabc luma prediction rides the very same
12088+ // whole-block override slot, so the multi-TU loop below windows it per
12089+ // transform unit exactly like a palette map -- setting it once up front
12090+ // handed the whole `side`x`side` buffer to the FIRST unit and left every
12091+ // later one predicting off block edges (the var-tx tree above is what
12092+ // first makes `logical_tx < side` reachable for an intrabc block).
12093+ let palette_y_buf = match &intrabc_bufs {
12094+ Some((yb, _, _)) => Some(yb.clone()),
12095+ None => palette_y_buf,
12096+ };
1203012097 // With one luma transform unit the whole `side`x`side` map is the
1203112098 // prediction; with several (`logical_tx != side`) each unit takes its own
1203212099 // `logical_tx`-sized window of that same map, set fresh inside the TU loop
@@ -12483,6 +12550,22 @@ fn decode_block(
1248312550 logical_tx as u8,
1248412551 0, fctx,
1248512552 );
12553+ // lane-t900 r32: libaom runs `set_txfm_ctxs` at the end of EVERY
12554+ // `decode_block`, key frames included, and the intrabc var-tx read above
12555+ // (`txfm_partition_ctx`) is the only intra-path reader of those bands --
12556+ // left at `TXFM_CTX_INIT` it would take the split symbol off the wrong CDF
12557+ // row. Armed by the frame's own `allow_intrabc` so every other key frame
12558+ // (whose readers use the deblock-grid approximation) is untouched.
12559+ if allow_intrabc {
12560+ set_txfm_ctxs(
12561+ neighbours,
12562+ (mi_r, mi_c),
12563+ logical_tx,
12564+ side / MI,
12565+ side / MI,
12566+ skip && intrabc_dv.is_some(),
12567+ );
12568+ }
1248612569 record_intrabc_mi(mi_r, mi_c, side / MI, intrabc_dv, fctx);
1248712570 Ok(())
1248812571 }
@@ -12965,11 +13048,6 @@ fn decode_leaf8(
1296513048 if intrabc_dv.is_some() {
1296613049 LEAF8_INTRABC_HITS.with(|c| c.set(c.get() + 1));
1296713050 }
12968- if intrabc_dv.is_some() && tx_select && !skip {
12969- return Err(unsupported(
12970- "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)",
12971- ));
12972- }
1297313051 // `av1_visit_palette`'s reconstruction (decodeframe.c:1135): the colour
1297413052 // index map, mapped through the base colours, IS the block's prediction --
1297513053 // carried to the next `reconstruct`/`read_plane` through the same
@@ -13003,11 +13081,35 @@ fn decode_leaf8(
1300313081 // which splits the leaf's own 8x8 prediction into a 2x2 grid of 4x4
1300413082 // transform units, same raster-order per-TU pattern `decode_block`'s
1300513083 // multi-TU branch runs).
13006- // ... and an intrabc leaf reads no intra `tx_depth` symbol at all: under
13007- // `TX_MODE_SELECT` a skipped inter block takes the largest transform
13008- // (`read_tx_size(.., is_inter=1, ..)`), and the unskipped case is refused
13009- // above.
13010- let resolved = if tx_select && intrabc_dv.is_none() {
13084+ // ... and an intrabc leaf reads no intra `tx_depth` symbol at all: libaom
13085+ // dispatches `read_block_tx_size` on `is_inter_block`, which counts an
13086+ // intrabc block, so a SKIPPED one takes the largest transform and an
13087+ // UNSKIPPED one reads the inter var-tx tree (lane-t900 r32). At 8x8 that
13088+ // tree is one `txfm_split` symbol: TX_8X8, or TX_4X4 over all four mi
13089+ // cells (`read_var_tx_size`'s `sub_txs == TX_4X4` early return).
13090+ let resolved = if tx_select && intrabc_dv.is_some() && !skip {
13091+ let mut leaves = Vec::new();
13092+ let mi_cols = 2 * y.true_width.div_ceil(8);
13093+ let mi_rows = 2 * y.true_height.div_ceil(8);
13094+ read_var_tx_size(
13095+ dec,
13096+ cdfs,
13097+ neighbours,
13098+ leaf_mi,
13099+ 8,
13100+ (
13101+ 2usize.min(mi_cols.saturating_sub(leaf_mi.1)),
13102+ 2usize.min(mi_rows.saturating_sub(leaf_mi.0)),
13103+ ),
13104+ (8, 8),
13105+ 0,
13106+ 0,
13107+ 0,
13108+ &mut leaves,
13109+ );
13110+ INTRABC_VARTX_HITS.with(|c| c.set(c.get() + 1));
13111+ leaves.first().map_or(8, |l| l.2)
13112+ } else if tx_select && intrabc_dv.is_none() {
1301113113 read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, None)
1301213114 } else {
1301313115 8
@@ -13043,9 +13145,13 @@ fn decode_leaf8(
1304313145 // The per-plane prediction override rides the same [`PALETTE_PRED`] slot
1304413146 // `decode_block` uses: set fresh right before each plane's own
1304513147 // `reconstruct`/`read_plane` call (the slot is taken, not copied).
13046- if let Some((yb, _, _)) = &intrabc_bufs {
13047- set_palette_pred(yb.clone(), fctx);
13048- }
13148+ // lane-t900 r32: through `palette_y_buf`, so the 4x4 TU loop below windows
13149+ // it per unit (an intrabc leaf whose var-tx tree split to TX_4X4 is the
13150+ // first shape that reaches that loop with an override set).
13151+ let palette_y_buf = match &intrabc_bufs {
13152+ Some((yb, _, _)) => Some(yb.clone()),
13153+ None => palette_y_buf,
13154+ };
1304913155 let (luma_grid, u_grid, v_grid);
1305013156 if skip {
1305113157 // lane-hgkf r2 (same shape as `decode_block`'s own skip branch): an
@@ -13290,7 +13396,9 @@ fn decode_leaf8(
1329013396 let tu_grid = read_plane(
1329113397 dec,
1329213398 cdfs,
13293- if reduced_tx_set {
13399+ if intrabc_dv.is_some() {
13400+ txbset_for_inter(4, reduced_tx_set)
13401+ } else if reduced_tx_set {
1329413402 TxbSet::Luma4
1329513403 } else {
1329613404 TxbSet::Luma4Set1
@@ -13413,6 +13521,12 @@ fn decode_leaf8(
1341313521 }
1341413522 neighbours.fill_skip_grid(leaf_mi, 2, skip);
1341513523 neighbours.fill_lf_grid(leaf_mi, 2, 4, 0, fctx);
13524+ // lane-t900 r32: `set_txfm_ctxs` for an 8x8 leaf -- see `decode_block`'s
13525+ // own copy; only an intrabc var-tx read consumes these bands on the intra
13526+ // path, so the write is armed by `allow_intrabc`.
13527+ if allow_intrabc {
13528+ set_txfm_ctxs(neighbours, leaf_mi, 4, 2, 2, skip && intrabc_dv.is_some());
13529+ }
1341613530 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);
1341713531 record_intrabc_mi(leaf_mi.0, leaf_mi.1, 2, intrabc_dv, fctx);
1341813532 return Ok(mode);
@@ -13438,6 +13552,12 @@ fn decode_leaf8(
1343813552 // (class `wrong-alphabet-same-value`; the ReelB key frame at
1343913553 // -ss 900, first bad luma sample row 186 col 1803).
1344013554 neighbours.fill_lf_grid(leaf_mi, 2, resolved as u8, 0, fctx);
13555+ // lane-t900 r32: `set_txfm_ctxs` for an 8x8 leaf -- see `decode_block`'s
13556+ // own copy; only an intrabc var-tx read consumes these bands on the intra
13557+ // path, so the write is armed by `allow_intrabc`.
13558+ if allow_intrabc {
13559+ set_txfm_ctxs(neighbours, leaf_mi, resolved, 2, 2, skip && intrabc_dv.is_some());
13560+ }
1344113561 neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode);
1344213562 // The DV predictor of a LATER intrabc block is the ordinary `INTRA_FRAME`
1344313563 // MV stack over this grid (`av1_find_mv_refs`), so an 8x8 leaf has to
crates/ec-av1/src/refusal_inventory.rsmodified+15 -46
@@ -56,7 +56,6 @@ const REFUSALS: &[&str] = &[
5656 "a block that actually uses a palette (Y) -- reconstruction is out of scope",
5757 "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)",
5858 "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)",
59- "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)",
6059 "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)",
6160 "a frame OBU with no tile group",
6261 "a frame naming primary_ref_frame at a reference slot with no saved CDF state",
@@ -124,37 +123,21 @@ const REFUSALS: &[&str] = &[
124123 // What still refuses is the 128-root half of a screen-content frame, whose
125124 // body (`decode_block_128rect`) reads no palette syntax and for which no
126125 // `--sb-size=128` screen witness exists yet.
127- // lane-t900 r23 CENSUS for this string's remaining 128-root arm (the
128- // 16x4/4x16 arm was lifted in r22): its premise is already known to be
129- // false by the spec -- `read_palette_mode_info` (5.11.46) codes palette
130- // only for `Block_Width <= 64 && Block_Height <= 64`, so a 128x64/64x128
131- // half consumes NO palette syntax and the screen flag changes nothing
132- // about it. It stays because nothing witnesses it: 6 aomenc encodes at
133- // `--sb-size=128 --tune-content=screen` (704x320 = 5*128+64 by 2*128+64,
134- // the edge-forced size r18 proved for the non-screen twin; screen cell
135- // content at cq 10/20/40, and r18's own panning-texture-plus-fresh-ramp
136- // shape with `--max-partition-size=128 --enable-ab-partitions=0
137- // --enable-1to4-partitions=0`) code ZERO 128-root halves of any kind
138- // (`intra128_in_inter` and `sb128_rect` both 0 in every stream), so
139- // lifting it would be a capability claim no gate exercises (class
140- // `refusal-lifted-without-a-gate`). What is still untried: a 10-bit
141- // source, and screen content in the forced bands with a NON-screen
142- // interior.
143- // lane-t900 r31, ENUMERATION: the premise is DISPROVED -- `av1_allow_palette`'s
144- // bound (`palette_bsize_ctx_wh`: `bw > 64 || bh > 64`) rejects every
145- // footprint with a 128-pixel side, so a screen-content frame codes no
146- // palette syntax on a 128-root half and that half decodes exactly like the
147- // non-screen twin r18 already witnesses (test
148- // `no_block_footprint_with_a_128_pixel_side_can_carry_palette_syntax`).
149- // The string is a claim about the SYNTAX, and the syntax it fears does not
150- // exist at this size. It stays UNPROVEN and live for two reasons: the
151- // guarded condition is reachable (proving the lift safe is not proving the
152- // case absent), and lifting it is a `decode.rs` edit -- delete the
153- // `if allow_screen_content_tools { return Err(unsupported(..)) }` block
154- // inside the `bw.max(bh) == 128` branch of `decode_intra_rect_in_inter`
155- // -- which needs a `--sb-size=128 --tune-content=screen` witness that
156- // actually codes a 128-root half (r23's census found none).
157- "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)",
126+ // lane-t900 r32: the 128-root arm is LIFTED. r31's enumeration
127+ // (`no_block_footprint_with_a_128_pixel_side_can_carry_palette_syntax`) is
128+ // its proof -- `av1_allow_palette`'s `bw > 64 || bh > 64` bound means a
129+ // 128x64/64x128 half codes NO palette syntax at all, so a screen-content
130+ // frame's half is byte-identical in syntax to the non-screen twin gate
131+ // `an_intra_coded_128_half_inside_an_inter_frame_decodes_pixel_exact`
132+ // already decodes pixel-exact. Nothing of this string remains.
133+ // lane-t900 r32: the residue of the LIFTED "an intrabc block under
134+ // TxMode::Select". The inter var-tx tree is read in full, but the intra
135+ // luma reconstruct loop it feeds is a UNIFORM grid of one square
136+ // transform, so a tree resolving to mixed leaf sizes would be
137+ // reconstructed at the wrong stride. Neither arm of
138+ // `an_intrabc_block_under_tx_mode_select_decodes_pixel_exact` reaches it
139+ // (both resolve uniform), so it is unwitnessed and stays live.
140+ "an intrabc block whose var-tx tree resolved to mixed leaf transform sizes",
158141 "a motion_mode symbol for a block shape with no CDF row here",
159142 ];
160143
@@ -374,20 +357,6 @@ const PROVEN: &[(&str, &str)] = &[
374357 "a frame naming primary_ref_frame at a reference slot with no saved CDF state",
375358 "an_inter_frame_naming_an_unrefreshed_primary_ref_slot_is_refused_by_name",
376359 ),
377- // lane-t900 r31, census + refusal-by-name: 13 real `--tune-content=screen
378- // --enable-intrabc=1` key frames measure this string instead of assuming
379- // it. The refusal is NOT unreachable -- an exact-repetition source
380- // (a 2x2 tiling of one bar pattern) with the rect/1:4 partitions off codes
381- // an unskipped intrabc block on a square block of a TX_MODE_SELECT frame,
382- // and exactly that arm refuses by name while the other twelve decode
383- // pixel-exact. So it is a real capability gap with a waiting witness gate
384- // (`an_intrabc_block_under_tx_mode_select_decodes_pixel_exact`, ignored),
385- // and libaom does not couple the two bits: `select_tx_mode`
386- // (encodeframe.c:2355) never reads `allow_intrabc`.
387- (
388- "an intrabc block under TxMode::Select (its transform size is coded by the inter var-tx partition tree, which this decoder never reads)",
389- "an_intrabc_census_over_screen_key_frames_measures_the_tx_select_refusal",
390- ),
391360 ];
392361
393362 /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than
crates/ec-av1/src/stream.rsmodified+118 -19
@@ -4370,7 +4370,7 @@ mod tests {
43704370 const TILE: &str = "smptebars=size=128x96:rate=25";
43714371 let (width, height) = (256usize, 192usize);
43724372 // (arm, source, cq, tx-size-search, tiled, square_only)
4373- let arms: [(&str, &str, &str, &str, bool, bool); 13] = [
4373+ let arms: [(&str, &str, &str, &str, bool, bool); 14] = [
43744374 ("smptebars-cq40-txs1", SB, "40", "1", false, false),
43754375 ("smptebars-cq45-txs1", SB, "45", "1", false, false),
43764376 ("smptebars-cq55-txs1", SB, "55", "1", false, false),
@@ -4384,13 +4384,11 @@ mod tests {
43844384 ("tiled-cq30-txs1", TILE, "30", "1", true, false),
43854385 ("tiled-cq45-txs1", TILE, "45", "1", true, false),
43864386 ("tiled-square-cq30-txs1", TILE, "30", "1", true, true),
4387- // `tiled-square-cq45-txs1` belongs here too and is NOT in this
4388- // table: its intrabc blocks are all `skip`, so the `&& !skip`
4389- // guard lets them through -- and the frame decodes WRONG against
4390- // ffmpeg. A refusal one `&&` narrower than the hole it guards
4391- // (class `refusal-hides-a-defect`); that arm lives in the ignored
4392- // gate below with the unskipped one, and the guard itself is a
4393- // `decode.rs` edit this round could not make.
4387+ // lane-t900 r32: both square arms are now ORDINARY census members
4388+ // -- cq30 (unskipped intrabc, the inter var-tx tree) and cq45
4389+ // (all-skip intrabc, `maxRectTxSize` with no symbol at all) decode
4390+ // pixel-exact, so nothing here reaches the lifted refusal.
4391+ ("tiled-square-cq45-txs1", TILE, "45", "1", true, true),
43944392 ];
43954393 let (mut select_arms, mut premise_arms, mut intrabc_arms, mut blocks_total) =
43964394 (0u32, 0u32, 0u32, 0usize);
@@ -4468,9 +4466,9 @@ mod tests {
44684466 tx_mode == Select, so the refusal's own premise was never within reach"
44694467 );
44704468 assert_eq!(
4471- refused_tx_select, 1,
4472- "{NAME}: exactly one arm (tiled-square-cq30-txs1) must reach the refusal -- if \
4473- none does, the census no longer measures it; if more do, say so here"
4469+ refused_tx_select, 0,
4470+ "{NAME}: lane-t900 r32 lifted this refusal -- an intrabc block now reads the \
4471+ INTER tx-size syntax, so no arm may reach it again"
44744472 );
44754473 assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact");
44764474 }
@@ -4484,13 +4482,17 @@ mod tests {
44844482 /// (`read_var_tx_size`), which this decoder reads nowhere on the intra
44854483 /// path -- reading the intra `tx_depth` symbol instead desyncs.
44864484 ///
4487- /// Two arms of the same recipe: `cq=30`, whose intrabc block is unskipped
4488- /// and refused by name, and `cq=45`, whose intrabc blocks are all `skip`
4489- /// and therefore pass the `&& !skip` guard -- and decode WRONG (frame 0
4490- /// mismatches ffmpeg). So the refusal is one `&&` narrower than the hole:
4491- /// until the var-tx read lands, the skipped case needs the same refusal.
4485+ /// lane-t900 r32 closed both arms. A SKIPPED intrabc block reads no
4486+ /// tx-size symbol at all (`allowSelect = !skip || !is_inter`, false for an
4487+ /// intrabc block since libaom's `is_inter_block` counts one); reading the
4488+ /// intra `tx_depth` for it consumed a symbol libaom never wrote and
4489+ /// desynced the tile a whole block later, at the superblock corner
4490+ /// (192,64) (class `equal-range-means-unread`). An UNSKIPPED one reads the
4491+ /// inter var-tx tree (`read_var_tx_size`). r31's note that cq=45's blocks
4492+ /// are all `skip` was read off that desynced decode: with the tx-size read
4493+ /// corrected, cq=45 carries 3 unskipped intrabc blocks of 10 and cq=30
4494+ /// carries 1 of 16, so both arms exercise both sides of the split.
44924495 #[test]
4493- #[ignore = "capability gap: an intrabc block's tx size is coded by the inter var-tx tree"]
44944496 fn an_intrabc_block_under_tx_mode_select_decodes_pixel_exact() {
44954497 const NAME: &str = "an_intrabc_block_under_tx_mode_select_decodes_pixel_exact";
44964498 if !have_ffmpeg() || !have_aomenc() {
@@ -4507,11 +4509,21 @@ mod tests {
45074509 (select={select} premise={premise})"
45084510 );
45094511 crate::decode::reset_intrabc_hits();
4512+ crate::decode::reset_intrabc_vartx_hits();
45104513 let frames = decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME}: cq={cq}: {e}"));
4514+ let (blocks, vartx) =
4515+ (crate::decode::intrabc_hits(), crate::decode::intrabc_vartx_hits());
4516+ assert!(blocks > 0, "{NAME}: cq={cq} no longer decodes an intrabc block");
4517+ // r31 recorded cq=45's intrabc blocks as ALL skip; that was read
4518+ // off the desynced decode. With the tx-size read corrected both
4519+ // arms carry unskipped ones (cq30 1 of 16, cq45 3 of 10), so both
4520+ // must reach the var-tx tree or the gate is blind to the lift
4521+ // (class `gate-blind-to-feature`).
45114522 assert!(
4512- crate::decode::intrabc_hits() > 0,
4513- "{NAME}: cq={cq} no longer decodes an intrabc block"
4523+ vartx > 0,
4524+ "{NAME}: cq={cq} no longer reads the inter var-tx tree for an intrabc block"
45144525 );
4526+ eprintln!("{NAME}: cq={cq} {blocks} intrabc block(s), {vartx} through var-tx");
45154527 let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len());
45164528 assert_eq!(frames.len(), theirs.len(), "{NAME}: cq={cq} frame count");
45174529 for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() {
@@ -32182,6 +32194,93 @@ mod tests {
3218232194 );
3218332195 }
3218432196
32197+ /// lane-t900 r32 GATE for the LIFTED refusal "a HORZ/VERT intra strip in
32198+ /// a screen-content frame (palette syntax is consumed for square blocks
32199+ /// only)": the r18 edge-forced recipe re-encoded with
32200+ /// `--tune-content=screen`, i.e. the exact case that refusal guarded.
32201+ ///
32202+ /// `crates/ec-av1/fixtures/intra128_in_inter_screen_witness.obu`, 119048
32203+ /// bytes, sha256
32204+ /// `c84a493f90327f5d2bea038a42e87cbfe56762b5c6a856d76b4bff9797c5ea09`,
32205+ /// from this repository's aomenc oracle over r18's own 10-bit 704x320
32206+ /// source (`gen3.py`): the r18 flag set plus `--tune-content=screen
32207+ /// --enable-palette=0 --enable-intrabc=0 --cq-level=20`. Three cq levels
32208+ /// were swept (20/35/50); all three fire, and the `--enable-rect-\
32209+ /// partitions=0` twin of each codes ZERO 128-root halves, which is what
32210+ /// says the shape here is the coded HORZ/VERT arm and not an artefact.
32211+ ///
32212+ /// The lift's proof is r31's enumeration
32213+ /// (`no_block_footprint_with_a_128_pixel_side_can_carry_palette_syntax`):
32214+ /// `av1_allow_palette`'s `bw > 64 || bh > 64` bound means a 128x64/64x128
32215+ /// half codes no palette syntax at all, so the screen flag changes nothing
32216+ /// about its syntax. This is the WITNESS that the lifted arm is reachable
32217+ /// and decodes, which r23's census could not produce.
32218+ #[test]
32219+ fn an_intra_coded_128_half_in_a_screen_content_inter_frame_decodes_pixel_exact() {
32220+ const NAME: &str =
32221+ "an_intra_coded_128_half_in_a_screen_content_inter_frame_decodes_pixel_exact";
32222+ if !have_ffmpeg() {
32223+ eprintln!("SKIP {NAME}: no ffmpeg");
32224+ return;
32225+ }
32226+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
32227+ .join("fixtures/intra128_in_inter_screen_witness.obu");
32228+ let stream = std::fs::read(&path)
32229+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
32230+ let (width, height) = (704usize, 320usize);
32231+ // The refusal named `allow_screen_content_tools`, so the gate reads
32232+ // that bit out of the frame headers rather than trusting the encoder
32233+ // flag (class `gate-blind-to-feature`).
32234+ let mut screen_frames = 0u32;
32235+ {
32236+ let mut p = Av1Parser::new();
32237+ let mut pos = 0usize;
32238+ while pos < stream.len() {
32239+ let obu = p.parse_obu(&stream[pos..]).expect("parse");
32240+ pos += obu.total_size;
32241+ let header = match &obu.kind {
32242+ ObuKind::Frame(h, _) => Some(&**h),
32243+ ObuKind::FrameHeader(h) => Some(&**h),
32244+ _ => None,
32245+ };
32246+ if header.is_some_and(|h| h.allow_screen_content_tools) {
32247+ screen_frames += 1;
32248+ }
32249+ }
32250+ }
32251+ assert!(
32252+ screen_frames > 0,
32253+ "{NAME}: no frame sets allow_screen_content_tools -- the gate no longer \
32254+ exercises the lifted refusal's own condition"
32255+ );
32256+ let before = intra128_in_inter_counters();
32257+ let frames = match decode_stream(&stream) {
32258+ Ok(frames) => frames,
32259+ Err(e) => panic!("{NAME}: decode_stream refused: {e}"),
32260+ };
32261+ let after = intra128_in_inter_counters();
32262+ let fired = [after[0] - before[0], after[1] - before[1]];
32263+ assert!(
32264+ fired[0] > 0 && fired[1] > 0,
32265+ "{NAME}: intra-128-in-inter fired {fired:?} (128x64, 64x128) -- both arms \
32266+ must fire or the lift is unwitnessed at the one that did not"
32267+ );
32268+ assert_eq!(frames.len(), 15, "{NAME}: 15 shown frames");
32269+ assert_eq!((frames[0].width, frames[0].height), (width, height));
32270+ let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len());
32271+ assert_eq!(ffmpeg_frames.len(), frames.len(), "{NAME}: frame count vs ffmpeg");
32272+ for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
32273+ assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg");
32274+ assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg");
32275+ assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg");
32276+ }
32277+ eprintln!(
32278+ "{NAME}: {screen_frames} screen-content frame(s), 15 shown frames pixel-exact \
32279+ on every plane; intra128_in_inter 128x64={} 64x128={}",
32280+ fired[0], fired[1]
32281+ );
32282+ }
32283+
3218532284 /// lane-t900 r22 GATE: a real `aomenc --tune-content=screen
3218632285 /// --enable-palette=1` stream whose INTER frames reconstruct palette
3218732286 /// blocks (Y and UV), at both bit depths.