From 6a16223660f0b67160f83e1be35e86348e466a4b 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:34:20 +0300 Subject: [PATCH] feat(av1): reconstruct palette blocks inside inter frames, and fix the palette colour-index CDF counter reset An intra block in an inter frame refused by name the moment it actually used a palette ("reconstruction is out of scope"), at both the square (`decode_inter_block`) and the rect (`decode_intra_rect_in_inter`) path. Both now read the real syntax -- mode/size/colours off this block's own `av1_get_palette_mode_ctx` context and `av1_get_palette_cache` colour cache, the two colour-index maps deferred past `filter_intra` exactly as `av1_visit_palette` runs them -- and predict from the map (per transform unit where the luma transform splits), the same machinery the key-frame paths use. Every block of an inter frame now also stamps its palette state (all-zero for an inter block) into the mi-granular neighbour bands, which is what libaom's mode-info grid holds and what the next block's cache and mode context read. The witness then desynced at the FIRST inter-frame palette block's colour index map, third symbol: the two palette colour-index tables are this decoder's only variable-alphabet CDFs (the reader takes `[..=n]` of a `[u16; 9]` row, so `update_cdf`'s symbol counter lives at index `n`), and `Cdfs::reset_counts` zeroed the array's last slot instead. Every colour-index row therefore crossed a frame boundary with a saturated count and adapted at rate 6 where libaom, counting from zero, adapts at 4 (class cdf-counter-not-reset). Swept: those two are the only `[..=n]` readers here. Also lifted, as a stale premise: the 16x4/4x16 arm of "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)" -- that arm routes through `decode_rect4_16_strip`, which takes `allow_screen_content_tools` and reads the whole palette syntax already. The 128-root arm keeps the refusal (its body reads none, and no --sb-size=128 screen witness exists). Gates (aomenc --tune-content=screen --enable-palette=1 --enable-intrabc=0 --sb-size=64, 15 frames, key + inter, 8-bit and 10-bit twins): a_real_aomenc_screen_stream_with_palette_blocks_decodes_pixel_exact and a_screen_stream_with_16x4_intra_strips_in_inter_frames_decodes_pixel_exact -- all 15 frames byte-exact vs ffmpeg on every plane, with inter-frame palette counters y/uv > 0 so neither gate is vacuous. --- crates/ec-av1/examples/decode_probe.rs | 2 + .../palette_screen_strip16_witness_10bit.obu | Bin 0 -> 6542 bytes .../fixtures/palette_screen_witness.obu | Bin 0 -> 1655 bytes .../fixtures/palette_screen_witness_10bit.obu | Bin 0 -> 7763 bytes crates/ec-av1/src/cdf_state.rs | 27 +++- crates/ec-av1/src/decode.rs | 37 +++--- crates/ec-av1/src/refusal_inventory.rs | 16 ++- crates/ec-av1/src/stream.rs | 124 ++++++++++++++++++ 8 files changed, 184 insertions(+), 22 deletions(-) create mode 100644 crates/ec-av1/fixtures/palette_screen_strip16_witness_10bit.obu create mode 100644 crates/ec-av1/fixtures/palette_screen_witness.obu create mode 100644 crates/ec-av1/fixtures/palette_screen_witness_10bit.obu diff --git a/crates/ec-av1/examples/decode_probe.rs b/crates/ec-av1/examples/decode_probe.rs index 7646c773..0b71457a 100644 --- a/crates/ec-av1/examples/decode_probe.rs +++ b/crates/ec-av1/examples/decode_probe.rs @@ -34,6 +34,8 @@ fn main() { let (h, v, c) = ec_av1::stream::rect4_32_counters(); println!("rect4_32: horz={h} vert={v} coded={c}"); println!("rect_intrabc_reads: {}", ec_av1::stream::rect_intrabc_reads()); + let (pal_y, pal_uv) = ec_av1::stream::intra_in_inter_palette_hits(); + println!("intra_in_inter_palette: y={pal_y} uv={pal_uv}"); println!( "rect64_corner_tu: 64x32={} 32x64={}", ec_av1::stream::rect64_corner_tu_hits(0), diff --git a/crates/ec-av1/fixtures/palette_screen_strip16_witness_10bit.obu b/crates/ec-av1/fixtures/palette_screen_strip16_witness_10bit.obu new file mode 100644 index 0000000000000000000000000000000000000000..2827d67ca4390b2ef4224fc8e37fcf9ad1f4be70 GIT binary patch literal 6542 zcmZ9Pg;E>}ux$r-8{7v77JMK`aCdhnI0PrSyGwAF1PKIp3-0djIzVt6{MLE(&Z%4X z7j~~+-5Ur%MFRi;a9yvD?>B*g;0RPa07wS_0097?Wp}x4l%K9@tkV;t6{lt~5pbA) zO*7mU^I3_ufJ}&c_nesOrB2o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yp3=qn$w3<*WqJ?ImkKv48_B4N?djF>`krVHl{PVo&KZOSZ4&<0PWj z4r1LgA&EU#LxSI=N9sL)%woy)>Lm~WPJ;!bo5G7f{YxDY3;^plNwqW_O5Ug&X<8F? zDwU9PNae~1%8?^I@JpTmB!|wE_*$GL`D&wVrMj$4K%LY;K$0 zqs3T}Mbg2}d8tpC6glY%yK;q0gXdlF8+F3j`-VJLP7!7EWdsIxkC7a+J7GWX$BaD0 zh5y%#DEVuUC2g_(S2H3%OH4Xe=TE<{3%eRW81^+`8pu?i!R&9}ub0|I>AR6V^(|8* z&i9RDk3A`JLLCAwC_BmF6n`s*4tjPV z#p~%>W!sm&Wh>K z#+QdE(*E&3r1-5diWRKEV(RQb05}p3jA@O$K=Ut8|42T@jW3}Z=eyhP2QEWN6SC<>bNovBECTB}Zd>#%QGDy{{xowYDfS8 literal 0 HcmV?d00001 diff --git a/crates/ec-av1/fixtures/palette_screen_witness.obu b/crates/ec-av1/fixtures/palette_screen_witness.obu new file mode 100644 index 0000000000000000000000000000000000000000..31a9ce085191022395825dc1e818e9f4df00603d GIT binary patch literal 1655 zcmYk*e>~H99Ki9f8Ro|^GmYD6vLoczef`Rh^J_ZQI%Jh&#mr;8JU)-l8v*F(0sx@iwzROK z0+^sw9SN8_0f0FG0KGfAPbzs#(wyq$l1-`;InAPORzJTbLGv<1RntEt!Fn~Z8R;(PWgUEqIF=HDhN9%ibV(h zNM)4o85o+!!!8$_G~8t>9Qju7h_|$U;iW?TgJ^k>7Z)I_jS9Q+{&cw?s3^@Bn`#S8wR4Myx^ zJJ&tN)IOcqi7Gq%6+x=pu?z0auGQ|Xp@xfo9^;l?El&@)^&AydpQhnh&Q}EQoSMJ0 zuvy%-&v6!wbjbA#w#hns-o@-SIUQSGoyXPT`Au7N9D6%`RV_&n;Y2|@{U%S-os;<9 zY&)#A*^B$+8u`BVxMoeK_(ZCy{V#?i+_QFFk7U;|dl5}0MLZm>Dqa@bm#Ji6(D^3_ zHtd7*ILs5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ec-av1/fixtures/palette_screen_witness_10bit.obu b/crates/ec-av1/fixtures/palette_screen_witness_10bit.obu new file mode 100644 index 0000000000000000000000000000000000000000..2aa19feedbbb009d627d14b89b854edad04eeb29 GIT binary patch literal 7763 zcmYM1RZtv?vPB1Xg1cLA8JxkL1PufYF2P*}cM0ynT?PrR!QGuOSa5;`8Qghw?zy+# zcUS*(_3FJE4}gvV000nrULM}Af`WiYhy(x{T>yXv007Ksj8+O8$q%|p3oDeF3k;+s zC@>uU5nJ4v3>xJ?`}UzT5Ub31yGA0=0k5TUYrygE+(^RI9P8Be#$)p5>glp*MF_m% zX*0556KVR3HReRRdPU@|F0rBz`_kWX9M-(BQhm|7n2Z*@k3Tg8GJm`yTpwD>sS<*_ zq+bHjND*kRxvrx}MHhS{l&V4gY|4wHJwvi}M>U`Ejl|#RJBP2|8bPGX#OSWtN2ncX zyiOJN;@8VS?`_`(4U{%{3H~||C7+O^Dc_B!MoOc)*OjqNz1(3I`J(&`~; zw5decKhyyX)^le#Cg#rhAfr=_r5F;#Kwq6nv3VdK$<6E1Ny5AV#eF(-JThyqQouZx zAHfBKCU}CI1<&$+gW;ocL1b;SQ7(m)fvB9*lmtBZ%jMv(zL>ld0V5{k&H@&rv@<^2m10=;ui`EZ+*dBk}HzHboyzJD5+1%z)Qce zPWvwezq3S-hl9;YSXtgpj+#D5X)31#9LZ}^?Sm|Qdr%6wK6Bdg$P%sl zWjq+$ox#&5Qv4Y>p-xaQw4`=z;>TUnG})M!S-ieNI@#j)cDe`bv9p}hjGd2i+@BBU zg6uRtxww5>OhU#)HY3`Qu9?L!C*7fVG@51Wujvm9!D#)ifluCNm(-vYxh&Nl%A~B5 zY{Vw`qYyqZRq-B9h&4G{DTQH3{M-;I``x^nlobHKZ1Bjtmw&8TCA6UM+0+YHmTh^m z@b?Z^OAAiMff_7@B{P+FCGj~3g7_pLM0tdFm`=W5t_*VF51ApOte&vusrs|=c} zVHYH#0=gsbl;N(QC*P=CA2d9K82*}~aR<*l(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s +++ b/crates/ec-av1/src/cdf_state.rs @@ -759,6 +759,19 @@ fn reset3(a: &mut [[[u16; N]; M] a.iter_mut().for_each(reset2); } +/// [`reset3`] for a table whose ALPHABET grows with its first index: the +/// palette colour-index CDFs are `[u16; 9]` rows read as `[..=n]` with +/// `n = idx + 2`, so their symbol counter sits at index `n`, not `N - 1`. +fn reset_var_alphabet( + a: &mut [[[u16; N]; M]; K], +) { + for (idx, rows) in a.iter_mut().enumerate() { + for row in rows.iter_mut() { + row[idx + 2] = 0; + } + } +} + impl MvComponentCdfs { fn reset_counts(&mut self) { reset1(&mut self.class); @@ -926,8 +939,18 @@ impl Cdfs { reset2(&mut self.palette_y_size); reset2(&mut self.palette_uv_mode); reset2(&mut self.palette_uv_size); - reset3(&mut self.palette_y_color_index); - reset3(&mut self.palette_uv_color_index); + // lane-t900 r22 (class cdf-counter-not-reset): the two colour-index + // tables are the only VARIABLE-ALPHABET ones here -- the reader takes + // `[..=n]` of a `[u16; 9]` row, so `update_cdf`'s symbol counter lives + // at index `n` (= table index + 2), not at the array's last entry. + // `reset3` zeroed slot 8, which no `n < 8` row ever uses, so every + // palette colour-index row crossed a frame boundary with a SATURATED + // count (32) and adapted at rate 6 where libaom, counting from 0, + // adapts at rate 4: the first inter-frame palette block's map desynced + // at its third colour-index symbol (witness `palette_screen_witness.obu`, + // decode-order frame 3, mi(40,0), Y map (0,2)). + reset_var_alphabet(&mut self.palette_y_color_index); + reset_var_alphabet(&mut self.palette_uv_color_index); reset1(&mut self.intrabc); reset1(&mut self.restore_wiener); reset1(&mut self.restore_sgrproj); diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 82f9af02..acb22df1 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -6710,7 +6710,12 @@ fn decode_color_index_map_wh( let (ctx, color_order) = palette_color_index_context(&map, bw, row, col, n); if trace { let (rng, _) = dec.debug_state(); - eprintln!("EC_PAL row={row} col={col} ctx={ctx} n={n} rng={rng}"); + let row_cdf = if uv { + &cdfs.palette_uv_color_index[n - 2][ctx] + } else { + &cdfs.palette_y_color_index[n - 2][ctx] + }; + eprintln!("EC_PAL row={row} col={col} ctx={ctx} n={n} cdf0={} cnt={} rng={rng}", row_cdf[0], row_cdf[n]); } let symbol = if uv { dec.symbol(&mut cdfs.palette_uv_color_index[n - 2][ctx][..=n]) @@ -6922,7 +6927,7 @@ fn read_intra_mode_rect( if use_palette_y { if palette.is_none() { return Err(unsupported( - "a block that actually uses a palette (Y@rect) -- reconstruction is out of scope", + "a block that actually uses a palette (Y) -- reconstruction is out of scope", )); } let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]); @@ -7733,12 +7738,13 @@ fn decode_intra_rect_in_inter( // [`INTRA_IN_INTER_MODE`] switches to `read_intra_block_mode_info`'s // `y_mode[0]` plus the `skip` this caller already read. if let Some((horz, has_chroma)) = strip16 { - if allow_screen_content_tools { - return Err(unsupported( - "a HORZ/VERT intra strip in a screen-content frame (palette syntax \ - is consumed for square blocks only)", - )); - } + // lane-t900 r22: the screen-content refusal here was STALE (class + // stale-premise): [`decode_rect4_16_strip`] takes + // `allow_screen_content_tools` and reads the whole palette syntax + // (mode/size/colours/colour-index map, its own `palette_ctx_and_cache_mi` + // pair) -- the key frame proves that body. Lifted with the 10-bit + // witness `palette_screen_witness_10bit.obu`, whose inter frames carry + // 16x4/4x16 intra strips inside a `--tune-content=screen` frame. debug_assert_eq!((bw, bh), if horz { (16, 4) } else { (4, 16) }); INTRA_IN_INTER_MODE.with(|c| c.set(Some((0, skip)))); let res = decode_rect4_16_strip( @@ -8088,9 +8094,6 @@ fn decode_intra_rect_in_inter( PALETTE_HITS.with(|c| c.set(c.get() + 1)); PALETTE_RECT_HITS.with(|c| c.set(c.get() + 1)); INTRA_IN_INTER_PALETTE_Y_HITS.with(|c| c.set(c.get() + 1)); - if crate::envflags::env_flag!("EC_PALII") { - eprintln!("EC_PALII yrect mi={mi_r},{mi_c} bw={bw} bh={bh} n={n} skip={skip}"); - } PaletteY { size: n, colors, map } }); let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { @@ -10891,7 +10894,7 @@ fn read_intra_mode( if use_palette_y { if palette.is_none() { return Err(unsupported( - "a block that actually uses a palette (Y@square) -- reconstruction is out of scope", + "a block that actually uses a palette (Y) -- reconstruction is out of scope", )); } let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]); @@ -23470,6 +23473,9 @@ fn decode_inter_block( let n = 2 + dec.symbol(&mut cdfs.palette_y_size[bsize_ctx]); palette_y_pending = Some((n, read_palette_colors_y(dec, n, &palette_cache))); } + if crate::envflags::env_flag!("EC_PALSYN") { + eprintln!("EC_PALSYN_PRE sq mi={rmi},{cmi} bw={write_w} bh={write_h} mode={mode} uv={uv_mode} ctx={palette_ctx} y={} rng={}", palette_y_pending.map_or(0, |(n, _)| n), dec.debug_state().0); + } let use_palette_uv = uv_mode == DC_PRED && dec.symbol(&mut cdfs.palette_uv_mode[usize::from(use_palette_y)]) != 0; if crate::envflags::env_flag!("EC_PALSYN") { @@ -23510,9 +23516,6 @@ fn decode_inter_block( let map = decode_color_index_map_wh(dec, cdfs, n, write_w, write_h, false); PALETTE_HITS.with(|c| c.set(c.get() + 1)); INTRA_IN_INTER_PALETTE_Y_HITS.with(|c| c.set(c.get() + 1)); - if crate::envflags::env_flag!("EC_PALII") { - eprintln!("EC_PALII y mi={rmi},{cmi} bw={write_w} bh={write_h} n={n} skip={skip}"); - } PaletteY { size: n, colors, map } }); let palette_uv = palette_uv_pending.map(|(n, u_colors, v_colors)| { @@ -27204,7 +27207,7 @@ fn decode_inter_block8( if allow_screen_content_tools { if mode == DC_PRED && dec.symbol(&mut cdfs.palette_y_mode[0][0]) != 0 { return Err(unsupported( - "a block that actually uses a palette (Y@inter_block8) -- reconstruction is out of scope", + "a block that actually uses a palette (Y) -- reconstruction is out of scope", )); } // lane-uv8 r1: `read_palette_mode_info` reads the UV symbol only @@ -27212,7 +27215,7 @@ fn decode_inter_block8( // while every non-DC uv_mode was refused a few lines above. if uv_mode == DC_PRED && dec.symbol(&mut cdfs.palette_uv_mode[0]) != 0 { return Err(unsupported( - "a block that actually uses a palette (UV@inter_block8) -- reconstruction is out of scope", + "a block that actually uses a palette (UV) -- reconstruction is out of scope", )); } } diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index c066c43b..2b65970f 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -46,6 +46,12 @@ 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", "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)", @@ -111,9 +117,13 @@ const REFUSALS: &[&str] = &[ // both arms of gate // `a_real_aomenc_screen_inter_sequence_codes_palette_syntax_on_rect_intra_strips` // decode ten frames pixel-exact with the strips counted. What still - // refuses is a 16x4/4x16 strip and a 128-root half, neither of which is - // palette-eligible (`palette_bsize_ctx_wh` wants `8 <= min`, `max <= 64`) - // and neither of which has a witness stream yet. + // lane-t900 r22 NARROWED it again: the 16x4/4x16 arm is LIFTED (that arm + // routes through `decode_rect4_16_strip`, which reads the palette syntax + // itself -- the premise was stale), gated by + // `a_screen_stream_with_16x4_intra_strips_in_inter_frames_decodes_pixel_exact`. + // What still refuses is the 128-root half of a screen-content frame, whose + // body (`decode_block_128rect`) reads no palette syntax and for which no + // `--sb-size=128` screen witness exists yet. "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)", "warp prediction with a scaled reference (superres, unimplemented)", "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 3553e151..6441223d 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -119,6 +119,13 @@ pub fn rect_intrabc_reads() -> usize { crate::decode::rect_intrabc_reads() } +/// `(y, uv)` palette blocks RECONSTRUCTED inside an inter frame (lane-t900 +/// r22) -- the counter a screen-content witness gate reads to prove it +/// exercises the inter-frame palette path, not the key frame's. +pub fn intra_in_inter_palette_hits() -> (usize, usize) { + crate::decode::intra_in_inter_palette_hits() +} + /// lane-rect64port r1: coded 64-level HORZ/VERT intra strips whose luma /// transform unit is the un-split TX_64X32 (orient 0) / TX_32X64 (orient 1). pub fn rect64_corner_tu_hits(orient: usize) -> usize { @@ -30922,6 +30929,123 @@ mod tests { ); } + /// lane-t900 r22 GATE: a real `aomenc --tune-content=screen + /// --enable-palette=1` stream whose INTER frames reconstruct palette + /// blocks (Y and UV), at both bit depths. + /// + /// Recipe (both fixtures, 15 frames, key + 14 inter, 256x192, one tile): + /// `aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=20 --cpu-used=1 + /// --threads=1 --row-mt=0 --lag-in-frames=0 --kf-max-dist=9999 + /// --sb-size=64 --tune-content=screen --enable-palette=1 + /// --enable-intrabc=0 --obu` (plus `--bit-depth=10 --profile=0` for the + /// twin) over a synthetic screen-like source: two luma levels on a 16x16 + /// grid, four chroma levels on an 8x8 one, both re-keyed per frame so the + /// encoder cannot predict the new blocks and codes them INTRA inside the + /// inter frames. `--enable-palette=0` on the same source is 13% larger, + /// which is what says the tool is really used. + /// + /// What this pins that no key-frame palette gate can: the palette + /// colour-index CDFs are this decoder's only VARIABLE-ALPHABET tables (the + /// reader takes `[..=n]` of a `[u16; 9]` row, so `update_cdf`'s counter + /// lives at index `n`), and `Cdfs::reset_counts` zeroed slot 8 instead -- + /// so every colour-index row crossed a frame boundary with a SATURATED + /// count and adapted at rate 6 where libaom, counting from 0, adapts at 4. + /// The first inter-frame palette block's map desynced at its THIRD + /// colour-index symbol (decode-order frame 3, mi(40,0), map cell (0,2): + /// ours cdf0 = 32768-1071, aomdec's = 32768-971, same ctx, same value, + /// different range). + #[test] + fn a_real_aomenc_screen_stream_with_palette_blocks_decodes_pixel_exact() { + const NAME: &str = + "a_real_aomenc_screen_stream_with_palette_blocks_decodes_pixel_exact"; + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + for (fixture, ten_bit) in [ + ("fixtures/palette_screen_witness.obu", false), + ("fixtures/palette_screen_witness_10bit.obu", true), + ] { + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join(fixture); + let stream = std::fs::read(&path) + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); + let (width, height) = (256usize, 192usize); + let before = intra_in_inter_palette_hits(); + let frames = match decode_stream(&stream) { + Ok(frames) => frames, + Err(e) => panic!("{NAME} [{fixture}]: decode_stream refused: {e}"), + }; + let after = intra_in_inter_palette_hits(); + let (fired_y, fired_uv) = (after.0 - before.0, after.1 - before.1); + assert!( + fired_y > 0 && fired_uv > 0, + "{NAME} [{fixture}]: inter-frame palette fired y={fired_y} uv={fired_uv} \ + -- both planes must fire or the gate is vacuous for the one that did not" + ); + assert_eq!(frames.len(), 15, "{NAME} [{fixture}]: 15 shown frames"); + let ffmpeg_frames = if ten_bit { + ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()) + } else { + ffmpeg_decode_sequence(&stream, width, height, frames.len()) + }; + assert_eq!( + ffmpeg_frames.len(), + frames.len(), + "{NAME} [{fixture}]: frame count" + ); + for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() { + assert_eq!(ours.y, theirs.y, "{NAME} [{fixture}]: frame {i} luma vs ffmpeg"); + assert_eq!(ours.u, theirs.u, "{NAME} [{fixture}]: frame {i} U vs ffmpeg"); + assert_eq!(ours.v, theirs.v, "{NAME} [{fixture}]: frame {i} V vs ffmpeg"); + } + eprintln!( + "{NAME} [{fixture}]: 15 frames pixel-exact on every plane; \ + inter-frame 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 + /// `decode_rect4_16_strip`, which takes `allow_screen_content_tools` and + /// reads the whole palette syntax itself, so the refusal was a stale + /// premise (the key-frame path proves that body). This 10-bit + /// `--tune-content=screen` stream reached that exact refusal before the + /// lift and now decodes all 15 frames pixel-exact while 8 inter-frame + /// palette blocks reconstruct. + #[test] + fn a_screen_stream_with_16x4_intra_strips_in_inter_frames_decodes_pixel_exact() { + const NAME: &str = + "a_screen_stream_with_16x4_intra_strips_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_strip16_witness_10bit.obu"); + let stream = std::fs::read(&path) + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); + let before = intra_in_inter_palette_hits(); + let frames = match decode_stream(&stream) { + Ok(frames) => frames, + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), + }; + let fired_y = intra_in_inter_palette_hits().0 - before.0; + assert!( + fired_y > 0, + "{NAME}: no inter-frame palette block -- gate is vacuous" + ); + assert_eq!(frames.len(), 15, "{NAME}: 15 shown frames"); + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, 256, 192, frames.len()); + 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; inter-frame palette y={fired_y}"); + } + /// lane-t900 r20 GATE, refusal A -- `"a non-skip rectangular /// (HORZ/VERT/HORZ_B) strip needs rectangular residual coding"`. ///