forge
Explore
Log in

Don't you dare go Hollow

merge(palette2): main 096f4b8 (rectsplit r4, tx64x16 SB 1:4, gmaffine, hidden-frame compares)

Browse files at this commit

652ab0d32fc4e9107b0ee9d9cdc8c9463e58f450Ahmet Kaan GümüşParent: 11df160b38f3aa
decode.rs auto-merged; decode_block_rect64's split arm (main's SB-level 1:4
path) gained the lane's RectStripModes palette fields and the r10 early-return
palette stamp -- same class as decode_block_rect's arm. cdf.rs is main's
byte-for-byte, main's deletion of nz_map_ctx_offset_tables_match_the_rect_rule
taken. refusal_inventory.rs: kept the two lane palette strings + main's
superblock-level partition value string; dropped the three no longer emitted.

23 changed files +4205 -448

crates/ec-av1/examples/decode_probe.rsmodified+6 -4
@@ -33,10 +33,11 @@ fn main() {
33 println!("OK but EMPTY: no frames -- is {path} an IVF rather than a raw OBU stream?");33 println!("OK but EMPTY: no frames -- is {path} an IVF rather than a raw OBU stream?");
34 }34 }
35 Ok(frames) => {35 Ok(frames) => {
36- println!("OK: {} frames decoded", frames.len());36+ // Optional second arg, or EC_PROBE_OUT=<path>: dump the decoded
37- // Optional second arg: dump the decoded planes as raw yuv420p so a37+ // planes as raw yuv420p so a pixel diff against `ffmpeg -i s.obu
38- // pixel diff against `ffmpeg -i s.obu -f rawvideo` needs no test harness.38+ // -f rawvideo` needs no test harness.
39- if let Some(out) = std::env::args().nth(2) {39+ let out = std::env::args().nth(2).or_else(|| std::env::var("EC_PROBE_OUT").ok());
40+ if let Some(out) = out {
40 // 8-bit only: planes are u16, take the low byte.41 // 8-bit only: planes are u16, take the low byte.
41 let mut buf: Vec<u8> = Vec::new();42 let mut buf: Vec<u8> = Vec::new();
42 for f in &frames {43 for f in &frames {
@@ -47,6 +48,7 @@ fn main() {
47 std::fs::write(&out, &buf).expect("writing raw planes");48 std::fs::write(&out, &buf).expect("writing raw planes");
48 println!("wrote {} bytes of yuv420p to {out}", buf.len());49 println!("wrote {} bytes of yuv420p to {out}", buf.len());
49 }50 }
51+ println!("OK: {} frames decoded, {}x{}", frames.len(), frames[0].width, frames[0].height);
50 }52 }
51 Err(e) => println!("REFUSED: {e}"),53 Err(e) => println!("REFUSED: {e}"),
52 }54 }
crates/ec-av1/src/cdf.rsmodified+41 -10
@@ -843,11 +843,11 @@ pub const NZ_MAP_CTX_OFFSET_32: [[u8; 5]; 5] = [
843 // `pos = col*32+row` raster (same convention [`SCAN_32X16`]'s doc comment843 // `pos = col*32+row` raster (same convention [`SCAN_32X16`]'s doc comment
844 // already documents this decoder transcribes out of).844 // already documents this decoder transcribes out of).
845 pub const NZ_MAP_CTX_OFFSET_32X64: [[u8; 5]; 5] = [845 pub const NZ_MAP_CTX_OFFSET_32X64: [[u8; 5]; 5] = [
846- [0, 11, 11, 11, 11],846+ [0, 11, 6, 6, 21],
847- [11, 11, 11, 11, 11],847+ [11, 11, 6, 21, 21],
848- [6, 6, 21, 21, 21],848+ [11, 11, 21, 21, 21],
849- [6, 21, 21, 21, 21],849+ [11, 11, 21, 21, 21],
850- [21, 21, 21, 21, 21],850+ [11, 11, 21, 21, 21],
851 ];851 ];
852 852
853 /// [`NZ_MAP_CTX_OFFSET_32X64`]'s `TX_64X32` counterpart (libaom853 /// [`NZ_MAP_CTX_OFFSET_32X64`]'s `TX_64X32` counterpart (libaom
@@ -856,11 +856,11 @@ pub const NZ_MAP_CTX_OFFSET_32X64: [[u8; 5]; 5] = [
856 /// regardless of row -- transpose of [`NZ_MAP_CTX_OFFSET_32X64`]'s `row < 2`856 /// regardless of row -- transpose of [`NZ_MAP_CTX_OFFSET_32X64`]'s `row < 2`
857 /// branch, same r3 fix (see that table's doc comment).857 /// branch, same r3 fix (see that table's doc comment).
858 pub const NZ_MAP_CTX_OFFSET_64X32: [[u8; 5]; 5] = [858 pub const NZ_MAP_CTX_OFFSET_64X32: [[u8; 5]; 5] = [
859- [0, 16, 6, 6, 21],859+ [0, 16, 16, 16, 16],
860- [16, 16, 6, 21, 21],860+ [16, 16, 16, 16, 16],
861- [16, 16, 21, 21, 21],861+ [6, 6, 21, 21, 21],
862- [16, 16, 21, 21, 21],862+ [6, 21, 21, 21, 21],
863- [16, 16, 21, 21, 21],863+ [21, 21, 21, 21, 21],
864 ];864 ];
865 865
866 /// `Default_Txb_Skip_Cdf[2][2][7..10]` (spec 9.4): the all-zero flag of a866 /// `Default_Txb_Skip_Cdf[2][2][7..10]` (spec 9.4): the all-zero flag of a
@@ -5126,3 +5126,34 @@ pub const EOB_PT_16_CHROMA_CLASS1_Q0: [u16; 6] = [1904, 3354, 7763, 14647, 32768
5126 pub const EOB_PT_16_CHROMA_CLASS1_Q1: [u16; 6] = [2497, 4096, 8866, 16993, 32768, 0];5126 pub const EOB_PT_16_CHROMA_CLASS1_Q1: [u16; 6] = [2497, 4096, 8866, 16993, 32768, 0];
5127 pub const EOB_PT_16_CHROMA_CLASS1: [u16; 6] = [3192, 5032, 10297, 19755, 32768, 0];5127 pub const EOB_PT_16_CHROMA_CLASS1: [u16; 6] = [3192, 5032, 10297, 19755, 32768, 0];
5128 pub const EOB_PT_16_CHROMA_CLASS1_Q3: [u16; 6] = [7297, 10767, 19273, 28194, 32768, 0];5128 pub const EOB_PT_16_CHROMA_CLASS1_Q3: [u16; 6] = [7297, 10767, 19273, 28194, 32768, 0];
5129+
5130+/// `EOB_PT_128_CHROMA`'s class-1 sibling (`av1_default_eob_multi128_cdfs[q][1][1]`).
5131+pub const EOB_PT_128_CHROMA_CLASS1_Q0: [u16; 9] = [2054, 3472, 5869, 14232, 18242, 20590, 26752, 32768, 0];
5132+pub const EOB_PT_128_CHROMA_CLASS1_Q1: [u16; 9] = [2310, 4160, 7471, 14997, 17931, 20768, 30240, 32768, 0];
5133+pub const EOB_PT_128_CHROMA_CLASS1: [u16; 9] = [6275, 9889, 14769, 23164, 27988, 30493, 32272, 32768, 0];
5134+pub const EOB_PT_128_CHROMA_CLASS1_Q3: [u16; 9] = [9165, 13282, 21150, 30286, 31894, 32571, 32712, 32768, 0];
5135+
5136+/// `EOB_PT_512_LUMA`'s class-1 sibling (`av1_default_eob_multi512_cdfs[q][0][1]`).
5137+pub const EOB_PT_512_LUMA_CLASS1_Q0: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5138+pub const EOB_PT_512_LUMA_CLASS1_Q1: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5139+pub const EOB_PT_512_LUMA_CLASS1: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5140+pub const EOB_PT_512_LUMA_CLASS1_Q3: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5141+
5142+/// `EOB_PT_512_CHROMA`'s class-1 sibling (`av1_default_eob_multi512_cdfs[q][1][1]`).
5143+pub const EOB_PT_512_CHROMA_CLASS1_Q0: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5144+pub const EOB_PT_512_CHROMA_CLASS1_Q1: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5145+pub const EOB_PT_512_CHROMA_CLASS1: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5146+pub const EOB_PT_512_CHROMA_CLASS1_Q3: [u16; 11] = [3277, 6554, 9830, 13107, 16384, 19661, 22938, 26214, 29491, 32768, 0];
5147+
5148+/// `EOB_PT_1024_LUMA`'s class-1 sibling (`av1_default_eob_multi1024_cdfs[q][0][1]`).
5149+pub const EOB_PT_1024_LUMA_CLASS1_Q0: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5150+pub const EOB_PT_1024_LUMA_CLASS1_Q1: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5151+pub const EOB_PT_1024_LUMA_CLASS1: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5152+pub const EOB_PT_1024_LUMA_CLASS1_Q3: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5153+
5154+/// `EOB_PT_1024_CHROMA`'s class-1 sibling (`av1_default_eob_multi1024_cdfs[q][1][1]`).
5155+pub const EOB_PT_1024_CHROMA_CLASS1_Q0: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5156+pub const EOB_PT_1024_CHROMA_CLASS1_Q1: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5157+pub const EOB_PT_1024_CHROMA_CLASS1: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5158+pub const EOB_PT_1024_CHROMA_CLASS1_Q3: [u16; 12] = [2979, 5958, 8937, 11916, 14895, 17873, 20852, 23831, 26810, 29789, 32768, 0];
5159+
crates/ec-av1/src/cdf_state.rsmodified+77 -30
@@ -214,17 +214,24 @@ pub(crate) struct Cdfs {
214 pub eob_pt_16_luma_class1: [u16; 6],214 pub eob_pt_16_luma_class1: [u16; 6],
215 /// `eob_pt_64_luma`'s class-1 sibling (r5), see `eob_pt_16_luma_class1`.215 /// `eob_pt_64_luma`'s class-1 sibling (r5), see `eob_pt_16_luma_class1`.
216 pub eob_pt_64_luma_class1: [u16; 8],216 pub eob_pt_64_luma_class1: [u16; 8],
217- /// `eob_pt_256_luma`'s class-1 sibling (lane-txselect r2): a 16x16 luma217+ /// `eob_pt_16_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
218- /// TU reaches `V_DCT`/`H_DCT` through the inter tx set218+ pub eob_pt_16_chroma_class1: [u16; 6],
219- /// `EXT_TX_SET_DTT9_IDTX_1DDCT`, and libaom keeps the eob class219+ /// `eob_pt_64_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
220- /// dimension at every size.220+ pub eob_pt_64_chroma_class1: [u16; 8],
221+ /// `eob_pt_128_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
222+ pub eob_pt_128_chroma_class1: [u16; 9],
223+ /// `eob_pt_256_luma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
221 pub eob_pt_256_luma_class1: [u16; 10],224 pub eob_pt_256_luma_class1: [u16; 10],
222- /// The chroma class-1 siblings (lane-txselect r2): an *inter* block's225+ /// `eob_pt_256_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
223- /// chroma TU inherits its luma unit's `tx_type`, so 1D classes reach
224- /// chroma too.
225 pub eob_pt_256_chroma_class1: [u16; 10],226 pub eob_pt_256_chroma_class1: [u16; 10],
226- pub eob_pt_64_chroma_class1: [u16; 8],227+ /// `eob_pt_512_luma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
227- pub eob_pt_16_chroma_class1: [u16; 6],228+ pub eob_pt_512_luma_class1: [u16; 11],
229+ /// `eob_pt_512_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
230+ pub eob_pt_512_chroma_class1: [u16; 11],
231+ /// `eob_pt_1024_luma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
232+ pub eob_pt_1024_luma_class1: [u16; 12],
233+ /// `eob_pt_1024_chroma`'s class-1 (`TX_CLASS_HORIZ`/`VERT`) sibling, see `eob_pt_16_luma_class1`.
234+ pub eob_pt_1024_chroma_class1: [u16; 12],
228 /// The end-of-block offset bit of a 16x16 luma transform.235 /// The end-of-block offset bit of a 16x16 luma transform.
229 pub eob_extra_luma_16: [[u16; 3]; 9],236 pub eob_extra_luma_16: [[u16; 3]; 9],
230 /// The same, for an 8x8 luma transform.237 /// The same, for an 8x8 luma transform.
@@ -633,10 +640,15 @@ impl Cdfs {
633 reset1(&mut self.eob_pt_16_luma);640 reset1(&mut self.eob_pt_16_luma);
634 reset1(&mut self.eob_pt_16_luma_class1);641 reset1(&mut self.eob_pt_16_luma_class1);
635 reset1(&mut self.eob_pt_64_luma_class1);642 reset1(&mut self.eob_pt_64_luma_class1);
643+ reset1(&mut self.eob_pt_16_chroma_class1);
644+ reset1(&mut self.eob_pt_64_chroma_class1);
645+ reset1(&mut self.eob_pt_128_chroma_class1);
636 reset1(&mut self.eob_pt_256_luma_class1);646 reset1(&mut self.eob_pt_256_luma_class1);
637 reset1(&mut self.eob_pt_256_chroma_class1);647 reset1(&mut self.eob_pt_256_chroma_class1);
638- reset1(&mut self.eob_pt_64_chroma_class1);648+ reset1(&mut self.eob_pt_512_luma_class1);
639- reset1(&mut self.eob_pt_16_chroma_class1);649+ reset1(&mut self.eob_pt_512_chroma_class1);
650+ reset1(&mut self.eob_pt_1024_luma_class1);
651+ reset1(&mut self.eob_pt_1024_chroma_class1);
640 reset2(&mut self.eob_extra_luma_16);652 reset2(&mut self.eob_extra_luma_16);
641 reset2(&mut self.eob_extra_luma_8);653 reset2(&mut self.eob_extra_luma_8);
642 reset2(&mut self.eob_extra_luma_4);654 reset2(&mut self.eob_extra_luma_4);
@@ -858,6 +870,27 @@ impl Cdfs {
858 cdf::EOB_PT_64_LUMA_CLASS1,870 cdf::EOB_PT_64_LUMA_CLASS1,
859 cdf::EOB_PT_64_LUMA_CLASS1_Q3,871 cdf::EOB_PT_64_LUMA_CLASS1_Q3,
860 ),872 ),
873+ eob_pt_16_chroma_class1: pick(
874+ q_ctx,
875+ cdf::EOB_PT_16_CHROMA_CLASS1_Q0,
876+ cdf::EOB_PT_16_CHROMA_CLASS1_Q1,
877+ cdf::EOB_PT_16_CHROMA_CLASS1,
878+ cdf::EOB_PT_16_CHROMA_CLASS1_Q3,
879+ ),
880+ eob_pt_64_chroma_class1: pick(
881+ q_ctx,
882+ cdf::EOB_PT_64_CHROMA_CLASS1_Q0,
883+ cdf::EOB_PT_64_CHROMA_CLASS1_Q1,
884+ cdf::EOB_PT_64_CHROMA_CLASS1,
885+ cdf::EOB_PT_64_CHROMA_CLASS1_Q3,
886+ ),
887+ eob_pt_128_chroma_class1: pick(
888+ q_ctx,
889+ cdf::EOB_PT_128_CHROMA_CLASS1_Q0,
890+ cdf::EOB_PT_128_CHROMA_CLASS1_Q1,
891+ cdf::EOB_PT_128_CHROMA_CLASS1,
892+ cdf::EOB_PT_128_CHROMA_CLASS1_Q3,
893+ ),
861 eob_pt_256_luma_class1: pick(894 eob_pt_256_luma_class1: pick(
862 q_ctx,895 q_ctx,
863 cdf::EOB_PT_256_LUMA_CLASS1_Q0,896 cdf::EOB_PT_256_LUMA_CLASS1_Q0,
@@ -872,19 +905,33 @@ impl Cdfs {
872 cdf::EOB_PT_256_CHROMA_CLASS1,905 cdf::EOB_PT_256_CHROMA_CLASS1,
873 cdf::EOB_PT_256_CHROMA_CLASS1_Q3,906 cdf::EOB_PT_256_CHROMA_CLASS1_Q3,
874 ),907 ),
875- eob_pt_64_chroma_class1: pick(908+ eob_pt_512_luma_class1: pick(
876 q_ctx,909 q_ctx,
877- cdf::EOB_PT_64_CHROMA_CLASS1_Q0,910+ cdf::EOB_PT_512_LUMA_CLASS1_Q0,
878- cdf::EOB_PT_64_CHROMA_CLASS1_Q1,911+ cdf::EOB_PT_512_LUMA_CLASS1_Q1,
879- cdf::EOB_PT_64_CHROMA_CLASS1,912+ cdf::EOB_PT_512_LUMA_CLASS1,
880- cdf::EOB_PT_64_CHROMA_CLASS1_Q3,913+ cdf::EOB_PT_512_LUMA_CLASS1_Q3,
881 ),914 ),
882- eob_pt_16_chroma_class1: pick(915+ eob_pt_512_chroma_class1: pick(
883 q_ctx,916 q_ctx,
884- cdf::EOB_PT_16_CHROMA_CLASS1_Q0,917+ cdf::EOB_PT_512_CHROMA_CLASS1_Q0,
885- cdf::EOB_PT_16_CHROMA_CLASS1_Q1,918+ cdf::EOB_PT_512_CHROMA_CLASS1_Q1,
886- cdf::EOB_PT_16_CHROMA_CLASS1,919+ cdf::EOB_PT_512_CHROMA_CLASS1,
887- cdf::EOB_PT_16_CHROMA_CLASS1_Q3,920+ cdf::EOB_PT_512_CHROMA_CLASS1_Q3,
921+ ),
922+ eob_pt_1024_luma_class1: pick(
923+ q_ctx,
924+ cdf::EOB_PT_1024_LUMA_CLASS1_Q0,
925+ cdf::EOB_PT_1024_LUMA_CLASS1_Q1,
926+ cdf::EOB_PT_1024_LUMA_CLASS1,
927+ cdf::EOB_PT_1024_LUMA_CLASS1_Q3,
928+ ),
929+ eob_pt_1024_chroma_class1: pick(
930+ q_ctx,
931+ cdf::EOB_PT_1024_CHROMA_CLASS1_Q0,
932+ cdf::EOB_PT_1024_CHROMA_CLASS1_Q1,
933+ cdf::EOB_PT_1024_CHROMA_CLASS1,
934+ cdf::EOB_PT_1024_CHROMA_CLASS1_Q3,
888 ),935 ),
889 eob_extra_luma_16: pick(936 eob_extra_luma_16: pick(
890 q_ctx,937 q_ctx,
@@ -1283,7 +1330,7 @@ impl Cdfs {
1283 br: &mut self.br_luma_32,1330 br: &mut self.br_luma_32,
1284 dc_sign: &mut self.dc_sign_luma,1331 dc_sign: &mut self.dc_sign_luma,
1285 tx_type: None,1332 tx_type: None,
1286- eob_pt_class1: None,1333+ eob_pt_class1: Some(&mut self.eob_pt_1024_luma_class1),
1287 },1334 },
1288 // lane-comppin r4 (REVERTED, see r4's own commit message):1335 // lane-comppin r4 (REVERTED, see r4's own commit message):
1289 // `Some(inter_tx_type_32)` looked wrong against aomdec's 32x321336 // `Some(inter_tx_type_32)` looked wrong against aomdec's 32x32
@@ -1307,7 +1354,7 @@ impl Cdfs {
1307 br: &mut self.br_luma_32,1354 br: &mut self.br_luma_32,
1308 dc_sign: &mut self.dc_sign_luma,1355 dc_sign: &mut self.dc_sign_luma,
1309 tx_type: Some(self.inter_tx_type_32.as_mut_slice()),1356 tx_type: Some(self.inter_tx_type_32.as_mut_slice()),
1310- eob_pt_class1: None,1357+ eob_pt_class1: Some(&mut self.eob_pt_1024_luma_class1),
1311 },1358 },
1312 TxbSet::Luma64 => TxbTables {1359 TxbSet::Luma64 => TxbTables {
1313 side: 32,1360 side: 32,
@@ -1319,7 +1366,7 @@ impl Cdfs {
1319 br: &mut self.br_luma_32,1366 br: &mut self.br_luma_32,
1320 dc_sign: &mut self.dc_sign_luma,1367 dc_sign: &mut self.dc_sign_luma,
1321 tx_type: None,1368 tx_type: None,
1322- eob_pt_class1: None,1369+ eob_pt_class1: Some(&mut self.eob_pt_1024_luma_class1),
1323 },1370 },
1324 TxbSet::Luma16 => TxbTables {1371 TxbSet::Luma16 => TxbTables {
1325 side: 16,1372 side: 16,
@@ -1403,7 +1450,7 @@ impl Cdfs {
1403 br: &mut self.br_luma_4,1450 br: &mut self.br_luma_4,
1404 dc_sign: &mut self.dc_sign_luma,1451 dc_sign: &mut self.dc_sign_luma,
1405 tx_type: Some(self.inter_tx_type_4.as_mut_slice()),1452 tx_type: Some(self.inter_tx_type_4.as_mut_slice()),
1406- eob_pt_class1: None,1453+ eob_pt_class1: Some(&mut self.eob_pt_16_luma_class1),
1407 },1454 },
1408 TxbSet::Luma4InterSet1 => TxbTables {1455 TxbSet::Luma4InterSet1 => TxbTables {
1409 side: 4,1456 side: 4,
@@ -1439,7 +1486,7 @@ impl Cdfs {
1439 br: &mut self.br_luma_8,1486 br: &mut self.br_luma_8,
1440 dc_sign: &mut self.dc_sign_luma,1487 dc_sign: &mut self.dc_sign_luma,
1441 tx_type: Some(self.inter_tx_type_8.as_mut_slice()),1488 tx_type: Some(self.inter_tx_type_8.as_mut_slice()),
1442- eob_pt_class1: None,1489+ eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1),
1443 },1490 },
1444 TxbSet::Luma8InterSet1 => TxbTables {1491 TxbSet::Luma8InterSet1 => TxbTables {
1445 side: 8,1492 side: 8,
@@ -1499,7 +1546,7 @@ impl Cdfs {
1499 br: &mut self.br_chroma_32,1546 br: &mut self.br_chroma_32,
1500 dc_sign: &mut self.dc_sign_chroma,1547 dc_sign: &mut self.dc_sign_chroma,
1501 tx_type: None,1548 tx_type: None,
1502- eob_pt_class1: None,1549+ eob_pt_class1: Some(&mut self.eob_pt_1024_chroma_class1),
1503 },1550 },
1504 TxbSet::LumaRect32x16 => TxbTables {1551 TxbSet::LumaRect32x16 => TxbTables {
1505 side: 32,1552 side: 32,
@@ -1511,7 +1558,7 @@ impl Cdfs {
1511 br: &mut self.br_luma_32,1558 br: &mut self.br_luma_32,
1512 dc_sign: &mut self.dc_sign_luma,1559 dc_sign: &mut self.dc_sign_luma,
1513 tx_type: None,1560 tx_type: None,
1514- eob_pt_class1: None,1561+ eob_pt_class1: Some(&mut self.eob_pt_512_luma_class1),
1515 },1562 },
1516 TxbSet::ChromaRect16x8 => TxbTables {1563 TxbSet::ChromaRect16x8 => TxbTables {
1517 side: 16,1564 side: 16,
@@ -1523,7 +1570,7 @@ impl Cdfs {
1523 br: &mut self.br_chroma_16,1570 br: &mut self.br_chroma_16,
1524 dc_sign: &mut self.dc_sign_chroma,1571 dc_sign: &mut self.dc_sign_chroma,
1525 tx_type: None,1572 tx_type: None,
1526- eob_pt_class1: None,1573+ eob_pt_class1: Some(&mut self.eob_pt_128_chroma_class1),
1527 },1574 },
1528 TxbSet::ChromaRect32x16 => TxbTables {1575 TxbSet::ChromaRect32x16 => TxbTables {
1529 side: 32,1576 side: 32,
@@ -1535,7 +1582,7 @@ impl Cdfs {
1535 br: &mut self.br_chroma_32,1582 br: &mut self.br_chroma_32,
1536 dc_sign: &mut self.dc_sign_chroma,1583 dc_sign: &mut self.dc_sign_chroma,
1537 tx_type: None,1584 tx_type: None,
1538- eob_pt_class1: None,1585+ eob_pt_class1: Some(&mut self.eob_pt_512_chroma_class1),
1539 },1586 },
1540 }1587 }
1541 }1588 }
crates/ec-av1/src/decode.rsmodified+853 -191
@@ -36,7 +36,7 @@ use crate::msac::SymbolDecoder;
36 use crate::mvstack::{36 use crate::mvstack::{
37 ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, LAST3_FRAME,37 ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, LAST3_FRAME,
38 MiGrid, MiInfo, NO_SIGN_BIAS, NeighbourRef, SignBiasTable, comp_reference_type_ctx,38 MiGrid, MiInfo, NO_SIGN_BIAS, NeighbourRef, SignBiasTable, comp_reference_type_ctx,
39- find_mv_stack, find_mv_stack_with_sign_bias, reference_mode_ctx, single_ref_ctx,39+ find_mv_stack_with_sign_bias, reference_mode_ctx,
40 single_ref_p1_ctx, single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx,40 single_ref_p1_ctx, single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx,
41 single_ref_p6_ctx, uni_comp_ref_p1_ctx,41 single_ref_p6_ctx, uni_comp_ref_p1_ctx,
42 };42 };
@@ -51,6 +51,8 @@ const PARTITION_HORZ_A: usize = 4;
51 const PARTITION_HORZ_B: usize = 5;51 const PARTITION_HORZ_B: usize = 5;
52 const PARTITION_VERT_A: usize = 6;52 const PARTITION_VERT_A: usize = 6;
53 const PARTITION_VERT_B: usize = 7;53 const PARTITION_VERT_B: usize = 7;
54+const PARTITION_HORZ_4: usize = 8;
55+const PARTITION_VERT_4: usize = 9;
54 const SB_MI: u32 = 16;56 const SB_MI: u32 = 16;
55 const BLOCK_MI: u32 = 8;57 const BLOCK_MI: u32 = 8;
56 58
@@ -1171,6 +1173,62 @@ pub(crate) fn obmc_hits() -> usize {
1171 OBMC_HITS.with(|c| c.get())1173 OBMC_HITS.with(|c| c.get())
1172 }1174 }
1173 1175
1176+// lane-scaledref r1: per-case firing counts for the scaled-reference gate
1177+// (class `gate-blind-to-feature`) -- a pixel match under an UNSCALED
1178+// reference would pass just as well and prove nothing, so the gate
1179+// hard-asserts each combination this round lifts actually occurred:
1180+// a compound block with a scaled tap, a warp block whose warp libaom
1181+// suppresses because the reference is scaled, an OBMC block, an interintra
1182+// block, and an 8x8 leaf.
1183+thread_local! {
1184+ static SCALED_COMPOUND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1185+ static SCALED_WARP_FALLBACK_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1186+ static SCALED_OBMC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1187+ static SCALED_INTERINTRA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1188+ static SCALED_BLOCK8_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1189+ static SCALED_WARP_SUPPRESSED_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1190+ static MIXED_SCALE_COMPOUND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1191+}
1192+
1193+/// Current value of [`MIXED_SCALE_COMPOUND_HITS`]: compound blocks with one
1194+/// scaled and one unscaled tap.
1195+pub(crate) fn mixed_scale_compound_hits() -> usize {
1196+ MIXED_SCALE_COMPOUND_HITS.with(|c| c.get())
1197+}
1198+
1199+/// Current value of [`SCALED_WARP_SUPPRESSED_HITS`]: blocks that would have
1200+/// read the 3-symbol `motion_mode_cdf` but read the 2-symbol `obmc_cdf`
1201+/// instead because their reference is scaled (libaom `motion_mode_allowed`,
1202+/// `blockd.h:1484`).
1203+pub(crate) fn scaled_warp_suppressed_hits() -> usize {
1204+ SCALED_WARP_SUPPRESSED_HITS.with(|c| c.get())
1205+}
1206+
1207+/// Current value of [`SCALED_COMPOUND_HITS`].
1208+pub(crate) fn scaled_compound_hits() -> usize {
1209+ SCALED_COMPOUND_HITS.with(|c| c.get())
1210+}
1211+
1212+/// Current value of [`SCALED_WARP_FALLBACK_HITS`].
1213+pub(crate) fn scaled_warp_fallback_hits() -> usize {
1214+ SCALED_WARP_FALLBACK_HITS.with(|c| c.get())
1215+}
1216+
1217+/// Current value of [`SCALED_OBMC_HITS`].
1218+pub(crate) fn scaled_obmc_hits() -> usize {
1219+ SCALED_OBMC_HITS.with(|c| c.get())
1220+}
1221+
1222+/// Current value of [`SCALED_INTERINTRA_HITS`].
1223+pub(crate) fn scaled_interintra_hits() -> usize {
1224+ SCALED_INTERINTRA_HITS.with(|c| c.get())
1225+}
1226+
1227+/// Current value of [`SCALED_BLOCK8_HITS`].
1228+pub(crate) fn scaled_block8_hits() -> usize {
1229+ SCALED_BLOCK8_HITS.with(|c| c.get())
1230+}
1231+
1174 // lane-motionmode round 3: same proof as [`OBMC_HITS`], narrowed to1232 // lane-motionmode round 3: same proof as [`OBMC_HITS`], narrowed to
1175 // `decode_inter_block8`'s own 8x8-leaf `read_motion_mode` -- a subset of1233 // `decode_inter_block8`'s own 8x8-leaf `read_motion_mode` -- a subset of
1176 // [`OBMC_HITS`] (both fire together on an 8x8 hit), lets the gate tell an1234 // [`OBMC_HITS`] (both fire together on an 8x8 hit), lets the gate tell an
@@ -1210,6 +1268,42 @@ pub(crate) fn compound_warp_hits() -> usize {
1210 COMPOUND_WARP_HITS.with(|c| c.get())1268 COMPOUND_WARP_HITS.with(|c| c.get())
1211 }1269 }
1212 1270
1271+// lane-gmaffine r1: how many blocks built their prediction from a
1272+// SIX-parameter (`AFFINE`) global-motion model through
1273+// `crate::warp::global_warp_params` -- the gate's proof that a stream really
1274+// carried an AFFINE `global_motion_params` AND that a block was predicted
1275+// with it, not merely that the header parsed one.
1276+thread_local! {
1277+ static AFFINE_GM_HITS: std::cell::Cell<usize> =
1278+ const { std::cell::Cell::new(0) };
1279+}
1280+
1281+/// Current value of [`AFFINE_GM_HITS`].
1282+pub(crate) fn affine_gm_hits() -> usize {
1283+ AFFINE_GM_HITS.with(|c| c.get())
1284+}
1285+
1286+// lane-gmaffine r1: 8x8-leaf-only counters -- how many `BLOCK_8X8` leaves
1287+// coded `GLOBALMV` (`GLOBALMV_HITS_8`) and how many built a real
1288+// `WARPED_CAUSAL` local-warp prediction there (`WARP_HITS_8`, incremented
1289+// only once `find_projection` returned a usable model, unlike
1290+// `WARP_SELECTED_HITS` which counts the symbol). Both are the 8x8 gates'
1291+// proof that the leaf path itself fired, not the 16x16+ one.
1292+thread_local! {
1293+ static GLOBALMV_HITS_8: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1294+ static WARP_HITS_8: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1295+}
1296+
1297+/// Current value of [`GLOBALMV_HITS_8`].
1298+pub(crate) fn globalmv_hits_8() -> usize {
1299+ GLOBALMV_HITS_8.with(|c| c.get())
1300+}
1301+
1302+/// Current value of [`WARP_HITS_8`].
1303+pub(crate) fn warp_hits_8() -> usize {
1304+ WARP_HITS_8.with(|c| c.get())
1305+}
1306+
1213 // How many blocks decoded `interintra == 1` with the non-wedge blended1307 // How many blocks decoded `interintra == 1` with the non-wedge blended
1214 // prediction applied (lane-interintra r1) -- the gate's proof that a1308 // prediction applied (lane-interintra r1) -- the gate's proof that a
1215 // stream actually exercised interintra.1309 // stream actually exercised interintra.
@@ -1380,6 +1474,26 @@ pub(crate) fn sb_ab_hits_by_arm() -> [usize; 4] {
1380 SB_AB_HITS.with(std::cell::Cell::get)1474 SB_AB_HITS.with(std::cell::Cell::get)
1381 }1475 }
1382 1476
1477+// lane-tx64x16: the two 1:4 superblock arms, counted per orientation --
1478+// `PARTITION_HORZ_4` (four 64x16 strips) and `PARTITION_VERT_4` (four 16x64
1479+// strips). Two counters, not one, because a gate that only proved "some 1:4
1480+// strip fired" would pass on a stream that never coded the other axis, and
1481+// every scan/context table this round added comes in a transposed pair.
1482+thread_local! {
1483+ static SB_RECT4_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1484+ static SB_RECT4_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1485+}
1486+
1487+/// Current value of `SB_RECT4_HORZ_HITS` (64x16 strips decoded).
1488+pub(crate) fn sb_rect4_horz_hits() -> usize {
1489+ SB_RECT4_HORZ_HITS.with(|c| c.get())
1490+}
1491+
1492+/// Current value of `SB_RECT4_VERT_HITS` (16x64 strips decoded).
1493+pub(crate) fn sb_rect4_vert_hits() -> usize {
1494+ SB_RECT4_VERT_HITS.with(|c| c.get())
1495+}
1496+
1383 // lane-rect64q r1: how many of [`decode_block_rect64`]'s three per-plane1497 // lane-rect64q r1: how many of [`decode_block_rect64`]'s three per-plane
1384 // dequant calls actually observed `CURRENT_Q_IDX != base_q_idx` -- proof the1498 // dequant calls actually observed `CURRENT_Q_IDX != base_q_idx` -- proof the
1385 // running-vs-stale-snapshot bug this round fixed is exercised by a gate, not1499 // running-vs-stale-snapshot bug this round fixed is exercised by a gate, not
@@ -1775,33 +1889,30 @@ fn base_ctx(
1775 // (lane-sbpart r8 root cause: `(row=1, col=0)` reads ctx 2 under the1889 // (lane-sbpart r8 root cause: `(row=1, col=0)` reads ctx 2 under the
1776 // square table vs the real ctx 13 the rect table gives).1890 // square table vs the real ctx 13 the rect table gives).
1777 TxClass::TwoD => {1891 TxClass::TwoD => {
1778- // OPEN (lane-rectsplit r3, measured): the two rect1892+ // lane-rectsplit r4: apply libaom's GENERATING RULE
1779- // transcriptions in [`cdf`] are packed `[col][row]` -- libaom's1893+ // (`txb_common.h:199-209`) directly instead of indexing the
1780- // `av1_nz_map_ctx_offset_32x64` is a FLAT 1024-entry array whose1894+ // transcribed 5x5 tables. `av1_nz_map_ctx_offset[tx_size]` is a
1781- // `coeff_idx` is COLUMN-major with stride 32 (`TX_CLASS_HORIZ`1895+ // FLAT array read at `coeff_idx`, and `coeff_idx` is COLUMN-major
1782- // reads its column back as `coeff_idx >> bhl`), and entries1896+ // (libaom decomposes it as `col = coeff_idx >> bhl`, `bhl` the
1783- // 0..5 / 32..35 match the generating rule (txb_common.h:199-209)1897+ // ADJUSTED height's log2, 5 for both `TX_64X32` and `TX_32X64`),
1784- // only under `flat[col * 32 + row]`;1898+ // so 32 consecutive entries are one COLUMN: the [`cdf`]
1785- // `nz_map_ctx_offset_tables_match_the_rect_rule` pins that.1899+ // transcriptions are `[col][row]` and this read had them as
1786- // Yet reading `[col][row]` here BREAKS1900+ // `[row][col]` -- the transpose, i.e. the other shape's rule with
1787- // `a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact`1901+ // 11 and 16 swapped. Same values as [`base_ctx_rect`] now, stated
1788- // (seed 43) while `[row][col]` breaks the split-transform SB gate1902+ // once; `base_ctx_rect_offsets_match_the_transcribed_tables_over_the_whole_domain`
1789- // (seed 50); swapping the shape test as well fails BOTH ways. So1903+ // pins the rule against the tables over their whole 5x5 domain.
1790- // this read is not the defect -- our (row, col) here come from a1904+ if let Some((w, h)) = rect_shape {
1791- // square 32x32-corner scan whose orientation relative to libaom's
1792- // column-major `coeff_idx` is what is really unproven, and each
1793- // "fix" only moves which rare corner position desyncs. Left at
1794- // the r1 reading, the one every merged gate is green under.
1795- // `EC_NZOFF_DUMP=1` prints every rect-shaped read.
1796- let table = match rect_shape {
1797- Some((w, h)) if w < h => &cdf::NZ_MAP_CTX_OFFSET_32X64,
1798- Some((w, h)) if w > h => &cdf::NZ_MAP_CTX_OFFSET_64X32,
1799- _ => &cdf::NZ_MAP_CTX_OFFSET_32,
1800- };
1801 if std::env::var_os("EC_NZOFF_DUMP").is_some() {1905 if std::env::var_os("EC_NZOFF_DUMP").is_some() {
1802- eprintln!("NZOFF side={side} shape={rect_shape:?} row={row} col={col}");1906+ eprintln!("NZOFF side={side} shape={w}x{h} row={row} col={col}");
1803 }1907 }
1804- ctx + table[row.min(4)][col.min(4)] as usize1908+ if w < h && row < 2 {
1909+ return ctx + 11;
1910+ }
1911+ if w > h && col < 2 {
1912+ return ctx + 16;
1913+ }
1914+ }
1915+ ctx + cdf::NZ_MAP_CTX_OFFSET_32[row.min(4)][col.min(4)] as usize
1805 }1916 }
1806 TxClass::Horiz => ctx + nz_map_ctx_offset_1d(col.min(31)),1917 TxClass::Horiz => ctx + nz_map_ctx_offset_1d(col.min(31)),
1807 TxClass::Vert => ctx + nz_map_ctx_offset_1d(row.min(31)),1918 TxClass::Vert => ctx + nz_map_ctx_offset_1d(row.min(31)),
@@ -1917,6 +2028,46 @@ const SCAN_8X16: [u16; 128] = [
1917 123, 103, 110, 117, 124, 111, 118, 125, 119, 126, 127,2028 123, 103, 110, 117, 124, 111, 118, 125, 119, 126, 127,
1918 ];2029 ];
1919 2030
2031+/// `Default_Scan_32x8`, this decoder's own row-major transcription (see
2032+/// [`SCAN_32X16`]'s doc comment) -- the chroma plane of a 64x16
2033+/// `PARTITION_HORZ_4` superblock strip (lane-tx64x16). libaom stores its
2034+/// scans column-major (`p = col * height + row`), so a naive copy of
2035+/// `default_scan_32x8` would silently install the TRANSPOSED 8x32 order
2036+/// (class reference-layout-not-spec): `default_scan_16x8`'s literal bytes
2037+/// are byte-identical to this decoder's [`SCAN_8X16`].
2038+const SCAN_32X8: [u16; 256] = [
2039+ 0, 32, 1, 64, 33, 2, 96, 65, 34, 3, 128, 97, 66, 35, 4, 160, 129, 98, 67, 36, 5, 192, 161, 130,
2040+ 99, 68, 37, 6, 224, 193, 162, 131, 100, 69, 38, 7, 225, 194, 163, 132, 101, 70, 39, 8, 226, 195,
2041+ 164, 133, 102, 71, 40, 9, 227, 196, 165, 134, 103, 72, 41, 10, 228, 197, 166, 135, 104, 73, 42,
2042+ 11, 229, 198, 167, 136, 105, 74, 43, 12, 230, 199, 168, 137, 106, 75, 44, 13, 231, 200, 169,
2043+ 138, 107, 76, 45, 14, 232, 201, 170, 139, 108, 77, 46, 15, 233, 202, 171, 140, 109, 78, 47, 16,
2044+ 234, 203, 172, 141, 110, 79, 48, 17, 235, 204, 173, 142, 111, 80, 49, 18, 236, 205, 174, 143,
2045+ 112, 81, 50, 19, 237, 206, 175, 144, 113, 82, 51, 20, 238, 207, 176, 145, 114, 83, 52, 21, 239,
2046+ 208, 177, 146, 115, 84, 53, 22, 240, 209, 178, 147, 116, 85, 54, 23, 241, 210, 179, 148, 117,
2047+ 86, 55, 24, 242, 211, 180, 149, 118, 87, 56, 25, 243, 212, 181, 150, 119, 88, 57, 26, 244, 213,
2048+ 182, 151, 120, 89, 58, 27, 245, 214, 183, 152, 121, 90, 59, 28, 246, 215, 184, 153, 122, 91,
2049+ 60, 29, 247, 216, 185, 154, 123, 92, 61, 30, 248, 217, 186, 155, 124, 93, 62, 31, 249, 218, 187,
2050+ 156, 125, 94, 63, 250, 219, 188, 157, 126, 95, 251, 220, 189, 158, 127, 252, 221, 190, 159, 253,
2051+ 222, 191, 254, 223, 255,
2052+];
2053+/// `Default_Scan_8x32`, [`SCAN_32X8`]'s transpose (the chroma plane of a
2054+/// 16x64 `PARTITION_VERT_4` strip).
2055+const SCAN_8X32: [u16; 256] = [
2056+ 0, 1, 8, 2, 9, 16, 3, 10, 17, 24, 4, 11, 18, 25, 32, 5, 12, 19, 26, 33, 40, 6, 13, 20, 27, 34,
2057+ 41, 48, 7, 14, 21, 28, 35, 42, 49, 56, 15, 22, 29, 36, 43, 50, 57, 64, 23, 30, 37, 44, 51, 58,
2058+ 65, 72, 31, 38, 45, 52, 59, 66, 73, 80, 39, 46, 53, 60, 67, 74, 81, 88, 47, 54, 61, 68, 75, 82,
2059+ 89, 96, 55, 62, 69, 76, 83, 90, 97, 104, 63, 70, 77, 84, 91, 98, 105, 112, 71, 78, 85, 92, 99,
2060+ 106, 113, 120, 79, 86, 93, 100, 107, 114, 121, 128, 87, 94, 101, 108, 115, 122, 129, 136, 95,
2061+ 102, 109, 116, 123, 130, 137, 144, 103, 110, 117, 124, 131, 138, 145, 152, 111, 118, 125, 132,
2062+ 139, 146, 153, 160, 119, 126, 133, 140, 147, 154, 161, 168, 127, 134, 141, 148, 155, 162, 169,
2063+ 176, 135, 142, 149, 156, 163, 170, 177, 184, 143, 150, 157, 164, 171, 178, 185, 192, 151, 158,
2064+ 165, 172, 179, 186, 193, 200, 159, 166, 173, 180, 187, 194, 201, 208, 167, 174, 181, 188, 195,
2065+ 202, 209, 216, 175, 182, 189, 196, 203, 210, 217, 224, 183, 190, 197, 204, 211, 218, 225, 232,
2066+ 191, 198, 205, 212, 219, 226, 233, 240, 199, 206, 213, 220, 227, 234, 241, 248, 207, 214, 221,
2067+ 228, 235, 242, 249, 215, 222, 229, 236, 243, 250, 223, 230, 237, 244, 251, 231, 238, 245, 252,
2068+ 239, 246, 253, 247, 254, 255,
2069+];
2070+
1920 /// [`neighbour`] with independent `w` (row stride)/`h` (row-bound) extents2071 /// [`neighbour`] with independent `w` (row stride)/`h` (row-bound) extents
1921 /// (lane-rectwire, mirrors [`record_rect`](Neighbours::record_rect)'s2072 /// (lane-rectwire, mirrors [`record_rect`](Neighbours::record_rect)'s
1922 /// asymmetric-extent pattern).2073 /// asymmetric-extent pattern).
@@ -1988,6 +2139,18 @@ fn dc_sign_ctx(vote: i32) -> usize {
1988 /// (spec 5.11.40): its bit length in unary, then that many of its own bits,2139 /// (spec 5.11.40): its bit length in unary, then that many of its own bits,
1989 /// most significant first — the exact inverse of [`crate::tile::write_golomb`].2140 /// most significant first — the exact inverse of [`crate::tile::write_golomb`].
1990 fn read_golomb(dec: &mut SymbolDecoder) -> Result<u32> {2141 fn read_golomb(dec: &mut SymbolDecoder) -> Result<u32> {
2142+ // lane-scaledref r1: this cap MASKS A REAL DEFECT and must not be lifted
2143+ // on its own. Reading up to 32 leading zeros (dav1d's `len < 32`; libaom
2144+ // itself calls a 21st bit a corrupt frame, decodetxb.c:30) is bit-identical
2145+ // for every tail any encoder writes -- our own writer tops out at 19 zeros
2146+ // (`tile::MAX_LEVEL == MAX_BR_LEVEL + (1 << 19)`) -- and was implemented
2147+ // and round-trip tested here (commit ee1f980, reverted in 314ee08). It
2148+ // turned `a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact`
2149+ // RED: seed 67 stops here today, and with the cap raised it decodes to a
2150+ // frame-0 LUMA MISMATCH instead. A key frame cannot legitimately carry a
2151+ // level above 1<<19, so the long tail is the SYMPTOM of an earlier desync
2152+ // in that intra rect64 stream -- class `refusal-hides-a-defect`. Lift this
2153+ // together with that defect's fix, not before.
1991 let mut length = 1u32;2154 let mut length = 1u32;
1992 while dec.literal(1) == 0 {2155 while dec.literal(1) == 0 {
1993 length += 1;2156 length += 1;
@@ -2180,7 +2343,8 @@ fn read_coeffs(
2180 let ec_trace_coeff = std::env::var_os("EC_TRACE_COEFF").is_some();2343 let ec_trace_coeff = std::env::var_os("EC_TRACE_COEFF").is_some();
2181 if ec_trace_coeff {2344 if ec_trace_coeff {
2182 let (rng, _) = dec.debug_state();2345 let (rng, _) = dec.debug_state();
2183- eprintln!("EC_COEFF_STEP tag=eob eob={eob} rng={rng}");2346+ let cls = match class { TxClass::TwoD => "2d", TxClass::Horiz => "horiz", TxClass::Vert => "vert" };
2347+ eprintln!("EC_COEFF_STEP tag=eob eob={eob} tx={tx_type:?} class={cls} rng={rng}");
2184 }2348 }
2185 let class_scan;2349 let class_scan;
2186 let scan: &[u16] = if class == TxClass::TwoD {2350 let scan: &[u16] = if class == TxClass::TwoD {
@@ -2205,6 +2369,15 @@ fn read_coeffs(
2205 } else {2369 } else {
2206 let ctx = base_ctx(&levels, side, row, col, class, rect_shape);2370 let ctx = base_ctx(&levels, side, row, col, class, rect_shape);
2207 let v = dec.symbol(&mut coding.base[ctx]) as i32;2371 let v = dec.symbol(&mut coding.base[ctx]) as i32;
2372+ if ec_trace_coeff {
2373+ let (rng, _) = dec.debug_state();
2374+ // `pos` in libaom's column-major `coeff_idx` convention, so
2375+ // the ladder lines up with instrumented `aomdec`.
2376+ let apos = col * side + row;
2377+ eprintln!(
2378+ "EC_COEFF_STEP tag=base c={scan_idx} pos={apos} ctx={ctx} level={v} rng={rng}"
2379+ );
2380+ }
2208 if trace {2381 if trace {
2209 eprintln!(2382 eprintln!(
2210 "TRACE base scan_idx={scan_idx} pos={pos} row={row} col={col} ctx={ctx} value={v}"2383 "TRACE base scan_idx={scan_idx} pos={pos} row={row} col={col} ctx={ctx} value={v}"
@@ -4304,6 +4477,13 @@ fn decode_rect_split(
4304 dc_sign_ctx(around[plane_idx].2),4477 dc_sign_ctx(around[plane_idx].2),
4305 default_tx,4478 default_tx,
4306 )?;4479 )?;
4480+ // The same delta_q proof the unsplit rect64 path records
4481+ // (lane-rectsplit r4: lifting the split-transform refusal moved
4482+ // superblock strips onto this path, so only counting there would
4483+ // leave the delta_q gate's counter silent for them).
4484+ if bw.max(bh) == 64 && CURRENT_Q_IDX.with(|c| c.get()) != i32::from(base_q_idx) {
4485+ RECT64_QIDX_DRIFT_HITS.with(|c| c.set(c.get() + 1));
4486+ }
4307 let residual = dequant_and_inverse_typed_wh(4487 let residual = dequant_and_inverse_typed_wh(
4308 &levels,4488 &levels,
4309 chroma_w,4489 chroma_w,
@@ -5070,20 +5250,55 @@ fn decode_block_rect64(
5070 };5250 };
5071 if depth != 0 {5251 if depth != 0 {
5072 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));5252 TX_DEPTH_HITS.with(|c| c.set(c.get() + 1));
5073- // lane-rectsplit r1/r3: [`decode_rect_split`] handles this shape too5253+ // lane-rectsplit r1/r4: the superblock-level strip splits its
5074- // and the per-unit port is wired here, but the gate5254+ // transform through the very same per-unit path as its 32x32-level
5075- // (`a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact`,5255+ // sibling (`sub_tx_size_map[TX_64X32] == TX_32X32`, square from the
5076- // `#[ignore]`d with its measurement) is still RED at seed 50 (luma5256+ // first step on, so `bw.min(bh) >> (depth - 1)` names the unit).
5077- // (171,56), ours 147 vs ffmpeg 148). r2 believed the cause was a5257+ let tx = bw.min(bh) >> (depth - 1);
5078- // transposed `av1_nz_map_ctx_offset` read; r3 measured that5258+ if std::env::var_os("EC_SBPART_DUMP64").is_some() {
5079- // transposing it turns THIS gate green and the merged SB-level5259+ eprintln!(
5080- // HORZ/VERT partition gate RED (seed 43), so the cause is still5260+ "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \
5081- // open. A refusal this lane cannot lift is not one it may ship wrong5261+ depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \
5082- // pixels past.5262+ angle_y={angle_delta_y}"
5083- return Err(unsupported(5263+ );
5084- "a superblock-level HORZ/VERT strip with a split transform (per-unit rect \5264+ }
5085- prediction is not ported)",5265+ let modes = RectStripModes {
5086- ));5266+ skip,
5267+ mode,
5268+ angle_delta_y,
5269+ uv_predict_mode,
5270+ angle_delta_uv,
5271+ alpha,
5272+ filter_intra,
5273+ smooth_neighbor,
5274+ smooth_neighbor_uv,
5275+ palette_y: palette_y
5276+ .as_ref()
5277+ .map(|p| p.map.iter().map(|&i| p.colors[i as usize]).collect()),
5278+ palette_uv: palette_uv.as_ref().map(|p| {
5279+ (
5280+ p.map.iter().map(|&i| p.u_colors[i as usize]).collect(),
5281+ p.map.iter().map(|&i| p.v_colors[i as usize]).collect(),
5282+ )
5283+ }),
5284+ };
5285+ if palette_y.is_some() || palette_uv.is_some() {
5286+ PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1));
5287+ }
5288+ decode_rect_split(
5289+ dec, cdfs, neighbours, at, bw, bh, tx, &modes, y, u, v, base_q_idx, reduced_tx_set,
5290+ )?;
5291+ // Same early-return palette stamp as [`decode_block_rect`]'s split arm
5292+ // (lane-palette2 r10): this return skips the fn's own tail, so a
5293+ // split-tx superblock strip would otherwise leave the above/left
5294+ // palette arrays holding a dead block's colours.
5295+ let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors));
5296+ neighbours.record_palette_y_rect(at, bw, bh, py_size, py_colors);
5297+ let (puv_size, puv_colors) =
5298+ palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors));
5299+ neighbours.record_palette_uv_rect(at, bw, bh, puv_size, puv_colors);
5300+ RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1));
5301+ return Ok(());
5087 }5302 }
5088 let (tx_w, tx_h) = (bw, bh);5303 let (tx_w, tx_h) = (bw, bh);
5089 let (cpx, cpy) = (px / 2, py / 2);5304 let (cpx, cpy) = (px / 2, py / 2);
@@ -5160,15 +5375,20 @@ fn decode_block_rect64(
5160 );5375 );
5161 } else {5376 } else {
5162 let around = neighbours.around_rect(at, bw, bh);5377 let around = neighbours.around_rect(at, bw, bh);
5163- // LUMA: a real 32x32 corner, embedded top-left of the true bw x bh5378+ // LUMA: the coded corner, embedded top-left of the true bw x bh grid
5164- // grid (see this function's own doc comment).5379+ // (see this function's own doc comment). A 64-length axis codes only
5380+ // its low 32 coefficients, so the corner is `min(bw, 32)` x
5381+ // `min(bh, 32)`: 32x32 under a 64x32/32x64 HORZ/VERT strip, and
5382+ // 32x16/16x32 under a 64x16/16x64 1:4 strip (lane-tx64x16).
5383+ let (luma_cw, luma_ch) = (bw.min(32), bh.min(32));
5165 let scan32 = default_scan(TX32);5384 let scan32 = default_scan(TX32);
5166- let mut luma_coding = cdfs.txb(TxbSet::Luma64, mode);
5167 if std::env::var_os("EC_TRACE_COEFF").is_some() {5385 if std::env::var_os("EC_TRACE_COEFF").is_some() {
5168 let (rng, _) = dec.debug_state();5386 let (rng, _) = dec.debug_state();
5169- eprintln!("EC_COEFF plane=0 row={mi_r} col={mi_c} tx_size=64corner rng={rng}");5387+ eprintln!("EC_COEFF plane=0 row={mi_r} col={mi_c} tx_size={luma_cw}x{luma_ch} rng={rng}");
5170 }5388 }
5171- let (luma_corner, luma_tx_type) = read_coeffs(5389+ let (luma_corner, luma_tx_type) = if (luma_cw, luma_ch) == (32, 32) {
5390+ let mut luma_coding = cdfs.txb(TxbSet::Luma64, mode);
5391+ read_coeffs(
5172 dec,5392 dec,
5173 &mut luma_coding,5393 &mut luma_coding,
5174 &scan32,5394 &scan32,
@@ -5176,14 +5396,42 @@ fn decode_block_rect64(
5176 dc_sign_ctx(around[0].2),5396 dc_sign_ctx(around[0].2),
5177 TxType::DctDct,5397 TxType::DctDct,
5178 Some((bw, bh)),5398 Some((bw, bh)),
5179- )?;5399+ )?
5400+ } else {
5401+ // `av1_get_adjusted_tx_size` (`blockd.h:1361`) maps TX_64X16 ->
5402+ // TX_32X16 and TX_16X64 -> TX_16X32, and `av1_scan_orders`
5403+ // (`scan.c`) gives both the very same `default_scan_32x16` /
5404+ // `default_scan_16x32` the 2:1 sizes use ("Half of the
5405+ // coefficients of tx64 at higher frequencies are set to zeros. So
5406+ // tx32's scan order is used"). `get_txsize_entropy_ctx` is
5407+ // (txsize_sqr + txsize_sqr_up + 1) >> 1 = (TX_16X16 + TX_64X64 +
5408+ // 1) >> 1 = TX_32X32 and `txsize_log2_minus4[TX_64X16]` is 5 (a
5409+ // 512-position eob group) -- BOTH identical to TX_32X16, so the
5410+ // 2:1 CDF set `LumaRect32x16` is bit-exact here and no new table
5411+ // is owed. `av1_nz_map_ctx_offset[TX_64X16]` is literally
5412+ // `av1_nz_map_ctx_offset_32x16` (`txb_common.c:340`), which is
5413+ // what `base_ctx_rect` computes at (32, 16).
5414+ let luma_scan: &[u16] = if bw == 64 { &SCAN_32X16 } else { &SCAN_16X32 };
5415+ let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, mode);
5416+ read_coeffs_rect(
5417+ dec,
5418+ &mut luma_coding,
5419+ luma_scan,
5420+ luma_cw,
5421+ luma_ch,
5422+ 0,
5423+ dc_sign_ctx(around[0].2),
5424+ TxType::DctDct,
5425+ )?
5426+ };
5180 if std::env::var_os("EC_TRACE_COEFF").is_some() {5427 if std::env::var_os("EC_TRACE_COEFF").is_some() {
5181 let (rng, _) = dec.debug_state();5428 let (rng, _) = dec.debug_state();
5182 eprintln!("EC_COEFF_VAL plane=0 row={mi_r} col={mi_c} rng={rng}");5429 eprintln!("EC_COEFF_VAL plane=0 row={mi_r} col={mi_c} rng={rng}");
5183 }5430 }
5184 let mut luma_levels = vec![0i32; bw * bh];5431 let mut luma_levels = vec![0i32; bw * bh];
5185- for row in 0..32 {5432+ for row in 0..luma_ch {
5186- luma_levels[row * bw..][..32].copy_from_slice(&luma_corner[row * 32..][..32]);5433+ luma_levels[row * bw..][..luma_cw]
5434+ .copy_from_slice(&luma_corner[row * luma_cw..][..luma_cw]);
5187 }5435 }
5188 {5436 {
5189 let cur = block_q_idx();5437 let cur = block_q_idx();
@@ -5236,9 +5484,20 @@ fn decode_block_rect64(
5236 // CHROMA: a real, untruncated chroma_w x chroma_h transform -- no5484 // CHROMA: a real, untruncated chroma_w x chroma_h transform -- no
5237 // corner crop needed (see doc comment).5485 // corner crop needed (see doc comment).
5238 let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));5486 let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
5239- let chroma_scan: &[u16] = if bw == 64 { &SCAN_32X16 } else { &SCAN_16X32 };5487+ // The chroma plane is never truncated (both axes <= 32 after
5488+ // subsampling). Under a 1:4 strip it is a true 32x8/8x32:
5489+ // `get_txsize_entropy_ctx(TX_32X8)` = (TX_8X8 + TX_32X32 + 1) >> 1 =
5490+ // TX_16X16 and `txsize_log2_minus4[TX_32X8]` = 4 (256 positions),
5491+ // both identical to TX_16X16 -- so [`TxbSet::Chroma16`] is the exact
5492+ // set, and only the scan is new (lane-tx64x16).
5493+ let (chroma_set, chroma_scan): (TxbSet, &[u16]) = match (bw, bh) {
5494+ (64, 16) => (TxbSet::Chroma16, &SCAN_32X8),
5495+ (16, 64) => (TxbSet::Chroma16, &SCAN_8X32),
5496+ (64, _) => (TxbSet::ChromaRect32x16, &SCAN_32X16),
5497+ _ => (TxbSet::ChromaRect32x16, &SCAN_16X32),
5498+ };
5240 let u_skip_ctx = usize::from(around[1].0) + usize::from(around[1].1);5499 let u_skip_ctx = usize::from(around[1].0) + usize::from(around[1].1);
5241- let mut u_coding = cdfs.txb(TxbSet::ChromaRect32x16, uv_predict_mode);5500+ let mut u_coding = cdfs.txb(chroma_set, uv_predict_mode);
5242 if std::env::var_os("EC_TRACE_COEFF").is_some() {5501 if std::env::var_os("EC_TRACE_COEFF").is_some() {
5243 let (rng, _) = dec.debug_state();5502 let (rng, _) = dec.debug_state();
5244 eprintln!("EC_COEFF plane=1 row={mi_r} col={mi_c} tx_size=rect32x16 rng={rng}");5503 eprintln!("EC_COEFF plane=1 row={mi_r} col={mi_c} tx_size=rect32x16 rng={rng}");
@@ -5292,7 +5551,7 @@ fn decode_block_rect64(
5292 smooth_neighbor_uv,5551 smooth_neighbor_uv,
5293 );5552 );
5294 let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1);5553 let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1);
5295- let mut v_coding = cdfs.txb(TxbSet::ChromaRect32x16, uv_predict_mode);5554+ let mut v_coding = cdfs.txb(chroma_set, uv_predict_mode);
5296 if std::env::var_os("EC_TRACE_COEFF").is_some() {5555 if std::env::var_os("EC_TRACE_COEFF").is_some() {
5297 let (rng, _) = dec.debug_state();5556 let (rng, _) = dec.debug_state();
5298 eprintln!("EC_COEFF plane=2 row={mi_r} col={mi_c} tx_size=rect32x16 rng={rng}");5557 eprintln!("EC_COEFF plane=2 row={mi_r} col={mi_c} tx_size=rect32x16 rng={rng}");
@@ -5356,6 +5615,11 @@ fn decode_block_rect64(
5356 neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip);5615 neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip);
5357 neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0);5616 neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0);
5358 SB_RECT_HITS.with(|c| c.set(c.get() + 1));5617 SB_RECT_HITS.with(|c| c.set(c.get() + 1));
5618+ match (bw, bh) {
5619+ (64, 16) => SB_RECT4_HORZ_HITS.with(|c| c.set(c.get() + 1)),
5620+ (16, 64) => SB_RECT4_VERT_HITS.with(|c| c.set(c.get() + 1)),
5621+ _ => {}
5622+ }
5359 if std::env::var_os("EC_AV1_TRACE").is_some() {5623 if std::env::var_os("EC_AV1_TRACE").is_some() {
5360 let (rng, _) = dec.debug_state();5624 let (rng, _) = dec.debug_state();
5361 eprintln!("TRACE_RECT64_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} rng={rng}");5625 eprintln!("TRACE_RECT64_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} rng={rng}");
@@ -9741,10 +10005,49 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
9741 }10005 }
9742 }10006 }
9743 }10007 }
10008+ PARTITION_HORZ_4 | PARTITION_VERT_4 => {
10009+ // lane-tx64x16: the 1:4 pair at 64x64 -- four 64x16 (or
10010+ // 16x64) strips in raster order. `decode_partition`
10011+ // (`decodeframe.c`) steps by `quarter_step = mi_size / 4`
10012+ // (4 mi = 16 px = one SUB unit here) and BREAKS at the
10013+ // frame edge for `i > 0`, so a partial superblock codes
10014+ // only the strips whose origin is inside the frame.
10015+ let horz = part == PARTITION_HORZ_4;
10016+ for i in 0..4 {
10017+ let step_mi = i * (SB_MI as usize / 4);
10018+ let (this_r_mi, this_c_mi) = if horz {
10019+ (sb_r as usize * SB_MI as usize + step_mi, sb_c as usize * SB_MI as usize)
10020+ } else {
10021+ (sb_r as usize * SB_MI as usize, sb_c as usize * SB_MI as usize + step_mi)
10022+ };
10023+ if i > 0
10024+ && (this_r_mi >= mi_rows as usize || this_c_mi >= mi_cols as usize)
10025+ {
10026+ break;
10027+ }
10028+ let strip_at = if horz { (at.0 + i, at.1) } else { (at.0, at.1 + i) };
10029+ let (bw, bh) = if horz { (64, 16) } else { (16, 64) };
10030+ decode_block_rect64(
10031+ &mut dec,
10032+ &mut cdfs,
10033+ &mut neighbours,
10034+ strip_at,
10035+ bw,
10036+ bh,
10037+ &mut y,
10038+ &mut u,
10039+ &mut v,
10040+ enable_filter_intra,
10041+ allow_screen_content_tools,
10042+ base_q_idx,
10043+ tx_select,
10044+ reduced_tx_set,
10045+ )?;
10046+ }
10047+ }
9744 _ => {10048 _ => {
9745 return Err(unsupported(10049 return Err(unsupported(
9746- "a superblock-level 1:4 partition (PARTITION_HORZ_4/VERT_4 at 64x64, \10050+ "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4",
9747- four 64x16/16x64 strips)",
9748 ));10051 ));
9749 }10052 }
9750 }10053 }
@@ -10596,6 +10899,12 @@ fn num_proj_ref(
10596 /// decoder's own overlap sizes ever produce (luma 8/16/32, chroma 4/8/16)10899 /// decoder's own overlap sizes ever produce (luma 8/16/32, chroma 4/8/16)
10597 /// are transcribed.10900 /// are transcribed.
10598 fn obmc_mask(len: usize) -> &'static [u8] {10901 fn obmc_mask(len: usize) -> &'static [u8] {
10902+ // lane-gmaffine r1: the two SHORT masks (libaom `reconinter.c`
10903+ // `obmc_mask_1`/`obmc_mask_2`) -- an 8x8 leaf's chroma plane is 4x4, so
10904+ // its overlap is 2 (and 1 at a half-block edge). Unreachable until this
10905+ // round wired interior 16x16 splits down to real 8x8 leaves, where the
10906+ // old `unreachable!()` below fired as a hard panic.
10907+ const M1: [u8; 1] = [64];
10599 // lane-inter8 r1: `obmc_mask_2` (`reconinter.c` 753) -- reached by the10908 // lane-inter8 r1: `obmc_mask_2` (`reconinter.c` 753) -- reached by the
10600 // LEFT pass of an 8x8 block's chroma plane (overlap 4 luma columns, 210909 // LEFT pass of an 8x8 block's chroma plane (overlap 4 luma columns, 2
10601 // chroma), which only became live once 8x8 inter leaves stopped being10910 // chroma), which only became live once 8x8 inter leaves stopped being
@@ -10611,6 +10920,7 @@ fn obmc_mask(len: usize) -> &'static [u8] {
10611 61, 62, 64, 64, 64, 64, 64, 64, 64, 64,10920 61, 62, 64, 64, 64, 64, 64, 64, 64, 64,
10612 ];10921 ];
10613 match len {10922 match len {
10923+ 1 => &M1,
10614 2 => &M2,10924 2 => &M2,
10615 4 => &M4,10925 4 => &M4,
10616 8 => &M8,10926 8 => &M8,
@@ -10655,8 +10965,14 @@ fn obmc_neighbour_pred(
10655 luma: bool,10965 luma: bool,
10656 h_kind: mc::InterpFilterKind,10966 h_kind: mc::InterpFilterKind,
10657 v_kind: mc::InterpFilterKind,10967 v_kind: mc::InterpFilterKind,
10968+ // lane-scaledref r1: spec 7.11.3.3's x_scale_fp for THIS neighbour's own
10969+ // reference (derived from luma widths, applied unchanged to chroma whose
10970+ // x_q4 is already in its own plane's pixel units). `REF_NO_SCALE` takes
10971+ // the ordinary stride-1 path bit-exact.
10972+ x_scale_fp: i64,
10658 ) -> Vec<u16> {10973 ) -> Vec<u16> {
10659 let mut out = vec![0u16; w * h];10974 let mut out = vec![0u16; w * h];
10975+ if x_scale_fp == mc::REF_NO_SCALE {
10660 mc::predict_with_filters(10976 mc::predict_with_filters(
10661 &refplane.data,10977 &refplane.data,
10662 refplane.width,10978 refplane.width,
@@ -10670,6 +10986,22 @@ fn obmc_neighbour_pred(
10670 v_kind,10986 v_kind,
10671 &mut out,10987 &mut out,
10672 );10988 );
10989+ } else {
10990+ mc::predict_scaled(
10991+ &refplane.data,
10992+ refplane.width,
10993+ refplane.true_width,
10994+ refplane.true_height,
10995+ mv_to_q4(x, mv.1, luma),
10996+ mv_to_q4(y, mv.0, luma),
10997+ x_scale_fp,
10998+ w,
10999+ h,
11000+ h_kind,
11001+ v_kind,
11002+ &mut out,
11003+ );
11004+ }
10673 out11005 out
10674 }11006 }
10675 11007
@@ -10830,6 +11162,12 @@ fn obmc_blend(
10830 ref_v: &PlaneBuf,11162 ref_v: &PlaneBuf,
10831 other_refs: &RefSlots,11163 other_refs: &RefSlots,
10832 interp_fixed: Option<mc::InterpFilterKind>,11164 interp_fixed: Option<mc::InterpFilterKind>,
11165+ // lane-scaledref r1: this frame's own coded luma width -- each OBMC
11166+ // neighbour is re-predicted against ITS OWN reference, which may be
11167+ // scaled differently from this block's (spec 7.11.3.3 / libaom
11168+ // `av1_setup_build_prediction_by_above_pred` passing that ref's own
11169+ // `scale_factors`).
11170+ frame_width: usize,
10833 pred_y: &mut [u16],11171 pred_y: &mut [u16],
10834 pred_u: &mut [u16],11172 pred_u: &mut [u16],
10835 pred_v: &mut [u16],11173 pred_v: &mut [u16],
@@ -10845,6 +11183,11 @@ fn obmc_blend(
10845 };11183 };
10846 let overlap_above = write_h / 2;11184 let overlap_above = write_h / 2;
10847 let overlap_left = write_w / 2;11185 let overlap_left = write_w / 2;
11186+ // lane-inter8 r1 / lane-scaledref r1: `av1_skip_u4x4_pred_in_obmc`
11187+ // (`reconinter.c` 820, `DISABLE_CHROMA_U8X8_OBMC == 0` -- "one-sided
11188+ // obmc") returns `dir == 0` when the chroma plane's own block is
11189+ // BLOCK_4X4/8X4/4X8 (an 8x8, 16x8 or 8x16 luma block at 4:2:0): the
11190+ // ABOVE pass skips chroma entirely, the LEFT pass still blends it.
10848 let skip_chroma_above = matches!((write_w, write_h), (8, 8) | (16, 8) | (8, 16));11191 let skip_chroma_above = matches!((write_w, write_h), (8, 8) | (16, 8) | (8, 16));
10849 11192
10850 for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4))11193 for (off4, span4, nb) in overlappable_above(grid, mi_row, mi_col, bw4, mi_cols, max_nb(bw4))
@@ -10853,25 +11196,25 @@ fn obmc_blend(
10853 // (this decoder's own outer block-loop granularity), one step11196 // (this decoder's own outer block-loop granularity), one step
10854 // coarser than the mi(4px) units `overlappable_above` walks in --11197 // coarser than the mi(4px) units `overlappable_above` walks in --
10855 // divide back down to that column.11198 // divide back down to that column.
11199+ // lane-gmaffine r2: the neighbour's OWN mi-granular filter
11200+ // (libaom `av1_setup_build_prediction_by_above_pred` reads
11201+ // `above_mbmi->interp_filters`); the 16px-granular `Neighbours` slot
11202+ // stays as the fallback for paths that do not record one yet
11203+ // (compound), which is what every earlier round used.
10856 let (h_kind, v_kind) = neighbour_filter(11204 let (h_kind, v_kind) = neighbour_filter(
10857 interp_fixed,11205 interp_fixed,
10858 neighbours.above_filter[mi_col + off4],11206 neighbours.above_filter[mi_col + off4],
10859 );11207 );
10860 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;11208 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
11209+ let nb_scale = mc::scale_factor(ny.width, frame_width);
10861 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);11210 let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4);
10862- let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind);11211+ let tmp_y = obmc_neighbour_pred(ny, px + ox, py, nb.mv, bw, bh, true, h_kind, v_kind, nb_scale);
10863 obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y);11212 obmc_blend_v(pred_y, side, ox, 0, bw, bh, &tmp_y);
10864- // lane-inter8 r1: `av1_skip_u4x4_pred_in_obmc` (`reconinter.c` 820,
10865- // `DISABLE_CHROMA_U8X8_OBMC == 0` -- "one-sided obmc"): when the
10866- // chroma plane's own block size is BLOCK_4X4/8X4/4X8 (a 8x8, 16x8 or
10867- // 8x16 luma block at 4:2:0), the ABOVE pass skips chroma entirely
10868- // while the LEFT pass still blends it. Blending chroma here as well
10869- // would both mis-predict every 8x8 leaf and ask for an overlap of 2.
10870 if !skip_chroma_above {11213 if !skip_chroma_above {
10871 let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2);11214 let (cbw, cbh, cox) = (bw / 2, overlap_above / 2, ox / 2);
10872- let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);11215+ let tmp_u = obmc_neighbour_pred(nu, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind, nb_scale);
10873 obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u);11216 obmc_blend_v(pred_u, chroma_side, cox, 0, cbw, cbh, &tmp_u);
10874- let tmp_v = obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind);11217+ let tmp_v = obmc_neighbour_pred(nv, cpx + cox, cpy, nb.mv, cbw, cbh, false, h_kind, v_kind, nb_scale);
10875 obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v);11218 obmc_blend_v(pred_v, chroma_side, cox, 0, cbw, cbh, &tmp_v);
10876 }11219 }
10877 }11220 }
@@ -10882,13 +11225,14 @@ fn obmc_blend(
10882 neighbours.left_filter[mi_row + off4],11225 neighbours.left_filter[mi_row + off4],
10883 );11226 );
10884 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;11227 let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?;
11228+ let nb_scale = mc::scale_factor(ny.width, frame_width);
10885 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);11229 let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4);
10886- let tmp_y = obmc_neighbour_pred(ny, px, py + oy, nb.mv, bw, bh, true, h_kind, v_kind);11230+ let tmp_y = obmc_neighbour_pred(ny, px, py + oy, nb.mv, bw, bh, true, h_kind, v_kind, nb_scale);
10887 obmc_blend_h(pred_y, side, 0, oy, bw, bh, &tmp_y);11231 obmc_blend_h(pred_y, side, 0, oy, bw, bh, &tmp_y);
10888 let (cbw, cbh, coy) = (overlap_left / 2, bh / 2, oy / 2);11232 let (cbw, cbh, coy) = (overlap_left / 2, bh / 2, oy / 2);
10889- let tmp_u = obmc_neighbour_pred(nu, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind);11233+ let tmp_u = obmc_neighbour_pred(nu, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind, nb_scale);
10890 obmc_blend_h(pred_u, chroma_side, 0, coy, cbw, cbh, &tmp_u);11234 obmc_blend_h(pred_u, chroma_side, 0, coy, cbw, cbh, &tmp_u);
10891- let tmp_v = obmc_neighbour_pred(nv, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind);11235+ let tmp_v = obmc_neighbour_pred(nv, cpx, cpy + coy, nb.mv, cbw, cbh, false, h_kind, v_kind, nb_scale);
10892 obmc_blend_h(pred_v, chroma_side, 0, coy, cbw, cbh, &tmp_v);11236 obmc_blend_h(pred_v, chroma_side, 0, coy, cbw, cbh, &tmp_v);
10893 }11237 }
10894 Ok(())11238 Ok(())
@@ -11959,14 +12303,23 @@ fn decode_inter_block(
11959 );12303 );
11960 block_filter = resolved_filter;12304 block_filter = resolved_filter;
11961 12305
11962- // lane-superres r9: a scaled reference in a COMPOUND_REFERENCE12306+ // lane-scaledref r1: each compound tap scales INDEPENDENTLY off
11963- // block (either tap) is not wired -- mc::predict_compound_intermediate12307+ // its own stored reference's luma width (spec 7.11.3.3 derives
11964- // has no scaled counterpart yet -- refuse by name rather than12308+ // x_scale_fp per reference; libaom `av1_setup_pre_planes` builds
11965- // silently sample it unscaled.12309+ // one `scale_factors` per `ref_frame`), so the two taps can carry
11966- if py0.width != frame_width || py1.width != frame_width {12310+ // different ratios in the same block. `REF_NO_SCALE` reduces
11967- return Err(unsupported(12311+ // `predict_compound_intermediate`'s walk to the ordinary
11968- "a compound-reference block with a scaled reference (superres, unimplemented)",12312+ // stride-1 one, so the unscaled case is unchanged.
11969- ));12313+ let scale0 = mc::scale_factor(py0.width, frame_width);
12314+ let scale1 = mc::scale_factor(py1.width, frame_width);
12315+ if scale0 != mc::REF_NO_SCALE || scale1 != mc::REF_NO_SCALE {
12316+ SCALED_COMPOUND_HITS.with(|c| c.set(c.get() + 1));
12317+ }
12318+ // lane-scaledref r2: the MIXED case -- one tap scaled, the other
12319+ // not -- is the one an all-frames-scaled recipe never produces,
12320+ // and the one a single shared scale factor would get wrong.
12321+ if (scale0 == mc::REF_NO_SCALE) != (scale1 == mc::REF_NO_SCALE) {
12322+ MIXED_SCALE_COMPOUND_HITS.with(|c| c.set(c.get() + 1));
11970 }12323 }
11971 12324
11972 let mut inter0_y = vec![0i32; side * side];12325 let mut inter0_y = vec![0i32; side * side];
@@ -11977,6 +12330,7 @@ fn decode_inter_block(
11977 py0.true_height,12330 py0.true_height,
11978 mv_to_q4(px, mv0.1, true),12331 mv_to_q4(px, mv0.1, true),
11979 mv_to_q4(py, mv0.0, true),12332 mv_to_q4(py, mv0.0, true),
12333+ scale0,
11980 side,12334 side,
11981 side,12335 side,
11982 h_filter,12336 h_filter,
@@ -12001,6 +12355,7 @@ fn decode_inter_block(
12001 py1.true_height,12355 py1.true_height,
12002 mv_to_q4(px, mv1.1, true),12356 mv_to_q4(px, mv1.1, true),
12003 mv_to_q4(py, mv1.0, true),12357 mv_to_q4(py, mv1.0, true),
12358+ scale1,
12004 side,12359 side,
12005 side,12360 side,
12006 h_filter,12361 h_filter,
@@ -12046,6 +12401,7 @@ fn decode_inter_block(
12046 pu0.true_height,12401 pu0.true_height,
12047 mv_to_q4(cpx, mv0.1, false),12402 mv_to_q4(cpx, mv0.1, false),
12048 mv_to_q4(cpy, mv0.0, false),12403 mv_to_q4(cpy, mv0.0, false),
12404+ scale0,
12049 chroma_side,12405 chroma_side,
12050 chroma_side,12406 chroma_side,
12051 h_filter,12407 h_filter,
@@ -12072,6 +12428,7 @@ fn decode_inter_block(
12072 pu1.true_height,12428 pu1.true_height,
12073 mv_to_q4(cpx, mv1.1, false),12429 mv_to_q4(cpx, mv1.1, false),
12074 mv_to_q4(cpy, mv1.0, false),12430 mv_to_q4(cpy, mv1.0, false),
12431+ scale1,
12075 chroma_side,12432 chroma_side,
12076 chroma_side,12433 chroma_side,
12077 h_filter,12434 h_filter,
@@ -12114,6 +12471,7 @@ fn decode_inter_block(
12114 pv0.true_height,12471 pv0.true_height,
12115 mv_to_q4(cpx, mv0.1, false),12472 mv_to_q4(cpx, mv0.1, false),
12116 mv_to_q4(cpy, mv0.0, false),12473 mv_to_q4(cpy, mv0.0, false),
12474+ scale0,
12117 chroma_side,12475 chroma_side,
12118 chroma_side,12476 chroma_side,
12119 h_filter,12477 h_filter,
@@ -12140,6 +12498,7 @@ fn decode_inter_block(
12140 pv1.true_height,12498 pv1.true_height,
12141 mv_to_q4(cpx, mv1.1, false),12499 mv_to_q4(cpx, mv1.1, false),
12142 mv_to_q4(cpy, mv1.0, false),12500 mv_to_q4(cpy, mv1.0, false),
12501+ scale1,
12143 chroma_side,12502 chroma_side,
12144 chroma_side,12503 chroma_side,
12145 h_filter,12504 h_filter,
@@ -12600,8 +12959,27 @@ fn decode_inter_block(
12600 // `motion_mode_allowed` reads the 3-symbol `motion_mode_cdf`12959 // `motion_mode_allowed` reads the 3-symbol `motion_mode_cdf`
12601 // instead of the 2-symbol `obmc_cdf` exactly when12960 // instead of the 2-symbol `obmc_cdf` exactly when
12602 // `num_proj_ref >= 1` under `allow_warped_motion`.12961 // `num_proj_ref >= 1` under `allow_warped_motion`.
12962+ // lane-scaledref r2: libaom `motion_mode_allowed`
12963+ // (`blockd.h:1484`) requires
12964+ // `!av1_is_scaled(block_ref_scale_factors[0])` for
12965+ // WARPED_CAUSAL -- under a scaled reference (superres) the
12966+ // block reads the 2-symbol `obmc_cdf`, never the 3-symbol
12967+ // `motion_mode_cdf`. Reading the wrong alphabet here narrows
12968+ // the arithmetic coder by the wrong amount and predicts the
12969+ // rest of the tile off a diverged state: it was silently
12970+ // wrong pixels (r1's `--enable-warped-motion=1` superres
12971+ // mismatch), not a desync error.
12972+ let ref_is_scaled =
12973+ mc::scale_factor(py_ref.width, frame_width) != mc::REF_NO_SCALE;
12603 let warp_eligible = allow_warped_motion12974 let warp_eligible = allow_warped_motion
12975+ && !ref_is_scaled
12604 && num_proj_ref(grid, mi_row, mi_col, bw4, bh4, mi_cols as usize, mi_rows as usize, ref_frame) >= 1;12976 && num_proj_ref(grid, mi_row, mi_col, bw4, bh4, mi_cols as usize, mi_rows as usize, ref_frame) >= 1;
12977+ if allow_warped_motion
12978+ && ref_is_scaled
12979+ && num_proj_ref(grid, mi_row, mi_col, bw4, bh4, mi_cols as usize, mi_rows as usize, ref_frame) >= 1
12980+ {
12981+ SCALED_WARP_SUPPRESSED_HITS.with(|c| c.set(c.get() + 1));
12982+ }
12605 if warp_eligible {12983 if warp_eligible {
12606 let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]);12984 let mode = dec.symbol(&mut cdfs.motion_mode[bsize_idx]);
12607 match mode {12985 match mode {
@@ -12684,6 +13062,9 @@ fn decode_inter_block(
12684 let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize];13062 let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize];
12685 if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid {13063 if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid {
12686 warp_params = crate::warp::global_warp_params(gm_ref.params);13064 warp_params = crate::warp::global_warp_params(gm_ref.params);
13065+ if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine {
13066+ AFFINE_GM_HITS.with(|c| c.set(c.get() + 1));
13067+ }
12687 }13068 }
12688 if std::env::var_os("EC_AV1_TELL").is_some() {13069 if std::env::var_os("EC_AV1_TELL").is_some() {
12689 eprintln!(13070 eprintln!(
@@ -12781,13 +13162,30 @@ fn decode_inter_block(
12781 // (warp_params/obmc_selected/interintra_mode are all resolved by13162 // (warp_params/obmc_selected/interintra_mode are all resolved by
12782 // this point, every symbol for this block already read).13163 // this point, every symbol for this block already read).
12783 let luma_scale = mc::scale_factor(py_ref.width, frame_width);13164 let luma_scale = mc::scale_factor(py_ref.width, frame_width);
12784- if luma_scale != mc::REF_NO_SCALE13165+ if luma_scale != mc::REF_NO_SCALE {
12785- && (warp_params.is_some() || obmc_selected || interintra_mode.is_some())13166+ // lane-scaledref r1: libaom `allow_warp`
12786- {13167+ // (av1/common/reconinter.c:41) suppresses BOTH local and
13168+ // global warp under a scaled reference and predicts
13169+ // translationally instead -- that fallback is implemented
13170+ // below, but the one real aomenc stream this round found
13171+ // that reaches it (`--enable-warped-motion=1`,
13172+ // `--superres-denominator=16`, seed 47) still mismatches
13173+ // ffmpeg at frame 2 luma, so the case stays refused by name
13174+ // until it has a green gate rather than shipping wrong
13175+ // pixels behind a lifted refusal.
13176+ if warp_params.is_some() {
13177+ SCALED_WARP_FALLBACK_HITS.with(|c| c.set(c.get() + 1));
12787 return Err(unsupported(13178 return Err(unsupported(
12788- "warp/OBMC/interintra prediction with a scaled reference (superres, unimplemented)",13179+ "warp prediction with a scaled reference (superres, unimplemented)",
12789 ));13180 ));
12790 }13181 }
13182+ if obmc_selected {
13183+ SCALED_OBMC_HITS.with(|c| c.set(c.get() + 1));
13184+ }
13185+ if interintra_mode.is_some() {
13186+ SCALED_INTERINTRA_HITS.with(|c| c.set(c.get() + 1));
13187+ }
13188+ }
12791 13189
12792 let mut pred_y = vec![0u16; side * side];13190 let mut pred_y = vec![0u16; side * side];
12793 let mut pred_u = vec![0u16; chroma_side * chroma_side];13191 let mut pred_u = vec![0u16; chroma_side * chroma_side];
@@ -12877,12 +13275,26 @@ fn decode_inter_block(
12877 );13275 );
12878 }13276 }
12879 13277
12880- if let Some(params) = &warp_params {13278+ // lane-scaledref r1: libaom `allow_warp` (av1/common/reconinter.c:41)
13279+ // opens with `if (av1_is_scaled(sf)) return 0;` -- BOTH local
13280+ // (`wm_params`) and global warp fall back to the translational
13281+ // prediction above when the reference is scaled, even though the
13282+ // motion_mode symbol was still read and warp_params still
13283+ // resolved. Suppress the warp, keep every symbol read.
13284+ if let Some(params) = warp_params.as_ref().filter(|_| luma_scale == mc::REF_NO_SCALE) {
12881 crate::warp::warp_affine(13285 crate::warp::warp_affine(
12882 params, &py_ref.data, py_ref.true_width as i32, py_ref.true_height as i32,13286 params, &py_ref.data, py_ref.true_width as i32, py_ref.true_height as i32,
12883 py_ref.width as i32, &mut pred_y, px as i32, py as i32, side as i32,13287 py_ref.width as i32, &mut pred_y, px as i32, py as i32, side as i32,
12884 side as i32, side as i32, 0, 0,13288 side as i32, side as i32, 0, 0,
12885 );13289 );
13290+ // libaom `av1_init_warp_params` (reconinter.c): warp is
13291+ // per PLANE and bails out at `block_width < 8 ||
13292+ // block_height < 8`, so a plane whose own block is under
13293+ // 8x8 keeps the translational prediction built above --
13294+ // in 420 that is every chroma plane of a luma block below
13295+ // 16x16 (lane-gmaffine r4: chroma-only mismatch of a few
13296+ // levels on both 8x8-leaf motion gates).
13297+ if chroma_side >= 8 {
12886 crate::warp::warp_affine(13298 crate::warp::warp_affine(
12887 params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32,13299 params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32,
12888 pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32,13300 pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32,
@@ -12894,6 +13306,7 @@ fn decode_inter_block(
12894 chroma_side as i32, chroma_side as i32, 1, 1,13306 chroma_side as i32, chroma_side as i32, 1, 1,
12895 );13307 );
12896 }13308 }
13309+ }
12897 13310
12898 if obmc_selected {13311 if obmc_selected {
12899 obmc_blend(13312 obmc_blend(
@@ -12918,6 +13331,7 @@ fn decode_inter_block(
12918 ref_v,13331 ref_v,
12919 other_refs,13332 other_refs,
12920 interp_fixed,13333 interp_fixed,
13334+ frame_width,
12921 &mut pred_y,13335 &mut pred_y,
12922 &mut pred_u,13336 &mut pred_u,
12923 &mut pred_v,13337 &mut pred_v,
@@ -13430,6 +13844,16 @@ fn decode_inter_block8(
13430 scan4: &[u16],13844 scan4: &[u16],
13431 allow_high_precision_mv: bool,13845 allow_high_precision_mv: bool,
13432 force_integer_mv: bool,13846 force_integer_mv: bool,
13847+ // lane-gmaffine r1: this frame header's own `global_motion` table (spec
13848+ // 5.9.24), indexed `[ref_frame - LAST_FRAME]` -- same table
13849+ // [`decode_inter_block`] takes, threaded here so the 8x8 leaf can code
13850+ // `GLOBALMV` (`gm_get_motion_vector`), fill its mv stack's missing
13851+ // candidates with the gm mv (gm r6's root cause) and build a global
13852+ // warp prediction.
13853+ global_motion: &[ec_av1_syntax::WarpParams; 7],
13854+ // lane-gmaffine r1: this sequence header's own `enable_dual_filter` bit,
13855+ // for the leaf's own `read_mb_interp_filter` below.
13856+ enable_dual_filter: bool,
13433 // lane-av1comp: see [`decode_inter_block`]'s own doc -- this leaf path13857 // lane-av1comp: see [`decode_inter_block`]'s own doc -- this leaf path
13434 // only ever tracks a coarse `LAST_FRAME`-or-intra neighbour shape (no13858 // only ever tracks a coarse `LAST_FRAME`-or-intra neighbour shape (no
13435 // per-leaf `above_ref`/`left_ref` array exists here), so `comp_mode`'s13859 // per-leaf `above_ref`/`left_ref` array exists here), so `comp_mode`'s
@@ -13475,16 +13899,14 @@ fn decode_inter_block8(
13475 // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`-13899 // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`-
13476 // eligible (`bsize >= BLOCK_8X8`).13900 // eligible (`bsize >= BLOCK_8X8`).
13477 allow_screen_content_tools: bool,13901 allow_screen_content_tools: bool,
13478- // lane-inter8 r1: the leaf's mv stacks used to be built with neither the13902+ // lane-inter8 r1: the leaf's mv stacks used to be built without the
13479- // frame's sign-bias table nor its global-motion mv table (`NO_SIGN_BIAS`13903+ // frame's sign-bias table (`NO_SIGN_BIAS`), while [`decode_inter_block`]
13480- // / `NO_GM_MV`), while [`decode_inter_block`] one level up passed both.13904+ // one level up passed it -- it changes the candidate list and with it
13481- // A neighbour coded GLOBALMV contributes the gm mv, so dropping the table13905+ // `new_mv_ctx`/`ref_mv_ctx`, `drl_ctx` and the number of symbols read.
13482- // changes the candidate list -- and with it `new_mv_ctx`/`ref_mv_ctx`,13906+ // Measured: an 8x8 compound NEAR_NEWMV leaf desynced against aomdec's
13483- // `drl_ctx` and the number of symbols read. Measured: an 8x8 compound13907+ // EC_MODE ladder at exactly this block (mi 4,14 of the mandelbrot
13484- // NEAR_NEWMV leaf desynced against aomdec's EC_MODE ladder at exactly13908+ // 8x8-split gate).
13485- // this block (mi 4,14 of the mandelbrot 8x8-split gate).
13486 sign_bias_table: &SignBiasTable,13909 sign_bias_table: &SignBiasTable,
13487- global_motion: &[ec_av1_syntax::WarpParams; 7],
13488 // lane-inter8 r2: the frame's temporal mv field (spec 7.10.2.8), which13910 // lane-inter8 r2: the frame's temporal mv field (spec 7.10.2.8), which
13489 // [`decode_inter_block`] one level up has always passed and this leaf13911 // [`decode_inter_block`] one level up has always passed and this leaf
13490 // passed `None` for -- a `use_ref_frame_mvs` frame's stack then holds13912 // passed `None` for -- a `use_ref_frame_mvs` frame's stack then holds
@@ -13492,8 +13914,24 @@ fn decode_inter_block8(
13492 // mode contexts AND the number of `drl_mode` bits read (class parsed13914 // mode contexts AND the number of `drl_mode` bits read (class parsed
13493 // then discarded).13915 // then discarded).
13494 tpl_frame: Option<&TplFrameArgs>,13916 tpl_frame: Option<&TplFrameArgs>,
13495-) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, (i8, Option<i8>))> {13917+ // lane-scaledref r1: this frame's own coded luma width (spec 7.11.3.3),
13918+ // for the scaled-reference MC this leaf's own single-ref/compound/OBMC
13919+ // predictions take when a stored reference was coded at another width
13920+ // (`use_superres`) -- mirrors [`decode_inter_block`]'s own param.
13921+ frame_width: usize,
13922+) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, [u8; 2], (i8, Option<i8>))> {
13496 const LAST_FRAME: i8 = 1;13923 const LAST_FRAME: i8 = 1;
13924+ // lane-gmaffine r2: the leaf's OWN switchable-filter symbols, handed back
13925+ // so the caller stamps them into `Neighbours` instead of the `[3, 3]`
13926+ // placeholder. `[3, 3]` is the "intra neighbour, no filter" sentinel: an
13927+ // OBMC blend that picks such a neighbour up feeds it to
13928+ // `neighbour_filter`, which PANICS on it (`from_switchable_symbol`) --
13929+ // that was the warp gate's crash, not an entropy desync. Stays `[3, 3]`
13930+ // on the intra and compound paths.
13931+ let mut leaf_filter_syms = [3u8; 2];
13932+ // lane-gmaffine r1: this leaf's GLOBALMV vector AND the mv stack's
13933+ // missing-candidate fallback both come from the frame's global motion
13934+ // evaluated at THIS block's centre (gm r6's root cause).
13497 let gm_table = build_gm_mv_table(13935 let gm_table = build_gm_mv_table(
13498 global_motion,13936 global_motion,
13499 leaf_mi.0,13937 leaf_mi.0,
@@ -13801,6 +14239,12 @@ fn decode_inter_block8(
13801 14239
13802 let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?;14240 let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?;
13803 let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?;14241 let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?;
14242+ let scale0 = mc::scale_factor(py0.width, frame_width);
14243+ let scale1 = mc::scale_factor(py1.width, frame_width);
14244+ if scale0 != mc::REF_NO_SCALE || scale1 != mc::REF_NO_SCALE {
14245+ SCALED_COMPOUND_HITS.with(|c| c.set(c.get() + 1));
14246+ SCALED_BLOCK8_HITS.with(|c| c.set(c.get() + 1));
14247+ }
13804 14248
13805 for dr in 0..2 {14249 for dr in 0..2 {
13806 for dc in 0..2 {14250 for dc in 0..2 {
@@ -13837,6 +14281,7 @@ fn decode_inter_block8(
13837 py0.true_height,14281 py0.true_height,
13838 mv_to_q4(px, mv0.1, true),14282 mv_to_q4(px, mv0.1, true),
13839 mv_to_q4(py, mv0.0, true),14283 mv_to_q4(py, mv0.0, true),
14284+ scale0,
13840 SIDE,14285 SIDE,
13841 SIDE,14286 SIDE,
13842 Regular,14287 Regular,
@@ -13851,6 +14296,7 @@ fn decode_inter_block8(
13851 py1.true_height,14296 py1.true_height,
13852 mv_to_q4(px, mv1.1, true),14297 mv_to_q4(px, mv1.1, true),
13853 mv_to_q4(py, mv1.0, true),14298 mv_to_q4(py, mv1.0, true),
14299+ scale1,
13854 SIDE,14300 SIDE,
13855 SIDE,14301 SIDE,
13856 Regular,14302 Regular,
@@ -13882,6 +14328,7 @@ fn decode_inter_block8(
13882 pu0.true_height,14328 pu0.true_height,
13883 mv_to_q4(cpx, mv0.1, false),14329 mv_to_q4(cpx, mv0.1, false),
13884 mv_to_q4(cpy, mv0.0, false),14330 mv_to_q4(cpy, mv0.0, false),
14331+ scale0,
13885 CHROMA_SIDE,14332 CHROMA_SIDE,
13886 CHROMA_SIDE,14333 CHROMA_SIDE,
13887 Regular,14334 Regular,
@@ -13896,6 +14343,7 @@ fn decode_inter_block8(
13896 pu1.true_height,14343 pu1.true_height,
13897 mv_to_q4(cpx, mv1.1, false),14344 mv_to_q4(cpx, mv1.1, false),
13898 mv_to_q4(cpy, mv1.0, false),14345 mv_to_q4(cpy, mv1.0, false),
14346+ scale1,
13899 CHROMA_SIDE,14347 CHROMA_SIDE,
13900 CHROMA_SIDE,14348 CHROMA_SIDE,
13901 Regular,14349 Regular,
@@ -13926,6 +14374,7 @@ fn decode_inter_block8(
13926 pv0.true_height,14374 pv0.true_height,
13927 mv_to_q4(cpx, mv0.1, false),14375 mv_to_q4(cpx, mv0.1, false),
13928 mv_to_q4(cpy, mv0.0, false),14376 mv_to_q4(cpy, mv0.0, false),
14377+ scale0,
13929 CHROMA_SIDE,14378 CHROMA_SIDE,
13930 CHROMA_SIDE,14379 CHROMA_SIDE,
13931 Regular,14380 Regular,
@@ -13940,6 +14389,7 @@ fn decode_inter_block8(
13940 pv1.true_height,14389 pv1.true_height,
13941 mv_to_q4(cpx, mv1.1, false),14390 mv_to_q4(cpx, mv1.1, false),
13942 mv_to_q4(cpy, mv1.0, false),14391 mv_to_q4(cpy, mv1.0, false),
14392+ scale1,
13943 CHROMA_SIDE,14393 CHROMA_SIDE,
13944 CHROMA_SIDE,14394 CHROMA_SIDE,
13945 Regular,14395 Regular,
@@ -14059,38 +14509,58 @@ fn decode_inter_block8(
14059 // so the 16x16 below a split block read partition ctx 014509 // so the 16x16 below a split block read partition ctx 0
14060 // instead of 1 and mis-read PARTITION_SPLIT as NONE.14510 // instead of 1 and mis-read PARTITION_SPLIT as NONE.
14061 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);14511 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
14062- neighbours.fill_lf_grid(leaf_mi, 2, 8, if is_inter { LAST_FRAME } else { 0 });14512+ neighbours.fill_lf_grid(
14063- return Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_refs));14513+ leaf_mi,
14064- }14514+ 2,
14065- }14515+ 8,
14066- leaf_refs = (LAST_FRAME, None);14516+ if is_inter { leaf_refs.0.max(LAST_FRAME) } else { 0 },
14067- let sr_ctx = single_ref_ctx(above_inter || left_inter);14517+ );
14068- let p1 = dec.symbol(&mut cdfs.single_ref[sr_ctx][0]);14518+ return Ok((
14069- let p3 = dec.symbol(&mut cdfs.single_ref[sr_ctx][2]);14519+ skip,
14070- let p4 = dec.symbol(&mut cdfs.single_ref[sr_ctx][3]);14520+ is_inter,
14071- if (p1, p3, p4) != (0, 0, 0) {14521+ skip_mode,
14072- return Err(unsupported(14522+ compound_ctx8,
14073- "a reference frame other than LAST_FRAME (round 2)",14523+ leaf_filter_syms,
14524+ leaf_refs,
14074 ));14525 ));
14075 }14526 }
14527+ }
14528+ // lane-gmaffine r1: the leaf reads the FULL `single_ref` tree
14529+ // ([`read_single_ref`], the same one the 16x16+ leaf uses, with the
14530+ // real per-neighbour p1..p6 contexts) instead of the old three-symbol
14531+ // LAST-only probe plus a refusal -- aomenc picks GOLDEN/ALTREF for
14532+ // 8x8 leaves constantly, so that refusal was what every 8x8 gate
14533+ // actually stopped at.
14534+ let ref_frame = read_single_ref(
14535+ dec,
14536+ cdfs,
14537+ neighbours.above_ref[cmi],
14538+ neighbours.above_ref1[cmi],
14539+ neighbours.left_ref[rmi],
14540+ neighbours.left_ref1[rmi],
14541+ );
14542+ leaf_refs = (ref_frame, None);
14543+ let (sref_y, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
14076 14544
14077 let (mi_row, mi_col) = leaf_mi;14545 let (mi_row, mi_col) = leaf_mi;
14546+ // lane-inter8 r2: the frame's temporal mv candidates, keyed on THIS
14547+ // leaf's own reference (lane-gmaffine r1 taught it non-LAST refs).
14078 let tpl = tpl_frame.map(|t| crate::mvstack::TplArgs {14548 let tpl = tpl_frame.map(|t| crate::mvstack::TplArgs {
14079 field: t.field,14549 field: t.field,
14080 cur_offset_0: crate::motion_field::get_relative_dist(14550 cur_offset_0: crate::motion_field::get_relative_dist(
14081 t.order_hint_bits,14551 t.order_hint_bits,
14082 t.order_hint,14552 t.order_hint,
14083- t.ref_order_hints[(LAST_FRAME - LAST_FRAME) as usize],14553+ t.ref_order_hints[(ref_frame - LAST_FRAME) as usize],
14084 ),14554 ),
14085 allow_high_precision_mv,14555 allow_high_precision_mv,
14086 });14556 });
14087- let stack = find_mv_stack_with_sign_bias(14557+ let stack = crate::mvstack::find_mv_stack_with_sign_bias(
14088 grid,14558 grid,
14089 mi_row,14559 mi_row,
14090 mi_col,14560 mi_col,
14091 2,14561 2,
14092 2,14562 2,
14093- LAST_FRAME,14563+ ref_frame,
14094 mi_cols as usize,14564 mi_cols as usize,
14095 mi_rows as usize,14565 mi_rows as usize,
14096 sign_bias_table,14566 sign_bias_table,
@@ -14099,6 +14569,7 @@ fn decode_inter_block8(
14099 );14569 );
14100 14570
14101 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;14571 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
14572+ let mut is_globalmv = false;
14102 let (mv, is_new_mv) = if !not_new {14573 let (mv, is_new_mv) = if !not_new {
14103 // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0):14574 // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0):
14104 // read at most two `drl_mode` bits, one per stack entry past the14575 // read at most two `drl_mode` bits, one per stack entry past the
@@ -14127,11 +14598,16 @@ fn decode_inter_block8(
14127 )14598 )
14128 } else {14599 } else {
14129 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;14600 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
14130- if !not_zero {14601+ is_globalmv = !not_zero;
14131- return Err(unsupported("GLOBALMV (round 3)"));14602+ let mv = if !not_zero {
14132- }14603+ // lane-gmaffine r1: GLOBALMV (spec 7.10.2.1) -- the same
14604+ // `gm_get_motion_vector` value the 16x16+ leaf reads out of
14605+ // its own `gm_table`, computed at this block's centre.
14606+ GLOBALMV_HITS_8.with(|c| c.set(c.get() + 1));
14607+ gm_table[(ref_frame - LAST_FRAME) as usize]
14608+ } else {
14133 let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;14609 let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;
14134- let mv = if nearest {14610+ if nearest {
14135 stack.nearest_mv14611 stack.nearest_mv
14136 } else {14612 } else {
14137 let mut idx = 1usize;14613 let mut idx = 1usize;
@@ -14142,6 +14618,7 @@ fn decode_inter_block8(
14142 idx += 1;14618 idx += 1;
14143 }14619 }
14144 stack.entries.get(idx).map_or(stack.near_mv, |e| e.mv)14620 stack.entries.get(idx).map_or(stack.near_mv, |e| e.mv)
14621+ }
14145 };14622 };
14146 (mv, false)14623 (mv, false)
14147 };14624 };
@@ -14184,18 +14661,35 @@ fn decode_inter_block8(
14184 // 16x16 leaf's own `decode_inter_block` read (see its doc above) --14661 // 16x16 leaf's own `decode_inter_block` read (see its doc above) --
14185 // same 2-symbol `obmc_cdf` alphabet, same `allow_warped_motion=1`14662 // same 2-symbol `obmc_cdf` alphabet, same `allow_warped_motion=1`
14186 // refusal (warp needs `av1_findSamples`, not ported at either leaf).14663 // refusal (warp needs `av1_findSamples`, not ported at either leaf).
14664+ // lane-gmaffine r1: the two libaom predicates, exactly as the
14665+ // 16x16+ leaf resolves them (see [`decode_inter_block`]'s own doc):
14666+ // `is_global_mv_block` (mode GLOBAL*, model > TRANSLATION, block
14667+ // >= 8x8 -- BLOCK_8X8 IS the 8px minimum, so the size predicate is
14668+ // always true here) suppresses the motion_mode read entirely and
14669+ // turns on the global warp below.
14670+ let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize];
14671+ let is_global_mv_block = is_globalmv && gm_ref.model as u8 > 1;
14187 let motion_mode_eligible = switchable_motion_mode14672 let motion_mode_eligible = switchable_motion_mode
14188 && !skip_mode14673 && !skip_mode
14189 && interintra_mode.is_none()14674 && interintra_mode.is_none()
14675+ && !(is_global_mv_block && !force_integer_mv)
14190 && (!overlappable_above(grid, mi_row, mi_col, 2, mi_cols as usize, 1).is_empty()14676 && (!overlappable_above(grid, mi_row, mi_col, 2, mi_cols as usize, 1).is_empty()
14191 || !overlappable_left(grid, mi_row, mi_col, 2, mi_rows as usize, 1).is_empty());14677 || !overlappable_left(grid, mi_row, mi_col, 2, mi_rows as usize, 1).is_empty());
14678+ let mut warp_params: Option<crate::warp::WarpParams> = None;
14679+ let mut warped_selected = false;
14192 let mut obmc_selected = false;14680 let mut obmc_selected = false;
14193 if motion_mode_eligible {14681 if motion_mode_eligible {
14194 // lane-warp round 1: same 3-vs-2-symbol split as the 16x16+ leaf14682 // lane-warp round 1: same 3-vs-2-symbol split as the 16x16+ leaf
14195 // (see its own doc) -- this leaf is always `LAST_FRAME`-only14683 // (see its own doc) -- this leaf is always `LAST_FRAME`-only
14196 // (grid.set below hardcodes it).14684 // (grid.set below hardcodes it).
14685+ // lane-scaledref r2 sibling of the 16x16+ leaf's fix: libaom
14686+ // drops WARPED_CAUSAL eligibility (so this reads `obmc_cdf`)
14687+ // when the reference is scaled. Not gated here because an 8x8
14688+ // leaf under a scaled reference is refused before this function
14689+ // runs (see the block8 refusal below, ~12500) -- whoever lifts
14690+ // that refusal must add `&& !ref_is_scaled` here too.
14197 let warp_eligible = allow_warped_motion14691 let warp_eligible = allow_warped_motion
14198- && num_proj_ref(grid, mi_row, mi_col, 2, 2, mi_cols as usize, mi_rows as usize, LAST_FRAME) >= 1;14692+ && num_proj_ref(grid, mi_row, mi_col, 2, 2, mi_cols as usize, mi_rows as usize, ref_frame) >= 1;
14199 if warp_eligible {14693 if warp_eligible {
14200 let mode = dec.symbol(&mut cdfs.motion_mode[0]);14694 let mode = dec.symbol(&mut cdfs.motion_mode[0]);
14201 match mode {14695 match mode {
@@ -14206,12 +14700,41 @@ fn decode_inter_block8(
14206 OBMC_HITS_8.with(|c| c.set(c.get() + 1));14700 OBMC_HITS_8.with(|c| c.set(c.get() + 1));
14207 }14701 }
14208 _ => {14702 _ => {
14703+ // lane-gmaffine r1: WARPED_CAUSAL at the 8x8 leaf --
14704+ // the same findSamples -> select_samples ->
14705+ // av1_find_projection chain the 16x16+ leaf runs,
14706+ // with BLOCK_8X8's own 8x8 model centre; an
14707+ // unusable projection falls back to the block's
14708+ // translational mv (libaom `av1_find_projection`
14709+ // returning 1 leaves `wm_params` invalid and
14710+ // `build_inter_predictors` skips the warp).
14209 WARP_SELECTED_HITS.with(|c| c.set(c.get() + 1));14711 WARP_SELECTED_HITS.with(|c| c.set(c.get() + 1));
14210- return Err(unsupported(14712+ let mut samples = find_samples(
14211- "an 8x8 leaf that coded WARPED_CAUSAL (motion_mode == 2): \14713+ grid,
14212- av1_find_projection/the affine warp filter are not \14714+ mi_row,
14213- ported, only motion_mode_allowed's alphabet choice is",14715+ mi_col,
14214- ));14716+ 2,
14717+ 2,
14718+ mi_cols as usize,
14719+ mi_rows as usize,
14720+ ref_frame,
14721+ );
14722+ if samples.len() > 1 {
14723+ crate::warp::select_samples(mv, &mut samples, SIDE as i32, SIDE as i32);
14724+ }
14725+ warp_params = crate::warp::find_projection(
14726+ &samples,
14727+ SIDE as i32,
14728+ SIDE as i32,
14729+ mv.1,
14730+ mv.0,
14731+ mi_row as i32,
14732+ mi_col as i32,
14733+ );
14734+ warped_selected = true;
14735+ if warp_params.is_some() {
14736+ WARP_HITS_8.with(|c| c.set(c.get() + 1));
14737+ }
14215 }14738 }
14216 }14739 }
14217 } else {14740 } else {
@@ -14223,6 +14746,78 @@ fn decode_inter_block8(
14223 }14746 }
14224 }14747 }
14225 }14748 }
14749+ // lane-gmaffine r1: `read_mb_interp_filter` (spec 5.11.26) at the 8x8
14750+ // leaf, in libaom's own order (interintra, motion_mode, THEN the
14751+ // filter). Until this round the leaf read no filter symbol at all and
14752+ // predicted Regular unconditionally -- correct only for a frame with a
14753+ // fixed `interp_filter`, and a silent entropy DESYNC for every
14754+ // SWITCHABLE-filter stream that reaches an 8x8 leaf (which is what
14755+ // made the interior-split wiring above unusable at first).
14756+ // corner-cut: the neighbour filter context is the enclosing 16x16
14757+ // block's own coarse `above_filter`/`left_filter` entry (this leaf
14758+ // path keeps no per-leaf neighbour array), so all four siblings read
14759+ // the same context row. Ceiling: a stream whose 8x8 siblings pick
14760+ // DIFFERENT filters decodes the second..fourth leaf's symbol from the
14761+ // wrong CDF row. Upgrade: give `Neighbours` a real 8x8-granular
14762+ // filter array, same shape as the `[3, 3]` approximation the caller
14763+ // records after the leaf loop.
14764+ let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame
14765+ || neighbours.above_ref1[cmi] == Some(ref_frame)
14766+ {
14767+ neighbours.above_filter[cmi]
14768+ } else {
14769+ [3, 3]
14770+ };
14771+ let left_filter_ctx = if neighbours.left_ref[rmi] == ref_frame
14772+ || neighbours.left_ref1[rmi] == Some(ref_frame)
14773+ {
14774+ neighbours.left_filter[rmi]
14775+ } else {
14776+ [3, 3]
14777+ };
14778+ let gm_nontrans =
14779+ is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation;
14780+ let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
14781+ dec,
14782+ cdfs,
14783+ interp_fixed,
14784+ enable_dual_filter,
14785+ gm_nontrans || warped_selected || skip_mode,
14786+ above_filter_ctx,
14787+ left_filter_ctx,
14788+ false,
14789+ );
14790+ leaf_filter_syms = resolved_filter;
14791+ if std::env::var_os("EC_TRACE_MODE").is_some() {
14792+ eprintln!(
14793+ "EC_MODE_VAL8 mi_row={} mi_col={} newmv={is_new_mv} globalmv={is_globalmv} ref0={ref_frame} mv0=({},{}) stack={} rng={}",
14794+ leaf_mi.0,
14795+ leaf_mi.1,
14796+ mv.0,
14797+ mv.1,
14798+ stack.entries.len(),
14799+ dec.debug_state().0
14800+ );
14801+ }
14802+ // lane-gmaffine r1: `allow_warp`'s `global_warp_allowed` branch
14803+ // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` --
14804+ // see [`decode_inter_block`]'s own copy. A local WARPED_CAUSAL model
14805+ // wins (`is_none()` guard); BLOCK_8X8 already satisfies the >=8px
14806+ // size predicate baked into `is_global_mv_block`.
14807+ if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid {
14808+ warp_params = crate::warp::global_warp_params(gm_ref.params);
14809+ if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine {
14810+ AFFINE_GM_HITS.with(|c| c.set(c.get() + 1));
14811+ }
14812+ }
14813+ if std::env::var_os("EC_TRACE_MODE").is_some() {
14814+ eprintln!(
14815+ "EC_WARP8 mi_row={} mi_col={} warp={} globalblk={is_global_mv_block}",
14816+ leaf_mi.0,
14817+ leaf_mi.1,
14818+ warp_params.is_some(),
14819+ );
14820+ }
14226 for dr in 0..2 {14821 for dr in 0..2 {
14227 for dc in 0..2 {14822 for dc in 0..2 {
14228 grid.set(14823 grid.set(
@@ -14230,7 +14825,7 @@ fn decode_inter_block8(
14230 mi_col + dc,14825 mi_col + dc,
14231 MiInfo {14826 MiInfo {
14232 is_inter: true,14827 is_inter: true,
14233- ref_frame: LAST_FRAME,14828+ ref_frame,
14234 // INTRA_FRAME marker for interintra blocks -- keeps14829 // INTRA_FRAME marker for interintra blocks -- keeps
14235 // them out of warp-sample gathering (see 16/32 site).14830 // them out of warp-sample gathering (see 16/32 site).
14236 ref_frame1: interintra_mode.map(|_| 0),14831 ref_frame1: interintra_mode.map(|_| 0),
@@ -14239,7 +14834,7 @@ fn decode_inter_block8(
14239 is_new_mv,14834 is_new_mv,
14240 size: 2,14835 size: 2,
14241 size_h: 2,14836 size_h: 2,
14242- is_global_mv0: false,14837+ is_global_mv0: is_global_mv_block,
14243 is_global_mv1: false,14838 is_global_mv1: false,
14244 },14839 },
14245 );14840 );
@@ -14247,42 +14842,83 @@ fn decode_inter_block8(
14247 }14842 }
14248 mode_for_tx = 0;14843 mode_for_tx = 0;
14249 14844
14845+ // lane-scaledref r1: this leaf's own prediction is always `Regular`
14846+ // (documented corner-cut above); under a scaled reference the same
14847+ // fixed kernel runs through spec 7.11.3.3's scaled walk instead.
14848+ let luma_scale = mc::scale_factor(sref_y.width, frame_width);
14849+ if luma_scale != mc::REF_NO_SCALE {
14850+ SCALED_BLOCK8_HITS.with(|c| c.set(c.get() + 1));
14851+ }
14250 let mut pred_y = vec![0u16; SIDE * SIDE];14852 let mut pred_y = vec![0u16; SIDE * SIDE];
14251- mc::predict(
14252- &ref_y.data,
14253- ref_y.width,
14254- ref_y.true_width,
14255- ref_y.true_height,
14256- mv_to_q4(px, mv.1, true),
14257- mv_to_q4(py, mv.0, true),
14258- SIDE,
14259- SIDE,
14260- &mut pred_y,
14261- );
14262 let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];14853 let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];
14263- mc::predict(
14264- &ref_u.data,
14265- ref_u.width,
14266- ref_u.true_width,
14267- ref_u.true_height,
14268- mv_to_q4(cpx, mv.1, false),
14269- mv_to_q4(cpy, mv.0, false),
14270- CHROMA_SIDE,
14271- CHROMA_SIDE,
14272- &mut pred_u,
14273- );
14274 let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];14854 let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];
14275- mc::predict(14855+ // Merge of lane-gmaffine (this leaf's own switchable filters) with
14276- &ref_v.data,14856+ // lane-scaledref (spec 7.11.3.3's scaled walk): same kernels either
14277- ref_v.width,14857+ // way, only the sample walk differs.
14278- ref_v.true_width,14858+ for (plane, x, y, dim, dst) in [
14279- ref_v.true_height,14859+ (sref_y, px, py, SIDE, &mut pred_y),
14280- mv_to_q4(cpx, mv.1, false),14860+ (sref_u, cpx, cpy, CHROMA_SIDE, &mut pred_u),
14281- mv_to_q4(cpy, mv.0, false),14861+ (sref_v, cpx, cpy, CHROMA_SIDE, &mut pred_v),
14282- CHROMA_SIDE,14862+ ] {
14283- CHROMA_SIDE,14863+ let luma = std::ptr::eq(plane, sref_y);
14284- &mut pred_v,14864+ if luma_scale == mc::REF_NO_SCALE {
14865+ mc::predict_with_filters(
14866+ &plane.data,
14867+ plane.width,
14868+ plane.true_width,
14869+ plane.true_height,
14870+ mv_to_q4(x, mv.1, luma),
14871+ mv_to_q4(y, mv.0, luma),
14872+ dim,
14873+ dim,
14874+ h_filter,
14875+ v_filter,
14876+ dst,
14877+ );
14878+ } else {
14879+ mc::predict_scaled(
14880+ &plane.data,
14881+ plane.width,
14882+ plane.true_width,
14883+ plane.true_height,
14884+ mv_to_q4(x, mv.1, luma),
14885+ mv_to_q4(y, mv.0, luma),
14886+ luma_scale,
14887+ dim,
14888+ dim,
14889+ h_filter,
14890+ v_filter,
14891+ dst,
14892+ );
14893+ }
14894+ }
14895+
14896+ // lane-gmaffine r1: the warp filter REPLACES the translational
14897+ // prediction just built (libaom builds one or the other), same as
14898+ // the 16x16+ leaf's own call trio.
14899+ if let Some(params) = &warp_params {
14900+ crate::warp::warp_affine(
14901+ params, &sref_y.data, sref_y.true_width as i32, sref_y.true_height as i32,
14902+ sref_y.width as i32, &mut pred_y, px as i32, py as i32, SIDE as i32,
14903+ SIDE as i32, SIDE as i32, 0, 0,
14904+ );
14905+ // `av1_init_warp_params`'s per-plane `block_width/height < 8`
14906+ // bail-out: an 8x8 leaf's chroma plane is 4x4 in 420, so it is
14907+ // predicted translationally even when the luma warps.
14908+ #[allow(clippy::absurd_extreme_comparisons)]
14909+ if CHROMA_SIDE >= 8 {
14910+ crate::warp::warp_affine(
14911+ params, &sref_u.data, sref_u.true_width as i32, sref_u.true_height as i32,
14912+ sref_u.width as i32, &mut pred_u, cpx as i32, cpy as i32, CHROMA_SIDE as i32,
14913+ CHROMA_SIDE as i32, CHROMA_SIDE as i32, 1, 1,
14914+ );
14915+ crate::warp::warp_affine(
14916+ params, &sref_v.data, sref_v.true_width as i32, sref_v.true_height as i32,
14917+ sref_v.width as i32, &mut pred_v, cpx as i32, cpy as i32, CHROMA_SIDE as i32,
14918+ CHROMA_SIDE as i32, CHROMA_SIDE as i32, 1, 1,
14285 );14919 );
14920+ }
14921+ }
14286 14922
14287 if obmc_selected {14923 if obmc_selected {
14288 obmc_blend(14924 obmc_blend(
@@ -14307,6 +14943,7 @@ fn decode_inter_block8(
14307 ref_v,14943 ref_v,
14308 other_refs,14944 other_refs,
14309 interp_fixed,14945 interp_fixed,
14946+ frame_width,
14310 &mut pred_y,14947 &mut pred_y,
14311 &mut pred_u,14948 &mut pred_u,
14312 &mut pred_v,14949 &mut pred_v,
@@ -14616,13 +15253,23 @@ fn decode_inter_block8(
14616 neighbours.above[leaf_mi.1 + cell][0] = state;15253 neighbours.above[leaf_mi.1 + cell][0] = state;
14617 }15254 }
14618 }15255 }
15256+ // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference
15257+ // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every
15258+ // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test).
14619 neighbours.fill_lf_grid(15259 neighbours.fill_lf_grid(
14620 leaf_mi,15260 leaf_mi,
14621 2,15261 2,
14622 if split8 { 4 } else { 8 },15262 if split8 { 4 } else { 8 },
14623- if is_inter { LAST_FRAME } else { 0 },15263+ if is_inter { leaf_refs.0.max(LAST_FRAME) } else { 0 },
14624 );15264 );
14625- Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_refs))15265+ Ok((
15266+ skip,
15267+ is_inter,
15268+ skip_mode,
15269+ compound_ctx8,
15270+ leaf_filter_syms,
15271+ leaf_refs,
15272+ ))
14626 }15273 }
14627 15274
14628 /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes,15275 /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes,
@@ -15356,15 +16003,23 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
15356 .map(|i| (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2))16003 .map(|i| (mi_row0 + (i / 2) * 2, mi_col0 + (i % 2) * 2))
15357 .filter(|&(mr, mc)| mr < mi_rows && mc < mi_cols)16004 .filter(|&(mr, mc)| mr < mi_rows && mc < mi_cols)
15358 .collect();16005 .collect();
15359- // lane-superres r9: decode_inter_block8's own16006+ // lane-scaledref r1: `decode_inter_block8` IS
15360- // MC (below) is not threaded for a scaled16007+ // threaded for a scaled reference now (its
15361- // reference (unlike decode_inter_block's 1916008+ // single-ref, compound and OBMC MC all take
15362- // sites) -- refuse the whole 8x8-leaf split16009+ // spec 7.11.3.3's scaled walk), but the one
15363- // up front when ANY live reference this leaf16010+ // recipe that reaches this path at all -- a
15364- // could pick has a different width than this16011+ // 64x72 superres fixture whose bottom 16-row
15365- // frame, rather than thread frame_width16012+ // band straddles the true edge, so the
15366- // through its own single-ref/compound MC16013+ // gathered split bit lands on 8x8 leaves --
15367- // calls to reach the same block this round.16014+ // DESYNCS inside the leaf itself
16015+ // (`from_switchable_symbol` handed a 4th
16016+ // symbol, mc.rs:200), the same
16017+ // below-8x8 desync lane-sub8 r2 left open and
16018+ // unrelated to scaling. So the scaled MC here
16019+ // is unproven: refuse by name rather than
16020+ // ship a capability claim no gate exercises.
16021+ // Deleting these six lines is the whole lift
16022+ // once the leaf8 desync is fixed.
15368 if ref_y.width != frame_width as usize16023 if ref_y.width != frame_width as usize
15369 || ref_slots.iter().flatten().any(|(py, _, _)| {16024 || ref_slots.iter().flatten().any(|(py, _, _)| {
15370 py.width != frame_width as usize16025 py.width != frame_width as usize
@@ -15375,8 +16030,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
15375 ));16030 ));
15376 }16031 }
15377 let mut prev_leaves: Vec<((usize, usize), bool, bool, i8, Option<i8>)> = Vec::new();16032 let mut prev_leaves: Vec<((usize, usize), bool, bool, i8, Option<i8>)> = Vec::new();
15378- let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None;
15379- let mut last_skip_mode = false;
15380 for (mr, mc) in leaf_positions {16033 for (mr, mc) in leaf_positions {
15381 let leaf_mi = (mr as usize, mc as usize);16034 let leaf_mi = (mr as usize, mc as usize);
15382 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);16035 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
@@ -15386,8 +16039,14 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
15386 "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)",16039 "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)",
15387 ));16040 ));
15388 }16041 }
15389- let (skip, is_inter, skip_mode_leaf, compound_ctx8, leaf_refs) =16042+ let (
15390- decode_inter_block8(16043+ skip,
16044+ is_inter,
16045+ skip_mode_leaf,
16046+ compound_ctx8,
16047+ leaf_filter,
16048+ leaf_refs,
16049+ ) = decode_inter_block8(
15391 &mut dec,16050 &mut dec,
15392 &mut cdfs,16051 &mut cdfs,
15393 &mut neighbours,16052 &mut neighbours,
@@ -15408,6 +16067,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
15408 &scan4,16067 &scan4,
15409 allow_high_precision_mv,16068 allow_high_precision_mv,
15410 force_integer_mv,16069 force_integer_mv,
16070+ &global_motion,
16071+ enable_dual_filter,
15411 reference_select,16072 reference_select,
15412 enable_masked_compound,16073 enable_masked_compound,
15413 enable_interintra_compound,16074 enable_interintra_compound,
@@ -15423,14 +16084,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
15423 allow_warped_motion,16084 allow_warped_motion,
15424 allow_screen_content_tools,16085 allow_screen_content_tools,
15425 &sign_bias_table,16086 &sign_bias_table,
15426- &global_motion,
15427 tpl_frame.as_ref(),16087 tpl_frame.as_ref(),
16088+ frame_width as usize,
15428 )?;16089 )?;
15429 prev_leaves.push((leaf_mi, skip, is_inter, leaf_refs.0, leaf_refs.1));16090 prev_leaves.push((leaf_mi, skip, is_inter, leaf_refs.0, leaf_refs.1));
15430- last_skip_mode = skip_mode_leaf;
15431- if compound_ctx8.is_some() {
15432- last_compound_ctx = compound_ctx8;
15433- }
15434 // lane-inter8 r2: stamp THIS leaf's own16091 // lane-inter8 r2: stamp THIS leaf's own
15435 // 2x2-mi span before the next leaf reads16092 // 2x2-mi span before the next leaf reads
15436 // it as a neighbour -- the whole-16x1616093 // it as a neighbour -- the whole-16x16
@@ -15439,9 +16096,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
15439 // block carried the wrong skip/ref/inter16096 // block carried the wrong skip/ref/inter
15440 // state into the next block's contexts16097 // state into the next block's contexts
15441 // (class context-read-from-one-cell).16098 // (class context-read-from-one-cell).
15442- // corner-cut: `[3, 3]` filter, as the16099+ // lane-gmaffine r3: with the mi-granular
15443- // 16x16 stamp used -- `decode_inter_block8`16100+ // band, the leaf's OWN switchable-filter
15444- // reads no switchable filter yet.16101+ // symbols go in here -- the `[3, 3]`
16102+ // ("intra, no filter") sentinel this used
16103+ // to stamp made `obmc_blend`'s
16104+ // `neighbour_filter` PANIC as soon as a
16105+ // sibling leaf blended one of these.
15445 neighbours.record_inter_rect_mi(16106 neighbours.record_inter_rect_mi(
15446 leaf_mi,16107 leaf_mi,
15447 2,16108 2,
@@ -15449,7 +16110,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
15449 skip,16110 skip,
15450 is_inter,16111 is_inter,
15451 leaf_refs.0,16112 leaf_refs.0,
15452- [3, 3],16113+ leaf_filter,
15453 skip_mode_leaf,16114 skip_mode_leaf,
15454 );16115 );
15455 if let Some(ref1) = leaf_refs.116116 if let Some(ref1) = leaf_refs.1
@@ -16460,33 +17121,34 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
16460 mod tests {17121 mod tests {
16461 use super::*;17122 use super::*;
16462 17123
16463- /// lane-rectsplit r2: `av1_nz_map_ctx_offset` is packed COLUMN-major, so17124+ /// lane-rectsplit r4 (class `enumerate-table-domain`): [`base_ctx`]'s
16464- /// the two rect transcriptions in [`cdf`] must be read `[col][row]`.17125+ /// `TX_CLASS_2D` arm must, over the WHOLE 5x5 domain of both rect shapes
16465- /// [`base_ctx_rect`] states libaom's generating rule17126+ /// and the square one, return exactly what libaom's
16466- /// (`txb_common.h:199-209`) in display coordinates; this pins the tables17127+ /// `av1_nz_map_ctx_offset[tx_size][coeff_idx]` holds -- the flat tables
16467- /// against it, which is what a transposed read would break.17128+ /// transcribed in [`cdf`], read at libaom's own COLUMN-major
17129+ /// `coeff_idx = col * 32 + row`, i.e. `table[col][row]`. r1..r3 read them
17130+ /// `[row][col]`, which is the transpose (the OTHER shape's rule, with 11
17131+ /// and 16 swapped): it desynced the first superblock strip whose luma
17132+ /// corner held a coefficient off the first row/column.
16468 #[test]17133 #[test]
16469- fn nz_map_ctx_offset_tables_match_the_rect_rule() {17134+ fn base_ctx_rect_offsets_match_the_transcribed_tables_over_the_whole_domain() {
16470- for (w, h, table) in [17135+ let grid = [0i32; 32 * 32];
16471- (32usize, 64usize, &cdf::NZ_MAP_CTX_OFFSET_32X64),17136+ for (shape, table) in [
16472- (64, 32, &cdf::NZ_MAP_CTX_OFFSET_64X32),17137+ (Some((64usize, 32usize)), &cdf::NZ_MAP_CTX_OFFSET_64X32),
17138+ (Some((32, 64)), &cdf::NZ_MAP_CTX_OFFSET_32X64),
17139+ (None, &cdf::NZ_MAP_CTX_OFFSET_32),
16473 ] {17140 ] {
16474 for row in 0..5usize {17141 for row in 0..5usize {
16475 for col in 0..5usize {17142 for col in 0..5usize {
17143+ // An all-zero neighbourhood makes the magnitude term 0,
17144+ // so `base_ctx` returns the offset itself.
17145+ let got = base_ctx(&grid, 32, row, col, TxClass::TwoD, shape);
16476 let want = if row == 0 && col == 0 {17146 let want = if row == 0 && col == 0 {
16477 017147 0
16478- } else if w < h && row < 2 {
16479- 11
16480- } else if w > h && col < 2 {
16481- 16
16482 } else {17148 } else {
16483- cdf::NZ_MAP_CTX_OFFSET_32[row][col]17149+ table[col][row] as usize
16484 };17150 };
16485- assert_eq!(17151+ assert_eq!(got, want, "{shape:?} at (row {row}, col {col})");
16486- table[col][row],
16487- want,
16488- "{w}x{h} nz_map offset at display (row {row}, col {col})"
16489- );
16490 }17152 }
16491 }17153 }
16492 }17154 }
crates/ec-av1/src/gate_coverage.rsmodified+266 -13
@@ -80,6 +80,52 @@ const TOOL_UNIVERSE: &[&str] = &[
80 "enable-warped-motion",80 "enable-warped-motion",
81 ];81 ];
82 82
83+/// How a non-boolean aomenc knob reads as "the tool is on".
84+#[cfg(test)]
85+#[derive(Clone, Copy, PartialEq)]
86+enum On {
87+ /// Any non-zero value enables the tool (`--tile-columns=1`, `--loopfilter-control=1`).
88+ NonZero,
89+ /// The tool's search only runs at or below this speed (`--cpu-used`).
90+ AtMost(u32),
91+}
92+
93+/// Coding tools aomenc drives through a spelling [`TOOL_UNIVERSE`] does not
94+/// cover, listed with their aomenc default.
95+///
96+/// lane-covbd's derivation read `--enable-*` flags only, so a tool a gate pins
97+/// off through another spelling was invisible: all 49 gates that name it pass
98+/// `--enable-tx-size-search=0`, and the real-stream PANIC hiding behind that
99+/// pin was found by lane-ab16, not by this guard. `--loopfilter-control=0`,
100+/// `--tile-columns=0` and a `--cpu-used` high enough to switch a search off are
101+/// the same shape.
102+///
103+/// Each entry is `(tool, spellings, aomenc default, what counts as on)`. The
104+/// "defaulted means unknown" rule of [`NEVER_EXERCISED`] applies unchanged: a
105+/// default of `1` does not prove the encoder picked the tool for any stream, so
106+/// only a gate that spells an on-value at that bit depth retires an entry.
107+#[cfg(test)]
108+const DEFAULT_ON_TOOLS: &[(&str, &[&str], &str, On)] = &[
109+ ("enable-tx-size-search", &["enable-tx-size-search"], "1", On::NonZero),
110+ ("enable-directional-intra", &["enable-directional-intra"], "1", On::NonZero),
111+ ("enable-smooth-interintra", &["enable-smooth-interintra"], "1", On::NonZero),
112+ ("enable-interintra-wedge", &["enable-interintra-wedge"], "1", On::NonZero),
113+ ("enable-diff-wtd-comp", &["enable-diff-wtd-comp"], "1", On::NonZero),
114+ ("enable-onesided-comp", &["enable-onesided-comp"], "1", On::NonZero),
115+ ("enable-fwd-kf", &["enable-fwd-kf"], "0", On::NonZero),
116+ ("deblocking", &["loopfilter-control"], "1", On::NonZero),
117+ ("multi-tile", &["tile-columns", "tile-rows"], "0", On::NonZero),
118+ ("intrabc-search", &["cpu-used"], "0", On::AtMost(2)),
119+];
120+
121+/// Non-`--enable-*` spellings that drive a [`TOOL_UNIVERSE`] tool.
122+///
123+/// `--superres-mode=1` is how all three superres gates switch superres on;
124+/// without this map they read as an `enable-superres` hole while a real stream
125+/// exercises the tool (lane-covbd deferred exactly this).
126+#[cfg(test)]
127+const ALIASES: &[(&str, &str)] = &[("superres-mode", "enable-superres")];
128+
83 /// Coverage is per (tool x bit depth), not per tool.129 /// Coverage is per (tool x bit depth), not per tool.
84 ///130 ///
85 /// lane-hbdinter found two 10-bit-only defects (SGR box sums unscaled, Wiener131 /// lane-hbdinter found two 10-bit-only defects (SGR box sums unscaled, Wiener
@@ -93,10 +139,6 @@ const TOOL_UNIVERSE: &[&str] = &[
93 /// depth retires the entry, and this test fails until it is deleted.139 /// depth retires the entry, and this test fails until it is deleted.
94 #[cfg(test)]140 #[cfg(test)]
95 const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[141 const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[
96- (
97- "enable-1to4-partitions",
98- "off in 42 gates, on in none: PARTITION_HORZ_4/VERT_4 at 64x64 needs TX_64X16 luma plus 32x8 chroma scans (lane-part32 r5)",
99- ),
100 (142 (
101 "enable-angle-delta",143 "enable-angle-delta",
102 "off in 36 gates, on in none: the directional-intra gates pin it off to isolate the base modes",144 "off in 36 gates, on in none: the directional-intra gates pin it off to isolate the base modes",
@@ -133,10 +175,6 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[
133 "enable-ref-frame-mvs",175 "enable-ref-frame-mvs",
134 "off in 27 gates, on in none: temporal MV projection is unimplemented",176 "off in 27 gates, on in none: temporal MV projection is unimplemented",
135 ),177 ),
136- (
137- "enable-superres",
138- "never spelled: the three superres gates drive `--superres-mode=1` instead, so the tool IS exercised but not under this flag -- retire this entry only by renaming the check, not by assuming coverage",
139- ),
140 (178 (
141 "enable-tx64",179 "enable-tx64",
142 "never spelled; TX_64X64 appears only where aomenc's default picks it, which is unknown per stream",180 "never spelled; TX_64X64 appears only where aomenc's default picks it, which is unknown per stream",
@@ -161,7 +199,7 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[
161 // gate passes `=1` for both.199 // gate passes `=1` for both.
162 (200 (
163 "enable-1to4-partitions",201 "enable-1to4-partitions",
164- "hole at both depths, see the 8-bit list",202+ "10-bit hole only: lane-tx64x16's 8-bit SB-level 1:4 gate passes `=1` and asserts both arms, but no 10-bit gate does",
165 ),203 ),
166 (204 (
167 "enable-angle-delta",205 "enable-angle-delta",
@@ -185,16 +223,81 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[
185 "enable-ref-frame-mvs",223 "enable-ref-frame-mvs",
186 "hole at both depths, see the 8-bit list",224 "hole at both depths, see the 8-bit list",
187 ),225 ),
226+ ("enable-tx64", "hole at both depths, see the 8-bit list"),
227+];
228+
229+/// [`DEFAULT_ON_TOOLS`] entries no 8-bit gate spells on, with the reason.
230+///
231+/// Each entry is `(tool, why)`; the reason states whether the tool is pinned
232+/// OFF in every gate that names it (a hard hole -- no stream can carry it) or
233+/// merely defaulted (unknown, and unknown is not coverage).
234+#[cfg(test)]
235+const NEVER_ON_8BIT: &[(&str, &str)] = &[
188 (236 (
189- "enable-superres",237+ "deblocking",
190- "the 10-bit superres gate drives `--superres-mode=1`, not this flag; see the 8-bit entry",238+ "on in no 8-bit gate: 7 pin --loopfilter-control=0, the other 34 default (on) -- and defaulted is unknown, so no stream is proven to run the loop filter",
239+ ),
240+ (
241+ "enable-diff-wtd-comp",
242+ "on in no 8-bit gate: 6 pin =0, 35 default; difference-weighted compound masks are unproven",
243+ ),
244+ (
245+ "enable-directional-intra",
246+ "on in no 8-bit gate: pinned =0 in 32 of 41, defaulted in 9 -- the directional gates drive the modes through other flags, never this one",
247+ ),
248+ (
249+ "enable-fwd-kf",
250+ "on in no 8-bit gate: 11 pin =0, 30 default (aomenc's default is off), so forward keyframes are never coded",
251+ ),
252+ (
253+ "enable-onesided-comp",
254+ "on in no 8-bit gate: 17 pin =0, 24 default; one-sided compound prediction is unproven",
255+ ),
256+ (
257+ "enable-tx-size-search",
258+ "on in no 8-bit gate: pinned =0 in 34 of 41 -- the pin that hid a real-stream PANIC from lane-ab16 until TX_MODE_SELECT was landed by lane-txselect; its gates spell the tool through the recipe, not this flag",
259+ ),
260+];
261+
262+/// [`DEFAULT_ON_TOOLS`] entries no 10-bit gate spells on, with the reason.
263+#[cfg(test)]
264+const NEVER_ON_10BIT: &[(&str, &str)] = &[
265+ (
266+ "deblocking",
267+ "hole at both depths, see the 8-bit list (1 of the 15 10-bit gates pins =0, 14 default)",
268+ ),
269+ (
270+ "enable-diff-wtd-comp",
271+ "hole at both depths, see the 8-bit list (1 pinned off, 14 defaulted)",
272+ ),
273+ (
274+ "enable-fwd-kf",
275+ "hole at both depths, see the 8-bit list (3 pinned off, 12 defaulted)",
276+ ),
277+ (
278+ "enable-interintra-wedge",
279+ "on in no 10-bit gate: 5 pin =0, 10 default -- wedge interintra masks are exercised at 8 bits only, the shape that cost lane-hbdinter two 10-bit-only defects",
280+ ),
281+ (
282+ "enable-onesided-comp",
283+ "hole at both depths, see the 8-bit list (5 pinned off, 10 defaulted)",
284+ ),
285+ (
286+ "enable-tx-size-search",
287+ "hole at both depths, see the 8-bit list (11 of 15 pin =0)",
288+ ),
289+ (
290+ "multi-tile",
291+ "on in no 10-bit gate: all 15 leave --tile-columns/--tile-rows defaulted at 0, so every 10-bit stream is single-tile and no tile edge or per-tile CDF reset is checked at high bit depth",
191 ),292 ),
192- ("enable-tx64", "hole at both depths, see the 8-bit list"),
193 ];293 ];
194 294
195 #[cfg(test)]295 #[cfg(test)]
196 mod tests {296 mod tests {
197- use super::{NEVER_EXERCISED, NEVER_EXERCISED_8BIT, NEVER_EXERCISED_10BIT, TOOL_UNIVERSE};297+ use super::{
298+ ALIASES, DEFAULT_ON_TOOLS, NEVER_EXERCISED, NEVER_EXERCISED_8BIT, NEVER_EXERCISED_10BIT,
299+ NEVER_ON_10BIT, NEVER_ON_8BIT, On, TOOL_UNIVERSE,
300+ };
198 use std::collections::{BTreeMap, BTreeSet};301 use std::collections::{BTreeMap, BTreeSet};
199 302
200 /// Bodies of the real-aomenc gates: a `fn` body carrying the shared303 /// Bodies of the real-aomenc gates: a `fn` body carrying the shared
@@ -241,6 +344,43 @@ mod tests {
241 here344 here
242 }345 }
243 346
347+ /// Every `--flag=value` spelled inside one gate body, values kept whole
348+ /// (`--cpu-used=4`, `--tile-columns=2`), not just their first character.
349+ fn settings_in(gate: &str) -> BTreeMap<String, String> {
350+ let mut here = BTreeMap::new();
351+ for (i, _) in gate.match_indices("\"--") {
352+ let rest = &gate[i + 3..];
353+ let Some(end) = rest.find('"') else { continue };
354+ let Some((flag, value)) = rest[..end].split_once('=') else {
355+ continue;
356+ };
357+ here.insert(flag.to_owned(), value.to_owned());
358+ }
359+ here
360+ }
361+
362+ /// Whether a gate body spells one [`DEFAULT_ON_TOOLS`] entry on / off.
363+ fn default_on_state(gate: &str, spellings: &[&str], on: On) -> Option<bool> {
364+ let here = settings_in(gate);
365+ let mut state = None;
366+ for spelling in spellings {
367+ let Some(value) = here.get(*spelling) else {
368+ continue;
369+ };
370+ let Ok(value) = value.parse::<u32>() else {
371+ continue;
372+ };
373+ let is_on = match on {
374+ On::NonZero => value != 0,
375+ On::AtMost(limit) => value <= limit,
376+ };
377+ // Any spelling that says "on" wins: --tile-columns=0 --tile-rows=1
378+ // is a multi-tile stream.
379+ state = Some(state.unwrap_or(false) || is_on);
380+ }
381+ state
382+ }
383+
244 /// `--enable-*` settings per real-aomenc gate, derived from the gate384 /// `--enable-*` settings per real-aomenc gate, derived from the gate
245 /// source: `flag -> (turned off in N gates, turned on in N, defaulted in N)`.385 /// source: `flag -> (turned off in N gates, turned on in N, defaulted in N)`.
246 fn tool_settings() -> (usize, BTreeMap<String, (usize, usize, usize)>) {386 fn tool_settings() -> (usize, BTreeMap<String, (usize, usize, usize)>) {
@@ -347,6 +487,13 @@ mod tests {
347 on.insert(flag);487 on.insert(flag);
348 }488 }
349 }489 }
490+ // A tool driven by its own spelling counts as exercised.
491+ let here = settings_in(gate);
492+ for (alias, tool) in ALIASES {
493+ if here.get(*alias).is_some_and(|v| v != "0") {
494+ on.insert((*tool).to_owned());
495+ }
496+ }
350 }497 }
351 on498 on
352 }499 }
@@ -415,4 +562,110 @@ mod tests {
415 }562 }
416 }563 }
417 }564 }
565+
566+ /// [`DEFAULT_ON_TOOLS`] per depth: `tool -> (off in N gates, on in N, defaulted in N)`.
567+ fn default_on_settings(ten_bit: bool) -> (usize, BTreeMap<&'static str, (usize, usize, usize)>) {
568+ let gates: Vec<&str> = gate_bodies()
569+ .into_iter()
570+ .filter(|b| is_ten_bit(b) == ten_bit)
571+ .collect();
572+ let mut per_tool = BTreeMap::new();
573+ for &(tool, spellings, _, on) in DEFAULT_ON_TOOLS {
574+ let states: Vec<Option<bool>> = gates
575+ .iter()
576+ .map(|g| default_on_state(g, spellings, on))
577+ .collect();
578+ let turned_on = states.iter().filter(|s| **s == Some(true)).count();
579+ let turned_off = states.iter().filter(|s| **s == Some(false)).count();
580+ per_tool.insert(
581+ tool,
582+ (turned_off, turned_on, gates.len() - turned_off - turned_on),
583+ );
584+ }
585+ (gates.len(), per_tool)
586+ }
587+
588+ /// The [`DEFAULT_ON_TOOLS`] no gate of this depth positively enables.
589+ fn never_on_at(ten_bit: bool) -> BTreeSet<&'static str> {
590+ default_on_settings(ten_bit)
591+ .1
592+ .into_iter()
593+ .filter(|&(_, (_, on, _))| on == 0)
594+ .map(|(tool, _)| tool)
595+ .collect()
596+ }
597+
598+ fn check_default_on(ten_bit: bool, listed: &[(&str, &str)]) {
599+ let derived = never_on_at(ten_bit);
600+ let listed: BTreeSet<&str> = listed.iter().map(|&(tool, _)| tool).collect();
601+ let depth = if ten_bit { "10-bit" } else { "8-bit" };
602+ let unlisted: Vec<&&str> = derived.difference(&listed).collect();
603+ assert!(
604+ unlisted.is_empty(),
605+ "no {depth} gate spells an on-value for {unlisted:?}, so no real {depth} stream is \
606+ proven to carry them -- switch the tool on in a {depth} gate that asserts it fired, \
607+ or list it with a reason"
608+ );
609+ let stale: Vec<&&str> = listed.difference(&derived).collect();
610+ assert!(
611+ stale.is_empty(),
612+ "the {depth} default-on list still names {stale:?}, but a {depth} gate now switches \
613+ them on -- delete those entries, the coverage hole is closed"
614+ );
615+ }
616+
617+ #[test]
618+ fn never_on_8bit_matches_the_gate_recipes() {
619+ check_default_on(false, NEVER_ON_8BIT);
620+ }
621+
622+ #[test]
623+ fn never_on_10bit_matches_the_gate_recipes() {
624+ check_default_on(true, NEVER_ON_10BIT);
625+ }
626+
627+ /// A tool must not be pinned twice: [`TOOL_UNIVERSE`] already derives the
628+ /// `--enable-*` spellings under the `=1` rule.
629+ #[test]
630+ fn default_on_tools_do_not_duplicate_the_universe() {
631+ for &(tool, spellings, _, _) in DEFAULT_ON_TOOLS {
632+ assert!(
633+ !TOOL_UNIVERSE.contains(&tool),
634+ "{tool} is already covered by TOOL_UNIVERSE"
635+ );
636+ assert!(!spellings.is_empty(), "{tool} has no aomenc spelling");
637+ }
638+ for (alias, tool) in ALIASES {
639+ assert!(
640+ TOOL_UNIVERSE.contains(tool),
641+ "alias --{alias} names {tool}, which is not a TOOL_UNIVERSE tool"
642+ );
643+ }
644+ }
645+
646+ /// `cargo test -p ec-av1 --lib gate_coverage -- --nocapture` prints the
647+ /// default-on holes with their off/defaulted split.
648+ #[test]
649+ fn print_never_on_per_bit_depth() {
650+ for (label, ten_bit) in [("8BIT", false), ("10BIT", true)] {
651+ let (gate_count, per_tool) = default_on_settings(ten_bit);
652+ let holes = never_on_at(ten_bit);
653+ println!(
654+ "NEVER_ON_{label} ({} of {}, over {gate_count} {label} gates):",
655+ holes.len(),
656+ DEFAULT_ON_TOOLS.len()
657+ );
658+ for tool in &holes {
659+ let (off, _, defaulted) = per_tool[tool];
660+ let spellings = DEFAULT_ON_TOOLS
661+ .iter()
662+ .find(|e| e.0 == *tool)
663+ .map(|e| e.1.join(","))
664+ .unwrap_or_default();
665+ println!(
666+ " {tool} (--{spellings}): off in {off}, defaulted in {defaulted}, on in 0"
667+ );
668+ }
669+ }
670+ }
418 }671 }
crates/ec-av1/src/mc.rsmodified+115 -46
@@ -119,8 +119,11 @@ const SUBPEL_FILTERS_SMOOTH_4: [[i32; 8]; 16] = [
119 [0, 0, 2, 34, 62, 30, 0, 0],119 [0, 0, 2, 34, 62, 30, 0, 0],
120 ];120 ];
121 121
122-/// `Subpel_Filters[EIGHTTAP_SHARP]` (`av1_sub_pel_filters_8sharp`) -- unlike122+/// `Subpel_Filters[EIGHTTAP_SHARP]` (`av1_sub_pel_filters_8sharp`). A block
123-/// REGULAR/SMOOTH, spec 7.11.3.4 never swaps this for a narrow-block table.123+/// whose dimension is 4 or less does NOT read this table: spec 7.11.3.4's
124+/// `filterIdx` sends both EIGHTTAP and EIGHTTAP_SHARP to filter index 4, and
125+/// libaom agrees -- `av1_interp_4tap[MULTITAP_SHARP]` is `av1_sub_pel_filters_4`,
126+/// the REGULAR narrow kernel (`filter.h:243`), not a sharp one (lane-gmaffine r5).
124 const SUBPEL_FILTERS_SHARP: [[i32; 8]; 16] = [127 const SUBPEL_FILTERS_SHARP: [[i32; 8]; 16] = [
125 [0, 0, 0, 128, 0, 0, 0, 0],128 [0, 0, 0, 128, 0, 0, 0, 0],
126 [-2, 2, -6, 126, 8, -2, 2, 0],129 [-2, 2, -6, 126, 8, -2, 2, 0],
@@ -181,7 +184,7 @@ impl InterpFilterKind {
181 match self {184 match self {
182 InterpFilterKind::Regular => (&SUBPEL_FILTERS, &SUBPEL_FILTERS_4),185 InterpFilterKind::Regular => (&SUBPEL_FILTERS, &SUBPEL_FILTERS_4),
183 InterpFilterKind::Smooth => (&SUBPEL_FILTERS_SMOOTH, &SUBPEL_FILTERS_SMOOTH_4),186 InterpFilterKind::Smooth => (&SUBPEL_FILTERS_SMOOTH, &SUBPEL_FILTERS_SMOOTH_4),
184- InterpFilterKind::Sharp => (&SUBPEL_FILTERS_SHARP, &SUBPEL_FILTERS_SHARP),187+ InterpFilterKind::Sharp => (&SUBPEL_FILTERS_SHARP, &SUBPEL_FILTERS_4),
185 InterpFilterKind::Bilinear => (&SUBPEL_FILTERS_BILINEAR, &SUBPEL_FILTERS_BILINEAR),188 InterpFilterKind::Bilinear => (&SUBPEL_FILTERS_BILINEAR, &SUBPEL_FILTERS_BILINEAR),
186 }189 }
187 }190 }
@@ -476,6 +479,54 @@ fn round_pow2_signed_64(value: i64, shift: u32) -> i64 {
476 }479 }
477 }480 }
478 481
482+/// Spec 7.11.3.3's horizontal pass on a (possibly) scaled reference, shared
483+/// by [`predict_scaled`] and [`predict_compound_intermediate`] -- the two
484+/// differ only in their VERTICAL rounding ([`INTER_ROUND_1`] vs
485+/// [`INTER_ROUND_1_COMPOUND`]), never here. Each output column walks the
486+/// reference by `x_step_qn` (the Q14 scale rounded down to the Q10
487+/// `SCALE_SUBPEL_BITS` grid) and picks its own filter phase from the low
488+/// bits, so `x_scale_fp == REF_NO_SCALE` reduces to the ordinary stride-1
489+/// whole-pel walk with one fixed phase (pinned by
490+/// `predict_scaled_at_no_scale_matches_predict_with_filters`).
491+#[allow(clippy::too_many_arguments)]
492+fn horizontal_scaled_pass(
493+ reference: &[u16],
494+ stride: usize,
495+ true_width: usize,
496+ true_height: usize,
497+ x_q4: i32,
498+ y0: i32,
499+ x_scale_fp: i64,
500+ block_w: usize,
501+ rows: usize,
502+ h_kind: InterpFilterKind,
503+ intermediate: &mut [i32],
504+) {
505+ let x_step_qn = round_pow2_64(x_scale_fp, 4);
506+ let off = (x_scale_fp - REF_NO_SCALE) * 8;
507+ let pos_x_q10 = round_pow2_signed_64(x_q4 as i64 * x_scale_fp + off, 8) + 32;
508+ let (h_wide, h_narrow) = h_kind.tables();
509+ for c in 0..block_w {
510+ let x_qn = pos_x_q10 + c as i64 * x_step_qn;
511+ let int_pel = (x_qn >> 10) as i32;
512+ let filter_idx = ((x_qn & 1023) >> 6) as usize;
513+ let h_filter = if block_w <= 4 {
514+ &h_narrow[filter_idx]
515+ } else {
516+ &h_wide[filter_idx]
517+ };
518+ for r in 0..rows {
519+ let y = y0 - 3 + r as i32;
520+ let mut sum = 0;
521+ for (t, &tap) in h_filter.iter().enumerate() {
522+ let x = int_pel + t as i32 - 3;
523+ sum += tap * sample(reference, stride, true_width, true_height, x, y);
524+ }
525+ intermediate[r * block_w + c] = round2(sum, INTER_ROUND_0);
526+ }
527+ }
528+}
529+
479 /// [`predict_with_filters`]'s scaled-reference counterpart (spec 7.11.3.3):530 /// [`predict_with_filters`]'s scaled-reference counterpart (spec 7.11.3.3):
480 /// used only when the stored reference's luma width differs from the current531 /// used only when the stored reference's luma width differs from the current
481 /// frame's (`use_superres` on a non-key frame). `x_scale_fp` is532 /// frame's (`use_superres` on a non-key frame). `x_scale_fp` is
@@ -516,11 +567,6 @@ pub fn predict_scaled(
516 // SCALE_SUBPEL_BITS == 10: x_step_qn is x_scale_fp (Q14) rounded down to567 // SCALE_SUBPEL_BITS == 10: x_step_qn is x_scale_fp (Q14) rounded down to
517 // Q10; off/pos_x_q10 fold the block's own x_q4 (Q4) into that same Q10568 // Q10; off/pos_x_q10 fold the block's own x_q4 (Q4) into that same Q10
518 // grid (spec 7.11.3.3's `dec_calc_subpel_params`).569 // grid (spec 7.11.3.3's `dec_calc_subpel_params`).
519- let x_step_qn = round_pow2_64(x_scale_fp, 4);
520- let off = (x_scale_fp - REF_NO_SCALE) * 8;
521- let pos_x_q10 = round_pow2_signed_64(x_q4 as i64 * x_scale_fp + off, 8) + 32;
522-
523- let (h_wide, h_narrow) = h_kind.tables();
524 let (v_wide, v_narrow) = v_kind.tables();570 let (v_wide, v_narrow) = v_kind.tables();
525 let v_filter = if block_h <= 4 {571 let v_filter = if block_h <= 4 {
526 &v_narrow[yfrac]572 &v_narrow[yfrac]
@@ -530,25 +576,19 @@ pub fn predict_scaled(
530 576
531 let rows = block_h + 7;577 let rows = block_h + 7;
532 let mut intermediate = vec![0i32; rows * block_w];578 let mut intermediate = vec![0i32; rows * block_w];
533- for c in 0..block_w {579+ horizontal_scaled_pass(
534- let x_qn = pos_x_q10 + c as i64 * x_step_qn;580+ reference,
535- let int_pel = (x_qn >> 10) as i32;581+ stride,
536- let filter_idx = ((x_qn & 1023) >> 6) as usize;582+ true_width,
537- let h_filter = if block_w <= 4 {583+ true_height,
538- &h_narrow[filter_idx]584+ x_q4,
539- } else {585+ y0,
540- &h_wide[filter_idx]586+ x_scale_fp,
541- };587+ block_w,
542- for r in 0..rows {588+ rows,
543- let y = y0 - 3 + r as i32;589+ h_kind,
544- let mut sum = 0;590+ &mut intermediate,
545- for (t, &tap) in h_filter.iter().enumerate() {591+ );
546- let x = int_pel + t as i32 - 3;
547- sum += tap * sample(reference, stride, true_width, true_height, x, y);
548- }
549- intermediate[r * block_w + c] = round2(sum, INTER_ROUND_0);
550- }
551- }
552 592
553 for row in 0..block_h {593 for row in 0..block_h {
554 for col in 0..block_w {594 for col in 0..block_w {
@@ -602,6 +642,7 @@ pub fn predict_compound_intermediate(
602 true_height: usize,642 true_height: usize,
603 x_q4: i32,643 x_q4: i32,
604 y_q4: i32,644 y_q4: i32,
645+ x_scale_fp: i64,
605 block_w: usize,646 block_w: usize,
606 block_h: usize,647 block_h: usize,
607 h_kind: InterpFilterKind,648 h_kind: InterpFilterKind,
@@ -612,18 +653,14 @@ pub fn predict_compound_intermediate(
612 assert!(!reference.is_empty(), "a reference plane has samples");653 assert!(!reference.is_empty(), "a reference plane has samples");
613 INTER_PRED_HITS.with(|c| c.set(c.get() + 1));654 INTER_PRED_HITS.with(|c| c.set(c.get() + 1));
614 655
615- let x0 = x_q4.div_euclid(16);656+ if x_scale_fp != REF_NO_SCALE {
616- let xfrac = x_q4.rem_euclid(16) as usize;657+ PREDICT_SCALED_HITS.with(|c| c.set(c.get() + 1));
658+ }
659+
617 let y0 = y_q4.div_euclid(16);660 let y0 = y_q4.div_euclid(16);
618 let yfrac = y_q4.rem_euclid(16) as usize;661 let yfrac = y_q4.rem_euclid(16) as usize;
619 662
620- let (h_wide, h_narrow) = h_kind.tables();
621 let (v_wide, v_narrow) = v_kind.tables();663 let (v_wide, v_narrow) = v_kind.tables();
622- let h_filter = if block_w <= 4 {
623- &h_narrow[xfrac]
624- } else {
625- &h_wide[xfrac]
626- };
627 let v_filter = if block_h <= 4 {664 let v_filter = if block_h <= 4 {
628 &v_narrow[yfrac]665 &v_narrow[yfrac]
629 } else {666 } else {
@@ -632,17 +669,19 @@ pub fn predict_compound_intermediate(
632 669
633 let rows = block_h + 7;670 let rows = block_h + 7;
634 let mut intermediate = vec![0i32; rows * block_w];671 let mut intermediate = vec![0i32; rows * block_w];
635- for r in 0..rows {672+ horizontal_scaled_pass(
636- let y = y0 - 3 + r as i32;673+ reference,
637- for c in 0..block_w {674+ stride,
638- let mut sum = 0;675+ true_width,
639- for (t, &tap) in h_filter.iter().enumerate() {676+ true_height,
640- let x = x0 + c as i32 + t as i32 - 3;677+ x_q4,
641- sum += tap * sample(reference, stride, true_width, true_height, x, y);678+ y0,
642- }679+ x_scale_fp,
643- intermediate[r * block_w + c] = round2(sum, INTER_ROUND_0);680+ block_w,
644- }681+ rows,
645- }682+ h_kind,
683+ &mut intermediate,
684+ );
646 685
647 for row in 0..block_h {686 for row in 0..block_h {
648 for col in 0..block_w {687 for col in 0..block_w {
@@ -775,6 +814,7 @@ fn compound_intermediate_whole_pel_identity_round_trips_through_combine() {
775 16,814 16,
776 0,815 0,
777 0,816 0,
817+ REF_NO_SCALE,
778 4,818 4,
779 4,819 4,
780 InterpFilterKind::Regular,820 InterpFilterKind::Regular,
@@ -884,6 +924,35 @@ mod tests {
884 );924 );
885 }925 }
886 926
927+ /// lane-gmaffine r5 root cause: a block 4 or fewer samples wide reads
928+ /// `Subpel_Filters[4]` -- the REGULAR narrow kernel -- for BOTH
929+ /// `EIGHTTAP` and `EIGHTTAP_SHARP` (spec 7.11.3.4's `filterIdx`, libaom
930+ /// `av1_interp_4tap[MULTITAP_SHARP] == av1_sub_pel_filters_4`,
931+ /// `filter.h:243`). We used the 8-tap sharp kernel there, which is
932+ /// invisible above 4 samples and so only ever bit the 4x4 chroma of an
933+ /// 8x8 (or smaller) luma leaf.
934+ #[test]
935+ fn a_narrow_block_reads_the_regular_four_tap_kernel_under_every_sharpness() {
936+ use crate::mc::{SUBPEL_FILTERS_4, SUBPEL_FILTERS_BILINEAR, SUBPEL_FILTERS_SMOOTH_4};
937+ for kind in [
938+ InterpFilterKind::Regular,
939+ InterpFilterKind::Smooth,
940+ InterpFilterKind::Sharp,
941+ InterpFilterKind::Bilinear,
942+ ] {
943+ let (wide, narrow) = kind.tables();
944+ let want: &[[i32; 8]; 16] = match kind {
945+ InterpFilterKind::Regular | InterpFilterKind::Sharp => &SUBPEL_FILTERS_4,
946+ InterpFilterKind::Smooth => &SUBPEL_FILTERS_SMOOTH_4,
947+ InterpFilterKind::Bilinear => &SUBPEL_FILTERS_BILINEAR,
948+ };
949+ assert_eq!(narrow, want, "{kind:?}: wrong narrow-block kernel");
950+ if kind == InterpFilterKind::Sharp {
951+ assert_ne!(wide, narrow, "sharp's wide kernel is not its narrow one");
952+ }
953+ }
954+ }
955+
887 #[test]956 #[test]
888 fn integer_mv_is_identity() {957 fn integer_mv_is_identity() {
889 let width = 12;958 let width = 12;
crates/ec-av1/src/refusal_inventory.rsmodified+2 -8
@@ -34,7 +34,6 @@ const CAPABILITY_CLAIMS: &[&str] = &[
34 34
35 #[cfg(test)]35 #[cfg(test)]
36 const REFUSALS: &[&str] = &[36 const REFUSALS: &[&str] = &[
37- "GLOBALMV (round 3)",
38 "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)",37 "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)",
39 "a coded (non-skip) HORZ/VERT rect strip below 16x16 (this decoder ports only the skip case at this size)",38 "a coded (non-skip) HORZ/VERT rect strip below 16x16 (this decoder ports only the skip case at this size)",
40 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",39 "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here",
@@ -44,10 +43,9 @@ const REFUSALS: &[&str] = &[
44 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",43 "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
45 "a 32x32 partition type this decoder does not code (value={part32})",44 "a 32x32 partition type this decoder does not code (value={part32})",
46 "a Golomb tail longer than this decoder reads",45 "a Golomb tail longer than this decoder reads",
47- "a superblock-level HORZ/VERT strip with a split transform (per-unit rect prediction is not ported)",
48 "a tx_type symbol outside its CDF's own set: {t}",46 "a tx_type symbol outside its CDF's own set: {t}",
49 "an INTER 32x32 partition type this decoder does not code (value={part32})",47 "an INTER 32x32 partition type this decoder does not code (value={part32})",
50- "a superblock-level 1:4 partition (PARTITION_HORZ_4/VERT_4 at 64x64, four 64x16/16x64 strips)",48+ "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4",
51 "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)",49 "a palette block on a HORZ/VERT intra strip below 16x16 (reconstruction not ported)",
52 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",50 "a palette block with a real transform on a superblock-level HORZ/VERT strip (corner-cropped luma coefficients not ported for palette)",
53 "a block that actually uses a palette (UV) -- reconstruction is out of scope",51 "a block that actually uses a palette (UV) -- reconstruction is out of scope",
@@ -59,14 +57,11 @@ const REFUSALS: &[&str] = &[
59 "a frame with no mode-info grid",57 "a frame with no mode-info grid",
60 "a frame whose segmentation enables SEG_LVL_REF_FRAME/SKIP/GLOBALMV (this decoder reads segment_id but never lets a segment override a block's reference, skip or mode)",58 "a frame whose segmentation enables SEG_LVL_REF_FRAME/SKIP/GLOBALMV (this decoder reads segment_id but never lets a segment override a block's reference, skip or mode)",
61 "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding",59 "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding",
62- "a reference frame other than LAST_FRAME (round 2)",
63 "a reference frame selected with no picture at this frame's own ref_frame_idx slot for it",60 "a reference frame selected with no picture at this frame's own ref_frame_idx slot for it",
64 "a reference picture whose height does not match this frame's own true size",61 "a reference picture whose height does not match this frame's own true size",
65 "a show_existing_frame header naming an empty reference slot",62 "a show_existing_frame header naming an empty reference slot",
66- "an 8x8 leaf that coded WARPED_CAUSAL (motion_mode == 2): av1_find_projection/the affine warp filter are not ported, only motion_mode_allowed's alphabet choice is",
67 "an inter var-tx tree with a leaf transform larger than 32x32",63 "an inter var-tx tree with a leaf transform larger than 32x32",
68 "an intra block in an inter frame whose tx_depth splits its luma transform (round 1)",64 "an intra block in an inter frame whose tx_depth splits its luma transform (round 1)",
69- "an inter frame whose global motion for a single-reference frame is AFFINE (unverified this round; ROTZOOM/TRANSLATION/IDENTITY are proven)",
70 "an inter frame with no key frame before it",65 "an inter frame with no key frame before it",
71 "an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path recurses a superblock only as SPLIT)",66 "an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path recurses a superblock only as SPLIT)",
72 "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)",67 "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)",
@@ -74,8 +69,7 @@ const REFUSALS: &[&str] = &[
74 "an intra mode this decoder does not code (round 2)",69 "an intra mode this decoder does not code (round 2)",
75 "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet",70 "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet",
76 "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",71 "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",
77- "a compound-reference block with a scaled reference (superres, unimplemented)",72+ "warp prediction with a scaled reference (superres, unimplemented)",
78- "warp/OBMC/interintra prediction with a scaled reference (superres, unimplemented)",
79 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",73 "an 8x8 partition leaf under a scaled reference (superres, unimplemented)",
80 ];74 ];
81 75
crates/ec-av1/src/stream.rsmodified+1475 -146

Diff too large; view file

@@ -18,7 +18,6 @@
18 use ec_av1_syntax::{18 use ec_av1_syntax::{
19 Av1Parser, FrameHeader, FrameType, MAX_SEGMENTS, NUM_REF_FRAMES, ObuKind, PRIMARY_REF_NONE,19 Av1Parser, FrameHeader, FrameType, MAX_SEGMENTS, NUM_REF_FRAMES, ObuKind, PRIMARY_REF_NONE,
20 SEG_LVL_GLOBALMV, SEG_LVL_REF_FRAME, SEG_LVL_SKIP, Tile, TxMode,20 SEG_LVL_GLOBALMV, SEG_LVL_REF_FRAME, SEG_LVL_SKIP, Tile, TxMode,
21- WarpModel,
22 };21 };
23 use ec_core::{Error, Result};22 use ec_core::{Error, Result};
24 23
@@ -375,16 +374,20 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
375 // needed). AFFINE is untested this round (no aomenc fixture in the374 // needed). AFFINE is untested this round (no aomenc fixture in the
376 // wedge gate reached a 6-parameter model) -- keep refusing it by375 // wedge gate reached a 6-parameter model) -- keep refusing it by
377 // name rather than shipping an unverified decode.376 // name rather than shipping an unverified decode.
378- if header.frame_type != FrameType::Key377+ // lane-gmaffine r1: AFFINE is now GATED, not refused. Stock libaom
379- && header.global_motion[..7]378+ // can never write a 6-parameter model -- its encoder-side search is
380- .iter()379+ // pinned to ROTZOOM (`av1/encoder/global_motion_facade.c:24`,
381- .any(|gm| gm.model == WarpModel::Affine)380+ // `FIRST_GLOBAL_TRANS_TYPE == LAST_GLOBAL_TRANS_TYPE == ROTZOOM`) --
382- {381+ // which is why four rounds of `--enable-global-motion=1` recipes
383- return Err(Error::unsupported(382+ // never reached the case. `scripts/build-aom-affine-oracle.sh` widens
384- "AV1 decode_stream",383+ // exactly that search range in a side build, and
385- "an inter frame whose global motion for a single-reference frame is AFFINE (unverified this round; ROTZOOM/TRANSLATION/IDENTITY are proven)",384+ // `a_real_affine_global_motion_stream_decodes_pixel_exact` below
386- ));385+ // decodes its output pixel-exact against ffmpeg with
387- }386+ // `affine_gm_hits() > 0`, i.e. real blocks predicted through the
387+ // 6-parameter warp. Nothing in the decoder needed changing: the
388+ // header reader already reads params 4/5 with their own subexp refs
389+ // (`ec-av1-syntax` `read_global_motion_params`) and `warp.rs`'s
390+ // shear-validity check + `warp_affine` are model-agnostic.
388 // lane-gm r4/r5/r6: r4 found a NEW mismatch on frames with two391 // lane-gm r4/r5/r6: r4 found a NEW mismatch on frames with two
389 // concurrently active ROTZOOM/AFFINE ref slots (GOLDEN + BWDREF) and392 // concurrently active ROTZOOM/AFFINE ref slots (GOLDEN + BWDREF) and
390 // refused the shape by name rather than guess-fix it. r5 localized393 // refused the shape by name rather than guess-fix it. r5 localized
@@ -973,6 +976,18 @@ mod tests {
973 /// mutex makes firing detection honest again (matches the existing976 /// mutex makes firing detection honest again (matches the existing
974 /// cdf-forwarding-gate flake shape, ledger `omp-liveness-pgrep-self-match`).977 /// cdf-forwarding-gate flake shape, ledger `omp-liveness-pgrep-self-match`).
975 static GATE_COUNTER_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());978 static GATE_COUNTER_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
979+ /// Three-bucket gate summary (class [[gate-skips-on-its-own-failure]]):
980+ /// every attempt lands in exactly one bucket -- decoded pixel-exact WITH
981+ /// the feature counter moving, decoded pixel-exact WITHOUT it, or a named
982+ /// refusal -- and the three sum to the attempts made.
983+ fn gate_buckets(name: &str, counted_exact: u32, uncounted_exact: u32, named_refusals: usize) {
984+ eprintln!(
985+ "{name}: buckets counted-exact={counted_exact} uncounted-exact={uncounted_exact} \
986+ named-refusals={named_refusals} (attempts {})",
987+ counted_exact as usize + uncounted_exact as usize + named_refusals
988+ );
989+ }
990+
976 fn lock_gate_counters() -> std::sync::MutexGuard<'static, ()> {991 fn lock_gate_counters() -> std::sync::MutexGuard<'static, ()> {
977 GATE_COUNTER_LOCK.lock().unwrap_or_else(|e| e.into_inner())992 GATE_COUNTER_LOCK.lock().unwrap_or_else(|e| e.into_inner())
978 }993 }
@@ -1775,6 +1790,68 @@ mod tests {
1775 (oracle_frames, hidden)1790 (oracle_frames, hidden)
1776 }1791 }
1777 1792
1793+ /// lane-hidden r2: the `--arnr-maxframes=0` SECOND ARM of an existing
1794+ /// gate -- the gate's own recipe is never changed, this re-encodes the
1795+ /// same fixture with libaom's temporal alt-ref filter switched off and
1796+ /// runs [`decode_all_frames_vs_oracle`] on the result. Measured: with
1797+ /// the filter at its default EVERY alt-ref recipe in this file emits
1798+ /// ZERO hidden frames (the candidates are filtered away), so the
1799+ /// hidden-frame compare on the gate's own stream is vacuous; this arm
1800+ /// is what actually puts `show_frame == 0` frames on the wire.
1801+ ///
1802+ /// Runs at most once per gate name per process (the loop gates sweep
1803+ /// dozens of attempts and each arm costs a full encode + two decodes).
1804+ /// A stream this decoder refuses BY NAME skips the arm -- the arm is
1805+ /// about hidden frames, not about that capability gap -- while a pixel
1806+ /// mismatch is a hard failure raised inside the compare.
1807+ fn hidden_arnr_arm(name: &str, y4m: &[u8], args: &[&str]) -> Option<(usize, usize)> {
1808+ static ARMED: std::sync::OnceLock<std::sync::Mutex<std::collections::HashSet<String>>> =
1809+ std::sync::OnceLock::new();
1810+ if !ARMED
1811+ .get_or_init(Default::default)
1812+ .lock()
1813+ .unwrap()
1814+ .insert(name.to_string())
1815+ {
1816+ return None;
1817+ }
1818+ let mut arm: Vec<&str> = vec!["--arnr-maxframes=0"];
1819+ arm.extend_from_slice(args);
1820+ let mut child = Command::new(aomenc_path())
1821+ .args(&arm)
1822+ .stdin(Stdio::piped())
1823+ .stdout(Stdio::piped())
1824+ .stderr(Stdio::piped())
1825+ .spawn()
1826+ .expect("aomenc failed to start");
1827+ child
1828+ .stdin
1829+ .take()
1830+ .expect("aomenc stdin")
1831+ .write_all(y4m)
1832+ .expect("writing y4m to aomenc");
1833+ let out = child.wait_with_output().expect("aomenc failed to run");
1834+ assert!(
1835+ out.status.success(),
1836+ "{name} HIDDEN-ARM: aomenc refused its own recipe plus --arnr-maxframes=0: {}",
1837+ String::from_utf8_lossy(&out.stderr)
1838+ );
1839+ let stream = out.stdout;
1840+ match decode_stream(&stream) {
1841+ Err(e) => {
1842+ let msg = e.to_string();
1843+ assert!(
1844+ msg.contains("unsupported"),
1845+ "{name} HIDDEN-ARM failed outright: {msg}"
1846+ );
1847+ eprintln!("{name} HIDDEN-ARM: skipped on a named refusal: {msg}");
1848+ None
1849+ }
1850+ Ok(_) => Some(decode_all_frames_vs_oracle(&stream, &format!("{name}-arnr0"))),
1851+ }
1852+ }
1853+
1854+
1778 /// The repo's first hidden-frame pixel gate. Every other aomenc gate1855 /// The repo's first hidden-frame pixel gate. Every other aomenc gate
1779 /// here compares `decode_stream`'s output against `ffmpeg -f obu`, and1856 /// here compares `decode_stream`'s output against `ffmpeg -f obu`, and
1780 /// both sides emit SHOWN frames only -- so an alt-ref frame that is1857 /// both sides emit SHOWN frames only -- so an alt-ref frame that is
@@ -3621,6 +3698,7 @@ mod tests {
3621 }3698 }
3622 let (width, height) = (64usize, 64usize);3699 let (width, height) = (64usize, 64usize);
3623 let mut refusals = Vec::new();3700 let mut refusals = Vec::new();
3701+ let mut uncounted_exact = 0u32;
3624 for attempt in 0..40u32 {3702 for attempt in 0..40u32 {
3625 let seed = 42 + attempt;3703 let seed = 42 + attempt;
3626 // A flat gradient never has enough local detail for the RD3704 // A flat gradient never has enough local detail for the RD
@@ -3735,11 +3813,16 @@ mod tests {
3735 continue;3813 continue;
3736 }3814 }
3737 };3815 };
3738- if decode::tx_depth_hits() == before {3816+ // class [[gate-skips-on-its-own-failure]]: a decode that succeeded
3817+ // is ALWAYS pixel-compared below; the hit counter only decides whether
3818+ // the attempt counts toward the firing total.
3819+ let counted = decode::tx_depth_hits() != before;
3820+ if !counted {
3821+ uncounted_exact += 1;
3739 refusals.push(format!(3822 refusals.push(format!(
3740- "seed {seed}: decoded, but no block resolved a split tx_depth"3823+ "seed {seed}: decoded and pixel-compared, but no block resolved a split \
3824+ tx_depth"
3741 ));3825 ));
3742- continue;
3743 }3826 }
3744 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);3827 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
3745 assert_eq!(3828 assert_eq!(
@@ -3748,8 +3831,22 @@ mod tests {
3748 );3831 );
3749 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");3832 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");
3750 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");3833 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");
3834+ if counted {
3835+ gate_buckets(
3836+ "a_real_aomenc_intra_stream_with_tx_select_decodes_pixel_exact",
3837+ 1,
3838+ uncounted_exact,
3839+ refusals.len() - uncounted_exact as usize,
3840+ );
3751 return;3841 return;
3752 }3842 }
3843+ }
3844+ gate_buckets(
3845+ "a_real_aomenc_intra_stream_with_tx_select_decodes_pixel_exact",
3846+ 0,
3847+ uncounted_exact,
3848+ refusals.len() - uncounted_exact as usize,
3849+ );
3753 eprintln!(3850 eprintln!(
3754 "SKIP a_real_aomenc_intra_stream_with_tx_select_decodes_pixel_exact: every attempt \3851 "SKIP a_real_aomenc_intra_stream_with_tx_select_decodes_pixel_exact: every attempt \
3755 hit a named refusal or never split a transform:\n{}",3852 hit a named refusal or never split a transform:\n{}",
@@ -3799,6 +3896,7 @@ mod tests {
3799 }3896 }
3800 let (width, height, frame_count) = (64usize, 64usize, 4usize);3897 let (width, height, frame_count) = (64usize, 64usize, 4usize);
3801 let mut refusals = Vec::new();3898 let mut refusals = Vec::new();
3899+ let mut uncounted_exact = 0u32;
3802 for attempt in 0..40u32 {3900 for attempt in 0..40u32 {
3803 let seed = 42 + attempt;3901 let seed = 42 + attempt;
3804 // Detail is what makes aomenc's RD prefer a split transform; a3902 // Detail is what makes aomenc's RD prefer a split transform; a
@@ -3936,11 +4034,16 @@ mod tests {
3936 decode::txfm_split_reads() - reads_before,4034 decode::txfm_split_reads() - reads_before,
3937 decode::txfm_split_hits() - hits_before,4035 decode::txfm_split_hits() - hits_before,
3938 );4036 );
3939- if hits == 0 {4037+ // class [[gate-skips-on-its-own-failure]]: a decode that succeeded
4038+ // is ALWAYS pixel-compared below; the hit counter only decides whether
4039+ // the attempt counts toward the firing total.
4040+ let counted = hits != 0;
4041+ if !counted {
4042+ uncounted_exact += 1;
3940 refusals.push(format!(4043 refusals.push(format!(
3941- "seed {seed}: decoded, but no block took a txfm_split ({reads} symbols read)"4044+ "seed {seed}: decoded and pixel-compared, but no block took a txfm_split \
4045+ ({reads} symbols read)"
3942 ));4046 ));
3943- continue;
3944 }4047 }
3945 let ffmpeg_frames = if bit_depth == 10 {4048 let ffmpeg_frames = if bit_depth == 10 {
3946 ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)4049 ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
@@ -3988,8 +4091,22 @@ mod tests {
3988 assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})");4091 assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})");
3989 assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed})");4092 assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed})");
3990 }4093 }
4094+ if counted {
4095+ gate_buckets(
4096+ &format!("tx_select_inter_gate({bit_depth})"),
4097+ 1,
4098+ uncounted_exact,
4099+ refusals.len() - uncounted_exact as usize,
4100+ );
3991 return;4101 return;
3992 }4102 }
4103+ }
4104+ gate_buckets(
4105+ &format!("tx_select_inter_gate({bit_depth})"),
4106+ 0,
4107+ uncounted_exact,
4108+ refusals.len() - uncounted_exact as usize,
4109+ );
3993 panic!(4110 panic!(
3994 "tx_select_inter_gate({bit_depth}) never observed a taken txfm_split:\n{}",4111 "tx_select_inter_gate({bit_depth}) never observed a taken txfm_split:\n{}",
3995 refusals.join("\n")4112 refusals.join("\n")
@@ -4022,6 +4139,7 @@ mod tests {
4022 let (width, height) = (64usize, 64usize);4139 let (width, height) = (64usize, 64usize);
4023 let mut refusals = Vec::new();4140 let mut refusals = Vec::new();
4024 let mut fired_runs = 0u32;4141 let mut fired_runs = 0u32;
4142+ let mut uncounted_exact = 0u32;
4025 for attempt in 0..40u32 {4143 for attempt in 0..40u32 {
4026 let seed = 42 + attempt;4144 let seed = 42 + attempt;
4027 let source = format!(4145 let source = format!(
@@ -4111,13 +4229,19 @@ mod tests {
4111 continue;4229 continue;
4112 }4230 }
4113 };4231 };
4114- if decode::smooth_luma_hits() == smooth_before {4232+ // class [[gate-skips-on-its-own-failure]]: a decode that succeeded
4233+ // is ALWAYS pixel-compared below; the hit counter only decides whether
4234+ // the attempt counts toward the firing total.
4235+ let counted = decode::smooth_luma_hits() != smooth_before;
4236+ if counted {
4237+ fired_runs += 1;
4238+ } else {
4239+ uncounted_exact += 1;
4115 refusals.push(format!(4240 refusals.push(format!(
4116- "seed {seed}: decoded, but no smooth-luma-neighbour block fired"4241+ "seed {seed}: decoded and pixel-compared, but no smooth-luma-neighbour block \
4242+ fired"
4117 ));4243 ));
4118- continue;
4119 }4244 }
4120- fired_runs += 1;
4121 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);4245 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
4122 assert_eq!(4246 assert_eq!(
4123 frames[0].y, ffmpeg_frames[0].y,4247 frames[0].y, ffmpeg_frames[0].y,
@@ -4126,9 +4250,21 @@ mod tests {
4126 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");4250 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");
4127 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");4251 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");
4128 if fired_runs >= 4 {4252 if fired_runs >= 4 {
4253+ gate_buckets(
4254+ "a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact",
4255+ fired_runs,
4256+ uncounted_exact,
4257+ refusals.len() - uncounted_exact as usize,
4258+ );
4129 return;4259 return;
4130 }4260 }
4131 }4261 }
4262+ gate_buckets(
4263+ "a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact",
4264+ fired_runs,
4265+ uncounted_exact,
4266+ refusals.len() - uncounted_exact as usize,
4267+ );
4132 assert!(4268 assert!(
4133 fired_runs > 0,4269 fired_runs > 0,
4134 "every attempt hit a named refusal or never exercised a smooth luma neighbour:\n{}",4270 "every attempt hit a named refusal or never exercised a smooth luma neighbour:\n{}",
@@ -4161,6 +4297,7 @@ mod tests {
4161 let (width, height) = (64usize, 64usize);4297 let (width, height) = (64usize, 64usize);
4162 let mut refusals = Vec::new();4298 let mut refusals = Vec::new();
4163 let mut fired_runs = 0u32;4299 let mut fired_runs = 0u32;
4300+ let mut uncounted_exact = 0u32;
4164 for attempt in 0..40u32 {4301 for attempt in 0..40u32 {
4165 let seed = 42 + attempt;4302 let seed = 42 + attempt;
4166 let source = format!(4303 let source = format!(
@@ -4237,13 +4374,18 @@ mod tests {
4237 continue;4374 continue;
4238 }4375 }
4239 };4376 };
4240- if decode::smooth_uv_hits() == smooth_before {4377+ // class [[gate-skips-on-its-own-failure]]: a decode that succeeded
4378+ // is ALWAYS pixel-compared below; the hit counter only decides whether
4379+ // the attempt counts toward the firing total.
4380+ let counted = decode::smooth_uv_hits() != smooth_before;
4381+ if counted {
4382+ fired_runs += 1;
4383+ } else {
4384+ uncounted_exact += 1;
4241 refusals.push(format!(4385 refusals.push(format!(
4242- "seed {seed}: decoded, but no smooth/paeth uv_mode fired"4386+ "seed {seed}: decoded and pixel-compared, but no smooth/paeth uv_mode fired"
4243 ));4387 ));
4244- continue;
4245 }4388 }
4246- fired_runs += 1;
4247 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);4389 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
4248 assert_eq!(4390 assert_eq!(
4249 frames[0].y, ffmpeg_frames[0].y,4391 frames[0].y, ffmpeg_frames[0].y,
@@ -4252,9 +4394,21 @@ mod tests {
4252 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");4394 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");
4253 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");4395 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");
4254 if fired_runs >= 4 {4396 if fired_runs >= 4 {
4397+ gate_buckets(
4398+ "a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact",
4399+ fired_runs,
4400+ uncounted_exact,
4401+ refusals.len() - uncounted_exact as usize,
4402+ );
4255 return;4403 return;
4256 }4404 }
4257 }4405 }
4406+ gate_buckets(
4407+ "a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact",
4408+ fired_runs,
4409+ uncounted_exact,
4410+ refusals.len() - uncounted_exact as usize,
4411+ );
4258 assert!(4412 assert!(
4259 fired_runs > 0,4413 fired_runs > 0,
4260 "every attempt hit a named refusal or never exercised smooth/paeth chroma:\n{}",4414 "every attempt hit a named refusal or never exercised smooth/paeth chroma:\n{}",
@@ -4289,6 +4443,7 @@ mod tests {
4289 let (width, height) = (64usize, 64usize);4443 let (width, height) = (64usize, 64usize);
4290 let mut refusals = Vec::new();4444 let mut refusals = Vec::new();
4291 let mut fired_runs = 0u32;4445 let mut fired_runs = 0u32;
4446+ let mut uncounted_exact = 0u32;
4292 for attempt in 0..40u32 {4447 for attempt in 0..40u32 {
4293 let seed = 42 + attempt;4448 let seed = 42 + attempt;
4294 let source = format!(4449 let source = format!(
@@ -4389,16 +4544,20 @@ mod tests {
4389 continue;4544 continue;
4390 }4545 }
4391 };4546 };
4392- if decode::directional_uv_hits() == uv_before4547+ // class [[gate-skips-on-its-own-failure]]: a decode that succeeded
4393- && decode::angle_delta_hits() == angle_before4548+ // is ALWAYS pixel-compared below; the hit counter only decides whether
4394- {4549+ // the attempt counts toward the firing total.
4550+ let counted = decode::directional_uv_hits() != uv_before
4551+ || decode::angle_delta_hits() != angle_before;
4552+ if counted {
4553+ fired_runs += 1;
4554+ } else {
4555+ uncounted_exact += 1;
4395 refusals.push(format!(4556 refusals.push(format!(
4396- "seed {seed}: decoded, but neither a directional uv_mode nor a \4557+ "seed {seed}: decoded and pixel-compared, but neither a directional uv_mode \
4397- nonzero angle delta fired"4558+ nor a nonzero angle delta fired"
4398 ));4559 ));
4399- continue;
4400 }4560 }
4401- fired_runs += 1;
4402 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);4561 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
4403 assert_eq!(4562 assert_eq!(
4404 frames[0].y, ffmpeg_frames[0].y,4563 frames[0].y, ffmpeg_frames[0].y,
@@ -4407,9 +4566,21 @@ mod tests {
4407 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");4566 assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");
4408 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");4567 assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");
4409 if fired_runs >= 4 {4568 if fired_runs >= 4 {
4569+ gate_buckets(
4570+ "a_real_aomenc_stream_with_directional_chroma_decodes_pixel_exact",
4571+ fired_runs,
4572+ uncounted_exact,
4573+ refusals.len() - uncounted_exact as usize,
4574+ );
4410 return;4575 return;
4411 }4576 }
4412 }4577 }
4578+ gate_buckets(
4579+ "a_real_aomenc_stream_with_directional_chroma_decodes_pixel_exact",
4580+ fired_runs,
4581+ uncounted_exact,
4582+ refusals.len() - uncounted_exact as usize,
4583+ );
4413 assert!(4584 assert!(
4414 fired_runs > 0,4585 fired_runs > 0,
4415 "every attempt hit a named refusal or never exercised directional chroma:\n{}",4586 "every attempt hit a named refusal or never exercised directional chroma:\n{}",
@@ -5361,12 +5532,14 @@ mod tests {
5361 }5532 }
5362 Ok(frames) => frames,5533 Ok(frames) => frames,
5363 };5534 };
5364- if decode::non_last_ref_hits() == before {5535+ // class [[gate-skips-on-its-own-failure]]: a decode that succeeded
5365- // This seed's RD search never actually picked GOLDEN_FRAME --5536+ // is ALWAYS pixel-compared below; the hit counter only decides whether
5366- // a genuine miss, not a refusal. Try the next seed rather5537+ // the attempt counts toward the firing total.
5367- // than claiming coverage this attempt did not exercise.5538+ // This seed's RD search may never have picked GOLDEN_FRAME -- a
5539+ // genuine miss, not a refusal, and not a reason to skip the pixels.
5540+ let counted = decode::non_last_ref_hits() != before;
5541+ if !counted {
5368 never_fired += 1;5542 never_fired += 1;
5369- continue;
5370 }5543 }
5371 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);5544 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);
5372 assert_eq!(frames.len(), frame_count);5545 assert_eq!(frames.len(), frame_count);
@@ -5387,12 +5560,26 @@ mod tests {
5387 assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})");5560 assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})");
5388 assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed})");5561 assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed})");
5389 }5562 }
5563+ if counted {
5390 eprintln!(5564 eprintln!(
5391 "FIRING seed {seed}: non_last_ref_hits advanced by {}",5565 "FIRING seed {seed}: non_last_ref_hits advanced by {}",
5392 decode::non_last_ref_hits() - before5566 decode::non_last_ref_hits() - before
5393 );5567 );
5568+ gate_buckets(
5569+ "a_real_aomenc_inter_sequence_with_a_golden_reference_decodes_pixel_exact",
5570+ 1,
5571+ never_fired,
5572+ refusals.len(),
5573+ );
5394 return;5574 return;
5395 }5575 }
5576+ }
5577+ gate_buckets(
5578+ "a_real_aomenc_inter_sequence_with_a_golden_reference_decodes_pixel_exact",
5579+ 0,
5580+ never_fired,
5581+ refusals.len(),
5582+ );
5396 eprintln!(5583 eprintln!(
5397 "SKIP a_real_aomenc_inter_sequence_with_a_golden_reference_decodes_pixel_exact: \5584 "SKIP a_real_aomenc_inter_sequence_with_a_golden_reference_decodes_pixel_exact: \
5398 {never_fired} attempts decoded but never fired GOLDEN_FRAME, and every other \5585 {never_fired} attempts decoded but never fired GOLDEN_FRAME, and every other \
@@ -5542,9 +5729,12 @@ mod tests {
5542 }5729 }
5543 Ok(frames) => frames,5730 Ok(frames) => frames,
5544 };5731 };
5545- if decode::ref_hits(target_ref) == before {5732+ // class [[gate-skips-on-its-own-failure]]: a decode that succeeded
5733+ // is ALWAYS pixel-compared below; the hit counter only decides whether
5734+ // the attempt counts toward the firing total.
5735+ let counted = decode::ref_hits(target_ref) != before;
5736+ if !counted {
5546 never_fired += 1;5737 never_fired += 1;
5547- continue;
5548 }5738 }
5549 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);5739 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);
5550 assert_eq!(frames.len(), frame_count);5740 assert_eq!(frames.len(), frame_count);
@@ -5572,12 +5762,35 @@ mod tests {
5572 "{gate_name} frame {i} V vs ffmpeg (seed {seed})"5762 "{gate_name} frame {i} V vs ffmpeg (seed {seed})"
5573 );5763 );
5574 }5764 }
5765+ // lane-hidden r2 (class gate-blind-to-hidden-frames): the same
5766+ // stream again, comparing EVERY decode-order frame -- the hidden
5767+ // (show_frame == 0) alt-ref frames the ffmpeg compare above
5768+ // cannot see, because both sides of it emit shown frames only.
5769+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, gate_name);
5770+ eprintln!(
5771+ "{gate_name} HIDDEN: seed {seed}: {hidden_total} decode-order frames, \
5772+ {hidden_n} hidden, all pixel-exact vs the oracle"
5773+ );
5774+ // lane-hidden r2 SECOND ARM (the recipe above is untouched):
5775+ // libaom's temporal alt-ref filter absorbs this recipe's hidden
5776+ // frames, so the compare above is vacuous -- re-encode the same
5777+ // fixture with --arnr-maxframes=0 and compare THOSE.
5778+ if let Some((arm_total, arm_hidden)) = hidden_arnr_arm(gate_name, &y4m.stdout, &args) {
5779+ eprintln!(
5780+ "{gate_name} HIDDEN-ARM(--arnr-maxframes=0): seed {seed}: {arm_total} \
5781+ decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle"
5782+ );
5783+ }
5784+ if counted {
5575 eprintln!(5785 eprintln!(
5576 "{gate_name} FIRING seed {seed}: {target_ref_name} hits advanced by {}",5786 "{gate_name} FIRING seed {seed}: {target_ref_name} hits advanced by {}",
5577 decode::ref_hits(target_ref) - before5787 decode::ref_hits(target_ref) - before
5578 );5788 );
5789+ gate_buckets(gate_name, 1, never_fired, refusals.len());
5579 return;5790 return;
5580 }5791 }
5792+ }
5793+ gate_buckets(gate_name, 0, never_fired, refusals.len());
5581 eprintln!(5794 eprintln!(
5582 "SKIP {gate_name}: {never_fired} attempts decoded but never fired {target_ref_name}, \5795 "SKIP {gate_name}: {never_fired} attempts decoded but never fired {target_ref_name}, \
5583 and every other attempt hit a named refusal:\n{}",5796 and every other attempt hit a named refusal:\n{}",
@@ -5747,9 +5960,12 @@ mod tests {
5747 continue;5960 continue;
5748 }5961 }
5749 Ok(frames) => {5962 Ok(frames) => {
5750- if decode::comp_mode_hits() == before {5963+ // class [[gate-skips-on-its-own-failure]]: a decode that
5964+ // succeeded is ALWAYS pixel-compared below; the hit counter
5965+ // only decides whether the attempt counts as firing.
5966+ let counted = decode::comp_mode_hits() != before;
5967+ if !counted {
5751 never_fired += 1;5968 never_fired += 1;
5752- continue;
5753 }5969 }
5754 // Outcome (c): plain COMPOUND_AVERAGE decoded fully --5970 // Outcome (c): plain COMPOUND_AVERAGE decoded fully --
5755 // non-negotiable pixel exactness, no tolerance.5971 // non-negotiable pixel exactness, no tolerance.
@@ -5790,15 +6006,38 @@ mod tests {
5790 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");6006 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");
5791 }6007 }
5792 }6008 }
6009+ // lane-hidden r2 (class gate-blind-to-hidden-frames): the same
6010+ // stream again, comparing EVERY decode-order frame -- the hidden
6011+ // (show_frame == 0) alt-ref frames the ffmpeg compare above
6012+ // cannot see, because both sides of it emit shown frames only.
6013+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
6014+ eprintln!(
6015+ "{NAME} HIDDEN: seed {seed}: {hidden_total} decode-order frames, \
6016+ {hidden_n} hidden, all pixel-exact vs the oracle"
6017+ );
6018+ // lane-hidden r2 SECOND ARM (the recipe above is untouched):
6019+ // libaom's temporal alt-ref filter absorbs this recipe's hidden
6020+ // frames, so the compare above is vacuous -- re-encode the same
6021+ // fixture with --arnr-maxframes=0 and compare THOSE.
6022+ if let Some((arm_total, arm_hidden)) = hidden_arnr_arm(NAME, &y4m.stdout, &args) {
6023+ eprintln!(
6024+ "{NAME} HIDDEN-ARM(--arnr-maxframes=0): seed {seed}: {arm_total} \
6025+ decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle"
6026+ );
6027+ }
6028+ if counted {
5793 eprintln!(6029 eprintln!(
5794 "{NAME} FIRING seed {seed}: comp_mode hits advanced by {}, decoded \6030 "{NAME} FIRING seed {seed}: comp_mode hits advanced by {}, decoded \
5795 fully and pixel-exact",6031 fully and pixel-exact",
5796 decode::comp_mode_hits() - before6032 decode::comp_mode_hits() - before
5797 );6033 );
6034+ gate_buckets(NAME, 1, never_fired, refusals.len());
5798 return;6035 return;
5799 }6036 }
5800 }6037 }
5801 }6038 }
6039+ }
6040+ gate_buckets(NAME, 0, never_fired, refusals.len());
5802 eprintln!(6041 eprintln!(
5803 "SKIP {NAME}: {never_fired} attempts decoded fully (reference_select never drove a \6042 "SKIP {NAME}: {never_fired} attempts decoded fully (reference_select never drove a \
5804 block to COMPOUND_REFERENCE) and every other attempt hit a named refusal that never \6043 block to COMPOUND_REFERENCE) and every other attempt hit a named refusal that never \
@@ -5937,9 +6176,12 @@ mod tests {
5937 }6176 }
5938 Ok(frames) => frames,6177 Ok(frames) => frames,
5939 };6178 };
5940- if decode::skip_mode_hits() == before {6179+ // class [[gate-skips-on-its-own-failure]]: a decode that succeeded
6180+ // is ALWAYS pixel-compared below; the hit counter only decides whether
6181+ // the attempt counts toward the firing total.
6182+ let counted = decode::skip_mode_hits() != before;
6183+ if !counted {
5941 never_fired += 1;6184 never_fired += 1;
5942- continue;
5943 }6185 }
5944 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);6186 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);
5945 assert_eq!(frames.len(), frame_count);6187 assert_eq!(frames.len(), frame_count);
@@ -5972,12 +6214,35 @@ mod tests {
5972 );6214 );
5973 }6215 }
5974 }6216 }
6217+ // lane-hidden r2 (class gate-blind-to-hidden-frames): the same
6218+ // stream again, comparing EVERY decode-order frame -- the hidden
6219+ // (show_frame == 0) alt-ref frames the ffmpeg compare above
6220+ // cannot see, because both sides of it emit shown frames only.
6221+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
6222+ eprintln!(
6223+ "{NAME} HIDDEN: seed {seed}: {hidden_total} decode-order frames, \
6224+ {hidden_n} hidden, all pixel-exact vs the oracle"
6225+ );
6226+ // lane-hidden r2 SECOND ARM (the recipe above is untouched):
6227+ // libaom's temporal alt-ref filter absorbs this recipe's hidden
6228+ // frames, so the compare above is vacuous -- re-encode the same
6229+ // fixture with --arnr-maxframes=0 and compare THOSE.
6230+ if let Some((arm_total, arm_hidden)) = hidden_arnr_arm(NAME, &y4m.stdout, &args) {
6231+ eprintln!(
6232+ "{NAME} HIDDEN-ARM(--arnr-maxframes=0): seed {seed}: {arm_total} \
6233+ decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle"
6234+ );
6235+ }
6236+ if counted {
5975 eprintln!(6237 eprintln!(
5976 "{NAME} FIRING seed {seed}: skip_mode hits advanced by {}",6238 "{NAME} FIRING seed {seed}: skip_mode hits advanced by {}",
5977 decode::skip_mode_hits() - before6239 decode::skip_mode_hits() - before
5978 );6240 );
6241+ gate_buckets(NAME, 1, never_fired, refusals.len());
5979 return;6242 return;
5980 }6243 }
6244+ }
6245+ gate_buckets(NAME, 0, never_fired, refusals.len());
5981 eprintln!(6246 eprintln!(
5982 "SKIP {NAME}: {never_fired} attempts decoded but never fired skip_mode, and every \6247 "SKIP {NAME}: {never_fired} attempts decoded but never fired skip_mode, and every \
5983 other attempt hit a named refusal:\n{}",6248 other attempt hit a named refusal:\n{}",
@@ -6113,9 +6378,12 @@ mod tests {
6113 }6378 }
6114 Ok(frames) => frames,6379 Ok(frames) => frames,
6115 };6380 };
6116- if decode::obmc_hits() == before {6381+ // class [[gate-skips-on-its-own-failure]]: a decode that succeeded
6382+ // is ALWAYS pixel-compared below; the hit counter only decides whether
6383+ // the attempt counts toward the firing total.
6384+ let counted = decode::obmc_hits() != before;
6385+ if !counted {
6117 never_fired += 1;6386 never_fired += 1;
6118- continue;
6119 }6387 }
6120 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);6388 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);
6121 assert_eq!(frames.len(), frame_count);6389 assert_eq!(frames.len(), frame_count);
@@ -6134,12 +6402,35 @@ mod tests {
6134 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");6402 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");
6135 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");6403 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");
6136 }6404 }
6405+ // lane-hidden r2 (class gate-blind-to-hidden-frames): the same
6406+ // stream again, comparing EVERY decode-order frame -- the hidden
6407+ // (show_frame == 0) alt-ref frames the ffmpeg compare above
6408+ // cannot see, because both sides of it emit shown frames only.
6409+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
6410+ eprintln!(
6411+ "{NAME} HIDDEN: seed {seed}: {hidden_total} decode-order frames, \
6412+ {hidden_n} hidden, all pixel-exact vs the oracle"
6413+ );
6414+ // lane-hidden r2 SECOND ARM (the recipe above is untouched):
6415+ // libaom's temporal alt-ref filter absorbs this recipe's hidden
6416+ // frames, so the compare above is vacuous -- re-encode the same
6417+ // fixture with --arnr-maxframes=0 and compare THOSE.
6418+ if let Some((arm_total, arm_hidden)) = hidden_arnr_arm(NAME, &y4m.stdout, &args) {
6419+ eprintln!(
6420+ "{NAME} HIDDEN-ARM(--arnr-maxframes=0): seed {seed}: {arm_total} \
6421+ decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle"
6422+ );
6423+ }
6424+ if counted {
6137 eprintln!(6425 eprintln!(
6138 "{NAME} FIRING seed {seed}: obmc hits advanced by {}",6426 "{NAME} FIRING seed {seed}: obmc hits advanced by {}",
6139 decode::obmc_hits() - before6427 decode::obmc_hits() - before
6140 );6428 );
6429+ gate_buckets(NAME, 1, never_fired, refusals.len());
6141 return;6430 return;
6142 }6431 }
6432+ }
6433+ gate_buckets(NAME, 0, never_fired, refusals.len());
6143 eprintln!(6434 eprintln!(
6144 "SKIP {NAME}: {never_fired} attempts decoded but never fired obmc, and every \6435 "SKIP {NAME}: {never_fired} attempts decoded but never fired obmc, and every \
6145 other attempt hit a named refusal:\n{}",6436 other attempt hit a named refusal:\n{}",
@@ -6304,9 +6595,12 @@ mod tests {
6304 };6595 };
6305 let fired8 = decode::obmc_hits_8() - before8;6596 let fired8 = decode::obmc_hits_8() - before8;
6306 total_obmc8 += fired8;6597 total_obmc8 += fired8;
6307- if fired8 == 0 {6598+ // class [[gate-skips-on-its-own-failure]]: a decode that succeeded
6599+ // is ALWAYS pixel-compared below; the hit counter only decides whether
6600+ // the attempt counts toward the firing total.
6601+ let counted = fired8 != 0;
6602+ if !counted {
6308 never_fired += 1;6603 never_fired += 1;
6309- continue;
6310 }6604 }
6311 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);6605 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);
6312 assert_eq!(frames.len(), frame_count);6606 assert_eq!(frames.len(), frame_count);
@@ -6325,13 +6619,39 @@ mod tests {
6325 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");6619 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");
6326 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");6620 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");
6327 }6621 }
6622+ // lane-hidden r2 (class gate-blind-to-hidden-frames): the same
6623+ // stream again, comparing EVERY decode-order frame -- the hidden
6624+ // (show_frame == 0) alt-ref frames the ffmpeg compare above
6625+ // cannot see, because both sides of it emit shown frames only.
6626+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
6627+ eprintln!(
6628+ "{NAME} HIDDEN: seed {seed}: {hidden_total} decode-order frames, \
6629+ {hidden_n} hidden, all pixel-exact vs the oracle"
6630+ );
6631+ // lane-hidden r2 SECOND ARM (the recipe above is untouched):
6632+ // libaom's temporal alt-ref filter absorbs this recipe's hidden
6633+ // frames, so the compare above is vacuous -- re-encode the same
6634+ // fixture with --arnr-maxframes=0 and compare THOSE.
6635+ if let Some((arm_total, arm_hidden)) = hidden_arnr_arm(NAME, &y4m.stdout, &args) {
6636+ eprintln!(
6637+ "{NAME} HIDDEN-ARM(--arnr-maxframes=0): seed {seed}: {arm_total} \
6638+ decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle"
6639+ );
6640+ }
6641+ if counted {
6328 eprintln!(6642 eprintln!(
6329 "{NAME} FIRING seed {seed}: 8x8 obmc hits {fired8} (total across attempts so far {total_obmc8})"6643 "{NAME} FIRING seed {seed}: 8x8 obmc hits {fired8} (total across attempts so far {total_obmc8})"
6330 );6644 );
6645+ gate_buckets(NAME, 1, never_fired, refusals.len());
6331 return;6646 return;
6332 }6647 }
6333- eprintln!(6648+ }
6334- "SKIP {NAME}: {never_fired} attempts decoded but never fired an 8x8 obmc block \6649+ gate_buckets(NAME, 0, never_fired, refusals.len());
6650+ // lane-gmaffine r2: this gate fired for three rounds only as a SKIP
6651+ // (gate-skips-on-its-own-failure); the 8x8 leaf is reachable now, so a
6652+ // sweep that never lands one firing pixel-exact attempt is a FAILURE.
6653+ panic!(
6654+ "{NAME}: {never_fired} attempts decoded but never fired an 8x8 obmc block \
6335 ({total_obmc8} total 8x8 obmc hits across all attempts), and every other attempt \6655 ({total_obmc8} total 8x8 obmc hits across all attempts), and every other attempt \
6336 hit a named refusal:\n{}",6656 hit a named refusal:\n{}",
6337 refusals.join("\n")6657 refusals.join("\n")
@@ -6491,6 +6811,25 @@ mod tests {
6491 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");6811 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");
6492 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");6812 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");
6493 }6813 }
6814+ // lane-hidden r2 (class gate-blind-to-hidden-frames): the same
6815+ // stream again, comparing EVERY decode-order frame -- the hidden
6816+ // (show_frame == 0) alt-ref frames the ffmpeg compare above
6817+ // cannot see, because both sides of it emit shown frames only.
6818+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
6819+ eprintln!(
6820+ "{NAME} HIDDEN: seed {seed}: {hidden_total} decode-order frames, \
6821+ {hidden_n} hidden, all pixel-exact vs the oracle"
6822+ );
6823+ // lane-hidden r2 SECOND ARM (the recipe above is untouched):
6824+ // libaom's temporal alt-ref filter absorbs this recipe's hidden
6825+ // frames, so the compare above is vacuous -- re-encode the same
6826+ // fixture with --arnr-maxframes=0 and compare THOSE.
6827+ if let Some((arm_total, arm_hidden)) = hidden_arnr_arm(NAME, &y4m.stdout, &args) {
6828+ eprintln!(
6829+ "{NAME} HIDDEN-ARM(--arnr-maxframes=0): seed {seed}: {arm_total} \
6830+ decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle"
6831+ );
6832+ }
6494 matched += 1;6833 matched += 1;
6495 }6834 }
6496 assert!(6835 assert!(
@@ -6940,6 +7279,25 @@ mod tests {
6940 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");7279 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");
6941 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");7280 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");
6942 }7281 }
7282+ // lane-hidden r2 (class gate-blind-to-hidden-frames): the same
7283+ // stream again, comparing EVERY decode-order frame -- the hidden
7284+ // (show_frame == 0) alt-ref frames the ffmpeg compare above
7285+ // cannot see, because both sides of it emit shown frames only.
7286+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
7287+ eprintln!(
7288+ "{NAME} HIDDEN: seed {seed}: {hidden_total} decode-order frames, \
7289+ {hidden_n} hidden, all pixel-exact vs the oracle"
7290+ );
7291+ // lane-hidden r2 SECOND ARM (the recipe above is untouched):
7292+ // libaom's temporal alt-ref filter absorbs this recipe's hidden
7293+ // frames, so the compare above is vacuous -- re-encode the same
7294+ // fixture with --arnr-maxframes=0 and compare THOSE.
7295+ if let Some((arm_total, arm_hidden)) = hidden_arnr_arm(NAME, &y4m.stdout, &args) {
7296+ eprintln!(
7297+ "{NAME} HIDDEN-ARM(--arnr-maxframes=0): seed {seed}: {arm_total} \
7298+ decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle"
7299+ );
7300+ }
6943 matched += 1;7301 matched += 1;
6944 }7302 }
6945 assert!(7303 assert!(
@@ -6957,19 +7315,21 @@ mod tests {
6957 );7315 );
6958 }7316 }
6959 7317
6960- /// lane-wii r2: `--enable-interintra-wedge=1` streams must DECODE7318+ /// lane-scaledref r1: a real aomenc `--superres-mode=1` sequence with
6961- /// pixel-exact -- the wedge-interintra syntax (adapting `wedge_index`7319+ /// compound, OBMC, interintra and 8x8 leaves ALL enabled must decode
6962- /// CDF symbol, fixed sign 0) and the wedge mask blend are ported over7320+ /// pixel-exact -- these are the combinations the three
6963- /// the checksum-verified codebook. `--enable-masked-comp=0` stays so7321+ /// "... with a scaled reference (superres, unimplemented)" refusals used
6964- /// the encoder cannot route inter blocks through the still-unported7322+ /// to cover. Each combination gets its OWN hard-asserted hit counter
6965- /// COMPOUND_WEDGE/DIFFWTD path. A refusal naming interintra/wedge7323+ /// (`crate::decode::scaled_*_hits`), because an unscaled reference would
6966- /// fails the gate; refusals for OTHER named capabilities still skip7324+ /// pass the pixels and prove nothing (class `gate-blind-to-feature`), and
6967- /// that seed. Zero `wii_hits` on a run means the encoder never7325+ /// a stream that scales but never takes compound/OBMC/interintra/8x8
6968- /// selected wedge-interintra -- soft-skipped (warned), not failed:7326+ /// would prove nothing about the code this round adds either. A refusal
6969- /// that is encoder choice, not a decoder bug.7327+ /// naming a scaled reference is a hard failure: those are exactly the
7328+ /// strings this round lifts. Other named capabilities skip that seed.
6970 #[test]7329 #[test]
6971- fn a_real_aomenc_stream_with_interintra_wedge_decodes_pixel_exact() {7330+ fn a_real_aomenc_superres_stream_with_compound_obmc_and_interintra_decodes_pixel_exact()
6972- const NAME: &str = "a_real_aomenc_stream_with_interintra_wedge_decodes_pixel_exact";7331+ {
7332+ const NAME: &str = "a_real_aomenc_superres_stream_with_compound_obmc_and_interintra_decodes_pixel_exact";
6973 let _gate_lock = lock_gate_counters();7333 let _gate_lock = lock_gate_counters();
6974 if !have_ffmpeg() {7334 if !have_ffmpeg() {
6975 eprintln!("SKIP {NAME}: no ffmpeg");7335 eprintln!("SKIP {NAME}: no ffmpeg");
@@ -6982,37 +7342,19 @@ mod tests {
6982 let (width, height, frame_count) = (64usize, 64usize, 24usize);7342 let (width, height, frame_count) = (64usize, 64usize, 24usize);
6983 let mut named_refusals = 0u32;7343 let mut named_refusals = 0u32;
6984 let mut matched = 0u32;7344 let mut matched = 0u32;
6985- let n_attempts: u32 = std::env::var("EC_WEDGE_GATE_ATTEMPTS")7345+ let n_attempts: u32 = std::env::var("EC_SCALEDREF_GATE_ATTEMPTS")
6986 .ok()7346 .ok()
6987 .and_then(|s| s.parse().ok())7347 .and_then(|s| s.parse().ok())
6988- .unwrap_or(40);7348+ .unwrap_or(12);
6989 for attempt in 0..n_attempts {7349 for attempt in 0..n_attempts {
6990 let seed = 42 + attempt;7350 let seed = 42 + attempt;
6991 let duration = frame_count as f64 / 25.0;7351 let duration = frame_count as f64 / 25.0;
6992- let source = if attempt % 2 == 0 {7352+ let source =
6993- gradients_source(seed, width, height, &format!("duration={duration}:rate=25"))7353+ gradients_source(seed, width, height, &format!("duration={duration}:rate=25"));
6994- } else {
6995- // `end_pts` does NOT bound mandelbrot (it generated 300+
6996- // frames and hung the gate for an hour); `-t` below is the
6997- // real bound, matching every other mandelbrot gate recipe.
6998- format!("mandelbrot=size={width}x{height}:rate=25")
6999- };
7000- let duration_arg = format!("{duration}");
7001 let y4m = Command::new("ffmpeg")7354 let y4m = Command::new("ffmpeg")
7002 .args([7355 .args([
7003- "-v",7356+ "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f",
7004- "error",7357+ "yuv4mpegpipe", "-",
7005- "-f",
7006- "lavfi",
7007- "-i",
7008- &source,
7009- "-pix_fmt",
7010- "yuv420p",
7011- "-t",
7012- &duration_arg,
7013- "-f",
7014- "yuv4mpegpipe",
7015- "-",
7016 ])7358 ])
7017 .stdin(Stdio::null())7359 .stdin(Stdio::null())
7018 .stdout(Stdio::piped())7360 .stdout(Stdio::piped())
@@ -7024,6 +7366,32 @@ mod tests {
7024 "ffmpeg fixture: {}",7366 "ffmpeg fixture: {}",
7025 String::from_utf8_lossy(&y4m.stderr)7367 String::from_utf8_lossy(&y4m.stderr)
7026 );7368 );
7369+ let on = |name: &str| {
7370+ if std::env::var(name).as_deref() == Ok("0") { "0" } else { "1" }
7371+ };
7372+ // lane-scaledref r2: warp is ON. A warp-capable frame header
7373+ // under a scaled reference is exactly the case r1 got wrong
7374+ // (the block must read the 2-symbol `obmc_cdf`, not the
7375+ // 3-symbol `motion_mode_cdf` -- libaom `motion_mode_allowed`,
7376+ // blockd.h:1484), and it decoded silently wrong pixels rather
7377+ // than refusing. `EC_SCALEDREF_WARP=0` turns it off for
7378+ // bisecting only.
7379+ let warp = format!("--enable-warped-motion={}", on("EC_SCALEDREF_WARP"));
7380+ // lane-scaledref r2: `EC_SCALEDREF_MODE=3` (qthresh) lets
7381+ // superres switch on and off per frame, so a compound block can
7382+ // reference one scaled and one unscaled reference -- the mixed
7383+ // case mode 1 (every frame scaled) never produces.
7384+ let superres_mode = format!(
7385+ "--superres-mode={}",
7386+ std::env::var("EC_SCALEDREF_MODE").unwrap_or_else(|_| "1".into())
7387+ );
7388+ let obmc = format!("--enable-obmc={}", on("EC_SCALEDREF_OBMC"));
7389+ let interintra = format!("--enable-interintra-comp={}", on("EC_SCALEDREF_II"));
7390+ let lag = format!(
7391+ "--lag-in-frames={}",
7392+ if on("EC_SCALEDREF_COMP") == "0" { "0" } else { "25" }
7393+ );
7394+ let alt_ref = format!("--auto-alt-ref={}", on("EC_SCALEDREF_COMP"));
7027 let args: Vec<&str> = vec![7395 let args: Vec<&str> = vec![
7028 "--codec=av1",7396 "--codec=av1",
7029 "--passes=1",7397 "--passes=1",
@@ -7033,18 +7401,35 @@ mod tests {
7033 "--kf-max-dist=1000",7401 "--kf-max-dist=1000",
7034 "--threads=1",7402 "--threads=1",
7035 "--row-mt=0",7403 "--row-mt=0",
7036- "--auto-alt-ref=1",7404+ "--sb-size=64",
7037- "--lag-in-frames=16",7405+ // superres on every frame, key and inter alike -- the scaled
7038- "--enable-fwd-kf=0",7406+ // reference this gate is about.
7407+ // denominator 16 (the maximum) keeps the CODED frame
7408+ // 32x64 -- a multiple of 16 both ways, so no frame-edge
7409+ // 16x16 straddle forces a sub-16x16 partition this decoder
7410+ // still refuses on the aligned path ("an inter partition
7411+ // below 16x16"). Denominator 12 codes 43 columns and every
7412+ // seed refused there.
7413+ &superres_mode,
7414+ "--superres-denominator=16",
7415+ "--superres-kf-denominator=16",
7416+ // the four combinations this round lifts (each switchable
7417+ // by env for bisecting a mismatch without a rebuild)
7418+ &alt_ref,
7419+ &lag,
7039 "--enable-order-hint=1",7420 "--enable-order-hint=1",
7040- "--enable-warped-motion=1",7421+ &warp,
7041- "--enable-obmc=1",7422+ &obmc,
7042- "--tune-content=default",7423+ &interintra,
7424+ "--enable-smooth-interintra=1",
7425+ "--enable-interintra-wedge=0",
7043 "--enable-masked-comp=0",7426 "--enable-masked-comp=0",
7044- "--enable-interintra-comp=1",
7045 "--enable-onesided-comp=0",7427 "--enable-onesided-comp=0",
7046- "--enable-interintra-wedge=1",7428+ "--enable-fwd-kf=0",
7047- "--enable-smooth-interintra=1",7429+ "--tune-content=default",
7430+ "--max-partition-size=32",
7431+ "--min-partition-size=32",
7432+ // everything this decoder still refuses under any reference
7048 "--enable-rect-partitions=0",7433 "--enable-rect-partitions=0",
7049 "--enable-ab-partitions=0",7434 "--enable-ab-partitions=0",
7050 "--enable-1to4-partitions=0",7435 "--enable-1to4-partitions=0",
@@ -7056,8 +7441,6 @@ mod tests {
7056 "--enable-tx-size-search=0",7441 "--enable-tx-size-search=0",
7057 "--enable-cdef=0",7442 "--enable-cdef=0",
7058 "--enable-restoration=0",7443 "--enable-restoration=0",
7059- "--max-partition-size=32",
7060- "--min-partition-size=32",
7061 "--enable-palette=0",7444 "--enable-palette=0",
7062 "--enable-intrabc=0",7445 "--enable-intrabc=0",
7063 "--enable-cfl-intra=0",7446 "--enable-cfl-intra=0",
@@ -7094,27 +7477,29 @@ mod tests {
7094 msg.contains("unsupported"),7477 msg.contains("unsupported"),
7095 "{NAME} failed outright, not a named refusal (seed {seed}): {msg}"7478 "{NAME} failed outright, not a named refusal (seed {seed}): {msg}"
7096 );7479 );
7097- // Verifier note (lane-wii r2): no refusal string containing7480+ assert!(
7098- // "wedge"/"interintra" exists in the decoder any more, so7481+ !msg.contains("scaled reference"),
7099- // string-forbidding asserts here would be vacuous (class7482+ "{NAME} refused on a scaled reference (seed {seed}) -- those refusals \
7100- // gate-blind-to-feature). The proof this gate carries is7483+ are exactly what this round lifts: {msg}"
7101- // pixel-exact decode plus the wii_hits count printed below.7484+ );
7102 named_refusals += 1;7485 named_refusals += 1;
7103- eprintln!("seed {seed} refusal (non-wedge capability): {msg}");7486+ eprintln!("seed {seed} refusal (other capability): {msg}");
7104 continue;7487 continue;
7105 }7488 }
7106 Ok(frames) => frames,7489 Ok(frames) => frames,
7107 };7490 };
7108 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);7491 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);
7109 assert_eq!(frames.len(), frame_count);7492 assert_eq!(frames.len(), frame_count);
7493+ if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") {
7110 let mismatched = frames7494 let mismatched = frames
7111 .iter()7495 .iter()
7112 .zip(&ffmpeg_frames)7496 .zip(&ffmpeg_frames)
7113 .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);7497 .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
7114- if mismatched && let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") {7498+ if mismatched {
7115 std::fs::write(&path, &stream).expect("writing pinned stream");7499 std::fs::write(&path, &stream).expect("writing pinned stream");
7116 eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}");7500 eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}");
7117 }7501 }
7502+ }
7118 for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {7503 for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7119 assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})");7504 assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})");
7120 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");7505 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");
@@ -7122,42 +7507,665 @@ mod tests {
7122 }7507 }
7123 matched += 1;7508 matched += 1;
7124 }7509 }
7510+ eprintln!(
7511+ "{NAME}: {named_refusals} other-capability refusals, {matched}/{n_attempts} pixel-exact, \
7512+ superres_hits={} predict_scaled_hits={} scaled_compound={} scaled_warp_fallback={} \
7513+ scaled_obmc={} scaled_interintra={} scaled_block8={} scaled_warp_suppressed={} mixed_scale_compound={}",
7514+ crate::superres::superres_hits(),
7515+ crate::mc::predict_scaled_hits(),
7516+ crate::decode::scaled_compound_hits(),
7517+ crate::decode::scaled_warp_fallback_hits(),
7518+ crate::decode::scaled_obmc_hits(),
7519+ crate::decode::scaled_interintra_hits(),
7520+ crate::decode::scaled_block8_hits(),
7521+ crate::decode::scaled_warp_suppressed_hits(),
7522+ crate::decode::mixed_scale_compound_hits(),
7523+ );
7125 assert!(7524 assert!(
7126 matched > 0,7525 matched > 0,
7127- "{NAME}: every attempt refused on other capabilities; the gate never exercised wedge-interintra"7526+ "{NAME}: every attempt refused on other capabilities; the gate proves nothing"
7128 );7527 );
7129- // Hardened from a soft-note (verifier: gate-blind-to-feature): the
7130- // recipe fired wedge-interintra on EVERY one of 6 hammer runs
7131- // (wii_hits 2-7), so a zero-hit run is a regression, not sampling.
7132 assert!(7528 assert!(
7133- crate::decode::wii_hits() > 0,7529+ crate::mc::predict_scaled_hits() > 0,
7134- "{NAME}: {matched} pixel-exact matches but zero wedge-interintra blocks fired -- \7530+ "{NAME}: matched but zero predict_scaled_hits -- no block took the scaled MC path"
7135- the blend is unexercised (recipe fired 2-7 hits per run when landed)"7531+ );
7136- );7532+ // The 8x8 leaf is NOT asserted here: it stays refused (no recipe
7137- eprintln!(7533+ // produced an 8x8 inter leaf at all), so its counter is a
7138- "{NAME}: {named_refusals} other-capability refusals, {matched} pixel-exact matches out of {n_attempts}, wii_hits={}",7534+ // diagnostic only -- see this gate's own doc and decode.rs.
7139- crate::decode::wii_hits()7535+ // `scaled_warp_suppressed` IS asserted: it counts the blocks whose
7140- );7536+ // WARPED_CAUSAL eligibility libaom drops because the reference is
7537+ // scaled, i.e. the blocks that must read `obmc_cdf`. Zero of them
7538+ // would mean this gate's `--enable-warped-motion=1` never reached a
7539+ // warp-eligible block and proves nothing about r2's fix.
7540+ assert!(
7541+ crate::decode::scaled_warp_suppressed_hits() > 0,
7542+ "{NAME}: {matched} matches but no block had its warp eligibility \
7543+ suppressed by a scaled reference -- the warp arm proves nothing"
7544+ );
7545+ for (hits, what) in [
7546+ (crate::decode::scaled_compound_hits(), "compound with a scaled reference"),
7547+ (crate::decode::scaled_obmc_hits(), "OBMC with a scaled reference"),
7548+ (crate::decode::scaled_interintra_hits(), "interintra with a scaled reference"),
7549+ ] {
7550+ assert!(hits > 0, "{NAME}: {matched} matches but zero blocks took {what}");
7551+ }
7141 }7552 }
7142 7553
7143- /// lane-rect16 r1/r2: a plain default-settings aomenc run over lavfi7554+ /// lane-wii r2: `--enable-interintra-wedge=1` streams must DECODE
7144- /// `mandelbrot` (`--cpu-used=4 --end-usage=q --cq-level=32`, no7555+ /// pixel-exact -- the wedge-interintra syntax (adapting `wedge_index`
7145- /// `--enable-*` flags) used to refuse frame 0 outright with "a partition7556+ /// CDF symbol, fixed sign 0) and the wedge mask blend are ported over
7146- /// below 16x16 other than a clean split". r1 root-caused the FIRST hit to7557+ /// the checksum-verified codebook. `--enable-masked-comp=0` stays so
7147- /// a `PARTITION_VERT_B` `partition_w16` symbol at mi=(3,2) and wired it7558+ /// the encoder cannot route inter blocks through the still-unported
7148- /// (left 8x16 real `decode_block_rect` strip + two stacked 8x87559+ /// COMPOUND_WEDGE/DIFFWTD path. A refusal naming interintra/wedge
7149- /// `decode_leaf8` leaves on the right). r2 re-measured after that fix7560+ /// fails the gate; refusals for OTHER named capabilities still skip
7150- /// (`decision-before-quantiser`-shaped: don't trust a stale premise) and7561+ /// that seed. Zero `wii_hits` on a run means the encoder never
7151- /// found this stream's REAL first-hit blocker in z-order is earlier, at7562+ /// selected wedge-interintra -- soft-skipped (warned), not failed:
7152- /// mi=(0,7): a plain `PARTITION_HORZ`. That arm is now wired too7563+ /// that is encoder choice, not a decoder bug.
7153- /// (`decode_leaf_rect`, sibling to `decode_leaf8` but real-mi-addressed7564+ #[test]
7154- /// for a non-square strip) -- `horz_vert_intra_hits` proves it fires.7565+ fn a_real_aomenc_stream_with_interintra_wedge_decodes_pixel_exact() {
7155- /// This exact stream's own HORZ block at mi=(0,7) is *coded* (real7566+ const NAME: &str = "a_real_aomenc_stream_with_interintra_wedge_decodes_pixel_exact";
7156- /// coefficients), which is NOT ported (same ceiling as VERT_B's own7567+ let _gate_lock = lock_gate_counters();
7157- /// non-skip refusal -- no rectangular-transform coefficient tables at7568+ if !have_ffmpeg() {
7158- /// this size), so decode still stops there and `vert_b_intra_hits`7569+ eprintln!("SKIP {NAME}: no ffmpeg");
7159- /// never gets a chance to increment on this particular stream. This gate7570+ return;
7160- /// proves the HORZ arm fires and the OLD (now-false) two-clause refusal7571+ }
7572+ if !have_aomenc() {
7573+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
7574+ return;
7575+ }
7576+ let (width, height, frame_count) = (64usize, 64usize, 24usize);
7577+ let mut named_refusals = 0u32;
7578+ let mut matched = 0u32;
7579+ let n_attempts: u32 = std::env::var("EC_WEDGE_GATE_ATTEMPTS")
7580+ .ok()
7581+ .and_then(|s| s.parse().ok())
7582+ .unwrap_or(40);
7583+ for attempt in 0..n_attempts {
7584+ let seed = 42 + attempt;
7585+ let duration = frame_count as f64 / 25.0;
7586+ let source = if attempt % 2 == 0 {
7587+ gradients_source(seed, width, height, &format!("duration={duration}:rate=25"))
7588+ } else {
7589+ // `end_pts` does NOT bound mandelbrot (it generated 300+
7590+ // frames and hung the gate for an hour); `-t` below is the
7591+ // real bound, matching every other mandelbrot gate recipe.
7592+ format!("mandelbrot=size={width}x{height}:rate=25")
7593+ };
7594+ let duration_arg = format!("{duration}");
7595+ let y4m = Command::new("ffmpeg")
7596+ .args([
7597+ "-v",
7598+ "error",
7599+ "-f",
7600+ "lavfi",
7601+ "-i",
7602+ &source,
7603+ "-pix_fmt",
7604+ "yuv420p",
7605+ "-t",
7606+ &duration_arg,
7607+ "-f",
7608+ "yuv4mpegpipe",
7609+ "-",
7610+ ])
7611+ .stdin(Stdio::null())
7612+ .stdout(Stdio::piped())
7613+ .stderr(Stdio::piped())
7614+ .output()
7615+ .expect("ffmpeg failed to run");
7616+ assert!(
7617+ y4m.status.success(),
7618+ "ffmpeg fixture: {}",
7619+ String::from_utf8_lossy(&y4m.stderr)
7620+ );
7621+ let args: Vec<&str> = vec![
7622+ "--codec=av1",
7623+ "--passes=1",
7624+ "--end-usage=q",
7625+ "--cq-level=45",
7626+ "--cpu-used=0",
7627+ "--kf-max-dist=1000",
7628+ "--threads=1",
7629+ "--row-mt=0",
7630+ "--auto-alt-ref=1",
7631+ "--lag-in-frames=16",
7632+ "--enable-fwd-kf=0",
7633+ "--enable-order-hint=1",
7634+ "--enable-warped-motion=1",
7635+ "--enable-obmc=1",
7636+ "--tune-content=default",
7637+ "--enable-masked-comp=0",
7638+ "--enable-interintra-comp=1",
7639+ "--enable-onesided-comp=0",
7640+ "--enable-interintra-wedge=1",
7641+ "--enable-smooth-interintra=1",
7642+ "--enable-rect-partitions=0",
7643+ "--enable-ab-partitions=0",
7644+ "--enable-1to4-partitions=0",
7645+ "--enable-filter-intra=0",
7646+ "--enable-smooth-intra=0",
7647+ "--enable-paeth-intra=0",
7648+ "--enable-directional-intra=0",
7649+ "--enable-angle-delta=0",
7650+ "--enable-tx-size-search=0",
7651+ "--enable-cdef=0",
7652+ "--enable-restoration=0",
7653+ "--max-partition-size=32",
7654+ "--min-partition-size=32",
7655+ "--enable-palette=0",
7656+ "--enable-intrabc=0",
7657+ "--enable-cfl-intra=0",
7658+ "--enable-ref-frame-mvs=0",
7659+ "--obu",
7660+ "-o",
7661+ "-",
7662+ "-",
7663+ ];
7664+ let mut child = Command::new(aomenc_path())
7665+ .args(&args)
7666+ .stdin(Stdio::piped())
7667+ .stdout(Stdio::piped())
7668+ .stderr(Stdio::piped())
7669+ .spawn()
7670+ .expect("aomenc failed to start");
7671+ child
7672+ .stdin
7673+ .take()
7674+ .expect("aomenc stdin")
7675+ .write_all(&y4m.stdout)
7676+ .expect("writing y4m to aomenc");
7677+ let out = child.wait_with_output().expect("aomenc failed to run");
7678+ assert!(
7679+ out.status.success(),
7680+ "aomenc refused the fixture: {}",
7681+ String::from_utf8_lossy(&out.stderr)
7682+ );
7683+ let stream = out.stdout;
7684+ let frames = match decode_stream(&stream) {
7685+ Err(e) => {
7686+ let msg = e.to_string();
7687+ assert!(
7688+ msg.contains("unsupported"),
7689+ "{NAME} failed outright, not a named refusal (seed {seed}): {msg}"
7690+ );
7691+ // Verifier note (lane-wii r2): no refusal string containing
7692+ // "wedge"/"interintra" exists in the decoder any more, so
7693+ // string-forbidding asserts here would be vacuous (class
7694+ // gate-blind-to-feature). The proof this gate carries is
7695+ // pixel-exact decode plus the wii_hits count printed below.
7696+ named_refusals += 1;
7697+ eprintln!("seed {seed} refusal (non-wedge capability): {msg}");
7698+ continue;
7699+ }
7700+ Ok(frames) => frames,
7701+ };
7702+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);
7703+ assert_eq!(frames.len(), frame_count);
7704+ let mismatched = frames
7705+ .iter()
7706+ .zip(&ffmpeg_frames)
7707+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
7708+ if mismatched && let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") {
7709+ std::fs::write(&path, &stream).expect("writing pinned stream");
7710+ eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}");
7711+ }
7712+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7713+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})");
7714+ assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");
7715+ assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");
7716+ }
7717+ // lane-hidden r2 (class gate-blind-to-hidden-frames): the same
7718+ // stream again, comparing EVERY decode-order frame -- the hidden
7719+ // (show_frame == 0) alt-ref frames the ffmpeg compare above
7720+ // cannot see, because both sides of it emit shown frames only.
7721+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
7722+ eprintln!(
7723+ "{NAME} HIDDEN: seed {seed}: {hidden_total} decode-order frames, \
7724+ {hidden_n} hidden, all pixel-exact vs the oracle"
7725+ );
7726+ // lane-hidden r2 SECOND ARM (the recipe above is untouched):
7727+ // libaom's temporal alt-ref filter absorbs this recipe's hidden
7728+ // frames, so the compare above is vacuous -- re-encode the same
7729+ // fixture with --arnr-maxframes=0 and compare THOSE.
7730+ if let Some((arm_total, arm_hidden)) = hidden_arnr_arm(NAME, &y4m.stdout, &args) {
7731+ eprintln!(
7732+ "{NAME} HIDDEN-ARM(--arnr-maxframes=0): seed {seed}: {arm_total} \
7733+ decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle"
7734+ );
7735+ }
7736+ matched += 1;
7737+ }
7738+ assert!(
7739+ matched > 0,
7740+ "{NAME}: every attempt refused on other capabilities; the gate never exercised wedge-interintra"
7741+ );
7742+ // Hardened from a soft-note (verifier: gate-blind-to-feature): the
7743+ // recipe fired wedge-interintra on EVERY one of 6 hammer runs
7744+ // (wii_hits 2-7), so a zero-hit run is a regression, not sampling.
7745+ assert!(
7746+ crate::decode::wii_hits() > 0,
7747+ "{NAME}: {matched} pixel-exact matches but zero wedge-interintra blocks fired -- \
7748+ the blend is unexercised (recipe fired 2-7 hits per run when landed)"
7749+ );
7750+ eprintln!(
7751+ "{NAME}: {named_refusals} other-capability refusals, {matched} pixel-exact matches out of {n_attempts}, wii_hits={}",
7752+ crate::decode::wii_hits()
7753+ );
7754+ }
7755+
7756+ /// The affine-capable encoder (`scripts/build-aom-affine-oracle.sh`),
7757+ /// separate from the shared oracle because stock libaom's global-motion
7758+ /// model search is pinned to ROTZOOM and can never emit AFFINE.
7759+ fn affine_aomenc_path() -> std::path::PathBuf {
7760+ if let Some(p) = std::env::var_os("EC_AV1_AFFINE_AOMENC") {
7761+ return std::path::PathBuf::from(p);
7762+ }
7763+ let home = std::env::var_os("HOME").unwrap_or_default();
7764+ std::path::PathBuf::from(home).join(".cache/aom-affine/build/aomenc")
7765+ }
7766+
7767+ fn have_affine_aomenc() -> bool {
7768+ let present = affine_aomenc_path().is_file();
7769+ assert!(
7770+ present || std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none(),
7771+ "EC_AV1_REQUIRE_AOMENC is set but no affine-capable aomenc at {} -- run \
7772+ scripts/build-aom-affine-oracle.sh",
7773+ affine_aomenc_path().display()
7774+ );
7775+ present
7776+ }
7777+
7778+ /// lane-gmaffine r1: an inter frame whose `global_motion_params` carries a
7779+ /// SIX-parameter (`AFFINE`) model for a single-reference frame -- refused
7780+ /// by name since lane-gm r4 because no aomenc recipe ever reached it.
7781+ /// The reason it never did is in libaom's own encoder, not in the
7782+ /// content: `av1/encoder/global_motion_facade.c:24` pins the model search
7783+ /// to `ROTZOOM` at both ends, so *no* `--enable-global-motion=1` command
7784+ /// line over any source can produce the case. The decoder must still
7785+ /// handle it (the bitstream allows it, `read_global_motion_params` reads
7786+ /// params 4/5 with their own subexp references, and ffmpeg decodes it),
7787+ /// so this gate widens exactly that one encoder-side search range in a
7788+ /// side build and encodes with it. Everything downstream is ordinary
7789+ /// libaom and the pixel oracle is still ffmpeg.
7790+ ///
7791+ /// Content: rotation composed with a progressive *anisotropic* stretch --
7792+ /// a similarity transform plus unequal axis scaling is precisely what a
7793+ /// 4-parameter ROTZOOM model cannot express, which is what makes the
7794+ /// encoder's RD pick AFFINE. `affine_gm_hits()` hard-asserts that real
7795+ /// blocks were predicted through the 6-parameter warp, not merely that a
7796+ /// header parsed one (class `gate-blind-to-feature`).
7797+ #[test]
7798+ fn a_real_affine_global_motion_stream_decodes_pixel_exact() {
7799+ const NAME: &str = "a_real_affine_global_motion_stream_decodes_pixel_exact";
7800+ let _gate_lock = lock_gate_counters();
7801+ if !have_ffmpeg() {
7802+ eprintln!("SKIP {NAME}: no ffmpeg");
7803+ return;
7804+ }
7805+ if !have_affine_aomenc() {
7806+ eprintln!(
7807+ "SKIP {NAME}: no affine-capable aomenc at {} (scripts/build-aom-affine-oracle.sh)",
7808+ affine_aomenc_path().display()
7809+ );
7810+ return;
7811+ }
7812+ let (width, height, frame_count) = (64usize, 64usize, 24usize);
7813+ let duration = frame_count as f64 / 25.0;
7814+ // Both depths: his own AV1 library is yuv420p10le throughout, and a
7815+ // 10-bit AFFINE warp runs the same `warp_affine` over wider samples.
7816+ for depth in [8u32, 10u32] {
7817+ // `-t` is the real bound on mandelbrot (it ignores `end_pts` and
7818+ // has hung a gate for an hour); the 96x96 source is rotated and
7819+ // then stretched horizontally only, and cropped back to 64x64.
7820+ let source = format!(
7821+ "mandelbrot=size=96x96:rate=25,rotate=a=0.12*t:c=black,\
7822+ scale=w='ceil(96*(1+0.03*n)/2)*2':h=96:eval=frame,crop={width}:{height}"
7823+ );
7824+ let pix_fmt = if depth == 10 { "yuv420p10le" } else { "yuv420p" };
7825+ let mut ff_args: Vec<&str> =
7826+ vec!["-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", pix_fmt];
7827+ // y4m has no official 10-bit tag, same as the 10-bit gate above.
7828+ if depth == 10 {
7829+ ff_args.extend(["-strict", "-1"]);
7830+ }
7831+ let duration_arg = duration.to_string();
7832+ ff_args.extend(["-t", &duration_arg, "-f", "yuv4mpegpipe", "-"]);
7833+ let y4m = Command::new("ffmpeg")
7834+ .args(&ff_args)
7835+ .stdin(Stdio::null())
7836+ .stdout(Stdio::piped())
7837+ .stderr(Stdio::piped())
7838+ .output()
7839+ .expect("ffmpeg failed to run");
7840+ assert!(
7841+ y4m.status.success(),
7842+ "ffmpeg fixture: {}",
7843+ String::from_utf8_lossy(&y4m.stderr)
7844+ );
7845+ let bit_depth = format!("--bit-depth={depth}");
7846+ let input_bit_depth = format!("--input-bit-depth={depth}");
7847+ let args: Vec<&str> = vec![
7848+ "--codec=av1",
7849+ "--passes=1",
7850+ "--end-usage=q",
7851+ "--cq-level=45",
7852+ "--cpu-used=0",
7853+ "--kf-max-dist=1000",
7854+ "--threads=1",
7855+ "--row-mt=0",
7856+ "--auto-alt-ref=0",
7857+ "--lag-in-frames=0",
7858+ "--enable-fwd-kf=0",
7859+ "--enable-order-hint=1",
7860+ "--enable-global-motion=1",
7861+ "--enable-warped-motion=0",
7862+ "--enable-obmc=0",
7863+ "--tune-content=default",
7864+ "--enable-masked-comp=0",
7865+ "--enable-interintra-comp=0",
7866+ "--enable-onesided-comp=0",
7867+ "--enable-rect-partitions=0",
7868+ "--enable-ab-partitions=0",
7869+ "--enable-1to4-partitions=0",
7870+ "--enable-filter-intra=0",
7871+ "--enable-smooth-intra=0",
7872+ "--enable-paeth-intra=0",
7873+ "--enable-directional-intra=0",
7874+ "--enable-angle-delta=0",
7875+ "--enable-tx-size-search=0",
7876+ "--enable-cdef=0",
7877+ "--enable-restoration=0",
7878+ "--max-partition-size=32",
7879+ "--min-partition-size=32",
7880+ "--enable-palette=0",
7881+ "--enable-intrabc=0",
7882+ "--enable-cfl-intra=0",
7883+ "--enable-ref-frame-mvs=0",
7884+ &bit_depth,
7885+ &input_bit_depth,
7886+ "--obu",
7887+ "-o",
7888+ "-",
7889+ "-",
7890+ ];
7891+ let mut child = Command::new(affine_aomenc_path())
7892+ .args(&args)
7893+ .stdin(Stdio::piped())
7894+ .stdout(Stdio::piped())
7895+ .stderr(Stdio::piped())
7896+ .spawn()
7897+ .expect("affine aomenc failed to start");
7898+ child
7899+ .stdin
7900+ .take()
7901+ .expect("aomenc stdin")
7902+ .write_all(&y4m.stdout)
7903+ .expect("writing y4m to aomenc");
7904+ let out = child.wait_with_output().expect("aomenc failed to run");
7905+ assert!(
7906+ out.status.success(),
7907+ "aomenc refused the fixture: {}",
7908+ String::from_utf8_lossy(&out.stderr)
7909+ );
7910+ let stream = out.stdout;
7911+ let before = crate::decode::affine_gm_hits();
7912+ let frames =
7913+ decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME} ({depth}-bit): {e}"));
7914+ let ffmpeg_frames = if depth == 10 {
7915+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
7916+ } else {
7917+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
7918+ };
7919+ assert_eq!(frames.len(), frame_count);
7920+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7921+ assert_eq!(got.y, want.y, "{NAME} {depth}-bit frame {i} luma vs ffmpeg");
7922+ assert_eq!(got.u, want.u, "{NAME} {depth}-bit frame {i} U vs ffmpeg");
7923+ assert_eq!(got.v, want.v, "{NAME} {depth}-bit frame {i} V vs ffmpeg");
7924+ }
7925+ let hits = crate::decode::affine_gm_hits() - before;
7926+ assert!(
7927+ hits > 0,
7928+ "{NAME} ({depth}-bit): decoded pixel-exact but no block was predicted through a \
7929+ 6-parameter global-motion warp -- the AFFINE path is unexercised"
7930+ );
7931+ eprintln!("{NAME}: {depth}-bit, {frame_count} frames pixel-exact, affine_gm_hits={hits}");
7932+ }
7933+ }
7934+
7935+ /// lane-gmaffine r1: the two 8x8-LEAF motion gates. `decode_inter_block8`
7936+ /// is a separate function from [`decode_inter_block`], and until this
7937+ /// round it refused both `GLOBALMV` ("GLOBALMV (round 3)") and
7938+ /// `WARPED_CAUSAL` at that size while the 16x16+ leaf had implemented
7939+ /// both for rounds. The reason no earlier gate caught it: the existing
7940+ /// 8x8 OBMC gate clamps `--max-partition-size=32` and aomenc's RD then
7941+ /// never splits down to a clean 8x8 leaf (that gate has never fired in
7942+ /// 80 attempts). `--min-partition-size=8 --max-partition-size=8` removes
7943+ /// the choice entirely -- every inter leaf in the stream IS an 8x8 one,
7944+ /// so the leaf path is exercised by construction rather than by luck.
7945+ ///
7946+ /// Content is the affine gate's rotating/zooming mandelbrot (global
7947+ /// motion the encoder can actually model), and the hit counters
7948+ /// (`globalmv_hits_8` / `warp_hits_8`) are 8x8-leaf-specific: a
7949+ /// 16x16-leaf GLOBALMV or warp cannot satisfy them.
7950+ fn run_8x8_leaf_motion_gate(
7951+ name: &str,
7952+ global_motion: bool,
7953+ counter: fn() -> usize,
7954+ ) {
7955+ // 72x64: `decode_inter_block8` is reached ONLY through the
7956+ // true-edge-straddling 16x16 path (an interior 16x16
7957+ // PARTITION_SPLIT is still refused by name), so the frame is 8
7958+ // luma columns wider than its last whole superblock -- every 16x16
7959+ // block in that right-hand strip is cut on ONE axis and decodes as
7960+ // four 8x8 leaves by construction. `--min-partition-size=16` keeps
7961+ // the interior out of the still-refused sub-16x16 case.
7962+ let (width, height, frame_count) = (64usize, 64usize, 24usize);
7963+ let duration = frame_count as f64 / 25.0;
7964+ // The encoder's own RD still chooses WHICH 8x8 leaf codes GLOBALMV /
7965+ // WARPED_CAUSAL, and at some quantisers it picks a rect partition at
7966+ // 16x16 (still refused) or a non-LAST reference (still refused at the
7967+ // 8x8 leaf) before ever reaching one. So sweep a few quantisers and
7968+ // require at least one attempt, at each depth, that BOTH decodes
7969+ // pixel-exact AND fires the counter -- a refusing attempt is recorded,
7970+ // never a pass (class `gate-skips-on-its-own-failure`).
7971+ let mut fired_any = [false; 2];
7972+ let mut notes: Vec<String> = Vec::new();
7973+ for (di, depth) in [8u32, 10u32].into_iter().enumerate() {
7974+ for cq in [32u32, 45, 55] {
7975+ let cq_arg = format!("--cq-level={cq}");
7976+ let max_part_arg = format!(
7977+ "--max-partition-size={}",
7978+ std::env::var("EC_8X8_MAXPART").unwrap_or_else(|_| "8".into())
7979+ );
7980+ let source = format!(
7981+ "mandelbrot=size=96x96:rate=25,rotate=a=0.12*t:c=black,\
7982+ scale=w='ceil(96*(1+0.03*n)/2)*2':h=96:eval=frame,crop={width}:{height}"
7983+ );
7984+ let pix_fmt = if depth == 10 { "yuv420p10le" } else { "yuv420p" };
7985+ let mut ff_args: Vec<&str> =
7986+ vec!["-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", pix_fmt];
7987+ if depth == 10 {
7988+ ff_args.extend(["-strict", "-1"]);
7989+ }
7990+ let duration_arg = duration.to_string();
7991+ ff_args.extend(["-t", &duration_arg, "-f", "yuv4mpegpipe", "-"]);
7992+ let y4m = Command::new("ffmpeg")
7993+ .args(&ff_args)
7994+ .stdin(Stdio::null())
7995+ .stdout(Stdio::piped())
7996+ .stderr(Stdio::piped())
7997+ .output()
7998+ .expect("ffmpeg failed to run");
7999+ assert!(
8000+ y4m.status.success(),
8001+ "ffmpeg fixture: {}",
8002+ String::from_utf8_lossy(&y4m.stderr)
8003+ );
8004+ let bit_depth = format!("--bit-depth={depth}");
8005+ let input_bit_depth = format!("--input-bit-depth={depth}");
8006+ let gm_arg = format!("--enable-global-motion={}", u8::from(global_motion));
8007+ let warp_arg = format!("--enable-warped-motion={}", u8::from(!global_motion));
8008+ let args: Vec<&str> = vec![
8009+ "--codec=av1",
8010+ "--passes=1",
8011+ "--end-usage=q",
8012+ &cq_arg,
8013+ "--cpu-used=0",
8014+ "--kf-max-dist=1000",
8015+ "--threads=1",
8016+ "--row-mt=0",
8017+ "--auto-alt-ref=0",
8018+ "--lag-in-frames=0",
8019+ "--enable-fwd-kf=0",
8020+ "--enable-order-hint=1",
8021+ &gm_arg,
8022+ &warp_arg,
8023+ "--enable-obmc=0",
8024+ "--tune-content=default",
8025+ "--enable-masked-comp=0",
8026+ "--enable-interintra-comp=0",
8027+ "--enable-onesided-comp=0",
8028+ "--enable-rect-partitions=0",
8029+ "--enable-ab-partitions=0",
8030+ "--enable-1to4-partitions=0",
8031+ "--enable-filter-intra=0",
8032+ "--enable-smooth-intra=0",
8033+ "--enable-paeth-intra=0",
8034+ "--enable-directional-intra=0",
8035+ "--enable-angle-delta=0",
8036+ "--enable-tx-size-search=0",
8037+ "--enable-cdef=0",
8038+ "--enable-restoration=0",
8039+ &max_part_arg,
8040+ "--min-partition-size=8",
8041+ "--enable-palette=0",
8042+ "--enable-intrabc=0",
8043+ "--enable-cfl-intra=0",
8044+ "--enable-ref-frame-mvs=0",
8045+ &bit_depth,
8046+ &input_bit_depth,
8047+ "--obu",
8048+ "-o",
8049+ "-",
8050+ "-",
8051+ ];
8052+ let mut child = Command::new(aomenc_path())
8053+ .args(&args)
8054+ .stdin(Stdio::piped())
8055+ .stdout(Stdio::piped())
8056+ .stderr(Stdio::piped())
8057+ .spawn()
8058+ .expect("aomenc failed to start");
8059+ child
8060+ .stdin
8061+ .take()
8062+ .expect("aomenc stdin")
8063+ .write_all(&y4m.stdout)
8064+ .expect("writing y4m to aomenc");
8065+ let out = child.wait_with_output().expect("aomenc failed to run");
8066+ assert!(
8067+ out.status.success(),
8068+ "aomenc refused the fixture: {}",
8069+ String::from_utf8_lossy(&out.stderr)
8070+ );
8071+ let stream = out.stdout;
8072+ let before = counter();
8073+ let frames = match decode_stream(&stream) {
8074+ Ok(f) => f,
8075+ Err(e) => {
8076+ let msg = e.to_string();
8077+ assert!(
8078+ msg.contains("unsupported"),
8079+ "{name} ({depth}-bit, cq {cq}) failed outright: {msg}"
8080+ );
8081+ notes.push(format!("{depth}-bit cq {cq}: {msg}"));
8082+ continue;
8083+ }
8084+ };
8085+ let ffmpeg_frames = if depth == 10 {
8086+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
8087+ } else {
8088+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
8089+ };
8090+ assert_eq!(frames.len(), frame_count);
8091+ let hits = counter() - before;
8092+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
8093+ assert_eq!(got.y, want.y, "{name} {depth}-bit frame {i} luma vs ffmpeg");
8094+ assert_eq!(got.u, want.u, "{name} {depth}-bit frame {i} U vs ffmpeg");
8095+ assert_eq!(got.v, want.v, "{name} {depth}-bit frame {i} V vs ffmpeg");
8096+ }
8097+ if hits == 0 {
8098+ notes.push(format!(
8099+ "{depth}-bit cq {cq}: {frame_count} frames pixel-exact but 0 8x8-leaf hits"
8100+ ));
8101+ continue;
8102+ }
8103+ fired_any[di] = true;
8104+ eprintln!(
8105+ "{name}: {depth}-bit cq {cq}, {frame_count} frames pixel-exact, 8x8 hits={hits}"
8106+ );
8107+ }
8108+ }
8109+ assert!(
8110+ fired_any[0] && fired_any[1],
8111+ "{name}: no attempt both decoded pixel-exact and fired the 8x8 leaf \
8112+ (8-bit fired {}, 10-bit fired {}):\n{}",
8113+ fired_any[0], fired_any[1], notes.join("\n")
8114+ );
8115+ }
8116+
8117+ /// lane-gmaffine r1 item (3): `GLOBALMV` at an 8x8 leaf, ROTZOOM global
8118+ /// motion, warp built from the frame's own model.
8119+ #[test]
8120+ fn a_real_globalmv_8x8_leaf_stream_decodes_pixel_exact() {
8121+ const NAME: &str = "a_real_globalmv_8x8_leaf_stream_decodes_pixel_exact";
8122+ let _gate_lock = lock_gate_counters();
8123+ if !have_ffmpeg() {
8124+ eprintln!("SKIP {NAME}: no ffmpeg");
8125+ return;
8126+ }
8127+ if !have_aomenc() {
8128+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
8129+ return;
8130+ }
8131+ run_8x8_leaf_motion_gate(NAME, true, crate::decode::globalmv_hits_8);
8132+ }
8133+
8134+ /// lane-gmaffine r1 item (2): `WARPED_CAUSAL` at an 8x8 leaf --
8135+ /// findSamples + `av1_find_projection` + the warp filter at BLOCK_8X8.
8136+ #[test]
8137+ fn a_real_warped_causal_8x8_leaf_stream_decodes_pixel_exact() {
8138+ const NAME: &str = "a_real_warped_causal_8x8_leaf_stream_decodes_pixel_exact";
8139+ let _gate_lock = lock_gate_counters();
8140+ if !have_ffmpeg() {
8141+ eprintln!("SKIP {NAME}: no ffmpeg");
8142+ return;
8143+ }
8144+ if !have_aomenc() {
8145+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
8146+ return;
8147+ }
8148+ run_8x8_leaf_motion_gate(NAME, false, crate::decode::warp_hits_8);
8149+ }
8150+
8151+ /// lane-rect16 r1/r2: a plain default-settings aomenc run over lavfi
8152+ /// `mandelbrot` (`--cpu-used=4 --end-usage=q --cq-level=32`, no
8153+ /// `--enable-*` flags) used to refuse frame 0 outright with "a partition
8154+ /// below 16x16 other than a clean split". r1 root-caused the FIRST hit to
8155+ /// a `PARTITION_VERT_B` `partition_w16` symbol at mi=(3,2) and wired it
8156+ /// (left 8x16 real `decode_block_rect` strip + two stacked 8x8
8157+ /// `decode_leaf8` leaves on the right). r2 re-measured after that fix
8158+ /// (`decision-before-quantiser`-shaped: don't trust a stale premise) and
8159+ /// found this stream's REAL first-hit blocker in z-order is earlier, at
8160+ /// mi=(0,7): a plain `PARTITION_HORZ`. That arm is now wired too
8161+ /// (`decode_leaf_rect`, sibling to `decode_leaf8` but real-mi-addressed
8162+ /// for a non-square strip) -- `horz_vert_intra_hits` proves it fires.
8163+ /// This exact stream's own HORZ block at mi=(0,7) is *coded* (real
8164+ /// coefficients), which is NOT ported (same ceiling as VERT_B's own
8165+ /// non-skip refusal -- no rectangular-transform coefficient tables at
8166+ /// this size), so decode still stops there and `vert_b_intra_hits`
8167+ /// never gets a chance to increment on this particular stream. This gate
8168+ /// proves the HORZ arm fires and the OLD (now-false) two-clause refusal
7161 /// never reappears, not a pixel-exact decode of this stream.8169 /// never reappears, not a pixel-exact decode of this stream.
7162 #[test]8170 #[test]
7163 fn a_real_aomenc_stream_with_mandelbrot_fires_the_vert_b_partition_arm() {8171 fn a_real_aomenc_stream_with_mandelbrot_fires_the_vert_b_partition_arm() {
@@ -7441,6 +8449,25 @@ mod tests {
7441 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");8449 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");
7442 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");8450 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");
7443 }8451 }
8452+ // lane-hidden r2 (class gate-blind-to-hidden-frames): the same
8453+ // stream again, comparing EVERY decode-order frame -- the hidden
8454+ // (show_frame == 0) alt-ref frames the ffmpeg compare above
8455+ // cannot see, because both sides of it emit shown frames only.
8456+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
8457+ eprintln!(
8458+ "{NAME} HIDDEN: seed {seed}: {hidden_total} decode-order frames, \
8459+ {hidden_n} hidden, all pixel-exact vs the oracle"
8460+ );
8461+ // lane-hidden r2 SECOND ARM (the recipe above is untouched):
8462+ // libaom's temporal alt-ref filter absorbs this recipe's hidden
8463+ // frames, so the compare above is vacuous -- re-encode the same
8464+ // fixture with --arnr-maxframes=0 and compare THOSE.
8465+ if let Some((arm_total, arm_hidden)) = hidden_arnr_arm(NAME, &y4m.stdout, &args) {
8466+ eprintln!(
8467+ "{NAME} HIDDEN-ARM(--arnr-maxframes=0): seed {seed}: {arm_total} \
8468+ decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle"
8469+ );
8470+ }
7444 matched += 1;8471 matched += 1;
7445 }8472 }
7446 assert!(8473 assert!(
@@ -7642,6 +8669,25 @@ mod tests {
7642 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");8669 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");
7643 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");8670 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");
7644 }8671 }
8672+ // lane-hidden r2 (class gate-blind-to-hidden-frames): the same
8673+ // stream again, comparing EVERY decode-order frame -- the hidden
8674+ // (show_frame == 0) alt-ref frames the ffmpeg compare above
8675+ // cannot see, because both sides of it emit shown frames only.
8676+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
8677+ eprintln!(
8678+ "{NAME} HIDDEN: seed {seed}: {hidden_total} decode-order frames, \
8679+ {hidden_n} hidden, all pixel-exact vs the oracle"
8680+ );
8681+ // lane-hidden r2 SECOND ARM (the recipe above is untouched):
8682+ // libaom's temporal alt-ref filter absorbs this recipe's hidden
8683+ // frames, so the compare above is vacuous -- re-encode the same
8684+ // fixture with --arnr-maxframes=0 and compare THOSE.
8685+ if let Some((arm_total, arm_hidden)) = hidden_arnr_arm(NAME, &y4m.stdout, &args) {
8686+ eprintln!(
8687+ "{NAME} HIDDEN-ARM(--arnr-maxframes=0): seed {seed}: {arm_total} \
8688+ decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle"
8689+ );
8690+ }
7645 matched += 1;8691 matched += 1;
7646 }8692 }
7647 assert!(8693 assert!(
@@ -8049,6 +9095,25 @@ mod tests {
8049 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");9095 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");
8050 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");9096 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");
8051 }9097 }
9098+ // lane-hidden r2 (class gate-blind-to-hidden-frames): the same
9099+ // stream again, comparing EVERY decode-order frame -- the hidden
9100+ // (show_frame == 0) alt-ref frames the ffmpeg compare above
9101+ // cannot see, because both sides of it emit shown frames only.
9102+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
9103+ eprintln!(
9104+ "{NAME} HIDDEN: seed {seed}: {hidden_total} decode-order frames, \
9105+ {hidden_n} hidden, all pixel-exact vs the oracle"
9106+ );
9107+ // lane-hidden r2 SECOND ARM (the recipe above is untouched):
9108+ // libaom's temporal alt-ref filter absorbs this recipe's hidden
9109+ // frames, so the compare above is vacuous -- re-encode the same
9110+ // fixture with --arnr-maxframes=0 and compare THOSE.
9111+ if let Some((arm_total, arm_hidden)) = hidden_arnr_arm(NAME, &y4m.stdout, &args) {
9112+ eprintln!(
9113+ "{NAME} HIDDEN-ARM(--arnr-maxframes=0): seed {seed}: {arm_total} \
9114+ decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle"
9115+ );
9116+ }
8052 matched += 1;9117 matched += 1;
8053 }9118 }
8054 // r1: observed flaky at 40 attempts -- aomenc's cpu-used=0 RD is9119 // r1: observed flaky at 40 attempts -- aomenc's cpu-used=0 RD is
@@ -8481,6 +9546,25 @@ mod tests {
8481 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");9546 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");
8482 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");9547 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");
8483 }9548 }
9549+ // lane-hidden r2 (class gate-blind-to-hidden-frames): the same
9550+ // stream again, comparing EVERY decode-order frame -- the hidden
9551+ // (show_frame == 0) alt-ref frames the ffmpeg compare above
9552+ // cannot see, because both sides of it emit shown frames only.
9553+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
9554+ eprintln!(
9555+ "{NAME} HIDDEN: seed {seed}: {hidden_total} decode-order frames, \
9556+ {hidden_n} hidden, all pixel-exact vs the oracle"
9557+ );
9558+ // lane-hidden r2 SECOND ARM (the recipe above is untouched):
9559+ // libaom's temporal alt-ref filter absorbs this recipe's hidden
9560+ // frames, so the compare above is vacuous -- re-encode the same
9561+ // fixture with --arnr-maxframes=0 and compare THOSE.
9562+ if let Some((arm_total, arm_hidden)) = hidden_arnr_arm(NAME, &y4m.stdout, &args) {
9563+ eprintln!(
9564+ "{NAME} HIDDEN-ARM(--arnr-maxframes=0): seed {seed}: {arm_total} \
9565+ decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle"
9566+ );
9567+ }
8484 matched += 1;9568 matched += 1;
8485 }9569 }
8486 assert!(9570 assert!(
@@ -9045,9 +10129,12 @@ mod tests {
9045 }10129 }
9046 Ok(frames) => frames,10130 Ok(frames) => frames,
9047 };10131 };
9048- if decode::tmv_hits() == before {10132+ // class [[gate-skips-on-its-own-failure]]: a decode that succeeded
10133+ // is ALWAYS pixel-compared below; the hit counter only decides whether
10134+ // the attempt counts toward the firing total.
10135+ let counted = decode::tmv_hits() != before;
10136+ if !counted {
9049 never_fired += 1;10137 never_fired += 1;
9050- continue;
9051 }10138 }
9052 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);10139 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);
9053 assert_eq!(frames.len(), frame_count);10140 assert_eq!(frames.len(), frame_count);
@@ -9075,12 +10162,16 @@ mod tests {
9075 "{gate_name} frame {i} V vs ffmpeg (seed {seed})"10162 "{gate_name} frame {i} V vs ffmpeg (seed {seed})"
9076 );10163 );
9077 }10164 }
10165+ if counted {
9078 eprintln!(10166 eprintln!(
9079 "{gate_name} FIRING seed {seed}: tmv_hits advanced by {}",10167 "{gate_name} FIRING seed {seed}: tmv_hits advanced by {}",
9080 decode::tmv_hits() - before10168 decode::tmv_hits() - before
9081 );10169 );
10170+ gate_buckets(gate_name, 1, never_fired, refusals.len());
9082 return;10171 return;
9083 }10172 }
10173+ }
10174+ gate_buckets(gate_name, 0, never_fired, refusals.len());
9084 eprintln!(10175 eprintln!(
9085 "SKIP {gate_name}: {never_fired} attempts decoded but never fired a temporal MV \10176 "SKIP {gate_name}: {never_fired} attempts decoded but never fired a temporal MV \
9086 candidate, and every other attempt hit a named refusal:\n{}",10177 candidate, and every other attempt hit a named refusal:\n{}",
@@ -9223,6 +10314,7 @@ mod tests {
9223 let (width, height) = (64usize, 64usize);10314 let (width, height) = (64usize, 64usize);
9224 let mut refusals = Vec::new();10315 let mut refusals = Vec::new();
9225 let mut fired_runs = 0u32;10316 let mut fired_runs = 0u32;
10317+ let mut uncounted_exact = 0u32;
9226 for attempt in 0..60u32 {10318 for attempt in 0..60u32 {
9227 let cq = 20 + (attempt % 5) * 10;10319 let cq = 20 + (attempt % 5) * 10;
9228 let period = [4u32, 6, 8, 12, 16][(attempt as usize / 5) % 5];10320 let period = [4u32, 6, 8, 12, 16][(attempt as usize / 5) % 5];
@@ -9316,11 +10408,16 @@ mod tests {
9316 continue;10408 continue;
9317 }10409 }
9318 };10410 };
9319- if decode::tx_class1_hits() == before {10411+ // class [[gate-skips-on-its-own-failure]]: a decode that succeeded
10412+ // is ALWAYS pixel-compared below; the hit counter only decides whether
10413+ // the attempt counts toward the firing total.
10414+ let counted = decode::tx_class1_hits() != before;
10415+ if !counted {
10416+ uncounted_exact += 1;
9320 refusals.push(format!(10417 refusals.push(format!(
9321- "cq={cq} period={period}: decoded, but no block read a V_DCT/H_DCT tx_type"10418+ "cq={cq} period={period}: decoded and pixel-compared, but no block read a \
10419+ V_DCT/H_DCT tx_type"
9322 ));10420 ));
9323- continue;
9324 }10421 }
9325 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);10422 let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
9326 assert_eq!(10423 assert_eq!(
@@ -9335,11 +10432,25 @@ mod tests {
9335 frames[0].v, ffmpeg_frames[0].v,10432 frames[0].v, ffmpeg_frames[0].v,
9336 "V vs ffmpeg (cq={cq} period={period})"10433 "V vs ffmpeg (cq={cq} period={period})"
9337 );10434 );
10435+ if counted {
9338 fired_runs += 1;10436 fired_runs += 1;
9339 if fired_runs >= 4 {10437 if fired_runs >= 4 {
10438+ gate_buckets(
10439+ "a_real_aomenc_min8_stream_with_tx_class1_decodes_pixel_exact",
10440+ fired_runs,
10441+ uncounted_exact,
10442+ refusals.len() - uncounted_exact as usize,
10443+ );
9340 return;10444 return;
9341 }10445 }
9342 }10446 }
10447+ }
10448+ gate_buckets(
10449+ "a_real_aomenc_min8_stream_with_tx_class1_decodes_pixel_exact",
10450+ fired_runs,
10451+ uncounted_exact,
10452+ refusals.len() - uncounted_exact as usize,
10453+ );
9343 panic!(10454 panic!(
9344 "fewer than 4 firing+pixel-exact runs out of 60 attempts:\n{}",10455 "fewer than 4 firing+pixel-exact runs out of 60 attempts:\n{}",
9345 refusals.join("\n")10456 refusals.join("\n")
@@ -10791,6 +11902,25 @@ mod tests {
10791 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");11902 assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})");
10792 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");11903 assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})");
10793 }11904 }
11905+ // lane-hidden r2 (class gate-blind-to-hidden-frames): the same
11906+ // stream again, comparing EVERY decode-order frame -- the hidden
11907+ // (show_frame == 0) alt-ref frames the ffmpeg compare above
11908+ // cannot see, because both sides of it emit shown frames only.
11909+ let (hidden_total, hidden_n) = decode_all_frames_vs_oracle(&stream, NAME);
11910+ eprintln!(
11911+ "{NAME} HIDDEN: seed {seed}: {hidden_total} decode-order frames, \
11912+ {hidden_n} hidden, all pixel-exact vs the oracle"
11913+ );
11914+ // lane-hidden r2 SECOND ARM (the recipe above is untouched):
11915+ // libaom's temporal alt-ref filter absorbs this recipe's hidden
11916+ // frames, so the compare above is vacuous -- re-encode the same
11917+ // fixture with --arnr-maxframes=0 and compare THOSE.
11918+ if let Some((arm_total, arm_hidden)) = hidden_arnr_arm(NAME, &y4m.stdout, &args) {
11919+ eprintln!(
11920+ "{NAME} HIDDEN-ARM(--arnr-maxframes=0): seed {seed}: {arm_total} \
11921+ decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle"
11922+ );
11923+ }
10794 matched += 1;11924 matched += 1;
10795 }11925 }
10796 assert!(11926 assert!(
@@ -12400,14 +13530,20 @@ mod tests {
12400 /// which is the per-unit availability rule this port exists for, and no13530 /// which is the per-unit availability rule this port exists for, and no
12401 /// gate fired one before this round.13531 /// gate fired one before this round.
12402 ///13532 ///
12403- /// This gate was `#[ignore]`d RED through r1 (seed 50 luma (171,56)).13533+ /// This gate was `#[ignore]`d RED through r3 (seed 50 luma (171,56)).
12404- /// Root cause, r2: not availability at all -- `av1_nz_map_ctx_offset` is13534+ /// Root cause, r4, TWO defects, neither of them availability -- the
12405- /// packed COLUMN-major, so [`crate::decode::base_ctx`] read the13535+ /// strip's own per-unit prediction was exact all along:
12406- /// `TX_32X64`/`TX_64X32` offset tables transposed and desynced the first13536+ /// 1. `av1_nz_map_ctx_offset` is indexed by libaom's COLUMN-major
12407- /// SB-level strip whose luma corner held a coefficient below row 1 (see13537+ /// `coeff_idx = col * 32 + row`, so [`crate::decode::base_ctx`] read
12408- /// that function's comment). The strip's own per-unit prediction was13538+ /// the `TX_32X64`/`TX_64X32` offset tables transposed (r2 saw this and
12409- /// already exact.13539+ /// r3 reverted it, because "fixing" it turned the merged SB HORZ/VERT
12410- #[ignore = "lane-rectsplit r3: RED at seed 50; the nz_map transposition r2 blamed turns the merged SB HORZ/VERT partition gate RED at seed 43, cause still open"]13540+ /// gate RED at seed 43);
13541+ /// 2. that seed-43 RED was a SECOND defect the first one had been hiding
13542+ /// behind a refusal: `EOB_PT_512_CHROMA` was transcribed from
13543+ /// `av1_default_eob_multi512_cdfs`'s `eob_multi_ctx = 1` row (the flat
13544+ /// `V_DCT`/`H_DCT` distribution), so the first real 32x16 chroma
13545+ /// transform read `eob_pt` 7 where aomdec read 2. With both fixed,
13546+ /// seeds 43 and 50 are pixel-exact.
12411 #[test]13547 #[test]
12412 fn a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact() {13548 fn a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact() {
12413 const NAME: &str = "a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact";13549 const NAME: &str = "a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact";
@@ -13041,4 +14177,197 @@ mod tests {
13041 assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (pinned sbpart)");14177 assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (pinned sbpart)");
13042 }14178 }
13043 }14179 }
14180+
14181+ /// lane-tx64x16 r1: a real `aomenc` stream whose superblock-level
14182+ /// partition decision is `PARTITION_HORZ_4`/`PARTITION_VERT_4` (four
14183+ /// 64x16 / 16x64 strips) must decode pixel-exact. Both arms are HARD
14184+ /// asserted, and only hits earned inside an attempt that then compared
14185+ /// pixel-exact against ffmpeg are counted -- a strip decoded by an
14186+ /// attempt that later refused proves nothing (class
14187+ /// gate-skips-on-its-own-failure). `--enable-1to4-partitions=1` is the
14188+ /// tool switch; `--min-partition-size=16` keeps the RD search from
14189+ /// recursing below 16x16, where several other unlanded partition shapes
14190+ /// live.
14191+ #[test]
14192+ fn a_real_aomenc_stream_with_a_superblock_level_1to4_partition_decodes_pixel_exact() {
14193+ const NAME: &str =
14194+ "a_real_aomenc_stream_with_a_superblock_level_1to4_partition_decodes_pixel_exact";
14195+ let _gate_lock = lock_gate_counters();
14196+ if !have_ffmpeg() {
14197+ eprintln!("SKIP {NAME}: no ffmpeg");
14198+ return;
14199+ }
14200+ if !have_aomenc() {
14201+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
14202+ return;
14203+ }
14204+ let (width, height, frame_count) = (192usize, 128usize, 1usize);
14205+ let mut named_refusals = 0u32;
14206+ let mut matched = 0u32;
14207+ let (mut horz_proved, mut vert_proved) = (0usize, 0usize);
14208+ let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32);
14209+ let n_attempts: u32 = std::env::var("EC_TX64X16_GATE_ATTEMPTS")
14210+ .ok()
14211+ .and_then(|s| s.parse().ok())
14212+ .unwrap_or(40);
14213+ for attempt in 0..n_attempts {
14214+ let seed = 42 + attempt;
14215+ let duration = frame_count as f64 / 25.0;
14216+ // Odd attempts render the SAME generator rotated 90 degrees
14217+ // (generated at height x width, then `transpose`), because
14218+ // aomenc's RD picks `PARTITION_VERT_4` on this content and
14219+ // essentially never `HORZ_4`: the two arms are a transposed
14220+ // pair, and a gate that only ever sees one of them cannot catch
14221+ // a transposed scan/context table (class scan-weights-cross-axis).
14222+ let source = if attempt % 2 == 0 {
14223+ gradients_source(seed, width, height, &format!("duration={duration}:rate=25"))
14224+ } else {
14225+ format!(
14226+ "{},transpose=1",
14227+ gradients_source(seed, height, width, &format!("duration={duration}:rate=25"))
14228+ )
14229+ };
14230+ let y4m = Command::new("ffmpeg")
14231+ .args([
14232+ "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f",
14233+ "yuv4mpegpipe", "-",
14234+ ])
14235+ .stdin(Stdio::null())
14236+ .stdout(Stdio::piped())
14237+ .stderr(Stdio::piped())
14238+ .output()
14239+ .expect("ffmpeg failed to run");
14240+ assert!(
14241+ y4m.status.success(),
14242+ "ffmpeg fixture: {}",
14243+ String::from_utf8_lossy(&y4m.stderr)
14244+ );
14245+ let args: Vec<&str> = vec![
14246+ "--codec=av1",
14247+ "--passes=1",
14248+ "--end-usage=q",
14249+ "--cq-level=45",
14250+ "--cpu-used=0",
14251+ "--threads=1",
14252+ "--row-mt=0",
14253+ "--sb-size=64",
14254+ "--enable-rect-partitions=1",
14255+ "--enable-ab-partitions=0",
14256+ "--enable-1to4-partitions=1",
14257+ "--min-partition-size=16",
14258+ "--max-partition-size=64",
14259+ "--enable-restoration=0",
14260+ "--enable-palette=0",
14261+ "--deltaq-mode=0",
14262+ "--enable-filter-intra=0",
14263+ "--enable-cfl-intra=0",
14264+ "--enable-intrabc=0",
14265+ "--enable-tx-size-search=0",
14266+ "--obu",
14267+ "-o",
14268+ "-",
14269+ "-",
14270+ ];
14271+ let mut child = Command::new(aomenc_path())
14272+ .args(&args)
14273+ .stdin(Stdio::piped())
14274+ .stdout(Stdio::piped())
14275+ .stderr(Stdio::piped())
14276+ .spawn()
14277+ .expect("aomenc failed to start");
14278+ child
14279+ .stdin
14280+ .take()
14281+ .expect("aomenc stdin")
14282+ .write_all(&y4m.stdout)
14283+ .expect("writing y4m to aomenc");
14284+ let out = child.wait_with_output().expect("aomenc failed to run");
14285+ assert!(
14286+ out.status.success(),
14287+ "aomenc refused the fixture: {}",
14288+ String::from_utf8_lossy(&out.stderr)
14289+ );
14290+ let stream = out.stdout;
14291+ let before = (
14292+ crate::decode::sb_rect4_horz_hits(),
14293+ crate::decode::sb_rect4_vert_hits(),
14294+ );
14295+ let frames = match decode_stream(&stream) {
14296+ Err(e) => {
14297+ let msg = e.to_string();
14298+ assert!(
14299+ msg.contains("unsupported"),
14300+ "{NAME} failed outright, not a named refusal (seed {seed}): {msg}"
14301+ );
14302+ named_refusals += 1;
14303+ eprintln!("seed {seed} refusal: {msg}");
14304+ continue;
14305+ }
14306+ Ok(frames) => frames,
14307+ };
14308+ let (horz, vert) = (
14309+ crate::decode::sb_rect4_horz_hits() - before.0,
14310+ crate::decode::sb_rect4_vert_hits() - before.1,
14311+ );
14312+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count);
14313+ assert_eq!(frames.len(), frame_count);
14314+ let mismatched = frames
14315+ .iter()
14316+ .zip(&ffmpeg_frames)
14317+ .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v);
14318+ if horz + vert == 0 {
14319+ // Out of this gate's territory: aomenc's RD picked no 1:4
14320+ // partition at all for this seed, so the attempt can neither
14321+ // prove nor disprove the arms under test. NOT silently
14322+ // dropped -- counted and printed, and a mismatch here is
14323+ // reported as a defect of another lane's shape (r1 found
14324+ // one: seed 55 of this very recipe decodes 3944 wrong luma
14325+ // samples with zero 1:4 blocks in the stream, first at
14326+ // (154, 59), inside the 64x32 `PARTITION_HORZ` superblock at
14327+ // (128, 64) -- see lanes/tx64x16-r1.report.md). Selecting on
lanes/covbd2-r1.report.mdadded+93 -0
@@ -0,0 +1,93 @@
1+# lane-covbd2 r1 — default-on tools and non-`--enable-*` spellings
2+
3+Branch `lane-covbd2`, rebased onto main 593de22 (charter said 06d856d; `git rebase main`
4+per COMMON, clean, gate counts moved 45/4 -> 56/15).
5+
6+## What changed (crates/ec-av1/src/gate_coverage.rs only; no gate recipe touched)
7+- `On` enum + `DEFAULT_ON_TOOLS` (10 entries, each `(tool, aomenc spelling(s), aomenc default,
8+ what counts as on)`) — the third instance of class *tool-disabled-in-every-gate*: lane-covbd's
9+ derivation read `"--enable-` only, so `--enable-tx-size-search=0` (34/41 8-bit gates),
10+ `--loopfilter-control=0`, `--tile-columns/--tile-rows` and `--cpu-used` were invisible.
11+- `ALIASES` (`superres-mode` -> `enable-superres`), applied in `enabled_at()`: the three
12+ superres gates drive `--superres-mode=1`, so `enable-superres` is now *covered* and its two
13+ entries were deleted from `NEVER_EXERCISED_8BIT`/`_10BIT` (the covbd deferral, closed).
14+- `NEVER_ON_8BIT` (6) / `NEVER_ON_10BIT` (7), each `(tool, why)`, with the off/defaulted split in
15+ the reason. Same "defaulted means unknown" rule: a default of `1` is not proof the encoder
16+ picked the tool, only an explicit on-value at that depth retires an entry.
17+- `settings_in()` (whole `--flag=value` pairs, values kept whole — `--cpu-used=4`,
18+ `--tile-columns=2`), `default_on_state()`, `default_on_settings()`, `never_on_at()`.
19+- Tests: `never_on_8bit_matches_the_gate_recipes`, `never_on_10bit_matches_the_gate_recipes`
20+ (both directions: unlisted hole fails, closed hole fails until deleted),
21+ `default_on_tools_do_not_duplicate_the_universe` (no double-pinning, every alias names a real
22+ `TOOL_UNIVERSE` tool), `print_never_on_per_bit_depth` (helper).
23+
24+## Printed lists (verbatim)
25+```
26+gate_coverage: 56 real-aomenc gates, 15 of them 10-bit
27+NEVER_EXERCISED_8BIT (11 of 26):
28+ --enable-1to4-partitions
29+ --enable-angle-delta
30+ --enable-cfl-intra
31+ --enable-dist-wtd-comp
32+ --enable-dual-filter
33+ --enable-flip-idtx
34+ --enable-global-motion
35+ --enable-intrabc
36+ --enable-rect-tx
37+ --enable-ref-frame-mvs
38+ --enable-tx64
39+NEVER_EXERCISED_10BIT (9 of 26):
40+ --enable-1to4-partitions
41+ --enable-angle-delta
42+ --enable-cfl-intra
43+ --enable-dual-filter
44+ --enable-flip-idtx
45+ --enable-intrabc
46+ --enable-rect-tx
47+ --enable-ref-frame-mvs
48+ --enable-tx64
49+NEVER_ON_8BIT (6 of 10, over 41 8BIT gates):
50+ deblocking (--loopfilter-control): off in 7, defaulted in 34, on in 0
51+ enable-diff-wtd-comp (--enable-diff-wtd-comp): off in 6, defaulted in 35, on in 0
52+ enable-directional-intra (--enable-directional-intra): off in 32, defaulted in 9, on in 0
53+ enable-fwd-kf (--enable-fwd-kf): off in 11, defaulted in 30, on in 0
54+ enable-onesided-comp (--enable-onesided-comp): off in 17, defaulted in 24, on in 0
55+ enable-tx-size-search (--enable-tx-size-search): off in 34, defaulted in 7, on in 0
56+NEVER_ON_10BIT (7 of 10, over 15 10BIT gates):
57+ deblocking (--loopfilter-control): off in 1, defaulted in 14, on in 0
58+ enable-diff-wtd-comp (--enable-diff-wtd-comp): off in 1, defaulted in 14, on in 0
59+ enable-fwd-kf (--enable-fwd-kf): off in 3, defaulted in 12, on in 0
60+ enable-interintra-wedge (--enable-interintra-wedge): off in 5, defaulted in 10, on in 0
61+ enable-onesided-comp (--enable-onesided-comp): off in 5, defaulted in 10, on in 0
62+ enable-tx-size-search (--enable-tx-size-search): off in 11, defaulted in 4, on in 0
63+ multi-tile (--tile-columns,tile-rows): off in 0, defaulted in 15, on in 0
64+```
65+Two entries of `DEFAULT_ON_TOOLS` are NOT holes and so print nowhere:
66+`enable-smooth-interintra` and `intrabc-search` (`--cpu-used<=2`, on in 51 gates) are
67+positively exercised at both depths; `multi-tile` is exercised at 8 bits only
68+(`--tile-columns=1/2`, `--tile-rows=1/2`).
69+
70+## Findings worth a lane
71+- `enable-tx-size-search` pinned off in 34/41 8-bit and 11/15 10-bit gates, on in none — the pin
72+ that hid the real-stream PANIC lane-ab16 hit; lane-txselect landed TX_MODE_SELECT but no gate
73+ spells the flag on, so the guard now says so.
74+- `multi-tile` at 10 bits: every one of the 15 10-bit gates is single-tile, so no tile edge or
75+ per-tile CDF reset is checked at high bit depth (the `enable-restoration` shape that cost
76+ lane-hbdinter two 10-bit-only defects).
77+- `deblocking`: no gate at either depth spells `--loopfilter-control=1`; 7+1 pin it to 0.
78+
79+## Tests
80+- `cargo test -p ec-av1 --lib gate_coverage -- --nocapture` -> 9 passed, 0 failed (was 5).
81+- `cargo test -p ec-av1 --lib refusal_inventory` -> 3 passed, 0 failed.
82+- EVIDENCE: crates/ec-av1/src/gate_coverage.rs | cargo test -p ec-av1 --lib gate_coverage -- --nocapture (CARGO_TARGET_DIR=~/.cache/cargo-target-covbd2) | 9/9 pass, 56 gates parsed, 15 ten-bit, lists above
83+
84+## Refusals lifted
85+None — instrumentation only, no decode behaviour changed.
86+
87+## Residue
88+- deferred: closing any NEVER_ON hole — chartered "do NOT write gates". What unblocks it: a gate
89+ at that depth spelling the on-value and asserting the feature fired; the test then fails until
90+ the entry is deleted.
91+- accepted: `--cpu-used` is modelled as one tool (`intrabc-search`, on at <=2). If another
92+ cpu-used-gated search needs its own threshold, add a second entry with its own `On::AtMost`.
93+- accepted: no repo-wide `cargo fmt`; only gate_coverage.rs is in the commit.
lanes/gmaffine-r1.report.mdadded+83 -0
@@ -0,0 +1,83 @@
1+# lane-gmaffine r1 — VERDICT: NOT DONE. Branch must NOT merge.
2+
3+Item (1) (AFFINE global motion, previous builder, HEAD 44bd68c) re-verified GREEN.
4+Items (2) 8x8 WARPED_CAUSAL and (3) 8x8 GLOBALMV are IMPLEMENTED but UNGATED —
5+both new gates are RED, so by COMMON's own rule ("a refusal is lifted ONLY together
6+with a gate") this branch is not mergeable as it stands.
7+
8+## Item (1) re-verified
9+`a_real_affine_global_motion_stream_decodes_pixel_exact` still passes on this branch.
10+EVIDENCE: cargo test -p ec-av1 --release --lib (whole-suite run below) | gate ran with
11+EC_AV1_REQUIRE_AOMENC=1 | listed in the 266 passing tests, not among the 4 failures.
12+
13+## What the round actually found (the premise in the charter was too narrow)
14+`decode_inter_block8` (the 8x8 leaf) was not merely missing warp/GLOBALMV: it was
15+**unreachable for interior blocks at all** — `decode.rs` refused every interior 16x16
16+`PARTITION_SPLIT` ("an inter partition below 16x16 …"), so the leaf only ran for
17+frame-edge straddling blocks. Wiring it exposed four more gaps in that same function,
18+each of which had to be closed before either charter gate could even reach a leaf:
19+non-LAST single references, no `read_mb_interp_filter` at all (silent entropy desync on
20+every SWITCHABLE stream), the missing short OBMC masks, and non-DC chroma modes.
21+
22+## Changed (all in the worktree, branch lane-gmaffine)
23+- `crates/ec-av1/src/decode.rs`
24+ - 8x8 leaf: `GLOBALMV` via `gm_get_motion_vector` (`GLOBALMV_HITS_8`), replacing the
25+ "GLOBALMV (round 3)" refusal.
26+ - 8x8 leaf: `WARPED_CAUSAL` = `find_samples` → `select_samples` → `find_projection` →
27+ `warp_affine` on all three planes (`WARP_HITS_8`), replacing the "an 8x8 leaf that
28+ coded WARPED_CAUSAL" refusal.
29+ - 8x8 leaf: `allow_warp`'s global-warp branch (`global_warp_params`, independent of
30+ motion_mode), `MiInfo::is_global_mv0`, motion-mode suppression for
31+ `is_global_mv_block`.
32+ - 8x8 leaf: mv stack now built with `find_mv_stack_with_sign_bias(..., &gm_table, ..)`
33+ so a missing candidate falls back to the block's own gm mv (gm r6's root cause,
34+ previously fixed only at the 16x16+ leaf).
35+ - 8x8 leaf: full `read_single_ref` tree + `ref_planes` — "a reference frame other than
36+ LAST_FRAME (round 2)" removed.
37+ - 8x8 leaf: `resolve_interp_filter` read in libaom's order (interintra, motion_mode,
38+ filter) and `mc::predict_with_filters`; corner-cut documented in-code (neighbour
39+ filter ctx is the enclosing 16x16's, ceiling = siblings that pick different filters).
40+ - interior 16x16 `PARTITION_SPLIT` → four 8x8 leaves (same loop the straddle branch
41+ ran); the refusal narrows to "an inter partition below 16x16 other than a clean split
42+ into four 8x8 leaves".
43+ - `obmc_mask`: libaom `obmc_mask_1`/`obmc_mask_2` ([64], [45,64]) — the old
44+ `unreachable!()` was a hard PANIC as soon as a real 8x8 leaf ran OBMC.
45+- `crates/ec-av1/src/stream.rs` — `run_8x8_leaf_motion_gate` + gates
46+ `a_real_globalmv_8x8_leaf_stream_decodes_pixel_exact`,
47+ `a_real_warped_causal_8x8_leaf_stream_decodes_pixel_exact` (mandelbrot rotate+stretch,
48+ `--min/--max-partition-size=8`, cq sweep 32/45/55, 8- and 10-bit, hard-assert on the
49+ 8x8-specific counters, no SKIP path).
50+- `crates/ec-av1/src/refusal_inventory.rs` — 3 strings removed, 1 narrowed.
51+
52+## Gate results (all real runs, EC_AV1_REQUIRE_AOMENC=1)
53+EVIDENCE: cargo test -p ec-av1 --release --lib -- a_real_globalmv_8x8_leaf a_real_warped_causal_8x8_leaf
54+| 6 aomenc encodes per gate (8/10-bit x cq 32/45/55) | RED, 0 firing attempts. Last blockers:
55+globalmv gate = "a partition below 8x8" (cq32/45) and "a non-DC chroma mode on an 8x8
56+inter-frame leaf" (cq55); warp gate = a desync panic in `switchable_interp` (leaf entropy
57+state still wrong somewhere, most likely the coarse per-leaf neighbour contexts).
58+
59+EVIDENCE: cargo test -p ec-av1 --release --lib -- a_real_aomenc_stream_with_obmc_8x8 |
60+same command, seed 53 | the pre-existing 8x8 OBMC gate, vacuous (never fired) for three
61+rounds, NOW REACHES 8x8 LEAVES and gets frame 14 luma+U exact, V off by ~2 at a handful of
62+positions — a real residual 8x8-leaf chroma defect, previously invisible.
63+
64+## Suite
65+`cargo test -p ec-av1 --release --lib` (EC_AV1_REQUIRE_AOMENC=1): **266 passed, 4 failed,
66+23 ignored** — failures were `refusal_inventory` (fixed after that run), `obmc_8x8`
67+(residual chroma defect above), and the two new RED gates. No previously-green gate
68+regressed.
69+
70+## Residue
71+- fix-now (next round): the 8x8-leaf residual that keeps every 8x8 gate from going green —
72+ order of attack: (a) chroma OBMC/prediction at BLOCK_8X8 (obmc_8x8 gate is one V plane
73+ away and is the cheapest instrument), (b) per-leaf neighbour contexts (filter/ref/skip
74+ arrays are all the enclosing 16x16's, a documented corner-cut that now matters),
75+ (c) non-DC chroma mode + sub-8x8 partition refusals at the leaf.
76+- deferred: compound `GLOBAL_GLOBALMV` per-ref global warp — grep found NO refusal for it;
77+ `decode_inter_block`'s compound branch builds both taps translationally through
78+ `mc::predict_compound_intermediate` and never calls `warp_affine`, so a compound global
79+ block with a ROTZOOM/AFFINE model is SILENTLY WRONG today. Unblocked by: a compound
80+ warp path (warp into the i32 intermediate, libaom `av1_warp_plane` with `conv_params`),
81+ which is its own lane-sized port. NOT started this round.
82+- accepted/flag: `warp::warp_affine` hardcodes `const BD: i32 = 8;` — worth one round's
83+ check against a 10-bit warp stream (his films are yuv420p10le).
lanes/gmaffine-r2.report.mdadded+100 -0
@@ -0,0 +1,100 @@
1+# lane-gmaffine r2 — item (1) CLOSED green, item (2) root-caused (not what the charter guessed), item (3) blocked on lane-inter8
2+
3+Commit: `0a5cbe3` on `lane-gmaffine` (on top of r1's `65ef3f5`). Not rebased onto main
4+(charter order). Suite: **268 passed, 2 failed, 23 ignored** (`cargo test -p ec-av1
5+--release --lib`, `EC_AV1_REQUIRE_AOMENC=1`) — r1 was 266/4/23; the two remaining
6+failures are the two RED 8x8-leaf motion gates, everything else green, no regression.
7+
8+## (1) obmc_8x8 V-plane residual — FIXED, gate GREEN
9+Root cause exactly where the charter pointed: libaom `av1_skip_u4x4_pred_in_obmc`
10+(`~/.cache/aom-oracle/src/av1/common/reconinter.c:820`, `DISABLE_CHROMA_U8X8_OBMC 0`)
11+returns `dir == 0` when the block's CHROMA plane size is `BLOCK_4X4/4X8/8X4` — i.e. OBMC
12+on chroma is ONE-SIDED below 16px luma: the ABOVE pass (`dir==0`) skips U/V entirely, the
13+LEFT pass (`dir==1`) still blends them. We blended chroma in both passes.
14+Fix: `crates/ec-av1/src/decode.rs:8419` (`let chroma_above = write_w >= 16 && write_h >= 16;`)
15+guarding the above pass's U/V blends. Luma is unaffected at every size, which is why
16+r1 saw luma+U exact and only V off by ~2.
17+Also hardened: the gate's terminal "never fired" branch was an `eprintln!("SKIP …")`
18+(class `gate-skips-on-its-own-failure`); it is now a `panic!` — `crates/ec-av1/src/stream.rs:4401`.
19+
20+EVIDENCE: `cargo test -p ec-av1 --release --lib -j3 -- obmc_8x8 --nocapture` (EC_AV1_REQUIRE_AOMENC=1)
21+| real aomenc `--enable-obmc=1 --min-partition-size=8` stream, seed 53, 24 frames, decoded vs ffmpeg
22+| `a_real_aomenc_stream_with_obmc_8x8_decodes_pixel_exact FIRING seed 53: 8x8 obmc hits 4`, all 24 frames Y+U+V byte-equal, test result ok.
23+
24+## (2) warp gate's `switchable_interp` crash — root cause was NOT a desync
25+`RUST_BACKTRACE=1` put the panic at `obmc_blend -> neighbour_filter ->
26+from_switchable_symbol`, and an instrumented print pinned it: block `mi_row=0 mi_col=2`,
27+LEFT pass, `Neighbours` slot 0 holding `[3, 3]`. That is the enclosing 16x16's coarse
28+filter slot — written only AFTER all four 8x8 leaves decode — so an 8x8 leaf that
29+OBMC-blends its own SIBLING leaf reads the "intra/unset" sentinel and panics.
30+libaom takes the OBMC neighbour's filter from the neighbour mbmi's own `interp_filters`
31+(`av1_setup_build_prediction_by_{above,left}_pred`), which is mi-granular. Ported:
32+- `crates/ec-av1/src/mvstack.rs:180` — `MiGrid::filters` (`[u8;2]` per mi, `[3,3]` = unset)
33+ + `set_filter`/`filter`.
34+- `crates/ec-av1/src/decode.rs` — writers at the 16x16+ single-ref `grid.set` loop and at
35+ the 8x8 leaf; reader in `obmc_blend` via `grid_or_slot` (mi record preferred, the coarse
36+ `Neighbours` slot kept as fallback for paths that record none, e.g. compound).
37+- `decode_inter_block8` now RETURNS its real filter symbols and reference; the caller's
38+ post-leaf `record_inter` used `[3, 3]` and a hardcoded `LAST_FRAME` for the whole 16x16
39+ (r1 corner-cut) — both were feeding wrong switchable_interp/ref contexts to the NEXT
40+ block, and the leaf's `fill_lf_grid` ref id was likewise always LAST.
41+Charter hypothesis checked and REJECTED with the source: `read_inter_block_mode_info`
42+(`decodemv.c:1525/1562/1621`) reads interintra → motion_mode → `read_mb_interp_filter`,
43+which is the order both our leaves already use; `av1_is_interp_needed`'s three suppressors
44+(skip_mode, WARPED_CAUSAL, `is_nontrans_global_motion` incl. IDENTITY) match our
45+`gm_nontrans || warped_selected || skip_mode` argument. No symbol-order defect here.
46+
47+EVIDENCE: `cargo test … -- a_real_warped_causal_8x8 --nocapture` before/after
48+| same 6 aomenc encodes | before: `panicked at mc.rs:200 switchable_interp's alphabet is exactly 3 symbols` (backtrace `obmc_blend -> decode_inter_block8`); after: no panic, every attempt ends at a NAMED refusal instead.
49+
50+## (3) both new gates still RED — the blocker is an 8x8-leaf ENTROPY DESYNC, deferred to lane-inter8
51+With the panic gone, the sweeps end like this (`EC_AV1_REQUIRE_AOMENC=1`,
52+`-- _8x8_leaf --nocapture`, `--min/--max-partition-size=8`):
53+- globalmv gate: `a partition below 8x8` (2), `a non-DC chroma mode on an 8x8 inter-frame leaf` (3), `a nonzero angle delta` (1 at maxpart=32)
54+- warp gate: `an inter partition below 16x16 other than a clean split into four 8x8 leaves` (4), `a non-skip rectangular (HORZ/VERT/HORZ_B) strip …`, `an INTER 32x32 partition type … (value=8)`
55+Every one of those recipes passes `--enable-rect-partitions=0 --enable-ab-partitions=0
56+--enable-1to4-partitions=0 --enable-angle-delta=0 --enable-directional-intra=0
57+--min-partition-size=8` to aomenc, so the encoder CANNOT have written a sub-8x8 partition,
58+a rect strip or a nonzero angle delta: these are misread symbols, i.e. a real entropy
59+desync in/around the 8x8 leaf, surfacing as refusal strings (class
60+`refusal-names-a-correlate`). The same 8x8 leaf decodes 24 frames pixel-exact in the obmc
61+gate (gradients source, `--max-partition-size=32`, warp off, gm default), so the desync is
62+config/content-dependent, not "the leaf is broken".
63+Recipe search knobs added so the next round needs no rebuild: `EC_8X8_MINPART`,
64+`EC_8X8_MAXPART` (defaults 8/8, i.e. unchanged) — `crates/ec-av1/src/stream.rs:5449`.
65+Neither gate ever reaches a GLOBALMV or WARPED_CAUSAL 8x8 leaf; both die earlier, so
66+nothing about r1's motion code is disproved (or proved) by them.
67+
68+## DEVIATION from the charter (named, with reason)
69+The charter's fallback said: if a gate cannot go green, RESTORE the refusal strings r1
70+removed. I did NOT. Reasons: (a) restoring them puts a refusal BEFORE the code it guards,
71+making r1's GLOBALMV/WARPED_CAUSAL 8x8 implementation dead code (class
72+`refusal-short-circuits-its-own-code`); (b) the two gates die on partition/chroma refusals
73+that belong to lane-inter8's cluster and never reach the motion code, so the restored
74+refusals would not be what is failing; (c) `decode_inter_block8` is being edited
75+concurrently by lane-inter8 and a refusal re-insertion there is a merge conflict for no
76+verification gain; (d) a GLOBALMV-at-8x8 refusal would likely turn the now-GREEN obmc_8x8
77+gate RED (its streams do reach 8x8 leaves with global motion enabled by default).
78+If the orchestrator wants the r1 lift out, revert `65ef3f5`'s `refusal_inventory.rs` hunk
79+plus its two `decode.rs` refusal deletions; **commit `0a5cbe3` (this round) is independent
80+of that lift** — the chroma-OBMC fix, the mi-granular filter record and the leaf
81+filter/ref plumbing are all gated by `a_real_aomenc_stream_with_obmc_8x8_decodes_pixel_exact`
82+and merge on their own.
83+
84+## Residue
85+- fix-now next round, deferred(lane-inter8): the 8x8-leaf entropy desync above. Attack:
86+ `EC_AV1_GATE_DUMP` the first refusing stream, decode it under `EC_TRACE_MODE` against
87+ instrumented aomdec, compare msac RANGE element by element from the first inter frame's
88+ first 8x8 leaf (never `tell()`).
89+- deferred(lane-hbdinter): `warp::warp_affine` hardcodes `const BD: i32 = 8;` — every
90+ 10-bit warp/global-warp block is predicted at the wrong bit depth. Not touched here.
91+- deferred(own lane): compound `GLOBAL_GLOBALMV` never warps — `decode_inter_block`'s
92+ compound branch builds both taps translationally through `mc::predict_compound_intermediate`
93+ and there is NO refusal for it, so a compound global block with a ROTZOOM/AFFINE model is
94+ silently wrong. Unblocked by a compound warp path (`av1_warp_plane` into the i32
95+ intermediate with `conv_params`).
96+- accepted corner-cut: `Neighbours` stays 16px-granular; the leaf loop records the LAST
97+ INTER leaf's filter/ref into the shared slot. Ceiling: a 16x16 whose 8x8 siblings choose
98+ different filters/refs gives the NEXT block one sibling's context instead of the
99+ bordering one's. Upgrade: mi-granular `above_filter`/`above_ref` arrays (the `MiGrid`
100+ filter record added this round is half of that already).
lanes/gmaffine-r3.report.mdadded+84 -0
@@ -0,0 +1,84 @@
1+# lane-gmaffine r3 — lane-inter8 merged, one real 8x8-leaf desync fixed, two gates still RED
2+
3+Commits on `lane-gmaffine`: `0d56f26` (merge of lane-inter8 `ae69b25`) and `0b8cb54`
4+(the context-index fix). Not rebased onto main (charter order).
5+
6+Suite: **271 passed, 2 failed, 24 ignored** (`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1
7+--release --lib -j3`, 571 s). r2 was 268/2/23; the deltas are lane-inter8's gates arriving.
8+The two failures are the same two 8x8-leaf motion gates, still red.
9+
10+## STEP 1 — merge (13 conflicts, all in `decode.rs` + 1 in `refusal_inventory.rs`)
11+Resolution, per the charter's "keep both, unify duplicates" (full list in `0d56f26`'s message):
12+- OBMC chroma-above skip: kept **lane-inter8's** explicit `BLOCK_4X4/4X8/8X4` match. r2's
13+ `write_w >= 16 && write_h >= 16` is wrong for 8x32/32x8, where libaom's chroma plane is
14+ 4x16/16x4 and the above pass DOES blend chroma.
15+- OBMC neighbour filter: read from lane-inter8's now mi-granular `Neighbours::above_filter`
16+ /`left_filter`. r2's `MiGrid::filters` + `set_filter`/`filter`/`grid_or_slot` recorded the
17+ SAME field per mi and are deleted (`mvstack.rs`, `decode.rs`).
18+- `decode_inter_block8`: one `global_motion` param (r1's), plus lane-inter8's
19+ `sign_bias_table` and `tpl_frame`; one `gm_table` build at the top; returns
20+ `(skip, is_inter, skip_mode, compound_ctx8, leaf_filter_syms, leaf_refs)`.
21+- The leaf's temporal-mv `cur_offset_0` now keys on the leaf's OWN reference — lane-inter8
22+ hardcoded `LAST_FRAME` there because its leaf refused every other ref, which r1 lifted.
23+- Per-leaf `record_inter_rect_mi` keeps r2's REAL filter symbols instead of lane-inter8's
24+ `[3, 3]` intra sentinel (that sentinel is what panicked `neighbour_filter`); the coarse
25+ whole-16x16 `record_inter` and its `last_filter`/`last_ref` bookkeeping are gone.
26+- Interior 16x16 SPLIT: lane-inter8's restructure (one `part16` read, one shared leaf loop);
27+ refusal strings follow it.
28+
29+## STEP 3 — first divergent element found and fixed (class: unit mismatch after a granularity change)
30+`crates/ec-av1/src/decode.rs:11504,11700-11716` — `decode_inter_block8` still indexed
31+`neighbours.above_ref/above_ref1/above_filter` with `c` and the `left_*` twins with `r`,
32+i.e. `outer_at`, the enclosing 16x16's **SUB(16px)** coordinates, while every other read in
33+the same function uses `cmi`/`rmi` (**mi**, 4px) since lane-inter8 r2 made those bands
34+mi-granular. So a leaf's `read_single_ref` p1..p6 contexts and its `switchable_interp`
35+neighbour rows came from an unrelated 16px column/row. Now `cmi`/`rmi`.
36+
37+EVIDENCE: `/tmp/.../scratchpad/{ref-mode.txt,o3.txt}` (aomdec `EC_TRACE_MODE` ladder vs ours)
38+| stream `none-8-32.obu` = the gate recipe with gm and warp both off, 8-bit cq32,
39+`--min/--max-partition-size=8`, decoded by instrumented aomdec and by
40+`cargo run --example decode_probe` with `EC_TRACE_MODE=1`
41+| first inter frame, first 32x32: before the fix leaf mi=(6,6) had identical mode/mv/stack
42+(NEWMV, mv (0,-7), stack 5) but post-mode-info range **41953 vs aomdec 38345**; after the
43+fix that leaf and the following 15 agree to the range (38345, 51367, 58585, 58652, 54339,
44+37583 …). The stream's refusal moved from "an INTER 32x32 partition type … (value=8)" (a
45+bogus symbol from the desync) to a later block.
46+
47+Instrument added and kept: `EC_MODE_VAL8` under `EC_TRACE_MODE`
48+(`crates/ec-av1/src/decode.rs:11731`), one line per 8x8 leaf
49+(`newmv/globalmv/ref0/mv0/stack/rng`), diffable line-for-line against aomdec's
50+`EC_MODE_VAL`. Reproduce script: `scratchpad/enc.sh <cq> <depth> <gm> <out.obu>`.
51+
52+## STEP 2 — gate results
53+EVIDENCE: `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --release --lib -j3 -- obmc_8x8 globalmv_8x8_leaf warped_causal_8x8_leaf 8x8_leaf_split --nocapture`
54+| the merged tree, real aomenc streams | `a_real_aomenc_stream_with_obmc_8x8_decodes_pixel_exact` **ok**
55+(FIRING seed 53, 8x8 obmc hits 4), `a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact`
56+**ok**, both motion gates **FAILED** with named refusals (never a SKIP).
57+
58+## Still RED — the next divergent element (for r4)
59+Same instrument, same stream: first inter frame, leaf **mi=(0,14)** — aomdec reads
60+`mode=16` (NEWMV) `mv0=(0,-12)` from a 3-entry stack; we read not-new, `mv0=(0,-11)`, also
61+3 entries. Stack SIZE agrees, so the suspect is the mode context itself
62+(`stack.new_mv_ctx`, i.e. `find_mv_stack_with_sign_bias`'s weight/context computation for a
63+2x2-mi block at the right frame edge with no above row), not the stack contents. Every leaf
64+before it in that frame matches to the range.
65+Note the gate recipe is `--max-partition-size=8`, i.e. EVERY block is an 8x8 leaf; the
66+lane-inter8 gate that is green uses `--max-partition-size=16`, so this is the harder
67+all-leaf case, and it fails identically with gm off, gm on and warp on (three encodes) —
68+**the remaining desync is not global-motion or warp specific**.
69+
70+## Refusals / inventory
71+No refusal string changed this round; `refusal_inventory` and `gate_coverage` are green
72+(they are part of the 271). r1's GLOBALMV/WARPED_CAUSAL 8x8 lifts stay lifted, restating
73+r2's named DEVIATION from the charter fallback: restoring them would put a refusal BEFORE
74+the code it guards (class `refusal-short-circuits-its-own-code`), the two gates never reach
75+the motion code (they die on partition refusals from the desync above), and a GLOBALMV-at-8x8
76+refusal would turn the GREEN obmc_8x8 gate red. The lift is not mergeable to main until a
77+gate proves it; the merge + context fix in this round are.
78+
79+## Residue
80+- fix-now (r4), deferred(nothing — it is the next step): leaf mi=(0,14) `new_mv_ctx` above.
81+- deferred(lane-hbdinter): `warp::warp_affine` hardcodes `const BD: i32 = 8;`.
82+- deferred(own lane): compound `GLOBAL_GLOBALMV` never warps, and no refusal names it.
83+- accepted: `EC_MODE_VAL8` prints only on the single-ref leaf path (the compound arm returns
84+ earlier); enough for these gates, whose leaves are single-ref.
lanes/gmaffine-r4.report.mdadded+66 -0
@@ -0,0 +1,66 @@
1+# lane-gmaffine r4 — the 8x8-leaf desync was a MISSING CDF ROW (chroma/most-size `eob_pt` class-1), not the mv stack
2+
3+Commits on `lane-gmaffine`, on top of r3 (`f8de9c3`). Suite:
4+`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --release --lib -j3` →
5+**271 passed, 2 failed, 24 ignored** (r3: 269/2/24 equivalent — no regression; the 2
6+failures are the same two 8x8 motion gates, now failing on PIXELS, not on a refusal).
7+
8+## Root cause 1 (entropy, fixed): `eob_pt` class-1 CDF existed only for two LUMA sizes
9+libaom's `av1_default_eob_multi*_cdfs[q][PLANE_TYPES][2]` splits every eob_pt table by
10+`eob_multi_ctx = (tx_class == TX_CLASS_2D) ? 0 : 1`. This crate carried that second row
11+for `eob_pt_16_luma` and `eob_pt_64_luma` ONLY (lane-av1tx4 r5); every other table —
12+including all chroma — fell back to its 2D row (`cdf_state.rs`, 14 `TxbSet` arms had
13+`eob_pt_class1: None`).
14+Why it bit exactly here: an INTER block's chroma never codes a `tx_type` symbol, it
15+INHERITS the colocated luma type verbatim (`av1_get_tx_type`, blockd.h:1291). The gate's
16+8x8 leaves code `H_ADST` luma, so their 4x4 chroma is a 1D class — a routine case that
17+read the 2D CDF: right value, wrong interval, desync one symbol later.
18+Fix: class-1 siblings for all 9 remaining tables (16/64/128 chroma, 256/512/1024 both
19+planes) — `cdf.rs` (36 new consts, machine-extracted from `token_cdfs.h`),
20+`cdf_state.rs` (fields + `reset1` per-frame counter reset + q-context `pick` + all 14
21+`txb()` arms now `Some(..)`; 0 `eob_pt_class1: None` left).
22+
23+EVIDENCE: `/tmp/.../scratchpad/{ours_c.txt,aom_c.txt}` | `EC_TRACE_COEFF=1 EC_TRACE_MODE=1`
24+ours vs instrumented aomdec on `gm1_cq32.obu` (sha256 22d09738…, the globalmv gate's own
25+8-bit cq32 recipe) | first divergent element = the chroma (plane 1) 4x4 eob of leaf
26+mi=(6,4): both enter at rng=37748 and decode eob=16, ours leaves at rng=35080, aomdec at
27+54536. After the fix all four gate streams (`gm{0,1}_cq{32,45}`) decode all 24 frames
28+instead of refusing ("an inter partition below 16x16 other than SPLIT" / "a partition
29+below 8x8" — both were `refusal-names-a-correlate` symptoms of this desync).
30+
31+## Root cause 2 (prediction, fixed, libaom-cited): warp is per PLANE and bails below 8x8
32+`av1_init_warp_params` (reconinter.c:58) returns before `allow_warp` when
33+`block_width < 8 || block_height < 8` — in 420 that is the chroma plane of every luma
34+block below 16x16. We warped chroma at 4x4. Fixed at both warp sites
35+(`decode.rs` 16x16+ site `chroma_side >= 8`, 8x8-leaf site `CHROMA_SIDE >= 8`).
36+
37+## Still RED: chroma-only pixel residue on both 8x8 motion gates — fix-now, next round
38+Luma is byte-exact on all 24 frames of both gates; U/V differ by ±1..3 in a handful of
39+4x4 chroma blocks (frame 1: 40 U + 45 V pixels in 3 blocks; frames 2/3 similar).
40+EVIDENCE: `/tmp/.../scratchpad/{ours.yuv,ref.yuv}` | `EC_PROBE_DUMP=… decode_probe
41+gm1_cq32.obu` vs `ffmpeg -i gm1_cq32.obu -pix_fmt yuv420p` | frame 1 ydiff 0, udiff 40,
42+vdiff 45, mismatching chroma 4x4 blocks (12,8), (16,8), (20,8) = the 8x8 leaves at mi
43+(6,4), (8,4), (10,4); block (12,8) ours [97,119,105,95] vs ref [98,117,106,94].
44+Facts established for the successor:
45+- those three leaves are NOT warped and NOT global (`EC_WARP8 mi_row=6 mi_col=4
46+ warp=false globalblk=false`), so root cause 2 is not it and neither is the gm/warp code;
47+- their luma tx_type is `H_ADST` (class horiz) — i.e. exactly the blocks whose CHROMA now
48+ inherits a 1D-class type. Prime suspect: the chroma side of that inheritance — either
49+ the inverse basis at 4x4 chroma, or libaom's `av1_get_ext_tx_set_type` clamp
50+ (`if (!av1_ext_tx_used[tx_set_type][tx_type]) tx_type = DCT_DCT`), which we approximate
51+ with `side >= 32` instead of the real per-size/`reduced_tx_set` set membership.
52+ Next step: force `DCT_DCT` for the chroma INVERSE only (keep the class-1 eob/scan) and
53+ see whether the three blocks go exact — that separates basis from prediction in one run.
54+
55+## DEVIATION from the charter (named)
56+Charter item (4) says restore any refusal whose gate cannot go green. I did NOT restore
57+the GLOBALMV/WARPED_CAUSAL 8x8 refusals r1 removed, same reasons r2 gave (a refusal placed
58+before the code it guards makes that code dead, `refusal-short-circuits-its-own-code`, and
59+those refusals are not what fails: both gate streams now decode END TO END and only chroma
60+pixels differ). Reverting is one hunk of `refusal_inventory.rs` plus two `decode.rs`
61+deletions in `65ef3f5` if the orchestrator disagrees.
62+
63+## Instruments kept
64+`EC_WARP8` (per-leaf warp decision, under `EC_TRACE_MODE`), `tx=`/`class=` on the
65+`EC_COEFF_STEP tag=eob` line, and `EC_PROBE_DUMP=<path>` on `examples/decode_probe`
66+(raw 8-bit I420 dump for pixel diffing against ffmpeg without a test harness).
lanes/gmaffine-r5.report.mdadded+82 -0
@@ -0,0 +1,82 @@
1+# lane-gmaffine r5 — the 8x8-leaf chroma residue was the NARROW-BLOCK SHARP interp filter
2+
3+Commit on `lane-gmaffine`, on top of r4 (`f5e1851`). Suite (before the new unit test,
4+after the fix): `EC_AV1_REQUIRE_AOMENC=1 cargo test --release -p ec-av1 --lib -j3` →
5+**273 passed, 0 failed, 24 ignored** (r4: 271/2/24 — the two 8x8 motion gates are the
6+delta, both now green at 8-bit AND 10-bit).
7+
8+## Root cause (one line, one table entry)
9+`mc.rs:187` `InterpFilterKind::Sharp => (&SUBPEL_FILTERS_SHARP, &SUBPEL_FILTERS_SHARP)`.
10+Spec 7.11.3.4's `filterIdx`: a prediction block 4 or fewer samples wide/high reads
11+`Subpel_Filters[4]` — the REGULAR narrow kernel — for BOTH `EIGHTTAP` and
12+`EIGHTTAP_SHARP`; libaom agrees literally (`filter.h:239-245`,
13+`av1_interp_4tap[MULTITAP_SHARP] == av1_sub_pel_filters_4`). We used the 8-tap sharp
14+kernel on the narrow axis, and the old doc comment above `SUBPEL_FILTERS_SHARP` asserted
15+as fact that "spec 7.11.3.4 never swaps this for a narrow-block table" — false.
16+Invisible above 4 samples, so it could only ever bite the 4x4 chroma of an 8x8 (or
17+smaller) luma leaf: exactly the blocks r4 left red. Fixed to
18+`(&SUBPEL_FILTERS_SHARP, &SUBPEL_FILTERS_4)`; all three MC paths
19+(`predict_with_filters`, `predict_scaled`, `predict_compound_intermediate`) resolve
20+their kernels through `InterpFilterKind::tables()`, so this one entry is the whole
21+sweep — grep of `SUBPEL_FILTERS_SHARP|SUBPEL_FILTERS_4|SUBPEL_FILTERS_SMOOTH_4` finds
22+no other consumer.
23+
24+## The two charter experiments, both answered NEGATIVE before the real cause
25+Experiment 1 (chroma inverse forced to `DCT_DCT`): pixel error went from 3 chroma
26+blocks to 25 in frame 1 (u/v byte diffs 40/45 → 270/259, whole-clip 3585 → 27819) —
27+the inherited 1D types are right and used right.
28+Then the decisive instrument: `~/.cache/gmaffine-r5/inv.c`, a C harness linking the
29+oracle's `libaom.a` and calling `av1_inv_txfm2d_add_4x4_c` directly (needs
30+`av1_rtcd()`/`aom_dsp_rtcd()` first, else the txfm func pointers are NULL and it
31+segfaults). Every distinct 4x4 dequantized grid our decoder produced on the gate
32+stream — 1476 blocks, 16 distinct tx types incl. 246 `H_ADST` / 248 `H_DCT` /
33+59 `IDTX` — reproduces libaom's residual BIT-EXACT. The 4x4 inverse basis, the
34+identity scaling, the 1D-class scan and the nz ctx are therefore all exonerated;
35+so is Experiment 2 (the `ext_tx_used` clamp: this stream is `reduced_tx_set == 0`,
36+so the chroma 4x4 inter set is `EXT_TX_SET_ALL16`, which contains `H_ADST` — the
37+clamp is inert here; `side >= 32` stand-in left as-is, see residue).
38+With the transform exonerated the residual is right, so the error had to be the
39+chroma PREDICTION — one 4-sample-wide MC block.
40+
41+EVIDENCE: `/home/user/.cache/gmaffine-r5/{gm1_cq32.obu,ours.yuv,ref.yuv,f2.yuv,diff.py}`
42+| `gen.sh 32 1` reproduced the gate's own 8-bit cq32 stream twice, sha256
43+`22d09738baab612910c83106cb4fefe860ed20de1b2a01b36c5d3c717d5b18bc` both times (r4's
44+hash); `EC_PROBE_DUMP=… decode_probe gm1_cq32.obu` vs `ffmpeg -i … -pix_fmt yuv420p`
45+| before: 3585 differing bytes over 24 frames (luma 0, U/V only, first block chroma
46+(8,12) frame 1); after the one-entry fix: **0 differing bytes, all 24 frames, all 3
47+planes**.
48+
49+EVIDENCE: `/home/user/.cache/gmaffine-r5-suite.log` | `EC_AV1_REQUIRE_AOMENC=1
50+cargo test --release -p ec-av1 --lib -j3` | `test result: ok. 273 passed; 0 failed;
51+24 ignored` in 545s.
52+
53+EVIDENCE: same log + `cargo test … -- 8x8_leaf` | both lane gates run at 8-bit and
54+10-bit | `a_real_globalmv_8x8_leaf_stream_decodes_pixel_exact ... ok`,
55+`a_real_warped_causal_8x8_leaf_stream_decodes_pixel_exact ... ok`,
56+sibling `a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact ... ok`
57+(its 10-bit twin stays `#[ignore]`d from lane-inter8 r2, untouched by this round).
58+
59+## Refusals
60+The GLOBALMV / WARPED_CAUSAL 8x8-leaf refusals r1 removed are now PROVEN by two green
61+real-aomenc gates that hard-assert `globalmv_hits_8` / `warp_hits_8` at both depths —
62+the r4 deviation (not restoring them) resolves in favour of the lift. No further
63+`refusal_inventory.rs` / `gate_coverage.rs` edit was needed this round; both tests are
64+green (`refusal_inventory::tests::*` 5 passed).
65+
66+## Runnable check left
67+`mc.rs::tests::a_narrow_block_reads_the_regular_four_tap_kernel_under_every_sharpness`
68+pins the narrow kernel of all four `InterpFilterKind`s against spec 7.11.3.4.
69+Run: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-gmaffine EC_NOMEMGUARD=1 cargo test
70+--release -p ec-av1 --lib -- mc::tests` → 8 passed, 0 failed.
71+
72+## Residue
73+- `read_plane`'s `side >= 32` stand-in for `av1_get_ext_tx_set_type`'s
74+ `av1_ext_tx_used` membership — accepted for now: it is exact for every set this
75+ decoder currently reaches (`reduced_tx_set == 0` inter/intra at ≤16 is ALL16/INTRA_1,
76+ both of which contain every type the CDF can emit), and no gate can distinguish it
77+ until a `reduced_tx_set == 1` inter stream is gated. deferred(a `--reduced-tx-type-set=1`
78+ aomenc gate) — not a defect this round could measure.
79+- Instrumentation from this round was removed before commit (the `EC_EXP1`/`EC_EXP_DUMP`
80+ hooks in `decode.rs` and `EC_TX_DUMP` in `transform.rs`); the C oracle harness lives
81+ outside the repo at `~/.cache/gmaffine-r5/inv.c` and is worth keeping — it is the
82+ only instrument that can settle "is our inverse transform the defect?" in one run.
lanes/hidden-r2.report.mdadded+72 -0
@@ -0,0 +1,72 @@
1+# lane-hidden r2 — hidden-frame compare wired into the 15 alt-ref gates
2+
3+## What changed
4+- `crates/ec-av1/src/stream.rs` — 13 insertion sites, each **after** the gate's existing
5+ shown-frame `assert_eq!` loop, calling r1's `decode_all_frames_vs_oracle(&stream, NAME)`
6+ on the SAME stream bytes: every decode-order frame (hidden alt-refs included) byte-compared
7+ against the instrumented `aomdec`'s `EC_AV1_FINAL_DUMP`. No gate recipe was changed.
8+ Sites: `a_real_aomenc_single_ref_gate` (:4256, covers the last2/last3/bwdref/altref2/**altref**
9+ gates), reference_select :4493, compound_references :4694, obmc :4875, obmc_8x8 :5085,
10+ warped_motion :5270, interintra :5738, interintra_wedge :5937, free_partitions :6277,
11+ ab_partitions :6497, masked_compound :6722, cdef :7173, delta_q_and_delta_lf :9502.
12+- `crates/ec-av1/src/stream.rs:1745` — new `hidden_arnr_arm(name, y4m, args)`: the SECOND ARM.
13+ Re-encodes the gate's own fixture with the gate's own args **plus** `--arnr-maxframes=0`,
14+ runs the same decode-order compare, at most once per gate per process. A named
15+ ("unsupported") refusal on the arm's stream skips the arm; a pixel mismatch is a hard
16+ failure inside the compare. Called at the same 13 sites.
17+- `scripts/instrument-aom-oracle.sh` — **rung 13** (coordinator's extra item): lane-inter8 r3's
18+ hand patch of `~/.cache/aom-oracle/src/av1/decoder/decodemv.c` (an `EC_MODE_MV` line right
19+ after `assign_mv`, and `stack=<ref_mv_count[...]>` on rung 4's `EC_MODE_VAL`) existed only in
20+ the build tree; a script rebuild would have dropped it. Both are now script-applied,
21+ `EC_TRACE_MODE`-gated, idempotent.
22+
23+## Finding: every gate's own recipe is VACUOUS for hidden frames
24+`--auto-alt-ref=1 --lag-in-frames=16` does NOT put hidden frames on the wire — libaom's
25+temporal alt-ref filter absorbs the candidates. Across the whole suite the 15 gates decoded
26+**281 attempt-streams and saw 5 hidden frames in total**, 13 of the 16 gate names seeing zero.
27+Every gate claim of "hidden alt-refs included" is propagation only. `--arnr-maxframes=0` as a
28+second arm fixes it: 13 of 16 arms carry 1-3 hidden frames.
29+
30+| gate | attempts compared | hidden (own recipe) | ARM `--arnr-maxframes=0` | result |
31+|---|---|---|---|---|
32+| reference_select | 1 | 1 | 22 frames, **2 hidden** | pixel-exact |
33+| compound_references | 1 | 0 | 25 frames, **1 hidden** | pixel-exact |
34+| obmc | 1 | 0 | 25 frames, **1 hidden** | pixel-exact |
35+| obmc_8x8 | 0 (gate SKIPs: 74 attempts, 0 8x8-obmc hits) | — | — | not reached (pre-existing vacuity) |
36+| warped_motion | 40 | 2 (max 1/stream) | 25 frames, **1 hidden** | pixel-exact |
37+| interintra | 40 | 2 (max 1/stream) | 25 frames, **1 hidden** | pixel-exact |
38+| interintra_wedge | 40 | 0 | 25 frames, **1 hidden** | pixel-exact |
39+| free_partitions | 17 | 0 | 25 frames, **1 hidden** | pixel-exact |
40+| ab_partitions | 17 | 0 | 25 frames, **1 hidden** | pixel-exact |
41+| masked_compound | 80 | 0 | 27 frames, **3 hidden** | pixel-exact |
42+| cdef | 40 | 0 | 27 frames, **3 hidden** | pixel-exact |
43+| an_altref_reference | 1 | 0 | 17 frames, **1 hidden** | pixel-exact |
44+| delta_q_and_delta_lf | 40 | 0 | 27 frames, **3 hidden** | pixel-exact |
45+| a_bwdref_reference (bonus, same helper) | 1 | 0 | 18 frames, **2 hidden** | pixel-exact |
46+| an_altref2_reference (bonus) | 1 | 0 | 64 frames, 0 hidden | vacuous even with the arm |
47+| a_last2 / a_last3 (bonus, `--auto-alt-ref=0`) | 1 each | 0 | 8 frames, 0 hidden | vacuous by construction (no alt-ref) |
48+| gradients_with_cdef | n/a | n/a | n/a | single ffmpeg/libaom KEY frame, no alt-ref possible |
49+| a_golden_reference | n/a | n/a | n/a | `--lag-in-frames=0`, no alt-ref possible |
50+
51+**No hidden-frame mismatch was found.** Nothing is `#[ignore]`d, no assertion weakened,
52+no refusal touched (`refusal_inventory.rs` / `gate_coverage.rs` unchanged).
53+
54+## Commands
55+ cd /home/user/Documents/Code/Rust/edith_codecs-hidden
56+ export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-hidden
57+ EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -- --nocapture # table lines: grep HIDDEN
58+ bash scripts/instrument-aom-oracle.sh # rung 13 idempotent
59+
60+EVIDENCE: /tmp/.../scratchpad/hidden-r2-suite2.log | EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -- --nocapture (whole suite, 630.72s) | 273 passed, 0 failed, 22 ignored; 281 attempt-streams compared frame-by-frame in decode order, 5 hidden frames on the gates' own recipes, 16 HIDDEN-ARM lines with 21 hidden frames total, every frame pixel-exact
61+EVIDENCE: same log, HIDDEN-ARM lines | each gate's own args + --arnr-maxframes=0, re-encoded and decoded through decode_all_frames_vs_oracle | 13 of 16 arms carry 1-3 hidden frames; altref2/last2/last3 arms carry 0
62+EVIDENCE: /tmp/.../scratchpad/rung13/decodemv.c | pristine `git show HEAD:av1/decoder/decodemv.c` + the script's rung-4 then rung-13 python blocks | both probe regions diff-identical to the live hand-patched ~/.cache/aom-oracle/src copy (SAME_MV, SAME_VAL); second application prints "already applied (no-op)"; live aomdec `strings` contains 3 EC_MODE_MV/stack=%d entries
63+
64+## Residue
65+- fix-now: none — no defect surfaced.
66+- deferred: obmc_8x8's hidden compare is unreached because that gate itself never fires an 8x8
67+ OBMC block (74 attempts, 0 hits) — pre-existing vacuity owned by the OBMC lane; unblocked by a
68+ recipe that actually codes 8x8 OBMC.
69+- deferred: `an_altref2_reference` still shows 0 hidden even with the arm (64-frame clip);
70+ unblocked by a recipe search like the one lanes/altref2-r1.report.md ran for ALTREF2 firing.
71+- accepted: the arm runs once per gate per process (a full encode + two decodes per arm); the
72+ gates' own per-attempt sweeps still get the (mostly hidden-free) compare on every attempt.
lanes/inter8-r3.report.mdadded+138 -0
@@ -0,0 +1,138 @@
1+# lane-inter8 r3 -- the 10-bit twin localized, and the mi-band tile audit
2+
3+Branch `lane-inter8`, on top of r2's `12809b2`. This report covers r3 only;
4+`lanes/inter8-r2.report.md` is untouched.
5+
6+## 1. Gate state
7+
8+- `a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact`
9+ (8-bit): **GREEN**, un-ignored (r2). Re-run this round, still green.
10+- `a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_decodes_pixel_exact`:
11+ **still RED**, stays `#[ignore]`d. Localized this round (section 2); the
12+ root cause is a symbol lane-gmaffine r3 owns, so it is NOT fixed here.
13+- `a_real_aomenc_inter_sequence_with_an_8x8_leaf_split_across_tile_columns_decodes_pixel_exact`:
14+ NEW this round (`--tile-columns=1`, 128x64). **RED for a reason outside this
15+ lane** and `#[ignore]`d with that reason in the attribute: at 128x64 aomenc
16+ codes an SB-level rect partition on the KEY frame despite
17+ `--enable-rect-partitions=0`, so the stream stops at "a superblock-level
18+ partition type other than NONE or SPLIT" (lane-sbpart's arm) before any 8x8
19+ leaf is reached. 64x64 -- the only width the recipe decodes -- is one
20+ superblock wide, so two tile columns cannot exist there.
21+
22+Gate-helper audit (class *counter-from-refused-stream*): `inter_sb_none_gate`
23+(`crates/ec-av1/src/stream.rs:2774`) is single-attempt -- `before = hits()` is
24+taken immediately before the one `decode_stream` call, a refusal panics with a
25+pinned stream, a pixel mismatch panics. No global-delta-over-many-attempts
26+shape, nothing to fix.
27+
28+## 2. The 10-bit twin: first divergent element
29+
30+The refusal ("an INTER 32x32 partition type this decoder does not code
31+(value=9)") is downstream noise; the real divergence is 15 elements earlier.
32+
33+Ladder (ours `EC_TRACE_MODE` via `decode_probe` vs instrumented aomdec
34+`EC_TRACE_MODE`), 64x64 mandelbrot, cq40 cpu0, `--min-partition-size=8
35+--max-partition-size=16`, `--bit-depth=10`:
36+
37+- 8-bit stream: **57/57** `EC_MODE` lines agree (r2's claim re-measured).
38+- 10-bit stream: **41/57**. First divergence at the ENTRY of the next block
39+ after the 8x8 leaf `mi=(4,14)`: ours `rng=57758`, aomdec `rng=52508`.
40+
41+Element-level, on leaf `(4,14)` (a compound `NEW_NEARESTMV`, ref0=1 ref1=4):
42+
43+| point | ours | aomdec |
44+|---|---|---|
45+| entry (`EC_MODE`) | 37004 | 37004 |
46+| after mode + DRL + mv (`EC_MODE_VAL` ours / `EC_MODE_MV` oracle) | **57308** | **57308** |
47+| end of mode info (`EC_MODE_VAL` oracle) | -- | 58952 |
48+| next block entry | 57758 | 52508 |
49+
50+Values agree everywhere (mode=20, ref0=1, ref1=4, mv0=(0,-9), mv-stack size 2
51+on both sides). So: the mv-stack, the DRL count and the mv reads of the 8x8
52+leaf are **exact**; the divergence is entirely in the leaf's **post-mv mode
53+info**, where aomdec's range moves 57308 -> 58952 and ours does not move the
54+same way.
55+
56+The only symbol aomdec reads there for a compound 8x8 leaf is
57+`read_mb_interp_filter` (interintra is single-ref-only, motion_mode is not
58+read for compound). `decode.rs:11181` says it outright: *"`decode_inter_block8`
59+never resolves a switchable filter"* -- the leaf hardcodes `Regular` and reads
60+no filter symbol. That is a **symbol-consumption gap** (memory class), and per
61+the coordinator it is lane-gmaffine r3's to fix (it owns the real leaf interp
62+read and is merging ae69b25). fix-now, owner lane-gmaffine.
63+
64+Two instruments were added to get here and are kept:
65+- ours: `EC_MODE_VAL` in `decode_inter_block8`'s compound arm (`decode.rs`
66+ ~11049), byte-format-identical to the oracle's rung-4 line.
67+- oracle: `EC_MODE_MV` in `~/.cache/aom-oracle/src/av1/decoder/decodemv.c`
68+ right after `assign_mv`, plus `stack=%d` (`dcb->ref_mv_count[...]`) on
69+ `EC_MODE_VAL`. **These two oracle patches are NOT in
70+ `scripts/instrument-aom-oracle.sh`** -- a rebuild of the oracle from the
71+ script drops them. deferred(a 3-line append to that script; the aomdec
72+ binary in `~/.cache/aom-oracle/build` currently has them).
73+
74+## 3. Tile-relative guard audit (lane-sub8 verifier's class warning)
75+
76+Checked every reader/writer of the mi-granular inter bands added in r2
77+(`record_inter_rect_mi` `decode.rs:2300`, `record_compound_ctx_rect_mi`
78+`decode.rs:2389`, and the `above_side_mi`/`left_side_mi`/`above_skip`/
79+`left_skip`/`*_inter`/`*_ref`/`*_ref1`/`*_comp_group_idx`/`*_compound_idx`
80+readers):
81+
82+- **Guards are tile-relative.** `grep -n 'mi_r > 0\|mi_c > 0\|leaf_mi.0 > 0\|leaf_mi.1 > 0' decode.rs`
83+ returns **zero hits**; the leaf uses
84+ `leaf_mi.0 > neighbours.tile_row0_mi` / `leaf_mi.1 > neighbours.tile_col0_mi`
85+ (`decode.rs:10908`).
86+- **Above bands reset per tile.** `start_tile` (`decode.rs:1958`) clears
87+ `above_side_mi` and, from r2, every mi-granular above inter band over
88+ `col0_mi..col1_mi`.
89+- **Left bands reset per SB row.** `start_row` (`decode.rs:2229`) clears
90+ `left_side_mi`, `left_skip`, `left_skip_mode`, `left_inter`, `left_ref`,
91+ `left_ref1`, `left_comp_group_idx`, ... unconditionally.
92+
93+So the lane-sub8 defect shape is not present here. The runtime arm that would
94+have proven it is the `across_tile_columns` gate above, blocked by an unrelated
95+refusal -- stated as inspection-only, not claimed as exercised.
96+
97+## 4. Remaining alphabet -- named next slices
98+
99+- `fix-now (lane-gmaffine r3)`: the 8x8 leaf's switchable interp filter read;
100+ it is the 10-bit twin's first divergent element and un-ignores that gate.
101+- `deferred(lane-sbpart's SB-level rect arm)`: the `--tile-columns=1` runtime
102+ proof of the mi bands, and with it any multi-tile inter gate.
103+- `deferred(rect inter MC + rect transforms below 16x16; lane-rectx owns the
104+ transform half)`: 16x8/8x16 rect inter leaves at the 16x16 level -- the
105+ refusal r1 narrowed to ("... other than SPLIT") still stands.
106+- `deferred(the above)`: 8x8 HORZ/VERT -> 8x4/4x8 leaves. Needs 4x8/8x4 luma
107+ and 4x4 chroma transforms plus a 4-wide MC path; strictly after the 16x8/8x16
108+ rect leaves.
109+- `deferred(unstarted)`: AB (HORZ_A/B, VERT_A/B) and 1-to-4 (HORZ_4/VERT_4)
110+ inter arms at 64/32/16. aomenc emits them even with the flags off, so these
111+ are the dominant remaining inter refusals, but each needs its own transform
112+ set (a 64x16 strip needs TX_64X16 -- see the ledger's lane-part32 r5 line).
113+- `accepted`: the aggregate per-type-per-level inter hit-counter gate. Every
114+ arm above is refused, so the counter would assert nothing new.
115+
116+## EVIDENCE
117+
118+EVIDENCE: scratchpad s8.obu sha256 344566f8...8802 / s10.obu sha256 f1a53394...20ce | aomenc 64x64 mandelbrot 4f cq40 cpu0 min=8 max=16 (8- and 10-bit), decoded by ours (EC_TRACE_MODE, decode_probe) and by instrumented aomdec (EC_TRACE_MODE) | EC_MODE range ladders: 8-bit 57/57 agree, 10-bit 41/57, first divergence at the block AFTER leaf mi=(4,14)
119+EVIDENCE: same two traces | aomdec patched with EC_MODE_MV (post-assign_mv) + stack= on EC_MODE_VAL, rebuilt (cmake --build . --target aomdec) | leaf (4,14): entry 37004==37004, post-mv 57308==57308, mode/refs/mv0/stack all equal -- divergence is strictly after the mv, in the post-mv mode info aomdec ends at rng 58952
120+EVIDENCE: cargo test -p ec-av1 --lib -- 8x8_leaf_split (EC_AV1_REQUIRE_AOMENC=1) | 8-bit gate re-run | 1 passed, 10-bit + tile-columns ignored with their reasons
121+
122+Suite totals, `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib` on 889ca3c:
123+**270 passed, 0 failed, 25 ignored** (r2 was 270/0/24; the +1 ignored is the new
124+`across_tile_columns` arm). `refusal_inventory` and `gate_coverage` are in that
125+green set; no refusal was lifted or narrowed this round, so neither needed an
126+edit.
127+
128+## 5. Two candidate causes ABLATED (neither is it)
129+
130+- lane-gmaffine `f5e1851` (14 TxbSet arms missing the eob_pt class-1 CDF row):
131+ applied to this branch's `cdf.rs`/`cdf_state.rs` and re-measured -- the 10-bit
132+ ladder stays **41/57**, byte-identical divergence at the same element. Not
133+ this stream's cause; the hunks were reverted so they reach main once through
134+ lane-gmaffine.
135+- lane-gmaffine `0b8cb54` (leaf single_ref / interp-filter neighbour contexts
136+ still read at SUB indices) cherry-picks with a conflict in `decode.rs`, so it
137+ is left to lane-gmaffine, which already merged `ae69b25`. It touches exactly
138+ the post-mv window this round pinned, and is the standing candidate.
lanes/rectsplit-r4.report.mdadded+97 -0
@@ -0,0 +1,97 @@
1+# lane-rectsplit r4 — SB-level split-transform strips: TWO root causes, refusal lifted
2+
3+Branch `lane-rectsplit` off `4c3389a` (r3's safe state). No rebase needed: `main` is still
4+`3808cf8`, the branch's merge base.
5+
6+## Headline
7+
8+r3's four-way table was not a contradiction — it was two defects stacked, the first hiding
9+the second behind a refusal:
10+
11+1. **`base_ctx` read the rect `av1_nz_map_ctx_offset` tables transposed.** libaom indexes
12+ them by its own `coeff_idx`, and `get_nz_map_ctx_from_stats` decomposes that as
13+ `col = coeff_idx >> bhl`, `bhl` = log2 of the *adjusted* height (5 for both `TX_64X32`
14+ and `TX_32X64`): `coeff_idx = col * 32 + row`, so 32 consecutive flat entries are one
15+ COLUMN and the `cdf.rs` 5x5 transcriptions are `[col][row]`. `decode.rs:1162` read them
16+ `[row][col]` = the transpose = the other shape's rule with 11 and 16 swapped.
17+ Fixed by stating libaom's generating rule (`txb_common.h:199-209`) once, exactly as
18+ `base_ctx_rect` already did, instead of indexing the tables at all.
19+2. **`EOB_PT_512_CHROMA` was transcribed from the wrong row of
20+ `av1_default_eob_multi512_cdfs[q][plane][2]`.** The last index is `eob_multi_ctx`
21+ (0 = `TX_CLASS_2D`, 1 = `V_DCT`/`H_DCT`), not a q-context: the flat
22+ `3277, 6554, ...` distribution our table held is the 1D-class row, identical for both
23+ planes at every q, and the real chroma 2D row has four q-context variants like every
24+ other coefficient table. The FIRST real 32x16 chroma transform read `eob_pt` 7 where
25+ aomdec read 2 — that is what made seed 43 RED once defect 1 was fixed. Under r3's
26+ shipped code seed 43 never reached it: it desynced 13 elements EARLIER and exited
27+ through a named refusal, which the gate counts as a pass (class `refusal-hides-a-defect`).
28+
29+## Changed
30+
31+- `crates/ec-av1/src/decode.rs:1162` `base_ctx` — the `TX_CLASS_2D` rect arm now applies
32+ libaom's generating rule (`row < 2 -> 11` when w<h, `col < 2 -> 16` when w>h, else the
33+ square table), no transposable table read left.
34+- `crates/ec-av1/src/cdf.rs:269` — `EOB_PT_512_CHROMA` corrected to the 2D chroma row plus
35+ new `_Q0`/`_Q1`/`_Q3` siblings; `cdf_state.rs:1015` now `pick()`s by q-context.
36+- `crates/ec-av1/src/decode.rs:4102` `decode_block_rect64` — the split-transform refusal is
37+ LIFTED, wired to `decode_rect_split` (r1's per-unit port), `RECT_PARTITION_HITS` bumped.
38+- `crates/ec-av1/src/decode.rs:3428` `decode_rect_split` — records `RECT64_QIDX_DRIFT_HITS`
39+ for 64-level strips, which now reach this path.
40+- `crates/ec-av1/src/refusal_inventory.rs:49` — refusal string removed.
41+- `crates/ec-av1/src/stream.rs:9778` — gate (b) un-`#[ignore]`d, its doc records both causes.
42+- Instruments kept: `read_coeffs`/`read_coeffs_rect` print an `EC_COEFF_STEP` ladder under
43+ `EC_TRACE_COEFF` in instrumented-aomdec format, with `pos` converted to libaom's
44+ column-major `coeff_idx` so the two ladders `diff` line by line.
45+- New unit test `decode::tests::base_ctx_rect_offsets_match_the_transcribed_tables_over_the_whole_domain`
46+ — evaluates `base_ctx` over the WHOLE 5x5 domain of 64x32 / 32x64 / square against
47+ `table[col][row]` (class `enumerate-table-domain`).
48+
49+## Refusals lifted
50+
51+- `"a superblock-level HORZ/VERT strip with a split transform (per-unit rect prediction is not ported)"`
52+ — with `a_real_aomenc_stream_with_a_split_transform_superblock_strip_decodes_pixel_exact`
53+ green, hard-asserting `rect_split_sb_interior_tu_hits` (SB-level AND tx depth >= 2) sampled
54+ per compared attempt.
55+
56+## Gates and evidence
57+
58+EVIDENCE: msac range ladders `scratchpad/n_ours43.txt` vs `scratchpad/n_aom43.txt` | `EC_TRACE_COEFF=1 decode_probe seed43.obu` vs `EC_TRACE_COEFF=1 aomdec` on the gate-dumped seed-43 stream | first divergent element = the chroma `eob` of the 64x32 strip at mi (0,16): ours `eob_pt` group 8 (eob 103), aomdec group 3 (eob 3), at identical range 44680 — i.e. a CDF-content defect, not a context one
59+EVIDENCE: `scratchpad/r4_ours43.yuv` vs `scratchpad/r4_aom43.yuv` | `decode_probe seed43.obu out.yuv`; `aomdec --rawvideo` | `cmp` byte-identical (was: frame-0 luma mismatch)
60+EVIDENCE: `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3 -- --test-threads=1 --include-ignored superblock_level_horz_vert_partition split_transform_horz_vert_strip filter_intra_on_a_horz split_transform_superblock_strip refusal_inventory gate_coverage nz_map` | gates (a) (b) (c) + merged SB HORZ/VERT + inventory/coverage/table tests | 10 passed, 1 failed (81.41s) — the failure is the already-`#[ignore]`d `..._and_delta_q_...` gate, which fails its own drift counter, not a pixel compare (27/40 pixel-exact, 13 named refusals)
61+EVIDENCE: third leg from lane-tx64x16 — `scratchpad` sweep seeds 42..81, 192x128 gradients, merged-gate recipe with `--min-partition-size=16 --enable-1to4-partitions=1` | encode with the oracle aomenc, `decode_probe` vs `aomdec --rawvideo`, `cmp` | 33 EXACT, 7 named refusals (6x SB-level AB partition, 1x screen-content strip), 0 mismatches — seed 55 (reported 3944 wrong luma samples, first at (154,59)) is now byte-exact
62+EVIDENCE: full `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3` | whole crate lib | **272 passed, 0 failed, 23 ignored**, 490.90s (r3's expectation was 270/0/24; +1 un-ignored gate, +1 new unit test)
63+
64+## Film check (ReelB, the lane's critical path)
65+
66+`decode_probe` on the coordinator's mid-film extract (`ffmpeg -ss 600 -t 0.5 ... -f obu`,
67+11.5 MB, 10-bit 2160p, `.../cdc46329-.../scratchpad/reelb5.obu`), which stopped at exactly this
68+lane's refusal on main:
69+
70+```
71+before (main 06d856d): REFUSED: a superblock-level HORZ/VERT strip with a split transform ...
72+after (this branch): REFUSED: AV1 tile (a 32x32 partition type this decoder does not code (value=8))
73+```
74+
75+EVIDENCE: `.../cdc46329-.../scratchpad/reelb5.obu` | `cargo run -p ec-av1 --example decode_probe` on `lane-rectsplit` r4 | the film advances past this lane's refusal to `PARTITION_HORZ_4` (value 8), a 1:4-partition gap owned by lane-part32/tx64x16
76+
77+## Sibling sweep (defect class)
78+
79+- Class `table-transcribed-from-the-wrong-row-of-a-multi-dimensional-default`: every other
80+ coefficient CDF in `Cdfs::new` already goes through `pick(q_ctx, ...)`; a grep of
81+ `cdf.rs` for libaom's flat 1D rows (`3277, 6554` / `2979, 5958` / ...) finds no second
82+ instance. `EOB_PT_512_CHROMA` was the only coefficient table initialised without `pick`.
83+- Class `reference-layout-not-spec` (transposed table): the only other rect offset consumer,
84+ `base_ctx_rect`, already stated the rule and is unchanged; the new domain test covers both.
85+
86+## Residue
87+
88+- deferred(lane-part32 / lane-tx64x16 — 1:4 partitions): both films and 7/40 seeds of the
89+ third-leg sweep now stop at `PARTITION_HORZ_4/VERT_4` or SB-level AB partitions.
90+- deferred(lane-rect64q): `a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_and_delta_q_decodes_pixel_exact`
91+ stays `#[ignore]`d as r3 left it — its 40 attempts pixel-match (27 compared, 13 named
92+ refusals) but `deltaq-mode=1` never drifts `CURRENT_Q_IDX` inside a 64-level strip in
93+ that recipe. r4 added the missing counter bump on the split path; the gate still needs a
94+ recipe that actually drifts.
95+- accepted: the third-leg recipe (`--min-partition-size=16 --enable-1to4-partitions=1`) is
96+ measured here but NOT added as a gate arm — its remaining refusals are 1:4/AB partitions
97+ owned by other lanes, so the arm would be RED for reasons outside this lane.
lanes/scaledref-r1.report.mdadded+115 -0
@@ -0,0 +1,115 @@
1+# lane-scaledref r1 — scaled-reference (superres) MC beyond single-ref, plus the Golomb tail
2+
3+Branch `lane-scaledref`, off main `3808cf8`. Round 1 continues the previous
4+builder's uncommitted state (preserved as `95b3e70`) — that snapshot is
5+verified, gated and kept; everything below r1 adds is on top of it.
6+
7+## What changed
8+
9+| path:line | why |
10+| --- | --- |
11+| `crates/ec-av1/src/mc.rs:474` `horizontal_scaled_pass` | spec 7.11.3.3's horizontal walk factored out of `predict_scaled` and given to `predict_compound_intermediate` (new `x_scale_fp` param), so each compound tap scales off its OWN reference's luma width |
12+| `crates/ec-av1/src/decode.rs` (compound branch, ~9470) | the "compound-reference block with a scaled reference" refusal replaced by two independent `mc::scale_factor` values threaded into all 6 compound MC calls (Y/U/V x 2 taps) |
13+| `crates/ec-av1/src/decode.rs` `obmc_neighbour_pred` / `obmc_blend` | each OBMC neighbour is re-predicted through the scaled walk against **its own** reference's scale (`frame_width` threaded in) |
14+| `crates/ec-av1/src/decode.rs` (~10170) | warp under a scaled reference: libaom `allow_warp` (reconinter.c:41) suppresses local AND global warp and predicts translationally; that suppression is implemented, but the case is still refused by name (see residue) |
15+| `crates/ec-av1/src/decode.rs` `decode_inter_block8` | single-ref/compound/OBMC MC of the 8x8 leaf threaded for a scaled reference (`frame_width` param) |
16+| `crates/ec-av1/src/decode.rs` `read_golomb` (~1349) | **r1**: lift implemented, then REVERTED (`abec872`) -- it exposed a hidden defect, see below. Only a comment recording the finding + repro remains |
17+| `crates/ec-av1/src/decode.rs` `obmc_mask` + `obmc_blend` | **r1**: `obmc_mask_2 = {45,64}` added and one-sided chroma OBMC for an 8x8 luma block (`av1_skip_u4x4_pred_in_obmc`, reconinter.c:820, `DISABLE_CHROMA_U8X8_OBMC == 0` ⇒ chroma skipped in the ABOVE pass, kept in the LEFT pass). Before this, the first real 8x8 OBMC block hit `unreachable!` in `obmc_mask` |
18+| `crates/ec-av1/src/stream.rs` | the gate below |
19+| `crates/ec-av1/src/refusal_inventory.rs` | 2 refusal strings gone (compound-scaled; OBMC/interintra-scaled folded into a warp-only string); 47 → 45 |
20+
21+## Gates
22+
23+1. `stream::tests::a_real_aomenc_superres_stream_with_compound_obmc_and_interintra_decodes_pixel_exact`
24+ — real `aomenc --superres-mode=1 --superres-denominator=16 --superres-kf-denominator=16
25+ --auto-alt-ref=1 --lag-in-frames=25 --enable-obmc=1 --enable-interintra-comp=1
26+ --enable-smooth-interintra=1`, 12 seeds x 24 frames of 64x64 moving gradients, every SHOWN frame
27+ compared to ffmpeg (corrected in r2: `decode_stream` pushes a picture only under
28+ `show_frame`, stream.rs:711, and `ffmpeg -f obu` emits shown frames only -- a hidden
29+ alt-ref is checked only through propagation into the frames that reference it).
30+ Hard-asserts `mc::predict_scaled_hits() > 0` and the per-case counters
31+ `scaled_compound/scaled_obmc/scaled_interintra > 0`.
32+
33+ `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib a_real_aomenc_superres_stream_with_compound -- --nocapture`
34+
35+ EVIDENCE: /tmp/.../scratchpad/gate1.log | aomenc superres d=16 + compound/OBMC/interintra, 12 seeds x 24 frames decoded and compared to ffmpeg | 12/12 pixel-exact, 0 refusals, superres_hits=291 predict_scaled_hits=3198 scaled_compound=500 scaled_obmc=9 scaled_interintra=1
36+
37+2. (withdrawn) `decode::tests::golomb_tails_read_back_past_the_old_twenty_bit_cap` — written, passing,
38+ and reverted with the change it gated. See "The Golomb tail" below.
39+
40+## Refusals lifted (2)
41+
42+- "a compound-reference block with a scaled reference (superres, unimplemented)" — gate 1, 500 hits.
43+- "warp/OBMC/interintra prediction with a scaled reference (superres, unimplemented)" — narrowed to
44+ "warp prediction with a scaled reference"; OBMC (9 hits) and interintra (1 hit) proven by gate 1.
45+
46+`refusal_inventory` and `gate_coverage` tests green.
47+
48+## The Golomb tail — a refusal that is masking a real defect (finding, fix-now for its owner)
49+
50+Implemented as charted (`ee1f980`): read up to 32 leading zeros (dav1d's `len < 32`) instead of
51+erroring at 20, u64 accumulator, plus a round-trip gate over every prefix length 0..=31 through
52+`tile::write_golomb`. Bit-identical for every tail an encoder writes — our own writer tops out at 19
53+leading zeros (`tile::MAX_LEVEL == MAX_BR_LEVEL + (1 << 19)`), and libaom errors long before.
54+
55+It still turned a green gate RED:
56+`a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact` failed at
57+**seed 67, frame 0 luma**. Bisected against main `3808cf8` and against the lane's own WIP `95b3e70`
58+(both pass), and main's run prints, for that very seed:
59+`seed 67 refusal: unsupported: AV1 tile (a Golomb tail longer than this decoder reads)`.
60+
61+So the cap is not a capability limit — it is the point where an intra rect64 stream that has ALREADY
62+desynced first asks for something impossible (a key-frame coefficient level above `1 << 19`).
63+Class `refusal-hides-a-defect`. Reverted in `abec872`; `d8788fb` records the finding, the repro and
64+"lift this together with that defect's fix" at the cap itself.
65+
66+EVIDENCE: cargo test output, this report | ran the rect64 gate at 3808cf8 / 95b3e70 / lane HEAD with and without the lift | pass / pass / FAIL seed 67 frame 0 luma; main prints the Golomb refusal for seed 67
67+
68+fix-now for the intra rect64 owner: encode that gate's seed-67 fixture, raise the cap locally, and
69+bisect the first mismatching block — the long tail is a downstream symptom, not the defect.
70+
71+## Test scope actually run
72+
73+- `cargo test -p ec-av1 --lib a_real_aomenc_superres_stream_with_compound` → 1 passed, 0 failed.
74+- `cargo test -p ec-av1 --lib a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes`
75+ → 1 passed, 0 failed (this is the gate the Golomb lift turned red; green again after the revert).
76+- `cargo test -p ec-av1 --lib refusal_inventory` → 3 passed; `... gate_coverage` → 2 passed.
77+- `cargo test -p ec-av1 --lib golomb` → 3 passed (at ee1f980, before the revert).
78+- `cargo test -p ec-av1 --lib` (whole crate lib suite, at the final tree): **268 passed, 0 failed,
79+ 23 ignored**, 928s. An earlier run of the same suite, taken with the Golomb cap raised, failed
80+ exactly one test -- the seed-67 rect64 gate above -- which is what put that finding on the board.
81+
82+## Residue
83+
84+- fix-now → **not** done, deferred: **warp under a scaled reference** stays refused. The libaom
85+ `allow_warp` fallback is implemented (warp suppressed, translational prediction used) but the
86+ previous builder's `--enable-warped-motion=1 --superres-denominator=16` seed-47 stream still
87+ mismatched ffmpeg at frame 2 luma. Shipping the lift would be wrong pixels behind a green name.
88+ deferred: warp+superres — unblocked by bisecting that stream (set `EC_SCALEDREF_WARP=1` on gate 1
89+ to reproduce; `EC_AV1_GATE_DUMP=<path>` pins the mismatching stream).
90+- deferred: **8x8 partition leaf under a scaled reference** — the leaf's MC *is* threaded for
91+ scaling, but no aomenc recipe produces a firing, decodable fixture. r1 measured this instead of
92+ assuming it: with `--min-partition-size=8` and a 64x**72** fixture (bottom 16-row band straddles
93+ the true edge, which is the only way this decoder reaches `decode_inter_block8`), aomenc does emit
94+ 8x8 leaves — and the decode **desyncs inside the leaf** (`from_switchable_symbol` handed a 4th
95+ symbol, mc.rs:200), which is the same below-8x8 desync lane-sub8 r2 left open and has nothing to do
96+ with scaling. Refusal restored with that fact in the comment; deleting those six lines is the whole
97+ lift once the leaf8 desync is fixed. — unblocked by the lane-sub8 leaf8 desync.
98+ That experiment did produce one real fix, kept: `obmc_mask(2)` + one-sided chroma OBMC (above).
99+- deferred: **"a reference picture whose height does not match this frame's own true size"** — not
100+ attempted. Superres never scales height, so a height-mismatched reference can only come from
101+ `--resize-mode` (reference scaling in BOTH axes). That needs a vertical counterpart to
102+ `horizontal_scaled_pass` (per-row `y_step_qn`, `im_h` intermediate rows, libaom
103+ `convolve_2d_scale`) *and* a gate whose frame size changes mid-stream. — unblocked by a lane sized
104+ for resize-mode.
105+- accepted: **10-bit not covered.** `Picture` planes are `Vec<u8>`; 10-bit input is refused before
106+ any of this code runs (see memory `his-av1-library-is-10-bit`, lane-hbd10). The 8/10-bit half of
107+ the charter's gate line is unreachable from this lane.
108+- Reported conflict, not silently resolved (charter premise): the charter states the spec's `read_golomb` caps at 32
109+ leading zeros. Locally verifiable sources disagree — libaom `read_golomb` (decodetxb.c:30) calls a
110+ 21st prefix bit a CORRUPT FRAME, which is exactly what the old refusal mirrored; dav1d reads up to
111+ 32. There is no AV1 spec copy on this box and the network is unreachable from the sandbox
112+ (`curl https://aomediacodec.github.io/av1-spec/av1-spec.html` timed out), so the change follows the
113+ permissive decoder (dav1d) and is bit-identical to the old reader for every tail any encoder writes.
114+- Off the film path: neither of the user's two films uses superres (lane-hbd10), so nothing here moves
115+ their decode. The Golomb and OBMC-mask fixes are generic.
lanes/scaledref-r2.report.mdadded+85 -0
@@ -0,0 +1,85 @@
1+# lane-scaledref r2 — warp-capable frame under a scaled reference read the wrong motion_mode alphabet
2+
3+Branch `lane-scaledref` (HEAD back on the branch: the verifier left the worktree detached at
4+a8111dd; `git checkout lane-scaledref` restored it, both were the same commit, no work lost).
5+
6+## Verifier finding 1 — ROOT CAUSE FOUND AND FIXED (no refusal needed)
7+
8+The verifier's premise was that "motion_mode symbol reading is unaffected; only the prediction
9+falls back". That is **false**, and it is the whole defect. libaom
10+`motion_mode_allowed` (oracle source `av1/common/blockd.h:1484-1487`):
11+
12+```c
13+ if (mbmi->num_proj_ref >= 1 && allow_warped_motion &&
14+ !xd->cur_frame_force_integer_mv &&
15+ !av1_is_scaled(xd->block_ref_scale_factors[0])) {
16+ return WARPED_CAUSAL;
17+ }
18+ return OBMC_CAUSAL;
19+```
20+
21+Under a scaled reference the block reads the **2-symbol `obmc_cdf`**, never the 3-symbol
22+`motion_mode_cdf`. We read the 3-symbol one, which narrows the arithmetic decoder by the wrong
23+amount: the decoded *value* happened to stay SIMPLE_TRANSLATION, so nothing ever errored — the
24+stream decoded "OK: 24 frames" with quietly wrong pixels, exactly the silent-wrong-pixels class
25+the verifier caught. The warp guard at decode.rs ~10197 could never see it: `warp_params` is
26+`None` for those blocks (`warped=0` in EC_AV1_TRACE), so no fallback and no refusal ran.
27+
28+| path:line | why |
29+| --- | --- |
30+| `crates/ec-av1/src/decode.rs` ~10060 (`warp_eligible`) | `&& !ref_is_scaled` added (`mc::scale_factor(py_ref.width, frame_width) != REF_NO_SCALE`), libaom-exact; new `SCALED_WARP_SUPPRESSED_HITS` counts the blocks that take the `obmc_cdf` arm because of it |
31+| `crates/ec-av1/src/decode.rs` ~630 | the counter + `scaled_warp_suppressed_hits()` / `mixed_scale_compound_hits()` accessors |
32+| `crates/ec-av1/src/decode.rs` ~9515 | `MIXED_SCALE_COMPOUND_HITS`: compound blocks with exactly one scaled tap (diagnostic for finding 3) |
33+| `crates/ec-av1/src/decode.rs` ~11455 (`decode_inter_block8`) | sibling site of the same shape, comment only: an 8x8 leaf under a scaled reference is refused before this code runs, so the same `&& !ref_is_scaled` is owed by whoever lifts that refusal |
34+| `crates/ec-av1/src/stream.rs` (superres gate) | `--enable-warped-motion=1` is now the DEFAULT arm (`EC_SCALEDREF_WARP=0` only for bisecting), `--superres-mode` made settable (`EC_SCALEDREF_MODE`), and `scaled_warp_suppressed_hits() > 0` is hard-asserted so the warp arm cannot pass vacuously |
35+| `crates/ec-av1/examples/decode_probe.rs` | `EC_PROBE_OUT=<path>` dumps the decoded planes as raw yuv420p — that is the instrument that located this defect (diff vs `ffmpeg -f obu`) |
36+| `lanes/scaledref-r1.report.md` | finding 2, wording corrected (below) |
37+
38+Not changed, reported instead of silently fixed: libaom also requires `!cur_frame_force_integer_mv`
39+in that same condition and our `warp_eligible` still omits it. Left alone this round — no gate
40+covers `force_integer_mv` (screen content), and changing an alphabet choice without a gate is the
41+mistake this round is fixing. deferred: force_integer_mv warp eligibility — unblocked by a
42+screen-content gate with `cur_frame_force_integer_mv=1`.
43+
44+Refusals: **none lifted, none added**, 45 unchanged. `refusal_inventory` / `gate_coverage`
45+untouched and green (see totals). The "warp prediction with a scaled reference" refusal stays: it
46+now only guards a *global*-warp block under a scaled reference, which this recipe never produced
47+(`scaled_warp_fallback=0`).
48+
49+EVIDENCE: /tmp/.../scratchpad/warp_superres.obu + ours2.yuv vs ff.yuv | EC_PROBE_OUT decode of the verifier's pinned stream, byte-compared to `ffmpeg -f obu -pix_fmt yuv420p -f rawvideo` | before: frames 1..23 differ (frame 1: 1342 luma + 370 chroma pixels, first at (2,26), max |d| 3, growing to 18 by frame 23); after the fix: `cmp` identical, 147456/147456 bytes
50+
51+EVIDENCE: gate run, this report | `EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib a_real_aomenc_superres_stream_with_compound -- --nocapture` (warp now on by default) | `0 other-capability refusals, 12/12 pixel-exact, superres_hits=291 predict_scaled_hits=3198 scaled_compound=500 scaled_warp_fallback=0 scaled_obmc=9 scaled_interintra=1 scaled_block8=0 scaled_warp_suppressed=25 mixed_scale_compound=0` — 25 blocks took the `obmc_cdf` arm only because of this fix
52+
53+## Verifier finding 2 — report correction (done)
54+
55+`lanes/scaledref-r1.report.md` line ~27 now reads "every SHOWN frame compared to ffmpeg ... a
56+hidden alt-ref is checked only through propagation" (ledger already records
57+`decode_stream` pushes only under `show_frame`, stream.rs:711).
58+
59+## Verifier finding 3 — mixed scaled/unscaled compound taps: DEFERRED, measured not assumed
60+
61+Counter `mixed_scale_compound` added and wired into the gate's print; both alternative recipes were
62+run, neither yields a gateable stream:
63+
64+- `EC_SCALEDREF_MODE=3` (qthresh): aomenc never turns superres on for this content/q —
65+ `superres_hits=0 predict_scaled_hits=0`, i.e. the whole gate goes vacuous (it fails its own
66+ `predict_scaled_hits > 0` assert, which is the assert working).
67+- `EC_SCALEDREF_MODE=2` (random denominator per frame): produces coded widths that are not
68+ multiples of 32, so the frame edge forces sub-16 partitions and the stream stops at the still-open
69+ named refusal `an 8x8 partition leaf under a scaled reference (superres, unimplemented)` at
70+ seed 42.
71+
72+deferred: mixed one-scaled-one-unscaled compound tap — unblocked by the leaf8 desync (lane-sub8),
73+which is what mode-2 recipes hit; the counter is in place so any future recipe proves the case
74+immediately. The per-tap code itself is r1's (`scale0`/`scale1` are already independent).
75+
76+## Test totals
77+
78+`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib` (whole crate lib suite): **268 passed, 0 failed, 23 ignored**, 968s (same totals as r1, now with the warp arm of the superres gate ON). Run at the final tree.
79+
80+## Residue carried from r1 (unchanged)
81+
82+- deferred: 8x8 partition leaf under a scaled reference — unblocked by the lane-sub8 leaf8 desync.
83+- deferred: reference scaling in BOTH axes (`--resize-mode`) — unblocked by a lane sized for it.
84+- accepted: 10-bit is refused upstream (`Picture` planes are `Vec<u8>`).
85+- accepted: the Golomb-tail cap stays where r1 left it (it masks an intra-rect64 defect).
lanes/tx64x16-r1.report.mdadded+138 -0
@@ -0,0 +1,138 @@
1+# lane-tx64x16 r1 — the 1:4 pair at 64x64 (TX_64X16 / TX_16X64)
2+
3+Branch `lane-tx64x16`, worktree `edith_codecs-tx64x16`, off main `dc5553f`.
4+
5+## STATUS: INCOMPLETE — gate RED. The refusal is narrowed in the code but NOT
6+proven: a real `PARTITION_VERT_4` stream with coefficients still mismatches.
7+Do not merge as is.
8+
9+## Premises re-measured (charter carried two stale ones)
10+
11+- "the refusal string now names the 1:4 pair" — FALSE at `dc5553f`. It read
12+ *"a superblock-level partition type other than NONE or SPLIT"*
13+ (`refusal_inventory.rs:48`) while `decode.rs` already coded HORZ/VERT; the AB
14+ arms part32-r5 reports are NOT on main. Command:
15+ `grep -n "64" crates/ec-av1/src/refusal_inventory.rs`.
16+- "requires the transform primitives (TX_64X16 / TX_16X64 …)" — FALSE. They
17+ already exist: `inverse_transform_2d_typed_wh` (transform.rs:817) is generic
18+ in (w,h), already zeroes everything past the low 32 on a 64-length axis
19+ (`transform.rs:842`), already gets the rect scale right (fires only at
20+ log2 ratio 1, i.e. never for 4:1 — `transform.rs:837`, and its comment
21+ already names 16x64/64x16), and `row_shift_wh` (transform.rs:288) already
22+ carries `(16,64)|(64,16) => 2` and `(8,32)|(32,8) => 2`, both verified
23+ against `av1_inv_txfm_shift_ls` / `inv_shift_64x16` == `{-2,-4}`
24+ (`~/.cache/aom-oracle/src/av1/common/av1_inv_txfm2d.c:150`). Dequant is
25+ area-keyed (`dq_denom_area`), and `av1_get_tx_scale` is too (1024 pels → 1).
26+ Nothing was owed here; the real work was entropy wiring + partition wiring.
27+
28+## What changed
29+
30+- `crates/ec-av1/src/decode.rs`
31+ - `SCAN_32X8` / `SCAN_8X32` (new, ~line 1650): row-major transcriptions of
32+ libaom `default_scan_32x8` / `default_scan_8x32`, converted with
33+ `row*w+col = (p % h)*w + (p / h)` from libaom's COLUMN-major `p`. The rule
34+ was validated by reproducing this repo's existing `SCAN_16X8` byte for byte
35+ from `default_scan_16x8` before generating anything new — and libaom's
36+ `default_scan_16x8` literal is byte-identical to this repo's `SCAN_8X16`,
37+ i.e. a naive copy installs the transpose (class
38+ reference-layout-not-spec).
39+ - `decode_block_rect64`: luma corner generalised from a hardcoded 32x32 to
40+ `(bw.min(32), bh.min(32))`, reading 32x16/16x32 through `read_coeffs_rect`
41+ with `SCAN_32X16`/`SCAN_16X32` and `TxbSet::LumaRect32x16`; chroma set/scan
42+ picked per shape, 32x8/8x32 reading `TxbSet::Chroma16` with the new scans.
43+ Why no new CDF tables are owed, all read out of the oracle source:
44+ `av1_get_adjusted_tx_size` maps TX_64X16→TX_32X16, TX_16X64→TX_16X32
45+ (`blockd.h:1361`); `av1_scan_orders` gives TX_64X16 `default_scan_32x16`
46+ ("tx32's scan order is used", `scan.c`); `get_txsize_entropy_ctx` is 3 for
47+ both TX_64X16 and TX_32X16 and 2 for both TX_32X8 and TX_16X16;
48+ `txsize_log2_minus4` is 5 for TX_64X16 *and* TX_32X16, 4 for TX_32X8 *and*
49+ TX_16X16 (`common_data.h:346`) so the eob alphabet matches too; and
50+ `av1_nz_map_ctx_offset[TX_64X16]` is literally
51+ `av1_nz_map_ctx_offset_32x16` (`txb_common.c:340`) — which is what
52+ `base_ctx_rect(32,16)` computes, since both raw and coded dims are w>h.
53+ - `PARTITION_HORZ_4`/`PARTITION_VERT_4` (8/9) wired at the superblock level:
54+ four strips, `quarter_step` = 1 SUB unit, with libaom's `i > 0` frame-edge
55+ break.
56+ - New per-orientation hit counters `sb_rect4_horz_hits()` /
57+ `sb_rect4_vert_hits()`.
58+- `crates/ec-av1/src/refusal_inventory.rs`: SB-level string narrowed to
59+ "a superblock-level HORZ_A/HORZ_B/VERT_A/VERT_B partition (… codes NONE,
60+ SPLIT, HORZ, VERT and the 1:4 pair at 64x64)".
61+- `crates/ec-av1/src/stream.rs`: new gate
62+ `a_real_aomenc_stream_with_a_superblock_level_1to4_partition_decodes_pixel_exact`.
63+- `crates/ec-av1/fixtures/tx64x16-vert4-mismatch-seed73.obu`: the failing
64+ stream, pinned.
65+
66+## Gate
67+
68+`cargo test -p ec-av1 --lib -- --exact stream::tests::a_real_aomenc_stream_with_a_superblock_level_1to4_partition_decodes_pixel_exact`
69+(`EC_TX64X16_GATE_ATTEMPTS`, default 40). aomenc recipe = the sbpart gate's,
70+with `--enable-1to4-partitions=1` and `--min-partition-size=16`; odd attempts
71+render the generator rotated 90 degrees (`transpose=1`) because aomenc picks
72+VERT_4 on this content and essentially never HORZ_4, and the two arms are a
73+transposed pair. Attempts whose decode fired zero 1:4 strips are counted and
74+printed, never asserted on — selection is on "the stream contains the
75+feature", never on "the stream decoded correctly".
76+
77+RESULT: **FAIL**. `seed 73` (a stream with four real 16x64 `PARTITION_VERT_4`
78+strips at mi(16,16..28)) mismatches ffmpeg: 10754 wrong luma samples, first at
79+(64, 56) — one row band ABOVE the strips, i.e. across the y=64 deblock edge.
80+An earlier 13-attempt run (before the transpose arm) had VERT_4 fire 4 strips
81+and decode PIXEL-EXACT, so the skip/low-energy case works and the coded case
82+does not.
83+
84+EVIDENCE: /home/user/Documents/Code/Rust/edith_codecs-tx64x16/crates/ec-av1/fixtures/tx64x16-vert4-mismatch-seed73.obu | decode_probe dump vs `ffmpeg -f rawvideo`, EC_AV1_TRACE partition trace | 10754/24576 luma samples differ, first (64,56); trace shows `partition_w64 value=9` then four `TRACE_RECT64_END bw=16 bh=64`
85+EVIDENCE: gate stdout above | 40 aomenc attempts, seeds 42..81, `--enable-1to4-partitions=1` | 21 named refusals, VERT_4 arm reached a real decode, HORZ_4 arm never selected by aomenc on this content
86+
87+## Open, with dispositions
88+
89+- **fix-now (r2)**: the coded-16x64 mismatch above. Not yet root-caused.
90+ Ruled out by reading the oracle source, NOT by experiment: shift chain
91+ (`inv_shift_64x16`/`inv_shift_16x64` = {-2,-4} = our `row_shift_wh` 2), rect
92+ scale (4:1 gets none), dequant denominator (area 1024 → 2), eob alphabet
93+ (512), CDF set, scan choice, nz-map offset table. Untested suspects, in
94+ order: (1) the deblock grid for a 1:4 strip
95+ (`fill_lf_grid_rect(.., tx_w=16, tx_h=64, 0)`) — the first diffs are on the
96+ OTHER side of the edge; (2) 16x64 intra prediction edge reach; (3) the
97+ chroma 8x32 plane. First move should be a prefilt dump
98+ (`EC_AV1_PREFILT_DUMP`) to split "reconstruction wrong" from "deblock
99+ wrong" — the diff band starting above the block is exactly the tell that
100+ cost lane-tiny a round.
101+- **deferred(a green 64-level gate)**: the 32x32-level 1:4 arms. They ARE
102+ requested by this recipe — `a 32x32 partition type this decoder does not
103+ code (value=9)` appears in the sweep — and need TX_32X8/TX_8X32 luma
104+ (`TxbSet::Luma16` exactly: entropy ctx 2, eob 256) plus 16x4/4x16 chroma
105+ (`TxbSet::Chroma8`: ctx 1, eob 64) and two more scans. Same shape of work,
106+ not started.
107+- **flagged, not this lane's shape (pre-existing)**: with
108+ `--min-partition-size=16`, seed 55 of this recipe decodes 3944 wrong luma
109+ samples with ZERO 1:4 blocks in the stream (trace: SB(1,0) SPLIT with a
110+ 32x32 `PARTITION_HORZ`, SB(1,2) a 64x32 `PARTITION_HORZ`), first diff at
111+ (154, 59). My diff cannot reach that stream (every path it touches needs a
112+ 16-with-64 dimension pair), so it is a pre-existing defect of the 32x16 /
113+ 64x32 strip shapes exposed by a recipe the existing sbpart gate
114+ (`--min-partition-size=32`) never uses. Stream: rerun the gate with
115+ `EC_AV1_GATE_DUMP` at `EC_TX64X16_GATE_ATTEMPTS=14`.
116+- **accepted**: `palette_bsize_ctx_wh` has no rect caller at all
117+ (`read_intra_mode_rect` never reads a palette symbol), so 64x16/16x64 need
118+ no entry there; a screen-content rect strip is a different lane's hole.
119+
120+## Suite totals
121+
122+`cargo test -p ec-av1 --lib` (worktree, `CARGO_TARGET_DIR=~/.cache/cargo-target-tx64x16`,
123+1347s under a 10-lane concurrent load):
124+**256 passed, 17 failed, 22 ignored, 0 filtered out.**
125+Two of the 17 captured by name --
126+`stream::tests::a_real_aomenc_superres_key_frame_sequence_decodes_pixel_exact`
127+and `stream::tests::real_aomenc_film_grain_streams_decode_pixel_exact` -- are
128+outside anything this diff can reach (no 16-with-64 dimension pair), plus this
129+lane's own new gate. The remaining 14 were NOT enumerated: the capture pipeline
130+dropped the failure list and a re-run costs another 22 minutes, which the tool
131+budget did not have. A successor MUST re-run this and diff the failure set
132+against `main` before attributing any of it to this branch.
133+
134+Note: `crates/ec-av1/fixtures/` is covered by `.gitignore:2 (fixtures)`, so the
135+pinned mismatching stream is NOT in the commit -- it is on disk in the worktree
136+at `crates/ec-av1/fixtures/tx64x16-vert4-mismatch-seed73.obu`
137+(sha256 0d9c3dd8a178a96309ea7165f3018146b5e09e660fd78a6870da2a5b5b1b60c1) and
138+regenerable by the gate with `EC_AV1_GATE_DUMP`.
lanes/tx64x16-r2.report.mdadded+113 -0
@@ -0,0 +1,113 @@
1+# lane-tx64x16 r2 — the SB-level 1:4 pair is GREEN; r1's "17 failures" were a stale base
2+
3+Branch `lane-tx64x16`, rebased dc5553f -> `5811ec5` -> **`6d86d3a`** (current main
4+at the time of writing). Commits: `3435835` (r1 wiring, replayed), `23aa4b3`
5+(r1 report), `d1f71b6` (this round).
6+
7+## Headline
8+
9+**r1's red gate was a STALE BASE, not a defect.** Nothing in the 1:4 wiring
10+changed this round. Rebasing onto main turns
11+`a_real_aomenc_stream_with_a_superblock_level_1to4_partition_decodes_pixel_exact`
12+GREEN (both arms hard-asserted, 40 aomenc attempts), and the r1 suite's
13+"17 failed" collapses to 2 — neither of them reachable by this lane's diff.
14+
15+Class for the ledger: **stale-premise lane** (5th instance) — a lane whose gate
16+is red against a base that is 20 merges behind measures the base, not its own
17+change. Re-measure the premise on today's main BEFORE bisecting your own diff.
18+
19+## The 17, enumerated (charter's first job)
20+
21+They do not exist on the rebased branch. Full `cargo test -p ec-av1 --lib`
22+(`EC_AV1_REQUIRE_AOMENC=1`) on the rebase-onto-5811ec5 tree, before any fix of
23+mine: **290 passed, 2 failed, 27 ignored**, the two being
24+
25+1. `decode::tests::nz_map_ctx_offset_tables_match_the_rect_rule` — **RED ON
26+ MAIN**, not caused by this branch (`git diff --stat main..HEAD` touches
27+ `decode.rs` (partition arms + counters + scans), `refusal_inventory.rs`,
28+ `stream.rs` only; the table, its consumer and this test are all main's).
29+ Root cause: the test read `NZ_MAP_CTX_OFFSET_32X64`/`_64X32` as
30+ `table[col][row]` — lane-rectsplit r2's column-major premise, which r3
31+ disproved and reverted in the *tables* without reverting the *test*. The
32+ tables as they stand are display-major and satisfy libaom's generating rule
33+ (`txb_common.h:199-209`) read `[row][col]`, which is exactly how the only
34+ real consumer reads them (`base_ctx`, `TxClass::TwoD` arm,
35+ `crates/ec-av1/src/decode.rs:1829`) and the reading every merged rect gate
36+ is green under. FIX: read the test in the consumer's order. Table content
37+ untouched — zero risk to the 64x32/32x64 path.
38+ Verification of the direction: for `TX_32X64` (w<h) libaom's rule gives
39+ `11+ctx` for every `row < 2`; our const's row 0 is `[0,11,11,11,11]` and row
40+ 2 is `[6,6,21,21,21]` = `row+col<4 -> 6`, i.e. display-major and correct.
41+2. `gate_coverage::tests::never_exercised_8bit_matches_the_gate_recipes` —
42+ caused by this branch, and by design: this lane's gate is the first to pass
43+ `--enable-1to4-partitions=1` at 8 bit, so the 8-bit coverage hole is retired.
44+ FIX: entry deleted from `NEVER_EXERCISED_8BIT`; the 10-bit entry stays and
45+ now says "10-bit hole only".
46+
47+Bisecting the corner generalisation vs the scan additions (the charter's plan)
48+was therefore not needed and not run — the premise it rested on ("a change that
49+breaks 17 gates") was false.
50+
51+## Rebase conflict resolutions (main had moved onto the same lines)
52+
53+- `decode.rs` SB partition dispatch: BOTH arms kept — main's
54+ `PARTITION_HORZ_A/_B/VERT_A/_B` (part32 r4) and this lane's
55+ `PARTITION_HORZ_4/VERT_4`; `reduced_tx_set` (new on main) threaded into the
56+ 1:4 `decode_block_rect64` calls.
57+- `decode.rs` counters: both `SB_AB_HITS` and `SB_RECT4_{HORZ,VERT}_HITS` kept.
58+- The `_` arm of the SB partition match is now unreachable (all ten partition
59+ values are coded at 64x64); it refuses "a superblock-level partition value
60+ outside PARTITION_NONE..PARTITION_VERT_4" and `refusal_inventory` lists that
61+ string instead of the retired 1:4 one.
62+- `stream.rs`: git had spliced this lane's gate INTO main's AB gate. Resolved by
63+ taking main's file whole and re-appending the 1:4 gate function verbatim.
64+
65+## Refusal lifted
66+
67+`"a superblock-level 1:4 partition (PARTITION_HORZ_4/VERT_4 at 64x64, four
68+64x16/16x64 strips)"` — gone from `decode.rs` and `refusal_inventory.rs`, with
69+the gate above green. `refusal_inventory` + all five `gate_coverage` tests green.
70+
71+## EVIDENCE
72+
73+EVIDENCE: ~/.cache/tx64-sb-gates.log | `cargo test -p ec-av1 --lib -- superblock_level` with EC_AV1_REQUIRE_AOMENC=1 on d1f71b6 | 3 passed, 0 failed, 1 ignored (rect64q drift gate, ignored on main): the 1:4 gate AND both sibling SB gates (horz_vert, ab) green — SIBLING GATES rule satisfied
74+EVIDENCE: ~/.cache/tx64-suite-r2.log | full `cargo test -p ec-av1 --lib`, rebase onto 5811ec5, before my fixes | 290 passed / 2 failed / 27 ignored — the two named above, replacing r1's unenumerated 17
75+EVIDENCE: /tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/b6d8a07f-96a4-4bbb-b378-af9ae25cf7c9/scratchpad/reelc.obu (sha256 32e0619ca9fd9ae0e16072c66013757aa7abfedccc99bc6d3509f6e213195226, `ffmpeg -ss 300 -t 0.4 -c:v copy -f obu`) | `cargo run -p ec-av1 --example decode_probe` on d1f71b6 | ReelC no longer stops at the 1:4 refusal; new stop is "a superblock-level HORZ/VERT strip with a split transform (per-unit rect prediction is not ported)" — the refusal lane-rectsplit r4 (7b55227) lifts
76+EVIDENCE: ~/.cache/tx64-suite-r2b.log | full `cargo test -p ec-av1 --lib` on d1f71b6 (rebased onto 6d86d3a, both fixes in) | see "Suite totals" below
77+
78+## Open, with dispositions
79+
80+- **fix-now, NEXT ROUND (ReelB critical path)**: the **32x32-level**
81+ `PARTITION_HORZ_4/VERT_4` (`decode.rs:9384`, refusal "a 32x32 partition type
82+ this decoder does not code (value={part32})", value 8 = HORZ_4). Shape of the
83+ work, already scouted: four `decode_block_rect(at32, 32, 8)` /
84+ `(8, 32)` strips at `quarter_step` = 1 mi-pair, same `i > 0` frame-edge break
85+ as the 64-level arm. Luma TX_32X8/TX_8X32 are their own adjusted size
86+ (`av1_get_adjusted_tx_size` leaves them alone), entropy ctx = TX_16X16 and
87+ `txsize_log2_minus4` = 4 (256 positions) => `TxbSet::Luma16` exactly, and the
88+ scans **already exist** in this branch: `SCAN_32X8` / `SCAN_8X32`
89+ (`decode.rs:1952`/`1969`). What is genuinely missing is CHROMA 16x4 / 4x16:
90+ `TxbSet::Chroma8` (ctx TX_8X8, 64 positions) plus two new scans
91+ `default_scan_16x4` / `default_scan_4x16`, transcribed with this repo's
92+ column-major -> row-major rule (`row*w+col = (p % h)*w + (p / h)`; validate
93+ the rule by regenerating an existing scan first — a naive copy installs the
94+ transpose).
95+- **deferred(the 32-level arms above)**: a 10-bit twin of the 1:4 gate. The
96+ `NEVER_EXERCISED_10BIT` entry for `enable-1to4-partitions` is still live and
97+ now says so explicitly.
98+- **flagged, resolved**: r1's "pre-existing seed-55 defect (3944 wrong luma,
99+ zero 1:4 blocks)" did not reproduce on the rebased tree — the 1:4 gate runs
100+ all 40 seeds of that same recipe (seeds 42..81, `--min-partition-size=16`) and
101+ every decoded attempt now compares pixel-exact, including seed 55. It was
102+ another symptom of the stale base (main has since landed inter8/rectsplit/
103+ txselect/seg fixes). No separate pin is owed.
104+- **accepted**: `main` moved again during the round (rectsplit r4 `7b55227` is
105+ not yet merged). If it lands first, its `base_ctx` rewrite may delete
106+ `NZ_MAP_CTX_OFFSET_32X64/_64X32` outright and conflict with my one-line test
107+ fix — resolve by taking r4's version, the defect is the same one.
108+
109+## Suite totals
110+
111+`cargo test -p ec-av1 --lib` with `EC_AV1_REQUIRE_AOMENC=1`, on `d1f71b6`:
112+**295 passed, 0 failed, 27 ignored, 0 filtered out** (1234s under concurrent lane load).
113+Both failures above are fixed; no new failure introduced. r1's 256/17/22 is superseded.
scripts/build-aom-affine-oracle.shadded+48 -0
@@ -0,0 +1,48 @@
1+#!/usr/bin/env bash
2+# Provision an aomenc that can emit AFFINE global motion.
3+#
4+# Stock libaom NEVER writes a 6-parameter (AFFINE) global-motion model: its
5+# encoder-side model search is pinned to ROTZOOM,
6+#
7+# av1/encoder/global_motion_facade.c:24
8+# #define FIRST_GLOBAL_TRANS_TYPE ROTZOOM
9+# #define LAST_GLOBAL_TRANS_TYPE ROTZOOM
10+#
11+# so no `--enable-global-motion=1` recipe over any content can produce the
12+# AFFINE case the decoder must still handle (the *bitstream* allows it, the
13+# spec's `global_motion_params` reads 6 params, and ffmpeg decodes it). This
14+# builds a side copy of the oracle source with that search range widened to
15+# AFFINE -- decode-normative output, still ordinary libaom, still verified
16+# against ffmpeg -- into its own prefix so the shared oracle at
17+# ~/.cache/aom-oracle (used by every other gate) is untouched.
18+#
19+# Used by the `a_real_affine_global_motion_stream_decodes_pixel_exact` gate in
20+# crates/ec-av1/src/stream.rs.
21+set -euo pipefail
22+
23+ROOT="${AOM_AFFINE_ROOT:-$HOME/.cache/aom-affine}"
24+ORACLE_SRC="${AOM_ORACLE_ROOT:-$HOME/.cache/aom-oracle}/src"
25+SRC="$ROOT/src"
26+BUILD="$ROOT/build"
27+
28+if [ ! -d "$ORACLE_SRC/.git" ]; then
29+ echo "no oracle source at $ORACLE_SRC -- run scripts/build-aom-oracle.sh first" >&2
30+ exit 1
31+fi
32+
33+if [ ! -d "$SRC" ]; then
34+ mkdir -p "$ROOT"
35+ cp -a "$ORACLE_SRC" "$SRC"
36+fi
37+
38+facade="$SRC/av1/encoder/global_motion_facade.c"
39+sed -i 's/^#define LAST_GLOBAL_TRANS_TYPE ROTZOOM$/#define LAST_GLOBAL_TRANS_TYPE AFFINE/' "$facade"
40+grep -q '^#define LAST_GLOBAL_TRANS_TYPE AFFINE$' "$facade" ||
41+ { echo "patch did not apply to $facade" >&2; exit 1; }
42+
43+cmake -S "$SRC" -B "$BUILD" -G Ninja \
44+ -DCMAKE_BUILD_TYPE=Release \
45+ -DENABLE_TESTS=0 -DENABLE_DOCS=0 -DENABLE_EXAMPLES=1
46+ninja -C "$BUILD" aomenc
47+
48+echo "affine-capable encoder ready: $BUILD/aomenc"
scripts/instrument-aom-oracle.shmodified+56 -0
@@ -21,6 +21,8 @@
21 # two lanes stalled on 2026-08-30 because this rung did not exist.21 # two lanes stalled on 2026-08-30 because this rung did not exist.
22 # EC_TRACE_MODE=1 -> "EC_MODE mi_row=.. mi_col=.. rng=.." before every inter22 # EC_TRACE_MODE=1 -> "EC_MODE mi_row=.. mi_col=.. rng=.." before every inter
23 # block's mode info, "EC_MODE_VAL .. mode=.. ref0/1=.. mv0=.. rng=.."23 # block's mode info, "EC_MODE_VAL .. mode=.. ref0/1=.. mv0=.. rng=.."
24+# (rung 13 adds "stack=" to that line and an "EC_MODE_MV" line right
25+# after assign_mv)
24 # after -- the mv-stack/DRL/mv reads EC_PART cannot see. The same flag26 # after -- the mv-stack/DRL/mv reads EC_PART cannot see. The same flag
25 # also emits "EC_IMODE .. rng=.." / "EC_IMODE_VAL .. mode=.. uv_mode=..27 # also emits "EC_IMODE .. rng=.." / "EC_IMODE_VAL .. mode=.. uv_mode=..
26 # skip=.. tx=.. rng=.." around every INTRA key-frame block: without it28 # skip=.. tx=.. rng=.." around every INTRA key-frame block: without it
@@ -705,3 +707,57 @@ s = s.replace(anchor, dump + anchor, 1)
705 open(path, "w").write(s)707 open(path, "w").write(s)
706 print("final dump instrumented")708 print("final dump instrumented")
707 PYF709 PYF
710+
711+# --- rung 13: MV ground truth inside the inter mode ladder (lane-inter8 r3) --
712+# lane-inter8 r3 patched the live oracle tree BY HAND and rebuilt aomdec, so
713+# these two probes existed only in ~/.cache/aom-oracle/src and any rebuild
714+# from this script would have silently dropped them (class: instrument that
715+# lives only in a build tree). Both extend rung 4 and are gated by the same
716+# EC_TRACE_MODE:
717+# * EC_MODE_MV .. mode=.. mv0=(..,..) rng=.. -- printed immediately after
718+# assign_mv, i.e. the MV as decoded, BEFORE interintra/motion-mode/
719+# interp-filter syntax moves the range further; lets a lane separate an
720+# MV defect from a later-symbol defect on the same block.
721+# * stack=<ref_mv_count[ref_frame_type]> added to rung 4's EC_MODE_VAL --
722+# the reference's own mv-stack depth for the block's reference pair.
723+H="$SRC/av1/decoder/decodemv.c"
724+[ -f "$H" ] || { echo "no oracle source at $H" >&2; exit 1; }
725+
726+python3 - "$H" <<'PYMV'
727+import sys
728+path = sys.argv[1]
729+s = open(path).read()
730+if "EC_MODE_MV" in s:
731+ print("decodemv rung 13 already applied (no-op)")
732+ sys.exit(0)
733+assert "EC_INSTRUMENTED" in s, "rung 13 needs rung 4 (run this script top to bottom)"
734+
735+# (a) stack= on rung 4's EC_MODE_VAL
736+old_val = """ "mv0=(%d,%d) rng=%u\\n",
737+ ec_xd->mi_row, ec_xd->mi_col, (int)mbmi->mode,
738+ (int)mbmi->ref_frame[0], (int)mbmi->ref_frame[1],
739+ mbmi->mv[0].as_mv.row, mbmi->mv[0].as_mv.col,
740+ (unsigned)r->ec.rng);"""
741+new_val = """ "mv0=(%d,%d) stack=%d rng=%u\\n",
742+ ec_xd->mi_row, ec_xd->mi_col, (int)mbmi->mode,
743+ (int)mbmi->ref_frame[0], (int)mbmi->ref_frame[1],
744+ mbmi->mv[0].as_mv.row, mbmi->mv[0].as_mv.col,
745+ /* EC_STACK */ (int)dcb->ref_mv_count[av1_ref_frame_type(mbmi->ref_frame)],
746+ (unsigned)r->ec.rng);"""
747+assert old_val in s, "rung 4's EC_MODE_VAL body moved"
748+s = s.replace(old_val, new_val, 1)
749+
750+# (b) EC_MODE_MV right after assign_mv's corrupted-flag merge
751+anchor = " aom_merge_corrupted_flag(&dcb->corrupted, mv_corrupted_flag);\n"
752+assert s.count(anchor) == 1, "assign_mv corrupted-flag merge is no longer unique"
753+probe = """ if (getenv("EC_TRACE_MODE") != NULL) {
754+ fprintf(stderr,
755+ "EC_MODE_MV mi_row=%d mi_col=%d mode=%d mv0=(%d,%d) rng=%u\\n",
756+ xd->mi_row, xd->mi_col, (int)mbmi->mode, mbmi->mv[0].as_mv.row,
757+ mbmi->mv[0].as_mv.col, (unsigned)r->ec.rng);
758+ }
759+"""
760+s = s.replace(anchor, anchor + probe, 1)
761+open(path, "w").write(s)
762+print("decodemv rung 13 (EC_MODE_MV + EC_MODE_VAL stack=) instrumented")
763+PYMV