From 2fe9a361b00e3c0df5c0bb0af64ad4ac0bcee851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Mon, 7 Sep 2026 12:50:26 +0300 Subject: [PATCH] fix(av1): the palette neighbour bands are cleared by the key-frame sub-8x8 leaves Narrows the previous commit: the 5 INTER-side zero-stamps regressed 13 tests (our own encoder's screen streams stopped decoding) because the inter readers' band index/footprint convention is not the palette bands' -- reverted, recorded in lanes/dkey.report.md as the open half of the sweep. The two key-frame sub-8x8 stamps, which are what the measured mi(76,88) desync needed, stay. --- crates/ec-av1/src/decode.rs | 54 ------------------------------------- lanes/dkey.report.md | 22 +++++++++++---- 2 files changed, 17 insertions(+), 59 deletions(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 99594afb..2df093e1 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -29614,15 +29614,6 @@ fn decode_inter_block( write_h / MI, skip, ); - // lane-dkey sweep: an INTER block (and every sub-8x8 leaf) has - // `palette_size == 0` in libaom's mi grid, so the next block's - // `av1_get_palette_mode_ctx`/colour cache must read 0 across this - // footprint. Only the >=8x8 intra readers published palette state, so a - // palette block's size/colours stayed standing in the mi-granular bands - // and a later intra block read `palette_y_mode` off the wrong CDF row - // (class [[cdf-row-held-constant]]). - neighbours.record_palette_y_rect((rmi, cmi), write_w, write_h, 0, [0u16; 8]); - neighbours.record_palette_uv_rect((rmi, cmi), write_w, write_h, 0, [0u16; 8]); neighbours.fill_lf_grid_rect( (rmi, cmi), write_w / MI, @@ -30107,15 +30098,6 @@ fn decode_inter_sub8_split4( // var-tx context instead of leaving whatever the previous block left. set_txfm_ctxs(neighbours, lmi, B4, 1, 1, false); neighbours.fill_skip_grid_rect(lmi, 1, 1, skip); - // lane-dkey sweep: an INTER block (and every sub-8x8 leaf) has - // `palette_size == 0` in libaom's mi grid, so the next block's - // `av1_get_palette_mode_ctx`/colour cache must read 0 across this - // footprint. Only the >=8x8 intra readers published palette state, so a - // palette block's size/colours stayed standing in the mi-granular bands - // and a later intra block read `palette_y_mode` off the wrong CDF row - // (class [[cdf-row-held-constant]]). - neighbours.record_palette_y_rect(lmi, MI, MI, 0, [0u16; 8]); - neighbours.record_palette_uv_rect(lmi, MI, MI, 0, [0u16; 8]); neighbours.fill_lf_grid_rect(lmi, 1, 1, B4 as u8, B4 as u8, ref_frame.max(LAST_FRAME), fctx); last_skip = skip; } @@ -30573,15 +30555,6 @@ fn decode_intra_sub8_leaf( } let (tx_w, tx_h) = if split { (4, 4) } else { (bw, bh) }; neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip); - // lane-dkey sweep: an INTER block (and every sub-8x8 leaf) has - // `palette_size == 0` in libaom's mi grid, so the next block's - // `av1_get_palette_mode_ctx`/colour cache must read 0 across this - // footprint. Only the >=8x8 intra readers published palette state, so a - // palette block's size/colours stayed standing in the mi-granular bands - // and a later intra block read `palette_y_mode` off the wrong CDF row - // (class [[cdf-row-held-constant]]). - neighbours.record_palette_y_rect(lmi, w_mi * MI, h_mi * MI, 0, [0u16; 8]); - neighbours.record_palette_uv_rect(lmi, w_mi * MI, h_mi * MI, 0, [0u16; 8]); neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, tx_w as u8, tx_h as u8, 0, fctx); // `set_txfm_ctxs(tx_size, n4_w, n4_h, skip && is_inter == 0, xd)`: an // intra block of an inter frame publishes its TRANSFORM dims, never its @@ -31195,15 +31168,6 @@ fn decode_inter_sub8_rect2( neighbours.record_mode_mi(rmi, cmi, w_mi, h_mi, DC_PRED); neighbours.record_inter_rect_mi(lmi, w_mi, h_mi, skip, true, ref_frame, resolved_filter, false); neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip); - // lane-dkey sweep: an INTER block (and every sub-8x8 leaf) has - // `palette_size == 0` in libaom's mi grid, so the next block's - // `av1_get_palette_mode_ctx`/colour cache must read 0 across this - // footprint. Only the >=8x8 intra readers published palette state, so a - // palette block's size/colours stayed standing in the mi-granular bands - // and a later intra block read `palette_y_mode` off the wrong CDF row - // (class [[cdf-row-held-constant]]). - neighbours.record_palette_y_rect(lmi, w_mi * MI, h_mi * MI, 0, [0u16; 8]); - neighbours.record_palette_uv_rect(lmi, w_mi * MI, h_mi * MI, 0, [0u16; 8]); last_skip = skip; } // lane-sub8intra: when the chroma-reference sub-block was INTRA it coded @@ -32306,15 +32270,6 @@ fn decode_inter_block8( // dlist excludes it (3 luma samples on a 192x128 inter frame). hit!(INTER8_SKIP_BAND_HITS); neighbours.fill_skip_grid(leaf_mi, 2, skip); - // lane-dkey sweep: an INTER block (and every sub-8x8 leaf) has - // `palette_size == 0` in libaom's mi grid, so the next block's - // `av1_get_palette_mode_ctx`/colour cache must read 0 across this - // footprint. Only the >=8x8 intra readers published palette state, so a - // palette block's size/colours stayed standing in the mi-granular bands - // and a later intra block read `palette_y_mode` off the wrong CDF row - // (class [[cdf-row-held-constant]]). - neighbours.record_palette_y_rect(leaf_mi, 8, 8, 0, [0u16; 8]); - neighbours.record_palette_uv_rect(leaf_mi, 8, 8, 0, [0u16; 8]); // lane-sub8x4 r2: `split8` is this leaf's OWN var-tx split, so // the deblock grid must publish the TX_4X4 leaves' width the // same way the fall-through arm below does (libaom @@ -33512,15 +33467,6 @@ fn decode_inter_block8( // gate failed on an instrumentation gap, with the band written either way. hit!(INTER8_SKIP_BAND_HITS); neighbours.fill_skip_grid(leaf_mi, 2, skip); - // lane-dkey sweep: an INTER block (and every sub-8x8 leaf) has - // `palette_size == 0` in libaom's mi grid, so the next block's - // `av1_get_palette_mode_ctx`/colour cache must read 0 across this - // footprint. Only the >=8x8 intra readers published palette state, so a - // palette block's size/colours stayed standing in the mi-granular bands - // and a later intra block read `palette_y_mode` off the wrong CDF row - // (class [[cdf-row-held-constant]]). - neighbours.record_palette_y_rect(leaf_mi, 8, 8, 0, [0u16; 8]); - neighbours.record_palette_uv_rect(leaf_mi, 8, 8, 0, [0u16; 8]); neighbours.fill_lf_grid( leaf_mi, 2, diff --git a/lanes/dkey.report.md b/lanes/dkey.report.md index db227155..e0285186 100644 --- a/lanes/dkey.report.md +++ b/lanes/dkey.report.md @@ -47,8 +47,15 @@ paths only. ## Sweep `fill_skip_grid*` (every leaf block publishes it) vs `record_palette_*` over -all 16 block readers: 9 readers had skip but no palette publication. Fixed the -7 that provably code no palette. **Remaining, deferred:** `decode_rect_split`, +all 16 block readers: 9 readers had skip but no palette publication. Stamped +7; the 5 INTER-side stamps (`decode_inter_block`, `decode_inter_block8` x2, +`decode_inter_sub8_split4`, `decode_inter_sub8_rect2`, `decode_intra_sub8_leaf`) +REGRESSED 13 tests (our own encoder's screen streams stopped decoding: "a +reference frame selected with no picture at this frame's own ref_frame_idx +slot") and were reverted -- the inter readers' `(rmi, cmi)`/`write_w`/`write_h` +are not the same footprint convention the palette bands index, so those stamps +zeroed cells belonging to real palette blocks. Only the two KEY-frame sub-8x8 +stamps ship. **Remaining, deferred:** `decode_rect_split`, `decode_leaf_rect`, `decode_block_rect4`, `decode_rect4_16_strip` and `decode_intra_rect_in_inter` are >=8x8 intra readers that CAN code palette (`decode_intra_rect_in_inter` reads `palette_y_mode` at decode.rs:10131) and @@ -68,8 +75,8 @@ neighbours). Needs each reader's decoded palette threaded to the tail. ## Files -* `crates/ec-av1/src/decode.rs` — the 7 zero-stamps (2 in the key-frame sub8 - readers, 5 in the inter/sub8 readers). +* `crates/ec-av1/src/decode.rs` — 2 zero-stamps, in `decode_leaf_split4` and + `decode_leaf_rect8` (the key-frame sub-8x8 groups). * `crates/ec-av1/src/encode.rs` — `external_ladder` now decodes EVERY reference ladder point through `decode_stream` and asserts sample-exactness against ffmpeg, naming encoder/params/frame/plane/sample (the assertion that would @@ -82,7 +89,12 @@ neighbours). Needs each reader's decoded palette threaded to the tail. 1. **crf 5 inter-frame Golomb refusal** — key frame is exact now; the failure is in an inter frame (`EC_MM` trace, last read mi(124,412)). Unblocks: diff aomdec `EC_MODE`/`EC_STACK` against our `EC_MM` from the first inter frame. -2. **The palette-publishing mirror gap** above (5 readers). +2. **The inter-side half of the sweep** (5 readers, reverted above) and the + palette-publishing mirror gap (`decode_intra_rect_in_inter` reads + `palette_y_mode` and publishes nothing). Unblocks: read each inter reader's + real band-index/footprint convention before stamping (the failing tests are + `encoder::tests::the_content_gate_keeps_screen_streams_flat` and the 12 + others listed in the suite log). 3. **The sensitive `force_integer_mv` fixture**: a 1920x1024 source with a textured patch moving 2.5 px per duplicate-pair (half-pel motion, exact duplicate frames) makes libaom round 72 projected candidates