forge
Explore
Log in

Don't you dare go Hollow

wip(palette2): builder's in-flight edits, committed verbatim at the 75-turn cap (state unverified by me)

Browse files at this commit

7d58d310b46477845137b52dc5f52859b3f3dc5bAhmet Kaan GümüşParent: 5feaca3
crates/ec-av1/src/decode.rsmodified+280 -24
@@ -451,6 +451,42 @@ pub(crate) fn palette_hits() -> usize {
451451 PALETTE_HITS.with(|c| c.get())
452452 }
453453
454+// lane-palette2 r1: as [`PALETTE_HITS`], for a real (nonzero-size) chroma
455+// palette use -- proves a stream actually reconstructed UV palette pixels,
456+// not just read and refused the `palette_uv_mode` symbol.
457+thread_local! {
458+ static PALETTE_UV_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
459+}
460+
461+/// Current value of [`PALETTE_UV_HITS`].
462+pub(crate) fn palette_uv_hits() -> usize {
463+ PALETTE_UV_HITS.with(|c| c.get())
464+}
465+
466+// lane-palette2 r1: how many HORZ/VERT rect intra strips ([`read_intra_mode_rect`])
467+// decoded a real palette-Y use -- proves the rect strip's own palette syntax
468+// (not just the square path's) actually fired.
469+thread_local! {
470+ static PALETTE_RECT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
471+}
472+
473+/// Current value of [`PALETTE_RECT_HITS`].
474+pub(crate) fn palette_rect_hits() -> usize {
475+ PALETTE_RECT_HITS.with(|c| c.get())
476+}
477+
478+// lane-palette2 r1: how many palette-Y blocks decoded with a split luma
479+// transform (`tx_select && logical_tx != side`) -- proves the per-TU index-map
480+// slicing actually ran, not just that the whole-block path stayed exact.
481+thread_local! {
482+ static PALETTE_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
483+}
484+
485+/// Current value of [`PALETTE_SPLIT_TX_HITS`].
486+pub(crate) fn palette_split_tx_hits() -> usize {
487+ PALETTE_SPLIT_TX_HITS.with(|c| c.get())
488+}
489+
454490 thread_local! {
455491 /// A just-decoded palette-Y block's own predicted pixels
456492 /// (`side*side`, row-major, `colors[map[i]]`), consumed by
@@ -1630,6 +1666,13 @@ struct Neighbours {
16301666 left_palette_size: Vec<usize>,
16311667 above_palette_colors: Vec<[u16; 8]>,
16321668 left_palette_colors: Vec<[u16; 8]>,
1669+ /// As the four fields above, for the neighbour's own chroma (U-channel
1670+ /// only -- `av1_get_palette_cache`'s plane-1 lookup, [`Self::palette_uv_cache`])
1671+ /// palette size/colours (lane-palette2 r1).
1672+ above_palette_uv_size: Vec<usize>,
1673+ left_palette_uv_size: Vec<usize>,
1674+ above_palette_uv_colors: Vec<[u16; 8]>,
1675+ left_palette_uv_colors: Vec<[u16; 8]>,
16331676 /// This tile's own top-left corner, in 4x4 mode-info units (spec
16341677 /// `MiRowStart`/`MiColStart`) -- lane-tiles: every "is there really a
16351678 /// neighbour" check compares against this instead of literal `0`, since a
@@ -1684,6 +1727,10 @@ impl Neighbours {
16841727 left_palette_size: vec![0; rows],
16851728 above_palette_colors: vec![[0u16; 8]; cols],
16861729 left_palette_colors: vec![[0u16; 8]; rows],
1730+ above_palette_uv_size: vec![0; cols],
1731+ left_palette_uv_size: vec![0; rows],
1732+ above_palette_uv_colors: vec![[0u16; 8]; cols],
1733+ left_palette_uv_colors: vec![[0u16; 8]; rows],
16871734 tile_row0_mi: 0,
16881735 tile_col0_mi: 0,
16891736 }
@@ -1789,6 +1836,70 @@ impl Neighbours {
17891836 (ctx, cache)
17901837 }
17911838
1839+ /// As [`Self::record_palette_y`], for a just-decoded block's own chroma
1840+ /// (U-channel) palette size/colours -- `size == 0` clears stale state the
1841+ /// same way (lane-palette2 r1).
1842+ fn record_palette_uv(&mut self, at: (usize, usize), side: usize, size: usize, colors: [u16; 8]) {
1843+ let (r, c) = at;
1844+ for cell in 0..side / SUB {
1845+ self.above_palette_uv_size[c + cell] = size;
1846+ self.above_palette_uv_colors[c + cell] = colors;
1847+ }
1848+ for cell in 0..side / SUB {
1849+ self.left_palette_uv_size[r + cell] = size;
1850+ self.left_palette_uv_colors[r + cell] = colors;
1851+ }
1852+ }
1853+
1854+ /// [`Self::palette_ctx_and_cache`]'s cache half, for the U channel
1855+ /// (`av1_get_palette_cache(xd, 1, cache)`) -- `palette_uv_mode_ctx` needs
1856+ /// no neighbour lookup at all (it is this block's own just-decided Y
1857+ /// palette use, `read_palette_mode_info`'s `pmi->palette_size[0] > 0`),
1858+ /// so only the cache is wanted here.
1859+ fn palette_uv_cache(&self, at: (usize, usize)) -> Vec<u16> {
1860+ let (r, c) = at;
1861+ let above_ok = r % 4 != 0;
1862+ let (above_n, above_colors) = if above_ok && self.above_palette_uv_size[c] > 0 {
1863+ (self.above_palette_uv_size[c], self.above_palette_uv_colors[c])
1864+ } else {
1865+ (0, [0u16; 8])
1866+ };
1867+ let (left_n, left_colors) = if self.left_palette_uv_size[r] > 0 {
1868+ (self.left_palette_uv_size[r], self.left_palette_uv_colors[r])
1869+ } else {
1870+ (0, [0u16; 8])
1871+ };
1872+ let mut cache = Vec::with_capacity(16);
1873+ let push_dedup = |cache: &mut Vec<u16>, v: u16| {
1874+ if cache.last() != Some(&v) {
1875+ cache.push(v);
1876+ }
1877+ };
1878+ let (mut ai, mut li) = (0usize, 0usize);
1879+ while ai < above_n && li < left_n {
1880+ let (va, vl) = (above_colors[ai], left_colors[li]);
1881+ if vl < va {
1882+ push_dedup(&mut cache, vl);
1883+ li += 1;
1884+ } else {
1885+ push_dedup(&mut cache, va);
1886+ ai += 1;
1887+ if vl == va {
1888+ li += 1;
1889+ }
1890+ }
1891+ }
1892+ while ai < above_n {
1893+ push_dedup(&mut cache, above_colors[ai]);
1894+ ai += 1;
1895+ }
1896+ while li < left_n {
1897+ push_dedup(&mut cache, left_colors[li]);
1898+ li += 1;
1899+ }
1900+ cache
1901+ }
1902+
17921903 /// Marks every 4x4 mi cell a just-decoded coded block covers with its own
17931904 /// transform width (in pixels) and `is_inter` flag -- the loop filter's
17941905 /// per-edge lookup (`apply_deblock`), filled at the same call sites and
@@ -2339,15 +2450,22 @@ fn filter_intra_size_class_rect(bw: usize, bh: usize) -> Option<usize> {
23392450 /// `av1_allow_palette`'s size bound (blockd.h: `block_size_wide/high <=
23402451 /// MAX_PALETTE_BLOCK_WIDTH/HEIGHT` (64) and `sb_type >= BLOCK_8X8`) plus
23412452 /// `av1_get_palette_bsize_ctx` (pred_common.h: `num_pels_log2_lookup[bsize]
2342-/// - num_pels_log2_lookup[BLOCK_8X8]`, i.e. `2*log2(side) - 6` for this
2343-/// decoder's square-only blocks) -- `None` past the bound (never gates a
2344-/// palette read), `Some(bsize_ctx)` otherwise.
2453+/// - num_pels_log2_lookup[BLOCK_8X8]`, i.e. `log2(bw*bh) - 6`) -- `None` past
2454+/// the bound (never gates a palette read), `Some(bsize_ctx)` otherwise.
23452455 fn palette_bsize_ctx(side: usize) -> Option<usize> {
2346- match side {
2347- 8 => Some(0),
2348- 16 => Some(2),
2349- 32 => Some(4),
2350- 64 => Some(6),
2456+ palette_bsize_ctx_wh(side, side)
2457+}
2458+
2459+/// [`palette_bsize_ctx`], generalised to a true `bw`x`bh` rect strip
2460+/// (lane-palette2 r1) -- the same `log2(bw*bh) - 6` formula, this decoder's
2461+/// square call sites are just `bw == bh`.
2462+fn palette_bsize_ctx_wh(bw: usize, bh: usize) -> Option<usize> {
2463+ match (bw, bh) {
2464+ (8, 8) => Some(0),
2465+ (16, 16) => Some(2),
2466+ (32, 16) | (16, 32) => Some(3),
2467+ (32, 32) => Some(4),
2468+ (64, 64) => Some(6),
23512469 _ => None,
23522470 }
23532471 }
@@ -2361,6 +2479,17 @@ struct PaletteY {
23612479 map: Vec<u8>,
23622480 }
23632481
2482+/// As [`PaletteY`], for a just-decoded chroma palette block: one shared
2483+/// per-pixel colour-index map (spec `av1_visit_palette`'s plane-1 pass is
2484+/// shared between U and V, both co-located after 4:2:0 subsampling) plus
2485+/// each plane's own base colours.
2486+struct PaletteUv {
2487+ size: usize,
2488+ u_colors: [u16; 8],
2489+ v_colors: [u16; 8],
2490+ map: Vec<u8>,
2491+}
2492+
23642493 /// `aom_ceil_log2` (aom_dsp/bitwriter_buffer.h-adjacent helper, used both by
23652494 /// `read_palette_colors_y`'s shrinking `bits` and `av1_read_uniform`'s
23662495 /// `get_unsigned_bits`, which is the same formula): smallest `n` with
@@ -2446,6 +2575,74 @@ fn read_palette_colors_y(dec: &mut SymbolDecoder, n: usize, cache: &[u16]) -> [u
24462575 colors
24472576 }
24482577
2578+/// `read_palette_colors_uv` (decodemv.c:509), bit_depth fixed at 8: U reads
2579+/// exactly [`read_palette_colors_y`]'s cache/delta scheme (against the U-only
2580+/// cache, `range` starting at `255 - prev` with no `-1`, and each raw `delta`
2581+/// unbiased by `+1` -- both differences from Y's own reader, matching the C
2582+/// side by side). V never uses a cache: a leading bit picks either `n` raw
2583+/// literals, or a first raw value plus `n-1` signed deltas that wrap mod 256
2584+/// rather than clamp.
2585+fn read_palette_colors_uv(dec: &mut SymbolDecoder, n: usize, cache: &[u16]) -> ([u16; 8], [u16; 8]) {
2586+ let mut cached = Vec::with_capacity(n);
2587+ for &c in cache {
2588+ if cached.len() >= n {
2589+ break;
2590+ }
2591+ if dec.literal(1) == 1 {
2592+ cached.push(c);
2593+ }
2594+ }
2595+ let mut u_colors = [0u16; 8];
2596+ let n_cached = cached.len();
2597+ if n_cached < n {
2598+ let mut transmitted = Vec::with_capacity(n - n_cached);
2599+ let first = dec.literal(8) as u16;
2600+ transmitted.push(first);
2601+ if n_cached + 1 < n {
2602+ let min_bits = 8u32 - 3;
2603+ let mut bits = min_bits + dec.literal(2);
2604+ let mut range = 255i32 - i32::from(first);
2605+ for _ in (n_cached + 1)..n {
2606+ let delta = dec.literal(bits) as i32;
2607+ let prev = *transmitted.last().unwrap();
2608+ let val = (i32::from(prev) + delta).clamp(0, 255) as u16;
2609+ range -= i32::from(val) - i32::from(prev);
2610+ bits = bits.min(ceil_log2(range.max(0) as u32));
2611+ transmitted.push(val);
2612+ }
2613+ }
2614+ let merged = merge_colors(&transmitted, &cached);
2615+ u_colors[..n].copy_from_slice(&merged);
2616+ } else {
2617+ u_colors[..n].copy_from_slice(&cached[..n]);
2618+ }
2619+ let mut v_colors = [0u16; 8];
2620+ if dec.literal(1) == 1 {
2621+ let min_bits_v = 8u32 - 4;
2622+ let bits = min_bits_v + dec.literal(2);
2623+ v_colors[0] = dec.literal(8) as u16;
2624+ for i in 1..n {
2625+ let mut delta = dec.literal(bits) as i32;
2626+ if delta != 0 && dec.literal(1) == 1 {
2627+ delta = -delta;
2628+ }
2629+ let mut val = i32::from(v_colors[i - 1]) + delta;
2630+ if val < 0 {
2631+ val += 256;
2632+ }
2633+ if val >= 256 {
2634+ val -= 256;
2635+ }
2636+ v_colors[i] = val as u16;
2637+ }
2638+ } else {
2639+ for i in 0..n {
2640+ v_colors[i] = dec.literal(8) as u16;
2641+ }
2642+ }
2643+ (u_colors, v_colors)
2644+}
2645+
24492646 /// `av1_palette_color_index_context_lookup` (entropymode.c:889): maps a
24502647 /// `NUM_PALETTE_NEIGHBORS`-weighted score hash (`0..=8`) to the real
24512648 /// `0..=4` context, `-1` for hashes no real neighbour configuration produces.
@@ -2514,7 +2711,13 @@ fn palette_color_index_context(
25142711 /// region (every other skip/residual path here does the same), so no
25152712 /// rows/cols-vs-plane_width/height cropping special case is needed, unlike
25162713 /// libaom's own non-block-aligned split.
2517-fn decode_color_index_map(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, n: usize, side: usize) -> Vec<u8> {
2714+fn decode_color_index_map(
2715+ dec: &mut SymbolDecoder,
2716+ cdfs: &mut Cdfs,
2717+ n: usize,
2718+ side: usize,
2719+ uv: bool,
2720+) -> Vec<u8> {
25182721 let trace = std::env::var_os("EC_AV1_TRACE").is_some();
25192722 let mut map = vec![0u8; side * side];
25202723 if trace {
@@ -2537,7 +2740,11 @@ fn decode_color_index_map(dec: &mut SymbolDecoder, cdfs: &mut Cdfs, n: usize, si
25372740 let (rng, _) = dec.debug_state();
25382741 eprintln!("EC_PAL row={row} col={col} ctx={ctx} n={n} rng={rng}");
25392742 }
2540- let symbol = dec.symbol(&mut cdfs.palette_y_color_index[n - 2][ctx][..=n]);
2743+ let symbol = if uv {
2744+ dec.symbol(&mut cdfs.palette_uv_color_index[n - 2][ctx][..=n])
2745+ } else {
2746+ dec.symbol(&mut cdfs.palette_y_color_index[n - 2][ctx][..=n])
2747+ };
25412748 map[row * side + col] = color_order[symbol];
25422749 if trace {
25432750 let (rng, _) = dec.debug_state();
@@ -3056,6 +3263,11 @@ fn read_intra_mode(
30563263 // decoder reads either way -- but refuse by name the moment it fires,
30573264 // exactly the old behaviour.
30583265 palette: Option<(usize, &[u16])>,
3266+ // The U-channel colour cache for a chroma palette read ([`Neighbours::palette_uv_cache`]),
3267+ // `&[]` at the excluded call sites -- same corner-cut as `palette` above,
3268+ // no `mode_ctx` needed (`palette_uv_mode_ctx` is this block's own just-read
3269+ // `use_palette_y`, not a neighbour lookup).
3270+ palette_uv_cache: &[u16],
30593271 mi_r: usize,
30603272 mi_c: usize,
30613273 ) -> Result<(
@@ -3067,6 +3279,7 @@ fn read_intra_mode(
30673279 Option<(i32, i32)>,
30683280 Option<usize>,
30693281 Option<PaletteY>,
3282+ Option<PaletteUv>,
30703283 )> {
30713284 let trace = std::env::var_os("EC_AV1_TRACE").is_some();
30723285 let skip = dec.symbol(&mut cdfs.skip[skip_ctx]) != 0;
@@ -3174,6 +3387,7 @@ fn read_intra_mode(
31743387 // bit-for-bit through the Y colours, diverged only at the old inline
31753388 // `decode_color_index_map` call).
31763389 let mut palette_y_pending: Option<(usize, [u16; 8])> = None;
3390+ let mut palette_uv_pending: Option<(usize, [u16; 8], [u16; 8])> = None;
31773391 if allow_screen_content_tools
31783392 && let Some(bsize_ctx) = palette_bsize_ctx(side)
31793393 {
@@ -3215,15 +3429,12 @@ fn read_intra_mode(
32153429 // UV_DC_PRED`, regardless of whether Y just fired -- this decoder's
32163430 // scope always reconstructs chroma alongside luma (`decode_block`
32173431 // always calls `u.reconstruct`/`v.reconstruct`), so `is_chroma_ref`
3218- // is always true here and does not need threading in. UV palette
3219- // reconstruction stays out of scope: refusing the moment the mode
3220- // symbol fires needs no further reads (the whole decode aborts),
3221- // so `palette_uv_size`/`read_palette_colors_uv` are never reached.
3432+ // is always true here and does not need threading in.
32223433 let palette_uv_mode_ctx = usize::from(use_palette_y);
32233434 if uv_mode == DC_PRED && dec.symbol(&mut cdfs.palette_uv_mode[palette_uv_mode_ctx]) != 0 {
3224- return Err(unsupported(
3225- "a block that actually uses a palette (UV) -- reconstruction is out of scope",
3226- ));
3435+ let n = 2 + dec.symbol(&mut cdfs.palette_uv_size[bsize_ctx]);
3436+ let (u_colors, v_colors) = read_palette_colors_uv(dec, n, palette_uv_cache);
3437+ palette_uv_pending = Some((n, u_colors, v_colors));
32273438 }
32283439 }
32293440 // `read_filter_intra_mode_info` (spec 5.11.14, libaom decodemv.c): a
@@ -3254,19 +3465,28 @@ fn read_intra_mode(
32543465 filter_intra = Some(fi_mode);
32553466 }
32563467 }
3257- // `av1_visit_palette` (decoder.c:234): the colour-index-map decode runs
3258- // here, after every mode-info symbol for the block (including UV
3259- // palette and filter_intra above) -- plane 0 (Y) only in this decoder's
3260- // scope, since UV palette already refused by name above and never left
3261- // a pending map to decode.
3468+ // `av1_visit_palette` (decoder.c:234): plane 0 (Y) then plane 1 (chroma,
3469+ // shared U/V map) -- the same order libaom's own loop visits them in.
32623470 let palette_y = palette_y_pending.map(|(n, colors)| {
3263- let map = decode_color_index_map(dec, cdfs, n, side);
3471+ let map = decode_color_index_map(dec, cdfs, n, side, false);
32643472 PALETTE_HITS.with(|c| c.set(c.get() + 1));
32653473 if trace {
32663474 eprintln!("TRACE palette_y size={n} colors={:?}", &colors[..n]);
32673475 }
32683476 PaletteY { size: n, colors, map }
32693477 });
3478+ let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| {
3479+ let map = decode_color_index_map(dec, cdfs, n, side / 2, true);
3480+ PALETTE_UV_HITS.with(|c| c.set(c.get() + 1));
3481+ if trace {
3482+ eprintln!(
3483+ "TRACE palette_uv size={n} u_colors={:?} v_colors={:?}",
3484+ &u_colors[..n],
3485+ &v_colors[..n]
3486+ );
3487+ }
3488+ PaletteUv { size: n, u_colors, v_colors, map }
3489+ });
32703490 Ok((
32713491 skip,
32723492 mode,
@@ -3276,6 +3496,7 @@ fn read_intra_mode(
32763496 alpha,
32773497 filter_intra,
32783498 palette_y,
3499+ palette_uv,
32793500 ))
32803501 }
32813502
@@ -3766,7 +3987,8 @@ fn decode_block(
37663987 let (r, c) = at;
37673988 let (px, py) = (c * SUB, r * SUB);
37683989 let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache(at);
3769- let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y) =
3990+ let palette_uv_cache = neighbours.palette_uv_cache(at);
3991+ let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) =
37703992 read_intra_mode(
37713993 dec,
37723994 cdfs,
@@ -3779,6 +4001,7 @@ fn decode_block(
37794001 allow_screen_content_tools,
37804002 allow_intrabc,
37814003 Some((palette_ctx, &palette_cache)),
4004+ &palette_uv_cache,
37824005 r * (SUB / MI),
37834006 c * (SUB / MI),
37844007 )?;
@@ -3842,6 +4065,17 @@ fn decode_block(
38424065 let buf: Vec<u8> = py.map.iter().map(|&idx| py.colors[idx as usize] as u8).collect();
38434066 PALETTE_PRED.with(|c| *c.borrow_mut() = Some(buf));
38444067 }
4068+ // A UV-palette block's own chroma prediction override (lane-palette2 r1),
4069+ // same [`PALETTE_PRED`] slot as Y above -- set fresh right before each
4070+ // plane's own `reconstruct`/`read_plane` call below (never both planes at
4071+ // once), since Y's own set-then-take already emptied the slot by the time
4072+ // either of these run.
4073+ let palette_uv_bufs: Option<(Vec<u8>, Vec<u8>)> = palette_uv.as_ref().map(|puv| {
4074+ (
4075+ puv.map.iter().map(|&idx| puv.u_colors[idx as usize] as u8).collect(),
4076+ puv.map.iter().map(|&idx| puv.v_colors[idx as usize] as u8).collect(),
4077+ )
4078+ });
38454079 if skip {
38464080 // A skipped block codes no residual syntax at all (spec 5.11.34):
38474081 // straight prediction, on every plane.
@@ -3858,6 +4092,9 @@ fn decode_block(
38584092 smooth_neighbor,
38594093 );
38604094 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
4095+ if let Some((ub, _)) = &palette_uv_bufs {
4096+ PALETTE_PRED.with(|c| *c.borrow_mut() = Some(ub.clone()));
4097+ }
38614098 u.reconstruct(
38624099 cpx,
38634100 cpy,
@@ -3870,6 +4107,9 @@ fn decode_block(
38704107 None,
38714108 smooth_neighbor_uv,
38724109 );
4110+ if let Some((_, vb)) = &palette_uv_bufs {
4111+ PALETTE_PRED.with(|c| *c.borrow_mut() = Some(vb.clone()));
4112+ }
38734113 v.reconstruct(
38744114 cpx,
38754115 cpy,
@@ -3914,6 +4154,9 @@ fn decode_block(
39144154 smooth_neighbor,
39154155 )?;
39164156 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
4157+ if let Some((ub, _)) = &palette_uv_bufs {
4158+ PALETTE_PRED.with(|c| *c.borrow_mut() = Some(ub.clone()));
4159+ }
39174160 let u_grid = read_plane(
39184161 dec,
39194162 cdfs,
@@ -3942,6 +4185,9 @@ fn decode_block(
39424185 &u.data[cpy * u.width + cpx..][..chroma_side]
39434186 );
39444187 }
4188+ if let Some((_, vb)) = &palette_uv_bufs {
4189+ PALETTE_PRED.with(|c| *c.borrow_mut() = Some(vb.clone()));
4190+ }
39454191 let v_grid = read_plane(
39464192 dec,
39474193 cdfs,
@@ -4023,6 +4269,9 @@ fn decode_block(
40234269 }
40244270 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side));
40254271 let chroma_around = neighbours.around(at, side);
4272+ if let Some((ub, _)) = &palette_uv_bufs {
4273+ PALETTE_PRED.with(|c| *c.borrow_mut() = Some(ub.clone()));
4274+ }
40264275 let u_grid = read_plane(
40274276 dec,
40284277 cdfs,
@@ -4045,6 +4294,9 @@ fn decode_block(
40454294 None,
40464295 smooth_neighbor_uv,
40474296 )?;
4297+ if let Some((_, vb)) = &palette_uv_bufs {
4298+ PALETTE_PRED.with(|c| *c.borrow_mut() = Some(vb.clone()));
4299+ }
40484300 let v_grid = read_plane(
40494301 dec,
40504302 cdfs,
@@ -4078,6 +4330,10 @@ fn decode_block(
40784330 .as_ref()
40794331 .map_or((0, [0u16; 8]), |p| (p.size, p.colors));
40804332 neighbours.record_palette_y(at, side, py_size, py_colors);
4333+ let (puv_size, puv_colors) = palette_uv
4334+ .as_ref()
4335+ .map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
4336+ neighbours.record_palette_uv(at, side, puv_size, puv_colors);
40814337 neighbours.fill_skip_grid((r * (SUB / MI), c * (SUB / MI)), side / MI, skip);
40824338 neighbours.fill_lf_grid(
40834339 (r * (SUB / MI), c * (SUB / MI)),