forge
Explore
Log in

Don't you dare go Hollow

wip(av1): palette reconstruction, r22 partial (committed by the orchestrator at the builder's turn cap)

Browse files at this commit

236830db1cf9528e1397c4a9ea3eeffe3373c4ccAhmet Kaan GümüşParent: b0b1b47
crates/ec-av1/src/decode.rsmodified+204 -27
@@ -1727,6 +1727,24 @@ pub(crate) fn reset_palette_sb_strip_hits() {
1727 PALETTE_SB_STRIP_HITS.with(|c| c.set(0));1727 PALETTE_SB_STRIP_HITS.with(|c| c.set(0));
1728 }1728 }
1729 1729
1730+// lane-t900 r22: palette blocks reconstructed inside an INTER frame (the
1731+// intra-in-inter path, `decode_inter_block`/`decode_inter_block8`) -- counted
1732+// apart from [`PALETTE_HITS`] so a witness gate can prove the INTER-frame
1733+// capability rather than the key frame's, which every screen stream also
1734+// carries.
1735+thread_local! {
1736+ static INTRA_IN_INTER_PALETTE_Y_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1737+ static INTRA_IN_INTER_PALETTE_UV_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1738+}
1739+
1740+/// Current values of the two intra-in-inter palette counters, `(y, uv)`.
1741+pub(crate) fn intra_in_inter_palette_hits() -> (usize, usize) {
1742+ (
1743+ INTRA_IN_INTER_PALETTE_Y_HITS.with(|c| c.get()),
1744+ INTRA_IN_INTER_PALETTE_UV_HITS.with(|c| c.get()),
1745+ )
1746+}
1747+
1730 // lane-hgkf r2: SKIPPED intra blocks whose `tx_depth` split the luma transform1748 // lane-hgkf r2: SKIPPED intra blocks whose `tx_depth` split the luma transform
1731 // and which are therefore predicted one transform unit at a time (a skipped1749 // and which are therefore predicted one transform unit at a time (a skipped
1732 // block codes no coefficients, so nothing else in the stream witnesses this1750 // block codes no coefficients, so nothing else in the stream witnesses this
@@ -6904,7 +6922,7 @@ fn read_intra_mode_rect(
6904 if use_palette_y {6922 if use_palette_y {
6905 if palette.is_none() {6923 if palette.is_none() {
6906 return Err(unsupported(6924 return Err(unsupported(
6907- "a block that actually uses a palette (Y) -- reconstruction is out of scope",6925+ "a block that actually uses a palette (Y@rect) -- reconstruction is out of scope",
6908 ));6926 ));
6909 }6927 }
6910 let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]);6928 let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]);
@@ -8015,24 +8033,35 @@ fn decode_intra_rect_in_inter(
8015 // frame writes `palette_y_mode`/`palette_uv_mode` for every block whose8033 // frame writes `palette_y_mode`/`palette_uv_mode` for every block whose
8016 // shape [`palette_bsize_ctx_wh`] admits, intra strips included, so8034 // shape [`palette_bsize_ctx_wh`] admits, intra strips included, so
8017 // skipping the syntax here desynced the tile at the strip's own symbol.8035 // skipping the syntax here desynced the tile at the strip's own symbol.
8018- // No block this decoder produces can USE a palette (the arms below refuse8036+ // lane-t900 r22: reconstructed, not refused -- the strip's real mode
8019- // by name), so the neighbour mode context is 0 and there is no cache --8037+ // context and colour cache at its own mi position, and the two
8020- // the same stand-in [`read_intra_mode_rect`] uses when its caller has none.8038+ // colour-index maps decoded after `filter_intra` (`av1_visit_palette`),
8039+ // exactly as [`read_intra_mode_rect`] does on the key-frame path.
8040+ let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi((mi_r, mi_c));
8041+ let palette_uv_cache = neighbours.palette_uv_cache_mi((mi_r, mi_c));
8042+ let mut palette_y_pending: Option<(usize, [u16; 8])> = None;
8043+ let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None;
8021 if allow_screen_content_tools8044 if allow_screen_content_tools
8022 && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh)8045 && let Some(bsize_ctx) = palette_bsize_ctx_wh(bw, bh)
8023 {8046 {
8024 INTRA_RECT_IN_INTER_SCREEN_HITS.with(|c| c.set(c.get() + 1));8047 INTRA_RECT_IN_INTER_SCREEN_HITS.with(|c| c.set(c.get() + 1));
8025- if mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][0]) != 0 {8048+ let use_palette_y =
8026- return Err(unsupported(8049+ mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][palette_ctx]) != 0;
8027- "a block that actually uses a palette (Y) -- reconstruction is out of scope",8050+ if use_palette_y {
8028- ));8051+ let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]);
8052+ palette_y_pending = Some((n, read_palette_colors_y(dec, n, &palette_cache)));
8029 }8053 }
8030 // A 2:1 strip of at least 8x8 is always a chroma reference, so8054 // A 2:1 strip of at least 8x8 is always a chroma reference, so
8031 // `read_palette_mode_info`'s `xd->is_chroma_ref` guard holds here.8055 // `read_palette_mode_info`'s `xd->is_chroma_ref` guard holds here.
8032- if uv_mode == DC_PRED && dec.symbol(&mut cdfs.palette_uv_mode[0]) != 0 {8056+ let use_palette_uv =
8033- return Err(unsupported(8057+ uv_mode == DC_PRED && dec.symbol(&mut cdfs.palette_uv_mode[usize::from(use_palette_y)]) != 0;
8034- "a block that actually uses a palette (UV) -- reconstruction is out of scope",8058+ if crate::envflags::env_flag!("EC_PALSYN") {
8035- ));8059+ eprintln!("EC_PALSYN rect mi={mi_r},{mi_c} bw={bw} bh={bh} mode={mode} uv={uv_mode} ctx={palette_ctx} y={} uv={} rng={}", use_palette_y as i32, use_palette_uv as i32, dec.debug_state().0);
8060+ }
8061+ if use_palette_uv {
8062+ let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]);
8063+ let (u_colors, v_colors) = read_palette_colors_uv(dec, n, &palette_uv_cache);
8064+ palette_uv_pending = Some((n, u_colors, v_colors));
8036 }8065 }
8037 }8066 }
8038 // lane-fiinter (merged on main for the square intra-in-inter arm):8067 // lane-fiinter (merged on main for the square intra-in-inter arm):
@@ -8044,6 +8073,8 @@ fn decode_intra_rect_in_inter(
8044 let mut filter_intra = None;8073 let mut filter_intra = None;
8045 if mode == DC_PRED8074 if mode == DC_PRED
8046 && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get)8075 && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get)
8076+ // `av1_filter_intra_allowed` excludes a palette-Y block.
8077+ && palette_y_pending.is_none()
8047 && let Some(class) = filter_intra_size_class_rect(bw, bh)8078 && let Some(class) = filter_intra_size_class_rect(bw, bh)
8048 && dec.symbol(&mut cdfs.filter_intra[class]) != 08079 && dec.symbol(&mut cdfs.filter_intra[class]) != 0
8049 {8080 {
@@ -8051,6 +8082,24 @@ fn decode_intra_rect_in_inter(
8051 INTRA_IN_INTER_FILTER_INTRA_HITS.with(|h| h.set(h.get() + 1));8082 INTRA_IN_INTER_FILTER_INTRA_HITS.with(|h| h.set(h.get() + 1));
8052 filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode));8083 filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode));
8053 }8084 }
8085+ // `av1_visit_palette`: Y's colour-index map then the shared chroma one.
8086+ let palette_y = palette_y_pending.map(|(n, colors)| {
8087+ let map = decode_color_index_map_wh(dec, cdfs, n, bw, bh, false);
8088+ PALETTE_HITS.with(|c| c.set(c.get() + 1));
8089+ PALETTE_RECT_HITS.with(|c| c.set(c.get() + 1));
8090+ INTRA_IN_INTER_PALETTE_Y_HITS.with(|c| c.set(c.get() + 1));
8091+ if crate::envflags::env_flag!("EC_PALII") {
8092+ eprintln!("EC_PALII yrect mi={mi_r},{mi_c} bw={bw} bh={bh} n={n} skip={skip}");
8093+ }
8094+ PaletteY { size: n, colors, map }
8095+ });
8096+ let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| {
8097+ let (cw, ch) = ((bw / 2).max(4), (bh / 2).max(4));
8098+ let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, true);
8099+ PALETTE_UV_HITS.with(|c| c.set(c.get() + 1));
8100+ INTRA_IN_INTER_PALETTE_UV_HITS.with(|c| c.set(c.get() + 1));
8101+ PaletteUv { size: n, u_colors, v_colors, map }
8102+ });
8054 // The intra-edge filter type is the NEIGHBOUR's mode (libaom8103 // The intra-edge filter type is the NEIGHBOUR's mode (libaom
8055 // `get_filt_type`), luma's off the luma neighbours and chroma's off the8104 // `get_filt_type`), luma's off the luma neighbours and chroma's off the
8056 // chroma ones -- [`decode_block_rect`]'s own pair.8105 // chroma ones -- [`decode_block_rect`]'s own pair.
@@ -8127,10 +8176,15 @@ fn decode_intra_rect_in_inter(
8127 filter_intra,8176 filter_intra,
8128 smooth_neighbor,8177 smooth_neighbor,
8129 smooth_neighbor_uv,8178 smooth_neighbor_uv,
8130- // screen-content frames are refused whole above, so this strip can8179+ palette_y: palette_y
8131- // carry no palette.8180+ .as_ref()
8132- palette_y: None,8181+ .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect()),
8133- palette_uv: None,8182+ palette_uv: palette_uv.as_ref().map(|p| {
8183+ (
8184+ p.map.iter().map(|&i| p.u_colors[i as usize]).collect(),
8185+ p.map.iter().map(|&i| p.v_colors[i as usize]).collect(),
8186+ )
8187+ }),
8134 };8188 };
8135 decode_rect_split(8189 decode_rect_split(
8136 dec,8190 dec,
@@ -8164,6 +8218,18 @@ fn decode_intra_rect_in_inter(
8164 *cell = tx_h as u8;8218 *cell = tx_h as u8;
8165 }8219 }
8166 }8220 }
8221+ // The strip's own palette state into the mi-granular neighbour bands, so
8222+ // the next block's colour cache and `palette_y_mode` context are libaom's.
8223+ record_strip_palette(
8224+ neighbours,
8225+ (mi_r, mi_c),
8226+ bw,
8227+ bh,
8228+ palette_y.as_ref().map_or(0, |p| p.size),
8229+ palette_y.as_ref().map_or([0u16; 8], |p| p.colors),
8230+ palette_uv.as_ref().map_or(0, |p| p.size),
8231+ palette_uv.as_ref().map_or([0u16; 8], |p| p.u_colors),
8232+ );
8167 let class = match bw.max(bh) {8233 let class = match bw.max(bh) {
8168 64 => 0,8234 64 => 0,
8169 32 => 1,8235 32 => 1,
@@ -10825,7 +10891,7 @@ fn read_intra_mode(
10825 if use_palette_y {10891 if use_palette_y {
10826 if palette.is_none() {10892 if palette.is_none() {
10827 return Err(unsupported(10893 return Err(unsupported(
10828- "a block that actually uses a palette (Y) -- reconstruction is out of scope",10894+ "a block that actually uses a palette (Y@square) -- reconstruction is out of scope",
10829 ));10895 ));
10830 }10896 }
10831 let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]);10897 let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]);
@@ -20691,6 +20757,13 @@ fn decode_inter_block(
20691 // than one luma transform -- read back by the residual loop, the20757 // than one luma transform -- read back by the residual loop, the
20692 // coefficient-context write-back and the loop-filter grid fill below.20758 // coefficient-context write-back and the loop-filter grid fill below.
20693 let mut vartx_leaves: Option<Vec<(usize, usize, usize, usize)>> = None;20759 let mut vartx_leaves: Option<Vec<(usize, usize, usize, usize)>> = None;
20760+ // lane-t900 r22: this block's own palette state, stamped into the
20761+ // mi-granular neighbour bands at the tail below for EVERY block --
20762+ // libaom's `MB_MODE_INFO.palette_size` is 0 on an inter block, and
20763+ // `av1_get_palette_cache`/`av1_get_palette_mode_ctx` read those cells, so
20764+ // leaving a previous palette block's colours standing here would feed the
20765+ // next intra block a cache libaom never builds.
20766+ let mut palette_record: (usize, [u16; 8], usize, [u16; 8]) = (0, [0u16; 8], 0, [0u16; 8]);
20694 let at_mi = at;20767 let at_mi = at;
20695 // lane-vert46 r1: set when this block's chroma was coded as one 32x32 unit20768 // lane-vert46 r1: set when this block's chroma was coded as one 32x32 unit
20696 // per 64x64 "mu" chunk (any side above 64), so the end-of-block record20769 // per 64x64 "mu" chunk (any side above 64), so the end-of-block record
@@ -23376,18 +23449,36 @@ fn decode_inter_block(
23376 // by the block's TRUE footprint -- a rect strip's row is not its23449 // by the block's TRUE footprint -- a rect strip's row is not its
23377 // enclosing square's, and a 16x4 strip (64 pixels) reads no palette23450 // enclosing square's, and a 16x4 strip (64 pixels) reads no palette
23378 // symbol at all.23451 // symbol at all.
23452+ // lane-t900 r22: reconstructed, not refused. Same syntax and same
23453+ // deferral of the colour-index maps past `filter_intra`
23454+ // (`av1_visit_palette` runs from `parse_decode_block`, after the whole
23455+ // mode-info read) as the key frame's [`read_intra_mode`]; the mode
23456+ // context and colour cache are this block's real above/left ones, at
23457+ // its own mi position (`av1_get_palette_mode_ctx`/
23458+ // `av1_get_palette_cache`), not the hardcoded 0/empty pair the refusal
23459+ // could get away with while no neighbour could ever be a palette.
23460+ let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi((rmi, cmi));
23461+ let palette_uv_cache = neighbours.palette_uv_cache_mi((rmi, cmi));
23462+ let mut palette_y_pending: Option<(usize, [u16; 8])> = None;
23463+ let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None;
23379 if allow_screen_content_tools23464 if allow_screen_content_tools
23380 && let Some(bsize_ctx) = palette_bsize_ctx_wh(write_w, write_h)23465 && let Some(bsize_ctx) = palette_bsize_ctx_wh(write_w, write_h)
23381 {23466 {
23382- if mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][0]) != 0 {23467+ let use_palette_y =
23383- return Err(unsupported(23468+ mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[bsize_ctx][palette_ctx]) != 0;
23384- "a block that actually uses a palette (Y) -- reconstruction is out of scope",23469+ if use_palette_y {
23385- ));23470+ let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]);
23471+ palette_y_pending = Some((n, read_palette_colors_y(dec, n, &palette_cache)));
23386 }23472 }
23387- if uv_mode == DC_PRED && dec.symbol(&mut cdfs.palette_uv_mode[0]) != 0 {23473+ let use_palette_uv =
23388- return Err(unsupported(23474+ uv_mode == DC_PRED && dec.symbol(&mut cdfs.palette_uv_mode[usize::from(use_palette_y)]) != 0;
23389- "a block that actually uses a palette (UV) -- reconstruction is out of scope",23475+ if crate::envflags::env_flag!("EC_PALSYN") {
23390- ));23476+ eprintln!("EC_PALSYN sq mi={rmi},{cmi} bw={write_w} bh={write_h} mode={mode} uv={uv_mode} ctx={palette_ctx} y={} uv={} rng={}", use_palette_y as i32, use_palette_uv as i32, dec.debug_state().0);
23477+ }
23478+ if use_palette_uv {
23479+ let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]);
23480+ let (u_colors, v_colors) = read_palette_colors_uv(dec, n, &palette_uv_cache);
23481+ palette_uv_pending = Some((n, u_colors, v_colors));
23391 }23482 }
23392 }23483 }
23393 // lane-fiinter r1: `read_filter_intra_mode_info` (libaom `decodemv.c`,23484 // lane-fiinter r1: `read_filter_intra_mode_info` (libaom `decodemv.c`,
@@ -23401,6 +23492,9 @@ fn decode_inter_block(
23401 let mut filter_intra = None;23492 let mut filter_intra = None;
23402 if mode == DC_PRED23493 if mode == DC_PRED
23403 && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get)23494 && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get)
23495+ // `av1_filter_intra_allowed` (reconintra.h:77) excludes a
23496+ // palette-Y block, so no `use_filter_intra` symbol exists there.
23497+ && palette_y_pending.is_none()
23404 // lane-inter16ab r4 (class sweep): `cdf::FILTER_INTRA`'s row is the23498 // lane-inter16ab r4 (class sweep): `cdf::FILTER_INTRA`'s row is the
23405 // true `BLOCK_SIZES_ALL` class of this strip, not its square side's.23499 // true `BLOCK_SIZES_ALL` class of this strip, not its square side's.
23406 && let Some(class) = filter_intra_size_class_rect(write_w, write_h)23500 && let Some(class) = filter_intra_size_class_rect(write_w, write_h)
@@ -23410,6 +23504,44 @@ fn decode_inter_block(
23410 INTRA_IN_INTER_FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1));23504 INTRA_IN_INTER_FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1));
23411 filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode));23505 filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode));
23412 }23506 }
23507+ // `av1_visit_palette`: the two colour-index maps, Y then the shared
23508+ // chroma one, after the WHOLE mode-info read.
23509+ let palette_y = palette_y_pending.map(|(n, colors)| {
23510+ let map = decode_color_index_map_wh(dec, cdfs, n, write_w, write_h, false);
23511+ PALETTE_HITS.with(|c| c.set(c.get() + 1));
23512+ INTRA_IN_INTER_PALETTE_Y_HITS.with(|c| c.set(c.get() + 1));
23513+ if crate::envflags::env_flag!("EC_PALII") {
23514+ eprintln!("EC_PALII y mi={rmi},{cmi} bw={write_w} bh={write_h} n={n} skip={skip}");
23515+ }
23516+ PaletteY { size: n, colors, map }
23517+ });
23518+ let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| {
23519+ // `av1_get_plane_block_size(bsize, 1, 1)` floors at the 4-px
23520+ // transform, as the rect reader's own copy.
23521+ let (cw, ch) = ((write_w / 2).max(4), (write_h / 2).max(4));
23522+ let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, true);
23523+ PALETTE_UV_HITS.with(|c| c.set(c.get() + 1));
23524+ INTRA_IN_INTER_PALETTE_UV_HITS.with(|c| c.set(c.get() + 1));
23525+ PaletteUv { size: n, u_colors, v_colors, map }
23526+ });
23527+ palette_record = (
23528+ palette_y.as_ref().map_or(0, |p| p.size),
23529+ palette_y.as_ref().map_or([0u16; 8], |p| p.colors),
23530+ palette_uv.as_ref().map_or(0, |p| p.size),
23531+ palette_uv.as_ref().map_or([0u16; 8], |p| p.u_colors),
23532+ );
23533+ // A palette block predicts from its own colour-index map, never from
23534+ // the block edge (spec 7.11.2/7.11.4) -- these ride the [`PALETTE_PRED`]
23535+ // slot into each `reconstruct`/`read_plane` call below, exactly as the
23536+ // key-frame paths do.
23537+ let palette_y_buf: Option<Vec<u16>> =
23538+ palette_y.as_ref().map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect());
23539+ let palette_uv_bufs: Option<(Vec<u16>, Vec<u16>)> = palette_uv.as_ref().map(|p| {
23540+ (
23541+ p.map.iter().map(|&i| p.u_colors[i as usize]).collect(),
23542+ p.map.iter().map(|&i| p.v_colors[i as usize]).collect(),
23543+ )
23544+ });
23413 mode_for_tx = mode;23545 mode_for_tx = mode;
23414 block_filter = [3, 3];23546 block_filter = [3, 3];
23415 ref_frame_for_lf = 0;23547 ref_frame_for_lf = 0;
@@ -23473,6 +23605,19 @@ fn decode_inter_block(
23473 // bottom-left availability is the block's, narrowed by the23605 // bottom-left availability is the block's, narrowed by the
23474 // unit's own offset inside it.23606 // unit's own offset inside it.
23475 let tu_reach = Reach::of_tu(side, side, col * MI, row * MI, tx_px, tx_px, reach);23607 let tu_reach = Reach::of_tu(side, side, col * MI, row * MI, tx_px, tx_px, reach);
23608+ // This unit's own window on the block's palette prediction
23609+ // (the whole-block buffer would be indexed at the wrong
23610+ // stride by the first unit).
23611+ if let Some(buf) = &palette_y_buf {
23612+ PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
23613+ let window: Vec<u16> = (0..tx_px)
23614+ .flat_map(|i| {
23615+ let base = (row * MI + i) * side + col * MI;
23616+ buf[base..base + tx_px].iter().copied()
23617+ })
23618+ .collect();
23619+ set_palette_pred(window);
23620+ }
23476 let tu_grid = if skip {23621 let tu_grid = if skip {
23477 y.reconstruct(23622 y.reconstruct(
23478 tu_px,23623 tu_px,
@@ -23611,6 +23756,9 @@ fn decode_inter_block(
23611 INTRA_128_IN_INTER_HITS.with(|c| c.set(c.get() + 1));23756 INTRA_128_IN_INTER_HITS.with(|c| c.set(c.get() + 1));
23612 } else if skip {23757 } else if skip {
23613 if !split_luma {23758 if !split_luma {
23759+ if let Some(buf) = &palette_y_buf {
23760+ set_palette_pred(buf.clone());
23761+ }
23614 y.reconstruct(23762 y.reconstruct(
23615 px,23763 px,
23616 py,23764 py,
@@ -23625,6 +23773,9 @@ fn decode_inter_block(
23625 );23773 );
23626 }23774 }
23627 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));23775 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
23776+ if let Some((ub, _)) = &palette_uv_bufs {
23777+ set_palette_pred(ub.clone());
23778+ }
23628 u.reconstruct(23779 u.reconstruct(
23629 cpx,23780 cpx,
23630 cpy,23781 cpy,
@@ -23637,6 +23788,9 @@ fn decode_inter_block(
23637 None,23788 None,
23638 smooth_neighbor_uv,23789 smooth_neighbor_uv,
23639 );23790 );
23791+ if let Some((_, vb)) = &palette_uv_bufs {
23792+ set_palette_pred(vb.clone());
23793+ }
23640 v.reconstruct(23794 v.reconstruct(
23641 cpx,23795 cpx,
23642 cpy,23796 cpy,
@@ -23660,6 +23814,9 @@ fn decode_inter_block(
23660 // which `record_split_luma` ignores for plane 0.23814 // which `record_split_luma` ignores for plane 0.
23661 vec![0i32; side * side]23815 vec![0i32; side * side]
23662 } else {23816 } else {
23817+ if let Some(buf) = &palette_y_buf {
23818+ set_palette_pred(buf.clone());
23819+ }
23663 read_plane(23820 read_plane(
23664 dec,23821 dec,
23665 cdfs,23822 cdfs,
@@ -23684,6 +23841,9 @@ fn decode_inter_block(
23684 )?23841 )?
23685 };23842 };
23686 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));23843 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
23844+ if let Some((ub, _)) = &palette_uv_bufs {
23845+ set_palette_pred(ub.clone());
23846+ }
23687 u_grid = read_plane(23847 u_grid = read_plane(
23688 dec,23848 dec,
23689 cdfs,23849 cdfs,
@@ -23706,6 +23866,9 @@ fn decode_inter_block(
23706 None,23866 None,
23707 smooth_neighbor_uv,23867 smooth_neighbor_uv,
23708 )?;23868 )?;
23869+ if let Some((_, vb)) = &palette_uv_bufs {
23870+ set_palette_pred(vb.clone());
23871+ }
23709 v_grid = read_plane(23872 v_grid = read_plane(
23710 dec,23873 dec,
23711 cdfs,23874 cdfs,
@@ -23791,6 +23954,20 @@ fn decode_inter_block(
23791 // mi(40,220): base 1 where libaom gathers 2). Snapshot and restore is23954 // mi(40,220): base 1 where libaom gathers 2). Snapshot and restore is
23792 // equivalent to not writing them, without threading a flag through both23955 // equivalent to not writing them, without threading a flag through both
23793 // recorders.23956 // recorders.
23957+ // lane-t900 r22: every block stamps its palette state (all-zero for an
23958+ // inter block, real for a palette one) into the mi-granular neighbour
23959+ // bands, so the next intra block's `av1_get_palette_mode_ctx` and colour
23960+ // cache see exactly what libaom's mode-info grid holds.
23961+ record_strip_palette(
23962+ neighbours,
23963+ at,
23964+ write_w,
23965+ write_h,
23966+ palette_record.0,
23967+ palette_record.1,
23968+ palette_record.2,
23969+ palette_record.3,
23970+ );
23794 let saved_chroma_ctx = (!has_chroma).then(|| {23971 let saved_chroma_ctx = (!has_chroma).then(|| {
23795 NON_CHROMA_REF_CTX_SKIP_HITS.with(|c| c.set(c.get() + 1));23972 NON_CHROMA_REF_CTX_SKIP_HITS.with(|c| c.set(c.get() + 1));
23796 let (w_mi, h_mi) = (write_w / MI, write_h / MI);23973 let (w_mi, h_mi) = (write_w / MI, write_h / MI);
@@ -27027,7 +27204,7 @@ fn decode_inter_block8(
27027 if allow_screen_content_tools {27204 if allow_screen_content_tools {
27028 if mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[0][0]) != 0 {27205 if mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[0][0]) != 0 {
27029 return Err(unsupported(27206 return Err(unsupported(
27030- "a block that actually uses a palette (Y) -- reconstruction is out of scope",27207+ "a block that actually uses a palette (Y@inter_block8) -- reconstruction is out of scope",
27031 ));27208 ));
27032 }27209 }
27033 // lane-uv8 r1: `read_palette_mode_info` reads the UV symbol only27210 // lane-uv8 r1: `read_palette_mode_info` reads the UV symbol only
@@ -27035,7 +27212,7 @@ fn decode_inter_block8(
27035 // while every non-DC uv_mode was refused a few lines above.27212 // while every non-DC uv_mode was refused a few lines above.
27036 if uv_mode == DC_PRED && dec.symbol(&mut cdfs.palette_uv_mode[0]) != 0 {27213 if uv_mode == DC_PRED && dec.symbol(&mut cdfs.palette_uv_mode[0]) != 0 {
27037 return Err(unsupported(27214 return Err(unsupported(
27038- "a block that actually uses a palette (UV) -- reconstruction is out of scope",27215+ "a block that actually uses a palette (UV@inter_block8) -- reconstruction is out of scope",
27039 ));27216 ));
27040 }27217 }
27041 }27218 }