From cdef95e4dce15d5998da5f97c1dbf8cdedc94a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 4 Sep 2026 13:50:58 +0300 Subject: [PATCH] feat(av1): reconstruct palette blocks on 8x8 leaves inside inter frames `decode_inter_block8`'s intra arm read `palette_y_mode`/`palette_uv_mode` off hardcoded CDF row 0 and refused the moment either said "yes". It now reads the whole `read_palette_mode_info` syntax with this leaf's REAL `av1_get_palette_mode_ctx` and colour cache, decodes both colour-index maps after the mode info (`av1_visit_palette`) and predicts from them through the existing PALETTE_PRED slot, per transform unit when the leaf's `tx_depth` splits -- the same shape the >=16 intra-in-inter block already ran. A palette block on an 8x8 leaf also made a pre-existing hole in the palette neighbour bands reachable: a sub-8x8 group published nothing, so the row's `left_palette_size` kept an earlier 8x8 palette block's size and `av1_get_palette_mode_ctx` read 1 where libaom gathers 0 (decode-order frame 1, mi(30,30): palette size decoded as 8 instead of 2). All three sub-8x8 tails now publish the all-zero state, as does `decode_inter_block8`'s own compound early return (class early-return-skips-tail). New rung `EC_PALPUB=1` prints every publication into those bands, which is what named the gap. Gate `a_screen_stream_with_palette_8x8_leaves_in_inter_frames_decodes_pixel_exact`: 15 frames pixel-exact on every plane vs ffmpeg, 25 palette-Y and 12 palette-UV 8x8 leaves inside inter frames -- exactly the 25 `bsize=BLOCK_8X8 palette_size>0` blocks aomdec's `EC_PALSYN` counts past the key frame. The `(UV)` refusal string is gone from the decoder entirely (this leaf was its only site); the `(Y)` one survives only as the defensive `palette.is_none()` guard no caller can reach. --- .../fixtures/palette_screen_leaf8_witness.obu | Bin 0 -> 10364 bytes crates/ec-av1/src/decode.rs | 28 +++++++++ crates/ec-av1/src/refusal_inventory.rs | 15 ++--- crates/ec-av1/src/stream.rs | 57 ++++++++++++++++++ 4 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 crates/ec-av1/fixtures/palette_screen_leaf8_witness.obu diff --git a/crates/ec-av1/fixtures/palette_screen_leaf8_witness.obu b/crates/ec-av1/fixtures/palette_screen_leaf8_witness.obu new file mode 100644 index 0000000000000000000000000000000000000000..f2cc7a75ea6ebef9479d4fccb6891d30c592d188 GIT binary patch literal 10364 zcmXw*gI^sE!1Zr+Z@Afu%eCySmTlX%-7=QlvTnvr%eHOX=F+P5etysMynn+v=leZa z05CED0D$X$fBCov1hQA7;sD5m001%ofNYcVl2TfVn)zCU%0ivP#9~kR1n+V7!$N{P zf9zMSxZS@J*~>^GqKucqGYVwKXJo`C1ZRhE);}jkPaEXrbba)#zi?|HJ6{Pn)LF3; zfXj!wxHYQ(v`eW!@f05@3r=5$(pn_rUcdA*ypot5!P7LOkg$f~+speo%B@YP6V*P; zzsCQGrYcckb{r~{5TtkQDXaYEyGHm2SUEcdL#g^9>q3K5!#gPQHn)u#&L zb2!25yK>-*Pyt^2{uixVq=QZb4dB$+;fIg^l5&yuYJic-3~#%@$wu^LGE!+1bG*+J z?6q4LZ^jI-3qp78G}i4QdUKkqi!mWP5%X#2%(!gsKrNFQQsk$t&KEM>{DUQ)M7JkR z{xA!R=R8i_)bX{6nq?(knLxFsxseXlWNYvvmLzJPCE;-8EBEp77mCAfeNlSQM?~~8 zA>0P7oT4OMbda!%8_R`%qZXn=1WHcGqmUZ%0<1EwDgiKL)hP>hMPu+p<+;g^dKM>{ zcV>U6T_qrXd=v=rKcX1$DXRN9FKS1$563GM&o$I>{)*yd9MbMKWH|D|Cg9~VK@)sr zC_rJjw!2_nB5XVPo^840FSm5{cp1>2IHENYbvnzhps58CSSK;k;m$R+9pv!bq+s@E z1=C?n42}49zV0^_6D1pE<7oOgHp?`K9V`x<8XPTsVNswfE39tM_QC7G@Bx9WRfGPyP;>h36uCo-b6-gd!z5njtpms<^oR=rJCbi*2Par zKwg$U7b;oM46mnw_&5<RCV4U0D1LLO1@q#-Lyy*Y_JyL}31=+cQ&w>*v2&2MK-O zn=uPxS2lM-1$deA|0a|XcEcT;Z-xD>t7T*b`6=_a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7igru5HT=c;D-rsc}S*dDKIb27uGqXXXIiKMCn_GUJmETp?isGB9UhH64`cVKM9az}u zQDKVUl{tsje!=QlX?iJ= BLOCK_8X8`), so the group always clears. + record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]); let round_up_even = |n: usize| n.div_ceil(2) * 2; let bound_h = round_up_even(neighbours.mi_rows); let bound_w = round_up_even(neighbours.mi_cols); @@ -25053,6 +25062,16 @@ fn decode_intra_sub8_leaf( neighbours.above_uv_mode[c] = uv_predict_mode; neighbours.left_uv_mode[r] = uv_predict_mode; neighbours.record_uv_mode_mi(gr, gc, 2, 2, uv_predict_mode); + // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map + // needs EVERY writer): a sub-8x8 group published no palette state, so + // once an 8x8 leaf of the same row can BE a palette block, the group + // left the row's band holding that earlier block's size and the next + // intra block read `av1_get_palette_mode_ctx` one too high (measured: + // mi(30,30) of decode-order frame 1, ours ctx 1 where libaom gathers + // 0). No sub-8x8 piece can itself be a palette (`av1_allow_palette` + // needs `bsize >= BLOCK_8X8`), so the group always clears. + record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]); + let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); let (u_grid, v_grid): (Vec, Vec) = if skip { if alpha.is_some() { @@ -25653,6 +25672,15 @@ fn decode_inter_sub8_rect2( (ug, vg) }; neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED); + // lane-t900 r23 (class [[new-map-ignores-tile-edge]]: a neighbour map + // needs EVERY writer): a sub-8x8 group published no palette state, so + // once an 8x8 leaf of the same row can BE a palette block, the group + // left the row's band holding that earlier block's size and the next + // intra block read `av1_get_palette_mode_ctx` one too high (measured: + // mi(30,30) of decode-order frame 1, ours ctx 1 where libaom gathers + // 0). No sub-8x8 piece can itself be a palette (`av1_allow_palette` + // needs `bsize >= BLOCK_8X8`), so the group always clears. + record_strip_palette(neighbours, (gr, gc), 8, 8, 0, [0u16; 8], 0, [0u16; 8]); let round_up_even = |n: usize| n.div_ceil(2) * 2; let bound_h = round_up_even(neighbours.mi_rows); let bound_w = round_up_even(neighbours.mi_cols); diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index 2b65970f..93b7ded5 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -46,13 +46,14 @@ const REFUSALS: &[&str] = &[ "CfL, filter intra or a palette on a 128-root HORZ/VERT intra block (every one of their size gates caps at 64x64 or below, so none of these symbols exists there)", "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)", "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)", - // lane-t900 r22: palette RECONSTRUCTION landed for the key-frame paths - // (earlier lanes) and for the intra-in-inter square and rect paths (this - // one). These two strings survive at exactly two kinds of site: the - // `palette.is_none()` guards in `read_intra_mode`/`read_intra_mode_rect` - // (defensive -- every caller now passes a real ctx/cache pair), and the - // sub-8x8 `decode_inter_block8` leaf, which has no witness stream. - "a block that actually uses a palette (UV) -- reconstruction is out of scope", + // lane-t900 r23: palette RECONSTRUCTION now covers the key-frame paths + // (earlier lanes), the intra-in-inter square/rect paths (r22) and the + // 8x8 LEAF inside an inter frame (this round, gate + // `a_screen_stream_with_palette_8x8_leaves_in_inter_frames_decodes_pixel_exact`), + // which is why the (UV) string is gone from the decoder entirely -- the + // leaf was its only site. The (Y) one survives ONLY as the defensive + // `palette.is_none()` guard in `read_intra_mode`/`read_intra_mode_rect`; + // every caller now passes a real ctx/cache pair, so no stream reaches it. "a block that actually uses a palette (Y) -- reconstruction is out of scope", "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 150ff8e0..03d7cfa2 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -31012,6 +31012,63 @@ mod tests { } } + /// lane-t900 r23 GATE for the two LIFTED refusals `"a block that actually + /// uses a palette (Y)/(UV) -- reconstruction is out of scope"` at their + /// 8x8-LEAF site ([`crate::decode`]'s `decode_inter_block8` intra arm): + /// a palette block on an 8x8 intra leaf inside an inter frame. + /// + /// Recipe (`fixtures/palette_screen_leaf8_witness.obu`): 256x192, 15 + /// frames, a static two-level 16x16 screen background with a 96x96 patch + /// of hashed 4x4 colour cells that moves non-periodically (so no + /// reference holds it and the encoder codes it INTRA inside the inter + /// frames), `aomenc --tune-content=screen --enable-palette=1 + /// --enable-intrabc=0 --sb-size=64 --cq-level=20 --cpu-used=1 + /// --lag-in-frames=0 --kf-max-dist=9999 --max-partition-size=8` -- the + /// partition cap is what puts the palette on BLOCK_8X8 rather than on the + /// 16x16/16x8 blocks r22's recipe produced. `EC_PALSYN=1` on aomdec + /// counts 25 `bsize=BLOCK_8X8 palette_size>0` blocks past the key frame. + /// + /// What it caught beyond the refusal itself: a sub-8x8 group publishes no + /// palette state, so it left the row's `left_palette_size` band holding an + /// earlier 8x8 palette block's size and `av1_get_palette_mode_ctx` read 1 + /// where libaom gathers 0 (decode-order frame 1, mi(30,30), palette size + /// decoded as 8 instead of 2) -- class `new-map-ignores-tile-edge`, fixed + /// at all three sub-8x8 tails. + #[test] + fn a_screen_stream_with_palette_8x8_leaves_in_inter_frames_decodes_pixel_exact() { + const NAME: &str = + "a_screen_stream_with_palette_8x8_leaves_in_inter_frames_decodes_pixel_exact"; + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("fixtures/palette_screen_leaf8_witness.obu"); + let stream = std::fs::read(&path) + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); + let before = inter8_palette_hits(); + let frames = match decode_stream(&stream) { + Ok(frames) => frames, + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), + }; + let after = inter8_palette_hits(); + let (fired_y, fired_uv) = (after.0 - before.0, after.1 - before.1); + assert!( + fired_y > 0, + "{NAME}: no palette block on an 8x8 leaf inside an inter frame \ + -- the gate is vacuous for the site whose refusal it pins" + ); + assert_eq!(frames.len(), 15, "{NAME}: 15 shown frames"); + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 256, 192, frames.len()); + assert_eq!(ffmpeg_frames.len(), frames.len(), "{NAME}: frame count"); + for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg"); + assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg"); + assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg"); + } + eprintln!("{NAME}: 15 frames pixel-exact; 8x8-leaf palette y={fired_y} uv={fired_uv}"); + } + /// lane-t900 r22 GATE for the LIFTED refusal `"a HORZ/VERT intra strip in /// a screen-content frame (palette syntax is consumed for square blocks /// only)"` on its 16x4/4x16 arm: that arm routes through