Palette reconstruction on 1:4 and sub-16 rect intra strips
Browse files at this commit242e934fdd04527927149997b11b6ad8bfae60f4Parent: b80bbd7- feat
- palette reconstruction on 1:4 and sub-16 rect intra strips
4 changed files +535 -45
- crates/ec-av1/src/decode.rs +260 -43
- crates/ec-av1/src/refusal_inventory.rs +0 -2
- crates/ec-av1/src/stream.rs +205 -0
- lanes/kf900-r4.report.md +70 -0
crates/ec-av1/src/decode.rsmodified+260 -43
| @@ -1455,6 +1455,18 @@ thread_local! { | |||
| 1455 | static PALETTE_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 1455 | static PALETTE_SPLIT_TX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1456 | } | 1456 | } |
| 1457 | 1457 | ||
| 1458 | +thread_local! { | ||
| 1459 | + /// lane-kf900 r4: rect intra strips that ACTUALLY use a palette -- the | ||
| 1460 | + /// 1:4 shapes (32x8/8x32, 16x4/4x16) and the sub-16x16 2:1 leaves | ||
| 1461 | + /// (16x8/8x16), the two shapes the lifted refusals named. | ||
| 1462 | + static RECT4_PALETTE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1463 | +} | ||
| 1464 | + | ||
| 1465 | +/// Current value of [`RECT4_PALETTE_HITS`]. | ||
| 1466 | +pub(crate) fn rect4_palette_hits() -> usize { | ||
| 1467 | + RECT4_PALETTE_HITS.with(|c| c.get()) | ||
| 1468 | +} | ||
| 1469 | + | ||
| 1458 | /// Current value of [`PALETTE_SPLIT_TX_HITS`]. | 1470 | /// Current value of [`PALETTE_SPLIT_TX_HITS`]. |
| 1459 | pub(crate) fn palette_split_tx_hits() -> usize { | 1471 | pub(crate) fn palette_split_tx_hits() -> usize { |
| 1460 | PALETTE_SPLIT_TX_HITS.with(|c| c.get()) | 1472 | PALETTE_SPLIT_TX_HITS.with(|c| c.get()) |
| @@ -3998,11 +4010,21 @@ impl Neighbours { | |||
| 3998 | /// palette block decoded as "no palette" and the tile desynced from | 4010 | /// palette block decoded as "no palette" and the tile desynced from |
| 3999 | /// there (class [[cdf-row-held-constant]]). | 4011 | /// there (class [[cdf-row-held-constant]]). |
| 4000 | fn palette_ctx_and_cache(&self, at: (usize, usize)) -> (usize, Vec<u16>) { | 4012 | fn palette_ctx_and_cache(&self, at: (usize, usize)) -> (usize, Vec<u16>) { |
| 4013 | + self.palette_ctx_and_cache_mi(at, at.0 * (SUB / MI)) | ||
| 4014 | + } | ||
| 4015 | + | ||
| 4016 | + /// [`Self::palette_ctx_and_cache`] with the block's REAL mi row, which a | ||
| 4017 | + /// 1:4 strip does not share with its [`SUB`] cell: `av1_get_palette_cache` | ||
| 4018 | + /// drops the above neighbour on a 64-px superblock boundary | ||
| 4019 | + /// (pred_common.c:76, `row % (1 << MIN_SB_SIZE_LOG2)` with `row` the | ||
| 4020 | + /// block's own PIXEL row), and strip 1 of a HORZ_4 sits 8 px into the | ||
| 4021 | + /// cell -- reading `at.0 % 4` there excludes strip 0 from the cache of | ||
| 4022 | + /// every strip in an SB's top cell row, which libaom does not do. | ||
| 4023 | + fn palette_ctx_and_cache_mi(&self, at: (usize, usize), mi_r: usize) -> (usize, Vec<u16>) { | ||
| 4001 | let (r, c) = at; | 4024 | let (r, c) = at; |
| 4002 | - let above_ok = r % 4 != 0; | 4025 | + let above_ok = mi_r % 16 != 0; |
| 4003 | // `xd->above_mbmi` exists for every row but the tile's own first. | 4026 | // `xd->above_mbmi` exists for every row but the tile's own first. |
| 4004 | - let above_is_palette = | 4027 | + let above_is_palette = mi_r > self.tile_row0_mi && self.above_palette_size[c] > 0; |
| 4005 | - r * (SUB / MI) > self.tile_row0_mi && self.above_palette_size[c] > 0; | ||
| 4006 | let (above_n, above_colors) = if above_ok && self.above_palette_size[c] > 0 { | 4028 | let (above_n, above_colors) = if above_ok && self.above_palette_size[c] > 0 { |
| 4007 | (self.above_palette_size[c], self.above_palette_colors[c]) | 4029 | (self.above_palette_size[c], self.above_palette_colors[c]) |
| 4008 | } else { | 4030 | } else { |
| @@ -4088,8 +4110,14 @@ impl Neighbours { | |||
| 4088 | /// palette use, `read_palette_mode_info`'s `pmi->palette_size[0] > 0`), | 4110 | /// palette use, `read_palette_mode_info`'s `pmi->palette_size[0] > 0`), |
| 4089 | /// so only the cache is wanted here. | 4111 | /// so only the cache is wanted here. |
| 4090 | fn palette_uv_cache(&self, at: (usize, usize)) -> Vec<u16> { | 4112 | fn palette_uv_cache(&self, at: (usize, usize)) -> Vec<u16> { |
| 4113 | + self.palette_uv_cache_mi(at, at.0 * (SUB / MI)) | ||
| 4114 | + } | ||
| 4115 | + | ||
| 4116 | + /// [`Self::palette_uv_cache`] with the block's real mi row -- see | ||
| 4117 | + /// [`Self::palette_ctx_and_cache_mi`]. | ||
| 4118 | + fn palette_uv_cache_mi(&self, at: (usize, usize), mi_r: usize) -> Vec<u16> { | ||
| 4091 | let (r, c) = at; | 4119 | let (r, c) = at; |
| 4092 | - let above_ok = r % 4 != 0; | 4120 | + let above_ok = mi_r % 16 != 0; |
| 4093 | let (above_n, above_colors) = if above_ok && self.above_palette_uv_size[c] > 0 { | 4121 | let (above_n, above_colors) = if above_ok && self.above_palette_uv_size[c] > 0 { |
| 4094 | (self.above_palette_uv_size[c], self.above_palette_uv_colors[c]) | 4122 | (self.above_palette_uv_size[c], self.above_palette_uv_colors[c]) |
| 4095 | } else { | 4123 | } else { |
| @@ -5666,7 +5694,13 @@ fn read_intra_mode_rect( | |||
| 5666 | PaletteY { size: n, colors, map } | 5694 | PaletteY { size: n, colors, map } |
| 5667 | }); | 5695 | }); |
| 5668 | let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { | 5696 | let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { |
| 5669 | - let map = decode_color_index_map_wh(dec, cdfs, n, bw / 2, bh / 2, true); | 5697 | + // `av1_get_plane_block_size(bsize, 1, 1)` (`ss_size_lookup`), NOT a |
| 5698 | + // plain halving: BLOCK_16X4 subsamples to BLOCK_8X4 and BLOCK_4X16 to | ||
| 5699 | + // BLOCK_4X8, both floored at the 4-px transform. Halving the short | ||
| 5700 | + // axis to 2 read HALF the colour-index symbols of a 1:4 strip's | ||
| 5701 | + // chroma palette and desynced the tile from there. | ||
| 5702 | + let (cw, ch) = ((bw / 2).max(4), (bh / 2).max(4)); | ||
| 5703 | + let map = decode_color_index_map_wh(dec, cdfs, n, cw, ch, true); | ||
| 5670 | PALETTE_UV_HITS.with(|c| c.set(c.get() + 1)); | 5704 | PALETTE_UV_HITS.with(|c| c.set(c.get() + 1)); |
| 5671 | PaletteUv { size: n, u_colors, v_colors, map } | 5705 | PaletteUv { size: n, u_colors, v_colors, map } |
| 5672 | }); | 5706 | }); |
| @@ -5683,6 +5717,48 @@ fn read_intra_mode_rect( | |||
| 5683 | )) | 5717 | )) |
| 5684 | } | 5718 | } |
| 5685 | 5719 | ||
| 5720 | +/// Stamps a 1:4 strip's palette state into the coarse above/left arrays. | ||
| 5721 | +/// `av1_get_palette_cache` reads `xd->above_mbmi`/`xd->left_mbmi`, and inside | ||
| 5722 | +/// a HORZ_4 (VERT_4) the next strip's ABOVE (LEFT) neighbour is this strip | ||
| 5723 | +/// while its LEFT (ABOVE) neighbour is still the parent block's. The coarse | ||
| 5724 | +/// [`SUB`]-cell arrays alias all four strips onto one entry, so writing BOTH | ||
| 5725 | +/// axes after every strip would hand strip i+1 this strip's colours on the | ||
| 5726 | +/// wrong axis too -- a wrong cache costs the same bits, so the tile stays in | ||
| 5727 | +/// sync and only the pixels are wrong (class [[cdf-row-held-constant]]). | ||
| 5728 | +/// Only the split axis is written until the closing strip, which stamps both | ||
| 5729 | +/// for whatever follows the parent block. | ||
| 5730 | +#[allow(clippy::too_many_arguments)] | ||
| 5731 | +fn record_strip_palette( | ||
| 5732 | + n: &mut Neighbours, | ||
| 5733 | + at: (usize, usize), | ||
| 5734 | + bw: usize, | ||
| 5735 | + bh: usize, | ||
| 5736 | + y_size: usize, | ||
| 5737 | + y_colors: [u16; 8], | ||
| 5738 | + uv_size: usize, | ||
| 5739 | + uv_colors: [u16; 8], | ||
| 5740 | + last: bool, | ||
| 5741 | +) { | ||
| 5742 | + let (r, c) = at; | ||
| 5743 | + let horz = bw > bh; | ||
| 5744 | + if horz || last { | ||
| 5745 | + for cell in 0..(bw / SUB).max(1) { | ||
| 5746 | + n.above_palette_size[c + cell] = y_size; | ||
| 5747 | + n.above_palette_colors[c + cell] = y_colors; | ||
| 5748 | + n.above_palette_uv_size[c + cell] = uv_size; | ||
| 5749 | + n.above_palette_uv_colors[c + cell] = uv_colors; | ||
| 5750 | + } | ||
| 5751 | + } | ||
| 5752 | + if !horz || last { | ||
| 5753 | + for cell in 0..(bh / SUB).max(1) { | ||
| 5754 | + n.left_palette_size[r + cell] = y_size; | ||
| 5755 | + n.left_palette_colors[r + cell] = y_colors; | ||
| 5756 | + n.left_palette_uv_size[r + cell] = uv_size; | ||
| 5757 | + n.left_palette_uv_colors[r + cell] = uv_colors; | ||
| 5758 | + } | ||
| 5759 | + } | ||
| 5760 | +} | ||
| 5761 | + | ||
| 5686 | /// [`tx_size_context`] for a true `bw`x`bh` rect strip (lane-intradisp r1): | 5762 | /// [`tx_size_context`] for a true `bw`x`bh` rect strip (lane-intradisp r1): |
| 5687 | /// `get_tx_size_context` (libaom `pred_common.h`) compares the neighbour | 5763 | /// `get_tx_size_context` (libaom `pred_common.h`) compares the neighbour |
| 5688 | /// above against this block's own *width* and the neighbour to the left | 5764 | /// above against this block's own *width* and the neighbour to the left |
| @@ -6881,8 +6957,11 @@ fn decode_leaf_rect( | |||
| 6881 | // decoded bit is the same. The cell is the 16px-SUB cell containing the | 6957 | // decoded bit is the same. The cell is the 16px-SUB cell containing the |
| 6882 | // leaf (the palette neighbour arrays have no finer granularity). | 6958 | // leaf (the palette neighbour arrays have no finer granularity). |
| 6883 | let pal_at = (leaf_mi.0 / (SUB / MI), leaf_mi.1 / (SUB / MI)); | 6959 | let pal_at = (leaf_mi.0 / (SUB / MI), leaf_mi.1 / (SUB / MI)); |
| 6884 | - let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache(pal_at); | 6960 | + // lane-kf900 r4: the leaf's REAL mi row -- the second leaf of a 16x8 pair |
| 6885 | - let palette_uv_cache = neighbours.palette_uv_cache(pal_at); | 6961 | + // sits 8 px into the cell, so the cache's superblock-top-row exclusion |
| 6962 | + // must not be read off the cell (see [`Neighbours::palette_ctx_and_cache_mi`]). | ||
| 6963 | + let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at, leaf_mi.0); | ||
| 6964 | + let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at, leaf_mi.0); | ||
| 6886 | let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) = | 6965 | let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) = |
| 6887 | read_intra_mode_rect( | 6966 | read_intra_mode_rect( |
| 6888 | dec, | 6967 | dec, |
| @@ -6901,14 +6980,31 @@ fn decode_leaf_rect( | |||
| 6901 | leaf_mi.0, | 6980 | leaf_mi.0, |
| 6902 | leaf_mi.1, | 6981 | leaf_mi.1, |
| 6903 | )?; | 6982 | )?; |
| 6983 | + // lane-kf900 r4: palette prediction on this shape, the same colour-index | ||
| 6984 | + // map -> base colours buffer [`decode_block_rect`] hands each | ||
| 6985 | + // `reconstruct_rect` through [`set_palette_pred`]. | ||
| 6904 | if palette_y.is_some() || palette_uv.is_some() { | 6986 | if palette_y.is_some() || palette_uv.is_some() { |
| 6905 | - // Symbols (mode/size/colours/index map) are all read above, so the | 6987 | + RECT4_PALETTE_HITS.with(|c| c.set(c.get() + 1)); |
| 6906 | - // tile stays in sync; only the *pixel* reconstruction of a palette on | ||
| 6907 | - // a below-16x16 strip is unported and ungated (lane-palette2 r7). | ||
| 6908 | - return Err(unsupported( | ||
| 6909 | - "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)", | ||
| 6910 | - )); | ||
| 6911 | } | 6988 | } |
| 6989 | + let palette_y_buf: Option<Vec<u16>> = palette_y | ||
| 6990 | + .as_ref() | ||
| 6991 | + .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect()); | ||
| 6992 | + let palette_uv_bufs: Option<(Vec<u16>, Vec<u16>)> = palette_uv.as_ref().map(|p| { | ||
| 6993 | + ( | ||
| 6994 | + p.map.iter().map(|&i| p.u_colors[i as usize]).collect(), | ||
| 6995 | + p.map.iter().map(|&i| p.v_colors[i as usize]).collect(), | ||
| 6996 | + ) | ||
| 6997 | + }); | ||
| 6998 | + let (pal_y_size, pal_y_colors) = | ||
| 6999 | + palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); | ||
| 7000 | + let (pal_uv_size, pal_uv_colors) = | ||
| 7001 | + palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | ||
| 7002 | + // The closing leaf of the pair -- see [`record_strip_palette`]. | ||
| 7003 | + let pal_last = if bw > bh { | ||
| 7004 | + leaf_mi.0 % 4 == 2 | ||
| 7005 | + } else { | ||
| 7006 | + leaf_mi.1 % 4 == 2 | ||
| 7007 | + }; | ||
| 6912 | if std::env::var_os("EC_AV1_RECTX_TRACE").is_some() { | 7008 | if std::env::var_os("EC_AV1_RECTX_TRACE").is_some() { |
| 6913 | eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}"); | 7009 | eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}"); |
| 6914 | } | 7010 | } |
| @@ -6967,11 +7063,12 @@ fn decode_leaf_rect( | |||
| 6967 | // the unsplit arm below passes the real neighbour answer -- chroma | 7063 | // the unsplit arm below passes the real neighbour answer -- chroma |
| 6968 | // of a tx-split 16x8/8x16 leaf lost its intra-edge filter type. | 7064 | // of a tx-split 16x8/8x16 leaf lost its intra-edge filter type. |
| 6969 | smooth_neighbor_uv, | 7065 | smooth_neighbor_uv, |
| 6970 | - // Both callers refuse a palette on this shape above (pixel | 7066 | + palette_y: palette_y_buf.clone(), |
| 6971 | - // reconstruction is unported here), so the split units carry none. | 7067 | + palette_uv: palette_uv_bufs.clone(), |
| 6972 | - palette_y: None, | ||
| 6973 | - palette_uv: None, | ||
| 6974 | }; | 7068 | }; |
| 7069 | + if palette_y.is_some() || palette_uv.is_some() { | ||
| 7070 | + PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | ||
| 7071 | + } | ||
| 6975 | decode_rect_split( | 7072 | decode_rect_split( |
| 6976 | dec, | 7073 | dec, |
| 6977 | cdfs, | 7074 | cdfs, |
| @@ -6988,6 +7085,10 @@ fn decode_leaf_rect( | |||
| 6988 | base_q_idx, | 7085 | base_q_idx, |
| 6989 | reduced_tx_set, | 7086 | reduced_tx_set, |
| 6990 | )?; | 7087 | )?; |
| 7088 | + record_strip_palette( | ||
| 7089 | + neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, | ||
| 7090 | + pal_last, | ||
| 7091 | + ); | ||
| 6991 | return Ok(mode); | 7092 | return Ok(mode); |
| 6992 | } | 7093 | } |
| 6993 | let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); | 7094 | let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); |
| @@ -6999,15 +7100,24 @@ fn decode_leaf_rect( | |||
| 6999 | luma_levels = vec![0i32; bw * bh]; | 7100 | luma_levels = vec![0i32; bw * bh]; |
| 7000 | u_levels = vec![0i32; chroma_w * chroma_h]; | 7101 | u_levels = vec![0i32; chroma_w * chroma_h]; |
| 7001 | v_levels = vec![0i32; chroma_w * chroma_h]; | 7102 | v_levels = vec![0i32; chroma_w * chroma_h]; |
| 7103 | + if let Some(b) = &palette_y_buf { | ||
| 7104 | + set_palette_pred(b.clone()); | ||
| 7105 | + } | ||
| 7002 | y.reconstruct_rect( | 7106 | y.reconstruct_rect( |
| 7003 | px, py, bw, bh, mode, angle_delta_y, reach, &luma_levels, None, filter_intra, | 7107 | px, py, bw, bh, mode, angle_delta_y, reach, &luma_levels, None, filter_intra, |
| 7004 | smooth_neighbor, | 7108 | smooth_neighbor, |
| 7005 | ); | 7109 | ); |
| 7006 | let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); | 7110 | let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); |
| 7111 | + if let Some((ub, _)) = &palette_uv_bufs { | ||
| 7112 | + set_palette_pred(ub.clone()); | ||
| 7113 | + } | ||
| 7007 | u.reconstruct_rect( | 7114 | u.reconstruct_rect( |
| 7008 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_levels, | 7115 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_levels, |
| 7009 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, | 7116 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, |
| 7010 | ); | 7117 | ); |
| 7118 | + if let Some((_, vb)) = &palette_uv_bufs { | ||
| 7119 | + set_palette_pred(vb.clone()); | ||
| 7120 | + } | ||
| 7011 | v.reconstruct_rect( | 7121 | v.reconstruct_rect( |
| 7012 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_levels, | 7122 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_levels, |
| 7013 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, | 7123 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, |
| @@ -7043,6 +7153,9 @@ fn decode_leaf_rect( | |||
| 7043 | &luma_levels, bw, bh, crate::decode::bit_depth(), | 7153 | &luma_levels, bw, bh, crate::decode::bit_depth(), |
| 7044 | CURRENT_Q_IDX.with(|c| c.get()), plane_q_delta(0).0, plane_q_delta(0).1, luma_tx_type, | 7154 | CURRENT_Q_IDX.with(|c| c.get()), plane_q_delta(0).0, plane_q_delta(0).1, luma_tx_type, |
| 7045 | ); | 7155 | ); |
| 7156 | + if let Some(b) = &palette_y_buf { | ||
| 7157 | + set_palette_pred(b.clone()); | ||
| 7158 | + } | ||
| 7046 | y.reconstruct_rect( | 7159 | y.reconstruct_rect( |
| 7047 | px, py, bw, bh, mode, angle_delta_y, reach, &luma_residual, None, filter_intra, | 7160 | px, py, bw, bh, mode, angle_delta_y, reach, &luma_residual, None, filter_intra, |
| 7048 | smooth_neighbor, | 7161 | smooth_neighbor, |
| @@ -7060,6 +7173,9 @@ fn decode_leaf_rect( | |||
| 7060 | &u_levels, chroma_w, chroma_h, crate::decode::bit_depth(), | 7173 | &u_levels, chroma_w, chroma_h, crate::decode::bit_depth(), |
| 7061 | CURRENT_Q_IDX.with(|c| c.get()), plane_q_delta(1).0, plane_q_delta(1).1, u_tx_type, | 7174 | CURRENT_Q_IDX.with(|c| c.get()), plane_q_delta(1).0, plane_q_delta(1).1, u_tx_type, |
| 7062 | ); | 7175 | ); |
| 7176 | + if let Some((ub, _)) = &palette_uv_bufs { | ||
| 7177 | + set_palette_pred(ub.clone()); | ||
| 7178 | + } | ||
| 7063 | u.reconstruct_rect( | 7179 | u.reconstruct_rect( |
| 7064 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_residual, | 7180 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_residual, |
| 7065 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, | 7181 | alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv, |
| @@ -7076,6 +7192,9 @@ fn decode_leaf_rect( | |||
| 7076 | &v_levels, chroma_w, chroma_h, crate::decode::bit_depth(), | 7192 | &v_levels, chroma_w, chroma_h, crate::decode::bit_depth(), |
| 7077 | CURRENT_Q_IDX.with(|c| c.get()), plane_q_delta(2).0, plane_q_delta(2).1, v_tx_type, | 7193 | CURRENT_Q_IDX.with(|c| c.get()), plane_q_delta(2).0, plane_q_delta(2).1, v_tx_type, |
| 7078 | ); | 7194 | ); |
| 7195 | + if let Some((_, vb)) = &palette_uv_bufs { | ||
| 7196 | + set_palette_pred(vb.clone()); | ||
| 7197 | + } | ||
| 7079 | v.reconstruct_rect( | 7198 | v.reconstruct_rect( |
| 7080 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_residual, | 7199 | cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_residual, |
| 7081 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, | 7200 | alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv, |
| @@ -7085,12 +7204,15 @@ fn decode_leaf_rect( | |||
| 7085 | neighbours.record_mi_rect(leaf_mi, bw, bh, &[luma_levels, u_levels, v_levels]); | 7204 | neighbours.record_mi_rect(leaf_mi, bw, bh, &[luma_levels, u_levels, v_levels]); |
| 7086 | neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip); | 7205 | neighbours.fill_skip_grid_rect(leaf_mi, mi_w, mi_h, skip); |
| 7087 | neighbours.fill_lf_grid_rect(leaf_mi, mi_w, mi_h, bw as u8, bh as u8, 0); | 7206 | neighbours.fill_lf_grid_rect(leaf_mi, mi_w, mi_h, bw as u8, bh as u8, 0); |
| 7088 | - // This leaf is necessarily non-palette (a palette one refused above), so | 7207 | + // The leaf's own palette state (`0` clears, as this site always did |
| 7089 | - // it must CLEAR the above/left palette state over its own span -- without | 7208 | + // while a palette leaf refused -- lane-palette2 r8), written on the SPLIT |
| 7090 | - // this the next block's `palette_y_mode` ctx and colour cache were read | 7209 | + // AXIS only until the pair's closing leaf: the coarse cell holds one |
| 7091 | - // off whatever block last covered the cell (lane-palette2 r8). | 7210 | + // entry for both leaves, and leaf 0 zeroing the LEFT one threw away the |
| 7092 | - neighbours.record_palette_y_rect(pal_at, bw, bh, 0, [0u16; 8]); | 7211 | + // real left neighbour leaf 1 reads (lane-kf900 r4). |
| 7093 | - neighbours.record_palette_uv_rect(pal_at, bw, bh, 0, [0u16; 8]); | 7212 | + record_strip_palette( |
| 7213 | + neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, | ||
| 7214 | + pal_last, | ||
| 7215 | + ); | ||
| 7094 | // A rect leaf spans mi_w x mi_h, so its mode reaches several columns and | 7216 | // A rect leaf spans mi_w x mi_h, so its mode reaches several columns and |
| 7095 | // rows -- record the whole span, not one cell. | 7217 | // rows -- record the whole span, not one cell. |
| 7096 | neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, mi_w, mi_h, mode); | 7218 | neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, mi_w, mi_h, mode); |
| @@ -7154,6 +7276,14 @@ fn decode_block_rect4( | |||
| 7154 | // 8-px strip of a `HORZ_4`/`VERT_4` onto one cell. | 7276 | // 8-px strip of a `HORZ_4`/`VERT_4` onto one cell. |
| 7155 | let (above_mode, left_mode) = | 7277 | let (above_mode, left_mode) = |
| 7156 | neighbours.modes_above_left_mi(mi_r, mi_c, (above_mode, left_mode)); | 7278 | neighbours.modes_above_left_mi(mi_r, mi_c, (above_mode, left_mode)); |
| 7279 | + // lane-kf900 r4: this strip's own palette-Y mode ctx and colour cache. | ||
| 7280 | + // Passing `None`/`&[]` read `palette_y_mode` off CDF row 0 and every | ||
| 7281 | + // `palette_colors_y` cache hit off an EMPTY cache -- right symbol count, | ||
| 7282 | + // wrong interval, so a screen-content tile desynced at the first strip | ||
| 7283 | + // whose neighbour used a palette (class [[cdf-row-held-constant]]). | ||
| 7284 | + let pal_at = (mi_r / (SUB / MI), mi_c / (SUB / MI)); | ||
| 7285 | + let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at, mi_r); | ||
| 7286 | + let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at, mi_r); | ||
| 7157 | let ( | 7287 | let ( |
| 7158 | skip, | 7288 | skip, |
| 7159 | mode, | 7289 | mode, |
| @@ -7176,21 +7306,35 @@ fn decode_block_rect4( | |||
| 7176 | enable_filter_intra, | 7306 | enable_filter_intra, |
| 7177 | neighbours.skip_txfm_ctx(mi_r, mi_c), | 7307 | neighbours.skip_txfm_ctx(mi_r, mi_c), |
| 7178 | allow_screen_content_tools, | 7308 | allow_screen_content_tools, |
| 7179 | - None, | 7309 | + Some((palette_ctx, &palette_cache)), |
| 7180 | - &[], | 7310 | + &palette_uv_cache, |
| 7181 | mi_r, | 7311 | mi_r, |
| 7182 | mi_c, | 7312 | mi_c, |
| 7183 | )?; | 7313 | )?; |
| 7184 | - // Merge of lane-palette2: `read_intra_mode_rect` now reads the palette | 7314 | + // lane-kf900 r4: palette prediction on this shape, exactly as |
| 7185 | - // syntax for every rect strip, but this 1:4 decoder has no palette | 7315 | + // [`decode_block_rect`] does one aspect ratio up -- the colour-index map |
| 7186 | - // reconstruction path (its caller never passes a cache). The symbols are | 7316 | + // mapped through the base colours IS the prediction (it reads no edge |
| 7187 | - // still read, so the stream stays in sync; a strip that ACTUALLY uses a | 7317 | + // pixels), handed to each `reconstruct_rect` through [`set_palette_pred`]. |
| 7188 | - // palette is refused rather than reconstructed wrong. | ||
| 7189 | if palette_y.is_some() || palette_uv.is_some() { | 7318 | if palette_y.is_some() || palette_uv.is_some() { |
| 7190 | - return Err(unsupported( | 7319 | + RECT4_PALETTE_HITS.with(|c| c.set(c.get() + 1)); |
| 7191 | - "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", | ||
| 7192 | - )); | ||
| 7193 | } | 7320 | } |
| 7321 | + let palette_y_buf: Option<Vec<u16>> = palette_y | ||
| 7322 | + .as_ref() | ||
| 7323 | + .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect()); | ||
| 7324 | + let palette_uv_bufs: Option<(Vec<u16>, Vec<u16>)> = palette_uv.as_ref().map(|p| { | ||
| 7325 | + ( | ||
| 7326 | + p.map.iter().map(|&i| p.u_colors[i as usize]).collect(), | ||
| 7327 | + p.map.iter().map(|&i| p.v_colors[i as usize]).collect(), | ||
| 7328 | + ) | ||
| 7329 | + }); | ||
| 7330 | + // `last`: strip 3 of the parent 32x32's HORZ_4 (VERT_4), the only one | ||
| 7331 | + // whose colours a block outside the parent sees -- see | ||
| 7332 | + // [`record_strip_palette`]. | ||
| 7333 | + let pal_last = if bw > bh { mi_r % 8 == 6 } else { mi_c % 8 == 6 }; | ||
| 7334 | + let (pal_y_size, pal_y_colors) = | ||
| 7335 | + palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); | ||
| 7336 | + let (pal_uv_size, pal_uv_colors) = | ||
| 7337 | + palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | ||
| 7194 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); | 7338 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 7195 | if smooth_neighbor { | 7339 | if smooth_neighbor { |
| 7196 | SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | 7340 | SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); |
| @@ -7250,11 +7394,12 @@ fn decode_block_rect4( | |||
| 7250 | filter_intra, | 7394 | filter_intra, |
| 7251 | smooth_neighbor, | 7395 | smooth_neighbor, |
| 7252 | smooth_neighbor_uv, | 7396 | smooth_neighbor_uv, |
| 7253 | - // Both callers refuse a palette on this shape above (pixel | 7397 | + palette_y: palette_y_buf.clone(), |
| 7254 | - // reconstruction is unported here), so the split units carry none. | 7398 | + palette_uv: palette_uv_bufs.clone(), |
| 7255 | - palette_y: None, | ||
| 7256 | - palette_uv: None, | ||
| 7257 | }; | 7399 | }; |
| 7400 | + if palette_y.is_some() || palette_uv.is_some() { | ||
| 7401 | + PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | ||
| 7402 | + } | ||
| 7258 | decode_rect_split( | 7403 | decode_rect_split( |
| 7259 | dec, | 7404 | dec, |
| 7260 | cdfs, | 7405 | cdfs, |
| @@ -7271,6 +7416,10 @@ fn decode_block_rect4( | |||
| 7271 | base_q_idx, | 7416 | base_q_idx, |
| 7272 | false, | 7417 | false, |
| 7273 | )?; | 7418 | )?; |
| 7419 | + record_strip_palette( | ||
| 7420 | + neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, | ||
| 7421 | + pal_uv_colors, pal_last, | ||
| 7422 | + ); | ||
| 7274 | if bw > bh { | 7423 | if bw > bh { |
| 7275 | RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | 7424 | RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); |
| 7276 | } else { | 7425 | } else { |
| @@ -7362,6 +7511,9 @@ fn decode_block_rect4( | |||
| 7362 | plane_q_delta(0).1, | 7511 | plane_q_delta(0).1, |
| 7363 | luma_tx_type, | 7512 | luma_tx_type, |
| 7364 | ); | 7513 | ); |
| 7514 | + if let Some(b) = &palette_y_buf { | ||
| 7515 | + set_palette_pred(b.clone()); | ||
| 7516 | + } | ||
| 7365 | y.reconstruct_rect( | 7517 | y.reconstruct_rect( |
| 7366 | px, | 7518 | px, |
| 7367 | py, | 7519 | py, |
| @@ -7390,6 +7542,9 @@ fn decode_block_rect4( | |||
| 7390 | plane_q_delta(plane).1, | 7542 | plane_q_delta(plane).1, |
| 7391 | tx_type, | 7543 | tx_type, |
| 7392 | ); | 7544 | ); |
| 7545 | + if let Some((ub, vb)) = &palette_uv_bufs { | ||
| 7546 | + set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }); | ||
| 7547 | + } | ||
| 7393 | buf.reconstruct_rect( | 7548 | buf.reconstruct_rect( |
| 7394 | cpx, | 7549 | cpx, |
| 7395 | cpy, | 7550 | cpy, |
| @@ -7414,6 +7569,10 @@ fn decode_block_rect4( | |||
| 7414 | ); | 7569 | ); |
| 7415 | neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip); | 7570 | neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip); |
| 7416 | neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0); | 7571 | neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0); |
| 7572 | + record_strip_palette( | ||
| 7573 | + neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, | ||
| 7574 | + pal_uv_colors, pal_last, | ||
| 7575 | + ); | ||
| 7417 | if bw > bh { | 7576 | if bw > bh { |
| 7418 | RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | 7577 | RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); |
| 7419 | } else { | 7578 | } else { |
| @@ -7421,6 +7580,9 @@ fn decode_block_rect4( | |||
| 7421 | } | 7580 | } |
| 7422 | return Ok((mode, uv_predict_mode)); | 7581 | return Ok((mode, uv_predict_mode)); |
| 7423 | }; | 7582 | }; |
| 7583 | + if let Some(b) = &palette_y_buf { | ||
| 7584 | + set_palette_pred(b.clone()); | ||
| 7585 | + } | ||
| 7424 | y.reconstruct_rect( | 7586 | y.reconstruct_rect( |
| 7425 | px, | 7587 | px, |
| 7426 | py, | 7588 | py, |
| @@ -7435,6 +7597,9 @@ fn decode_block_rect4( | |||
| 7435 | smooth_neighbor, | 7597 | smooth_neighbor, |
| 7436 | ); | 7598 | ); |
| 7437 | let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); | 7599 | let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); |
| 7600 | + if let Some((ub, _)) = &palette_uv_bufs { | ||
| 7601 | + set_palette_pred(ub.clone()); | ||
| 7602 | + } | ||
| 7438 | u.reconstruct_rect( | 7603 | u.reconstruct_rect( |
| 7439 | cpx, | 7604 | cpx, |
| 7440 | cpy, | 7605 | cpy, |
| @@ -7448,6 +7613,9 @@ fn decode_block_rect4( | |||
| 7448 | None, | 7613 | None, |
| 7449 | smooth_neighbor_uv, | 7614 | smooth_neighbor_uv, |
| 7450 | ); | 7615 | ); |
| 7616 | + if let Some((_, vb)) = &palette_uv_bufs { | ||
| 7617 | + set_palette_pred(vb.clone()); | ||
| 7618 | + } | ||
| 7451 | v.reconstruct_rect( | 7619 | v.reconstruct_rect( |
| 7452 | cpx, | 7620 | cpx, |
| 7453 | cpy, | 7621 | cpy, |
| @@ -7464,6 +7632,10 @@ fn decode_block_rect4( | |||
| 7464 | neighbours.record_mi_rect((mi_r, mi_c), bw, bh, &[luma_levels.to_vec(), u_levels, v_levels]); | 7632 | neighbours.record_mi_rect((mi_r, mi_c), bw, bh, &[luma_levels.to_vec(), u_levels, v_levels]); |
| 7465 | neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip); | 7633 | neighbours.fill_skip_grid_rect((mi_r, mi_c), mi_w, mi_h, skip); |
| 7466 | neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0); | 7634 | neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0); |
| 7635 | + record_strip_palette( | ||
| 7636 | + neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, | ||
| 7637 | + pal_last, | ||
| 7638 | + ); | ||
| 7467 | if bw > bh { | 7639 | if bw > bh { |
| 7468 | RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | 7640 | RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); |
| 7469 | } else { | 7641 | } else { |
| @@ -7543,6 +7715,12 @@ fn decode_rect4_16( | |||
| 7543 | } | 7715 | } |
| 7544 | let (above_mode, left_mode) = | 7716 | let (above_mode, left_mode) = |
| 7545 | neighbours.modes_above_left_mi(lmi.0, lmi.1, (above_mode, left_mode)); | 7717 | neighbours.modes_above_left_mi(lmi.0, lmi.1, (above_mode, left_mode)); |
| 7718 | + // lane-kf900 r4: the strip's real palette ctx + colour cache (see | ||
| 7719 | + // [`decode_block_rect4`]); `None`/`&[]` here read `palette_y_mode` | ||
| 7720 | + // off CDF row 0 and every cache hit off an empty cache. | ||
| 7721 | + let (palette_ctx, palette_cache) = | ||
| 7722 | + neighbours.palette_ctx_and_cache_mi(at16, lmi.0); | ||
| 7723 | + let palette_uv_cache = neighbours.palette_uv_cache_mi(at16, lmi.0); | ||
| 7546 | let ( | 7724 | let ( |
| 7547 | skip, | 7725 | skip, |
| 7548 | mode, | 7726 | mode, |
| @@ -7565,16 +7743,26 @@ fn decode_rect4_16( | |||
| 7565 | enable_filter_intra, | 7743 | enable_filter_intra, |
| 7566 | neighbours.skip_txfm_ctx(lmi.0, lmi.1), | 7744 | neighbours.skip_txfm_ctx(lmi.0, lmi.1), |
| 7567 | allow_screen_content_tools, | 7745 | allow_screen_content_tools, |
| 7568 | - None, | 7746 | + Some((palette_ctx, &palette_cache)), |
| 7569 | - &[], | 7747 | + &palette_uv_cache, |
| 7570 | lmi.0, | 7748 | lmi.0, |
| 7571 | lmi.1, | 7749 | lmi.1, |
| 7572 | )?; | 7750 | )?; |
| 7573 | if palette_y.is_some() || palette_uv.is_some() { | 7751 | if palette_y.is_some() || palette_uv.is_some() { |
| 7574 | - return Err(unsupported( | 7752 | + RECT4_PALETTE_HITS.with(|h| h.set(h.get() + 1)); |
| 7575 | - "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", | 7753 | + } |
| 7576 | - )); | 7754 | + // The colour-index map through the base colours IS the prediction. |
| 7577 | - } | 7755 | + // Chroma's map is the PAIR's 8x4 (4x8) block, matching the one |
| 7756 | + // chroma transform this closing strip codes. | ||
| 7757 | + let palette_y_buf: Option<Vec<u16>> = palette_y | ||
| 7758 | + .as_ref() | ||
| 7759 | + .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect()); | ||
| 7760 | + let palette_uv_bufs: Option<(Vec<u16>, Vec<u16>)> = palette_uv.as_ref().map(|p| { | ||
| 7761 | + ( | ||
| 7762 | + p.map.iter().map(|&i| p.u_colors[i as usize]).collect(), | ||
| 7763 | + p.map.iter().map(|&i| p.v_colors[i as usize]).collect(), | ||
| 7764 | + ) | ||
| 7765 | + }); | ||
| 7578 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); | 7766 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 7579 | if smooth_neighbor { | 7767 | if smooth_neighbor { |
| 7580 | SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1)); | 7768 | SMOOTH_LUMA_HITS.with(|h| h.set(h.get() + 1)); |
| @@ -7622,6 +7810,15 @@ fn decode_rect4_16( | |||
| 7622 | tx_h, | 7810 | tx_h, |
| 7623 | reach, | 7811 | reach, |
| 7624 | ); | 7812 | ); |
| 7813 | + if let Some(b) = &palette_y_buf { | ||
| 7814 | + let tu_buf: Vec<u16> = (0..tx_h) | ||
| 7815 | + .flat_map(|i| { | ||
| 7816 | + let base = (tu_row * tx_h + i) * bw + tu_col * tx_w; | ||
| 7817 | + b[base..base + tx_w].iter().copied() | ||
| 7818 | + }) | ||
| 7819 | + .collect(); | ||
| 7820 | + set_palette_pred(tu_buf); | ||
| 7821 | + } | ||
| 7625 | if skip { | 7822 | if skip { |
| 7626 | y.reconstruct_rect( | 7823 | y.reconstruct_rect( |
| 7627 | tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &zero_tu, | 7824 | tu_px, tu_py, tx_w, tx_h, mode, angle_delta_y, tu_reach, &zero_tu, |
| @@ -7705,6 +7902,9 @@ fn decode_rect4_16( | |||
| 7705 | } else { | 7902 | } else { |
| 7706 | let levels = if skip { | 7903 | let levels = if skip { |
| 7707 | let zeros = vec![0i32; bw * bh]; | 7904 | let zeros = vec![0i32; bw * bh]; |
| 7905 | + if let Some(b) = &palette_y_buf { | ||
| 7906 | + set_palette_pred(b.clone()); | ||
| 7907 | + } | ||
| 7708 | y.reconstruct_rect( | 7908 | y.reconstruct_rect( |
| 7709 | px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra, | 7909 | px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra, |
| 7710 | smooth_neighbor, | 7910 | smooth_neighbor, |
| @@ -7741,6 +7941,9 @@ fn decode_rect4_16( | |||
| 7741 | plane_q_delta(0).1, | 7941 | plane_q_delta(0).1, |
| 7742 | tx_type, | 7942 | tx_type, |
| 7743 | ); | 7943 | ); |
| 7944 | + if let Some(b) = &palette_y_buf { | ||
| 7945 | + set_palette_pred(b.clone()); | ||
| 7946 | + } | ||
| 7744 | y.reconstruct_rect( | 7947 | y.reconstruct_rect( |
| 7745 | px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra, | 7948 | px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra, |
| 7746 | smooth_neighbor, | 7949 | smooth_neighbor, |
| @@ -7801,6 +8004,9 @@ fn decode_rect4_16( | |||
| 7801 | CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | 8004 | CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); |
| 7802 | } | 8005 | } |
| 7803 | for (buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] { | 8006 | for (buf, plane) in [(&mut *u, 1usize), (&mut *v, 2)] { |
| 8007 | + if let Some((ub, vb)) = &palette_uv_bufs { | ||
| 8008 | + set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }); | ||
| 8009 | + } | ||
| 7804 | buf.reconstruct_rect( | 8010 | buf.reconstruct_rect( |
| 7805 | cpx, | 8011 | cpx, |
| 7806 | cpy, | 8012 | cpy, |
| @@ -7856,6 +8062,9 @@ fn decode_rect4_16( | |||
| 7856 | plane_q_delta(plane).1, | 8062 | plane_q_delta(plane).1, |
| 7857 | tx_type, | 8063 | tx_type, |
| 7858 | ); | 8064 | ); |
| 8065 | + if let Some((ub, vb)) = &palette_uv_bufs { | ||
| 8066 | + set_palette_pred(if plane == 1 { ub.clone() } else { vb.clone() }); | ||
| 8067 | + } | ||
| 7859 | buf.reconstruct_rect( | 8068 | buf.reconstruct_rect( |
| 7860 | cpx, | 8069 | cpx, |
| 7861 | cpy, | 8070 | cpy, |
| @@ -7906,6 +8115,14 @@ fn decode_rect4_16( | |||
| 7906 | } else { | 8115 | } else { |
| 7907 | RECT4_16_VERT_HITS.with(|h| h.set(h.get() + 1)); | 8116 | RECT4_16_VERT_HITS.with(|h| h.set(h.get() + 1)); |
| 7908 | } | 8117 | } |
| 8118 | + let (pal_y_size, pal_y_colors) = | ||
| 8119 | + palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); | ||
| 8120 | + let (pal_uv_size, pal_uv_colors) = | ||
| 8121 | + palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | ||
| 8122 | + record_strip_palette( | ||
| 8123 | + neighbours, at16, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, | ||
| 8124 | + i == 3, | ||
| 8125 | + ); | ||
| 7909 | last_mode = mode; | 8126 | last_mode = mode; |
| 7910 | prev = Some((lmi, mode)); | 8127 | prev = Some((lmi, mode)); |
| 7911 | } | 8128 | } |
crates/ec-av1/src/refusal_inventory.rsmodified+0 -2
| @@ -34,7 +34,6 @@ const REFUSALS: &[&str] = &[ | |||
| 34 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", | 34 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 35 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", | 35 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", |
| 36 | "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", | 36 | "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", |
| 37 | - "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", | ||
| 38 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", | 37 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 39 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", | 38 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 40 | "a 32x32 partition type this decoder does not code (value={part32})", | 39 | "a 32x32 partition type this decoder does not code (value={part32})", |
| @@ -45,7 +44,6 @@ const REFUSALS: &[&str] = &[ | |||
| 45 | "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)", | 44 | "a 128x128 superblock HORZ/VERT or AB partition (only SPLIT and NONE are decoded at the 128 root)", |
| 46 | "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)", | 45 | "a 128x128 superblock PARTITION_NONE root on an inter frame (only the key-frame path codes a whole 128x128 block)", |
| 47 | "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)", | 46 | "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)", |
| 48 | - "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)", | ||
| 49 | "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)", | 47 | "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)", |
| 50 | "a block that actually uses a palette (UV) -- reconstruction is out of scope", | 48 | "a block that actually uses a palette (UV) -- reconstruction is out of scope", |
| 51 | "a block that actually uses a palette (Y) -- reconstruction is out of scope", | 49 | "a block that actually uses a palette (Y) -- reconstruction is out of scope", |
crates/ec-av1/src/stream.rsmodified+205 -0
| @@ -2713,6 +2713,211 @@ mod tests { | |||
| 2713 | } | 2713 | } |
| 2714 | } | 2714 | } |
| 2715 | 2715 | ||
| 2716 | + /// lane-kf900 r4, the gate for the two lifted palette refusals ("a 1:4 | ||
| 2717 | + /// rect strip that actually uses a palette (reconstruction is not ported | ||
| 2718 | + /// at this shape)" and "a palette block on a HORZ/VERT intra strip below | ||
| 2719 | + /// 16x16 (reconstruction not ported)"): real `aomenc` streams that put a | ||
| 2720 | + /// palette on a RECT strip, decoded whole-frame pixel-exact against | ||
| 2721 | + /// ffmpeg's own decode of the identical bytes, at 8 AND 10 bit. | ||
| 2722 | + /// | ||
| 2723 | + /// Arm 0 is the stream lane-kf900 r3 pinned and stopped on -- `testsrc2` | ||
| 2724 | + /// 256x192, `--cq-level=59 --cpu-used=0 --min-partition-size=8 | ||
| 2725 | + /// --enable-rect-partitions=1 --enable-tx-size-search=1`, md5 | ||
| 2726 | + /// `e5f033d8fe34e4418d8cca3ac9d2b595` at 10 bit. Arms 1-2 force the shape | ||
| 2727 | + /// on screen-like content with `--tune-content=screen --enable-palette=1 | ||
| 2728 | + /// --enable-1to4-partitions=1`. | ||
| 2729 | + /// | ||
| 2730 | + /// An attempt whose decode never hit a rect-strip palette block proves | ||
| 2731 | + /// nothing about the lift, so it is counted OUT OF SCOPE rather than | ||
| 2732 | + /// silently passing -- but a mismatch on one is still a failure | ||
| 2733 | + /// (`out_of_scope_mismatch == 0`), and at least one attempt must fire the | ||
| 2734 | + /// counter or the gate is vacuous. | ||
| 2735 | + #[test] | ||
| 2736 | + fn a_real_aomenc_rect_strip_palette_decodes_pixel_exact() { | ||
| 2737 | + const NAME: &str = "a_real_aomenc_rect_strip_palette_decodes_pixel_exact"; | ||
| 2738 | + if !have_ffmpeg() { | ||
| 2739 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 2740 | + return; | ||
| 2741 | + } | ||
| 2742 | + if !have_aomenc() { | ||
| 2743 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 2744 | + return; | ||
| 2745 | + } | ||
| 2746 | + let (width, height) = (256usize, 192usize); | ||
| 2747 | + let screen: &[&str] = &[ | ||
| 2748 | + "--tune-content=screen", | ||
| 2749 | + "--enable-palette=1", | ||
| 2750 | + "--enable-1to4-partitions=1", | ||
| 2751 | + "--min-partition-size=8", | ||
| 2752 | + ]; | ||
| 2753 | + let arms: [(&str, String, &[&str]); 3] = [ | ||
| 2754 | + ("testsrc2-pinned", "testsrc2=s=256x192:r=25".to_string(), &[]), | ||
| 2755 | + ("testsrc2-screen", "testsrc2=s=256x192:r=25".to_string(), screen), | ||
| 2756 | + ("smptebars-screen", "smptebars=size=256x192:rate=25".to_string(), screen), | ||
| 2757 | + ]; | ||
| 2758 | + let (mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32, 0u32); | ||
| 2759 | + let mut refused = 0u32; | ||
| 2760 | + let mut fired_at_depth = [0u32; 2]; | ||
| 2761 | + let mut frames_compared = 0usize; | ||
| 2762 | + for (arm, src, extra) in &arms { | ||
| 2763 | + for depth in [8usize, 10] { | ||
| 2764 | + let pix_fmt = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 2765 | + let render = || { | ||
| 2766 | + let out = Command::new("ffmpeg") | ||
| 2767 | + .args([ | ||
| 2768 | + "-v", "error", "-f", "lavfi", "-i", src.as_str(), "-t", "0.2", | ||
| 2769 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 2770 | + ]) | ||
| 2771 | + .stdin(Stdio::null()) | ||
| 2772 | + .stdout(Stdio::piped()) | ||
| 2773 | + .stderr(Stdio::piped()) | ||
| 2774 | + .output() | ||
| 2775 | + .expect("ffmpeg failed to run"); | ||
| 2776 | + assert!(out.status.success(), "{NAME}: ffmpeg failed for {arm}"); | ||
| 2777 | + out.stdout | ||
| 2778 | + }; | ||
| 2779 | + let y4m_a = render(); | ||
| 2780 | + let y4m_b = render(); | ||
| 2781 | + assert_eq!( | ||
| 2782 | + y4m_a, y4m_b, | ||
| 2783 | + "{NAME}: {arm} must render byte-identical across two runs at {depth}-bit" | ||
| 2784 | + ); | ||
| 2785 | + let y4m = y4m_a; | ||
| 2786 | + let depth_arg = format!("--bit-depth={depth}"); | ||
| 2787 | + let in_depth_arg = format!("--input-bit-depth={depth}"); | ||
| 2788 | + let mut child = Command::new(aomenc_path()) | ||
| 2789 | + .args(["--codec=av1"]) | ||
| 2790 | + .args([&depth_arg, &in_depth_arg]) | ||
| 2791 | + .args([ | ||
| 2792 | + "--passes=1", | ||
| 2793 | + "--end-usage=q", | ||
| 2794 | + "--cq-level=59", | ||
| 2795 | + "--cpu-used=0", | ||
| 2796 | + "--lag-in-frames=0", | ||
| 2797 | + "--kf-max-dist=1", | ||
| 2798 | + "--limit=1", | ||
| 2799 | + "--threads=1", | ||
| 2800 | + "--tile-columns=0", | ||
| 2801 | + "--enable-tx-size-search=1", | ||
| 2802 | + "--min-partition-size=8", | ||
| 2803 | + "--enable-rect-partitions=1", | ||
| 2804 | + ]) | ||
| 2805 | + // Per-arm overrides go AFTER the base recipe: aomenc keeps | ||
| 2806 | + // the LAST occurrence of a repeated flag. | ||
| 2807 | + .args(*extra) | ||
| 2808 | + // The 8-bit twin of the pinned recipe picks a 128-root | ||
| 2809 | + // HORZ partition, which this decoder still refuses by name | ||
| 2810 | + // ("a 128x128 superblock HORZ/VERT or AB partition") -- | ||
| 2811 | + // an open refusal of another lane, unrelated to palette. | ||
| 2812 | + // Pinning the superblock to 64 keeps the 8-bit arm on the | ||
| 2813 | + // shape this gate is about; the 10-bit arms are the | ||
| 2814 | + // untouched pinned recipe. | ||
| 2815 | + .args(if depth == 8 { &["--sb-size=64"][..] } else { &[][..] }) | ||
| 2816 | + .args(["--obu", "-o", "-", "-"]) | ||
| 2817 | + .stdin(Stdio::piped()) | ||
| 2818 | + .stdout(Stdio::piped()) | ||
| 2819 | + .stderr(Stdio::piped()) | ||
| 2820 | + .spawn() | ||
| 2821 | + .expect("aomenc failed to start"); | ||
| 2822 | + child | ||
| 2823 | + .stdin | ||
| 2824 | + .take() | ||
| 2825 | + .expect("aomenc stdin") | ||
| 2826 | + .write_all(&y4m) | ||
| 2827 | + .or_else(|e| match e.kind() { | ||
| 2828 | + // aomenc rejecting the input closes the pipe before we | ||
| 2829 | + // finish writing; its own stderr below is the report. | ||
| 2830 | + std::io::ErrorKind::BrokenPipe => Ok(()), | ||
| 2831 | + _ => Err(e), | ||
| 2832 | + }) | ||
| 2833 | + .expect("writing y4m to aomenc"); | ||
| 2834 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 2835 | + assert!( | ||
| 2836 | + out.status.success(), | ||
| 2837 | + "{NAME}: aomenc refused {arm} at {depth}-bit: {}", | ||
| 2838 | + String::from_utf8_lossy(&out.stderr) | ||
| 2839 | + ); | ||
| 2840 | + let stream = out.stdout; | ||
| 2841 | + let before = decode::rect4_palette_hits(); | ||
| 2842 | + let frames = match decode_stream(&stream) { | ||
| 2843 | + Ok(frames) => frames, | ||
| 2844 | + // A NAMED refusal is another lane's open shape (here: a | ||
| 2845 | + // palette on an 8x8 SQUARE leaf, still out of scope), never | ||
| 2846 | + // a pass -- the attempt is counted out of scope and the | ||
| 2847 | + // per-depth firing assert below keeps the gate honest. | ||
| 2848 | + Err(e) if e.to_string().contains("unsupported") => { | ||
| 2849 | + eprintln!("{NAME}: {arm} {depth}-bit REFUSED: {e}"); | ||
| 2850 | + refused += 1; | ||
| 2851 | + continue; | ||
| 2852 | + } | ||
| 2853 | + Err(e) => panic!("{NAME}: decode failed on {arm} at {depth}-bit: {e}"), | ||
| 2854 | + }; | ||
| 2855 | + let fired = decode::rect4_palette_hits() - before; | ||
| 2856 | + let ffmpeg_frames = if depth == 10 { | ||
| 2857 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) | ||
| 2858 | + } else { | ||
| 2859 | + ffmpeg_decode_sequence(&stream, width, height, frames.len()) | ||
| 2860 | + }; | ||
| 2861 | + assert_eq!( | ||
| 2862 | + frames.len(), | ||
| 2863 | + ffmpeg_frames.len(), | ||
| 2864 | + "{NAME}: {arm} at {depth}-bit -- frame count" | ||
| 2865 | + ); | ||
| 2866 | + assert!(!frames.is_empty(), "{NAME}: {arm} at {depth}-bit decoded no frame"); | ||
| 2867 | + // EVERY decode-order frame, all three planes. | ||
| 2868 | + let mut exact = true; | ||
| 2869 | + for (i, (ours, theirs)) in frames.iter().zip(ffmpeg_frames.iter()).enumerate() { | ||
| 2870 | + if ours.y != theirs.y || ours.u != theirs.u || ours.v != theirs.v { | ||
| 2871 | + exact = false; | ||
| 2872 | + eprintln!("{NAME}: {arm} {depth}-bit frame {i} differs"); | ||
| 2873 | + } | ||
| 2874 | + frames_compared += 1; | ||
| 2875 | + } | ||
| 2876 | + if fired > 0 { | ||
| 2877 | + fired_arms += 1; | ||
| 2878 | + fired_at_depth[usize::from(depth == 10)] += 1; | ||
| 2879 | + assert!( | ||
| 2880 | + exact, | ||
| 2881 | + "{NAME}: {arm} at {depth}-bit has {fired} rect-strip palette block(s) \ | ||
| 2882 | + and does NOT decode pixel-exact" | ||
| 2883 | + ); | ||
| 2884 | + } else { | ||
| 2885 | + out_of_scope += 1; | ||
| 2886 | + if !exact { | ||
| 2887 | + out_of_scope_mismatch += 1; | ||
| 2888 | + } | ||
| 2889 | + } | ||
| 2890 | + } | ||
| 2891 | + } | ||
| 2892 | + eprintln!( | ||
| 2893 | + "{NAME}: {fired_arms} attempt(s) with a rect-strip palette block, \ | ||
| 2894 | + {out_of_scope} out of scope ({out_of_scope_mismatch} mismatched), \ | ||
| 2895 | + {refused} refused, {frames_compared} frames compared, \ | ||
| 2896 | + fired 8-bit={} 10-bit={}", | ||
| 2897 | + fired_at_depth[0], fired_at_depth[1] | ||
| 2898 | + ); | ||
| 2899 | + // MEASURED 2026-09-02, every 8-bit attempt of these recipes: aomenc | ||
| 2900 | + // puts its palettes on SQUARE blocks at 8 bit and every 8-bit stream | ||
| 2901 | + // that reaches a rect strip with one lands on a palette shape still | ||
| 2902 | + // out of scope (8x8 square leaf, or a 64x32/32x64 superblock strip | ||
| 2903 | + // with a real transform). So the 8-bit arms here prove the DECODE | ||
| 2904 | + // path, not the lift -- `fired_at_depth[0] == 0` is a known, reported | ||
| 2905 | + // coverage gap and not a silent pass: the counter is printed. | ||
| 2906 | + assert!( | ||
| 2907 | + fired_at_depth[1] > 0, | ||
| 2908 | + "{NAME}: no attempt put a palette on a rect strip \ | ||
| 2909 | + (8-bit={}, 10-bit={}) -- gate is vacuous", | ||
| 2910 | + fired_at_depth[0], | ||
| 2911 | + fired_at_depth[1] | ||
| 2912 | + ); | ||
| 2913 | + assert!(fired_arms > 0, "{NAME}: gate is vacuous"); | ||
| 2914 | + assert_eq!( | ||
| 2915 | + out_of_scope_mismatch, 0, | ||
| 2916 | + "{NAME}: {out_of_scope_mismatch} attempt(s) without a rect-strip palette block \ | ||
| 2917 | + still mismatched -- an unrelated defect, not a SKIP" | ||
| 2918 | + ); | ||
| 2919 | + } | ||
| 2920 | + | ||
| 2716 | /// lane-hbd r5: a real `aomenc --bit-depth=10` stream, decoded through | 2921 | /// lane-hbd r5: a real `aomenc --bit-depth=10` stream, decoded through |
| 2717 | /// this crate's own 10-bit planes (`Picture` widened to `u16` in an | 2922 | /// this crate's own 10-bit planes (`Picture` widened to `u16` in an |
| 2718 | /// earlier round) and checked pixel-exact against ffmpeg's own decode of | 2923 | /// earlier round) and checked pixel-exact against ffmpeg's own decode of |
lanes/kf900-r4.report.mdadded+70 -0
| @@ -0,0 +1,70 @@ | |||
| 1 | +# lane-kf900 r4 report -- rect-strip palette reconstruction | ||
| 2 | + | ||
| 3 | +## What changed (all in `crates/ec-av1/`) | ||
| 4 | + | ||
| 5 | +| path:line (post-change) | why | | ||
| 6 | +| --- | --- | | ||
| 7 | +| `src/decode.rs` `Neighbours::palette_ctx_and_cache_mi` / `palette_uv_cache_mi` | `av1_get_palette_cache` drops the above neighbour on a 64-px SB boundary keyed on the block's own PIXEL row (`pred_common.c:76`). The old code read `at.0 % 4` off the 16-px `SUB` cell, so strip 1 of a HORZ_4 (8 px into the cell) wrongly excluded strip 0 from its cache in every SB-top cell row. Old entry points kept, delegating. | | ||
| 8 | +| `src/decode.rs` `read_intra_mode_rect`, chroma colour-index map | the map is `av1_get_plane_block_size(bsize,1,1)` (`ss_size_lookup`), not a plain halving: BLOCK_16X4 -> BLOCK_8X4, BLOCK_4X16 -> BLOCK_4X8. `(bw/2, bh/2)` read HALF the colour-index symbols of a 1:4 strip's chroma palette. Now `((bw/2).max(4), (bh/2).max(4))`. | | ||
| 9 | +| `src/decode.rs` `record_strip_palette` (new) | the coarse `SUB`-cell palette arrays alias all four strips of a HORZ_4/VERT_4 (and both leaves of a 16x8/8x16 pair) onto one entry, so stamping BOTH axes after every strip hands strip i+1 strip i's colours on the WRONG axis too. Writes the split axis until the closing strip, both on it. | | ||
| 10 | +| `src/decode.rs` `decode_block_rect4` (32x8/8x32) | was `palette: None, &[]` -> real ctx + cache; palette-Y/UV prediction wired into the split-tx walk (`RectStripModes`), the coded arm and the skip arm; palette state stamped on all three exits. Refusal dropped. | | ||
| 11 | +| `src/decode.rs` `decode_rect4_16` (16x4/4x16) | same, per strip, incl. the inlined per-TU split walk (window of the block's palette buffer per unit) and the pair's chroma. Refusal dropped. | | ||
| 12 | +| `src/decode.rs` `decode_leaf_rect` (16x8/8x16) | sibling refusal "a palette block on a HORZ/VERT intra strip below 16x16" dropped the same way; its zero-clear of the palette arrays became `record_strip_palette`, which also fixes leaf 0 of a pair zeroing the LEFT entry leaf 1 legitimately reads. | | ||
| 13 | +| `src/decode.rs` `RECT4_PALETTE_HITS` / `rect4_palette_hits()` | the gate's counter: rect intra strips that ACTUALLY use a palette. | | ||
| 14 | +| `src/refusal_inventory.rs` | both lifted strings removed (47 -> 45). | | ||
| 15 | +| `src/stream.rs` `a_real_aomenc_rect_strip_palette_decodes_pixel_exact` | the gate. | | ||
| 16 | + | ||
| 17 | +libaom sites cited: `decodemv.c` `read_palette_mode_info` (`av1_allow_palette`, `av1_get_palette_bsize_ctx`, `av1_get_palette_mode_ctx`), `read_palette_colors_y` (`decodemv.c:478`) / `read_palette_colors_uv` (`:509`), `pred_common.c:73` `av1_get_palette_cache`, `decodeframe.c` `decode_color_map_tokens` via `av1_visit_palette` (map read AFTER all mode info -- unchanged, already correct here). | ||
| 18 | + | ||
| 19 | +## Refusals lifted (2) | ||
| 20 | + | ||
| 21 | +1. `a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)` | ||
| 22 | +2. `a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)` | ||
| 23 | + | ||
| 24 | +## Gate | ||
| 25 | + | ||
| 26 | +`crates/ec-av1/src/stream.rs::a_real_aomenc_rect_strip_palette_decodes_pixel_exact` | ||
| 27 | +3 arms x 2 depths. Arm 0 IS the r3 pinned stream: `testsrc2=s=256x192:r=25`, `--cq-level=59 | ||
| 28 | +--cpu-used=0 --lag-in-frames=0 --kf-max-dist=1 --limit=1 --threads=1 --tile-columns=0 | ||
| 29 | +--enable-tx-size-search=1 --min-partition-size=8 --enable-rect-partitions=1`, and the encoder | ||
| 30 | +invocation inside the test reproduces md5 `e5f033d8fe34e4418d8cca3ac9d2b595` byte for byte at | ||
| 31 | +10-bit. Arms 1-2 add `--tune-content=screen --enable-palette=1 --enable-1to4-partitions=1 | ||
| 32 | +--min-partition-size=8` on testsrc2 / smptebars. Every decode-order frame, all three planes, | ||
| 33 | +compared against ffmpeg's decode of the identical bytes. Hard asserts: a rect-strip palette | ||
| 34 | +block fired (`rect4_palette_hits()` delta), `out_of_scope_mismatch == 0`, sources render | ||
| 35 | +byte-identical twice. A NAMED (`unsupported`) refusal is counted and printed, never a pass. | ||
| 36 | + | ||
| 37 | +``` | ||
| 38 | +cargo test -p ec-av1 --lib a_real_aomenc_rect_strip_palette_decodes_pixel_exact -- --nocapture | ||
| 39 | +``` | ||
| 40 | + | ||
| 41 | +EVIDENCE: $HOME/.cache/kf900/sweep/g.obu + gate stdout | aomenc pinned recipe -> decode_stream -> ffmpeg compare, 3 arms x {8,10} bit | 2 attempts with a rect-strip palette block, both whole-frame pixel-exact (Y+U+V), 0 out-of-scope mismatches, 4 named refusals on other shapes, md5 of the test's own 10-bit arm-0 stream == e5f033d8fe34e4418d8cca3ac9d2b595 | ||
| 42 | +EVIDENCE: decode_probe on $HOME/.cache/kf900/sweep/g.obu | before/after this commit | `REFUSED: ... a 1:4 rect strip that actually uses a palette` -> `OK: 1 frames decoded, 256x192`, rect4_32 horz=8 vert=0 -> horz=12 vert=16 | ||
| 43 | + | ||
| 44 | +## Corrected premises (both stated as fact in the charter/handoff) | ||
| 45 | + | ||
| 46 | +- **`skip_split_tx` does NOT fire on the pinned stream.** `decode_probe` on the fully decoded | ||
| 47 | + stream prints `skip_split_tx: 0`. The r3 handoff's "fires skip_split_tx AND reaches that | ||
| 48 | + refusal" is half wrong, so the gate asserts the palette counter and does not assert | ||
| 49 | + `skip_split_tx`; asserting it would have been a vacuous/failing gate. | ||
| 50 | +- **64x16/16x64 needed no work.** `decode_block_rect64` already passes the real ctx/cache and | ||
| 51 | + reconstructs palette; its only palette refusal is the separate corner-cropped-luma one. | ||
| 52 | + | ||
| 53 | +## Open residue | ||
| 54 | + | ||
| 55 | +- **deferred(8-bit rect-strip palette coverage)** -- `fired 8-bit=0, 10-bit=2`. At 8 bit aomenc | ||
| 56 | + puts its palettes on SQUARE blocks; every 8-bit recipe tried that reaches a rect strip with a | ||
| 57 | + palette lands on a shape still out of scope (`a block that actually uses a palette (Y)` on an | ||
| 58 | + 8x8 square leaf, or `a palette block with a real transform on a superblock-level HORZ/VERT | ||
| 59 | + strip`). Unblocked by lifting either of those two refusals. The 8-bit arms still run and prove | ||
| 60 | + the decode path; the counter is printed, not hidden. | ||
| 61 | +- **fix-now-elsewhere: a NEW pre-existing 8-bit 1:4 pixel mismatch, unrelated to palette.** | ||
| 62 | + Recipe: `testsrc2=s=256x192:r=25`, 8-bit, base recipe above plus | ||
| 63 | + `--tune-content=screen --enable-palette=1 --enable-1to4-partitions=1 --max-partition-size=32 | ||
| 64 | + --sb-size=64`. Decodes `OK: 1 frames decoded` with `rect4_32: horz=8 vert=8 coded=16` and | ||
| 65 | + frame 0 differs from ffmpeg. Proved unrelated to this round: the stream reads ZERO palette | ||
| 66 | + symbols (`EC_AV1_TRACE=1 decode_probe | grep -c "^EC_PAL "` == 0), so every change in this | ||
| 67 | + commit is inert on it. Needs its own lane. | ||
| 68 | +- **accepted**: `a palette block with a real transform on a superblock-level HORZ/VERT strip` | ||
| 69 | + and `a block that actually uses a palette (Y/UV)` (8x8 square leaf) remain -- out of this | ||
| 70 | + lane's charter (both are square/SB-level, not rect strips). | ||