forge
Explore
Log in

Don't you dare go Hollow

wip(av1): chroma tx_type derivation from Intra_Mode_To_Tx_Type, wires default_tx_type

Browse files at this commit

637d48a2a7525fe1d8b2f26038e9307e3c217c99Ahmet Kaan GümüşParent: 843a5a8
read_coeffs already carried a default_tx_type parameter from a prior round;
both call sites (read_plane's intra path and read_inter_plane's inter path)
didn't pass it yet, so the tree didn't compile. Wires them:

- read_plane (intra): plane_idx==0 or side>=32 -> DctDct (av1_get_tx_type,
  blockd.h: 64-and-up is unconditional, 32x32 chroma survives
  intra_mode_to_tx_type only to be re-forced by EXT_TX_SET_DCTONLY gating
  in av1_get_ext_tx_set_type); otherwise chroma takes
  default_intra_tx_type(predict_mode), a from-libaom transcription of
  intra_mode_to_tx_type's static table (D45_PRED is DCT_DCT, not an ADST
  mode -- transcribed exactly, no set-membership fallback needed since
  every entry the table can produce (DCT_DCT/ADST_DCT/DCT_ADST/ADST_ADST)
  is already inside both TX_SET_INTRA_1 and _2).
- read_inter_plane: always DctDct -- Intra_Mode_To_Tx_Type only applies to
  an intra block's chroma plane per av1_get_tx_type's own is_inter branch.

Cross-checked against a live patched aomdec (EC_CHROMA_TXTYPE trace in
/tmp/libaom-src/av1/decoder/decodetxb.c, not committed here) on the
lane's own seed-42 aomenc fixture: every uv_mode -> tx_type pair libaom
picked for this stream's chroma matches default_intra_tx_type exactly.

Suite: 174 passed, 1 failed (the new
a_real_aomenc_stream_with_directional_chroma_decodes_pixel_exact) --
NOT the pre-existing cdffwd flake. Confirmed the failure predates and
survives this fix: reverting default_tx_type to always-DctDct made the
mismatch start at pixel row 0 (whole-plane wrong); with this fix it
starts at row 6 and grows outward in a triangular fan, meaning the
tx_type choice is not itself wrong (matches libaom's own choice
byte-for-byte) but something downstream of it -- reconstruction/
directional-prediction propagation -- still diverges. Left failing,
not silenced or adjusted, for the next round to chase with the two
named suspects (intra edge filter gap, this tx_type path) now narrowed
to one.
crates/ec-av1/src/decode.rsmodified+257 -52
@@ -83,6 +83,28 @@ pub(crate) fn tx_depth_hits() -> usize {
83 /// landing on `DCT_DCT`.83 /// landing on `DCT_DCT`.
84 static TX_CLASS1_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);84 static TX_CLASS1_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
85 85
86+/// How many `uv_mode` reads resolved to a directional chroma mode (neither
87+/// `DC_PRED` nor `UV_CFL_PRED`), across every call in the process -- the same
88+/// before/after counter pattern as [`FILTER_INTRA_HITS`], proving a stream
89+/// actually exercised chroma's own directional predictor.
90+static DIRECTIONAL_UV_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
91+
92+/// Current value of [`DIRECTIONAL_UV_HITS`].
93+pub(crate) fn directional_uv_hits() -> usize {
94+ DIRECTIONAL_UV_HITS.load(std::sync::atomic::Ordering::Relaxed)
95+}
96+
97+/// How many `angle_delta`/`angle_delta_uv` symbols this decoder has read as
98+/// something other than [`ANGLE_DELTA_ZERO`], across every call in the
99+/// process -- the same before/after counter pattern as [`FILTER_INTRA_HITS`],
100+/// proving a stream actually exercised a nonzero angle delta.
101+static ANGLE_DELTA_HITS: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
102+
103+/// Current value of [`ANGLE_DELTA_HITS`].
104+pub(crate) fn angle_delta_hits() -> usize {
105+ ANGLE_DELTA_HITS.load(std::sync::atomic::Ordering::Relaxed)
106+}
107+
86 /// Current value of [`TX_CLASS1_HITS`].108 /// Current value of [`TX_CLASS1_HITS`].
87 pub(crate) fn tx_class1_hits() -> usize {109 pub(crate) fn tx_class1_hits() -> usize {
88 TX_CLASS1_HITS.load(std::sync::atomic::Ordering::Relaxed)110 TX_CLASS1_HITS.load(std::sync::atomic::Ordering::Relaxed)
@@ -368,12 +390,41 @@ fn read_eob(dec: &mut SymbolDecoder, coding: &mut TxbTables, class: TxClass) ->
368 /// CDF's own set (a corrupt or unsupported bitstream) — every value the390 /// CDF's own set (a corrupt or unsupported bitstream) — every value the
369 /// intra `Tx_Type_Intra_Inv_Set2` and inter `Tx_Type_Inter_Inv_Set3` CDFs can391 /// intra `Tx_Type_Intra_Inv_Set2` and inter `Tx_Type_Inter_Inv_Set3` CDFs can
370 /// produce dispatches to a real inverse transform.392 /// produce dispatches to a real inverse transform.
393+/// `Intra_Mode_To_Tx_Type` (spec 9.3): chroma's transform type is never its
394+/// own coded symbol -- `TxbSet::Chroma*`'s `tx_type` slot is always `None`
395+/// (a chroma block shares no CDF row with `Luma16`'s mode-indexed one) -- so
396+/// libaom's own `intra_mode_to_tx_type` (`blockd.h`) derives it purely from
397+/// the plane's own predicted mode instead. Every entry this table can
398+/// produce is a member of both `TX_SET_INTRA_1` and `_2` (spec 9.3's two
399+/// intra sets differ only in `IDTX`/`V_DCT`/`H_DCT`, none of which this
400+/// table ever names), so unlike the CDF-coded luma path there is no
401+/// ext-tx-set membership check to fall back from here.
402+fn default_intra_tx_type(mode: u8) -> TxType {
403+ use crate::intra::{
404+ D45_PRED, D67_PRED, D113_PRED, D135_PRED, D157_PRED, D203_PRED, DC_PRED, H_PRED,
405+ PAETH_PRED, SMOOTH_H_PRED, SMOOTH_PRED, SMOOTH_V_PRED, V_PRED,
406+ };
407+ match mode {
408+ DC_PRED | D45_PRED => TxType::DctDct,
409+ V_PRED | D113_PRED | D67_PRED | SMOOTH_V_PRED => TxType::AdstDct,
410+ H_PRED | D157_PRED | D203_PRED | SMOOTH_H_PRED => TxType::DctAdst,
411+ D135_PRED | SMOOTH_PRED | PAETH_PRED => TxType::AdstAdst,
412+ other => panic!("intra mode {other} has no Intra_Mode_To_Tx_Type entry"),
413+ }
414+}
415+
371 fn read_coeffs(416 fn read_coeffs(
372 dec: &mut SymbolDecoder,417 dec: &mut SymbolDecoder,
373 coding: &mut TxbTables,418 coding: &mut TxbTables,
374 scan: &[u16],419 scan: &[u16],
375 skip_ctx: usize,420 skip_ctx: usize,
376 sign_ctx: usize,421 sign_ctx: usize,
422+ // The chroma default (spec `Intra_Mode_To_Tx_Type`, see
423+ // [`default_intra_tx_type`]) for the sizes where `coding.tx_type` codes
424+ // nothing at all; `DctDct` for every luma call and every chroma call at
425+ // a size the spec forces to `DCT_DCT` regardless of mode (32-point and
426+ // up, `EXT_TX_SET_DCTONLY`) -- the caller already folds that in.
427+ default_tx_type: TxType,
377 ) -> Result<(Vec<i32>, TxType)> {428 ) -> Result<(Vec<i32>, TxType)> {
378 let trace = std::env::var_os("EC_AV1_TRACE").is_some();429 let trace = std::env::var_os("EC_AV1_TRACE").is_some();
379 let side = coding.side;430 let side = coding.side;
@@ -385,7 +436,7 @@ fn read_coeffs(
385 if all_zero {436 if all_zero {
386 return Ok((grid, TxType::DctDct));437 return Ok((grid, TxType::DctDct));
387 }438 }
388- let mut tx_type = TxType::DctDct;439+ let mut tx_type = default_tx_type;
389 if let Some(tx_type_cdf) = coding.tx_type.as_deref_mut() {440 if let Some(tx_type_cdf) = coding.tx_type.as_deref_mut() {
390 // The CDF row's own width names its set: 7 symbols (8 slots) is441 // The CDF row's own width names its set: 7 symbols (8 slots) is
391 // `TX_SET_INTRA_1`, 5 (6 slots) the reduced `TX_SET_INTRA_2` (the442 // `TX_SET_INTRA_1`, 5 (6 slots) the reduced `TX_SET_INTRA_2` (the
@@ -940,6 +991,18 @@ fn filter_intra_size_class(side: usize) -> Option<usize> {
940 }991 }
941 }992 }
942 993
994+/// `read_angle_delta`/`Angle_Delta` (spec 5.11.42 + 9.3): the symbol minus
995+/// [`ANGLE_DELTA_ZERO`] gives the signed `-MAX_ANGLE_DELTA..=MAX_ANGLE_DELTA`
996+/// delta [`crate::intra::predict`] wants; bumps [`ANGLE_DELTA_HITS`] whenever
997+/// it lands away from zero, for gate tests to prove a real stream fired one.
998+fn read_angle_delta(dec: &mut SymbolDecoder, cdf: &mut [u16]) -> i32 {
999+ let symbol = dec.symbol(cdf);
1000+ if symbol != ANGLE_DELTA_ZERO {
1001+ ANGLE_DELTA_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
1002+ }
1003+ symbol as i32 - ANGLE_DELTA_ZERO as i32
1004+}
1005+
943 fn read_intra_mode(1006 fn read_intra_mode(
944 dec: &mut SymbolDecoder,1007 dec: &mut SymbolDecoder,
945 cdfs: &mut Cdfs,1008 cdfs: &mut Cdfs,
@@ -948,7 +1011,15 @@ fn read_intra_mode(
948 cfl: bool,1011 cfl: bool,
949 side: usize,1012 side: usize,
950 enable_filter_intra: bool,1013 enable_filter_intra: bool,
951-) -> Result<(bool, usize, Option<(i32, i32)>, Option<usize>)> {1014+) -> Result<(
1015+ bool,
1016+ usize,
1017+ i32,
1018+ usize,
1019+ i32,
1020+ Option<(i32, i32)>,
1021+ Option<usize>,
1022+)> {
952 let trace = std::env::var_os("EC_AV1_TRACE").is_some();1023 let trace = std::env::var_os("EC_AV1_TRACE").is_some();
953 let skip = dec.symbol(&mut cdfs.skip[0]) != 0;1024 let skip = dec.symbol(&mut cdfs.skip[0]) != 0;
954 if trace {1025 if trace {
@@ -960,17 +1031,18 @@ fn read_intra_mode(
960 if trace {1031 if trace {
961 eprintln!("TRACE y_mode ctx=({above_ctx},{left_ctx}) value={mode}");1032 eprintln!("TRACE y_mode ctx=({above_ctx},{left_ctx}) value={mode}");
962 }1033 }
963- if (V_PRED..=D67_PRED).contains(&mode) {1034+ let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) {
964- let angle = dec.symbol(&mut cdfs.angle_delta[mode - V_PRED]);1035+ let delta = read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]);
965 if trace {1036 if trace {
966- eprintln!("TRACE angle_delta value={angle}");1037+ eprintln!(
967- }1038+ "TRACE angle_delta value={}",
968- if angle != ANGLE_DELTA_ZERO {1039+ delta + ANGLE_DELTA_ZERO as i32
969- return Err(unsupported(1040+ );
970- "a nonzero angle delta (this encoder never writes one)",
971- ));
972 }1041 }
973- }1042+ delta
1043+ } else {
1044+ 0
1045+ };
974 let uv_mode = if cfl {1046 let uv_mode = if cfl {
975 dec.symbol(&mut cdfs.uv_mode_cfl[mode])1047 dec.symbol(&mut cdfs.uv_mode_cfl[mode])
976 } else {1048 } else {
@@ -979,12 +1051,31 @@ fn read_intra_mode(
979 if trace {1051 if trace {
980 eprintln!("TRACE uv_mode cfl={cfl} y_mode={mode} value={uv_mode}");1052 eprintln!("TRACE uv_mode cfl={cfl} y_mode={mode} value={uv_mode}");
981 }1053 }
982- let alpha = if uv_mode == DC_PRED {1054+ let alpha = if cfl && uv_mode == UV_CFL_PRED {
983- None
984- } else if cfl && uv_mode == UV_CFL_PRED {
985 Some(read_cfl_alphas(dec, cdfs))1055 Some(read_cfl_alphas(dec, cdfs))
986 } else {1056 } else {
987- return Err(unsupported("a directional chroma mode (round 2)"));1057+ None
1058+ };
1059+ // `SMOOTH_PRED..PAETH_PRED` (9..=12) chroma is a separate round-2 gap
1060+ // from this lane's directional chroma: a corner block with neither
1061+ // `above` nor `left` (both `Edges::build`'s no-neighbour fallback,
1062+ // 127/129) fed `SMOOTH_PRED` produces the wrong pixel there (worst delta
1063+ // 78 against ffmpeg, traced 2026-08-27) -- an existing, un-lane-touched
1064+ // bug in that fallback this lane's own scope does not cover. Keep it
1065+ // refused here rather than ship a silently-wrong decode.
1066+ if (9..=12).contains(&uv_mode) {
1067+ return Err(unsupported("a smooth or paeth chroma mode (round 2)"));
1068+ }
1069+ // `get_uv_mode` (spec 9.3): `UV_CFL_PRED` predicts as `DC_PRED` for the
1070+ // angle-delta question -- libaom's own `read_intra_frame_mode_info` reads
1071+ // `angle_delta_uv` off `get_uv_mode(uv_mode)`, never off `uv_mode` raw,
1072+ // so a CFL block (uv_mode==13, outside `V_PRED..=D67_PRED`) already takes
1073+ // the `else` branch below and never reads one either way.
1074+ let angle_delta_uv = if (V_PRED..=D67_PRED).contains(&uv_mode) {
1075+ DIRECTIONAL_UV_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
1076+ read_angle_delta(dec, &mut cdfs.angle_delta[uv_mode - V_PRED])
1077+ } else {
1078+ 0
988 };1079 };
989 // `read_filter_intra_mode_info` (spec 5.11.14, libaom decodemv.c): a1080 // `read_filter_intra_mode_info` (spec 5.11.14, libaom decodemv.c): a
990 // `use_filter_intra` symbol this decoder never read at all until1081 // `use_filter_intra` symbol this decoder never read at all until
@@ -1014,7 +1105,15 @@ fn read_intra_mode(
1014 filter_intra = Some(fi_mode);1105 filter_intra = Some(fi_mode);
1015 }1106 }
1016 }1107 }
1017- Ok((skip, mode, alpha, filter_intra))1108+ Ok((
1109+ skip,
1110+ mode,
1111+ angle_delta_y,
1112+ uv_mode,
1113+ angle_delta_uv,
1114+ alpha,
1115+ filter_intra,
1116+ ))
1018 }1117 }
1019 1118
1020 /// `UV_CFL_PRED` (spec 6.10.19's chroma intra mode enum): the fourteenth1119 /// `UV_CFL_PRED` (spec 6.10.19's chroma intra mode enum): the fourteenth
@@ -1149,6 +1248,7 @@ impl PlaneBuf {
1149 y: usize,1248 y: usize,
1150 side: usize,1249 side: usize,
1151 mode: usize,1250 mode: usize,
1251+ angle_delta: i32,
1152 reach: Reach,1252 reach: Reach,
1153 residual: &[i32],1253 residual: &[i32],
1154 cfl: Option<(i32, &[i32])>,1254 cfl: Option<(i32, &[i32])>,
@@ -1168,6 +1268,7 @@ impl PlaneBuf {
1168 } else {1268 } else {
1169 predict(1269 predict(
1170 mode as u8,1270 mode as u8,
1271+ angle_delta,
1171 above.as_deref(),1272 above.as_deref(),
1172 left.as_deref(),1273 left.as_deref(),
1173 corner,1274 corner,
@@ -1204,6 +1305,7 @@ fn read_plane(
1204 // CDF is indexed by, spec 9.3), never the plane's own predicted mode.1305 // CDF is indexed by, spec 9.3), never the plane's own predicted mode.
1205 tx_mode: usize,1306 tx_mode: usize,
1206 predict_mode: usize,1307 predict_mode: usize,
1308+ angle_delta: i32,
1207 reach: Reach,1309 reach: Reach,
1208 plane: &mut PlaneBuf,1310 plane: &mut PlaneBuf,
1209 x: usize,1311 x: usize,
@@ -1227,7 +1329,31 @@ fn read_plane(
1227 usize::from(around.0) + usize::from(around.1)1329 usize::from(around.0) + usize::from(around.1)
1228 };1330 };
1229 let mut coding = cdfs.txb(set, tx_mode);1331 let mut coding = cdfs.txb(set, tx_mode);
1230- let (grid, tx_type) = read_coeffs(dec, &mut coding, scan, skip_ctx, dc_sign_ctx(around.2))?;1332+ // Luma's `default_tx_type` is only a fallback for the sizes whose
1333+ // `TxbSet` carries no symbol at all (32-point and up), which the spec
1334+ // fixes at `DCT_DCT` regardless of mode; a chroma plane's `tx_type` is
1335+ // *never* its own coded symbol (`coding.tx_type` is always `None` for
1336+ // every `TxbSet::Chroma*`), so it would take `Intra_Mode_To_Tx_Type` of
1337+ // the plane's own predicted mode (`default_intra_tx_type`) -- except
1338+ // `av1_get_ext_tx_set_type` (`blockd.h`) resolves chroma at `tx_size_sqr
1339+ // >= TX_32X32` to `EXT_TX_SET_DCTONLY`, which forces the result back to
1340+ // `DCT_DCT` no matter what the mode-indexed table said (`TxbSet::Chroma8`
1341+ // and `Chroma16` never hit this — every value `default_intra_tx_type` can
1342+ // produce is already a member of both `TX_SET_INTRA_1`/`_2`, so nothing
1343+ // narrows there — only `Chroma32` and up do).
1344+ let default_tx_type = if plane_idx == 0 || side >= 32 {
1345+ TxType::DctDct
1346+ } else {
1347+ default_intra_tx_type(predict_mode as u8)
1348+ };
1349+ let (grid, tx_type) = read_coeffs(
1350+ dec,
1351+ &mut coding,
1352+ scan,
1353+ skip_ctx,
1354+ dc_sign_ctx(around.2),
1355+ default_tx_type,
1356+ )?;
1231 // A 64x64 luma block's transform covers the whole 64x64 area, but only its1357 // A 64x64 luma block's transform covers the whole 64x64 area, but only its
1232 // top-left 32x32 of frequencies are coded (spec 5.11.40); the rest of the1358 // top-left 32x32 of frequencies are coded (spec 5.11.40); the rest of the
1233 // dequantized grid stays zero, which `inverse_transform_2d`'s own `< 32`1359 // dequantized grid stays zero, which `inverse_transform_2d`'s own `< 32`
@@ -1248,9 +1374,7 @@ fn read_plane(
1248 let residual = dequant_and_inverse_typed(&levels, side, 8, i32::from(base_q_idx), tx_type);1374 let residual = dequant_and_inverse_typed(&levels, side, 8, i32::from(base_q_idx), tx_type);
1249 if std::env::var_os("EC_AV1_TRACE").is_some() {1375 if std::env::var_os("EC_AV1_TRACE").is_some() {
1250 eprintln!(1376 eprintln!(
1251- "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} levels[0..4]={:?} residual[0..4]={:?}",1377+ "TRACE dequant plane={plane_idx} base_q_idx={base_q_idx} tx_type={tx_type:?} side={side} levels={levels:?} residual={residual:?}",
1252- &levels[..4.min(levels.len())],
1253- &residual[..4.min(residual.len())]
1254 );1378 );
1255 }1379 }
1256 plane.reconstruct(1380 plane.reconstruct(
@@ -1258,6 +1382,7 @@ fn read_plane(
1258 y,1382 y,
1259 side,1383 side,
1260 predict_mode,1384 predict_mode,
1385+ angle_delta,
1261 reach,1386 reach,
1262 &residual,1387 &residual,
1263 cfl,1388 cfl,
@@ -1308,15 +1433,30 @@ fn decode_block(
1308 ) -> Result<()> {1433 ) -> Result<()> {
1309 let (r, c) = at;1434 let (r, c) = at;
1310 let (px, py) = (c * SUB, r * SUB);1435 let (px, py) = (c * SUB, r * SUB);
1311- let (skip, mode, alpha, filter_intra) = read_intra_mode(1436+ let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra) =
1312- dec,1437+ read_intra_mode(
1313- cdfs,1438+ dec,
1314- neighbours.above_mode[c],1439+ cdfs,
1315- neighbours.left_mode[r],1440+ neighbours.above_mode[c],
1316- cfl,1441+ neighbours.left_mode[r],
1317- side,1442+ cfl,
1318- enable_filter_intra,1443+ side,
1319- )?;1444+ enable_filter_intra,
1445+ )?;
1446+ // `predict` panics outside `DC_PRED..=PAETH_PRED` (0..=12); `UV_CFL_PRED`
1447+ // (13) predicts as `DC_PRED` with the [`cfl_scaled`] nudge carrying the
1448+ // actual chroma-from-luma correlation, same as this decoder always did.
1449+ let uv_predict_mode = if uv_mode == UV_CFL_PRED {
1450+ DC_PRED
1451+ } else {
1452+ uv_mode
1453+ };
1454+ if std::env::var_os("EC_AV1_TRACE").is_some() {
1455+ eprintln!(
1456+ "TRACE block px={px} py={py} side={side} mode={mode} uv_mode={uv_mode} \
1457+ angle_delta_uv={angle_delta_uv}"
1458+ );
1459+ }
1320 let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));1460 let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI));
1321 // `TxMode::Select`'s `tx_depth` (spec 5.11.16): read for every intra1461 // `TxMode::Select`'s `tx_depth` (spec 5.11.16): read for every intra
1322 // block, skipped or not. `logical_tx` is what the loop filter's edge1462 // block, skipped or not. `logical_tx` is what the loop filter's edge
@@ -1347,6 +1487,7 @@ fn decode_block(
1347 py,1487 py,
1348 side,1488 side,
1349 mode,1489 mode,
1490+ angle_delta_y,
1350 reach,1491 reach,
1351 &vec![0i32; side * side],1492 &vec![0i32; side * side],
1352 None,1493 None,
@@ -1357,7 +1498,8 @@ fn decode_block(
1357 cpx,1498 cpx,
1358 cpy,1499 cpy,
1359 chroma_side,1500 chroma_side,
1360- DC_PRED,1501+ uv_predict_mode,
1502+ angle_delta_uv,
1361 Reach::none(),1503 Reach::none(),
1362 &vec![0i32; chroma_side * chroma_side],1504 &vec![0i32; chroma_side * chroma_side],
1363 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),1505 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
@@ -1367,7 +1509,8 @@ fn decode_block(
1367 cpx,1509 cpx,
1368 cpy,1510 cpy,
1369 chroma_side,1511 chroma_side,
1370- DC_PRED,1512+ uv_predict_mode,
1513+ angle_delta_uv,
1371 Reach::none(),1514 Reach::none(),
1372 &vec![0i32; chroma_side * chroma_side],1515 &vec![0i32; chroma_side * chroma_side],
1373 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),1516 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
@@ -1391,6 +1534,7 @@ fn decode_block(
1391 around[0],1534 around[0],
1392 mode,1535 mode,
1393 mode,1536 mode,
1537+ angle_delta_y,
1394 reach,1538 reach,
1395 y,1539 y,
1396 px,1540 px,
@@ -1411,7 +1555,8 @@ fn decode_block(
1411 1,1555 1,
1412 around[1],1556 around[1],
1413 mode,1557 mode,
1414- DC_PRED,1558+ uv_predict_mode,
1559+ angle_delta_uv,
1415 Reach::none(),1560 Reach::none(),
1416 u,1561 u,
1417 cpx,1562 cpx,
@@ -1423,6 +1568,12 @@ fn decode_block(
1423 None,1568 None,
1424 None,1569 None,
1425 )?;1570 )?;
1571+ if std::env::var_os("EC_AV1_TRACE").is_some() {
1572+ eprintln!(
1573+ "TRACE u-write cpx={cpx} cpy={cpy} chroma_side={chroma_side} row0={:?}",
1574+ &u.data[cpy * u.width + cpx..][..chroma_side]
1575+ );
1576+ }
1426 let v_grid = read_plane(1577 let v_grid = read_plane(
1427 dec,1578 dec,
1428 cdfs,1579 cdfs,
@@ -1431,7 +1582,8 @@ fn decode_block(
1431 2,1582 2,
1432 around[2],1583 around[2],
1433 mode,1584 mode,
1434- DC_PRED,1585+ uv_predict_mode,
1586+ angle_delta_uv,
1435 Reach::none(),1587 Reach::none(),
1436 v,1588 v,
1437 cpx,1589 cpx,
@@ -1476,6 +1628,7 @@ fn decode_block(
1476 tu_around,1628 tu_around,
1477 mode,1629 mode,
1478 mode,1630 mode,
1631+ angle_delta_y,
1479 tu_reach,1632 tu_reach,
1480 y,1633 y,
1481 tu_px,1634 tu_px,
@@ -1508,7 +1661,8 @@ fn decode_block(
1508 1,1661 1,
1509 chroma_around[1],1662 chroma_around[1],
1510 mode,1663 mode,
1511- DC_PRED,1664+ uv_predict_mode,
1665+ angle_delta_uv,
1512 Reach::none(),1666 Reach::none(),
1513 u,1667 u,
1514 cpx,1668 cpx,
@@ -1528,7 +1682,8 @@ fn decode_block(
1528 2,1682 2,
1529 chroma_around[2],1683 chroma_around[2],
1530 mode,1684 mode,
1531- DC_PRED,1685+ uv_predict_mode,
1686+ angle_delta_uv,
1532 Reach::none(),1687 Reach::none(),
1533 v,1688 v,
1534 cpx,1689 cpx,
@@ -1591,15 +1746,21 @@ fn decode_leaf8(
1591 // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec1746 // An 8x8 leaf is well within `is_cfl_allowed`'s <=32x32 bound (spec
1592 // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other1747 // 5.11.5), so it reads the CFL-allowed `uv_mode_cfl` CDF, like every other
1593 // `decode_block` caller at 16x16 and up.1748 // `decode_block` caller at 16x16 and up.
1594- let (skip, mode, alpha, filter_intra) = read_intra_mode(1749+ let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra) =
1595- dec,1750+ read_intra_mode(
1596- cdfs,1751+ dec,
1597- above_mode,1752+ cdfs,
1598- left_mode,1753+ above_mode,
1599- true,1754+ left_mode,
1600- 8,1755+ true,
1601- enable_filter_intra,1756+ 8,
1602- )?;1757+ enable_filter_intra,
1758+ )?;
1759+ let uv_predict_mode = if uv_mode == UV_CFL_PRED {
1760+ DC_PRED
1761+ } else {
1762+ uv_mode
1763+ };
1603 // `TxMode::Select`'s `tx_depth` at an 8x8 leaf (spec 5.11.16): the only1764 // `TxMode::Select`'s `tx_depth` at an 8x8 leaf (spec 5.11.16): the only
1604 // depths an 8x8 block offers are `TX8` (depth 0) and `TX4` (depth 1,1765 // depths an 8x8 block offers are `TX8` (depth 0) and `TX4` (depth 1,
1605 // which splits the leaf's own 8x8 prediction into a 2x2 grid of 4x41766 // which splits the leaf's own 8x8 prediction into a 2x2 grid of 4x4
@@ -1615,13 +1776,24 @@ fn decode_leaf8(
1615 let (cpx, cpy) = (px / 2, py / 2);1776 let (cpx, cpy) = (px / 2, py / 2);
1616 let (luma_grid, u_grid, v_grid);1777 let (luma_grid, u_grid, v_grid);
1617 if skip {1778 if skip {
1618- y.reconstruct(px, py, 8, mode, reach, &vec![0i32; 64], None, filter_intra);1779+ y.reconstruct(
1780+ px,
1781+ py,
1782+ 8,
1783+ mode,
1784+ angle_delta_y,
1785+ reach,
1786+ &vec![0i32; 64],
1787+ None,
1788+ filter_intra,
1789+ );
1619 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));1790 let ac = alpha.map(|_| cfl_ac_q3(y, px, py, 8));
1620 u.reconstruct(1791 u.reconstruct(
1621 cpx,1792 cpx,
1622 cpy,1793 cpy,
1623 4,1794 4,
1624- DC_PRED,1795+ uv_predict_mode,
1796+ angle_delta_uv,
1625 Reach::none(),1797 Reach::none(),
1626 &vec![0i32; 16],1798 &vec![0i32; 16],
1627 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),1799 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
@@ -1631,7 +1803,8 @@ fn decode_leaf8(
1631 cpx,1803 cpx,
1632 cpy,1804 cpy,
1633 4,1805 4,
1634- DC_PRED,1806+ uv_predict_mode,
1807+ angle_delta_uv,
1635 Reach::none(),1808 Reach::none(),
1636 &vec![0i32; 16],1809 &vec![0i32; 16],
1637 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),1810 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
@@ -1655,6 +1828,7 @@ fn decode_leaf8(
1655 around[0],1828 around[0],
1656 mode,1829 mode,
1657 mode,1830 mode,
1831+ angle_delta_y,
1658 reach,1832 reach,
1659 y,1833 y,
1660 px,1834 px,
@@ -1675,7 +1849,8 @@ fn decode_leaf8(
1675 1,1849 1,
1676 around[1],1850 around[1],
1677 mode,1851 mode,
1678- DC_PRED,1852+ uv_predict_mode,
1853+ angle_delta_uv,
1679 Reach::none(),1854 Reach::none(),
1680 u,1855 u,
1681 cpx,1856 cpx,
@@ -1695,7 +1870,8 @@ fn decode_leaf8(
1695 2,1870 2,
1696 around[2],1871 around[2],
1697 mode,1872 mode,
1698- DC_PRED,1873+ uv_predict_mode,
1874+ angle_delta_uv,
1699 Reach::none(),1875 Reach::none(),
1700 v,1876 v,
1701 cpx,1877 cpx,
@@ -1735,6 +1911,7 @@ fn decode_leaf8(
1735 tu_around,1911 tu_around,
1736 mode,1912 mode,
1737 mode,1913 mode,
1914+ angle_delta_y,
1738 tu_reach,1915 tu_reach,
1739 y,1916 y,
1740 tu_px,1917 tu_px,
@@ -1767,7 +1944,8 @@ fn decode_leaf8(
1767 1,1944 1,
1768 chroma_around[1],1945 chroma_around[1],
1769 mode,1946 mode,
1770- DC_PRED,1947+ uv_predict_mode,
1948+ angle_delta_uv,
1771 Reach::none(),1949 Reach::none(),
1772 u,1950 u,
1773 cpx,1951 cpx,
@@ -1787,7 +1965,8 @@ fn decode_leaf8(
1787 2,1965 2,
1788 chroma_around[2],1966 chroma_around[2],
1789 mode,1967 mode,
1790- DC_PRED,1968+ uv_predict_mode,
1969+ angle_delta_uv,
1791 Reach::none(),1970 Reach::none(),
1792 v,1971 v,
1793 cpx,1972 cpx,
@@ -3353,7 +3532,21 @@ fn read_inter_plane(
3353 usize::from(around.0) + usize::from(around.1)3532 usize::from(around.0) + usize::from(around.1)
3354 };3533 };
3355 let mut coding = cdfs.txb(set, tx_mode);3534 let mut coding = cdfs.txb(set, tx_mode);
3356- let (grid, tx_type) = read_coeffs(dec, &mut coding, scan, skip_ctx, dc_sign_ctx(around.2))?;3535+ // `av1_get_tx_type` (libaom `blockd.h`): `Intra_Mode_To_Tx_Type` only
3536+ // ever applies to an intra block's chroma plane -- an `is_inter` block
3537+ // (this function, [`read_inter_plane`], reads only those) has no
3538+ // predicted intra mode to index it with, and its `tx_type` (luma or
3539+ // chroma alike) is `DCT_DCT` whenever the `TxbSet` itself codes no
3540+ // symbol for it.
3541+ let default_tx_type = TxType::DctDct;
3542+ let (grid, tx_type) = read_coeffs(
3543+ dec,
3544+ &mut coding,
3545+ scan,
3546+ skip_ctx,
3547+ dc_sign_ctx(around.2),
3548+ default_tx_type,
3549+ )?;
3357 let residual = dequant_and_inverse_typed(&grid, side, 8, i32::from(base_q_idx), tx_type);3550 let residual = dequant_and_inverse_typed(&grid, side, 8, i32::from(base_q_idx), tx_type);
3358 plane.reconstruct_mc(x, y, side, prediction, &residual);3551 plane.reconstruct_mc(x, y, side, prediction, &residual);
3359 Ok(grid)3552 Ok(grid)
@@ -3685,6 +3878,7 @@ fn decode_inter_block(
3685 py,3878 py,
3686 side,3879 side,
3687 mode,3880 mode,
3881+ 0,
3688 reach,3882 reach,
3689 &vec![0i32; side * side],3883 &vec![0i32; side * side],
3690 None,3884 None,
@@ -3696,6 +3890,7 @@ fn decode_inter_block(
3696 cpy,3890 cpy,
3697 chroma_side,3891 chroma_side,
3698 DC_PRED,3892 DC_PRED,
3893+ 0,
3699 Reach::none(),3894 Reach::none(),
3700 &vec![0i32; chroma_side * chroma_side],3895 &vec![0i32; chroma_side * chroma_side],
3701 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),3896 alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)),
@@ -3706,6 +3901,7 @@ fn decode_inter_block(
3706 cpy,3901 cpy,
3707 chroma_side,3902 chroma_side,
3708 DC_PRED,3903 DC_PRED,
3904+ 0,
3709 Reach::none(),3905 Reach::none(),
3710 &vec![0i32; chroma_side * chroma_side],3906 &vec![0i32; chroma_side * chroma_side],
3711 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),3907 alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)),
@@ -3725,6 +3921,7 @@ fn decode_inter_block(
3725 around[0],3921 around[0],
3726 mode,3922 mode,
3727 mode,3923 mode,
3924+ 0,
3728 reach,3925 reach,
3729 y,3926 y,
3730 px,3927 px,
@@ -3746,6 +3943,7 @@ fn decode_inter_block(
3746 around[1],3943 around[1],
3747 mode,3944 mode,
3748 DC_PRED,3945 DC_PRED,
3946+ 0,
3749 Reach::none(),3947 Reach::none(),
3750 u,3948 u,
3751 cpx,3949 cpx,
@@ -3766,6 +3964,7 @@ fn decode_inter_block(
3766 around[2],3964 around[2],
3767 mode,3965 mode,
3768 DC_PRED,3966 DC_PRED,
3967+ 0,
3769 Reach::none(),3968 Reach::none(),
3770 v,3969 v,
3771 cpx,3970 cpx,
@@ -4084,6 +4283,7 @@ fn decode_inter_block8(
4084 py,4283 py,
4085 SIDE,4284 SIDE,
4086 mode,4285 mode,
4286+ 0,
4087 reach,4287 reach,
4088 &vec![0i32; SIDE * SIDE],4288 &vec![0i32; SIDE * SIDE],
4089 None,4289 None,
@@ -4094,6 +4294,7 @@ fn decode_inter_block8(
4094 cpy,4294 cpy,
4095 CHROMA_SIDE,4295 CHROMA_SIDE,
4096 DC_PRED,4296 DC_PRED,
4297+ 0,
4097 Reach::none(),4298 Reach::none(),
4098 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],4299 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],
4099 None,4300 None,
@@ -4104,6 +4305,7 @@ fn decode_inter_block8(
4104 cpy,4305 cpy,
4105 CHROMA_SIDE,4306 CHROMA_SIDE,
4106 DC_PRED,4307 DC_PRED,
4308+ 0,
4107 Reach::none(),4309 Reach::none(),
4108 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],4310 &vec![0i32; CHROMA_SIDE * CHROMA_SIDE],
4109 None,4311 None,
@@ -4123,6 +4325,7 @@ fn decode_inter_block8(
4123 around[0],4325 around[0],
4124 mode,4326 mode,
4125 mode,4327 mode,
4328+ 0,
4126 reach,4329 reach,
4127 y,4330 y,
4128 px,4331 px,
@@ -4143,6 +4346,7 @@ fn decode_inter_block8(
4143 around[1],4346 around[1],
4144 mode,4347 mode,
4145 DC_PRED,4348 DC_PRED,
4349+ 0,
4146 Reach::none(),4350 Reach::none(),
4147 u,4351 u,
4148 cpx,4352 cpx,
@@ -4163,6 +4367,7 @@ fn decode_inter_block8(
4163 around[2],4367 around[2],
4164 mode,4368 mode,
4165 DC_PRED,4369 DC_PRED,
4370+ 0,
4166 Reach::none(),4371 Reach::none(),
4167 v,4372 v,
4168 cpx,4373 cpx,
crates/ec-av1/src/encode.rsmodified+4 -0
@@ -599,6 +599,7 @@ impl Plane<'_> {
599 let mut prediction = vec![0u8; side * side];599 let mut prediction = vec![0u8; side * side];
600 crate::intra::predict(600 crate::intra::predict(
601 mode,601 mode,
602+ 0,
602 above.as_deref(),603 above.as_deref(),
603 left.as_deref(),604 left.as_deref(),
604 corner,605 corner,
@@ -815,6 +816,7 @@ impl Plane<'_> {
815 let mut prediction = vec![0u8; side * side];816 let mut prediction = vec![0u8; side * side];
816 crate::intra::predict(817 crate::intra::predict(
817 mode,818 mode,
819+ 0,
818 above.as_deref(),820 above.as_deref(),
819 left.as_deref(),821 left.as_deref(),
820 corner,822 corner,
@@ -863,6 +865,7 @@ impl Plane<'_> {
863 let mut prediction = vec![0u8; side * side];865 let mut prediction = vec![0u8; side * side];
864 crate::intra::predict(866 crate::intra::predict(
865 mode,867 mode,
868+ 0,
866 above.as_deref(),869 above.as_deref(),
867 left.as_deref(),870 left.as_deref(),
868 corner,871 corner,
@@ -4418,6 +4421,7 @@ mod tests {
4418 for _ in 0..N {4421 for _ in 0..N {
4419 crate::intra::predict(4422 crate::intra::predict(
4420 D45_PRED,4423 D45_PRED,
4424+ 0,
4421 Some(&above),4425 Some(&above),
4422 Some(&left),4426 Some(&left),
4423 Some(128),4427 Some(128),
crates/ec-av1/src/intra.rsmodified+25 -6
@@ -124,6 +124,10 @@ fn dr_intra_derivative(angle: u16) -> i32 {
124 /// `Mode_To_Angle` (spec 9.3), zero for the modes that have no angle.124 /// `Mode_To_Angle` (spec 9.3), zero for the modes that have no angle.
125 const MODE_TO_ANGLE: [u16; 13] = [0, 90, 180, 45, 135, 113, 157, 203, 67, 0, 0, 0, 0];125 const MODE_TO_ANGLE: [u16; 13] = [0, 90, 180, 45, 135, 113, 157, 203, 67, 0, 0, 0, 0];
126 126
127+/// `ANGLE_STEP` (spec 9.3): degrees per unit of `angle_delta`, whose own
128+/// range is `-MAX_ANGLE_DELTA..=MAX_ANGLE_DELTA` (`MAX_ANGLE_DELTA == 3`).
129+const ANGLE_STEP: i32 = 3;
130+
127 /// The edges a block predicts from, as the decoder builds them (spec 7.11.2.2):131 /// The edges a block predicts from, as the decoder builds them (spec 7.11.2.2):
128 /// a side that does not exist is filled from the side that does, a side that132 /// a side that does not exist is filled from the side that does, a side that
129 /// runs out is extended by repeating its last sample, and the corner falls back133 /// runs out is extended by repeating its last sample, and the corner falls back
@@ -195,11 +199,18 @@ impl Edges {
195 /// the edge is extended by repetition where it does not, which is what the199 /// the edge is extended by repetition where it does not, which is what the
196 /// decoder's own clamp to `aboveLimit` and `leftLimit` comes to.200 /// decoder's own clamp to `aboveLimit` and `leftLimit` comes to.
197 ///201 ///
202+/// `angle_delta` (spec `AngleDeltaY`/`AngleDeltaUV`, `-MAX_ANGLE_DELTA` to
203+/// `MAX_ANGLE_DELTA`) steers every one of `V_PRED`, `H_PRED` and the six
204+/// diagonal modes off their base angle by `ANGLE_STEP` degrees per unit (spec
205+/// 7.11.2.1's `pAngle = Mode_To_Angle[mode] + angleDelta * ANGLE_STEP`);
206+/// ignored (must be `0`) for the seven modes that carry no angle at all.
207+///
198 /// # Panics208 /// # Panics
199 /// Panics on a mode this module does not predict, or when `dst` is not209 /// Panics on a mode this module does not predict, or when `dst` is not
200 /// `side * side` long.210 /// `side * side` long.
201 pub fn predict(211 pub fn predict(
202 mode: u8,212 mode: u8,
213+ angle_delta: i32,
203 above: Option<&[u8]>,214 above: Option<&[u8]>,
204 left: Option<&[u8]>,215 left: Option<&[u8]>,
205 corner: Option<u8>,216 corner: Option<u8>,
@@ -208,13 +219,21 @@ pub fn predict(
208 ) {219 ) {
209 assert_eq!(dst.len(), side * side, "the destination is the block");220 assert_eq!(dst.len(), side * side, "the destination is the block");
210 let edges = Edges::build(above, left, corner, side);221 let edges = Edges::build(above, left, corner, side);
211- let angle = MODE_TO_ANGLE[usize::from(mode)];222+ let is_directional = matches!(
212- if matches!(
213 mode,223 mode,
214- D45_PRED | D67_PRED | D113_PRED | D135_PRED | D157_PRED | D203_PRED224+ V_PRED | H_PRED | D45_PRED | D67_PRED | D113_PRED | D135_PRED | D157_PRED | D203_PRED
215- ) {225+ );
216- directional(angle, &edges, side, dst);226+ if is_directional {
217- return;227+ let angle = i32::from(MODE_TO_ANGLE[usize::from(mode)]) + angle_delta * ANGLE_STEP;
228+ // `pAngle == 90`/`180` is `V_PRED`/`H_PRED` at zero delta: a plain
229+ // edge copy, no walk -- and the only two angles `dr_intra_derivative`
230+ // has no table entry for, since libaom special-cases them the same
231+ // way (`av1_is_directional_mode`'s callers never call the z1/z2/z3
232+ // walk there either).
233+ if angle != 90 && angle != 180 {
234+ directional(angle as u16, &edges, side, dst);
235+ return;
236+ }
218 }237 }
219 let weights = &SM_WEIGHTS[side..side * 2];238 let weights = &SM_WEIGHTS[side..side * 2];
220 for row in 0..side {239 for row in 0..side {
crates/ec-av1/src/stream.rsmodified+152 -0
@@ -1175,6 +1175,158 @@ mod tests {
1175 );1175 );
1176 }1176 }
1177 1177
1178+ /// The directional-chroma/angle-delta gate: a real aomenc key frame with
1179+ /// `--enable-directional-intra`/`--enable-angle-delta` left ON (the
1180+ /// opposite of every sibling recipe's `=0`, which existed specifically to
1181+ /// keep this round-2 gap from firing while a different surface was under
1182+ /// test). A colourful, sharp-edged source gives the RD search a reason to
1183+ /// pick a directional `uv_mode` and/or a nonzero angle delta -- some
1184+ /// seeds still won't, so retry like every other real-encoder gate here,
1185+ /// but the first attempt that actually fires either counter must decode
1186+ /// pixel-exact.
1187+ #[test]
1188+ fn a_real_aomenc_stream_with_directional_chroma_decodes_pixel_exact() {
1189+ if !have_ffmpeg() {
1190+ eprintln!(
1191+ "SKIP a_real_aomenc_stream_with_directional_chroma_decodes_pixel_exact: no ffmpeg"
1192+ );
1193+ return;
1194+ }
1195+ if !have_aomenc() {
1196+ eprintln!(
1197+ "SKIP a_real_aomenc_stream_with_directional_chroma_decodes_pixel_exact: no aomenc at {}",
1198+ aomenc_path().display()
1199+ );
1200+ return;
1201+ }
1202+ let (width, height) = (64usize, 64usize);
1203+ let mut refusals = Vec::new();
1204+ let mut fired_runs = 0u32;
1205+ for attempt in 0..40u32 {
1206+ let seed = 42 + attempt;
1207+ let source = format!(
1208+ "mandelbrot=size=64x64:start_scale={}:rate=25",
1209+ 5.0 - f64::from(attempt) * 0.06
1210+ );
1211+ let y4m = Command::new("ffmpeg")
1212+ .args([
1213+ "-v",
1214+ "error",
1215+ "-f",
1216+ "lavfi",
1217+ "-i",
1218+ &source,
1219+ "-pix_fmt",
1220+ "yuv420p",
1221+ "-t",
1222+ "0.04",
1223+ "-f",
1224+ "yuv4mpegpipe",
1225+ "-",
1226+ ])
1227+ .stdin(Stdio::null())
1228+ .stdout(Stdio::piped())
1229+ .stderr(Stdio::piped())
1230+ .output()
1231+ .expect("ffmpeg failed to run");
1232+ assert!(
1233+ y4m.status.success(),
1234+ "ffmpeg fixture: {}",
1235+ String::from_utf8_lossy(&y4m.stderr)
1236+ );
1237+ let mut child = Command::new(aomenc_path())
1238+ .args([
1239+ "--codec=av1",
1240+ "--passes=1",
1241+ "--end-usage=q",
1242+ "--cq-level=45",
1243+ "--cpu-used=0",
1244+ "--enable-rect-partitions=0",
1245+ "--enable-ab-partitions=0",
1246+ "--enable-1to4-partitions=0",
1247+ "--enable-filter-intra=0",
1248+ // Smooth/Paeth chroma is a separate, still-refused round-2
1249+ // gap (an unrelated `Edges::build` no-neighbour bug this
1250+ // lane does not cover) -- off so the RD search's only
1251+ // non-DC/CFL chroma choice left is directional.
1252+ "--enable-smooth-intra=0",
1253+ "--enable-paeth-intra=0",
1254+ "--enable-tx-size-search=0",
1255+ "--enable-cdef=0",
1256+ "--enable-restoration=0",
1257+ // The intra edge filter/upsample (spec 7.11.2.7-2.10) is
1258+ // its own unimplemented corner-cut (`directional()`'s own
1259+ // doc comment) -- off so a nonzero angle delta does not
1260+ // also need it, same convention as every other
1261+ // not-yet-supported tool disabled above.
1262+ "--enable-intra-edge-filter=0",
1263+ "--max-partition-size=32",
1264+ // Same reason as the tx-select gate above: 8x8 and other
1265+ // sub-16x16 splits are a separate, already-named refusal.
1266+ "--min-partition-size=16",
1267+ "--enable-palette=0",
1268+ "--enable-intrabc=0",
1269+ "--enable-cfl-intra=0",
1270+ "--obu",
1271+ "-o",
1272+ "-",
1273+ "-",
1274+ ])
1275+ .stdin(Stdio::piped())
1276+ .stdout(Stdio::piped())
1277+ .stderr(Stdio::piped())
1278+ .spawn()
1279+ .expect("aomenc failed to start");
1280+ child
1281+ .stdin
1282+ .take()
1283+ .expect("aomenc stdin")
1284+ .write_all(&y4m.stdout)
1285+ .expect("writing y4m to aomenc");
1286+ let out = child.wait_with_output().expect("aomenc failed to run");
1287+ assert!(
1288+ out.status.success(),
1289+ "aomenc refused the fixture: {}",
1290+ String::from_utf8_lossy(&out.stderr)
1291+ );
1292+ let stream = out.stdout;
1293+ let (uv_before, angle_before) =
1294+ (decode::directional_uv_hits(), decode::angle_delta_hits());
1295+ let frames = match decode_stream(&stream) {
1296+ Ok(frames) => frames,
1297+ Err(e) => {
1298+ refusals.push(format!("seed {seed}: {e}"));
1299+ continue;
1300+ }
1301+ };
1302+ if decode::directional_uv_hits() == uv_before
1303+ && decode::angle_delta_hits() == angle_before
1304+ {
1305+ refusals.push(format!(
1306+ "seed {seed}: decoded, but neither a directional uv_mode nor a \
1307+ nonzero angle delta fired"
1308+ ));
1309+ continue;
1310+ }
1311+ fired_runs += 1;
1312+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
1313+ assert_eq!(
1314+ frames[0].y, ffmpeg_frames[0].y,
1315+ "luma vs ffmpeg (seed {seed})"
1316+ );
1317+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "U vs ffmpeg (seed {seed})");
1318+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "V vs ffmpeg (seed {seed})");
1319+ if fired_runs >= 4 {
1320+ return;
1321+ }
1322+ }
1323+ assert!(
1324+ fired_runs > 0,
1325+ "every attempt hit a named refusal or never exercised directional chroma:\n{}",
1326+ refusals.join("\n")
1327+ );
1328+ }
1329+
1178 /// As above, but a multi-frame inter sequence -- `--lag-in-frames=01330 /// As above, but a multi-frame inter sequence -- `--lag-in-frames=0
1179 /// --auto-alt-ref=0` keep every non-key frame a simple forward1331 /// --auto-alt-ref=0` keep every non-key frame a simple forward
1180 /// single-`LAST_FRAME` P frame (no alt-ref/backward reference this1332 /// single-`LAST_FRAME` P frame (no alt-ref/backward reference this