forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-cfl': chroma intra-edge filter reads the neighbour's uv_mode below 16x16 (was a literal false; coarse 16px uv map never written by sub-16 blocks)

Browse files at this commit

b49a79b1c5582374758f67de60a90977fd92bfdaAhmet Kaan GümüşParent: e3ed88cf3ecd38
Resolved decode.rs in favour of main's mi-granular uv_mode map family
(sub8merge: uv_mode_col/uv_mode_row + record_uv_mode_mi + smooth_uv_neighbour);
the lane's 3-tuple widening of sub8_mode_col/row is dropped as redundant.
The lane's call sites (decode_leaf_rect, decode_leaf8, decode_block_rect,
decode_block_rect64, decode_block, decode_inter_block) are wired to
smooth_uv_neighbour, and its UV_MODE_MI_OVERRIDE_HITS counter now lives
inside that function. Gate + CFL/angle-delta counters taken from the lane.
crates/ec-av1/src/decode.rsmodified+69 -10
@@ -1426,6 +1426,38 @@ pub(crate) fn mode_mi_override_hits() -> usize {
14261426 MODE_MI_OVERRIDE_HITS.with(|c| c.get())
14271427 }
14281428
1429+// lane-cfl r1: how many times a chroma intra-edge filter-type read
1430+// (`get_filt_type`, libaom reconintra.c) took an above/left UV mode from the
1431+// mi-exact map that DIFFERS from its coarse 16x16 slot -- i.e. how often the
1432+// r1 defect would have filtered a chroma edge with the wrong strength.
1433+thread_local! {
1434+ static UV_MODE_MI_OVERRIDE_HITS: std::cell::Cell<usize> =
1435+ const { std::cell::Cell::new(0) };
1436+}
1437+
1438+/// Current value of [`UV_MODE_MI_OVERRIDE_HITS`].
1439+pub(crate) fn uv_mode_mi_override_hits() -> usize {
1440+ UV_MODE_MI_OVERRIDE_HITS.with(|c| c.get())
1441+}
1442+
1443+// lane-cfl r1 gate counters: `UV_CFL_PRED` blocks (every `cfl_alpha_signs`
1444+// read) and chroma blocks with a NONZERO `angle_delta_uv` -- the two block
1445+// shapes the r1 chroma defect showed up on.
1446+thread_local! {
1447+ static CFL_BLOCK_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1448+ static UV_ANGLE_DELTA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
1449+}
1450+
1451+/// Current value of [`CFL_BLOCK_HITS`].
1452+pub(crate) fn cfl_block_hits() -> usize {
1453+ CFL_BLOCK_HITS.with(|c| c.get())
1454+}
1455+
1456+/// Current value of [`UV_ANGLE_DELTA_HITS`].
1457+pub(crate) fn uv_angle_delta_hits() -> usize {
1458+ UV_ANGLE_DELTA_HITS.with(|c| c.get())
1459+}
1460+
14291461 // lane-sbpart r2: how many superblock-level `PARTITION_HORZ`/`PARTITION_VERT`
14301462 // blocks (two true 64x32/32x64 strips, [`decode_block_rect64`]) fired -- the
14311463 // gate's proof this round's arms actually reached a real block, not just
@@ -3671,7 +3703,14 @@ impl Neighbours {
36713703 /// block to the right reads via `mi(row, col-1)`). Only sub-8x8 leaves
36723704 /// read these back, and only when the recorded position is exactly their
36733705 /// own neighbour -- see [`Self::sub8_mode_col`]'s doc.
3674- fn record_mode_mi(&mut self, mi_r: usize, mi_c: usize, mi_w: usize, mi_h: usize, mode: usize) {
3706+ fn record_mode_mi(
3707+ &mut self,
3708+ mi_r: usize,
3709+ mi_c: usize,
3710+ mi_w: usize,
3711+ mi_h: usize,
3712+ mode: usize,
3713+ ) {
36753714 let (last_r, last_c) = (mi_r + mi_h - 1, mi_c + mi_w - 1);
36763715 for cell in 0..mi_w {
36773716 if let Some(slot) = self.sub8_mode_col.get_mut(mi_c + cell) {
@@ -3739,6 +3778,12 @@ impl Neighbours {
37393778 Some(&(col, m)) if mi_c > self.tile_col0_mi && col == mi_c - 1 => m,
37403779 _ => self.left_uv_mode[r],
37413780 };
3781+ // lane-cfl r1 counter: how often the mi-exact chroma neighbour differs
3782+ // from the coarse [`SUB`] slot -- i.e. how often a chroma edge would
3783+ // have been filtered at the wrong strength by the coarse map alone.
3784+ if above != self.above_uv_mode[c] || left != self.left_uv_mode[r] {
3785+ UV_MODE_MI_OVERRIDE_HITS.with(|h| h.set(h.get() + 1));
3786+ }
37423787 is_smooth_mode(above) || is_smooth_mode(left)
37433788 }
37443789
@@ -4390,6 +4435,9 @@ fn read_intra_mode_rect(
43904435 0
43914436 };
43924437 istep!("angle_uv", angle_delta_uv);
4438+ if angle_delta_uv != 0 {
4439+ UV_ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1));
4440+ }
43934441 let mut filter_intra = None;
43944442 if std::env::var_os("EC_AV1_TRACE").is_some() {
43954443 let (rng, _) = dec.debug_state();
@@ -4777,7 +4825,7 @@ fn decode_block_rect(
47774825 // (spec `get_intra_edge_filter_type`) reads the CHROMA neighbour's
47784826 // `uv_mode`, not the luma one.
47794827 let smooth_neighbor_uv =
4780- is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]);
4828+ neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c);
47814829 // lane-rectsplit r1: `predict_filter_intra` now takes the block's own
47824830 // `bw`x`bh` (`av1_filter_intra_predictor_c` walks its 4x2 patches over a
47834831 // rectangle just as happily), so a `use_filter_intra` strip at this level
@@ -5193,6 +5241,10 @@ fn decode_leaf_rect(
51935241 FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.set(c.get() + 1));
51945242 }
51955243 let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode };
5244+ // lane-cfl r1, same defect as [`decode_leaf_8x8`]: chroma's intra-edge
5245+ // filter type is the NEIGHBOUR's `uv_mode` (libaom `get_filt_type`), not
5246+ // a constant `false`.
5247+ let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c);
51965248 let depth = if tx_select {
51975249 let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh);
51985250 dec.symbol(&mut cdfs.tx_size_cat2[ctx])
@@ -5221,11 +5273,11 @@ fn decode_leaf_rect(
52215273 let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh));
52225274 u.reconstruct_rect(
52235275 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_levels,
5224- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, false,
5276+ alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv,
52255277 );
52265278 v.reconstruct_rect(
52275279 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_levels,
5228- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, false,
5280+ alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv,
52295281 );
52305282 } else {
52315283 // lane-rectx: a genuine 16x8/8x16 luma transform (`TxbSet::LumaRect16x8`,
@@ -5277,7 +5329,7 @@ fn decode_leaf_rect(
52775329 );
52785330 u.reconstruct_rect(
52795331 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &u_residual,
5280- alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, false,
5332+ alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv,
52815333 );
52825334 let v_default_tx = default_intra_tx_type(uv_predict_mode as u8);
52835335 let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1);
@@ -5293,7 +5345,7 @@ fn decode_leaf_rect(
52935345 );
52945346 v.reconstruct_rect(
52955347 cpx, cpy, chroma_w, chroma_h, uv_predict_mode, angle_delta_uv, reach, &v_residual,
5296- alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, false,
5348+ alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv,
52975349 );
52985350 RECT_LEAF_COEFF_HITS.with(|c| c.set(c.get() + 1));
52995351 }
@@ -5377,7 +5429,7 @@ fn decode_block_rect4(
53775429 SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
53785430 }
53795431 let smooth_neighbor_uv =
5380- is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]);
5432+ neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c);
53815433 if filter_intra.is_some() {
53825434 FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1));
53835435 }
@@ -5651,7 +5703,7 @@ fn decode_block_rect64(
56515703 SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
56525704 }
56535705 let smooth_neighbor_uv =
5654- is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]);
5706+ neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c);
56555707 if filter_intra.is_some() {
56565708 // `filter_intra_size_class_rect` already returns `None` for both
56575709 // `(64, 32)` and `(32, 64)` (`av1_filter_intra_allowed_bsize` caps at
@@ -6191,6 +6243,9 @@ fn read_intra_mode(
61916243 0
61926244 };
61936245 istep!("angle_uv", angle_delta_uv);
6246+ if angle_delta_uv != 0 {
6247+ UV_ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1));
6248+ }
61946249 // `read_palette_mode_info` (spec 5.11.13, libaom decodemv.c:567, called
61956250 // at :840 right after `xd->cfl.store_y` and before `read_filter_intra_mode_info`):
61966251 // gated by `av1_allow_palette` (blockd.h -- size bound only,
@@ -6342,6 +6397,7 @@ const UV_CFL_PRED: usize = 13;
63426397 /// joint sign the same way. Returns each plane's final signed `alpha_q3`
63436398 /// (`cfl_idx_to_alpha`, cfl.c): magnitude `idx + 1`, sign-zero collapsing to 0.
63446399 fn read_cfl_alphas(dec: &mut SymbolDecoder, cdfs: &mut Cdfs) -> (i32, i32) {
6400+ CFL_BLOCK_HITS.with(|c| c.set(c.get() + 1));
63456401 let joint_sign = dec.symbol(&mut cdfs.cfl_sign) as i32;
63466402 let sign_u = ((joint_sign + 1) * 11) >> 5;
63476403 let sign_v = (joint_sign + 1) - 3 * sign_u;
@@ -6904,7 +6960,7 @@ fn decode_block(
69046960 SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1));
69056961 }
69066962 let smooth_neighbor_uv =
6907- is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]);
6963+ neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c);
69086964 if std::env::var_os("EC_AV1_TRACE").is_some() {
69096965 eprintln!(
69106966 "TRACE block px={px} py={py} side={side} mode={mode} uv_mode={uv_mode} \
@@ -14693,6 +14749,9 @@ fn decode_inter_block(
1469314749 } else {
1469414750 0
1469514751 };
14752+ if angle_delta_uv != 0 {
14753+ UV_ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1));
14754+ }
1469614755 uv_predict_mode = if uv_mode == UV_CFL_PRED {
1469714756 DC_PRED
1469814757 } else {
@@ -14702,7 +14761,7 @@ fn decode_inter_block(
1470214761 // as [`read_intra_mode`]/[`read_intra_mode_rect`] -- the CHROMA
1470314762 // neighbour's own `uv_mode`, not the luma one.
1470414763 let smooth_neighbor_uv =
14705- is_smooth_mode(neighbours.above_uv_mode[c]) || is_smooth_mode(neighbours.left_uv_mode[r]);
14764+ neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c);
1470614765 // `read_palette_mode_info` (decodemv.c:567, called from
1470714766 // `read_intra_block_mode_info` right after `xd->cfl.store_y`, same
1470814767 // gating and same corner-cut as `read_intra_mode`'s own copy above
crates/ec-av1/src/stream.rsmodified+170 -0
@@ -8178,6 +8178,176 @@ mod tests {
81788178 eprintln!("{NAME}: pixel-exact, mode_mi_override_hits={total_overrides}");
81798179 }
81808180
8181+ /// lane-cfl r1: the chroma intra-edge FILTER TYPE is the neighbour's
8182+ /// `uv_mode` (libaom `get_filt_type`, reconintra.c: `chroma_above_mbmi`/
8183+ /// `chroma_left_mbmi` -> `is_smooth` on `uv_mode`), and two whole decode
8184+ /// paths passed a hardcoded `false` for it -- `decode_leaf_8x8` (every
8185+ /// 8x8 leaf of a SPLIT) and `decode_leaf_rect` (every rect strip below
8186+ /// 16x16), on a stale "chroma stays false (exact) until a smooth/paeth
8187+ /// uv_mode can reach decode at all" comment. On top of that the coarse
8188+ /// `above_uv_mode`/`left_uv_mode` cells are 16px-granular and their
8189+ /// `for cell in 0..w / SUB` write runs ZERO times for any block below
8190+ /// 16x16, so even the paths that DID read them saw whatever a
8191+ /// 16x16-or-larger block had left there (class: context read from one
8192+ /// cell / neighbour map at the wrong granularity). Result on this
8193+ /// recipe: luma byte-exact, entropy ladder identical, and 40 U + 86 V
8194+ /// chroma bytes wrong -- every one of them downstream of one 4x4 chroma
8195+ /// block at mi(8,12) whose D135 + `angle_delta_uv=-3` left edge was
8196+ /// filtered at the wrong strength (`ft=0` where the instrumented aomdec
8197+ /// prints `ft=1`, left edge `95,59,30,28` vs `90,61,37,29`).
8198+ ///
8199+ /// Both arms hard-assert per-attempt counters for the two chroma block
8200+ /// shapes involved (`UV_CFL_PRED` blocks, nonzero `angle_delta_uv`
8201+ /// blocks) plus the mi-exact UV-neighbour override, and are counted only
8202+ /// on an attempt that decoded AND is pixel-compared.
8203+ #[test]
8204+ fn a_real_aomenc_stream_whose_chroma_edge_filter_reads_a_sub16_neighbours_uv_mode_decodes_pixel_exact()
8205+ {
8206+ const NAME: &str = "a_real_aomenc_stream_whose_chroma_edge_filter_reads_a_sub16_neighbours_uv_mode_decodes_pixel_exact";
8207+ let _gate_lock = lock_gate_counters();
8208+ if !have_ffmpeg() {
8209+ eprintln!("SKIP {NAME}: no ffmpeg");
8210+ return;
8211+ }
8212+ if !have_aomenc() {
8213+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
8214+ return;
8215+ }
8216+ let mut compared = 0usize;
8217+ let (width, height) = (64usize, 64usize);
8218+ // 8-bit arm = the r5 residue cell ("mandfi161"); 10-bit arm = its
8219+ // twin through the same recipe at `--bit-depth=10`.
8220+ for depth in [8usize, 10] {
8221+ let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" };
8222+ let y4m = Command::new("ffmpeg")
8223+ .args([
8224+ "-v", "error", "-f", "lavfi", "-i",
8225+ &format!("mandelbrot=size={width}x{height}:start_x=-0.6"),
8226+ "-pix_fmt", pix, "-strict", "-1", "-t", "1", "-vframes", "1",
8227+ "-f", "yuv4mpegpipe", "-",
8228+ ])
8229+ .stdin(Stdio::null())
8230+ .stdout(Stdio::piped())
8231+ .stderr(Stdio::piped())
8232+ .output()
8233+ .expect("ffmpeg failed to run");
8234+ assert!(
8235+ y4m.status.success(),
8236+ "{NAME}: ffmpeg fixture (depth={depth}): {}",
8237+ String::from_utf8_lossy(&y4m.stderr)
8238+ );
8239+ let encode = || {
8240+ let mut child = Command::new(aomenc_path())
8241+ .args([
8242+ "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=16",
8243+ "--cpu-used=4", "--threads=1", "--row-mt=0", "--sb-size=64",
8244+ "--kf-max-dist=0", "--enable-rect-partitions=1",
8245+ "--enable-ab-partitions=0", "--enable-1to4-partitions=0",
8246+ "--enable-tx-size-search=0", "--enable-filter-intra=1",
8247+ "--reduced-tx-type-set=1", "--min-partition-size=8",
8248+ "--max-partition-size=32",
8249+ &format!("--input-bit-depth={depth}"),
8250+ &format!("--bit-depth={depth}"),
8251+ "--obu", "-o", "-", "-",
8252+ ])
8253+ .stdin(Stdio::piped())
8254+ .stdout(Stdio::piped())
8255+ .stderr(Stdio::piped())
8256+ .spawn()
8257+ .expect("aomenc failed to start");
8258+ child
8259+ .stdin
8260+ .take()
8261+ .expect("aomenc stdin")
8262+ .write_all(&y4m.stdout)
8263+ .expect("writing y4m to aomenc");
8264+ let out = child.wait_with_output().expect("aomenc failed to run");
8265+ assert!(
8266+ out.status.success(),
8267+ "aomenc refused the fixture (depth={depth}): {}",
8268+ String::from_utf8_lossy(&out.stderr)
8269+ );
8270+ out.stdout
8271+ };
8272+ let stream = encode();
8273+ assert_eq!(
8274+ stream,
8275+ encode(),
8276+ "{NAME}: aomenc output is not reproducible (depth={depth})"
8277+ );
8278+ let before_cfl = crate::decode::cfl_block_hits();
8279+ let before_angle = crate::decode::uv_angle_delta_hits();
8280+ let before_uv = crate::decode::uv_mode_mi_override_hits();
8281+ let frames = match decode_stream(&stream) {
8282+ Ok(frames) => frames,
8283+ // Only a NAMED refusal is tolerated (COMMON rule): the 10-bit
8284+ // twin of this recipe still stops at another lane's open
8285+ // sub-16 AB-partition / strip-filter-intra refusals, so it
8286+ // cannot be compared yet. Any other error is a failure, and
8287+ // `compared` below keeps the test from passing vacuously.
8288+ Err(e) => {
8289+ let msg = e.to_string();
8290+ assert!(
8291+ msg.contains("unsupported"),
8292+ "{NAME}: decode failed (depth={depth}): {msg}"
8293+ );
8294+ eprintln!("{NAME}: depth={depth} arm refused (not compared): {msg}");
8295+ continue;
8296+ }
8297+ };
8298+ compared += 1;
8299+ // Read only on an attempt that decoded AND is compared below.
8300+ let cfl_blocks = crate::decode::cfl_block_hits() - before_cfl;
8301+ let angle_blocks = crate::decode::uv_angle_delta_hits() - before_angle;
8302+ let uv_overrides = crate::decode::uv_mode_mi_override_hits() - before_uv;
8303+ let ffmpeg_frames = if depth == 10 {
8304+ ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len())
8305+ } else {
8306+ ffmpeg_decode_sequence(&stream, width, height, frames.len())
8307+ };
8308+ assert_eq!(frames.len(), 1, "{NAME}: expected one key frame (depth={depth})");
8309+ assert_eq!(ffmpeg_frames.len(), frames.len(), "{NAME}: ffmpeg frame count");
8310+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
8311+ assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (depth={depth})");
8312+ assert_eq!(
8313+ got.u, want.u,
8314+ "{NAME} frame {i} U vs ffmpeg (depth={depth}, {cfl_blocks} CFL blocks, \
8315+ {angle_blocks} nonzero-angle_delta_uv blocks, {uv_overrides} mi-exact UV \
8316+ neighbour overrides)"
8317+ );
8318+ assert_eq!(
8319+ got.v, want.v,
8320+ "{NAME} frame {i} V vs ffmpeg (depth={depth}, {cfl_blocks} CFL blocks, \
8321+ {angle_blocks} nonzero-angle_delta_uv blocks, {uv_overrides} mi-exact UV \
8322+ neighbour overrides)"
8323+ );
8324+ }
8325+ assert!(
8326+ cfl_blocks > 0,
8327+ "{NAME}: no UV_CFL_PRED block decoded (depth={depth}) -- the gate proves nothing"
8328+ );
8329+ assert!(
8330+ angle_blocks > 0,
8331+ "{NAME}: no nonzero angle_delta_uv chroma block decoded (depth={depth}) -- \
8332+ the chroma intra-edge filter path never ran"
8333+ );
8334+ assert!(
8335+ uv_overrides > 0,
8336+ "{NAME}: no chroma edge-filter read ever took a mi-exact UV neighbour that \
8337+ disagreed with its coarse 16x16 slot (depth={depth}) -- the r1 defect is \
8338+ not exercised"
8339+ );
8340+ eprintln!(
8341+ "{NAME}: pixel-exact at {depth}-bit, cfl_blocks={cfl_blocks} \
8342+ angle_delta_uv_blocks={angle_blocks} uv_mi_overrides={uv_overrides}"
8343+ );
8344+ }
8345+ assert!(
8346+ compared > 0,
8347+ "{NAME}: every arm refused -- the gate compared no pixels at all"
8348+ );
8349+ }
8350+
81818351 #[test]
81828352 #[ignore = "lane-rectx r3 scratch sweep"]
81838353 fn sweep_rectx_recipes() {
lanes/cfl-r1.report.mdadded+87 -0
@@ -0,0 +1,87 @@
1+# lane-cfl r1+r2 report — chroma intra-edge filter type below 16x16
2+
3+Branch `lane-cfl` @ `7148dba` (off `lane-rectx` bb41f82; not rebased, per charter).
4+r1 and r2 were both killed at their turn/session cap; their work was preserved as WIP
5+commits 38d096e + 455a142 and is squashed into `7148dba` by this round.
6+
7+## Root cause
8+
9+libaom `get_filt_type` (reconintra.c) chooses the chroma intra-edge filter STRENGTH from
10+`chroma_above_mbmi`/`chroma_left_mbmi`'s `uv_mode` (smooth-family neighbour => filtered
11+edge). Two defects stacked on the sub-16x16 path:
12+
13+1. **Constant `false`.** `decode_leaf_rect` and `decode_leaf_8x8` passed a literal `false`
14+ as `smooth_neighbor_uv` into every chroma `reconstruct_rect` call, so a chroma edge was
15+ never smooth-filtered below 16x16 regardless of the neighbour.
16+2. **Neighbour map coarser than the block.** `above_uv_mode`/`left_uv_mode` are written in
17+ `SUB` (16px) cells by `for cell in 0..w / SUB`, which iterates ZERO times for a block
18+ narrower/shorter than 16. A sub-16 block therefore never *wrote* its uv_mode, and every
19+ reader (including the 16x16-and-up ones) saw whatever the last 16x16-or-larger block had
20+ left in that slot. Class: *context read from one cell* / neighbour map coarser than the
21+ block, the chroma twin of lane-rectx r5's luma `mode_above_mi`/`mode_left_mi`.
22+
23+Observed symptom before the fix: the mandelbrot cq16 cell filtered a chroma left edge at
24+`ft=0` where the instrumented aomdec prints `ft=1` (left edge `95,59,30,28` vs `90,61,37,29`).
25+
26+## Files changed
27+
28+- `crates/ec-av1/src/decode.rs:1886,2015,2089,2349,2595` — `Neighbours::sub8_mode_col/row`
29+ widened from `(pos, mode)` to `(pos, mode, uv_mode)`; every reset/init site updated.
30+- `crates/ec-av1/src/decode.rs:2622-2680` — `uv_mode_above_mi`/`uv_mode_left_mi` and
31+ `uv_modes_above_left{,_mi}`: mi-exact chroma neighbour with the coarse `SUB` slot as
32+ fallback; tile-edge guards (`mi_r > tile_row0_mi` / `mi_c > tile_col0_mi`) inherited from
33+ the luma twin, per the COMMON neighbour-map rule.
34+- `crates/ec-av1/src/decode.rs:3422,3825,4001,5122,5552` — every `smooth_neighbor_uv`
35+ derivation now goes through `uv_modes_above_left{,_mi}`; `decode_leaf_rect` (3825) and
36+ `decode_leaf_8x8` (5552) previously had none at all.
37+- `crates/ec-av1/src/decode.rs:3854,3858,3910,3926, 5216..5428` — chroma reconstruct call
38+ sites take the derived flag. **Sweep: `grep -c "None, false," decode.rs` = 0** — no
39+ constant-false chroma edge-filter site remains.
40+- `crates/ec-av1/src/decode.rs:775-805,3294` — gate counters `uv_mode_mi_override_hits`,
41+ `cfl_block_hits`, `uv_angle_delta_hits`.
42+- `crates/ec-av1/src/stream.rs:5597-5742` — the gate (below).
43+
44+No refusal string was lifted this lane (none in `refusal_inventory.rs` covered this path);
45+`gate_coverage.rs` unchanged.
46+
47+## Gate
48+
49+`a_real_aomenc_stream_whose_chroma_edge_filter_reads_a_sub16_neighbours_uv_mode_decodes_pixel_exact`
50+— real aomenc, `mandelbrot=size=64x64:start_x=-0.6`, `--cq-level=16 --cpu-used=4
51+--sb-size=64 --enable-rect-partitions=1 --enable-filter-intra=1 --reduced-tx-type-set=1
52+--min-partition-size=8 --max-partition-size=32`, aomenc output hashed twice for
53+reproducibility, pixel-compared against ffmpeg. Hard asserts `cfl_blocks > 0`,
54+`angle_blocks > 0`, `uv_overrides > 0`, and `compared > 0` (no vacuous pass). The 10-bit
55+arm is tolerated ONLY on a message containing "unsupported" and is then not compared.
56+
57+```
58+EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib chroma_edge_filter_reads_a_sub16 -- --nocapture
59+```
60+
61+EVIDENCE: $HOME/.cache/cfl-suite.log (gate line) | aomenc mandelbrot -0.6 64x64 cq16 rtx=1 filter-intra=1, decode_stream vs ffmpeg_decode_sequence, all three planes | pixel-exact at 8-bit, cfl_blocks=15 angle_delta_uv_blocks=19 uv_mi_overrides=52; test result ok 1 passed
62+
63+EVIDENCE: scratchpad/ours.yuv vs scratchpad/ff.yuv | `cargo run -p ec-av1 --example decode_probe -- cfl.obu ours.yuv` on the same aomenc stream; `ffmpeg -i cfl.obu -pix_fmt yuv420p -f rawvideo ff.yuv`; `cmp` | byte-identical, 6144 bytes, sha256 c8cfa9b332f9c6e8...
64+
65+## Suite
66+
67+`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib` (log `$HOME/.cache/cfl-suite.log`):
68+**273 passed; 0 failed; 24 ignored; 0 filtered out** (963.81s), exit 0.
69+
70+Siblings re-run green in that suite (COMMON sibling-gate rule): `a_real_libaom_cfl_stream_decodes_pixel_exact`,
71+`a_real_aomenc_stream_whose_square_block_reads_a_sub16_neighbours_mode_decodes_pixel_exact`,
72+`a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16_decodes_pixel_exact`,
73+`a_rect_strip_below_16x16_reads_its_own_filter_intra_cdf_row`,
74+`a_real_aomenc_filter_intra_stream_decodes_pixel_exact`,
75+`a_real_aomenc_stream_with_smooth_luma_neighbour_decodes_pixel_exact`,
76+`a_real_aomenc_stream_with_smooth_paeth_chroma_decodes_pixel_exact`,
77+`a_real_aomenc_stream_with_directional_chroma_decodes_pixel_exact`,
78+`rect_reach_tables_are_indexed_with_a_32_mi_row_stride`, plus all three
79+`refusal_inventory::tests::*` and both `gate_coverage::tests::*`.
80+
81+## Residue
82+
83+- deferred(lane owning sub-16 AB partitions): the 10-bit twin of this recipe stops at
84+ `a HORZ_A/HORZ_B/VERT_A partition below 16x16` and is therefore never pixel-compared.
85+ The gate records this explicitly rather than passing silently.
86+- accepted: no refusal string lifted — this round is a correctness fix behind existing
87+ capability, not a capability claim.