forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-gmaffine': AFFINE global motion, 8x8 GLOBALMV/WARPED_CAUSAL leaves, chroma warp >=8 only, eob_pt class-1 rows for every TxbSet arm (44 consts byte-checked vs libaom); 4 real-aomenc gates at 8/10-bit

Browse files at this commit

e31db3b9a80486db68020a27b194083de81204b2Ahmet Kaan GümüşParent: 01c42f606a5eac

11 changed files +1331 -127

crates/ec-av1/src/cdf.rsmodified+31 -0
@@ -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+346 -80
@@ -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 };
@@ -1213,6 +1213,42 @@ pub(crate) fn compound_warp_hits() -> usize {
1213 COMPOUND_WARP_HITS.with(|c| c.get())1213 COMPOUND_WARP_HITS.with(|c| c.get())
1214 }1214 }
1215 1215
1216+// lane-gmaffine r1: how many blocks built their prediction from a
1217+// SIX-parameter (`AFFINE`) global-motion model through
1218+// `crate::warp::global_warp_params` -- the gate's proof that a stream really
1219+// carried an AFFINE `global_motion_params` AND that a block was predicted
1220+// with it, not merely that the header parsed one.
1221+thread_local! {
1222+ static AFFINE_GM_HITS: std::cell::Cell<usize> =
1223+ const { std::cell::Cell::new(0) };
1224+}
1225+
1226+/// Current value of [`AFFINE_GM_HITS`].
1227+pub(crate) fn affine_gm_hits() -> usize {
1228+ AFFINE_GM_HITS.with(|c| c.get())
1229+}
1230+
1231+// lane-gmaffine r1: 8x8-leaf-only counters -- how many `BLOCK_8X8` leaves
1232+// coded `GLOBALMV` (`GLOBALMV_HITS_8`) and how many built a real
1233+// `WARPED_CAUSAL` local-warp prediction there (`WARP_HITS_8`, incremented
1234+// only once `find_projection` returned a usable model, unlike
1235+// `WARP_SELECTED_HITS` which counts the symbol). Both are the 8x8 gates'
1236+// proof that the leaf path itself fired, not the 16x16+ one.
1237+thread_local! {
1238+ static GLOBALMV_HITS_8: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1239+ static WARP_HITS_8: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1240+}
1241+
1242+/// Current value of [`GLOBALMV_HITS_8`].
1243+pub(crate) fn globalmv_hits_8() -> usize {
1244+ GLOBALMV_HITS_8.with(|c| c.get())
1245+}
1246+
1247+/// Current value of [`WARP_HITS_8`].
1248+pub(crate) fn warp_hits_8() -> usize {
1249+ WARP_HITS_8.with(|c| c.get())
1250+}
1251+
1216 // How many blocks decoded `interintra == 1` with the non-wedge blended1252 // How many blocks decoded `interintra == 1` with the non-wedge blended
1217 // prediction applied (lane-interintra r1) -- the gate's proof that a1253 // prediction applied (lane-interintra r1) -- the gate's proof that a
1218 // stream actually exercised interintra.1254 // stream actually exercised interintra.
@@ -2195,7 +2231,8 @@ fn read_coeffs(
2195 let ec_trace_coeff = std::env::var_os("EC_TRACE_COEFF").is_some();2231 let ec_trace_coeff = std::env::var_os("EC_TRACE_COEFF").is_some();
2196 if ec_trace_coeff {2232 if ec_trace_coeff {
2197 let (rng, _) = dec.debug_state();2233 let (rng, _) = dec.debug_state();
2198- eprintln!("EC_COEFF_STEP tag=eob eob={eob} rng={rng}");2234+ let cls = match class { TxClass::TwoD => "2d", TxClass::Horiz => "horiz", TxClass::Vert => "vert" };
2235+ eprintln!("EC_COEFF_STEP tag=eob eob={eob} tx={tx_type:?} class={cls} rng={rng}");
2199 }2236 }
2200 let class_scan;2237 let class_scan;
2201 let scan: &[u16] = if class == TxClass::TwoD {2238 let scan: &[u16] = if class == TxClass::TwoD {
@@ -10297,6 +10334,12 @@ fn num_proj_ref(
10297 /// decoder's own overlap sizes ever produce (luma 8/16/32, chroma 4/8/16)10334 /// decoder's own overlap sizes ever produce (luma 8/16/32, chroma 4/8/16)
10298 /// are transcribed.10335 /// are transcribed.
10299 fn obmc_mask(len: usize) -> &'static [u8] {10336 fn obmc_mask(len: usize) -> &'static [u8] {
10337+ // lane-gmaffine r1: the two SHORT masks (libaom `reconinter.c`
10338+ // `obmc_mask_1`/`obmc_mask_2`) -- an 8x8 leaf's chroma plane is 4x4, so
10339+ // its overlap is 2 (and 1 at a half-block edge). Unreachable until this
10340+ // round wired interior 16x16 splits down to real 8x8 leaves, where the
10341+ // old `unreachable!()` below fired as a hard panic.
10342+ const M1: [u8; 1] = [64];
10300 // lane-inter8 r1: `obmc_mask_2` (`reconinter.c` 753) -- reached by the10343 // lane-inter8 r1: `obmc_mask_2` (`reconinter.c` 753) -- reached by the
10301 // LEFT pass of an 8x8 block's chroma plane (overlap 4 luma columns, 210344 // LEFT pass of an 8x8 block's chroma plane (overlap 4 luma columns, 2
10302 // chroma), which only became live once 8x8 inter leaves stopped being10345 // chroma), which only became live once 8x8 inter leaves stopped being
@@ -10312,6 +10355,7 @@ fn obmc_mask(len: usize) -> &'static [u8] {
10312 61, 62, 64, 64, 64, 64, 64, 64, 64, 64,10355 61, 62, 64, 64, 64, 64, 64, 64, 64, 64,
10313 ];10356 ];
10314 match len {10357 match len {
10358+ 1 => &M1,
10315 2 => &M2,10359 2 => &M2,
10316 4 => &M4,10360 4 => &M4,
10317 8 => &M8,10361 8 => &M8,
@@ -10587,6 +10631,11 @@ fn obmc_blend(
10587 // (this decoder's own outer block-loop granularity), one step10631 // (this decoder's own outer block-loop granularity), one step
10588 // coarser than the mi(4px) units `overlappable_above` walks in --10632 // coarser than the mi(4px) units `overlappable_above` walks in --
10589 // divide back down to that column.10633 // divide back down to that column.
10634+ // lane-gmaffine r2: the neighbour's OWN mi-granular filter
10635+ // (libaom `av1_setup_build_prediction_by_above_pred` reads
10636+ // `above_mbmi->interp_filters`); the 16px-granular `Neighbours` slot
10637+ // stays as the fallback for paths that do not record one yet
10638+ // (compound), which is what every earlier round used.
10590 let (h_kind, v_kind) = neighbour_filter(10639 let (h_kind, v_kind) = neighbour_filter(
10591 interp_fixed,10640 interp_fixed,
10592 neighbours.above_filter[mi_col + off4],10641 neighbours.above_filter[mi_col + off4],
@@ -12448,6 +12497,9 @@ fn decode_inter_block(
12448 let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize];12497 let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize];
12449 if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid {12498 if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid {
12450 warp_params = crate::warp::global_warp_params(gm_ref.params);12499 warp_params = crate::warp::global_warp_params(gm_ref.params);
12500+ if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine {
12501+ AFFINE_GM_HITS.with(|c| c.set(c.get() + 1));
12502+ }
12451 }12503 }
12452 if std::env::var_os("EC_AV1_TELL").is_some() {12504 if std::env::var_os("EC_AV1_TELL").is_some() {
12453 eprintln!(12505 eprintln!(
@@ -12670,16 +12722,25 @@ fn decode_inter_block(
12670 py_ref.width as i32, &mut pred_y, px as i32, py as i32, side as i32,12722 py_ref.width as i32, &mut pred_y, px as i32, py as i32, side as i32,
12671 side as i32, side as i32, 0, 0,12723 side as i32, side as i32, 0, 0,
12672 );12724 );
12673- crate::warp::warp_affine(12725+ // libaom `av1_init_warp_params` (reconinter.c): warp is
12674- params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32,12726+ // per PLANE and bails out at `block_width < 8 ||
12675- pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32,12727+ // block_height < 8`, so a plane whose own block is under
12676- chroma_side as i32, chroma_side as i32, 1, 1,12728+ // 8x8 keeps the translational prediction built above --
12677- );12729+ // in 420 that is every chroma plane of a luma block below
12678- crate::warp::warp_affine(12730+ // 16x16 (lane-gmaffine r4: chroma-only mismatch of a few
12679- params, &pv_ref.data, pv_ref.true_width as i32, pv_ref.true_height as i32,12731+ // levels on both 8x8-leaf motion gates).
12680- pv_ref.width as i32, &mut pred_v, cpx as i32, cpy as i32, chroma_side as i32,12732+ if chroma_side >= 8 {
12681- chroma_side as i32, chroma_side as i32, 1, 1,12733+ crate::warp::warp_affine(
12682- );12734+ params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32,
12735+ pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32,
12736+ chroma_side as i32, chroma_side as i32, 1, 1,
12737+ );
12738+ crate::warp::warp_affine(
12739+ params, &pv_ref.data, pv_ref.true_width as i32, pv_ref.true_height as i32,
12740+ pv_ref.width as i32, &mut pred_v, cpx as i32, cpy as i32, chroma_side as i32,
12741+ chroma_side as i32, chroma_side as i32, 1, 1,
12742+ );
12743+ }
12683 }12744 }
12684 12745
12685 if obmc_selected {12746 if obmc_selected {
@@ -13218,6 +13279,16 @@ fn decode_inter_block8(
13218 scan4: &[u16],13279 scan4: &[u16],
13219 allow_high_precision_mv: bool,13280 allow_high_precision_mv: bool,
13220 force_integer_mv: bool,13281 force_integer_mv: bool,
13282+ // lane-gmaffine r1: this frame header's own `global_motion` table (spec
13283+ // 5.9.24), indexed `[ref_frame - LAST_FRAME]` -- same table
13284+ // [`decode_inter_block`] takes, threaded here so the 8x8 leaf can code
13285+ // `GLOBALMV` (`gm_get_motion_vector`), fill its mv stack's missing
13286+ // candidates with the gm mv (gm r6's root cause) and build a global
13287+ // warp prediction.
13288+ global_motion: &[ec_av1_syntax::WarpParams; 7],
13289+ // lane-gmaffine r1: this sequence header's own `enable_dual_filter` bit,
13290+ // for the leaf's own `read_mb_interp_filter` below.
13291+ enable_dual_filter: bool,
13221 // lane-av1comp: see [`decode_inter_block`]'s own doc -- this leaf path13292 // lane-av1comp: see [`decode_inter_block`]'s own doc -- this leaf path
13222 // only ever tracks a coarse `LAST_FRAME`-or-intra neighbour shape (no13293 // only ever tracks a coarse `LAST_FRAME`-or-intra neighbour shape (no
13223 // per-leaf `above_ref`/`left_ref` array exists here), so `comp_mode`'s13294 // per-leaf `above_ref`/`left_ref` array exists here), so `comp_mode`'s
@@ -13263,16 +13334,14 @@ fn decode_inter_block8(
13263 // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`-13334 // `BLOCK_8X8` (this leaf's fixed size) is always `av1_allow_palette`-
13264 // eligible (`bsize >= BLOCK_8X8`).13335 // eligible (`bsize >= BLOCK_8X8`).
13265 allow_screen_content_tools: bool,13336 allow_screen_content_tools: bool,
13266- // lane-inter8 r1: the leaf's mv stacks used to be built with neither the13337+ // lane-inter8 r1: the leaf's mv stacks used to be built without the
13267- // frame's sign-bias table nor its global-motion mv table (`NO_SIGN_BIAS`13338+ // frame's sign-bias table (`NO_SIGN_BIAS`), while [`decode_inter_block`]
13268- // / `NO_GM_MV`), while [`decode_inter_block`] one level up passed both.13339+ // one level up passed it -- it changes the candidate list and with it
13269- // A neighbour coded GLOBALMV contributes the gm mv, so dropping the table13340+ // `new_mv_ctx`/`ref_mv_ctx`, `drl_ctx` and the number of symbols read.
13270- // changes the candidate list -- and with it `new_mv_ctx`/`ref_mv_ctx`,13341+ // Measured: an 8x8 compound NEAR_NEWMV leaf desynced against aomdec's
13271- // `drl_ctx` and the number of symbols read. Measured: an 8x8 compound13342+ // EC_MODE ladder at exactly this block (mi 4,14 of the mandelbrot
13272- // NEAR_NEWMV leaf desynced against aomdec's EC_MODE ladder at exactly13343+ // 8x8-split gate).
13273- // this block (mi 4,14 of the mandelbrot 8x8-split gate).
13274 sign_bias_table: &SignBiasTable,13344 sign_bias_table: &SignBiasTable,
13275- global_motion: &[ec_av1_syntax::WarpParams; 7],
13276 // lane-inter8 r2: the frame's temporal mv field (spec 7.10.2.8), which13345 // lane-inter8 r2: the frame's temporal mv field (spec 7.10.2.8), which
13277 // [`decode_inter_block`] one level up has always passed and this leaf13346 // [`decode_inter_block`] one level up has always passed and this leaf
13278 // passed `None` for -- a `use_ref_frame_mvs` frame's stack then holds13347 // passed `None` for -- a `use_ref_frame_mvs` frame's stack then holds
@@ -13285,8 +13354,19 @@ fn decode_inter_block8(
13285 // predictions take when a stored reference was coded at another width13354 // predictions take when a stored reference was coded at another width
13286 // (`use_superres`) -- mirrors [`decode_inter_block`]'s own param.13355 // (`use_superres`) -- mirrors [`decode_inter_block`]'s own param.
13287 frame_width: usize,13356 frame_width: usize,
13288-) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, (i8, Option<i8>))> {13357+) -> Result<(bool, bool, bool, Option<(i8, i8, u8, u8)>, [u8; 2], (i8, Option<i8>))> {
13289 const LAST_FRAME: i8 = 1;13358 const LAST_FRAME: i8 = 1;
13359+ // lane-gmaffine r2: the leaf's OWN switchable-filter symbols, handed back
13360+ // so the caller stamps them into `Neighbours` instead of the `[3, 3]`
13361+ // placeholder. `[3, 3]` is the "intra neighbour, no filter" sentinel: an
13362+ // OBMC blend that picks such a neighbour up feeds it to
13363+ // `neighbour_filter`, which PANICS on it (`from_switchable_symbol`) --
13364+ // that was the warp gate's crash, not an entropy desync. Stays `[3, 3]`
13365+ // on the intra and compound paths.
13366+ let mut leaf_filter_syms = [3u8; 2];
13367+ // lane-gmaffine r1: this leaf's GLOBALMV vector AND the mv stack's
13368+ // missing-candidate fallback both come from the frame's global motion
13369+ // evaluated at THIS block's centre (gm r6's root cause).
13290 let gm_table = build_gm_mv_table(13370 let gm_table = build_gm_mv_table(
13291 global_motion,13371 global_motion,
13292 leaf_mi.0,13372 leaf_mi.0,
@@ -13864,38 +13944,58 @@ fn decode_inter_block8(
13864 // so the 16x16 below a split block read partition ctx 013944 // so the 16x16 below a split block read partition ctx 0
13865 // instead of 1 and mis-read PARTITION_SPLIT as NONE.13945 // instead of 1 and mis-read PARTITION_SPLIT as NONE.
13866 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);13946 neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]);
13867- neighbours.fill_lf_grid(leaf_mi, 2, 8, if is_inter { LAST_FRAME } else { 0 });13947+ neighbours.fill_lf_grid(
13868- return Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_refs));13948+ leaf_mi,
13949+ 2,
13950+ 8,
13951+ if is_inter { leaf_refs.0.max(LAST_FRAME) } else { 0 },
13952+ );
13953+ return Ok((
13954+ skip,
13955+ is_inter,
13956+ skip_mode,
13957+ compound_ctx8,
13958+ leaf_filter_syms,
13959+ leaf_refs,
13960+ ));
13869 }13961 }
13870 }13962 }
13871- leaf_refs = (LAST_FRAME, None);13963+ // lane-gmaffine r1: the leaf reads the FULL `single_ref` tree
13872- let sr_ctx = single_ref_ctx(above_inter || left_inter);13964+ // ([`read_single_ref`], the same one the 16x16+ leaf uses, with the
13873- let p1 = dec.symbol(&mut cdfs.single_ref[sr_ctx][0]);13965+ // real per-neighbour p1..p6 contexts) instead of the old three-symbol
13874- let p3 = dec.symbol(&mut cdfs.single_ref[sr_ctx][2]);13966+ // LAST-only probe plus a refusal -- aomenc picks GOLDEN/ALTREF for
13875- let p4 = dec.symbol(&mut cdfs.single_ref[sr_ctx][3]);13967+ // 8x8 leaves constantly, so that refusal was what every 8x8 gate
13876- if (p1, p3, p4) != (0, 0, 0) {13968+ // actually stopped at.
13877- return Err(unsupported(13969+ let ref_frame = read_single_ref(
13878- "a reference frame other than LAST_FRAME (round 2)",13970+ dec,
13879- ));13971+ cdfs,
13880- }13972+ neighbours.above_ref[cmi],
13973+ neighbours.above_ref1[cmi],
13974+ neighbours.left_ref[rmi],
13975+ neighbours.left_ref1[rmi],
13976+ );
13977+ leaf_refs = (ref_frame, None);
13978+ let (sref_y, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?;
13881 13979
13882 let (mi_row, mi_col) = leaf_mi;13980 let (mi_row, mi_col) = leaf_mi;
13981+ // lane-inter8 r2: the frame's temporal mv candidates, keyed on THIS
13982+ // leaf's own reference (lane-gmaffine r1 taught it non-LAST refs).
13883 let tpl = tpl_frame.map(|t| crate::mvstack::TplArgs {13983 let tpl = tpl_frame.map(|t| crate::mvstack::TplArgs {
13884 field: t.field,13984 field: t.field,
13885 cur_offset_0: crate::motion_field::get_relative_dist(13985 cur_offset_0: crate::motion_field::get_relative_dist(
13886 t.order_hint_bits,13986 t.order_hint_bits,
13887 t.order_hint,13987 t.order_hint,
13888- t.ref_order_hints[(LAST_FRAME - LAST_FRAME) as usize],13988+ t.ref_order_hints[(ref_frame - LAST_FRAME) as usize],
13889 ),13989 ),
13890 allow_high_precision_mv,13990 allow_high_precision_mv,
13891 });13991 });
13892- let stack = find_mv_stack_with_sign_bias(13992+ let stack = crate::mvstack::find_mv_stack_with_sign_bias(
13893 grid,13993 grid,
13894 mi_row,13994 mi_row,
13895 mi_col,13995 mi_col,
13896 2,13996 2,
13897 2,13997 2,
13898- LAST_FRAME,13998+ ref_frame,
13899 mi_cols as usize,13999 mi_cols as usize,
13900 mi_rows as usize,14000 mi_rows as usize,
13901 sign_bias_table,14001 sign_bias_table,
@@ -13904,6 +14004,7 @@ fn decode_inter_block8(
13904 );14004 );
13905 14005
13906 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;14006 let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1;
14007+ let mut is_globalmv = false;
13907 let (mv, is_new_mv) = if !not_new {14008 let (mv, is_new_mv) = if !not_new {
13908 // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0):14009 // NEWMV (spec 5.11.24's `read_drl_idx`, `RefMvIdx` starting at 0):
13909 // read at most two `drl_mode` bits, one per stack entry past the14010 // read at most two `drl_mode` bits, one per stack entry past the
@@ -13932,21 +14033,27 @@ fn decode_inter_block8(
13932 )14033 )
13933 } else {14034 } else {
13934 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;14035 let not_zero = dec.symbol(&mut cdfs.zero_mv[stack.zero_mv_ctx]) == 1;
13935- if !not_zero {14036+ is_globalmv = !not_zero;
13936- return Err(unsupported("GLOBALMV (round 3)"));14037+ let mv = if !not_zero {
13937- }14038+ // lane-gmaffine r1: GLOBALMV (spec 7.10.2.1) -- the same
13938- let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;14039+ // `gm_get_motion_vector` value the 16x16+ leaf reads out of
13939- let mv = if nearest {14040+ // its own `gm_table`, computed at this block's centre.
13940- stack.nearest_mv14041+ GLOBALMV_HITS_8.with(|c| c.set(c.get() + 1));
14042+ gm_table[(ref_frame - LAST_FRAME) as usize]
13941 } else {14043 } else {
13942- let mut idx = 1usize;14044+ let nearest = dec.symbol(&mut cdfs.ref_mv[stack.ref_mv_ctx]) == 0;
13943- while idx < 3 && stack.entries.len() > idx + 1 {14045+ if nearest {
13944- if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {14046+ stack.nearest_mv
13945- break;14047+ } else {
14048+ let mut idx = 1usize;
14049+ while idx < 3 && stack.entries.len() > idx + 1 {
14050+ if dec.symbol(&mut cdfs.drl_mode[stack.drl_ctx[idx]]) == 0 {
14051+ break;
14052+ }
14053+ idx += 1;
13946 }14054 }
13947- idx += 1;14055+ stack.entries.get(idx).map_or(stack.near_mv, |e| e.mv)
13948 }14056 }
13949- stack.entries.get(idx).map_or(stack.near_mv, |e| e.mv)
13950 };14057 };
13951 (mv, false)14058 (mv, false)
13952 };14059 };
@@ -13989,11 +14096,22 @@ fn decode_inter_block8(
13989 // 16x16 leaf's own `decode_inter_block` read (see its doc above) --14096 // 16x16 leaf's own `decode_inter_block` read (see its doc above) --
13990 // same 2-symbol `obmc_cdf` alphabet, same `allow_warped_motion=1`14097 // same 2-symbol `obmc_cdf` alphabet, same `allow_warped_motion=1`
13991 // refusal (warp needs `av1_findSamples`, not ported at either leaf).14098 // refusal (warp needs `av1_findSamples`, not ported at either leaf).
14099+ // lane-gmaffine r1: the two libaom predicates, exactly as the
14100+ // 16x16+ leaf resolves them (see [`decode_inter_block`]'s own doc):
14101+ // `is_global_mv_block` (mode GLOBAL*, model > TRANSLATION, block
14102+ // >= 8x8 -- BLOCK_8X8 IS the 8px minimum, so the size predicate is
14103+ // always true here) suppresses the motion_mode read entirely and
14104+ // turns on the global warp below.
14105+ let gm_ref = &global_motion[(ref_frame - LAST_FRAME) as usize];
14106+ let is_global_mv_block = is_globalmv && gm_ref.model as u8 > 1;
13992 let motion_mode_eligible = switchable_motion_mode14107 let motion_mode_eligible = switchable_motion_mode
13993 && !skip_mode14108 && !skip_mode
13994 && interintra_mode.is_none()14109 && interintra_mode.is_none()
14110+ && !(is_global_mv_block && !force_integer_mv)
13995 && (!overlappable_above(grid, mi_row, mi_col, 2, mi_cols as usize, 1).is_empty()14111 && (!overlappable_above(grid, mi_row, mi_col, 2, mi_cols as usize, 1).is_empty()
13996 || !overlappable_left(grid, mi_row, mi_col, 2, mi_rows as usize, 1).is_empty());14112 || !overlappable_left(grid, mi_row, mi_col, 2, mi_rows as usize, 1).is_empty());
14113+ let mut warp_params: Option<crate::warp::WarpParams> = None;
14114+ let mut warped_selected = false;
13997 let mut obmc_selected = false;14115 let mut obmc_selected = false;
13998 if motion_mode_eligible {14116 if motion_mode_eligible {
13999 // lane-warp round 1: same 3-vs-2-symbol split as the 16x16+ leaf14117 // lane-warp round 1: same 3-vs-2-symbol split as the 16x16+ leaf
@@ -14006,7 +14124,7 @@ fn decode_inter_block8(
14006 // runs (see the block8 refusal below, ~12500) -- whoever lifts14124 // runs (see the block8 refusal below, ~12500) -- whoever lifts
14007 // that refusal must add `&& !ref_is_scaled` here too.14125 // that refusal must add `&& !ref_is_scaled` here too.
14008 let warp_eligible = allow_warped_motion14126 let warp_eligible = allow_warped_motion
14009- && num_proj_ref(grid, mi_row, mi_col, 2, 2, mi_cols as usize, mi_rows as usize, LAST_FRAME) >= 1;14127+ && num_proj_ref(grid, mi_row, mi_col, 2, 2, mi_cols as usize, mi_rows as usize, ref_frame) >= 1;
14010 if warp_eligible {14128 if warp_eligible {
14011 let mode = dec.symbol(&mut cdfs.motion_mode[0]);14129 let mode = dec.symbol(&mut cdfs.motion_mode[0]);
14012 match mode {14130 match mode {
@@ -14017,12 +14135,41 @@ fn decode_inter_block8(
14017 OBMC_HITS_8.with(|c| c.set(c.get() + 1));14135 OBMC_HITS_8.with(|c| c.set(c.get() + 1));
14018 }14136 }
14019 _ => {14137 _ => {
14138+ // lane-gmaffine r1: WARPED_CAUSAL at the 8x8 leaf --
14139+ // the same findSamples -> select_samples ->
14140+ // av1_find_projection chain the 16x16+ leaf runs,
14141+ // with BLOCK_8X8's own 8x8 model centre; an
14142+ // unusable projection falls back to the block's
14143+ // translational mv (libaom `av1_find_projection`
14144+ // returning 1 leaves `wm_params` invalid and
14145+ // `build_inter_predictors` skips the warp).
14020 WARP_SELECTED_HITS.with(|c| c.set(c.get() + 1));14146 WARP_SELECTED_HITS.with(|c| c.set(c.get() + 1));
14021- return Err(unsupported(14147+ let mut samples = find_samples(
14022- "an 8x8 leaf that coded WARPED_CAUSAL (motion_mode == 2): \14148+ grid,
14023- av1_find_projection/the affine warp filter are not \14149+ mi_row,
14024- ported, only motion_mode_allowed's alphabet choice is",14150+ mi_col,
14025- ));14151+ 2,
14152+ 2,
14153+ mi_cols as usize,
14154+ mi_rows as usize,
14155+ ref_frame,
14156+ );
14157+ if samples.len() > 1 {
14158+ crate::warp::select_samples(mv, &mut samples, SIDE as i32, SIDE as i32);
14159+ }
14160+ warp_params = crate::warp::find_projection(
14161+ &samples,
14162+ SIDE as i32,
14163+ SIDE as i32,
14164+ mv.1,
14165+ mv.0,
14166+ mi_row as i32,
14167+ mi_col as i32,
14168+ );
14169+ warped_selected = true;
14170+ if warp_params.is_some() {
14171+ WARP_HITS_8.with(|c| c.set(c.get() + 1));
14172+ }
14026 }14173 }
14027 }14174 }
14028 } else {14175 } else {
@@ -14034,6 +14181,78 @@ fn decode_inter_block8(
14034 }14181 }
14035 }14182 }
14036 }14183 }
14184+ // lane-gmaffine r1: `read_mb_interp_filter` (spec 5.11.26) at the 8x8
14185+ // leaf, in libaom's own order (interintra, motion_mode, THEN the
14186+ // filter). Until this round the leaf read no filter symbol at all and
14187+ // predicted Regular unconditionally -- correct only for a frame with a
14188+ // fixed `interp_filter`, and a silent entropy DESYNC for every
14189+ // SWITCHABLE-filter stream that reaches an 8x8 leaf (which is what
14190+ // made the interior-split wiring above unusable at first).
14191+ // corner-cut: the neighbour filter context is the enclosing 16x16
14192+ // block's own coarse `above_filter`/`left_filter` entry (this leaf
14193+ // path keeps no per-leaf neighbour array), so all four siblings read
14194+ // the same context row. Ceiling: a stream whose 8x8 siblings pick
14195+ // DIFFERENT filters decodes the second..fourth leaf's symbol from the
14196+ // wrong CDF row. Upgrade: give `Neighbours` a real 8x8-granular
14197+ // filter array, same shape as the `[3, 3]` approximation the caller
14198+ // records after the leaf loop.
14199+ let above_filter_ctx = if neighbours.above_ref[cmi] == ref_frame
14200+ || neighbours.above_ref1[cmi] == Some(ref_frame)
14201+ {
14202+ neighbours.above_filter[cmi]
14203+ } else {
14204+ [3, 3]
14205+ };
14206+ let left_filter_ctx = if neighbours.left_ref[rmi] == ref_frame
14207+ || neighbours.left_ref1[rmi] == Some(ref_frame)
14208+ {
14209+ neighbours.left_filter[rmi]
14210+ } else {
14211+ [3, 3]
14212+ };
14213+ let gm_nontrans =
14214+ is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation;
14215+ let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
14216+ dec,
14217+ cdfs,
14218+ interp_fixed,
14219+ enable_dual_filter,
14220+ gm_nontrans || warped_selected || skip_mode,
14221+ above_filter_ctx,
14222+ left_filter_ctx,
14223+ false,
14224+ );
14225+ leaf_filter_syms = resolved_filter;
14226+ if std::env::var_os("EC_TRACE_MODE").is_some() {
14227+ eprintln!(
14228+ "EC_MODE_VAL8 mi_row={} mi_col={} newmv={is_new_mv} globalmv={is_globalmv} ref0={ref_frame} mv0=({},{}) stack={} rng={}",
14229+ leaf_mi.0,
14230+ leaf_mi.1,
14231+ mv.0,
14232+ mv.1,
14233+ stack.entries.len(),
14234+ dec.debug_state().0
14235+ );
14236+ }
14237+ // lane-gmaffine r1: `allow_warp`'s `global_warp_allowed` branch
14238+ // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` --
14239+ // see [`decode_inter_block`]'s own copy. A local WARPED_CAUSAL model
14240+ // wins (`is_none()` guard); BLOCK_8X8 already satisfies the >=8px
14241+ // size predicate baked into `is_global_mv_block`.
14242+ if warp_params.is_none() && is_global_mv_block && !force_integer_mv && !gm_ref.invalid {
14243+ warp_params = crate::warp::global_warp_params(gm_ref.params);
14244+ if warp_params.is_some() && gm_ref.model == ec_av1_syntax::WarpModel::Affine {
14245+ AFFINE_GM_HITS.with(|c| c.set(c.get() + 1));
14246+ }
14247+ }
14248+ if std::env::var_os("EC_TRACE_MODE").is_some() {
14249+ eprintln!(
14250+ "EC_WARP8 mi_row={} mi_col={} warp={} globalblk={is_global_mv_block}",
14251+ leaf_mi.0,
14252+ leaf_mi.1,
14253+ warp_params.is_some(),
14254+ );
14255+ }
14037 for dr in 0..2 {14256 for dr in 0..2 {
14038 for dc in 0..2 {14257 for dc in 0..2 {
14039 grid.set(14258 grid.set(
@@ -14041,7 +14260,7 @@ fn decode_inter_block8(
14041 mi_col + dc,14260 mi_col + dc,
14042 MiInfo {14261 MiInfo {
14043 is_inter: true,14262 is_inter: true,
14044- ref_frame: LAST_FRAME,14263+ ref_frame,
14045 // INTRA_FRAME marker for interintra blocks -- keeps14264 // INTRA_FRAME marker for interintra blocks -- keeps
14046 // them out of warp-sample gathering (see 16/32 site).14265 // them out of warp-sample gathering (see 16/32 site).
14047 ref_frame1: interintra_mode.map(|_| 0),14266 ref_frame1: interintra_mode.map(|_| 0),
@@ -14050,7 +14269,7 @@ fn decode_inter_block8(
14050 is_new_mv,14269 is_new_mv,
14051 size: 2,14270 size: 2,
14052 size_h: 2,14271 size_h: 2,
14053- is_global_mv0: false,14272+ is_global_mv0: is_global_mv_block,
14054 is_global_mv1: false,14273 is_global_mv1: false,
14055 },14274 },
14056 );14275 );
@@ -14061,21 +14280,24 @@ fn decode_inter_block8(
14061 // lane-scaledref r1: this leaf's own prediction is always `Regular`14280 // lane-scaledref r1: this leaf's own prediction is always `Regular`
14062 // (documented corner-cut above); under a scaled reference the same14281 // (documented corner-cut above); under a scaled reference the same
14063 // fixed kernel runs through spec 7.11.3.3's scaled walk instead.14282 // fixed kernel runs through spec 7.11.3.3's scaled walk instead.
14064- let luma_scale = mc::scale_factor(ref_y.width, frame_width);14283+ let luma_scale = mc::scale_factor(sref_y.width, frame_width);
14065 if luma_scale != mc::REF_NO_SCALE {14284 if luma_scale != mc::REF_NO_SCALE {
14066 SCALED_BLOCK8_HITS.with(|c| c.set(c.get() + 1));14285 SCALED_BLOCK8_HITS.with(|c| c.set(c.get() + 1));
14067 }14286 }
14068 let mut pred_y = vec![0u16; SIDE * SIDE];14287 let mut pred_y = vec![0u16; SIDE * SIDE];
14069 let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];14288 let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];
14070 let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];14289 let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE];
14290+ // Merge of lane-gmaffine (this leaf's own switchable filters) with
14291+ // lane-scaledref (spec 7.11.3.3's scaled walk): same kernels either
14292+ // way, only the sample walk differs.
14071 for (plane, x, y, dim, dst) in [14293 for (plane, x, y, dim, dst) in [
14072- (ref_y, px, py, SIDE, &mut pred_y),14294+ (sref_y, px, py, SIDE, &mut pred_y),
14073- (ref_u, cpx, cpy, CHROMA_SIDE, &mut pred_u),14295+ (sref_u, cpx, cpy, CHROMA_SIDE, &mut pred_u),
14074- (ref_v, cpx, cpy, CHROMA_SIDE, &mut pred_v),14296+ (sref_v, cpx, cpy, CHROMA_SIDE, &mut pred_v),
14075 ] {14297 ] {
14076- let luma = std::ptr::eq(plane, ref_y);14298+ let luma = std::ptr::eq(plane, sref_y);
14077 if luma_scale == mc::REF_NO_SCALE {14299 if luma_scale == mc::REF_NO_SCALE {
14078- mc::predict(14300+ mc::predict_with_filters(
14079 &plane.data,14301 &plane.data,
14080 plane.width,14302 plane.width,
14081 plane.true_width,14303 plane.true_width,
@@ -14084,6 +14306,8 @@ fn decode_inter_block8(
14084 mv_to_q4(y, mv.0, luma),14306 mv_to_q4(y, mv.0, luma),
14085 dim,14307 dim,
14086 dim,14308 dim,
14309+ h_filter,
14310+ v_filter,
14087 dst,14311 dst,
14088 );14312 );
14089 } else {14313 } else {
@@ -14097,13 +14321,40 @@ fn decode_inter_block8(
14097 luma_scale,14321 luma_scale,
14098 dim,14322 dim,
14099 dim,14323 dim,
14100- mc::InterpFilterKind::Regular,14324+ h_filter,
14101- mc::InterpFilterKind::Regular,14325+ v_filter,
14102 dst,14326 dst,
14103 );14327 );
14104 }14328 }
14105 }14329 }
14106 14330
14331+ // lane-gmaffine r1: the warp filter REPLACES the translational
14332+ // prediction just built (libaom builds one or the other), same as
14333+ // the 16x16+ leaf's own call trio.
14334+ if let Some(params) = &warp_params {
14335+ crate::warp::warp_affine(
14336+ params, &sref_y.data, sref_y.true_width as i32, sref_y.true_height as i32,
14337+ sref_y.width as i32, &mut pred_y, px as i32, py as i32, SIDE as i32,
14338+ SIDE as i32, SIDE as i32, 0, 0,
14339+ );
14340+ // `av1_init_warp_params`'s per-plane `block_width/height < 8`
14341+ // bail-out: an 8x8 leaf's chroma plane is 4x4 in 420, so it is
14342+ // predicted translationally even when the luma warps.
14343+ #[allow(clippy::absurd_extreme_comparisons)]
14344+ if CHROMA_SIDE >= 8 {
14345+ crate::warp::warp_affine(
14346+ params, &sref_u.data, sref_u.true_width as i32, sref_u.true_height as i32,
14347+ sref_u.width as i32, &mut pred_u, cpx as i32, cpy as i32, CHROMA_SIDE as i32,
14348+ CHROMA_SIDE as i32, CHROMA_SIDE as i32, 1, 1,
14349+ );
14350+ crate::warp::warp_affine(
14351+ params, &sref_v.data, sref_v.true_width as i32, sref_v.true_height as i32,
14352+ sref_v.width as i32, &mut pred_v, cpx as i32, cpy as i32, CHROMA_SIDE as i32,
14353+ CHROMA_SIDE as i32, CHROMA_SIDE as i32, 1, 1,
14354+ );
14355+ }
14356+ }
14357+
14107 if obmc_selected {14358 if obmc_selected {
14108 obmc_blend(14359 obmc_blend(
14109 grid,14360 grid,
@@ -14437,13 +14688,23 @@ fn decode_inter_block8(
14437 neighbours.above[leaf_mi.1 + cell][0] = state;14688 neighbours.above[leaf_mi.1 + cell][0] = state;
14438 }14689 }
14439 }14690 }
14691+ // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference
14692+ // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every
14693+ // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test).
14440 neighbours.fill_lf_grid(14694 neighbours.fill_lf_grid(
14441 leaf_mi,14695 leaf_mi,
14442 2,14696 2,
14443 if split8 { 4 } else { 8 },14697 if split8 { 4 } else { 8 },
14444- if is_inter { LAST_FRAME } else { 0 },14698+ if is_inter { leaf_refs.0.max(LAST_FRAME) } else { 0 },
14445 );14699 );
14446- Ok((skip, is_inter, skip_mode, compound_ctx8, leaf_refs))14700+ Ok((
14701+ skip,
14702+ is_inter,
14703+ skip_mode,
14704+ compound_ctx8,
14705+ leaf_filter_syms,
14706+ leaf_refs,
14707+ ))
14447 }14708 }
14448 14709
14449 /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes,14710 /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes,
@@ -15204,8 +15465,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
15204 ));15465 ));
15205 }15466 }
15206 let mut prev_leaves: Vec<((usize, usize), bool, bool, i8, Option<i8>)> = Vec::new();15467 let mut prev_leaves: Vec<((usize, usize), bool, bool, i8, Option<i8>)> = Vec::new();
15207- let mut last_compound_ctx: Option<(i8, i8, u8, u8)> = None;
15208- let mut last_skip_mode = false;
15209 for (mr, mc) in leaf_positions {15468 for (mr, mc) in leaf_positions {
15210 let leaf_mi = (mr as usize, mc as usize);15469 let leaf_mi = (mr as usize, mc as usize);
15211 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);15470 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
@@ -15215,8 +15474,14 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
15215 "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)",15474 "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)",
15216 ));15475 ));
15217 }15476 }
15218- let (skip, is_inter, skip_mode_leaf, compound_ctx8, leaf_refs) =15477+ let (
15219- decode_inter_block8(15478+ skip,
15479+ is_inter,
15480+ skip_mode_leaf,
15481+ compound_ctx8,
15482+ leaf_filter,
15483+ leaf_refs,
15484+ ) = decode_inter_block8(
15220 &mut dec,15485 &mut dec,
15221 &mut cdfs,15486 &mut cdfs,
15222 &mut neighbours,15487 &mut neighbours,
@@ -15237,6 +15502,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
15237 &scan4,15502 &scan4,
15238 allow_high_precision_mv,15503 allow_high_precision_mv,
15239 force_integer_mv,15504 force_integer_mv,
15505+ &global_motion,
15506+ enable_dual_filter,
15240 reference_select,15507 reference_select,
15241 enable_masked_compound,15508 enable_masked_compound,
15242 enable_interintra_compound,15509 enable_interintra_compound,
@@ -15252,15 +15519,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
15252 allow_warped_motion,15519 allow_warped_motion,
15253 allow_screen_content_tools,15520 allow_screen_content_tools,
15254 &sign_bias_table,15521 &sign_bias_table,
15255- &global_motion,
15256 tpl_frame.as_ref(),15522 tpl_frame.as_ref(),
15257 frame_width as usize,15523 frame_width as usize,
15258 )?;15524 )?;
15259 prev_leaves.push((leaf_mi, skip, is_inter, leaf_refs.0, leaf_refs.1));15525 prev_leaves.push((leaf_mi, skip, is_inter, leaf_refs.0, leaf_refs.1));
15260- last_skip_mode = skip_mode_leaf;
15261- if compound_ctx8.is_some() {
15262- last_compound_ctx = compound_ctx8;
15263- }
15264 // lane-inter8 r2: stamp THIS leaf's own15526 // lane-inter8 r2: stamp THIS leaf's own
15265 // 2x2-mi span before the next leaf reads15527 // 2x2-mi span before the next leaf reads
15266 // it as a neighbour -- the whole-16x1615528 // it as a neighbour -- the whole-16x16
@@ -15269,9 +15531,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
15269 // block carried the wrong skip/ref/inter15531 // block carried the wrong skip/ref/inter
15270 // state into the next block's contexts15532 // state into the next block's contexts
15271 // (class context-read-from-one-cell).15533 // (class context-read-from-one-cell).
15272- // corner-cut: `[3, 3]` filter, as the15534+ // lane-gmaffine r3: with the mi-granular
15273- // 16x16 stamp used -- `decode_inter_block8`15535+ // band, the leaf's OWN switchable-filter
15274- // reads no switchable filter yet.15536+ // symbols go in here -- the `[3, 3]`
15537+ // ("intra, no filter") sentinel this used
15538+ // to stamp made `obmc_blend`'s
15539+ // `neighbour_filter` PANIC as soon as a
15540+ // sibling leaf blended one of these.
15275 neighbours.record_inter_rect_mi(15541 neighbours.record_inter_rect_mi(
15276 leaf_mi,15542 leaf_mi,
15277 2,15543 2,
@@ -15279,7 +15545,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
15279 skip,15545 skip,
15280 is_inter,15546 is_inter,
15281 leaf_refs.0,15547 leaf_refs.0,
15282- [3, 3],15548+ leaf_filter,
15283 skip_mode_leaf,15549 skip_mode_leaf,
15284 );15550 );
15285 if let Some(ref1) = leaf_refs.115551 if let Some(ref1) = leaf_refs.1
crates/ec-av1/src/refusal_inventory.rsmodified+0 -4
@@ -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",
@@ -59,14 +58,11 @@ const REFUSALS: &[&str] = &[
59 "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)",
60 "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",
61 "a palette block with a split luma transform (round 1)",60 "a palette block with a split luma transform (round 1)",
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",61 "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",62 "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",63 "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",64 "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)",65 "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",66 "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)",67 "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)",68 "a masked compound 64x64 inter block (compound_type is inferred, not coded, at this size)",
crates/ec-av1/src/stream.rsmodified+414 -13
@@ -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
@@ -6300,8 +6303,11 @@ mod tests {
6300 }6303 }
6301 }6304 }
6302 gate_buckets(NAME, 0, never_fired, refusals.len());6305 gate_buckets(NAME, 0, never_fired, refusals.len());
6303- eprintln!(6306+ // lane-gmaffine r2: this gate fired for three rounds only as a SKIP
6304- "SKIP {NAME}: {never_fired} attempts decoded but never fired an 8x8 obmc block \6307+ // (gate-skips-on-its-own-failure); the 8x8 leaf is reachable now, so a
6308+ // sweep that never lands one firing pixel-exact attempt is a FAILURE.
6309+ panic!(
6310+ "{NAME}: {never_fired} attempts decoded but never fired an 8x8 obmc block \
6305 ({total_obmc8} total 8x8 obmc hits across all attempts), and every other attempt \6311 ({total_obmc8} total 8x8 obmc hits across all attempts), and every other attempt \
6306 hit a named refusal:\n{}",6312 hit a named refusal:\n{}",
6307 refusals.join("\n")6313 refusals.join("\n")
@@ -7403,6 +7409,401 @@ mod tests {
7403 );7409 );
7404 }7410 }
7405 7411
7412+ /// The affine-capable encoder (`scripts/build-aom-affine-oracle.sh`),
7413+ /// separate from the shared oracle because stock libaom's global-motion
7414+ /// model search is pinned to ROTZOOM and can never emit AFFINE.
7415+ fn affine_aomenc_path() -> std::path::PathBuf {
7416+ if let Some(p) = std::env::var_os("EC_AV1_AFFINE_AOMENC") {
7417+ return std::path::PathBuf::from(p);
7418+ }
7419+ let home = std::env::var_os("HOME").unwrap_or_default();
7420+ std::path::PathBuf::from(home).join(".cache/aom-affine/build/aomenc")
7421+ }
7422+
7423+ fn have_affine_aomenc() -> bool {
7424+ let present = affine_aomenc_path().is_file();
7425+ assert!(
7426+ present || std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none(),
7427+ "EC_AV1_REQUIRE_AOMENC is set but no affine-capable aomenc at {} -- run \
7428+ scripts/build-aom-affine-oracle.sh",
7429+ affine_aomenc_path().display()
7430+ );
7431+ present
7432+ }
7433+
7434+ /// lane-gmaffine r1: an inter frame whose `global_motion_params` carries a
7435+ /// SIX-parameter (`AFFINE`) model for a single-reference frame -- refused
7436+ /// by name since lane-gm r4 because no aomenc recipe ever reached it.
7437+ /// The reason it never did is in libaom's own encoder, not in the
7438+ /// content: `av1/encoder/global_motion_facade.c:24` pins the model search
7439+ /// to `ROTZOOM` at both ends, so *no* `--enable-global-motion=1` command
7440+ /// line over any source can produce the case. The decoder must still
7441+ /// handle it (the bitstream allows it, `read_global_motion_params` reads
7442+ /// params 4/5 with their own subexp references, and ffmpeg decodes it),
7443+ /// so this gate widens exactly that one encoder-side search range in a
7444+ /// side build and encodes with it. Everything downstream is ordinary
7445+ /// libaom and the pixel oracle is still ffmpeg.
7446+ ///
7447+ /// Content: rotation composed with a progressive *anisotropic* stretch --
7448+ /// a similarity transform plus unequal axis scaling is precisely what a
7449+ /// 4-parameter ROTZOOM model cannot express, which is what makes the
7450+ /// encoder's RD pick AFFINE. `affine_gm_hits()` hard-asserts that real
7451+ /// blocks were predicted through the 6-parameter warp, not merely that a
7452+ /// header parsed one (class `gate-blind-to-feature`).
7453+ #[test]
7454+ fn a_real_affine_global_motion_stream_decodes_pixel_exact() {
7455+ const NAME: &str = "a_real_affine_global_motion_stream_decodes_pixel_exact";
7456+ let _gate_lock = lock_gate_counters();
7457+ if !have_ffmpeg() {
7458+ eprintln!("SKIP {NAME}: no ffmpeg");
7459+ return;
7460+ }
7461+ if !have_affine_aomenc() {
7462+ eprintln!(
7463+ "SKIP {NAME}: no affine-capable aomenc at {} (scripts/build-aom-affine-oracle.sh)",
7464+ affine_aomenc_path().display()
7465+ );
7466+ return;
7467+ }
7468+ let (width, height, frame_count) = (64usize, 64usize, 24usize);
7469+ let duration = frame_count as f64 / 25.0;
7470+ // Both depths: his own AV1 library is yuv420p10le throughout, and a
7471+ // 10-bit AFFINE warp runs the same `warp_affine` over wider samples.
7472+ for depth in [8u32, 10u32] {
7473+ // `-t` is the real bound on mandelbrot (it ignores `end_pts` and
7474+ // has hung a gate for an hour); the 96x96 source is rotated and
7475+ // then stretched horizontally only, and cropped back to 64x64.
7476+ let source = format!(
7477+ "mandelbrot=size=96x96:rate=25,rotate=a=0.12*t:c=black,\
7478+ scale=w='ceil(96*(1+0.03*n)/2)*2':h=96:eval=frame,crop={width}:{height}"
7479+ );
7480+ let pix_fmt = if depth == 10 { "yuv420p10le" } else { "yuv420p" };
7481+ let mut ff_args: Vec<&str> =
7482+ vec!["-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", pix_fmt];
7483+ // y4m has no official 10-bit tag, same as the 10-bit gate above.
7484+ if depth == 10 {
7485+ ff_args.extend(["-strict", "-1"]);
7486+ }
7487+ let duration_arg = duration.to_string();
7488+ ff_args.extend(["-t", &duration_arg, "-f", "yuv4mpegpipe", "-"]);
7489+ let y4m = Command::new("ffmpeg")
7490+ .args(&ff_args)
7491+ .stdin(Stdio::null())
7492+ .stdout(Stdio::piped())
7493+ .stderr(Stdio::piped())
7494+ .output()
7495+ .expect("ffmpeg failed to run");
7496+ assert!(
7497+ y4m.status.success(),
7498+ "ffmpeg fixture: {}",
7499+ String::from_utf8_lossy(&y4m.stderr)
7500+ );
7501+ let bit_depth = format!("--bit-depth={depth}");
7502+ let input_bit_depth = format!("--input-bit-depth={depth}");
7503+ let args: Vec<&str> = vec![
7504+ "--codec=av1",
7505+ "--passes=1",
7506+ "--end-usage=q",
7507+ "--cq-level=45",
7508+ "--cpu-used=0",
7509+ "--kf-max-dist=1000",
7510+ "--threads=1",
7511+ "--row-mt=0",
7512+ "--auto-alt-ref=0",
7513+ "--lag-in-frames=0",
7514+ "--enable-fwd-kf=0",
7515+ "--enable-order-hint=1",
7516+ "--enable-global-motion=1",
7517+ "--enable-warped-motion=0",
7518+ "--enable-obmc=0",
7519+ "--tune-content=default",
7520+ "--enable-masked-comp=0",
7521+ "--enable-interintra-comp=0",
7522+ "--enable-onesided-comp=0",
7523+ "--enable-rect-partitions=0",
7524+ "--enable-ab-partitions=0",
7525+ "--enable-1to4-partitions=0",
7526+ "--enable-filter-intra=0",
7527+ "--enable-smooth-intra=0",
7528+ "--enable-paeth-intra=0",
7529+ "--enable-directional-intra=0",
7530+ "--enable-angle-delta=0",
7531+ "--enable-tx-size-search=0",
7532+ "--enable-cdef=0",
7533+ "--enable-restoration=0",
7534+ "--max-partition-size=32",
7535+ "--min-partition-size=32",
7536+ "--enable-palette=0",
7537+ "--enable-intrabc=0",
7538+ "--enable-cfl-intra=0",
7539+ "--enable-ref-frame-mvs=0",
7540+ &bit_depth,
7541+ &input_bit_depth,
7542+ "--obu",
7543+ "-o",
7544+ "-",
7545+ "-",
7546+ ];
7547+ let mut child = Command::new(affine_aomenc_path())
7548+ .args(&args)
7549+ .stdin(Stdio::piped())
7550+ .stdout(Stdio::piped())
7551+ .stderr(Stdio::piped())
7552+ .spawn()
7553+ .expect("affine aomenc failed to start");
7554+ child
7555+ .stdin
7556+ .take()
7557+ .expect("aomenc stdin")
7558+ .write_all(&y4m.stdout)
7559+ .expect("writing y4m to aomenc");
7560+ let out = child.wait_with_output().expect("aomenc failed to run");
7561+ assert!(
7562+ out.status.success(),
7563+ "aomenc refused the fixture: {}",
7564+ String::from_utf8_lossy(&out.stderr)
7565+ );
7566+ let stream = out.stdout;
7567+ let before = crate::decode::affine_gm_hits();
7568+ let frames =
7569+ decode_stream(&stream).unwrap_or_else(|e| panic!("{NAME} ({depth}-bit): {e}"));
7570+ let ffmpeg_frames = if depth == 10 {
7571+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
7572+ } else {
7573+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
7574+ };
7575+ assert_eq!(frames.len(), frame_count);
7576+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7577+ assert_eq!(got.y, want.y, "{NAME} {depth}-bit frame {i} luma vs ffmpeg");
7578+ assert_eq!(got.u, want.u, "{NAME} {depth}-bit frame {i} U vs ffmpeg");
7579+ assert_eq!(got.v, want.v, "{NAME} {depth}-bit frame {i} V vs ffmpeg");
7580+ }
7581+ let hits = crate::decode::affine_gm_hits() - before;
7582+ assert!(
7583+ hits > 0,
7584+ "{NAME} ({depth}-bit): decoded pixel-exact but no block was predicted through a \
7585+ 6-parameter global-motion warp -- the AFFINE path is unexercised"
7586+ );
7587+ eprintln!("{NAME}: {depth}-bit, {frame_count} frames pixel-exact, affine_gm_hits={hits}");
7588+ }
7589+ }
7590+
7591+ /// lane-gmaffine r1: the two 8x8-LEAF motion gates. `decode_inter_block8`
7592+ /// is a separate function from [`decode_inter_block`], and until this
7593+ /// round it refused both `GLOBALMV` ("GLOBALMV (round 3)") and
7594+ /// `WARPED_CAUSAL` at that size while the 16x16+ leaf had implemented
7595+ /// both for rounds. The reason no earlier gate caught it: the existing
7596+ /// 8x8 OBMC gate clamps `--max-partition-size=32` and aomenc's RD then
7597+ /// never splits down to a clean 8x8 leaf (that gate has never fired in
7598+ /// 80 attempts). `--min-partition-size=8 --max-partition-size=8` removes
7599+ /// the choice entirely -- every inter leaf in the stream IS an 8x8 one,
7600+ /// so the leaf path is exercised by construction rather than by luck.
7601+ ///
7602+ /// Content is the affine gate's rotating/zooming mandelbrot (global
7603+ /// motion the encoder can actually model), and the hit counters
7604+ /// (`globalmv_hits_8` / `warp_hits_8`) are 8x8-leaf-specific: a
7605+ /// 16x16-leaf GLOBALMV or warp cannot satisfy them.
7606+ fn run_8x8_leaf_motion_gate(
7607+ name: &str,
7608+ global_motion: bool,
7609+ counter: fn() -> usize,
7610+ ) {
7611+ // 72x64: `decode_inter_block8` is reached ONLY through the
7612+ // true-edge-straddling 16x16 path (an interior 16x16
7613+ // PARTITION_SPLIT is still refused by name), so the frame is 8
7614+ // luma columns wider than its last whole superblock -- every 16x16
7615+ // block in that right-hand strip is cut on ONE axis and decodes as
7616+ // four 8x8 leaves by construction. `--min-partition-size=16` keeps
7617+ // the interior out of the still-refused sub-16x16 case.
7618+ let (width, height, frame_count) = (64usize, 64usize, 24usize);
7619+ let duration = frame_count as f64 / 25.0;
7620+ // The encoder's own RD still chooses WHICH 8x8 leaf codes GLOBALMV /
7621+ // WARPED_CAUSAL, and at some quantisers it picks a rect partition at
7622+ // 16x16 (still refused) or a non-LAST reference (still refused at the
7623+ // 8x8 leaf) before ever reaching one. So sweep a few quantisers and
7624+ // require at least one attempt, at each depth, that BOTH decodes
7625+ // pixel-exact AND fires the counter -- a refusing attempt is recorded,
7626+ // never a pass (class `gate-skips-on-its-own-failure`).
7627+ let mut fired_any = [false; 2];
7628+ let mut notes: Vec<String> = Vec::new();
7629+ for (di, depth) in [8u32, 10u32].into_iter().enumerate() {
7630+ for cq in [32u32, 45, 55] {
7631+ let cq_arg = format!("--cq-level={cq}");
7632+ let max_part_arg = format!(
7633+ "--max-partition-size={}",
7634+ std::env::var("EC_8X8_MAXPART").unwrap_or_else(|_| "8".into())
7635+ );
7636+ let source = format!(
7637+ "mandelbrot=size=96x96:rate=25,rotate=a=0.12*t:c=black,\
7638+ scale=w='ceil(96*(1+0.03*n)/2)*2':h=96:eval=frame,crop={width}:{height}"
7639+ );
7640+ let pix_fmt = if depth == 10 { "yuv420p10le" } else { "yuv420p" };
7641+ let mut ff_args: Vec<&str> =
7642+ vec!["-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", pix_fmt];
7643+ if depth == 10 {
7644+ ff_args.extend(["-strict", "-1"]);
7645+ }
7646+ let duration_arg = duration.to_string();
7647+ ff_args.extend(["-t", &duration_arg, "-f", "yuv4mpegpipe", "-"]);
7648+ let y4m = Command::new("ffmpeg")
7649+ .args(&ff_args)
7650+ .stdin(Stdio::null())
7651+ .stdout(Stdio::piped())
7652+ .stderr(Stdio::piped())
7653+ .output()
7654+ .expect("ffmpeg failed to run");
7655+ assert!(
7656+ y4m.status.success(),
7657+ "ffmpeg fixture: {}",
7658+ String::from_utf8_lossy(&y4m.stderr)
7659+ );
7660+ let bit_depth = format!("--bit-depth={depth}");
7661+ let input_bit_depth = format!("--input-bit-depth={depth}");
7662+ let gm_arg = format!("--enable-global-motion={}", u8::from(global_motion));
7663+ let warp_arg = format!("--enable-warped-motion={}", u8::from(!global_motion));
7664+ let args: Vec<&str> = vec![
7665+ "--codec=av1",
7666+ "--passes=1",
7667+ "--end-usage=q",
7668+ &cq_arg,
7669+ "--cpu-used=0",
7670+ "--kf-max-dist=1000",
7671+ "--threads=1",
7672+ "--row-mt=0",
7673+ "--auto-alt-ref=0",
7674+ "--lag-in-frames=0",
7675+ "--enable-fwd-kf=0",
7676+ "--enable-order-hint=1",
7677+ &gm_arg,
7678+ &warp_arg,
7679+ "--enable-obmc=0",
7680+ "--tune-content=default",
7681+ "--enable-masked-comp=0",
7682+ "--enable-interintra-comp=0",
7683+ "--enable-onesided-comp=0",
7684+ "--enable-rect-partitions=0",
7685+ "--enable-ab-partitions=0",
7686+ "--enable-1to4-partitions=0",
7687+ "--enable-filter-intra=0",
7688+ "--enable-smooth-intra=0",
7689+ "--enable-paeth-intra=0",
7690+ "--enable-directional-intra=0",
7691+ "--enable-angle-delta=0",
7692+ "--enable-tx-size-search=0",
7693+ "--enable-cdef=0",
7694+ "--enable-restoration=0",
7695+ &max_part_arg,
7696+ "--min-partition-size=8",
7697+ "--enable-palette=0",
7698+ "--enable-intrabc=0",
7699+ "--enable-cfl-intra=0",
7700+ "--enable-ref-frame-mvs=0",
7701+ &bit_depth,
7702+ &input_bit_depth,
7703+ "--obu",
7704+ "-o",
7705+ "-",
7706+ "-",
7707+ ];
7708+ let mut child = Command::new(aomenc_path())
7709+ .args(&args)
7710+ .stdin(Stdio::piped())
7711+ .stdout(Stdio::piped())
7712+ .stderr(Stdio::piped())
7713+ .spawn()
7714+ .expect("aomenc failed to start");
7715+ child
7716+ .stdin
7717+ .take()
7718+ .expect("aomenc stdin")
7719+ .write_all(&y4m.stdout)
7720+ .expect("writing y4m to aomenc");
7721+ let out = child.wait_with_output().expect("aomenc failed to run");
7722+ assert!(
7723+ out.status.success(),
7724+ "aomenc refused the fixture: {}",
7725+ String::from_utf8_lossy(&out.stderr)
7726+ );
7727+ let stream = out.stdout;
7728+ let before = counter();
7729+ let frames = match decode_stream(&stream) {
7730+ Ok(f) => f,
7731+ Err(e) => {
7732+ let msg = e.to_string();
7733+ assert!(
7734+ msg.contains("unsupported"),
7735+ "{name} ({depth}-bit, cq {cq}) failed outright: {msg}"
7736+ );
7737+ notes.push(format!("{depth}-bit cq {cq}: {msg}"));
7738+ continue;
7739+ }
7740+ };
7741+ let ffmpeg_frames = if depth == 10 {
7742+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
7743+ } else {
7744+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
7745+ };
7746+ assert_eq!(frames.len(), frame_count);
7747+ let hits = counter() - before;
7748+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
7749+ assert_eq!(got.y, want.y, "{name} {depth}-bit frame {i} luma vs ffmpeg");
7750+ assert_eq!(got.u, want.u, "{name} {depth}-bit frame {i} U vs ffmpeg");
7751+ assert_eq!(got.v, want.v, "{name} {depth}-bit frame {i} V vs ffmpeg");
7752+ }
7753+ if hits == 0 {
7754+ notes.push(format!(
7755+ "{depth}-bit cq {cq}: {frame_count} frames pixel-exact but 0 8x8-leaf hits"
7756+ ));
7757+ continue;
7758+ }
7759+ fired_any[di] = true;
7760+ eprintln!(
7761+ "{name}: {depth}-bit cq {cq}, {frame_count} frames pixel-exact, 8x8 hits={hits}"
7762+ );
7763+ }
7764+ }
7765+ assert!(
7766+ fired_any[0] && fired_any[1],
7767+ "{name}: no attempt both decoded pixel-exact and fired the 8x8 leaf \
7768+ (8-bit fired {}, 10-bit fired {}):\n{}",
7769+ fired_any[0], fired_any[1], notes.join("\n")
7770+ );
7771+ }
7772+
7773+ /// lane-gmaffine r1 item (3): `GLOBALMV` at an 8x8 leaf, ROTZOOM global
7774+ /// motion, warp built from the frame's own model.
7775+ #[test]
7776+ fn a_real_globalmv_8x8_leaf_stream_decodes_pixel_exact() {
7777+ const NAME: &str = "a_real_globalmv_8x8_leaf_stream_decodes_pixel_exact";
7778+ let _gate_lock = lock_gate_counters();
7779+ if !have_ffmpeg() {
7780+ eprintln!("SKIP {NAME}: no ffmpeg");
7781+ return;
7782+ }
7783+ if !have_aomenc() {
7784+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
7785+ return;
7786+ }
7787+ run_8x8_leaf_motion_gate(NAME, true, crate::decode::globalmv_hits_8);
7788+ }
7789+
7790+ /// lane-gmaffine r1 item (2): `WARPED_CAUSAL` at an 8x8 leaf --
7791+ /// findSamples + `av1_find_projection` + the warp filter at BLOCK_8X8.
7792+ #[test]
7793+ fn a_real_warped_causal_8x8_leaf_stream_decodes_pixel_exact() {
7794+ const NAME: &str = "a_real_warped_causal_8x8_leaf_stream_decodes_pixel_exact";
7795+ let _gate_lock = lock_gate_counters();
7796+ if !have_ffmpeg() {
7797+ eprintln!("SKIP {NAME}: no ffmpeg");
7798+ return;
7799+ }
7800+ if !have_aomenc() {
7801+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
7802+ return;
7803+ }
7804+ run_8x8_leaf_motion_gate(NAME, false, crate::decode::warp_hits_8);
7805+ }
7806+
7406 /// lane-rect16 r1/r2: a plain default-settings aomenc run over lavfi7807 /// lane-rect16 r1/r2: a plain default-settings aomenc run over lavfi
7407 /// `mandelbrot` (`--cpu-used=4 --end-usage=q --cq-level=32`, no7808 /// `mandelbrot` (`--cpu-used=4 --end-usage=q --cq-level=32`, no
7408 /// `--enable-*` flags) used to refuse frame 0 outright with "a partition7809 /// `--enable-*` flags) used to refuse frame 0 outright with "a partition
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.
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"