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 commit4 changed files +286 -98
- crates/ec-av1/fixtures/intra128_in_inter_screen_witness.obu +0 -0
- crates/ec-av1/src/decode.rs +153 -33
- crates/ec-av1/src/refusal_inventory.rs +15 -46
- crates/ec-av1/src/stream.rs +118 -19
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() { | ||
| 2005 | 2005 | INTRABC_HITS.with(|c| c.set(0)); |
| 2006 | 2006 | } |
| 2007 | 2007 | |
| 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 | + | |
| 2008 | 2025 | /// Records one coded block into [`INTRABC_MI_GRID`]: every block contributes |
| 2009 | 2026 | /// its size (libaom's `scan_row_mbmi` advances `processed_rows` off any |
| 2010 | 2027 | /// 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( | ||
| 8102 | 8119 | // reference holds (a fresh smooth ramp) in exactly those two bands of an |
| 8103 | 8120 | // inter frame and the encoder codes those forced halves INTRA. |
| 8104 | 8121 | 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. | |
| 8111 | 8128 | if coeff_trace_on() { |
| 8112 | 8129 | // lane-t900 r16: which decode-order frame this arm fires in -- |
| 8113 | 8130 | // interleaved with the `EC_COEFF_FRAME` markers, this is what |
| @@ -11920,15 +11937,6 @@ fn decode_block( | ||
| 11920 | 11937 | PALETTE_TILE_LEFT_HITS.with(|c| c.set(c.get() + 1)); |
| 11921 | 11938 | } |
| 11922 | 11939 | 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 | - } | |
| 11932 | 11940 | // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED` |
| 11933 | 11941 | // (13) predicts as `DC_PRED` with the [`cfl_scaled`] nudge carrying the |
| 11934 | 11942 | // actual chroma-from-luma correlation, same as this decoder always did. |
| @@ -11956,7 +11964,59 @@ fn decode_block( | ||
| 11956 | 11964 | // transform size -- 64 even for the 64x64 corner-scanned case, spec |
| 11957 | 11965 | // 5.11.40); `coeff_tx_side` is the actual coded coefficient grid's side, |
| 11958 | 11966 | // 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 { | |
| 11960 | 12020 | let resolved = read_tx_size(dec, cdfs, neighbours, (mi_r, mi_c), side, None); |
| 11961 | 12021 | (resolved, if resolved == 64 { 32 } else { resolved }) |
| 11962 | 12022 | } else { |
| @@ -12010,9 +12070,6 @@ fn decode_block( | ||
| 12010 | 12070 | ); |
| 12011 | 12071 | (yb, ub, vb) |
| 12012 | 12072 | }); |
| 12013 | - if let Some((yb, _, _)) = &intrabc_bufs { | |
| 12014 | - set_palette_pred(yb.clone(), fctx); | |
| 12015 | - } | |
| 12016 | 12073 | // A palette-Y block's own prediction is the reconstructed colour-index |
| 12017 | 12074 | // map, not `predict()`'s edge-based one -- [`PALETTE_PRED`] carries it |
| 12018 | 12075 | // to [`PlaneBuf::reconstruct`]'s next call rather than threading a |
| @@ -12027,6 +12084,16 @@ fn decode_block( | ||
| 12027 | 12084 | .map(|&idx| py.colors[idx as usize]) |
| 12028 | 12085 | .collect() |
| 12029 | 12086 | }); |
| 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 | + }; | |
| 12030 | 12097 | // With one luma transform unit the whole `side`x`side` map is the |
| 12031 | 12098 | // prediction; with several (`logical_tx != side`) each unit takes its own |
| 12032 | 12099 | // `logical_tx`-sized window of that same map, set fresh inside the TU loop |
| @@ -12483,6 +12550,22 @@ fn decode_block( | ||
| 12483 | 12550 | logical_tx as u8, |
| 12484 | 12551 | 0, fctx, |
| 12485 | 12552 | ); |
| 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 | + } | |
| 12486 | 12569 | record_intrabc_mi(mi_r, mi_c, side / MI, intrabc_dv, fctx); |
| 12487 | 12570 | Ok(()) |
| 12488 | 12571 | } |
| @@ -12965,11 +13048,6 @@ fn decode_leaf8( | ||
| 12965 | 13048 | if intrabc_dv.is_some() { |
| 12966 | 13049 | LEAF8_INTRABC_HITS.with(|c| c.set(c.get() + 1)); |
| 12967 | 13050 | } |
| 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 | - } | |
| 12973 | 13051 | // `av1_visit_palette`'s reconstruction (decodeframe.c:1135): the colour |
| 12974 | 13052 | // index map, mapped through the base colours, IS the block's prediction -- |
| 12975 | 13053 | // carried to the next `reconstruct`/`read_plane` through the same |
| @@ -13003,11 +13081,35 @@ fn decode_leaf8( | ||
| 13003 | 13081 | // which splits the leaf's own 8x8 prediction into a 2x2 grid of 4x4 |
| 13004 | 13082 | // transform units, same raster-order per-TU pattern `decode_block`'s |
| 13005 | 13083 | // 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() { | |
| 13011 | 13113 | read_tx_size(dec, cdfs, neighbours, leaf_mi, 8, None) |
| 13012 | 13114 | } else { |
| 13013 | 13115 | 8 |
| @@ -13043,9 +13145,13 @@ fn decode_leaf8( | ||
| 13043 | 13145 | // The per-plane prediction override rides the same [`PALETTE_PRED`] slot |
| 13044 | 13146 | // `decode_block` uses: set fresh right before each plane's own |
| 13045 | 13147 | // `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 | + }; | |
| 13049 | 13155 | let (luma_grid, u_grid, v_grid); |
| 13050 | 13156 | if skip { |
| 13051 | 13157 | // lane-hgkf r2 (same shape as `decode_block`'s own skip branch): an |
| @@ -13290,7 +13396,9 @@ fn decode_leaf8( | ||
| 13290 | 13396 | let tu_grid = read_plane( |
| 13291 | 13397 | dec, |
| 13292 | 13398 | 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 { | |
| 13294 | 13402 | TxbSet::Luma4 |
| 13295 | 13403 | } else { |
| 13296 | 13404 | TxbSet::Luma4Set1 |
| @@ -13413,6 +13521,12 @@ fn decode_leaf8( | ||
| 13413 | 13521 | } |
| 13414 | 13522 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 13415 | 13523 | 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 | + } | |
| 13416 | 13530 | neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode); |
| 13417 | 13531 | record_intrabc_mi(leaf_mi.0, leaf_mi.1, 2, intrabc_dv, fctx); |
| 13418 | 13532 | return Ok(mode); |
| @@ -13438,6 +13552,12 @@ fn decode_leaf8( | ||
| 13438 | 13552 | // (class `wrong-alphabet-same-value`; the ReelB key frame at |
| 13439 | 13553 | // -ss 900, first bad luma sample row 186 col 1803). |
| 13440 | 13554 | 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 | + } | |
| 13441 | 13561 | neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode); |
| 13442 | 13562 | // The DV predictor of a LATER intrabc block is the ordinary `INTRA_FRAME` |
| 13443 | 13563 | // 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] = &[ | ||
| 56 | 56 | "a block that actually uses a palette (Y) -- reconstruction is out of scope", |
| 57 | 57 | "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", |
| 58 | 58 | "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)", | |
| 60 | 59 | "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)", |
| 61 | 60 | "a frame OBU with no tile group", |
| 62 | 61 | "a frame naming primary_ref_frame at a reference slot with no saved CDF state", |
| @@ -124,37 +123,21 @@ const REFUSALS: &[&str] = &[ | ||
| 124 | 123 | // What still refuses is the 128-root half of a screen-content frame, whose |
| 125 | 124 | // body (`decode_block_128rect`) reads no palette syntax and for which no |
| 126 | 125 | // `--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", | |
| 158 | 141 | "a motion_mode symbol for a block shape with no CDF row here", |
| 159 | 142 | ]; |
| 160 | 143 | |
| @@ -374,20 +357,6 @@ const PROVEN: &[(&str, &str)] = &[ | ||
| 374 | 357 | "a frame naming primary_ref_frame at a reference slot with no saved CDF state", |
| 375 | 358 | "an_inter_frame_naming_an_unrefreshed_primary_ref_slot_is_refused_by_name", |
| 376 | 359 | ), |
| 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 | - ), | |
| 391 | 360 | ]; |
| 392 | 361 | |
| 393 | 362 | /// 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 { | ||
| 4370 | 4370 | const TILE: &str = "smptebars=size=128x96:rate=25"; |
| 4371 | 4371 | let (width, height) = (256usize, 192usize); |
| 4372 | 4372 | // (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] = [ | |
| 4374 | 4374 | ("smptebars-cq40-txs1", SB, "40", "1", false, false), |
| 4375 | 4375 | ("smptebars-cq45-txs1", SB, "45", "1", false, false), |
| 4376 | 4376 | ("smptebars-cq55-txs1", SB, "55", "1", false, false), |
| @@ -4384,13 +4384,11 @@ mod tests { | ||
| 4384 | 4384 | ("tiled-cq30-txs1", TILE, "30", "1", true, false), |
| 4385 | 4385 | ("tiled-cq45-txs1", TILE, "45", "1", true, false), |
| 4386 | 4386 | ("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), | |
| 4394 | 4392 | ]; |
| 4395 | 4393 | let (mut select_arms, mut premise_arms, mut intrabc_arms, mut blocks_total) = |
| 4396 | 4394 | (0u32, 0u32, 0u32, 0usize); |
| @@ -4468,9 +4466,9 @@ mod tests { | ||
| 4468 | 4466 | tx_mode == Select, so the refusal's own premise was never within reach" |
| 4469 | 4467 | ); |
| 4470 | 4468 | 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" | |
| 4474 | 4472 | ); |
| 4475 | 4473 | assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact"); |
| 4476 | 4474 | } |
| @@ -4484,13 +4482,17 @@ mod tests { | ||
| 4484 | 4482 | /// (`read_var_tx_size`), which this decoder reads nowhere on the intra |
| 4485 | 4483 | /// path -- reading the intra `tx_depth` symbol instead desyncs. |
| 4486 | 4484 | /// |
| 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. | |
| 4492 | 4495 | #[test] |
| 4493 | - #[ignore = "capability gap: an intrabc block's tx size is coded by the inter var-tx tree"] | |
| 4494 | 4496 | fn an_intrabc_block_under_tx_mode_select_decodes_pixel_exact() { |
| 4495 | 4497 | const NAME: &str = "an_intrabc_block_under_tx_mode_select_decodes_pixel_exact"; |
| 4496 | 4498 | if !have_ffmpeg() || !have_aomenc() { |
| @@ -4507,11 +4509,21 @@ mod tests { | ||
| 4507 | 4509 | (select={select} premise={premise})" |
| 4508 | 4510 | ); |
| 4509 | 4511 | crate::decode::reset_intrabc_hits(); |
| 4512 | + crate::decode::reset_intrabc_vartx_hits(); | |
| 4510 | 4513 | 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`). | |
| 4511 | 4522 | 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" | |
| 4514 | 4525 | ); |
| 4526 | + eprintln!("{NAME}: cq={cq} {blocks} intrabc block(s), {vartx} through var-tx"); | |
| 4515 | 4527 | let theirs = ffmpeg_decode_sequence(&stream, width, height, frames.len()); |
| 4516 | 4528 | assert_eq!(frames.len(), theirs.len(), "{NAME}: cq={cq} frame count"); |
| 4517 | 4529 | for (i, (ours, ref_frame)) in frames.iter().zip(theirs.iter()).enumerate() { |
| @@ -32182,6 +32194,93 @@ mod tests { | ||
| 32182 | 32194 | ); |
| 32183 | 32195 | } |
| 32184 | 32196 | |
| 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 | + | |
| 32185 | 32284 | /// lane-t900 r22 GATE: a real `aomenc --tune-content=screen |
| 32186 | 32285 | /// --enable-palette=1` stream whose INTER frames reconstruct palette |
| 32187 | 32286 | /// blocks (Y and UV), at both bit depths. |