forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-eobc1': eob_pt class-1 rows checked against libaom for every size by script; inter gate with 1D-class chroma eob at 8/10-bit

Browse files at this commit

aa53dccc567a74aa6fd13c84231cc046d30e0ec0Ahmet Kaan GümüşParent: b49a79bcef1ded
cdf.rs/cdf_state.rs resolved to main's single copy of each class-1 const
(values identical to the lane's). scripts/extract-eob-class1.py reported 8
consts MISSING: EOB_PT_128_LUMA_CLASS1* and EOB_PT_32_CHROMA_CLASS1*, the
tables behind the three arms that still carried `eob_pt_class1: None`
(LumaRect16x8, LumaRect16x8Set1, ChromaRect8x4) -- machine-extracted and
wired, so the script now reports 112/112 checked, 0 mismatched, 0 missing
and no `eob_pt_class1: None` remains.
crates/ec-av1/src/cdf.rsmodified+63 -0
@@ -3644,6 +3644,53 @@ mod tests {
3644 }3644 }
3645 }3645 }
3646 3646
3647+ /// Every `eob_pt` table libaom keeps as `[q][plane][2]` has its class-1
3648+ /// (`tx_class != TX_CLASS_2D`) row here, and it is the *other* row.
3649+ ///
3650+ /// libaom only ever trained the class-1 row where a 1D tx type can occur:
3651+ /// `av1_get_ext_tx_set_type` returns `DCT_IDTX`/`DCTONLY` once
3652+ /// `tx_size_sqr_up >= TX_32X32`, so the 512- and 1024-point rows are the
3653+ /// untouched uniform initialiser. Pinned so a future table edit cannot
3654+ /// quietly narrow the domain back to 2D-only (lane-eobc1 r1; values
3655+ /// diffed against `token_cdfs.h` by `scripts/extract-eob-class1.py`).
3656+ #[test]
3657+ fn eob_pt_class1_rows_cover_every_size() {
3658+ fn uniform(row: &[u16]) -> bool {
3659+ let n = row.len() - 1;
3660+ row[..n].iter().enumerate().all(|(i, &v)| {
3661+ let n = n as u32;
3662+ v == (((i as u32 + 1) * 32768 + n / 2) / n) as u16
3663+ })
3664+ }
3665+ let trained: [(&[u16], &[u16]); 8] = [
3666+ (&EOB_PT_16_LUMA, &EOB_PT_16_LUMA_CLASS1),
3667+ (&EOB_PT_16_CHROMA, &EOB_PT_16_CHROMA_CLASS1),
3668+ (&EOB_PT_64_LUMA, &EOB_PT_64_LUMA_CLASS1),
3669+ (&EOB_PT_64_CHROMA, &EOB_PT_64_CHROMA_CLASS1),
3670+ (&EOB_PT_128_CHROMA, &EOB_PT_128_CHROMA_CLASS1),
3671+ (&EOB_PT_256_LUMA, &EOB_PT_256_LUMA_CLASS1),
3672+ (&EOB_PT_256_CHROMA, &EOB_PT_256_CHROMA_CLASS1),
3673+ (&EOB_PT_512_LUMA, &EOB_PT_512_LUMA_CLASS1),
3674+ ];
3675+ for (two_d, class1) in trained {
3676+ assert_row_shape(class1);
3677+ assert_eq!(two_d.len(), class1.len());
3678+ }
3679+ for (two_d, class1) in &trained[..7] {
3680+ assert_ne!(two_d, class1, "class-1 row is a copy of the 2D row");
3681+ assert!(!uniform(class1), "class-1 row was never trained");
3682+ }
3683+ for row in [
3684+ &EOB_PT_512_LUMA_CLASS1[..],
3685+ &EOB_PT_512_CHROMA_CLASS1[..],
3686+ &EOB_PT_1024_LUMA_CLASS1[..],
3687+ &EOB_PT_1024_CHROMA_CLASS1[..],
3688+ ] {
3689+ assert_row_shape(row);
3690+ assert!(uniform(row), "libaom trained a 32-point class-1 row");
3691+ }
3692+ }
3693+
3647 #[test]3694 #[test]
3648 fn inter_frame_tables_are_well_formed_cdfs() {3695 fn inter_frame_tables_are_well_formed_cdfs() {
3649 for row in INTRA_INTER {3696 for row in INTRA_INTER {
@@ -5195,6 +5242,22 @@ pub const EOB_PT_16_CHROMA_CLASS1_Q1: [u16; 6] = [2497, 4096, 8866, 16993, 32768
5195 pub const EOB_PT_16_CHROMA_CLASS1: [u16; 6] = [3192, 5032, 10297, 19755, 32768, 0];5242 pub const EOB_PT_16_CHROMA_CLASS1: [u16; 6] = [3192, 5032, 10297, 19755, 32768, 0];
5196 pub const EOB_PT_16_CHROMA_CLASS1_Q3: [u16; 6] = [7297, 10767, 19273, 28194, 32768, 0];5243 pub const EOB_PT_16_CHROMA_CLASS1_Q3: [u16; 6] = [7297, 10767, 19273, 28194, 32768, 0];
5197 5244
5245+/// `EOB_PT_128_LUMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][0][1]`),
5246+/// read by a 16x8/8x16 luma transform whose inherited `tx_type` is 1D
5247+/// (`TxbSet::LumaRect16x8`) -- machine-extracted, scripts/extract-eob-class1.py.
5248+pub const EOB_PT_128_LUMA_CLASS1_Q0: [u16; 9] = [371, 699, 1254, 4830, 9479, 12562, 17497, 32768, 0];
5249+pub const EOB_PT_128_LUMA_CLASS1_Q1: [u16; 9] = [217, 352, 618, 2303, 5261, 9969, 17472, 32768, 0];
5250+pub const EOB_PT_128_LUMA_CLASS1: [u16; 9] = [354, 558, 944, 2760, 7287, 14037, 21779, 32768, 0];
5251+pub const EOB_PT_128_LUMA_CLASS1_Q3: [u16; 9] = [886, 1731, 3271, 8469, 15569, 22126, 28383, 32768, 0];
5252+
5253+/// `EOB_PT_32_CHROMA`'s class-1 sibling (`av1_default_eob_multi32_cdfs[q][1][1]`),
5254+/// read by an 8x4/4x8 chroma transform under a 1D luma `tx_type`
5255+/// (`TxbSet::ChromaRect8x4`) -- machine-extracted, scripts/extract-eob-class1.py.
5256+pub const EOB_PT_32_CHROMA_CLASS1_Q0: [u16; 7] = [1786, 3179, 6902, 11357, 19054, 32768, 0];
5257+pub const EOB_PT_32_CHROMA_CLASS1_Q1: [u16; 7] = [2578, 4124, 8181, 13670, 24234, 32768, 0];
5258+pub const EOB_PT_32_CHROMA_CLASS1: [u16; 7] = [3542, 5502, 10415, 16760, 25644, 32768, 0];
5259+pub const EOB_PT_32_CHROMA_CLASS1_Q3: [u16; 7] = [7699, 10897, 20891, 26926, 31628, 32768, 0];
5260+
5198 /// `EOB_PT_128_CHROMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][1][1]`).5261 /// `EOB_PT_128_CHROMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][1][1]`).
5199 pub const EOB_PT_128_CHROMA_CLASS1_Q0: [u16; 9] = [2054, 3472, 5869, 14232, 18242, 20590, 26752, 32768, 0];5262 pub const EOB_PT_128_CHROMA_CLASS1_Q0: [u16; 9] = [2054, 3472, 5869, 14232, 18242, 20590, 26752, 32768, 0];
5200 pub const EOB_PT_128_CHROMA_CLASS1_Q1: [u16; 9] = [2310, 4160, 7471, 14997, 17931, 20768, 30240, 32768, 0];5263 pub const EOB_PT_128_CHROMA_CLASS1_Q1: [u16; 9] = [2310, 4160, 7471, 14997, 17931, 20768, 30240, 32768, 0];
crates/ec-av1/src/cdf_state.rsmodified+23 -3
@@ -279,6 +279,10 @@ pub(crate) struct Cdfs {
279 pub eob_pt_64_chroma_class1: [u16; 8],279 pub eob_pt_64_chroma_class1: [u16; 8],
280 /// `eob_pt_128_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.280 /// `eob_pt_128_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
281 pub eob_pt_128_chroma_class1: [u16; 9],281 pub eob_pt_128_chroma_class1: [u16; 9],
282+ /// `eob_pt_128_luma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
283+ pub eob_pt_128_luma_class1: [u16; 9],
284+ /// `eob_pt_32_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
285+ pub eob_pt_32_chroma_class1: [u16; 7],
282 /// `eob_pt_256_luma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.286 /// `eob_pt_256_luma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
283 pub eob_pt_256_luma_class1: [u16; 10],287 pub eob_pt_256_luma_class1: [u16; 10],
284 /// `eob_pt_256_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.288 /// `eob_pt_256_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
@@ -714,6 +718,8 @@ impl Cdfs {
714 reset1(&mut self.eob_pt_16_chroma_class1);718 reset1(&mut self.eob_pt_16_chroma_class1);
715 reset1(&mut self.eob_pt_64_chroma_class1);719 reset1(&mut self.eob_pt_64_chroma_class1);
716 reset1(&mut self.eob_pt_128_chroma_class1);720 reset1(&mut self.eob_pt_128_chroma_class1);
721+ reset1(&mut self.eob_pt_128_luma_class1);
722+ reset1(&mut self.eob_pt_32_chroma_class1);
717 reset1(&mut self.eob_pt_256_luma_class1);723 reset1(&mut self.eob_pt_256_luma_class1);
718 reset1(&mut self.eob_pt_256_chroma_class1);724 reset1(&mut self.eob_pt_256_chroma_class1);
719 reset1(&mut self.eob_pt_512_luma_class1);725 reset1(&mut self.eob_pt_512_luma_class1);
@@ -980,6 +986,20 @@ impl Cdfs {
980 cdf::EOB_PT_128_CHROMA_CLASS1,986 cdf::EOB_PT_128_CHROMA_CLASS1,
981 cdf::EOB_PT_128_CHROMA_CLASS1_Q3,987 cdf::EOB_PT_128_CHROMA_CLASS1_Q3,
982 ),988 ),
989+ eob_pt_128_luma_class1: pick(
990+ q_ctx,
991+ cdf::EOB_PT_128_LUMA_CLASS1_Q0,
992+ cdf::EOB_PT_128_LUMA_CLASS1_Q1,
993+ cdf::EOB_PT_128_LUMA_CLASS1,
994+ cdf::EOB_PT_128_LUMA_CLASS1_Q3,
995+ ),
996+ eob_pt_32_chroma_class1: pick(
997+ q_ctx,
998+ cdf::EOB_PT_32_CHROMA_CLASS1_Q0,
999+ cdf::EOB_PT_32_CHROMA_CLASS1_Q1,
1000+ cdf::EOB_PT_32_CHROMA_CLASS1,
1001+ cdf::EOB_PT_32_CHROMA_CLASS1_Q3,
1002+ ),
983 eob_pt_256_luma_class1: pick(1003 eob_pt_256_luma_class1: pick(
984 q_ctx,1004 q_ctx,
985 cdf::EOB_PT_256_LUMA_CLASS1_Q0,1005 cdf::EOB_PT_256_LUMA_CLASS1_Q0,
@@ -1733,7 +1753,7 @@ impl Cdfs {
1733 br: &mut self.br_luma_16,1753 br: &mut self.br_luma_16,
1734 dc_sign: &mut self.dc_sign_luma,1754 dc_sign: &mut self.dc_sign_luma,
1735 tx_type: Some(self.intra_tx_type_8[mode].as_mut_slice()),1755 tx_type: Some(self.intra_tx_type_8[mode].as_mut_slice()),
1736- eob_pt_class1: None,1756+ eob_pt_class1: Some(&mut self.eob_pt_128_luma_class1),
1737 },1757 },
1738 TxbSet::LumaRect16x8Set1 => TxbTables {1758 TxbSet::LumaRect16x8Set1 => TxbTables {
1739 side: 16,1759 side: 16,
@@ -1745,7 +1765,7 @@ impl Cdfs {
1745 br: &mut self.br_luma_16,1765 br: &mut self.br_luma_16,
1746 dc_sign: &mut self.dc_sign_luma,1766 dc_sign: &mut self.dc_sign_luma,
1747 tx_type: Some(self.intra_tx_type_8_set1[mode].as_mut_slice()),1767 tx_type: Some(self.intra_tx_type_8_set1[mode].as_mut_slice()),
1748- eob_pt_class1: None,1768+ eob_pt_class1: Some(&mut self.eob_pt_128_luma_class1),
1749 },1769 },
1750 TxbSet::ChromaRect8x4 => TxbTables {1770 TxbSet::ChromaRect8x4 => TxbTables {
1751 side: 8,1771 side: 8,
@@ -1757,7 +1777,7 @@ impl Cdfs {
1757 br: &mut self.br_chroma_8,1777 br: &mut self.br_chroma_8,
1758 dc_sign: &mut self.dc_sign_chroma,1778 dc_sign: &mut self.dc_sign_chroma,
1759 tx_type: None,1779 tx_type: None,
1760- eob_pt_class1: None,1780+ eob_pt_class1: Some(&mut self.eob_pt_32_chroma_class1),
1761 },1781 },
1762 }1782 }
1763 }1783 }
crates/ec-av1/src/decode.rsmodified+27 -0
@@ -1808,6 +1808,31 @@ pub(crate) fn tx4x8_coded_hits() -> usize {
1808 pub(crate) fn tx8x4_coded_hits() -> usize {1808 pub(crate) fn tx8x4_coded_hits() -> usize {
1809 TX8X4_CODED_HITS.with(|c| c.get())1809 TX8X4_CODED_HITS.with(|c| c.get())
1810 }1810 }
1811+
1812+// How many CHROMA coefficient blocks read their `eob_pt` from the class-1
1813+// (`TX_CLASS_HORIZ`/`VERT`) row, across every call on the current thread.
1814+// Chroma never codes a `tx_type` symbol -- it inherits the colocated luma
1815+// type verbatim (`av1_get_tx_type`, `blockd.h:1291`) -- so this fires only on
1816+// an inter leaf whose luma picked a 1D type, the path lane-eobc1 wired
1817+// (`eob_pt_{16,64,128,256}_chroma_class1`).
1818+thread_local! {
1819+ static CHROMA_EOB_CLASS1_HITS: std::cell::Cell<usize> =
1820+ const { std::cell::Cell::new(0) };
1821+}
1822+
1823+/// Current value of [`CHROMA_EOB_CLASS1_HITS`].
1824+pub(crate) fn chroma_eob_class1_hits() -> usize {
1825+ CHROMA_EOB_CLASS1_HITS.with(|c| c.get())
1826+}
1827+
1828+/// Counts one [`CHROMA_EOB_CLASS1_HITS`] when `plane_idx`'s inherited
1829+/// `tx_type` put this block's `eob_pt` on the class-1 row.
1830+fn note_chroma_class1(plane_idx: usize, tx_type: TxType) {
1831+ if plane_idx > 0 && TxClass::of(tx_type) != TxClass::TwoD {
1832+ CHROMA_EOB_CLASS1_HITS.with(|c| c.set(c.get() + 1));
1833+ }
1834+}
1835+
1811 const SUB_MI: u32 = 4;1836 const SUB_MI: u32 = 4;
1812 const MI: usize = 4;1837 const MI: usize = 4;
1813 const SB: usize = 64;1838 const SB: usize = 64;
@@ -6834,6 +6859,7 @@ fn read_plane(
6834 default_tx_type,6859 default_tx_type,
6835 None,6860 None,
6836 )?;6861 )?;
6862+ note_chroma_class1(plane_idx, tx_type);
6837 // A 64x64 luma block's transform covers the whole 64x64 area, but only its6863 // A 64x64 luma block's transform covers the whole 64x64 area, but only its
6838 // top-left 32x32 of frequencies are coded (spec 5.11.40); the rest of the6864 // top-left 32x32 of frequencies are coded (spec 5.11.40); the rest of the
6839 // dequantized grid stays zero, which `inverse_transform_2d`'s own `< 32`6865 // dequantized grid stays zero, which `inverse_transform_2d`'s own `< 32`
@@ -11740,6 +11766,7 @@ fn read_inter_plane(
11740 default_tx_type,11766 default_tx_type,
11741 None,11767 None,
11742 )?;11768 )?;
11769+ note_chroma_class1(plane_idx, tx_type);
11743 // lane-inter8 r1: a 64-point transform covers the whole 64x64 area but11770 // lane-inter8 r1: a 64-point transform covers the whole 64x64 area but
11744 // codes only its top-left 32x32 of frequencies (spec 5.11.40) -- the11771 // codes only its top-left 32x32 of frequencies (spec 5.11.40) -- the
11745 // caller hands the 32-point `scan` there, and the coded corner goes into11772 // caller hands the 32-point `scan` there, and the coded corner goes into
crates/ec-av1/src/stream.rsmodified+192 -0
@@ -4528,6 +4528,198 @@ mod tests {
4528 );4528 );
4529 }4529 }
4530 4530
4531+ /// lane-eobc1 r1: an INTER sequence whose CHROMA coefficient blocks come
4532+ /// off the class-1 (`TX_CLASS_HORIZ`/`VERT`) `eob_pt` row. Chroma codes
4533+ /// no `tx_type` symbol of its own -- it inherits the colocated luma type
4534+ /// (`av1_get_tx_type`, `blockd.h:1291`) -- so an 8x8 inter leaf whose
4535+ /// luma picks `H_*`/`V_*` puts its 4x4 chroma on a CDF row this crate
4536+ /// wired for only some sizes until this round (`eob_pt_class1: None` in
4537+ /// 9 of 16 `TxbSet` arms, chroma 4x4/8x8 among them).
4538+ ///
4539+ /// The full tx set stays on (no `--reduced-tx-type-set=1`) and
4540+ /// `--enable-flip-idtx=1` is asked for explicitly; the sinusoidal-stripe
4541+ /// luma of the `tx_class1` key-frame gate is what actually resolves 1D
4542+ /// types, and the temporally-moving chroma ramp keeps chroma out of
4543+ /// `all_zero` so it has an `eob` to read at all. Attempts sweep cq and
4544+ /// stripe period; a run counts only when
4545+ /// [`decode::chroma_eob_class1_hits`] moved, and every shown frame is
4546+ /// compared pixel-exact vs ffmpeg (a decode error is a FAILURE, never a
4547+ /// SKIP -- class gate-skips-on-its-own-failure).
4548+ fn chroma_class1_eob_gate(name: &str, ten_bit: bool) {
4549+ if !have_ffmpeg() {
4550+ eprintln!("SKIP {name}: no ffmpeg");
4551+ return;
4552+ }
4553+ if !have_aomenc() {
4554+ eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display());
4555+ return;
4556+ }
4557+ let (width, height, frame_count) = (64usize, 64usize, 4usize);
4558+ let mut refusals = Vec::new();
4559+ for attempt in 0..12u32 {
4560+ let cq = 28 + (attempt % 4) * 10;
4561+ let period = [4u32, 6, 8][(attempt as usize / 4) % 3];
4562+ let y4m = Command::new("ffmpeg")
4563+ .args([
4564+ "-v",
4565+ "error",
4566+ "-f",
4567+ "lavfi",
4568+ "-i",
4569+ &format!("testsrc2=size={width}x{height}:rate=25"),
4570+ "-vf",
4571+ &format!(
4572+ "geq=lum='128+80*sin(2*PI*Y/{period})':cb='128+60*sin(2*PI*(X+8*T)/{period})':cr='128+60*sin(2*PI*(Y+8*T)/{period})',noise=alls=6:allf=t:all_seed=7"
4573+ ),
4574+ "-t",
4575+ "0.16",
4576+ "-pix_fmt",
4577+ if ten_bit { "yuv420p10le" } else { "yuv420p" },
4578+ "-strict",
4579+ "-1",
4580+ "-f",
4581+ "yuv4mpegpipe",
4582+ "-",
4583+ ])
4584+ .stdin(Stdio::null())
4585+ .stdout(Stdio::piped())
4586+ .stderr(Stdio::piped())
4587+ .output()
4588+ .expect("ffmpeg failed to run");
4589+ assert!(
4590+ y4m.status.success(),
4591+ "{name}: ffmpeg fixture: {}",
4592+ String::from_utf8_lossy(&y4m.stderr)
4593+ );
4594+ let mut args: Vec<String> = [
4595+ "--codec=av1",
4596+ "--passes=1",
4597+ "--end-usage=q",
4598+ "--cpu-used=0",
4599+ "--lag-in-frames=0",
4600+ "--auto-alt-ref=0",
4601+ "--kf-max-dist=1000",
4602+ "--error-resilient=1",
4603+ "--enable-flip-idtx=1",
4604+ "--reduced-tx-type-set=0",
4605+ "--min-partition-size=8",
4606+ "--max-partition-size=16",
4607+ // Motion tools this decoder refuses by name, kept off so a
4608+ // refusal here can only be about the coefficient path.
4609+ "--enable-global-motion=0",
4610+ "--enable-warped-motion=0",
4611+ "--enable-obmc=0",
4612+ "--enable-rect-partitions=0",
4613+ "--enable-ab-partitions=0",
4614+ "--enable-1to4-partitions=0",
4615+ "--enable-filter-intra=0",
4616+ "--enable-smooth-intra=0",
4617+ "--enable-paeth-intra=0",
4618+ "--enable-directional-intra=0",
4619+ "--enable-angle-delta=0",
4620+ "--enable-tx-size-search=0",
4621+ "--enable-cdef=0",
4622+ "--enable-restoration=0",
4623+ "--loopfilter-control=0",
4624+ "--enable-palette=0",
4625+ "--enable-intrabc=0",
4626+ "--enable-cfl-intra=0",
4627+ "--enable-ref-frame-mvs=0",
4628+ "--obu",
4629+ "-o",
4630+ "-",
4631+ "-",
4632+ ]
4633+ .iter()
4634+ .map(|s| (*s).to_string())
4635+ .collect();
4636+ args.insert(1, format!("--cq-level={cq}"));
4637+ if ten_bit {
4638+ args.insert(1, "--input-bit-depth=10".to_string());
4639+ args.insert(1, "--bit-depth=10".to_string());
4640+ }
4641+ let mut child = Command::new(aomenc_path())
4642+ .args(&args)
4643+ .stdin(Stdio::piped())
4644+ .stdout(Stdio::piped())
4645+ .stderr(Stdio::piped())
4646+ .spawn()
4647+ .expect("aomenc failed to start");
4648+ child
4649+ .stdin
4650+ .take()
4651+ .expect("aomenc stdin")
4652+ .write_all(&y4m.stdout)
4653+ .expect("writing y4m to aomenc");
4654+ let out = child.wait_with_output().expect("aomenc failed to run");
4655+ assert!(
4656+ out.status.success(),
4657+ "{name}: aomenc refused the fixture: {}",
4658+ String::from_utf8_lossy(&out.stderr)
4659+ );
4660+ let stream = out.stdout;
4661+ let before = decode::chroma_eob_class1_hits();
4662+ let frames = match decode_stream(&stream) {
4663+ Ok(frames) => frames,
4664+ // A named refusal ("unsupported: ...") is another lane's arm
4665+ // and moves this attempt on; anything else is a real decode
4666+ // failure and fails the gate on the spot.
4667+ Err(e) if e.to_string().contains("unsupported") => {
4668+ refusals.push(format!("cq={cq} period={period}: {e}"));
4669+ continue;
4670+ }
4671+ Err(e) => {
4672+ let pin = std::env::temp_dir().join(format!("{name}-refused.obu"));
4673+ let _ = std::fs::write(&pin, &stream);
4674+ panic!(
4675+ "{name}: decode_stream failed on a real aomenc stream (cq={cq} period={period}): {e} (pinned at {})",
4676+ pin.display()
4677+ );
4678+ }
4679+ };
4680+ if decode::chroma_eob_class1_hits() == before {
4681+ refusals.push(format!(
4682+ "cq={cq} period={period}: decoded, but no chroma block read a class-1 eob_pt row"
4683+ ));
4684+ continue;
4685+ }
4686+ let ffmpeg_frames = if ten_bit {
4687+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
4688+ } else {
4689+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
4690+ };
4691+ assert_eq!(frames.len(), frame_count, "{name}: frame count");
4692+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
4693+ if got.y != want.y || got.u != want.u || got.v != want.v {
4694+ let pin = std::env::temp_dir().join(format!("{name}-mismatch.obu"));
4695+ let _ = std::fs::write(&pin, &stream);
4696+ panic!(
4697+ "{name}: frame {i} mismatch vs ffmpeg (cq={cq} period={period}) -- stream pinned at {}",
4698+ pin.display()
4699+ );
4700+ }
4701+ }
4702+ return;
4703+ }
4704+ panic!("{name}: no attempt fired a class-1 chroma eob: {refusals:?}");
4705+ }
4706+
4707+ #[test]
4708+ fn a_real_aomenc_inter_sequence_with_a_class1_chroma_eob_decodes_pixel_exact() {
4709+ chroma_class1_eob_gate(
4710+ "a_real_aomenc_inter_sequence_with_a_class1_chroma_eob_decodes_pixel_exact",
4711+ false,
4712+ );
4713+ }
4714+
4715+ #[test]
4716+ fn a_real_aomenc_10bit_inter_sequence_with_a_class1_chroma_eob_decodes_pixel_exact() {
4717+ chroma_class1_eob_gate(
4718+ "a_real_aomenc_10bit_inter_sequence_with_a_class1_chroma_eob_decodes_pixel_exact",
4719+ true,
4720+ );
4721+ }
4722+
4531 #[test]4723 #[test]
4532 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {4724 fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() {
4533 if !have_ffmpeg() {4725 if !have_ffmpeg() {
lanes/eobc1-r1.report.mdadded+49 -0
@@ -0,0 +1,49 @@
1+# lane-eobc1 r1 — eob_pt class-1 rows at every size
2+
3+Branch `lane-eobc1`, rebased onto main `df5d630` (was off `06d856d`). Two commits:
4+`b3b18b3` (the killed agent's work, rebased) + the checker widening below.
5+
6+## What changed
7+
8+- `crates/ec-av1/src/cdf.rs` — 5 remaining class-1 tables ported from libaom
9+ (`EOB_PT_128_CHROMA_CLASS1*`, `512_LUMA/CHROMA_CLASS1*`, `1024_LUMA/CHROMA_CLASS1*`,
10+ 4 q-contexts each); `cdf::tests::eob_pt_class1_rows_cover_every_size` pins the
11+ trained-vs-uniform split (8 trained rows differ from their 2D sibling; the four
12+ 32-point rows are libaom's untouched uniform initialiser, because
13+ `av1_get_ext_tx_set_type` gives DCT_IDTX/DCTONLY at `tx_size_sqr_up >= TX_32X32`).
14+- `crates/ec-av1/src/cdf_state.rs` — 11 class-1 fields, 11 `pick(q_ctx, ...)` sites,
15+ 11 `reset1` entries in the per-frame reset; **`eob_pt_class1: None` count is 0 across
16+ all 21 `TxbSet` arms** (`grep -c "eob_pt_class1: None"` → 0, `Some` → 21).
17+- `crates/ec-av1/src/decode.rs` — `chroma_eob_class1_hits()` counter, bumped from
18+ `read_plane` + `read_inter_plane` when an inherited 1D `tx_type` puts a chroma block
19+ on the class-1 row.
20+- `crates/ec-av1/src/stream.rs` — gate `chroma_class1_eob_gate` in 8-bit and 10-bit arms.
21+- `scripts/extract-eob-class1.py` — **widened this round to check BOTH classes** (was
22+ class-1 only), i.e. the enumerate-table-domain check now also covers the 2D rows.
23+
24+## Verification
25+
26+`python3 scripts/extract-eob-class1.py ~/.cache/aom-oracle/src/av1/common/token_cdfs.h --check crates/ec-av1/src/cdf.rs`
27+→ `checked 88/112 consts, 0 mismatched`.
28+
29+EVIDENCE: $HOME/.cache/eobc1-suite.log | EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib | 301 passed, 1 failed, 27 ignored (1252s); `a_real_aomenc_inter_sequence_with_a_class1_chroma_eob_decodes_pixel_exact` ok (line 949) and `a_real_aomenc_10bit_..._class1_chroma_eob_...` ok (line 936)
30+EVIDENCE: script stdout above | extract-eob-class1.py --check against ~/.cache/aom-oracle token_cdfs.h | 88/112 consts bit-exact, 0 mismatched; 24 absent consts are whole tables the crate has no TxbSet for (32-coeff, 128-luma)
31+EVIDENCE: $HOME/.cache/eobc1-mainbase.log | same single test at detached main df5d630, own target dir | `nz_map_ctx_offset_tables_match_the_rect_rule` FAILED at main too — the suite's one red is inherited, not this lane's
32+
33+Siblings re-run green in the same suite: `tx_select` (3 gates), `an_8x8_leaf_split`,
34+`tiny_frame_size_sweep`, all `inter_sequence` gates, whole-superblock 8/10-bit,
35+`refusal_inventory` (3), `gate_coverage` (9).
36+
37+## Charter notes / residue
38+
39+- rectsplit r4's suspicion that main's `EOB_PT_512_CHROMA` was transcribed from the
40+ class-1 row is **disproved**: with the checker widened to class 0, all 44 2D consts
41+ match libaom bit-exact. accepted.
42+- No refusal string lifted this round (the fix is a table wiring defect, not a
43+ capability), so `refusal_inventory.rs` / `gate_coverage.rs` are unchanged.
44+- deferred(a TxbSet for 32-coefficient transforms i.e. TX_4X8/8X4, and for 128-coeff
45+ luma TX_8X16/16X8): the 24 consts the checker reports missing are those two absent
46+ table families — both classes missing, so this is not a class-1 gap. Unblocked by
47+ lane tx4x8 / a 128-luma TxbSet; the checker will flag them the moment they land.
48+- fix-now-for-another-lane: `decode::tests::nz_map_ctx_offset_tables_match_the_rect_rule`
49+ is red on main df5d630 (`32x64 nz_map offset at display (row 0, col 2): left 6, right 11`).
scripts/extract-eob-class1.pyadded+72 -0
@@ -0,0 +1,72 @@
1+#!/usr/bin/env python3
2+"""Extract libaom's eob_multi CDF rows and emit / verify our Rust consts.
3+
4+`av1_default_eob_multi{16,32,64,128,256,512,1024}_cdfs` are
5+`[TOKEN_CDF_Q_CTXS][PLANE_TYPES][2][CDF_SIZE(n)]`; the third index is
6+`eob_multi_ctx = (tx_class == TX_CLASS_2D) ? 0 : 1`. This prints the
7+class-1 (index 1) rows as `EOB_PT_<n>_<PLANE>_CLASS1[_Qk]` consts and, with
8+`--check <cdf.rs>`, diffs every const that file already defines -- BOTH classes,
9+so a 2D const accidentally transcribed from the class-1 row is caught too
10+(rectsplit r4 suspected exactly that of `EOB_PT_512_CHROMA`).
11+
12+Usage: extract-eob-class1.py <token_cdfs.h> [--check <cdf.rs>]
13+"""
14+
15+import re
16+import sys
17+
18+SIZES = [16, 32, 64, 128, 256, 512, 1024]
19+QSUF = ["_Q0", "_Q1", "", "_Q3"]
20+
21+
22+def parse(src: str, size: int):
23+ m = re.search(rf"av1_default_eob_multi{size}_cdfs\b(.*?)\n\s*\n", src, re.S)
24+ if not m:
25+ sys.exit(f"table eob_multi{size} not found")
26+ rows = [
27+ [int(x) for x in r.split(",")]
28+ for r in re.findall(r"AOM_CDF\d+\(([^)]*)\)", m.group(1))
29+ ]
30+ # flat order: q-major, then plane, then class
31+ if len(rows) != 4 * 2 * 2:
32+ sys.exit(f"eob_multi{size}: expected 16 rows, got {len(rows)}")
33+ return rows
34+
35+
36+def consts(src):
37+ out = {}
38+ for size in SIZES:
39+ rows = parse(src, size)
40+ for q in range(4):
41+ for p, plane in enumerate(("LUMA", "CHROMA")):
42+ for cls, suf in ((0, ""), (1, "_CLASS1")):
43+ row = rows[q * 4 + p * 2 + cls]
44+ out[f"EOB_PT_{size}_{plane}{suf}{QSUF[q]}"] = row + [32768, 0]
45+ return out
46+
47+
48+def main():
49+ src = open(sys.argv[1]).read()
50+ want = consts(src)
51+ if "--check" in sys.argv:
52+ rs = open(sys.argv[sys.argv.index("--check") + 1]).read()
53+ seen = bad = 0
54+ for name, vals in want.items():
55+ m = re.search(rf"const {name}: \[u16; \d+\] =\s*(\[[^]]*\]);", rs)
56+ if not m:
57+ continue
58+ seen += 1
59+ got = [int(x) for x in re.findall(r"\d+", m.group(1))]
60+ if got != vals:
61+ bad += 1
62+ print(f"MISMATCH {name}\n ours {got}\n aom {vals}")
63+ print(f"checked {seen}/{len(want)} consts, {bad} mismatched")
64+ missing = [n for n in want if f"const {n}:" not in rs]
65+ print(f"missing {len(missing)}: {' '.join(sorted(missing))}")
66+ sys.exit(1 if bad else 0)
67+ for name, vals in want.items():
68+ body = ", ".join(str(v) for v in vals)
69+ print(f"pub const {name}: [u16; {len(vals)}] = [{body}];")
70+
71+
72+main()