forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-t900' (6429a980): palette on 8x8 leaves inside inter frames; every sub-8x8 tail publishes its palette state; 128-root screen strip refusal censused

Browse files at this commit

93b82254ce36580f94c81eee63eaa469dcdce981Ahmet Kaan GümüşParent: 6352a70f79247a
crates/ec-av1/fixtures/palette_screen_leaf8_witness.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+203 -11
@@ -1737,6 +1737,20 @@ thread_local! {
17371737 static INTRA_IN_INTER_PALETTE_UV_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
17381738 }
17391739
1740+// lane-t900 r23: as [`INTRA_IN_INTER_PALETTE_Y_HITS`], narrowed to the 8x8
1741+// LEAF site ([`decode_inter_block8`]'s intra arm) -- the >=16 site fires the
1742+// shared counter too, so only this one proves a gate really reached the leaf
1743+// where the refusal used to sit.
1744+thread_local! {
1745+ static INTER8_PALETTE_HITS: std::cell::Cell<(usize, usize)> =
1746+ const { std::cell::Cell::new((0, 0)) };
1747+}
1748+
1749+/// Current values of the 8x8-leaf intra-in-inter palette counters, `(y, uv)`.
1750+pub(crate) fn inter8_palette_hits() -> (usize, usize) {
1751+ INTER8_PALETTE_HITS.with(std::cell::Cell::get)
1752+}
1753+
17401754 /// Current values of the two intra-in-inter palette counters, `(y, uv)`.
17411755 pub(crate) fn intra_in_inter_palette_hits() -> (usize, usize) {
17421756 (
@@ -5016,6 +5030,9 @@ impl Neighbours {
50165030 colors: [u16; 8],
50175031 ) {
50185032 let (r, c) = mi;
5033+ if crate::envflags::env_flag!("EC_PALPUB") {
5034+ eprintln!("EC_PALPUB yrect mi={r},{c} bw={w} bh={h} y={size}");
5035+ }
50195036 // lane-kf900 r6: mi (4px) granularity, libaom's own -- `palette_size`
50205037 // lives per mi cell in `MB_MODE_INFO`, and `xd->left_mbmi` is the mi
50215038 // cell immediately left of the block, not its 16px [`SUB`] cell. The
@@ -7023,6 +7040,13 @@ fn record_strip_palette(
70237040 uv_colors: [u16; 8],
70247041 ) {
70257042 let (r, c) = mi;
7043+ // lane-t900 r23 rung: every publication of a block's palette state into
7044+ // the neighbour bands (`EC_PALPUB=1`) -- the rung that names which decode
7045+ // path left a stale `left_palette_size` behind when
7046+ // `av1_get_palette_mode_ctx` disagrees with libaom's.
7047+ if crate::envflags::env_flag!("EC_PALPUB") {
7048+ eprintln!("EC_PALPUB strip mi={r},{c} bw={bw} bh={bh} y={y_size} uv={uv_size}");
7049+ }
70267050 // lane-kf900 r6: the palette side bands are mi-granular now, so a strip
70277051 // writes its OWN span on BOTH axes -- the old `last` split-axis rule only
70287052 // existed because the 16px [`SUB`] cell held one slot for all the strips
@@ -24628,6 +24652,15 @@ fn decode_inter_sub8_split4(
2462824652 (ug, vg)
2462924653 };
2463024654 neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED);
24655+ // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map
24656+ // needs EVERY writer): a sub-8x8 group published no palette state, so
24657+ // once an 8x8 leaf of the same row can BE a palette block, the group
24658+ // left the row's band holding that earlier block's size and the next
24659+ // intra block read `av1_get_palette_mode_ctx` one too high (measured:
24660+ // mi(30,30) of decode-order frame 1, ours ctx 1 where libaom gathers
24661+ // 0). No sub-8x8 piece can itself be a palette (`av1_allow_palette`
24662+ // needs `bsize >= BLOCK_8X8`), so the group always clears.
24663+ record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]);
2463124664 let round_up_even = |n: usize| n.div_ceil(2) * 2;
2463224665 let bound_h = round_up_even(neighbours.mi_rows);
2463324666 let bound_w = round_up_even(neighbours.mi_cols);
@@ -25029,6 +25062,16 @@ fn decode_intra_sub8_leaf(
2502925062 neighbours.above_uv_mode[c] = uv_predict_mode;
2503025063 neighbours.left_uv_mode[r] = uv_predict_mode;
2503125064 neighbours.record_uv_mode_mi(gr, gc, 2, 2, uv_predict_mode);
25065+ // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map
25066+ // needs EVERY writer): a sub-8x8 group published no palette state, so
25067+ // once an 8x8 leaf of the same row can BE a palette block, the group
25068+ // left the row's band holding that earlier block's size and the next
25069+ // intra block read `av1_get_palette_mode_ctx` one too high (measured:
25070+ // mi(30,30) of decode-order frame 1, ours ctx 1 where libaom gathers
25071+ // 0). No sub-8x8 piece can itself be a palette (`av1_allow_palette`
25072+ // needs `bsize >= BLOCK_8X8`), so the group always clears.
25073+ record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]);
25074+
2503225075 let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8));
2503325076 let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if skip {
2503425077 if alpha.is_some() {
@@ -25629,6 +25672,15 @@ fn decode_inter_sub8_rect2(
2562925672 (ug, vg)
2563025673 };
2563125674 neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED);
25675+ // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map
25676+ // needs EVERY writer): a sub-8x8 group published no palette state, so
25677+ // once an 8x8 leaf of the same row can BE a palette block, the group
25678+ // left the row's band holding that earlier block's size and the next
25679+ // intra block read `av1_get_palette_mode_ctx` one too high (measured:
25680+ // mi(30,30) of decode-order frame 1, ours ctx 1 where libaom gathers
25681+ // 0). No sub-8x8 piece can itself be a palette (`av1_allow_palette`
25682+ // needs `bsize >= BLOCK_8X8`), so the group always clears.
25683+ record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]);
2563225684 let round_up_even = |n: usize| n.div_ceil(2) * 2;
2563325685 let bound_h = round_up_even(neighbours.mi_rows);
2563425686 let bound_w = round_up_even(neighbours.mi_cols);
@@ -25901,6 +25953,11 @@ fn decode_inter_block8(
2590125953 // neighbour (`Neighbours`' arrays only move once per 16x16 block).
2590225954 // `(0, None)` is intra.
2590325955 let mut leaf_refs: (i8, Option<i8>) = (0, None);
25956+ // lane-t900 r23: this leaf's own palette state for the neighbour bands
25957+ // (`(y_size, y_colors, uv_size, uv_colors)`), all-zero for an inter leaf
25958+ // and for an intra one that codes no palette -- same publication the
25959+ // >=16 intra-in-inter block makes through [`record_strip_palette`].
25960+ let mut palette_record8: (usize, [u16; 8], usize, [u16; 8]) = (0, [0u16; 8], 0, [0u16; 8]);
2590425961 if is_inter {
2590525962 if reference_select || skip_mode {
2590625963 // lane-inter8 r1: the REAL neighbour references, not a
@@ -26526,6 +26583,21 @@ fn decode_inter_block8(
2652626583 ],
2652726584 )
2652826585 });
26586+ // lane-t900 r23: every leaf stamps its palette state (all-zero for an
26587+ // inter leaf or a non-palette intra one, real for a palette block) into
26588+ // the mi-granular neighbour bands, so the next intra block's
26589+ // `av1_get_palette_mode_ctx` and colour cache see exactly what libaom's
26590+ // mode-info grid holds.
26591+ record_strip_palette(
26592+ neighbours,
26593+ leaf_mi,
26594+ 8,
26595+ 8,
26596+ palette_record8.0,
26597+ palette_record8.1,
26598+ palette_record8.2,
26599+ palette_record8.3,
26600+ );
2652926601 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
2653026602 if let Some((left, above)) = saved_luma_ctx {
2653126603 for (cell, state) in left.into_iter().enumerate() {
@@ -27204,19 +27276,47 @@ fn decode_inter_block8(
2720427276 // leaf (a nonzero `mode` still passes, but `uv_mode` is forced
2720527277 // `DC_PRED` by the refusal just above), same order as libaom's
2720627278 // `read_palette_mode_info` call right after `xd->cfl.store_y`.
27207- if allow_screen_content_tools {
27208- if mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[0][0]) != 0 {
27209- return Err(unsupported(
27210- "a block that actually uses a palette (Y) -- reconstruction is out of scope",
27211- ));
27279+ // lane-t900 r23: reconstructed, not refused. Same syntax, same
27280+ // deferral of the colour-index maps past `use_filter_intra`
27281+ // (`av1_visit_palette` runs from `parse_decode_block`, after the whole
27282+ // mode-info read) as the >=16 intra-in-inter block's own copy in
27283+ // [`decode_inter_block`]; the mode context, the colour cache and the
27284+ // `palette_uv_mode` context are this leaf's REAL ones, not the
27285+ // hardcoded 0/empty pair the refusal could get away with while no
27286+ // neighbour could ever be a palette (class
27287+ // [[cdf-row-held-constant]]). `av1_get_palette_bsize_ctx(BLOCK_8X8)`
27288+ // = `num_pels_log2_lookup[BLOCK_8X8] - 6` = row 0.
27289+ let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(leaf_mi);
27290+ let palette_uv_cache = neighbours.palette_uv_cache_mi(leaf_mi);
27291+ let mut palette_y_pending: Option<(usize, [u16; 8])> = None;
27292+ let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None;
27293+ if allow_screen_content_tools
27294+ && let Some(bsize_ctx) = palette_bsize_ctx(SIDE)
27295+ {
27296+ let use_palette_y =
27297+ mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][palette_ctx]) != 0;
27298+ if use_palette_y {
27299+ let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]);
27300+ palette_y_pending = Some((n, read_palette_colors_y(dec, n, &palette_cache)));
2721227301 }
2721327302 // lane-uv8 r1: `read_palette_mode_info` reads the UV symbol only
27214- // when `uv_mode == UV_DC_PRED` (decodemv.c) -- unconditional here
27215- // while every non-DC uv_mode was refused a few lines above.
27216- if uv_mode == DC_PRED && dec.symbol(&mut cdfs.palette_uv_mode[0]) != 0 {
27217- return Err(unsupported(
27218- "a block that actually uses a palette (UV) -- reconstruction is out of scope",
27219- ));
27303+ // when `uv_mode == UV_DC_PRED` (decodemv.c).
27304+ let use_palette_uv = uv_mode == DC_PRED
27305+ && dec.symbol(&mut cdfs.palette_uv_mode[usize::from(use_palette_y)]) != 0;
27306+ if crate::envflags::env_flag!("EC_PALSYN") {
27307+ eprintln!(
27308+ "EC_PALSYN leaf8 mi={},{} bw=8 bh=8 mode={mode} uv={uv_mode} ctx={palette_ctx} y={} uv={} rng={}",
27309+ leaf_mi.0,
27310+ leaf_mi.1,
27311+ palette_y_pending.map_or(0, |(n, _)| n),
27312+ u8::from(use_palette_uv),
27313+ dec.debug_state().0
27314+ );
27315+ }
27316+ if use_palette_uv {
27317+ let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]);
27318+ let (u_colors, v_colors) = read_palette_colors_uv(dec, n, &palette_uv_cache);
27319+ palette_uv_pending = Some((n, u_colors, v_colors));
2722027320 }
2722127321 }
2722227322 // lane-fiinter r1: `read_filter_intra_mode_info` (libaom `decodemv.c`,
@@ -27235,6 +27335,9 @@ fn decode_inter_block8(
2723527335 let ec_istep8 = crate::envflags::env_flag!("EC_TRACE_MODE_STEP");
2723627336 if mode == DC_PRED
2723727337 && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get)
27338+ // `av1_filter_intra_allowed` (reconintra.h:77) excludes a
27339+ // palette-Y block, so no `use_filter_intra` symbol exists there.
27340+ && palette_y_pending.is_none()
2723827341 && let Some(class) = filter_intra_size_class(SIDE)
2723927342 {
2724027343 let use_fi = dec.symbol(&mut cdfs.filter_intra[class]) != 0;
@@ -27262,6 +27365,49 @@ fn decode_inter_block8(
2726227365 filter_intra = Some(fi);
2726327366 }
2726427367 }
27368+ // lane-t900 r23: `av1_visit_palette` -- the two colour-index maps, Y
27369+ // then the shared chroma one, after the WHOLE mode-info read.
27370+ let palette_y = palette_y_pending.map(|(n, colors)| {
27371+ let map = decode_color_index_map_wh(dec, cdfs, n, SIDE, SIDE, false);
27372+ PALETTE_HITS.with(|c| c.set(c.get() + 1));
27373+ INTRA_IN_INTER_PALETTE_Y_HITS.with(|c| c.set(c.get() + 1));
27374+ INTER8_PALETTE_HITS.with(|c| {
27375+ let mut v = c.get();
27376+ v.0 += 1;
27377+ c.set(v);
27378+ });
27379+ PaletteY { size: n, colors, map }
27380+ });
27381+ let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| {
27382+ // `av1_get_plane_block_size(BLOCK_8X8, 1, 1)` = BLOCK_4X4.
27383+ let map = decode_color_index_map_wh(dec, cdfs, n, CHROMA_SIDE, CHROMA_SIDE, true);
27384+ PALETTE_UV_HITS.with(|c| c.set(c.get() + 1));
27385+ INTRA_IN_INTER_PALETTE_UV_HITS.with(|c| c.set(c.get() + 1));
27386+ INTER8_PALETTE_HITS.with(|c| {
27387+ let mut v = c.get();
27388+ v.1 += 1;
27389+ c.set(v);
27390+ });
27391+ PaletteUv { size: n, u_colors, v_colors, map }
27392+ });
27393+ palette_record8 = (
27394+ palette_y.as_ref().map_or(0, |p| p.size),
27395+ palette_y.as_ref().map_or([0u16; 8], |p| p.colors),
27396+ palette_uv.as_ref().map_or(0, |p| p.size),
27397+ palette_uv.as_ref().map_or([0u16; 8], |p| p.u_colors),
27398+ );
27399+ // A palette block predicts from its own colour-index map, never from
27400+ // the block edge (spec 7.11.2/7.11.4) -- these ride the
27401+ // [`PALETTE_PRED`] slot into each `reconstruct`/`read_plane` call
27402+ // below, exactly as the key-frame and >=16 intra-in-inter paths do.
27403+ let palette_y_buf: Option<Vec<u16>> =
27404+ palette_y.as_ref().map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect());
27405+ let palette_uv_bufs: Option<(Vec<u16>, Vec<u16>)> = palette_uv.as_ref().map(|p| {
27406+ (
27407+ p.map.iter().map(|&i| p.u_colors[i as usize]).collect(),
27408+ p.map.iter().map(|&i| p.v_colors[i as usize]).collect(),
27409+ )
27410+ });
2726527411 mode_for_tx = mode;
2726627412 let (mi_row, mi_col) = leaf_mi;
2726727413 for dr in 0..2 {
@@ -27319,6 +27465,19 @@ fn decode_inter_block8(
2731927465 // position: top-right / bottom-left availability is the
2732027466 // block's, narrowed by the unit's offset inside it.
2732127467 let tu_reach = Reach::of_tu(SIDE, SIDE, col * MI, row * MI, tx_px, tx_px, reach);
27468+ // This unit's own window on the block's palette prediction
27469+ // (the whole-block buffer would be indexed at the wrong
27470+ // stride by the first unit).
27471+ if let Some(buf) = &palette_y_buf {
27472+ PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
27473+ let window: Vec<u16> = (0..tx_px)
27474+ .flat_map(|i| {
27475+ let base = (row * MI + i) * SIDE + col * MI;
27476+ buf[base..base + tx_px].iter().copied()
27477+ })
27478+ .collect();
27479+ set_palette_pred(window);
27480+ }
2732227481 let tu_grid = if skip {
2732327482 y.reconstruct(
2732427483 tu_px,
@@ -27370,6 +27529,9 @@ fn decode_inter_block8(
2737027529 }
2737127530 if skip {
2737227531 if !split8 {
27532+ if let Some(buf) = &palette_y_buf {
27533+ set_palette_pred(buf.clone());
27534+ }
2737327535 y.reconstruct(
2737427536 px,
2737527537 py,
@@ -27386,6 +27548,9 @@ fn decode_inter_block8(
2738627548 // CfL's AC contribution is the luma this leaf just reconstructed,
2738727549 // averaged over the 4x4 chroma block (`cfl_ac_q3`, spec 7.11.5).
2738827550 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, SIDE));
27551+ if let Some((ub, _)) = &palette_uv_bufs {
27552+ set_palette_pred(ub.clone());
27553+ }
2738927554 u.reconstruct(
2739027555 cpx,
2739127556 cpy,
@@ -27398,6 +27563,9 @@ fn decode_inter_block8(
2739827563 None,
2739927564 smooth_neighbor_uv,
2740027565 );
27566+ if let Some((_, vb)) = &palette_uv_bufs {
27567+ set_palette_pred(vb.clone());
27568+ }
2740127569 v.reconstruct(
2740227570 cpx,
2740327571 cpy,
@@ -27421,6 +27589,9 @@ fn decode_inter_block8(
2742127589 // which the `saved_luma_ctx` restore below keeps per-TU.
2742227590 vec![0i32; SIDE * SIDE]
2742327591 } else {
27592+ if let Some(buf) = &palette_y_buf {
27593+ set_palette_pred(buf.clone());
27594+ }
2742427595 read_plane(
2742527596 dec,
2742627597 cdfs,
@@ -27453,6 +27624,9 @@ fn decode_inter_block8(
2745327624 )?
2745427625 };
2745527626 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, SIDE));
27627+ if let Some((ub, _)) = &palette_uv_bufs {
27628+ set_palette_pred(ub.clone());
27629+ }
2745627630 u_grid = read_plane(
2745727631 dec,
2745827632 cdfs,
@@ -27475,6 +27649,9 @@ fn decode_inter_block8(
2747527649 None,
2747627650 smooth_neighbor_uv,
2747727651 )?;
27652+ if let Some((_, vb)) = &palette_uv_bufs {
27653+ set_palette_pred(vb.clone());
27654+ }
2747827655 v_grid = read_plane(
2747927656 dec,
2748027657 cdfs,
@@ -27516,6 +27693,21 @@ fn decode_inter_block8(
2751627693 ],
2751727694 )
2751827695 });
27696+ // lane-t900 r23: every leaf stamps its palette state (all-zero for an
27697+ // inter leaf or a non-palette intra one, real for a palette block) into
27698+ // the mi-granular neighbour bands, so the next intra block's
27699+ // `av1_get_palette_mode_ctx` and colour cache see exactly what libaom's
27700+ // mode-info grid holds.
27701+ record_strip_palette(
27702+ neighbours,
27703+ leaf_mi,
27704+ 8,
27705+ 8,
27706+ palette_record8.0,
27707+ palette_record8.1,
27708+ palette_record8.2,
27709+ palette_record8.3,
27710+ );
2751927711 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
2752027712 // lane-uv8 r1: this leaf never stamped a mode band at all, so the block
2752127713 // below/right of it read whatever block last wrote the coarse [`SUB`]
crates/ec-av1/src/refusal_inventory.rsmodified+24 -7
@@ -46,13 +46,14 @@ const REFUSALS: &[&str] = &[
4646 "CfL, filter intra or a palette on a 128-root HORZ/VERT intra block (every one of their size gates caps at 64x64 or below, so none of these symbols exists there)",
4747 "intrabc under a 128x128 superblock (libaom's av1_is_dv_valid derives the block-vector delay from sb_size, which this decoder hardcodes to 64)",
4848 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",
49- // lane-t900 r22: palette RECONSTRUCTION landed for the key-frame paths
50- // (earlier lanes) and for the intra-in-inter square and rect paths (this
51- // one). These two strings survive at exactly two kinds of site: the
52- // `palette.is_none()` guards in `read_intra_mode`/`read_intra_mode_rect`
53- // (defensive -- every caller now passes a real ctx/cache pair), and the
54- // sub-8x8 `decode_inter_block8` leaf, which has no witness stream.
55- "a block that actually uses a palette (UV) -- reconstruction is out of scope",
49+ // lane-t900 r23: palette RECONSTRUCTION now covers the key-frame paths
50+ // (earlier lanes), the intra-in-inter square/rect paths (r22) and the
51+ // 8x8 LEAF inside an inter frame (this round, gate
52+ // `a_screen_stream_with_palette_8x8_leaves_in_inter_frames_decodes_pixel_exact`),
53+ // which is why the (UV) string is gone from the decoder entirely -- the
54+ // leaf was its only site. The (Y) one survives ONLY as the defensive
55+ // `palette.is_none()` guard in `read_intra_mode`/`read_intra_mode_rect`;
56+ // every caller now passes a real ctx/cache pair, so no stream reaches it.
5657 "a block that actually uses a palette (Y) -- reconstruction is out of scope",
5758 "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)",
5859 "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)",
@@ -124,6 +125,22 @@ const REFUSALS: &[&str] = &[
124125 // What still refuses is the 128-root half of a screen-content frame, whose
125126 // body (`decode_block_128rect`) reads no palette syntax and for which no
126127 // `--sb-size=128` screen witness exists yet.
128+ // lane-t900 r23 CENSUS for this string's remaining 128-root arm (the
129+ // 16x4/4x16 arm was lifted in r22): its premise is already known to be
130+ // false by the spec -- `read_palette_mode_info` (5.11.46) codes palette
131+ // only for `Block_Width <= 64 && Block_Height <= 64`, so a 128x64/64x128
132+ // half consumes NO palette syntax and the screen flag changes nothing
133+ // about it. It stays because nothing witnesses it: 6 aomenc encodes at
134+ // `--sb-size=128 --tune-content=screen` (704x320 = 5*128+64 by 2*128+64,
135+ // the edge-forced size r18 proved for the non-screen twin; screen cell
136+ // content at cq 10/20/40, and r18's own panning-texture-plus-fresh-ramp
137+ // shape with `--max-partition-size=128 --enable-ab-partitions=0
138+ // --enable-1to4-partitions=0`) code ZERO 128-root halves of any kind
139+ // (`intra128_in_inter` and `sb128_rect` both 0 in every stream), so
140+ // lifting it would be a capability claim no gate exercises (class
141+ // `refusal-lifted-without-a-gate`). What is still untried: a 10-bit
142+ // source, and screen content in the forced bands with a NON-screen
143+ // interior.
127144 "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)",
128145 "warp prediction with a scaled reference (superres, unimplemented)",
129146 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
crates/ec-av1/src/stream.rsmodified+64 -0
@@ -126,6 +126,13 @@ pub fn intra_in_inter_palette_hits() -> (usize, usize) {
126126 crate::decode::intra_in_inter_palette_hits()
127127 }
128128
129+/// `(y, uv)` palette blocks reconstructed on an 8x8 LEAF inside an inter
130+/// frame (lane-t900 r23) -- the site-specific half of
131+/// [`intra_in_inter_palette_hits`], which a >=16 block also moves.
132+pub fn inter8_palette_hits() -> (usize, usize) {
133+ crate::decode::inter8_palette_hits()
134+}
135+
129136 /// lane-rect64port r1: coded 64-level HORZ/VERT intra strips whose luma
130137 /// transform unit is the un-split TX_64X32 (orient 0) / TX_32X64 (orient 1).
131138 pub fn rect64_corner_tu_hits(orient: usize) -> usize {
@@ -31005,6 +31012,63 @@ mod tests {
3100531012 }
3100631013 }
3100731014
31015+ /// lane-t900 r23 GATE for the two LIFTED refusals `"a block that actually
31016+ /// uses a palette (Y)/(UV) -- reconstruction is out of scope"` at their
31017+ /// 8x8-LEAF site ([`crate::decode`]'s `decode_inter_block8` intra arm):
31018+ /// a palette block on an 8x8 intra leaf inside an inter frame.
31019+ ///
31020+ /// Recipe (`fixtures/palette_screen_leaf8_witness.obu`): 256x192, 15
31021+ /// frames, a static two-level 16x16 screen background with a 96x96 patch
31022+ /// of hashed 4x4 colour cells that moves non-periodically (so no
31023+ /// reference holds it and the encoder codes it INTRA inside the inter
31024+ /// frames), `aomenc --tune-content=screen --enable-palette=1
31025+ /// --enable-intrabc=0 --sb-size=64 --cq-level=20 --cpu-used=1
31026+ /// --lag-in-frames=0 --kf-max-dist=9999 --max-partition-size=8` -- the
31027+ /// partition cap is what puts the palette on BLOCK_8X8 rather than on the
31028+ /// 16x16/16x8 blocks r22's recipe produced. `EC_PALSYN=1` on aomdec
31029+ /// counts 25 `bsize=BLOCK_8X8 palette_size>0` blocks past the key frame.
31030+ ///
31031+ /// What it caught beyond the refusal itself: a sub-8x8 group publishes no
31032+ /// palette state, so it left the row's `left_palette_size` band holding an
31033+ /// earlier 8x8 palette block's size and `av1_get_palette_mode_ctx` read 1
31034+ /// where libaom gathers 0 (decode-order frame 1, mi(30,30), palette size
31035+ /// decoded as 8 instead of 2) -- class `new-map-ignores-tile-edge`, fixed
31036+ /// at all three sub-8x8 tails.
31037+ #[test]
31038+ fn a_screen_stream_with_palette_8x8_leaves_in_inter_frames_decodes_pixel_exact() {
31039+ const NAME: &str =
31040+ "a_screen_stream_with_palette_8x8_leaves_in_inter_frames_decodes_pixel_exact";
31041+ if !have_ffmpeg() {
31042+ eprintln!("SKIP {NAME}: no ffmpeg");
31043+ return;
31044+ }
31045+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
31046+ .join("fixtures/palette_screen_leaf8_witness.obu");
31047+ let stream = std::fs::read(&path)
31048+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
31049+ let before = inter8_palette_hits();
31050+ let frames = match decode_stream(&stream) {
31051+ Ok(frames) => frames,
31052+ Err(e) => panic!("{NAME}: decode_stream refused: {e}"),
31053+ };
31054+ let after = inter8_palette_hits();
31055+ let (fired_y, fired_uv) = (after.0 - before.0, after.1 - before.1);
31056+ assert!(
31057+ fired_y > 0,
31058+ "{NAME}: no palette block on an 8x8 leaf inside an inter frame \
31059+ -- the gate is vacuous for the site whose refusal it pins"
31060+ );
31061+ assert_eq!(frames.len(), 15, "{NAME}: 15 shown frames");
31062+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 256, 192, frames.len());
31063+ assert_eq!(ffmpeg_frames.len(), frames.len(), "{NAME}: frame count");
31064+ for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
31065+ assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg");
31066+ assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg");
31067+ assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg");
31068+ }
31069+ eprintln!("{NAME}: 15 frames pixel-exact; 8x8-leaf palette y={fired_y} uv={fired_uv}");
31070+ }
31071+
3100831072 /// lane-t900 r22 GATE for the LIFTED refusal `"a HORZ/VERT intra strip in
3100931073 /// a screen-content frame (palette syntax is consumed for square blocks
3101031074 /// only)"` on its 16x4/4x16 arm: that arm routes through