forge
Explore
Log in

Don't you dare go Hollow

A non-skip palette block on a superblock-level strip lost its UV prediction

Browse files at this commit

3a302e703f7738b15b5f64e3fef7f951620187e2Ahmet Kaan GümüşParent: c4ca926
  • fix
    • a non-skip palette block on a superblock-level strip lost its UV prediction
Show full message
fix(av1): a non-skip palette block on a superblock-level strip lost its UV prediction

`decode_block_rect64` built the UV-palette prediction buffers and
installed them into the PALETTE_PRED slot only in its `skip` arm. The
non-skip arm reconstructed both chroma planes straight from
`reconstruct_rect`'s edge prediction, so a palette block with a real
residual on a 64x32/32x64 strip decoded its luma exactly and both
chroma planes wrong -- which is why the shape was refused by name
("corner-cropped luma coefficients not ported for palette", a
misattribution: the corner crop was never the defect).

FIRST BAD: testsrc2 128x128 10-bit cq55 `--tune-content=screen
--enable-palette=1 --min-partition-size=8 --sb-size=64 --tile-columns=1
--enable-tx-size-search=0`, the 32x64 strip at px=96: luma byte-exact,
U/V each 512 samples wrong over the block's 16x32 chroma footprint.
Installing the per-plane override right before each chroma
`reconstruct_rect`, exactly as the `skip` arm does, makes the frame
byte-exact against ffmpeg.

Class: an override slot installed on one arm of a skip/non-skip split.
Swept every palette+residual reconstruct path in decode.rs (rect, rect4,
rect_split, leaf_rect, leaf8, block, inter_block, inter_block8): this
was the only site missing the install.

The gate that documented the refusal now asserts zero refusals and a
non-zero superblock-strip palette count; inventory row deleted.
crates/ec-av1/src/decode.rsmodified+17 -17
@@ -10416,24 +10416,11 @@ fn decode_block_rect64(
1041610416 c * (SUB / MI), fctx,
1041710417 )?;
1041810418 if (palette_y.is_some() || palette_uv.is_some()) && !skip {
10419- // The luma coefficient path here is the corner-cropped 32x32 real
10420- // transform embedded in a 64x32/32x64 grid ([`decode_block_rect64`]'s
10421- // own doc comment) -- a real (non-skip) palette block's residual
10422- // needs the plain, uncropped rect reader [`decode_block_rect`] already
10423- // has, not this one's truncation. `skip` (no residual at all) is
10424- // still supported below (lane-palette2 r4).
10425- //
10426- // lane-pal8 r1 MEASURED the lift and it is NOT free: dropping this
10427- // refusal decodes `testsrc2` 128x128 10-bit cq55 `--enable-palette=1
10428- // --min-partition-size=8 --tile-columns=1` with a whole-frame pixel
10429- // mismatch (the arm the gate below counts). Something in this shape's
10430- // palette prediction or its corner-cropped residual is wrong, and the
10431- // refusal stays until that is found -- it is counted, never skipped.
10419+ // lane-t900 r34: a non-skip palette block on a superblock-level strip
10420+ // -- counted so its gate cannot go vacuous (this was a refusal until
10421+ // r34; see the gate `a_real_aomenc_palette_stream_with_8x8_leaves_
10422+ // decodes_pixel_exact`).
1043210423 PALETTE_SB_STRIP_HITS.with(|c| c.set(c.get() + 1));
10433- return Err(unsupported(
10434- "a palette block with a real transform on a superblock-level HORZ/VERT \
10435- strip (corner-cropped luma coefficients not ported for palette)",
10436- ));
1043710424 }
1043810425 let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode);
1043910426 if smooth_neighbor {
@@ -10817,6 +10804,16 @@ fn decode_block_rect64(
1081710804 plane_q_delta(1, fctx).1,
1081810805 u_tx_type,
1081910806 );
10807+ // lane-t900 r34: the UV-palette prediction override, exactly as the
10808+ // `skip` arm above installs it. The [`PALETTE_PRED`] slot is a
10809+ // set-then-take, so it must be filled again right before each plane's
10810+ // own reconstruct; leaving this out of the non-skip arm predicted a
10811+ // palette block's chroma off its block edges (measured: testsrc2
10812+ // 128x128 10-bit cq55 `--tile-columns=1`, the 32x64 strip at px=96 --
10813+ // luma exact, both chroma planes wrong over its whole 16x32).
10814+ if let Some((ub, _)) = &palette_uv_bufs {
10815+ set_palette_pred(ub.clone(), fctx);
10816+ }
1082010817 u.reconstruct_rect(
1082110818 cpx,
1082210819 cpy,
@@ -10871,6 +10868,9 @@ fn decode_block_rect64(
1087110868 plane_q_delta(2, fctx).1,
1087210869 v_tx_type,
1087310870 );
10871+ if let Some((_, vb)) = &palette_uv_bufs {
10872+ set_palette_pred(vb.clone(), fctx);
10873+ }
1087410874 v.reconstruct_rect(
1087510875 cpx,
1087610876 cpy,
crates/ec-av1/src/refusal_inventory.rsmodified+0 -11
@@ -43,7 +43,6 @@ const REFUSALS: &[&str] = &[
4343 "a 128x128 superblock partition value outside the 8-symbol alphabet",
4444 "an inter var-tx tree with a leaf transform larger than 64x64",
4545 "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)",
46- "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",
4746 // lane-t900 r23: palette RECONSTRUCTION now covers the key-frame paths
4847 // (earlier lanes), the intra-in-inter square/rect paths (r22) and the
4948 // 8x8 LEAF inside an inter frame (this round, gate
@@ -371,16 +370,6 @@ const PROVEN: &[(&str, &str)] = &[
371370 "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)",
372371 "no_128_root_half_reads_a_cfl_filter_intra_or_palette_symbol",
373372 ),
374- // lane-t900 r33, WITNESS of a capability gap: the refusal is REACHED by
375- // real `--tune-content=screen --enable-palette=1` streams, counted
376- // (`palette_sb_strip_hits`) and hard-asserted non-zero by its gate, which
377- // also decodes the arms that do not reach it pixel-exact. lane-pal8 r1
378- // measured the lift and it mismatches whole-frame, so the string names a
379- // real shape a real encoder writes -- an open capability, not a claim.
380- (
381- "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",
382- "a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact",
383- ),
384373 // lane-t900 r33, CENSUS: the `use_intrabc` symbol IS read at the sub-8
385374 // reader for every sub-8x8 leaf of an `allow_intrabc` frame, and over the
386375 // `--min-partition-size=4` exact-repetition screen arms every such symbol
crates/ec-av1/src/stream.rsmodified+9 -5
@@ -4141,8 +4141,8 @@ mod tests {
41414141 (0usize, 0u32, 0u32, 0usize);
41424142 let (mut out_of_scope, mut out_of_scope_mismatch, mut refusals) = (0u32, 0u32, 0u32);
41434143 let (mut sb_strip_total, mut sb_strip_arms) = (0usize, 0u32);
4144- // The one palette shape this round did NOT lift (measured: lifting it
4145- // mismatches -- see [`decode_block_rect64`]'s own comment).
4144+ // lane-t900 r34 LIFTED this shape; the counter stays so the gate
4145+ // fails loudly if the refusal ever comes back.
41464146 let mut sb_strip_refusals = 0u32;
41474147 for src in ["testsrc2", "smptebars"] {
41484148 for depth in [8usize, 10usize] {
@@ -4322,10 +4322,14 @@ mod tests {
43224322 leaf8_total > 0 && fired_arms > 0,
43234323 "{NAME}: gate is vacuous -- no compared arm decoded an 8x8-leaf palette block"
43244324 );
4325+ assert_eq!(
4326+ sb_strip_refusals, 0,
4327+ "{NAME}: the superblock-strip palette refusal is back (lane-t900 r34 lifted it)"
4328+ );
43254329 assert!(
4326- sb_strip_refusals > 0,
4327- "{NAME}: no arm reached the superblock-strip palette refusal -- the open residue \
4328- this gate documents is no longer exercised"
4330+ sb_strip_arms > 0 && sb_strip_total > 0,
4331+ "{NAME}: no arm decoded a non-skip palette block on a superblock-level strip -- \
4332+ the shape r34 lifted is no longer exercised"
43294333 );
43304334 assert_eq!(
43314335 out_of_scope_mismatch, 0,