forge
Explore
Log in

Don't you dare go Hollow

ec-av1: inherit segment maps verbatim (lane-av1seglvl): census ALT_Q-only, map-inheritance stream byte-exact

Browse files at this commit

587b6a0fd26f54e6c21ae48abf00061a67d353b4Ahmet Kaan GümüşParent: e32630c
crates/ec-av1/src/decode.rsmodified+33 -2
@@ -1089,6 +1089,27 @@ fn write_segment_id(mi_r: usize, mi_c: usize, w_mi: usize, h_mi: usize, id: u8,
1089 SEG_IDS_SEEN.with(|c| c.set(c.get() | 1 << id));1089 SEG_IDS_SEEN.with(|c| c.set(c.get() | 1 << id));
1090 }1090 }
1091 1091
1092+/// `copy_segment_id` (libaom `decodemv.c:342`): the previous frame's map is
1093+/// inherited VERBATIM over this block's own mi footprint -- per-cell copies,
1094+/// not the minified id [`predicted_segment_id`] hands the block. Without a
1095+/// previous map the footprint is zeroed, exactly as the C NULL branch does.
1096+fn copy_segment_ids(mi_r: usize, mi_c: usize, w_mi: usize, h_mi: usize, fctx: &crate::decode::FrameCtx) {
1097+ let (mi_rows, mi_cols) = fctx.seg_mi_dims.with(|c| c.get());
1098+ let (x_mis, y_mis) = (w_mi.min(mi_cols.saturating_sub(mi_c)), h_mi.min(mi_rows.saturating_sub(mi_r)));
1099+ fctx.seg_ids.with(|m| {
1100+ let mut m = m.borrow_mut();
1101+ fctx.prev_seg_ids.with(|p| {
1102+ let p = p.borrow();
1103+ for y in 0..y_mis {
1104+ for x in 0..x_mis {
1105+ let idx = (mi_r + y) * mi_cols + mi_c + x;
1106+ m[idx] = p.get(idx).copied().unwrap_or(0);
1107+ }
1108+ }
1109+ });
1110+ });
1111+}
1112+
1092 /// `get_predicted_segment_id` (libaom `dec_get_segment_id` over1113 /// `get_predicted_segment_id` (libaom `dec_get_segment_id` over
1093 /// `last_frame_seg_map`): the minimum previous-frame segment id over the1114 /// `last_frame_seg_map`): the minimum previous-frame segment id over the
1094 /// block's own mi footprint. `0` when there is no previous map.1115 /// block's own mi footprint. `0` when there is no previous map.
@@ -1230,9 +1251,19 @@ fn inter_segment_id(
1230 return;1251 return;
1231 }1252 }
1232 if !update_map {1253 if !update_map {
1233- // The map is inherited wholesale from the previous frame.1254+ // The map is inherited from the previous frame, and libaom's
1255+ // `copy_segment_id` (decodemv.c:342) does that VERBATIM -- a memcpy of
1256+ // the previous map over the block's own footprint, mixed ids intact --
1257+ // while the id the BLOCK itself carries is the min over that footprint
1258+ // (`get_predicted_segment_id`). Stamping the min here flattened mixed
1259+ // footprints into the saved map, and every later frame whose
1260+ // `update_map == 0` copy or temporal prediction read that position
1261+ // dequantized with the wrong segment's `SEG_LVL_ALT_Q` (class
1262+ // `simplified-inheritance`).
1263+ copy_segment_ids(mi_r, mi_c, w_mi, h_mi, fctx);
1234 let id = predicted_segment_id(mi_r, mi_c, w_mi, h_mi, fctx);1264 let id = predicted_segment_id(mi_r, mi_c, w_mi, h_mi, fctx);
1235- write_segment_id(mi_r, mi_c, w_mi, h_mi, id, fctx);1265+ fctx.cur_segment_id.with(|c| c.set(id));
1266+ SEG_IDS_SEEN.with(|c| c.set(c.get() | 1 << id));
1236 return;1267 return;
1237 }1268 }
1238 if pre_skip && !pre_skip_frame {1269 if pre_skip && !pre_skip_frame {
crates/ec-av1/src/refusal_inventory.rsmodified+125 -34
@@ -407,10 +407,18 @@ const PROVEN: &[(&str, &str)] = &[
407 ),407 ),
408 // lane-t900 r27, negative gate + census: a written key frame carrying408 // lane-t900 r27, negative gate + census: a written key frame carrying
409 // each of the three mode-overriding features (over three segment ids) is409 // each of the three mode-overriding features (over three segment ids) is
410- // refused by name with no picture; and six real aomenc recipes410+ // refused by name with no picture; and real aomenc recipes never enable
411- // (`--aq-mode=1/2/3`, `--deltaq-mode=1`, plus a baseline for arrival)411+ // one. lane-av1seglvl re-scoped the census: beyond r27's six 1-pass
412- // never enable one -- only `--aq-mode=3` changes the stream at all, and412+ // no-lag recipes it now parses EVERY frame header's feature table over
413- // what it codes is `segment_id` symbols under `SEG_LVL_ALT_Q`.413+ // alt-ref-lag and genuine two-pass arms (`--aq-mode=1/2`, cq45 and the
414+ // branch's own high-q cq63, screen + film sources) -- the shapes that
415+ // reach `configure_static_seg_features`, the only setter of ALT_LF/
416+ // REF_FRAME/SKIP in the tree, which is gated on `hl_sf.static_segmentation`
417+ // ("Always set to 0", speed_features.h) and the second pass
418+ // (encoder_utils.c:738). What aomenc codes is `SEG_LVL_ALT_Q` tables and
419+ // `segment_id` symbols, and nothing else; the map-inheritance defect that
420+ // census surfaced (verbatim copy, decodemv.c:342) is fixed and witnessed
421+ // by `a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_ // pixel_exact`.
414 (422 (
415 "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)",423 "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)",
416 "a_frame_whose_segmentation_overrides_a_block_mode_is_refused_by_name",424 "a_frame_whose_segmentation_overrides_a_block_mode_is_refused_by_name",
@@ -589,7 +597,11 @@ mod tests {
589 .chain(REFUSALS)597 .chain(REFUSALS)
590 .map(|&s| s.to_owned())598 .map(|&s| s.to_owned())
591 .collect();599 .collect();
592- assert!(found.len() >= 30, "the refusal scan found only {} reasons -- it is broken, not the decoder", found.len());600+ assert!(
601+ found.len() >= 30,
602+ "the refusal scan found only {} reasons -- it is broken, not the decoder",
603+ found.len()
604+ );
593 605
594 let added: Vec<&String> = found.difference(&listed).collect();606 let added: Vec<&String> = found.difference(&listed).collect();
595 assert!(607 assert!(
@@ -635,9 +647,14 @@ mod tests {
635 let mut found: BTreeSet<String> = BTreeSet::new();647 let mut found: BTreeSet<String> = BTreeSet::new();
636 for (i, _) in src.match_indices("\"SKIP ") {648 for (i, _) in src.match_indices("\"SKIP ") {
637 let rest = &src[i + "\"SKIP ".len()..];649 let rest = &src[i + "\"SKIP ".len()..];
638- let Some(colon) = rest.find(':') else { continue };650+ let Some(colon) = rest.find(':') else {
651+ continue;
652+ };
639 let name = &rest[..colon];653 let name = &rest[..colon];
640- if !name.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') {654+ if !name
655+ .chars()
656+ .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_')
657+ {
641 continue;658 continue;
642 }659 }
643 // The tail of the message says what was skipped. Only "{e}" -- the660 // The tail of the message says what was skipped. Only "{e}" -- the
@@ -650,7 +667,10 @@ mod tests {
650 }667 }
651 }668 }
652 let listed: BTreeSet<&str> = GATES_THAT_SKIP_ON_A_DECODE_ERROR.iter().copied().collect();669 let listed: BTreeSet<&str> = GATES_THAT_SKIP_ON_A_DECODE_ERROR.iter().copied().collect();
653- let added: Vec<&String> = found.iter().filter(|n| !listed.contains(n.as_str())).collect();670+ let added: Vec<&String> = found
671+ .iter()
672+ .filter(|n| !listed.contains(n.as_str()))
673+ .collect();
654 assert!(674 assert!(
655 added.is_empty(),675 added.is_empty(),
656 "these gates turn a decode error into a printed SKIP and are not declared: \676 "these gates turn a decode error into a printed SKIP and are not declared: \
@@ -723,9 +743,18 @@ mod tests {
723 fn every_partition_value_of_an_enumerated_alphabet_has_an_arm() {743 fn every_partition_value_of_an_enumerated_alphabet_has_an_arm() {
724 // (the refusal in the fallback arm, the alphabet its CDF codes)744 // (the refusal in the fallback arm, the alphabet its CDF codes)
725 let blocks: [(&str, usize); 4] = [745 let blocks: [(&str, usize); 4] = [
726- ("a 32x32 partition type this decoder does not code", crate::cdf::PARTITION_W32[0].len() - 1),746+ (
727- ("an INTER 32x32 partition type this decoder does not code", crate::cdf::PARTITION_W32[0].len() - 1),747+ "a 32x32 partition type this decoder does not code",
728- ("a 128x128 superblock partition value outside the 8-symbol alphabet", crate::cdf::PARTITION_W128[0].len() - 1),748+ crate::cdf::PARTITION_W32[0].len() - 1,
749+ ),
750+ (
751+ "an INTER 32x32 partition type this decoder does not code",
752+ crate::cdf::PARTITION_W32[0].len() - 1,
753+ ),
754+ (
755+ "a 128x128 superblock partition value outside the 8-symbol alphabet",
756+ crate::cdf::PARTITION_W128[0].len() - 1,
757+ ),
729 // lane-t900 r24: the key-frame superblock root. Its `part` is758 // lane-t900 r24: the key-frame superblock root. Its `part` is
730 // either a `partition_w64` symbol or, at a frame edge, one of the759 // either a `partition_w64` symbol or, at a frame edge, one of the
731 // three gathered outcomes (PARTITION_HORZ, PARTITION_VERT,760 // three gathered outcomes (PARTITION_HORZ, PARTITION_VERT,
@@ -779,7 +808,10 @@ mod tests {
779 "the `match` at decode.rs:{} refuses {reason:?} but has no arm for {:?} -- that \808 "the `match` at decode.rs:{} refuses {reason:?} but has no arm for {:?} -- that \
780 is a real gap in its {alphabet}-value alphabet, not a dead refusal",809 is a real gap in its {alphabet}-value alphabet, not a dead refusal",
781 i + 1,810 i + 1,
782- missing.iter().map(|v| PARTITION_NAMES[*v]).collect::<Vec<_>>()811+ missing
812+ .iter()
813+ .map(|v| PARTITION_NAMES[*v])
814+ .collect::<Vec<_>>()
783 );815 );
784 }816 }
785 assert_eq!(817 assert_eq!(
@@ -833,7 +865,11 @@ mod tests {
833 .next()865 .next()
834 .unwrap_or("")866 .unwrap_or("")
835 .to_owned();867 .to_owned();
836- assert!(!var.is_empty(), "the chain at decode.rs:{} tests nothing", head + 1);868+ assert!(
869+ !var.is_empty(),
870+ "the chain at decode.rs:{} tests nothing",
871+ head + 1
872+ );
837 873
838 // Walk up collecting every branch head of this chain, each read to874 // Walk up collecting every branch head of this chain, each read to
839 // the line that opens its body.875 // the line that opens its body.
@@ -843,7 +879,8 @@ mod tests {
843 loop {879 loop {
844 i -= 1;880 i -= 1;
845 let t = lines[i].trim_start();881 let t = lines[i].trim_start();
846- if indent(lines[i]) != outer || !(t.starts_with("} else if ") || t.starts_with("if "))882+ if indent(lines[i]) != outer
883+ || !(t.starts_with("} else if ") || t.starts_with("if "))
847 {884 {
848 if i == 0 {885 if i == 0 {
849 break;886 break;
@@ -893,7 +930,10 @@ mod tests {
893 "the chain at decode.rs:{} refuses {reason:?} but no branch names {:?} -- that \930 "the chain at decode.rs:{} refuses {reason:?} but no branch names {:?} -- that \
894 is a real gap in its {alphabet}-value alphabet, not a dead refusal",931 is a real gap in its {alphabet}-value alphabet, not a dead refusal",
895 head + 1,932 head + 1,
896- missing.iter().map(|v| PARTITION_NAMES[*v]).collect::<Vec<_>>()933+ missing
934+ .iter()
935+ .map(|v| PARTITION_NAMES[*v])
936+ .collect::<Vec<_>>()
897 );937 );
898 }938 }
899 assert_eq!(found, chains.len());939 assert_eq!(found, chains.len());
@@ -996,11 +1036,18 @@ mod tests {
996 values.insert(((1u64 << length) - 2) as u32);1036 values.insert(((1u64 << length) - 2) as u32);
997 }1037 }
998 let max = *values.iter().max().unwrap();1038 let max = *values.iter().max().unwrap();
999- assert_eq!(max, (1u32 << 20) - 2, "the enumeration misses the spec's own ceiling");1039+ assert_eq!(
1040+ max,
1041+ (1u32 << 20) - 2,
1042+ "the enumeration misses the spec's own ceiling"
1043+ );
1000 // A coefficient is masked to 20 bits (spec 5.11.39), and the base and1044 // A coefficient is masked to 20 bits (spec 5.11.39), and the base and
1001 // base-range syntax contribute at most 15 of that before the tail, so1045 // base-range syntax contribute at most 15 of that before the tail, so
1002 // this is the largest tail a legal coefficient can need.1046 // this is the largest tail a legal coefficient can need.
1003- assert!(max >= 0xF_FFFF - 15, "the ceiling is below the largest legal tail");1047+ assert!(
1048+ max >= 0xF_FFFF - 15,
1049+ "the ceiling is below the largest legal tail"
1050+ );
1004 for value in values {1051 for value in values {
1005 match roundtrip(value) {1052 match roundtrip(value) {
1006 Ok(read) => assert_eq!(read, value, "the Golomb tail {value} read back as {read}"),1053 Ok(read) => assert_eq!(read, value, "the Golomb tail {value} read back as {read}"),
@@ -1056,7 +1103,11 @@ mod tests {
1056 ];1103 ];
1057 assert_eq!(alphabets[0].1, 13, "the y_mode alphabet changed size");1104 assert_eq!(alphabets[0].1, 13, "the y_mode alphabet changed size");
1058 for group in &crate::cdf::Y_MODE {1105 for group in &crate::cdf::Y_MODE {
1059- assert_eq!(group.len() - 1, alphabets[0].1, "the y_mode rows disagree on width");1106+ assert_eq!(
1107+ group.len() - 1,
1108+ alphabets[0].1,
1109+ "the y_mode rows disagree on width"
1110+ );
1060 }1111 }
1061 1112
1062 let src = include_str!("decode.rs");1113 let src = include_str!("decode.rs");
@@ -1064,12 +1115,17 @@ mod tests {
1064 let mut sites = 0usize;1115 let mut sites = 0usize;
1065 for (i, line) in lines.iter().enumerate() {1116 for (i, line) in lines.iter().enumerate() {
1066 let t = line.trim();1117 let t = line.trim();
1067- let Some(rest) = t.strip_prefix("if mode >= ") else { continue };1118+ let Some(rest) = t.strip_prefix("if mode >= ") else {
1119+ continue;
1120+ };
1068 let Some(threshold) = rest.trim_end_matches(" {").parse::<usize>().ok() else {1121 let Some(threshold) = rest.trim_end_matches(" {").parse::<usize>().ok() else {
1069 continue;1122 continue;
1070 };1123 };
1071 // Only the guards carrying THIS refusal.1124 // Only the guards carrying THIS refusal.
1072- if !lines[i..(i + 4).min(lines.len())].join("\n").contains(REFUSAL) {1125+ if !lines[i..(i + 4).min(lines.len())]
1126+ .join("\n")
1127+ .contains(REFUSAL)
1128+ {
1073 continue;1129 continue;
1074 }1130 }
1075 sites += 1;1131 sites += 1;
@@ -1099,7 +1155,10 @@ mod tests {
1099 i + 11155 i + 1
1100 );1156 );
1101 }1157 }
1102- assert_eq!(sites, 3, "the intra-mode guard is at three sites, found {sites}");1158+ assert_eq!(
1159+ sites, 3,
1160+ "the intra-mode guard is at three sites, found {sites}"
1161+ );
1103 }1162 }
1104 1163
1105 /// lane-t900 r31, ENUMERATION for "a HORZ/VERT intra strip in a1164 /// lane-t900 r31, ENUMERATION for "a HORZ/VERT intra strip in a
@@ -1159,7 +1218,10 @@ mod tests {
1159 }1218 }
1160 }1219 }
1161 }1220 }
1162- assert!(with_128 > 0, "enumeration is vacuous -- no 128-sided footprint was tried");1221+ assert!(
1222+ with_128 > 0,
1223+ "enumeration is vacuous -- no 128-sided footprint was tried"
1224+ );
1163 assert_eq!(1225 assert_eq!(
1164 allowed_at_128, 0,1226 allowed_at_128, 0,
1165 "a footprint with a 128-pixel side passed av1_allow_palette's bound -- the \1227 "a footprint with a 128-pixel side passed av1_allow_palette's bound -- the \
@@ -1271,11 +1333,17 @@ mod tests {
1271 // (3) The two tables, read out of decode_rect_split's own text: every1333 // (3) The two tables, read out of decode_rect_split's own text: every
1272 // `(w, h) =>` / `(w, h) |` match arm head between the table's `let`1334 // `(w, h) =>` / `(w, h) |` match arm head between the table's `let`
1273 // and the guard that follows it.1335 // and the guard that follows it.
1274- let body_at = src.find("fn decode_rect_split(").expect("decode_rect_split is gone");1336+ let body_at = src
1337+ .find("fn decode_rect_split(")
1338+ .expect("decode_rect_split is gone");
1275 let body = &src[body_at..];1339 let body = &src[body_at..];
1276 let slice = |from: &str, to: &str| -> &str {1340 let slice = |from: &str, to: &str| -> &str {
1277- let a = body.find(from).unwrap_or_else(|| panic!("{from:?} is gone from decode_rect_split"));1341+ let a = body
1278- let b = body[a..].find(to).unwrap_or_else(|| panic!("{to:?} is gone from decode_rect_split"));1342+ .find(from)
1343+ .unwrap_or_else(|| panic!("{from:?} is gone from decode_rect_split"));
1344+ let b = body[a..]
1345+ .find(to)
1346+ .unwrap_or_else(|| panic!("{to:?} is gone from decode_rect_split"));
1279 &body[a..a + b]1347 &body[a..a + b]
1280 };1348 };
1281 let arm_shapes = |text: &str| -> BTreeSet<(usize, usize)> {1349 let arm_shapes = |text: &str| -> BTreeSet<(usize, usize)> {
@@ -1348,7 +1416,10 @@ mod tests {
1348 }1416 }
1349 }1417 }
1350 }1418 }
1351- assert_eq!(checked, 40, "the strip domain is not the ten rect shapes x four depths");1419+ assert_eq!(
1420+ checked, 40,
1421+ "the strip domain is not the ten rect shapes x four depths"
1422+ );
1352 }1423 }
1353 1424
1354 /// lane-t900 r33, ENUMERATION for "CfL, filter intra or a palette on a1425 /// lane-t900 r33, ENUMERATION for "CfL, filter intra or a palette on a
@@ -1458,9 +1529,15 @@ mod tests {
1458 }1529 }
1459 continue;1530 continue;
1460 }1531 }
1461- let Some(rest) = line.strip_prefix('(') else { continue };1532+ let Some(rest) = line.strip_prefix('(') else {
1462- let Some((pair, _)) = rest.split_once(") =>") else { continue };1533+ continue;
1463- let Some((a, b)) = pair.split_once(',') else { continue };1534+ };
1535+ let Some((pair, _)) = rest.split_once(") =>") else {
1536+ continue;
1537+ };
1538+ let Some((a, b)) = pair.split_once(',') else {
1539+ continue;
1540+ };
1464 let bw: usize = a.trim().parse().expect("arm bw");1541 let bw: usize = a.trim().parse().expect("arm bw");
1465 let bh: usize = b.trim().parse().expect("arm bh");1542 let bh: usize = b.trim().parse().expect("arm bh");
1466 assert!(1543 assert!(
@@ -1472,9 +1549,18 @@ mod tests {
1472 seen.push((bw, bh));1549 seen.push((bw, bh));
1473 arms += 1;1550 arms += 1;
1474 }1551 }
1475- assert!(arms >= 10, "only {arms} arms parsed -- the table's shape changed");1552+ assert!(
1476- assert!(saw_none_fallback, "filter_intra_size_class_rect lost its `_ => None` fallback");1553+ arms >= 10,
1477- assert!(saw_square_delegate, "filter_intra_size_class_rect lost its square-delegate arm");1554+ "only {arms} arms parsed -- the table's shape changed"
1555+ );
1556+ assert!(
1557+ saw_none_fallback,
1558+ "filter_intra_size_class_rect lost its `_ => None` fallback"
1559+ );
1560+ assert!(
1561+ saw_square_delegate,
1562+ "filter_intra_size_class_rect lost its square-delegate arm"
1563+ );
1478 // The guard arm delegates square strips to `filter_intra_size_class`;1564 // The guard arm delegates square strips to `filter_intra_size_class`;
1479 // drive the delegate directly, so a widening there turns THIS test red1565 // drive the delegate directly, so a widening there turns THIS test red
1480 // (the numeric walk never reaches the guard arm).1566 // (the numeric walk never reaches the guard arm).
@@ -1524,7 +1610,10 @@ mod tests {
1524 );1610 );
1525 }1611 }
1526 }1612 }
1527- assert_eq!(sites, 8, "the call-site audit found {sites} sites, not the 8 it enumerated");1613+ assert_eq!(
1614+ sites, 8,
1615+ "the call-site audit found {sites} sites, not the 8 it enumerated"
1616+ );
1528 }1617 }
1529 1618
1530 /// Every entry of [`PROVEN`] must still name a live refusal and a test1619 /// Every entry of [`PROVEN`] must still name a live refusal and a test
@@ -1543,7 +1632,9 @@ mod tests {
1543 "{reason:?} is listed as proven but is no longer a decode-path refusal -- drop it from PROVEN (the capability landed) or fix the string"1632 "{reason:?} is listed as proven but is no longer a decode-path refusal -- drop it from PROVEN (the capability landed) or fix the string"
1544 );1633 );
1545 assert!(1634 assert!(
1546- sources.iter().any(|src| src.contains(&format!("fn {gate}("))),1635+ sources
1636+ .iter()
1637+ .any(|src| src.contains(&format!("fn {gate}("))),
1547 "{reason:?} names the proving test {gate}, which exists in neither stream.rs \1638 "{reason:?} names the proving test {gate}, which exists in neither stream.rs \
1548 nor decode.rs"1639 nor decode.rs"
1549 );1640 );
crates/ec-av1/src/stream.rsmodified+410 -10
@@ -17,7 +17,7 @@
17 17
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_ALT_Q, SEG_LVL_GLOBALMV, SEG_LVL_MAX, SEG_LVL_REF_FRAME, SEG_LVL_SKIP, Tile, TxMode,
21 };21 };
22 use ec_core::{Error, Result};22 use ec_core::{Error, Result};
23 23
@@ -851,7 +851,9 @@ pub fn decode_stream_with_threads(
851 // symbols `decode_inter_block` unconditionally reads) -- have no851 // symbols `decode_inter_block` unconditionally reads) -- have no
852 // reader on the inter path, so they still refuse by name rather than852 // reader on the inter path, so they still refuse by name rather than
853 // desyncing. aomenc's `--aq-mode` segmentation only ever sets853 // desyncing. aomenc's `--aq-mode` segmentation only ever sets
854- // `SEG_LVL_ALT_Q`.854+ // `SEG_LVL_ALT_Q` (census gate
855+ // `a_segmentation_census_over_real_aq_streams_finds_no_mode_overriding_feature`:
856+ // 1-pass, alt-ref-lag and two-pass arms, every frame header parsed).
855 let tile_bufs: Vec<&[u8]> = tiles857 let tile_bufs: Vec<&[u8]> = tiles
856 .iter()858 .iter()
857 .map(|t| {859 .map(|t| {
@@ -1432,14 +1434,20 @@ fn decode_frame(
1432 // SEG_LVL_GLOBALMV, `:1071` in `read_ref_frames`, `:1350` in1434 // SEG_LVL_GLOBALMV, `:1071` in `read_ref_frames`, `:1350` in
1433 // `read_is_inter_block`), so a conformant stream CAN carry them and1435 // `read_is_inter_block`), so a conformant stream CAN carry them and
1434 // this is a capability gap, not a spec-conformant guard. Reachability1436 // this is a capability gap, not a spec-conformant guard. Reachability
1435- // from `aomenc` is nil -- its AQ modes set `SEG_LVL_ALT_Q` only1437+ // from `aomenc` is nil, for three independent reasons (lane-av1seglvl
1436- // (`aq_variance.c:89`, `aq_complexity.c:118`, `aq_cyclicrefresh.c:630`)1438+ // census): the AQ modules clear the table then set `SEG_LVL_ALT_Q`
1437- // and the mode-overriding features come only from the library API1439+ // only (`aq_variance.c:61` clear + `:89` enable, `aq_complexity.c:74`
1438- // (`av1_apply_roi_map` `encoder_utils.c:515`, `av1_apply_active_map`1440+ // + `:118`, `aq_cyclicrefresh.c:616` + `:630`); the one other setter,
1439- // `encoder_utils.c:557`, the alt-ref overlap case `:401-413`); the CLI1441+ // `configure_static_seg_features` (`encoder_utils.c:315`, which would
1440- // exposes no ROI/active-map flag (checked). Kept as a named gap: the1442+ // set ALT_LF/REF_FRAME/SKIP around alt-ref groups), is gated on
1441- // lift is an INTER-block-path change (ref/skip/mode selection) outside1443+ // `hl_sf.static_segmentation` -- a speed feature libaom's own
1442- // this lane's region. See `lanes/av1hdr.report.md` §4.1.1444+ // `speed_features.h` documents as "Always set to 0" -- AND on the
1445+ // second pass of a two-pass encode (`encoder_utils.c:738`); and
1446+ // ROI/active-map maps are control-API only (`av1_apply_roi_map`,
1447+ // `av1_apply_active_map`: the CLI exposes no flag for either). Kept as
1448+ // a named gap: the lift is an INTER-block-path change (ref/skip/mode
1449+ // selection) outside this lane's region. See `lanes/av1hdr.report.md`
1450+ // §4.1 and `lanes/av1seglvl.report.md`.
1443 for segment in 0..MAX_SEGMENTS {1451 for segment in 0..MAX_SEGMENTS {
1444 for feature in [SEG_LVL_REF_FRAME, SEG_LVL_SKIP, SEG_LVL_GLOBALMV] {1452 for feature in [SEG_LVL_REF_FRAME, SEG_LVL_SKIP, SEG_LVL_GLOBALMV] {
1445 if header.segmentation.feature_enabled[segment][feature] {1453 if header.segmentation.feature_enabled[segment][feature] {
@@ -2500,6 +2508,163 @@ pub(crate) mod tests {
2500 (stream.len(), result)2508 (stream.len(), result)
2501 }2509 }
2502 2510
2511+ /// lane-av1seglvl: encode `frames` frames of `source` with real aomenc
2512+ /// plus `extra` args and return the raw `.obu` bytes -- the census's
2513+ /// half-sibling of [`census_attempt`] that keeps the STREAM instead of
2514+ /// only its decode verdict, so the caller can parse the frame headers'
2515+ /// segmentation tables themselves.
2516+ fn encode_aomenc_stream(
2517+ source: &str,
2518+ width: usize,
2519+ height: usize,
2520+ frames: usize,
2521+ extra: &[&str],
2522+ ) -> Vec<u8> {
2523+ let duration = format!("{}", frames as f64 / 25.0);
2524+ let src = format!("{source}=size={width}x{height}:rate=25");
2525+ let y4m = Command::new("ffmpeg")
2526+ .args([
2527+ "-v", "error", "-f", "lavfi", "-i", &src, "-t", &duration, "-pix_fmt", "yuv420p",
2528+ "-strict", "-1", "-f", "yuv4mpegpipe", "-",
2529+ ])
2530+ .stdin(Stdio::null())
2531+ .stdout(Stdio::piped())
2532+ .stderr(Stdio::piped())
2533+ .output()
2534+ .expect("ffmpeg failed to run");
2535+ assert!(y4m.status.success(), "ffmpeg refused the {width}x{height} fixture");
2536+ let limit = format!("--limit={frames}");
2537+ let mut args: Vec<String> = [
2538+ "--codec=av1",
2539+ "--passes=1",
2540+ "--end-usage=q",
2541+ "--threads=1",
2542+ "--row-mt=0",
2543+ "--kf-max-dist=9999",
2544+ "--lag-in-frames=0",
2545+ ]
2546+ .iter()
2547+ .map(|s| (*s).to_owned())
2548+ .collect();
2549+ args.push(limit);
2550+ args.extend(extra.iter().map(|s| (*s).to_owned()));
2551+ args.extend(["--obu".to_owned(), "-o".to_owned(), "-".to_owned(), "-".to_owned()]);
2552+ let out = run_with_stdin(Command::new(aomenc_path()).args(&args), &y4m.stdout);
2553+ assert!(out.status.success(), "aomenc refused {args:?}: {}", String::from_utf8_lossy(&out.stderr));
2554+ out.stdout
2555+ }
2556+
2557+ /// lane-av1seglvl: encode `frames` frames with a real TWO-PASS aomenc
2558+ /// (pass 1 writes the stats file into the session temp dir, pass 2
2559+ /// consumes it) and return the `.obu` bytes. This is the only shape that
2560+ /// reaches libaom's `is_stat_consumption_stage_twopass` segmentation
2561+ /// setup (`configure_static_seg_features`), so the census is not proven
2562+ /// over the encoder's whole reachable surface without it.
2563+ fn encode_aomenc_stream_twopass(
2564+ source: &str,
2565+ width: usize,
2566+ height: usize,
2567+ frames: usize,
2568+ extra: &[&str],
2569+ ) -> Vec<u8> {
2570+ let duration = format!("{}", frames as f64 / 25.0);
2571+ let src = format!("{source}=size={width}x{height}:rate=25");
2572+ let y4m = Command::new("ffmpeg")
2573+ .args([
2574+ "-v", "error", "-f", "lavfi", "-i", &src, "-t", &duration, "-pix_fmt", "yuv420p",
2575+ "-strict", "-1", "-f", "yuv4mpegpipe", "-",
2576+ ])
2577+ .stdin(Stdio::null())
2578+ .stdout(Stdio::piped())
2579+ .stderr(Stdio::piped())
2580+ .output()
2581+ .expect("ffmpeg failed to run");
2582+ assert!(y4m.status.success(), "ffmpeg refused the {width}x{height} fixture");
2583+ let limit = format!("--limit={frames}");
2584+ let fpf = std::env::temp_dir().join(format!("ec-av1-segldapass-{}.fpf", std::process::id()));
2585+ let mut base: Vec<String> = [
2586+ "--codec=av1",
2587+ "--passes=2",
2588+ "--end-usage=q",
2589+ "--threads=1",
2590+ "--row-mt=0",
2591+ "--kf-max-dist=9999",
2592+ "--lag-in-frames=0",
2593+ ]
2594+ .iter()
2595+ .map(|s| (*s).to_owned())
2596+ .collect();
2597+ base.push(limit);
2598+ base.extend(extra.iter().map(|s| (*s).to_owned()));
2599+ let mut pass1 = base.clone();
2600+ pass1.extend(["--pass=1".to_owned(), format!("--fpf={}", fpf.display())]);
2601+ pass1.extend(["--obu".to_owned(), "-o".to_owned(), "/dev/null".to_owned(), "-".to_owned()]);
2602+ let out1 = run_with_stdin(Command::new(aomenc_path()).args(&pass1), &y4m.stdout);
2603+ assert!(out1.status.success(), "aomenc pass 1 refused {pass1:?}: {}", String::from_utf8_lossy(&out1.stderr));
2604+ let mut pass2 = base;
2605+ pass2.extend(["--pass=2".to_owned(), format!("--fpf={}", fpf.display())]);
2606+ pass2.extend(["--obu".to_owned(), "-o".to_owned(), "-".to_owned(), "-".to_owned()]);
2607+ let out2 = run_with_stdin(Command::new(aomenc_path()).args(&pass2), &y4m.stdout);
2608+ let _ = std::fs::remove_file(&fpf);
2609+ assert!(out2.status.success(), "aomenc pass 2 refused {pass2:?}: {}", String::from_utf8_lossy(&out2.stderr));
2610+ out2.stdout
2611+ }
2612+
2613+ /// lane-av1seglvl: walk every frame OBU of `stream` and tally which
2614+ /// `SEG_LVL` features the frame headers actually ENABLE, plus the shape
2615+ /// counters a census premise is asserted against: frames with
2616+ /// segmentation on, of which `update_map == 1` (the map is coded) and
2617+ /// `update_map == 0` (every block's id is INHERITED), and frames whose
2618+ /// table carries a real `SEG_LVL_ALT_Q` delta.
2619+ /// The last vector counts per SEGMENT-FEATURE INSTANCE (a frame with
2620+ /// ALT_Q on all 8 segments contributes 8), which is all the verdict
2621+ /// needs: only index `SEG_LVL_ALT_Q` may be non-zero.
2622+ /// Returns `(enabled_frames, update_map_frames, inherited_frames,
2623+ /// alt_q_frames, feature_instances: [usize; SEG_LVL_MAX])`.
2624+ #[allow(clippy::type_complexity)]
2625+ fn segmentation_feature_census(
2626+ stream: &[u8],
2627+ ) -> (usize, usize, usize, usize, [usize; SEG_LVL_MAX]) {
2628+ let mut parser = Av1Parser::new();
2629+ let obus = parser
2630+ .parse_temporal_unit(stream)
2631+ .unwrap_or_else(|e| panic!("the census stream does not even parse: {e}"));
2632+ let mut enabled = 0usize;
2633+ let mut update_map = 0usize;
2634+ let mut inherited = 0usize;
2635+ let mut alt_q = 0usize;
2636+ let mut feature_frames = [0usize; SEG_LVL_MAX];
2637+ for obu in &obus {
2638+ if let ObuKind::Frame(header, _) = &obu.kind {
2639+ let seg = &header.segmentation;
2640+ if !seg.enabled {
2641+ continue;
2642+ }
2643+ enabled += 1;
2644+ if seg.update_map {
2645+ update_map += 1;
2646+ } else {
2647+ inherited += 1;
2648+ }
2649+ let mut any_q = false;
2650+ for segment in 0..MAX_SEGMENTS {
2651+ for feature in 0..SEG_LVL_MAX {
2652+ if seg.feature_enabled[segment][feature] {
2653+ feature_frames[feature] += 1;
2654+ if feature == SEG_LVL_ALT_Q {
2655+ any_q = true;
2656+ }
2657+ }
2658+ }
2659+ }
2660+ if any_q {
2661+ alt_q += 1;
2662+ }
2663+ }
2664+ }
2665+ (enabled, update_map, inherited, alt_q, feature_frames)
2666+ }
2667+
2503 /// lane-hdrlossless: WITNESS for the one refusal the pilot report left2668 /// lane-hdrlossless: WITNESS for the one refusal the pilot report left
2504 /// without a proving test -- "a frame mixing lossless and lossy2669 /// without a proving test -- "a frame mixing lossless and lossy
2505 /// segments". It is a REAL encoder output, not a defensive pin:2670 /// segments". It is a REAL encoder output, not a defensive pin:
@@ -2633,6 +2798,16 @@ pub(crate) mod tests {
2633 /// `--aq-mode=1/2/3` (variance, complexity and cyclic-refresh AQ) and2798 /// `--aq-mode=1/2/3` (variance, complexity and cyclic-refresh AQ) and
2634 /// `--deltaq-mode=1` -- with the refusal as the instrument: if one of2799 /// `--deltaq-mode=1` -- with the refusal as the instrument: if one of
2635 /// those features appeared, the decode would stop by name.2800 /// those features appeared, the decode would stop by name.
2801+ ///
2802+ /// lane-av1seglvl re-scope: r27's arms were all `--passes=1
2803+ /// --lag-in-frames=0`, so they never coded an alt-ref frame or ran an
2804+ /// encoder second pass -- the only shapes where libaom's OTHER seg
2805+ /// feature setup (`configure_static_seg_features`) could ever run. The
2806+ /// re-scoped half below adds alt-ref-group arms and a real two-pass arm,
2807+ /// and upgrades the instrument from the refusal (blind to a pure-ALT_LF
2808+ /// stream) to a direct parse of every frame header's `feature_enabled`
2809+ /// table: over all of it, aomenc enables `SEG_LVL_ALT_Q` and nothing
2810+ /// else.
2636 #[test]2811 #[test]
2637 fn a_segmentation_census_over_real_aq_streams_finds_no_mode_overriding_feature() {2812 fn a_segmentation_census_over_real_aq_streams_finds_no_mode_overriding_feature() {
2638 if !have_aomenc() {2813 if !have_aomenc() {
@@ -2700,6 +2875,231 @@ pub(crate) mod tests {
2700 "no recipe coded a single segment_id symbol -- segmentation never arrived, so \2875 "no recipe coded a single segment_id symbol -- segmentation never arrived, so \
2701 this census measures nothing about the three mode-overriding features"2876 this census measures nothing about the three mode-overriding features"
2702 );2877 );
2878+
2879+ // lane-av1seglvl re-scope: the r27 arms above are all `--passes=1
2880+ // --lag-in-frames=0`, which never codes an alt-ref frame -- the one
2881+ // frame type whose segmentation libaom sets up differently
2882+ // (`configure_static_seg_features`, encoder_utils.c:738, is further
2883+ // gated on the second pass AND on `hl_sf.static_segmentation`, which
2884+ // speed_features.h itself documents as "Always set to 0"). The arms
2885+ // below cover that whole remaining surface: alt-ref groups under
2886+ // `--aq-mode`, a high-cq arm (the branch's own `high_q` gate is
2887+ // `avg_q > 48`), and a genuine two-pass encode. The instrument is no
2888+ // longer the refusal -- the refusal only fires on
2889+ // REF_FRAME/SKIP/GLOBALMV, so an ALT_LF-only stream would decode
2890+ // silently past it -- but a direct parse of every frame header's
2891+ // `feature_enabled` table.
2892+ let lag_recipes: [(&str, &str, usize, usize, Vec<&str>); 4] = [
2893+ (
2894+ "aq-mode=1 lag16 mandelbrot",
2895+ "mandelbrot",
2896+ 192,
2897+ 128,
2898+ vec!["--cpu-used=4", "--aq-mode=1", "--cq-level=45", "--lag-in-frames=16", "--auto-alt-ref=1"],
2899+ ),
2900+ (
2901+ "aq-mode=1 lag16 screen",
2902+ "testsrc2",
2903+ 256,
2904+ 192,
2905+ vec!["--cpu-used=4", "--aq-mode=1", "--cq-level=45", "--lag-in-frames=16", "--auto-alt-ref=1"],
2906+ ),
2907+ (
2908+ "aq-mode=1 lag16 cq63 high_q",
2909+ "mandelbrot",
2910+ 192,
2911+ 128,
2912+ vec!["--cpu-used=4", "--aq-mode=1", "--cq-level=63", "--lag-in-frames=16", "--auto-alt-ref=1"],
2913+ ),
2914+ (
2915+ "aq-mode=2 lag16",
2916+ "mandelbrot",
2917+ 192,
2918+ 128,
2919+ vec!["--cpu-used=4", "--aq-mode=2", "--cq-level=45", "--lag-in-frames=16", "--auto-alt-ref=1"],
2920+ ),
2921+ ];
2922+ let mut total_enabled = 0usize;
2923+ let mut total_inherited = 0usize;
2924+ let mut total_alt_q = 0usize;
2925+ let mut feature_frames = [0usize; SEG_LVL_MAX];
2926+ for (name, source, w, h, extra) in &lag_recipes {
2927+ let stream = encode_aomenc_stream(source, *w, *h, 40, extra);
2928+ let (enabled, umap, inherited, alt_q, frames_per_feature) =
2929+ segmentation_feature_census(&stream);
2930+ eprintln!(
2931+ "SEGCENSUS {name}: seg-enabled {enabled}, update_map {umap}, inherited {inherited}, ALT_Q {alt_q}, per-feature {frames_per_feature:?}"
2932+ );
2933+ total_enabled += enabled;
2934+ total_inherited += inherited;
2935+ total_alt_q += alt_q;
2936+ for (f, n) in frames_per_feature.iter().enumerate() {
2937+ feature_frames[f] += n;
2938+ }
2939+ }
2940+ // The two-pass arm: `configure_static_seg_features` runs ONLY at
2941+ // `is_stat_consumption_stage_twopass`, so this is the arm that would
2942+ // catch its ALT_LF/REF_FRAME/SKIP tables if the dead speed feature
2943+ // were ever revived.
2944+ {
2945+ let stream = encode_aomenc_stream_twopass(
2946+ "mandelbrot",
2947+ 192,
2948+ 128,
2949+ 40,
2950+ &["--cpu-used=4", "--aq-mode=1", "--cq-level=45", "--lag-in-frames=16", "--auto-alt-ref=1"],
2951+ );
2952+ let (enabled, umap, inherited, alt_q, frames_per_feature) =
2953+ segmentation_feature_census(&stream);
2954+ eprintln!(
2955+ "SEGCENSUS twopass aq-mode=1 lag16: seg-enabled {enabled}, update_map {umap}, inherited {inherited}, ALT_Q {alt_q}, per-feature {frames_per_feature:?}"
2956+ );
2957+ total_enabled += enabled;
2958+ total_inherited += inherited;
2959+ total_alt_q += alt_q;
2960+ for (f, n) in frames_per_feature.iter().enumerate() {
2961+ feature_frames[f] += n;
2962+ }
2963+ }
2964+ // Premise (class gate-blind-to-feature): the arms must actually reach
2965+ // the shapes the census speaks about -- segmentation-carrying frames,
2966+ // frames whose map is INHERITED (update_map == 0), and frames with a
2967+ // real ALT_Q table -- or the "only ALT_Q" verdict below measures
2968+ // nothing.
2969+ assert!(
2970+ total_enabled > 0 && total_alt_q > 0,
2971+ "no lag/two-pass arm carried a segmentation-enabled frame -- the census premise \
2972+ never arrived"
2973+ );
2974+ assert!(
2975+ total_inherited > 0,
2976+ "no arm carried an update_map == 0 frame -- the map-inheritance path the decoder \
2977+ reads segment ids through is unmeasured"
2978+ );
2979+ // The census verdict, over every frame of every arm: segmentation on
2980+ // aomenc's CLI carries SEG_LVL_ALT_Q and NOTHING else. The three
2981+ // mode-overriding features and the four ALT_LF deltas have no encoder
2982+ // path: `configure_static_seg_features` (the only setter of ALT_LF/
2983+ // REF_FRAME/SKIP in the tree) is gated on `hl_sf.static_segmentation`,
2984+ // documented "Always set to 0" (speed_features.h), and ROI/active-map
2985+ // are control-API only (aomenc.c has no flag for either).
2986+ for (feature, frames) in feature_frames.iter().enumerate() {
2987+ if feature == SEG_LVL_ALT_Q {
2988+ continue;
2989+ }
2990+ assert_eq!(
2991+ *frames, 0,
2992+ "feature index {feature} appeared on {frames} frames of real aomenc output -- \
2993+ the refusal's encoder-never-writes claim is FALSE and the mode path needs \
2994+ porting before this census can stay green"
2995+ );
2996+ }
2997+ eprintln!(
2998+ "SEGCENSUS lag/twopass: {total_enabled} seg-enabled frames over 5 arms, {total_inherited} inherited-map frames, {total_alt_q} with ALT_Q, all other SEG_LVL features: 0 frames"
2999+ );
3000+ }
3001+
3002+ /// lane-av1seglvl WITNESS: the reaching stream. `--aq-mode=1` turns
3003+ /// segmentation on for every frame; `--lag-in-frames=16 --auto-alt-ref=1`
3004+ /// adds real alt-ref groups, so the stream mixes map-CODING frames
3005+ /// (`update_map == 1`: the key frame and each group's arf) with dozens of
3006+ /// map-INHERITING frames (`update_map == 0`), and an inheriting block's
3007+ /// id is the MIN of the previous map over its own footprint while the
3008+ /// saved map itself inherits that footprint VERBATIM
3009+ /// (`copy_segment_id`, decodemv.c:342) -- heterogeneous footprints are
3010+ /// exactly what a 1:4-split arf leaves behind. Stamping the minified id
3011+ /// (the pre-lane defect) flattened those footprints and mis-dequantized
3012+ /// scattered blocks frames later: 2 luma bytes of mandelbrot frame 35
3013+ /// differed from the oracle, everything else exact.
3014+ ///
3015+ /// Both arms decode EVERY frame in decode order -- hidden arfs included
3016+ /// -- byte-exact against the instrumented oracle, and every SHOWN frame
3017+ /// pixel-exact against ffmpeg; the census counters prove the premise
3018+ /// (segmentation symbols read, a wider-than-zero quantizer span from
3019+ /// `SEG_LVL_ALT_Q`, and an inheritance-heavy shape).
3020+ #[test]
3021+ fn a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_pixel_exact() {
3022+ const NAME: &str = "a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_pixel_exact";
3023+ if !have_aomenc() {
3024+ eprintln!("SKIP {NAME}: no aomenc");
3025+ return;
3026+ }
3027+ if !have_ffmpeg() {
3028+ eprintln!("SKIP {NAME}: no ffmpeg");
3029+ return;
3030+ }
3031+ let extra = [
3032+ "--cpu-used=4",
3033+ "--aq-mode=1",
3034+ "--cq-level=45",
3035+ "--lag-in-frames=16",
3036+ "--auto-alt-ref=1",
3037+ ];
3038+ let arms: [(&str, &str, usize, usize); 2] = [
3039+ ("screen testsrc2", "testsrc2", 256, 192),
3040+ ("film mandelbrot", "mandelbrot", 192, 128),
3041+ ];
3042+ for (arm, source, width, height) in &arms {
3043+ let stream = encode_aomenc_stream(source, *width, *height, 40, &extra);
3044+ // Premise: the shape under test really arrived -- segmentation on
3045+ // every frame, the map both coded and inherited, and real ALT_Q
3046+ // tables. An aomenc drift that dropped any of these would make
3047+ // the decode below prove nothing (class gate-blind-to-feature).
3048+ let (enabled, umap, inherited, alt_q, _) = segmentation_feature_census(&stream);
3049+ eprintln!(
3050+ "{NAME} {arm}: seg-enabled {enabled}, update_map {umap}, inherited {inherited}, ALT_Q-carrying {alt_q}"
3051+ );
3052+ assert!(
3053+ enabled > 0 && umap > 0,
3054+ "{arm}: no segmentation-carrying/map-coding frame -- the premise is gone"
3055+ );
3056+ assert!(
3057+ inherited > 0,
3058+ "{arm}: no update_map == 0 frame -- the map-inheritance path under test never runs"
3059+ );
3060+ assert!(
3061+ alt_q > 0,
3062+ "{arm}: no frame carries a SEG_LVL_ALT_Q table -- the feature under test never fires"
3063+ );
3064+ // Every frame in decode order -- hidden arfs included (each one
3065+ // re-surfaces via show-existing in this recipe, so `hidden == 0`
3066+ // is possible while `frames` still covers the whole coded set) --
3067+ // byte-exact against the oracle.
3068+ let (frames, hidden) = decode_all_frames_vs_oracle(&stream, arm);
3069+ assert!(frames > 0, "{arm}: decoded nothing");
3070+ assert_eq!(
3071+ frames, enabled,
3072+ "{arm}: decode-order frame count != segmentation-enabled frame count -- the \
3073+ parse and the decode disagree about the stream"
3074+ );
3075+ let _ = hidden;
3076+ // And every shown frame pixel-exact against ffmpeg.
3077+ crate::decode::reset_segment_hits();
3078+ let pictures = decode_stream(&stream)
3079+ .unwrap_or_else(|e| panic!("{NAME} {arm}: decode refused: {e}"));
3080+ assert!(
3081+ crate::decode::segment_id_hits() > 0,
3082+ "{arm}: zero segment_id symbols read -- the decode proved nothing about \
3083+ segmentation"
3084+ );
3085+ let (lo, hi) = crate::decode::block_q_span();
3086+ assert!(
3087+ hi > lo,
3088+ "{arm}: every block dequantized at the same qindex ({lo}) -- SEG_LVL_ALT_Q \
3089+ never changed any block's quantizer"
3090+ );
3091+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, *width, *height, pictures.len());
3092+ for (i, (ours, theirs)) in pictures.iter().zip(&ffmpeg_frames).enumerate() {
3093+ assert_eq!(ours.y, theirs.y, "{NAME} {arm}: frame {i} luma vs ffmpeg");
3094+ assert_eq!(ours.u, theirs.u, "{NAME} {arm}: frame {i} U vs ffmpeg");
3095+ assert_eq!(ours.v, theirs.v, "{NAME} {arm}: frame {i} V vs ffmpeg");
3096+ }
3097+ eprintln!(
3098+ "{NAME} {arm}: {frames} frames decode-order exact vs oracle ({hidden} hidden), {} shown frames exact vs ffmpeg, q span {lo}..{hi}, segment_id symbols {}",
3099+ pictures.len(),
3100+ crate::decode::segment_id_hits()
3101+ );
3102+ }
2703 }3103 }
2704 3104
2705 /// lane-t900 r27, WITNESS half of the proof for "an OBMC neighbour whose3105 /// lane-t900 r27, WITNESS half of the proof for "an OBMC neighbour whose