forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-tiles': multi-tile decode, gated on real streams

Browse files at this commit

97ae5178454b3710e445b8c01828d21059cbfa20Ahmet Kaan GümüşParent: cee9a3d5183637
Four tile columns with the loop filter ON decode pixel-exact, and so do two
columns across an inter frame -- three new real-aomenc gates, 20/20 each.
decode_inter_frame_tile_with_cdfs has the same per-tile loop the key-frame path
has, and the MV-candidate scan is bounded by giving the shared MiGrid tile
bounds, which clamps all four find_mv_stack* call sites through one choke point
instead of widening their signatures.

Three refusals gone: more than two tile columns, multi-tile with loop filtering
enabled, and inter frames with more than one tile. Only tile ROWS still refuse.

The round before this one had lifted the inter refusal with only a green suite
behind it -- which exercises nothing the refusal guarded -- so the branch was
held out of main until the gate existed. Writing it found that
decode_inter_frame_tile_with_cdfs never incremented TILE_HITS: the gate's own
tile-count assert would have passed while blind. That is twice now that "the
suite is green" stood in for evidence, and twice that the gate found something
the suite could not.

AV1 has no loop_filter_across_tiles bit at all, unlike HEVC -- deblocking
crosses tile boundaries unconditionally -- so the loop-filter refusal was
really the same right-edge reach bound as the column-count one, and both lifted
together once PlaneBuf's tile clamps received real values.

Suite 245 passed / 0 failed.
crates/ec-av1/src/decode.rsmodified+154 -26
@@ -2844,6 +2844,13 @@ struct PlaneBuf {
28442844 /// right/bottom reach bound is still open, tracked in the report.
28452845 tile_x0: usize,
28462846 tile_y0: usize,
2847+ /// lane-tiles r5: this plane's own tile's right/bottom pixel bound
2848+ /// (exclusive) -- a non-last tile column/row's own reach must stop at
2849+ /// its own SB-aligned tile boundary. `width`/`height` (this plane's
2850+ /// full padded extent) for the single-tile/last-tile case, matching the
2851+ /// old unclipped behaviour exactly.
2852+ tile_x1: usize,
2853+ tile_y1: usize,
28472854 }
28482855
28492856 /// One entry per `MV_REFERENCE_FRAME` (index 0/1 unused -- `NONE`/
@@ -2859,9 +2866,11 @@ impl PlaneBuf {
28592866 /// [`Self::tile_y0`]) before that tile's own superblock walk. `x0`/`y0`
28602867 /// are already in this plane's own units (luma pixels for `y`, chroma
28612868 /// pixels — halved — for `u`/`v`).
2862- fn set_tile_origin(&mut self, x0: usize, y0: usize) {
2869+ fn set_tile_origin(&mut self, x0: usize, y0: usize, x1: usize, y1: usize) {
28632870 self.tile_x0 = x0;
28642871 self.tile_y0 = y0;
2872+ self.tile_x1 = x1;
2873+ self.tile_y1 = y1;
28652874 }
28662875
28672876 fn edges(
@@ -2877,14 +2886,16 @@ impl PlaneBuf {
28772886 } else {
28782887 own_across
28792888 }
2880- .min(self.width);
2889+ .min(self.width)
2890+ .min(self.tile_x1);
28812891 let own_down = y + side.min(self.true_height.saturating_sub(y));
28822892 let down = if reach.below_left {
28832893 own_down + side.min(self.true_height.saturating_sub(own_down))
28842894 } else {
28852895 own_down
28862896 }
2887- .min(self.height);
2897+ .min(self.height)
2898+ .min(self.tile_y1);
28882899 let above = (y > self.tile_y0 && across > x)
28892900 .then(|| self.data[(y - 1) * self.width + x..][..across - x].to_vec());
28902901 let left = (x > self.tile_x0 && down > y).then(|| {
@@ -2914,14 +2925,16 @@ impl PlaneBuf {
29142925 } else {
29152926 own_across
29162927 }
2917- .min(self.width);
2928+ .min(self.width)
2929+ .min(self.tile_x1);
29182930 let own_down = y + bh.min(self.true_height.saturating_sub(y));
29192931 let down = if reach.below_left {
29202932 own_down + bh.min(self.true_height.saturating_sub(own_down))
29212933 } else {
29222934 own_down
29232935 }
2924- .min(self.height);
2936+ .min(self.height)
2937+ .min(self.tile_y1);
29252938 let above = (y > self.tile_y0 && across > x)
29262939 .then(|| self.data[(y - 1) * self.width + x..][..across - x].to_vec());
29272940 let left = (x > self.tile_x0 && down > y).then(|| {
@@ -4818,6 +4831,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
48184831 true_height,
48194832 tile_x0: 0,
48204833 tile_y0: 0,
4834+ tile_x1: width,
4835+ tile_y1: height,
48214836 };
48224837 let mut u = PlaneBuf {
48234838 data: vec![0u8; width * height / 4],
@@ -4827,6 +4842,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
48274842 true_height: true_height / 2,
48284843 tile_x0: 0,
48294844 tile_y0: 0,
4845+ tile_x1: width / 2,
4846+ tile_y1: height / 2,
48304847 };
48314848 let mut v = PlaneBuf {
48324849 data: vec![0u8; width * height / 4],
@@ -4836,6 +4853,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
48364853 true_height: true_height / 2,
48374854 tile_x0: 0,
48384855 tile_y0: 0,
4856+ tile_x1: width / 2,
4857+ tile_y1: height / 2,
48394858 };
48404859
48414860 let scan32 = default_scan(TX32);
@@ -4888,9 +4907,24 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
48884907 }
48894908 let mut dec = SymbolDecoder::new(tile_bytes);
48904909 neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize);
4891- y.set_tile_origin(mi_col0 as usize * 4, mi_row0 as usize * 4);
4892- u.set_tile_origin(mi_col0 as usize * 2, mi_row0 as usize * 2);
4893- v.set_tile_origin(mi_col0 as usize * 2, mi_row0 as usize * 2);
4910+ y.set_tile_origin(
4911+ mi_col0 as usize * 4,
4912+ mi_row0 as usize * 4,
4913+ (mi_col1 as usize * 4).min(y.width),
4914+ (mi_row1 as usize * 4).min(y.height),
4915+ );
4916+ u.set_tile_origin(
4917+ mi_col0 as usize * 2,
4918+ mi_row0 as usize * 2,
4919+ (mi_col1 as usize * 2).min(u.width),
4920+ (mi_row1 as usize * 2).min(u.height),
4921+ );
4922+ v.set_tile_origin(
4923+ mi_col0 as usize * 2,
4924+ mi_row0 as usize * 2,
4925+ (mi_col1 as usize * 2).min(v.width),
4926+ (mi_row1 as usize * 2).min(v.height),
4927+ );
48944928 TILE_HITS.with(|c| c.set(c.get() + 1));
48954929
48964930 for sb_r in sb_r0..sb_r1 {
@@ -9455,8 +9489,14 @@ pub fn decode_inter_frame_tile(
94559489 enable_dual_filter: bool,
94569490 reference_select: bool,
94579491 ) -> Result<Picture> {
9492+ let single_tile = TileInfo {
9493+ mi_col_starts: vec![0, mi_cols],
9494+ mi_row_starts: vec![0, mi_rows],
9495+ ..TileInfo::default()
9496+ };
94589497 decode_inter_frame_tile_with_cdfs(
9459- data,
9498+ &[data],
9499+ &single_tile,
94609500 mi_cols,
94619501 mi_rows,
94629502 base_q_idx,
@@ -9497,7 +9537,8 @@ pub fn decode_inter_frame_tile(
94979537 /// `primary_ref_frame == PRIMARY_REF_NONE` too (an error-resilient stream),
94989538 /// so `None` is a real case here, not only a convenience default.
94999539 pub(crate) fn decode_inter_frame_tile_with_cdfs(
9500- data: &[u8],
9540+ tiles: &[&[u8]],
9541+ tile_info: &TileInfo,
95019542 mi_cols: u32,
95029543 mi_rows: u32,
95039544 base_q_idx: u8,
@@ -9587,6 +9628,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
95879628 true_height: reference.height,
95889629 tile_x0: 0,
95899630 tile_y0: 0,
9631+ tile_x1: reference.width,
9632+ tile_y1: reference.height,
95909633 };
95919634 let ref_u = PlaneBuf {
95929635 data: reference.u.clone(),
@@ -9596,6 +9639,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
95969639 true_height: reference.height / 2,
95979640 tile_x0: 0,
95989641 tile_y0: 0,
9642+ tile_x1: reference.width / 2,
9643+ tile_y1: reference.height / 2,
95999644 };
96009645 let ref_v = PlaneBuf {
96019646 data: reference.v.clone(),
@@ -9605,6 +9650,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
96059650 true_height: reference.height / 2,
96069651 tile_x0: 0,
96079652 tile_y0: 0,
9653+ tile_x1: reference.width / 2,
9654+ tile_y1: reference.height / 2,
96089655 };
96099656 // Every non-`LAST_FRAME` reference this frame header's own `ref_frame_idx`
96109657 // names a live DPB slot for (lane-av1refs: generalised from the old
@@ -9626,6 +9673,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
96269673 true_height: g.height,
96279674 tile_x0: 0,
96289675 tile_y0: 0,
9676+ tile_x1: g.width,
9677+ tile_y1: g.height,
96299678 },
96309679 PlaneBuf {
96319680 data: g.u.clone(),
@@ -9635,6 +9684,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
96359684 true_height: g.height / 2,
96369685 tile_x0: 0,
96379686 tile_y0: 0,
9687+ tile_x1: g.width / 2,
9688+ tile_y1: g.height / 2,
96389689 },
96399690 PlaneBuf {
96409691 data: g.v.clone(),
@@ -9644,6 +9695,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
96449695 true_height: g.height / 2,
96459696 tile_x0: 0,
96469697 tile_y0: 0,
9698+ tile_x1: g.width / 2,
9699+ tile_y1: g.height / 2,
96479700 },
96489701 )
96499702 })
@@ -9659,6 +9712,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
96599712 true_height,
96609713 tile_x0: 0,
96619714 tile_y0: 0,
9715+ tile_x1: width,
9716+ tile_y1: height,
96629717 };
96639718 let mut u = PlaneBuf {
96649719 data: vec![0u8; width * height / 4],
@@ -9668,6 +9723,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
96689723 true_height: true_height / 2,
96699724 tile_x0: 0,
96709725 tile_y0: 0,
9726+ tile_x1: width / 2,
9727+ tile_y1: height / 2,
96719728 };
96729729 let mut v = PlaneBuf {
96739730 data: vec![0u8; width * height / 4],
@@ -9677,6 +9734,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
96779734 true_height: true_height / 2,
96789735 tile_x0: 0,
96799736 tile_y0: 0,
9737+ tile_x1: width / 2,
9738+ tile_y1: height / 2,
96809739 };
96819740
96829741 let scan32 = default_scan(TX32);
@@ -9684,18 +9743,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
96849743 let scan8 = default_scan(TX8);
96859744 let scan4 = default_scan(TX4);
96869745
9687- let mut cdfs = initial_cdfs.unwrap_or_else(|| Cdfs::new(q_ctx_of(base_q_idx)));
9688- let mut dec = SymbolDecoder::new(data);
9689- // lane-comppin r9: tile-entry range, the earliest point comparable
9690- // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the
9691- // first ladder rung before any symbol (partition or otherwise) is read.
9692- if std::env::var_os("EC_AV1_TELL").is_some() {
9693- eprintln!(
9694- "TELL label=tile_init tell={} range={}",
9695- dec.debug_bitpos(),
9696- dec.debug_state().0
9697- );
9698- }
9746+ let base_cdfs = initial_cdfs.unwrap_or_else(|| Cdfs::new(q_ctx_of(base_q_idx)));
9747+ let mut result_cdfs = base_cdfs.clone();
96999748 let mut neighbours = Neighbours::new(
97009749 cols as usize * 2,
97019750 rows as usize * 2,
@@ -9704,9 +9753,73 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
97049753 );
97059754 let mut grid = MiGrid::new(mi_cols as usize, mi_rows as usize);
97069755
9707- for sb_r in 0..sb_rows {
9756+ // lane-tiles r6: mirrors decode_key_frame_tile_with_cdfs's own per-tile
9757+ // loop (spec 5.11.2 decode_tile / 7.20 exit_symbol) -- each tile gets
9758+ // its own fresh SymbolDecoder over its own byte range and its own fresh
9759+ // copy of the frame's initial CDFs; only context_update_tile_id's own
9760+ // end-of-tile adapted table becomes the frame's own output.
9761+ for (tile_idx, &data) in tiles.iter().enumerate() {
9762+ let tile_num = tile_idx as u32;
9763+ let (trow, tcol) = (tile_num / tile_info.cols, tile_num % tile_info.cols);
9764+ let mi_row0 = tile_info.mi_row_starts[trow as usize];
9765+ let mi_row1 = tile_info.mi_row_starts[trow as usize + 1];
9766+ let mi_col0 = tile_info.mi_col_starts[tcol as usize];
9767+ let mi_col1 = tile_info.mi_col_starts[tcol as usize + 1];
9768+ let (sb_r0, sb_r1) = (
9769+ (mi_row0 / SB_MI).min(sb_rows),
9770+ mi_row1.div_ceil(SB_MI).min(sb_rows),
9771+ );
9772+ let (sb_c0, sb_c1) = (
9773+ (mi_col0 / SB_MI).min(sb_cols),
9774+ mi_col1.div_ceil(SB_MI).min(sb_cols),
9775+ );
9776+ let mut cdfs = base_cdfs.clone();
9777+ let mut dec = SymbolDecoder::new(data);
9778+ // lane-comppin r9: tile-entry range, the earliest point comparable
9779+ // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the
9780+ // first ladder rung before any symbol (partition or otherwise) is read.
9781+ if std::env::var_os("EC_AV1_TELL").is_some() {
9782+ eprintln!(
9783+ "TELL label=tile_init tell={} range={}",
9784+ dec.debug_bitpos(),
9785+ dec.debug_state().0
9786+ );
9787+ }
9788+ neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize);
9789+ y.set_tile_origin(
9790+ mi_col0 as usize * 4,
9791+ mi_row0 as usize * 4,
9792+ (mi_col1 as usize * 4).min(y.width),
9793+ (mi_row1 as usize * 4).min(y.height),
9794+ );
9795+ u.set_tile_origin(
9796+ mi_col0 as usize * 2,
9797+ mi_row0 as usize * 2,
9798+ (mi_col1 as usize * 2).min(u.width),
9799+ (mi_row1 as usize * 2).min(u.height),
9800+ );
9801+ v.set_tile_origin(
9802+ mi_col0 as usize * 2,
9803+ mi_row0 as usize * 2,
9804+ (mi_col1 as usize * 2).min(v.width),
9805+ (mi_row1 as usize * 2).min(v.height),
9806+ );
9807+ // lane-tiles r6: an MV candidate scan (mvstack.rs's grid.get) must
9808+ // not reach across a tile boundary any more than intra prediction's
9809+ // PlaneBuf reach does -- bounding the shared grid's own read window
9810+ // per tile is equivalent to threading tile bounds through every
9811+ // find_mv_stack* call site (all four read through this one grid).
9812+ grid.set_tile_bounds(
9813+ mi_row0 as usize,
9814+ mi_col0 as usize,
9815+ mi_row1 as usize,
9816+ mi_col1 as usize,
9817+ );
9818+ TILE_HITS.with(|c| c.set(c.get() + 1));
9819+
9820+ for sb_r in sb_r0..sb_r1 {
97089821 neighbours.start_row();
9709- for sb_c in 0..sb_cols {
9822+ for sb_c in sb_c0..sb_c1 {
97109823 CDEF_TRANSMITTED.with(|c| c.set(false));
97119824 let sb_at = (sb_r as usize * 4, sb_c as usize * 4);
97129825 let sb_ctx = neighbours.partition_ctx(sb_at, SB);
@@ -10896,6 +11009,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1089611009 }
1089711010 }
1089811011
11012+ if tile_num == tile_info.context_update_tile_id {
11013+ result_cdfs = cdfs;
11014+ }
11015+ }
11016+
1089911017 // lane-comppin r4: pre-loop-filter decode-order dump, matching aomdec's
1090011018 // own EC_AV1_PREFILT_DUMP shape (decodeframe.c ~5451) -- diffs against
1090111019 // that isolate whether a decode-order frame's mismatch already exists
@@ -10933,7 +11051,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1093311051 u: u.data,
1093411052 v: v.data,
1093511053 },
10936- cdfs,
11054+ result_cdfs,
1093711055 motion_field,
1093811056 ));
1093911057 }
@@ -10952,7 +11070,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
1095211070 u: crop(&u, fw / 2, fh / 2),
1095311071 v: crop(&v, fw / 2, fh / 2),
1095411072 },
10955- cdfs,
11073+ result_cdfs,
1095611074 motion_field,
1095711075 ))
1095811076 }
@@ -11621,6 +11739,8 @@ mod tests {
1162111739 true_height: height / scale,
1162211740 tile_x0: 0,
1162311741 tile_y0: 0,
11742+ tile_x1: width / scale,
11743+ tile_y1: height / scale,
1162411744 };
1162511745 let ref_y = PlaneBuf {
1162611746 data: ref_pattern.clone(),
@@ -11630,6 +11750,8 @@ mod tests {
1163011750 true_height: height,
1163111751 tile_x0: 0,
1163211752 tile_y0: 0,
11753+ tile_x1: width,
11754+ tile_y1: height,
1163311755 };
1163411756 let ref_u = ref_plane(2);
1163511757 let ref_v = ref_plane(2);
@@ -11642,6 +11764,8 @@ mod tests {
1164211764 true_height: height,
1164311765 tile_x0: 0,
1164411766 tile_y0: 0,
11767+ tile_x1: width,
11768+ tile_y1: height,
1164511769 };
1164611770 let mut u = PlaneBuf {
1164711771 data: vec![0u8; (width / 2) * (height / 2)],
@@ -11651,6 +11775,8 @@ mod tests {
1165111775 true_height: height / 2,
1165211776 tile_x0: 0,
1165311777 tile_y0: 0,
11778+ tile_x1: width / 2,
11779+ tile_y1: height / 2,
1165411780 };
1165511781 let mut v = PlaneBuf {
1165611782 data: vec![0u8; (width / 2) * (height / 2)],
@@ -11660,6 +11786,8 @@ mod tests {
1166011786 true_height: height / 2,
1166111787 tile_x0: 0,
1166211788 tile_y0: 0,
11789+ tile_x1: width / 2,
11790+ tile_y1: height / 2,
1166311791 };
1166411792
1166511793 let mut cdfs = Cdfs::new(q_ctx_of(100));
crates/ec-av1/src/mvstack.rsmodified+33 -3
@@ -177,6 +177,15 @@ pub struct MiGrid {
177177 cols: usize,
178178 rows: usize,
179179 cells: Vec<Option<MiInfo>>,
180+ /// lane-tiles r6: the current tile's own mi-unit bounds (spec: an MV
181+ /// candidate scan never reaches across a tile boundary, mirroring
182+ /// `PlaneBuf`'s `tile_x0`/`tile_x1` reach clamp for intra prediction).
183+ /// Defaults to the whole grid (the single-tile case, unchanged old
184+ /// behaviour) and is narrowed per tile via [`Self::set_tile_bounds`].
185+ tile_row0: usize,
186+ tile_col0: usize,
187+ tile_row1: usize,
188+ tile_col1: usize,
180189 }
181190
182191 impl MiGrid {
@@ -186,9 +195,24 @@ impl MiGrid {
186195 cols,
187196 rows,
188197 cells: vec![None; cols * rows],
198+ tile_row0: 0,
199+ tile_col0: 0,
200+ tile_row1: rows,
201+ tile_col1: cols,
189202 }
190203 }
191204
205+ /// Narrows [`Self::get`]'s own read window to one tile's mi-unit span
206+ /// (`row1`/`col1` exclusive) -- called once per tile, before that
207+ /// tile's own superblock walk, the same way `Neighbours::start_tile`
208+ /// and `PlaneBuf::set_tile_origin` are.
209+ pub fn set_tile_bounds(&mut self, row0: usize, col0: usize, row1: usize, col1: usize) {
210+ self.tile_row0 = row0;
211+ self.tile_col0 = col0;
212+ self.tile_row1 = row1;
213+ self.tile_col1 = col1;
214+ }
215+
192216 /// Records the unit at `(row, col)`. Out-of-range coordinates are a
193217 /// no-op — the caller only ever addresses units inside the grid it built.
194218 pub fn set(&mut self, row: usize, col: usize, info: MiInfo) {
@@ -197,10 +221,16 @@ impl MiGrid {
197221 }
198222 }
199223
200- /// The unit at `(row, col)`, or `None` when it is outside the grid (the
201- /// tile) or hasn't been coded.
224+ /// The unit at `(row, col)`, or `None` when it is outside the grid, hasn't
225+ /// been coded, or sits outside the current tile's own bounds ([`Self::set_tile_bounds`]).
202226 pub fn get(&self, row: usize, col: usize) -> Option<&MiInfo> {
203- if row < self.rows && col < self.cols {
227+ if row < self.rows
228+ && col < self.cols
229+ && row >= self.tile_row0
230+ && row < self.tile_row1
231+ && col >= self.tile_col0
232+ && col < self.tile_col1
233+ {
204234 self.cells[row * self.cols + col].as_ref()
205235 } else {
206236 None
crates/ec-av1/src/refusal_inventory.rsmodified+0 -3
@@ -53,9 +53,6 @@ const REFUSALS: &[&str] = &[
5353 "a frame with delta_q_present or delta_lf_present set (this decoder never reads the per-superblock delta symbols)",
5454 "a frame with loop restoration enabled (this decoder never reads the per-unit lr symbols)",
5555 "a frame with more than one tile row (only tile columns are proven pixel-exact so far)",
56- "a frame with more than two tile columns (a non-last column's right-edge reach bound past column 0 is unimplemented)",
57- "a multi-tile frame with loop filtering enabled (deblocking crosses tile boundaries by spec default; PlaneBuf's tile origin does not clip a non-last column's right-edge reach)",
58- "an inter frame with more than one tile (the inter tile-decode path has no per-tile loop, only key frames do)",
5956 "a frame with no mode-info grid",
6057 "a frame with segmentation enabled (this decoder never reads a per-block segment_id symbol)",
6158 "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding",
crates/ec-av1/src/stream.rsmodified+400 -57
@@ -302,55 +302,26 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
302302 // naming a different tile there is refused rather than silently
303303 // forwarding the wrong tile's table.
304304 //
305- // lane-tiles r4: the multi-tile refusal itself is now scoped, not
306- // blanket. `decode_key_frame_tile_with_cdfs` genuinely loops every
307- // tile (r2/r3), proven pixel-exact by
308- // `a_real_aomenc_stream_with_two_tile_columns_decodes_pixel_exact`
309- // (2 tile columns, `--loopfilter-control=0`) -- but that gate's own
310- // doc comment names two gaps it deliberately sidesteps, so this
311- // refusal keeps refusing exactly those:
312- // - `decode_inter_frame_tile_with_cdfs` takes one `&[u8]` tile
313- // payload, not a `tiles: &[&[u8]]` list -- it has no per-tile
314- // loop at all, so an inter frame with >1 tile is still refused
315- // unconditionally.
316- // - Deblocking crosses tile boundaries by spec default (AV1 has
317- // no `loop_filter_across_tiles_enabled`-style flag at all --
318- // confirmed absent from `ec-av1-syntax`'s `loop_filter_params`
319- // read, spec 5.9.11 has no such field either), but `PlaneBuf`'s
320- // `tile_x0`/`tile_y0` origin only ever clips a tile's own
321- // left/top reach, not a non-last column's right-edge reach --
322- // so a key frame with `loop_filter.level` non-zero (deblocking
323- // actually on) still refuses.
324- // - The proven gate is 2 tile *columns*, 1 tile *row*; a
325- // non-last column's right-edge reach bound past column 0 is
326- // unimplemented for 3+ columns (r3's own known gap), so `cols`
327- // is capped at 2. Tile rows are untested this round, so `rows`
328- // stays capped at 1.
329- let loop_filter_on = header.loop_filter.level.iter().any(|&l| l != 0);
330- if header.frame_type != FrameType::Key && header.tile_info.cols > 1 {
331- return Err(Error::unsupported(
332- "AV1 decode_stream",
333- "an inter frame with more than one tile (the inter tile-decode path has no per-tile loop, only key frames do)",
334- ));
335- }
305+ // lane-tiles r4/r6/r7: the multi-tile refusal itself is scoped, not
306+ // blanket. `decode_key_frame_tile_with_cdfs` and (r6)
307+ // `decode_inter_frame_tile_with_cdfs` both genuinely loop every
308+ // tile, `mvstack.rs`'s `MiGrid` is bounded per tile
309+ // (`MiGrid::set_tile_bounds`), and `PlaneBuf`'s `tile_x0/y0/x1/y1`
310+ // origin receives real values at every call site (r6's
311+ // `set_tile_origin` sweep). r7 proved the two remaining named gaps
312+ // both closed: `a_real_aomenc_stream_with_two_tile_columns_and_an_
313+ // inter_frame_decodes_pixel_exact` (inter frame, 2 tile columns) and
314+ // `a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact`
315+ // (>2 columns AND loop filtering ON, an interior tile boundary) --
316+ // 20/20 pixel-exact each. Only tile *rows* stay unproven and
317+ // refused; tile *columns* (any count) and loop filtering across
318+ // them are no longer capped.
336319 if header.tile_info.rows > 1 {
337320 return Err(Error::unsupported(
338321 "AV1 decode_stream",
339322 "a frame with more than one tile row (only tile columns are proven pixel-exact so far)",
340323 ));
341324 }
342- if header.tile_info.cols > 2 {
343- return Err(Error::unsupported(
344- "AV1 decode_stream",
345- "a frame with more than two tile columns (a non-last column's right-edge reach bound past column 0 is unimplemented)",
346- ));
347- }
348- if header.tile_info.cols > 1 && loop_filter_on {
349- return Err(Error::unsupported(
350- "AV1 decode_stream",
351- "a multi-tile frame with loop filtering enabled (deblocking crosses tile boundaries by spec default; PlaneBuf's tile origin does not clip a non-last column's right-edge reach)",
352- ));
353- }
354325 // `Tile::offset` is relative to the buffer `parse_obu` was handed
355326 // (`&data[pos..]` at the time this OBU was parsed), so it is relative
356327 // to `obu_offset`, not to `data` as a whole.
@@ -491,7 +462,8 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
491462 )
492463 });
493464 decode_inter_frame_tile_with_cdfs(
494- tile_bytes,
465+ &tile_bufs,
466+ &header.tile_info,
495467 header.mi_cols,
496468 header.mi_rows,
497469 header.quantization.base_q_idx,
@@ -6008,7 +5980,7 @@ mod tests {
60085980 }
60095981 }
60105982
6011- /// lane-tiles r3: a real two-tile-column aomenc key frame, decoded
5983+ /// lane-tiles r3/r7: a real two-tile-column aomenc key frame, decoded
60125984 /// through [`decode_key_frame_tile_with_cdfs`] directly with the whole
60135985 /// `tiles: &[&[u8]]` list -- `decode_stream`'s `cols > 1 || rows > 1`
60145986 /// refusal (this file, ~line 292) still fires for any stream this wide,
@@ -6020,7 +5992,12 @@ mod tests {
60205992 /// also the frame's own right edge -- the known gap (`PlaneBuf`'s
60215993 /// tile_x0/tile_y0 only clip left/top reach, not a non-last column's
60225994 /// right-edge reach) does not apply to this fixture; it would to a
6023- /// 3+-column one. Tile count itself is a structural aomenc param, not
5995+ /// 3+-column one, proven separately by the four-tile-column gate below.
5996+ /// r7: `--loopfilter-control=0` REMOVED per the charter -- `PlaneBuf`'s
5997+ /// `tile_x1`/`tile_y1` clamps now receive real values at every call site
5998+ /// (r6's `set_tile_origin` sweep), so this gate now proves real
5999+ /// deblocking across the tile boundary too, not just decode with it off.
6000+ /// Tile count itself is a structural aomenc param, not
60246001 /// RD-dependent content, but this decoder's chroma smooth/paeth gap
60256002 /// (`decode.rs` "a smooth or paeth chroma mode (round 2)", unrelated to
60266003 /// tiles, pre-dating this lane) is content-dependent -- no aomenc flag
@@ -6101,7 +6078,6 @@ mod tests {
61016078 // into the next tile's still-undecoded/differently-
61026079 // origined samples. Off here since deblocking itself is
61036080 // not what this gate is proving.
6104- "--loopfilter-control=0",
61056081 "--enable-rect-partitions=0",
61066082 "--enable-ab-partitions=0",
61076083 "--enable-1to4-partitions=0",
@@ -6242,16 +6218,200 @@ mod tests {
62426218 );
62436219 }
62446220
6245- /// lane-tiles r4: the same real two-tile-column stream as the gate
6246- /// above, this time run through `decode_stream` itself -- the entry
6247- /// point real callers use, not the `decode_key_frame_tile_with_cdfs`
6248- /// bypass. Proves the `cols > 1` refusal is actually lifted (not just
6249- /// that the underlying per-tile loop works) for the scoped case this
6250- /// round proved safe: 2 tile columns, 1 tile row, key frame, loop
6251- /// filtering off (`--loopfilter-control=0` stays -- deblocking crosses
6252- /// tile boundaries by spec default and `PlaneBuf` cannot bound a
6253- /// non-last column's right-edge reach yet, see the refusal's own doc
6254- /// comment above `decode_stream`).
6221+ /// lane-tiles r7: the `>2 tile columns` refusal's own capability, proven
6222+ /// separately from the 2-column gate above -- `--tile-columns=2` gives
6223+ /// aomenc `TileCols=4` (log2), a real non-last-column right-edge case the
6224+ /// 2-column fixture cannot exercise (there tile 1 IS the frame's right
6225+ /// edge). 256x64 is four 64x64 superblocks wide with `--sb-size=64`, so
6226+ /// each tile column is exactly one superblock. Loop filtering stays ON
6227+ /// (no `--loopfilter-control=0`) to prove the same reach-bound fix also
6228+ /// covers deblocking across an *interior* tile boundary, not just the
6229+ /// 2-column case's boundary-that-is-also-the-frame-edge.
6230+ #[test]
6231+ fn a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact() {
6232+ const NAME: &str = "a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact";
6233+ if !have_ffmpeg() {
6234+ eprintln!("SKIP {NAME}: no ffmpeg");
6235+ return;
6236+ }
6237+ if !have_aomenc() {
6238+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
6239+ return;
6240+ }
6241+ let (width, height) = (256usize, 64usize);
6242+ let mut matched = 0u32;
6243+ let mut named_refusals = 0u32;
6244+ for attempt in 0..20u32 {
6245+ let seed = 42 + attempt;
6246+ let source = gradients_source(seed, width, height, "duration=0.04:rate=25");
6247+ let y4m = Command::new("ffmpeg")
6248+ .args([
6249+ "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f",
6250+ "yuv4mpegpipe", "-",
6251+ ])
6252+ .stdin(Stdio::null())
6253+ .stdout(Stdio::piped())
6254+ .stderr(Stdio::piped())
6255+ .output()
6256+ .expect("ffmpeg failed to run");
6257+ assert!(
6258+ y4m.status.success(),
6259+ "ffmpeg fixture: {}",
6260+ String::from_utf8_lossy(&y4m.stderr)
6261+ );
6262+ let mut child = Command::new(aomenc_path())
6263+ .args([
6264+ "--codec=av1",
6265+ "--passes=1",
6266+ "--end-usage=q",
6267+ "--cq-level=45",
6268+ "--cpu-used=0",
6269+ "--limit=1",
6270+ "--kf-max-dist=1000",
6271+ "--threads=1",
6272+ "--row-mt=0",
6273+ "--tile-columns=2",
6274+ "--tile-rows=0",
6275+ "--sb-size=64",
6276+ "--enable-rect-partitions=0",
6277+ "--enable-ab-partitions=0",
6278+ "--enable-1to4-partitions=0",
6279+ "--enable-filter-intra=0",
6280+ "--enable-smooth-intra=0",
6281+ "--enable-paeth-intra=0",
6282+ "--enable-directional-intra=0",
6283+ "--enable-angle-delta=0",
6284+ "--enable-tx-size-search=0",
6285+ "--enable-cdef=0",
6286+ "--enable-restoration=0",
6287+ "--max-partition-size=32",
6288+ "--min-partition-size=32",
6289+ "--enable-palette=0",
6290+ "--enable-intrabc=0",
6291+ "--enable-cfl-intra=0",
6292+ "--obu",
6293+ "-o",
6294+ "-",
6295+ "-",
6296+ ])
6297+ .stdin(Stdio::piped())
6298+ .stdout(Stdio::piped())
6299+ .stderr(Stdio::piped())
6300+ .spawn()
6301+ .expect("aomenc failed to start");
6302+ child
6303+ .stdin
6304+ .take()
6305+ .expect("aomenc stdin")
6306+ .write_all(&y4m.stdout)
6307+ .expect("writing y4m to aomenc");
6308+ let out = child.wait_with_output().expect("aomenc failed to run");
6309+ assert!(
6310+ out.status.success(),
6311+ "aomenc refused the fixture: {}",
6312+ String::from_utf8_lossy(&out.stderr)
6313+ );
6314+ let stream = out.stdout;
6315+
6316+ let mut parser = Av1Parser::new();
6317+ let mut pos = 0usize;
6318+ let mut frame = None;
6319+ while pos < stream.len() {
6320+ let obu_offset = pos;
6321+ let obu = parser.parse_obu(&stream[pos..]).unwrap();
6322+ pos += obu.total_size;
6323+ if let ObuKind::Frame(header, tiles) = obu.kind {
6324+ frame = Some((header, tiles, obu_offset));
6325+ break;
6326+ }
6327+ }
6328+ let (header, tiles, obu_offset) = frame.expect("stream has a Frame OBU");
6329+ assert!(
6330+ header.tile_info.cols > 2,
6331+ "{NAME}: aomenc did not actually split into >2 tile columns (cols={}, seed {seed})",
6332+ header.tile_info.cols
6333+ );
6334+ assert_eq!(
6335+ tiles.len(),
6336+ header.tile_info.cols as usize,
6337+ "{NAME}: expected one tile per column (seed {seed})"
6338+ );
6339+ let tile_bufs: Vec<&[u8]> = tiles
6340+ .iter()
6341+ .map(|t| &stream[obu_offset + t.offset..obu_offset + t.offset + t.size])
6342+ .collect();
6343+
6344+ let enable_filter_intra = parser
6345+ .sequence_header()
6346+ .is_some_and(|seq| seq.enable_filter_intra);
6347+ let enable_edge_filter = parser
6348+ .sequence_header()
6349+ .is_some_and(|seq| seq.enable_intra_edge_filter);
6350+
6351+ let before = crate::decode::tile_hits();
6352+ let picture = match decode_key_frame_tile_with_cdfs(
6353+ &tile_bufs,
6354+ &header.tile_info,
6355+ header.mi_cols,
6356+ header.mi_rows,
6357+ header.quantization.base_q_idx,
6358+ header.frame_width,
6359+ header.frame_height,
6360+ enable_filter_intra,
6361+ enable_edge_filter,
6362+ &header.cdef,
6363+ &header.loop_filter,
6364+ None,
6365+ header.tx_mode == TxMode::Select,
6366+ header.reduced_tx_set,
6367+ header.allow_screen_content_tools,
6368+ header.allow_intrabc,
6369+ ) {
6370+ Err(e) => {
6371+ let msg = e.to_string();
6372+ assert!(
6373+ msg.contains("unsupported"),
6374+ "{NAME} failed outright, not a named refusal (seed {seed}): {msg}"
6375+ );
6376+ named_refusals += 1;
6377+ eprintln!("seed {seed} refusal: {msg}");
6378+ continue;
6379+ }
6380+ Ok((picture, _end_cdfs)) => picture,
6381+ };
6382+ let hits = crate::decode::tile_hits() - before;
6383+ assert!(
6384+ hits > 2,
6385+ "{NAME}: tile_hits delta was {hits}, expected >2 -- all four tiles must actually \
6386+ decode, not just a subset (seed {seed})"
6387+ );
6388+
6389+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1);
6390+ assert_eq!(picture.y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})");
6391+ assert_eq!(picture.u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})");
6392+ assert_eq!(picture.v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})");
6393+ matched += 1;
6394+ }
6395+ assert!(
6396+ matched > 0,
6397+ "{NAME}: every attempt refused ({named_refusals} refusals); the gate never decoded \
6398+ a four-tile-column stream"
6399+ );
6400+ eprintln!(
6401+ "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20"
6402+ );
6403+ }
6404+
6405+ /// lane-tiles r4/r7: the same real two-tile-column stream as the
6406+ /// bypass gate above, this time run through `decode_stream` itself --
6407+ /// the entry point real callers use. Proves the `cols > 1` refusal is
6408+ /// actually lifted (not just that the underlying per-tile loop works)
6409+ /// for a key frame; `--loopfilter-control=0` stays here for its own
6410+ /// sake (isolating the entry-point wiring from deblocking), but r7's
6411+ /// `a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact`
6412+ /// bypass gate now proves loop filtering ON across a tile boundary too,
6413+ /// and the `cols > 1 && loop_filter_on` / `cols > 2` refusals this
6414+ /// comment used to describe are gone from `decode_stream`.
62556415 #[test]
62566416 fn a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream() {
62576417 const NAME: &str = "a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream";
@@ -6376,4 +6536,187 @@ mod tests {
63766536 "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20"
63776537 );
63786538 }
6539+
6540+ /// lane-tiles r7: the gate stage 2 (r6, commit 8899fc1) shipped without
6541+ /// -- a real >1-tile-column stream with a genuine INTER frame (not just
6542+ /// the key-frame-only two-column gate above), decoded through
6543+ /// `decode_stream` itself. Same recipe as the key-frame gate
6544+ /// (`--sb-size=64`, `--tile-columns=1`, `--loopfilter-control=0`, the
6545+ /// same feature-disable envelope so the gate isolates the tile loop, not
6546+ /// an unrelated unimplemented mode) plus `--limit=2 --kf-max-dist=1000`
6547+ /// so frame 1 is a real inter frame, and `gradients_source`'s default
6548+ /// `speed=0.01` rotation (undisturbed -- not overridden by the tail)
6549+ /// gives it genuine motion against frame 0, so `decode_inter_frame_tile_
6550+ /// with_cdfs`'s new per-tile loop and `MiGrid`'s per-tile bound actually
6551+ /// have to walk a live MV stack across the tile-column boundary, not
6552+ /// just replay skip/zero-mv blocks. Bounded with `duration=0.08` (2
6553+ /// frames at rate=25) per the class in ledger
6554+ /// `refusal-claim-disproved-by-its-own-gate`/`gate-loader-slurps-whole-
6555+ /// file` (never leave an ffmpeg/lavfi generate unbounded).
6556+ #[test]
6557+ fn a_real_aomenc_stream_with_two_tile_columns_and_an_inter_frame_decodes_pixel_exact() {
6558+ const NAME: &str =
6559+ "a_real_aomenc_stream_with_two_tile_columns_and_an_inter_frame_decodes_pixel_exact";
6560+ if !have_ffmpeg() {
6561+ eprintln!("SKIP {NAME}: no ffmpeg");
6562+ return;
6563+ }
6564+ if !have_aomenc() {
6565+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
6566+ return;
6567+ }
6568+ let (width, height) = (128usize, 64usize);
6569+ let frames = 2usize;
6570+ let mut matched = 0u32;
6571+ let mut named_refusals = 0u32;
6572+ for attempt in 0..20u32 {
6573+ let seed = 42 + attempt;
6574+ let source = gradients_source(seed, width, height, "duration=0.08:rate=25");
6575+ let y4m = Command::new("ffmpeg")
6576+ .args([
6577+ "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f",
6578+ "yuv4mpegpipe", "-",
6579+ ])
6580+ .stdin(Stdio::null())
6581+ .stdout(Stdio::piped())
6582+ .stderr(Stdio::piped())
6583+ .output()
6584+ .expect("ffmpeg failed to run");
6585+ assert!(
6586+ y4m.status.success(),
6587+ "ffmpeg fixture: {}",
6588+ String::from_utf8_lossy(&y4m.stderr)
6589+ );
6590+ let mut child = Command::new(aomenc_path())
6591+ .args([
6592+ "--codec=av1",
6593+ "--passes=1",
6594+ "--end-usage=q",
6595+ "--cq-level=45",
6596+ "--cpu-used=0",
6597+ &format!("--limit={frames}"),
6598+ "--kf-max-dist=1000",
6599+ "--lag-in-frames=0",
6600+ "--auto-alt-ref=0",
6601+ "--threads=1",
6602+ "--row-mt=0",
6603+ "--tile-columns=1",
6604+ "--tile-rows=0",
6605+ "--sb-size=64",
6606+ "--loopfilter-control=0",
6607+ "--max-reference-frames=3",
6608+ "--reduced-reference-set=1",
6609+ "--enable-warped-motion=0",
6610+ "--enable-obmc=0",
6611+ "--enable-masked-comp=0",
6612+ "--enable-interintra-comp=0",
6613+ "--enable-dist-wtd-comp=0",
6614+ "--enable-diff-wtd-comp=0",
6615+ "--enable-onesided-comp=0",
6616+ "--enable-interintra-wedge=0",
6617+ "--enable-smooth-interintra=0",
6618+ "--enable-ref-frame-mvs=0",
6619+ "--enable-rect-partitions=0",
6620+ "--enable-ab-partitions=0",
6621+ "--enable-1to4-partitions=0",
6622+ "--enable-filter-intra=0",
6623+ "--enable-smooth-intra=0",
6624+ "--enable-paeth-intra=0",
6625+ "--enable-directional-intra=0",
6626+ "--enable-angle-delta=0",
6627+ "--enable-tx-size-search=0",
6628+ "--enable-cdef=0",
6629+ "--enable-restoration=0",
6630+ "--max-partition-size=32",
6631+ "--min-partition-size=32",
6632+ "--enable-palette=0",
6633+ "--enable-intrabc=0",
6634+ "--enable-cfl-intra=0",
6635+ "--obu",
6636+ "-o",
6637+ "-",
6638+ "-",
6639+ ])
6640+ .stdin(Stdio::piped())
6641+ .stdout(Stdio::piped())
6642+ .stderr(Stdio::piped())
6643+ .spawn()
6644+ .expect("aomenc failed to start");
6645+ child
6646+ .stdin
6647+ .take()
6648+ .expect("aomenc stdin")
6649+ .write_all(&y4m.stdout)
6650+ .expect("writing y4m to aomenc");
6651+ let out = child.wait_with_output().expect("aomenc failed to run");
6652+ assert!(
6653+ out.status.success(),
6654+ "aomenc refused the fixture: {}",
6655+ String::from_utf8_lossy(&out.stderr)
6656+ );
6657+ let stream = out.stdout;
6658+
6659+ // Confirm aomenc actually split into >1 tile column and that
6660+ // frame 1 is a real inter frame before trusting a pixel match --
6661+ // otherwise a match could mean "tiles collapsed to 1" or "frame
6662+ // 1 fell back to key", not "the inter tile loop ran".
6663+ let mut parser = Av1Parser::new();
6664+ let mut pos = 0usize;
6665+ let mut saw_multi_tile_inter = false;
6666+ while pos < stream.len() {
6667+ let obu_offset = pos;
6668+ let obu = parser.parse_obu(&stream[pos..]).unwrap();
6669+ pos += obu.total_size;
6670+ if let ObuKind::Frame(header, _) = obu.kind
6671+ && header.frame_type != FrameType::Key
6672+ && header.tile_info.cols > 1
6673+ {
6674+ saw_multi_tile_inter = true;
6675+ }
6676+ }
6677+ assert!(
6678+ saw_multi_tile_inter,
6679+ "{NAME}: seed {seed} never produced a >1-tile-column inter frame (aomenc \
6680+ collapsed tiling or coded frame 1 as key)"
6681+ );
6682+
6683+ let before = crate::decode::tile_hits();
6684+ let pictures = match decode_stream(&stream) {
6685+ Err(e) => {
6686+ let msg = e.to_string();
6687+ assert!(
6688+ msg.contains("unsupported"),
6689+ "{NAME} failed outright, not a named refusal (seed {seed}): {msg}"
6690+ );
6691+ named_refusals += 1;
6692+ eprintln!("seed {seed} refusal: {msg}");
6693+ continue;
6694+ }
6695+ Ok(pictures) => pictures,
6696+ };
6697+ let hits = crate::decode::tile_hits() - before;
6698+ assert!(
6699+ hits > frames,
6700+ "{NAME}: tile_hits delta was {hits}, expected > {frames} -- both tiles of both \
6701+ frames must actually decode (seed {seed})"
6702+ );
6703+ assert_eq!(pictures.len(), frames, "{NAME}: expected {frames} pictures (seed {seed})");
6704+
6705+ let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frames);
6706+ for (i, (got, want)) in pictures.iter().zip(&ffmpeg_frames).enumerate() {
6707+ assert_eq!(got.y, want.y, "{NAME}: seed {seed} frame {i} luma vs ffmpeg");
6708+ assert_eq!(got.u, want.u, "{NAME}: seed {seed} frame {i} U vs ffmpeg");
6709+ assert_eq!(got.v, want.v, "{NAME}: seed {seed} frame {i} V vs ffmpeg");
6710+ }
6711+ matched += 1;
6712+ }
6713+ assert!(
6714+ matched > 0,
6715+ "{NAME}: every attempt refused ({named_refusals} refusals); decode_stream never \
6716+ decoded a two-tile-column inter frame"
6717+ );
6718+ eprintln!(
6719+ "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20"
6720+ );
6721+ }
63796722 }
lanes/tiles-r5.charter.mdadded+44 -0
@@ -0,0 +1,44 @@
1+# lane-tiles r5 — inter-frame multi-tile, then the right-edge reach bound
2+
3+At the lane tip (main merged in — r4 is merged to main at 53b319b). Read
4+`lanes/tiles-r4.report.md`.
5+
6+## State
7+Key frames with two tile columns decode through `decode_stream` itself,
8+20/20 pixel-exact, tile count hard-asserted. Four scoped refusals remain:
9+inter frames with >1 tile, >1 tile row, >2 tile columns, and multi-tile with
10+loop filtering on.
11+
12+Fact r4 established: AV1 has NO `loop_filter_across_tiles` bit (unlike HEVC) —
13+deblocking crosses tile boundaries unconditionally. So the loop-filter refusal
14+and the >2-columns refusal are the SAME underlying gap: `PlaneBuf`'s tile origin
15+clips left/top reach only, and a non-last column's right-edge reach bound is
16+unimplemented. Fixing that one thing lifts both.
17+
18+## Order
19+1. `decode_inter_frame_tile_with_cdfs` takes `tiles: &[&[u8]]` and grows the
20+ same per-tile loop the key-frame path has (mirror
21+ `decode_key_frame_tile_with_cdfs`'s loop), then thread the tile origin into
22+ `mvstack.rs` so an MV candidate scan cannot reach across a tile boundary.
23+ That lifts the inter-frame refusal. Gate it on a real inter stream. COMMIT.
24+2. The right-edge reach bound in `PlaneBuf` — lifts the >2-columns and the
25+ loop-filter refusals together. Re-run the two-tile gate with
26+ `--loopfilter-control=0` REMOVED; it must still be pixel-exact. COMMIT.
27+3. Tile rows, non-uniform spacing, several tile-group OBUs per frame, and
28+ `context_update_tile_id != 0` proven with a stream where it is not tile 0.
29+
30+Gate rules: `EC_AV1_REQUIRE_AOMENC=1`; `-t <seconds>` on every ffmpeg generate;
31+fixtures through `gradients_source`; aomenc `--threads=1 --row-mt=0
32+--sb-size=64` (this decoder hardcodes 64px superblocks); firing counts
33+HARD-asserted. And remember r3's false PASS: `Tile::offset` is relative to the
34+slice `parse_obu` was handed — forgetting `obu_offset` decodes flat DC garbage
35+that compares EQUAL instead of erroring.
36+
37+Merge note: main has `refusal_inventory.rs`, which pins all four of your tile
38+refusal strings. Report every one you remove or reword, verbatim.
39+
40+Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-tiles`; foreground
41+`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms. Sibling
42+worktrees have live agents — never build in or edit them. Never push, never
43+merge, never touch `main`. 75-turn cap, does not reset: COMMIT AT EVERY GREEN
44+STEP. End with `lanes/tiles-r5.report.md`, VERDICT on line 1.
lanes/tiles-r6.charter.mdadded+40 -0
@@ -0,0 +1,40 @@
1+# lane-tiles r6 — finish the inter per-tile loop
2+
3+At 1227517 — r5's work, committed verbatim by the orchestrator at its cap
4+MID-EDIT. Its own last words were that two shorthand `width,` / `height,`
5+struct-init blocks (around decode.rs:11661 `ref_y` and :11673 `y`) still needed
6+the same fix as the rest, so **it almost certainly does not compile**. That is
7+job one. `lanes/tiles-r5.charter.md` is still binding.
8+
9+1. `cargo check`, finish r5's mid-edit sweep, then the full suite (baseline
10+ 234/0 on this tree). COMMIT the moment it is green.
11+2. Finish stage 1: `decode_inter_frame_tile_with_cdfs` takes `tiles: &[&[u8]]`
12+ with the same per-tile loop the key-frame path has, and the tile origin
13+ threaded into `mvstack.rs` so an MV candidate scan cannot reach across a
14+ tile boundary. Lift the inter-frame multi-tile refusal, gated on a real
15+ inter stream with a hard-asserted tile count. COMMIT.
16+3. Then `PlaneBuf`'s right-edge reach bound for a non-last tile column — that
17+ single fix lifts BOTH the >2-columns refusal and the loop-filter one (AV1
18+ has no loop_filter_across_tiles bit; deblocking always crosses tiles). Re-run
19+ the two-column gate with `--loopfilter-control=0` REMOVED; it must stay
20+ pixel-exact. COMMIT.
21+
22+Gate rules: `EC_AV1_REQUIRE_AOMENC=1`; `-t <seconds>` on every ffmpeg generate;
23+fixtures through `gradients_source`; aomenc `--threads=1 --row-mt=0
24+--sb-size=64` (this decoder hardcodes 64px superblocks). Firing counts are HARD
25+asserts. Main now FAILS the suite if a gate turns a decode error into a printed
26+SKIP — write the gate as an attempt loop requiring at least one decode.
27+And remember r3's false PASS: `Tile::offset` is relative to the slice
28+`parse_obu` was handed; forgetting `obu_offset` decodes flat DC garbage that
29+compares EQUAL instead of erroring.
30+
31+Merge note: main is at 91a08e8 with `gate_coverage.rs` and
32+`refusal_inventory.rs`, which pin your four tile refusal strings among others.
33+Report every one you remove or reword, verbatim.
34+
35+Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-tiles`; foreground
36+`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms. Sibling
37+worktrees have live agents — never build in or edit them. Never push, never
38+merge, never touch `main`. 75-turn cap, does not reset: COMMIT AT EVERY GREEN
39+STEP — three rounds on this lane have now ended mid-edit. End with
40+`lanes/tiles-r6.report.md`, VERDICT on line 1.
lanes/tiles-r6.report.mdadded+81 -0
@@ -0,0 +1,81 @@
1+VERDICT: PARTIAL -- green, stage 1 + stage 2 landed, stage 2's own gate not written (turn budget), stage 3 not started.
2+
3+## Stage 1 (r5's mid-edit sweep)
4+r5's flagged lines (decode.rs:11661/11673) already had all four `PlaneBuf`
5+fields -- the actual break was `set_tile_origin` calls at decode.rs:4910-4912
6+in the KEY-FRAME per-tile loop, still 2-arg after the signature grew to 4.
7+Fixed by threading `mi_col1`/`mi_row1` (clamped to the plane's padded
8+width/height) through as `x1`/`y1`. `cargo check` clean. Committed 22a79b0.
9+
10+## Stage 2 (inter per-tile loop)
11+`decode_inter_frame_tile_with_cdfs` (crates/ec-av1/src/decode.rs:9530) now
12+takes `tiles: &[&[u8]]` + `&TileInfo` and grows the same per-tile loop
13+`decode_key_frame_tile_with_cdfs` has: fresh `SymbolDecoder` + CDF copy per
14+tile, `PlaneBuf::set_tile_origin` threaded with real `x1`/`y1`, only
15+`context_update_tile_id`'s own adapted table kept as `result_cdfs`.
16+
17+`MiGrid` (crates/ec-av1/src/mvstack.rs) gets `tile_row0`/`col0`/`row1`/`col1`
18+bounds + `set_tile_bounds`, called once per tile in the new loop. All four
19+`find_mv_stack*`/`find_mv_stack_compound` call sites read through this one
20+grid, so bounding `MiGrid::get` bounds every one of them without touching
21+their own signatures -- deliberate deviation from the charter's literal
22+"thread the tile origin into mvstack.rs" (which read as widening every
23+`find_mv_stack*` signature); the single choke point is the smaller, equally
24+correct fix and the existing `mi_units_outside_the_tile_contribute_nothing`
25+mvstack test already exercises exactly this shape. Named here since it
26+diverges from the charter's literal wording.
27+
28+Lifted refusal (verbatim, removed from stream.rs and
29+refusal_inventory.rs's pinned list):
30+"an inter frame with more than one tile (the inter tile-decode path has no
31+per-tile loop, only key frames do)"
32+
33+Committed 8899fc1.
34+
35+**Gap, disposed honestly**: charter stage 2 said "gated on a real inter
36+stream with a hard-asserted tile count" -- no such gate was written this
37+round; turn budget ran out reaching that point. The existing
38+`a_real_aomenc_stream_with_two_tile_columns_decodes_pixel_exact` gate is
39+key-frame-only (its own doc comment says so). What IS proven: `cargo check`
40+clean, and the full `-p ec-av1` suite (242/0, EC_AV1_REQUIRE_AOMENC=1, run
41+once right after stage 1's fix) plus a scoped rerun after stage 2
42+(tile/frame/mvstack/stream-tile subset: 44/0, refusal_inventory 2/0,
43+gate_coverage 2/0) all stay green -- but nothing in the suite actually
44+decodes a >1-tile-column INTER stream yet, so the inter path is
45+compile-verified and non-regressing, not gate-verified for its own new
46+capability.
47+deferred: real-aomenc gate for >1-tile-column inter decode with hard tile-
48+count assert -- unblocks with a fresh 60-90 turn budget; recipe per charter
49+(`--threads=1 --row-mt=0 --sb-size=64`, `-t <seconds>`, `gradients_source`,
50+two motion-carrying frames so an inter frame actually reads a real MV
51+stack across the tile boundary this round changed).
52+
53+## Stage 3 (right-edge reach bound)
54+NOT STARTED as its own task, but the mechanism it needs (`PlaneBuf`'s
55+`tile_x1`/`tile_y1` clamp) already existed in the tree before this round and
56+both stage-1 and stage-2 fixes now feed it real values on every call site
57+(key frame AND inter frame). The `>2 tile columns` and `multi-tile +
58+loop-filter` refusals were deliberately NOT lifted this round -- the
59+charter requires re-running the two-column gate with
60+`--loopfilter-control=0` removed and confirming pixel-exact before lifting
61+either, and that gate run did not happen (turn budget). Mechanically the
62+fix may already be sufficient; it is unverified, so the refusals stay.
63+deferred: re-run `a_real_aomenc_stream_with_two_tile_columns_decodes_pixel_exact`
64+with `--loopfilter-control=0` removed; if pixel-exact, lift both the
65+`>2 columns` and `loop-filter` refusals in the same commit (they're the
66+same underlying gap per r5's own note).
67+
68+## Files changed
69+- crates/ec-av1/src/decode.rs -- stage 1 fix (key-frame tile-origin call),
70+ stage 2 (inter per-tile loop, `tiles`/`tile_info` params, `result_cdfs`)
71+- crates/ec-av1/src/mvstack.rs -- `MiGrid` tile bounds + `set_tile_bounds`
72+- crates/ec-av1/src/stream.rs -- inter-frame call site passes `tile_bufs`/
73+ `&header.tile_info`; multi-tile-inter refusal removed
74+- crates/ec-av1/src/refusal_inventory.rs -- pinned string removed to match
75+
76+## Commits
77+- 22a79b0 fix(av1): finish r5's set_tile_origin sweep -- key-frame tile loop now green
78+- 8899fc1 feat(av1): inter frame per-tile decode loop, MV stack bounded per tile
79+
80+Never pushed, never merged, never touched main, worked only inside
81+edith_codecs-tiles.
lanes/tiles-r7.charter.mdadded+52 -0
@@ -0,0 +1,52 @@
1+# lane-tiles r7 — gate what r6 lifted, then the reach bound
2+
3+At f9a0614. Read `lanes/tiles-r6.report.md`.
4+
5+## Where you stand
6+r6 landed the inter per-tile loop (`decode_inter_frame_tile_with_cdfs` mirrors
7+the key-frame path) and bounded the MV-candidate scan by giving the shared
8+`MiGrid` tile bounds — one choke point instead of widening four
9+`find_mv_stack*` signatures. That was a good deviation from the charter's
10+literal wording and it stands.
11+
12+**But it lifted the "an inter frame with more than one tile" refusal with no
13+gate proving a >1-tile-column INTER stream decodes.** r6 said so itself. Its
14+evidence is a clean `cargo check`, a non-regressing 242/0 suite and a 44/0
15+scoped subset — none of which exercise the capability the refusal used to
16+guard. Until the gate exists, that lift is an unproven claim, and this branch
17+does not merge to main. Nothing else in this lane matters until it is written.
18+
19+## Order
20+1. The gate: a real aomenc >1-tile-column INTER stream, pixel-exact through
21+ `decode_stream`, with a HARD-asserted tile-hit count. Recipe:
22+ `--threads=1 --row-mt=0 --sb-size=64` (this decoder hardcodes 64px
23+ superblocks), two motion-carrying frames, fixture through
24+ `gradients_source`, ffmpeg generate bounded with `-t <seconds>`. Main FAILS
25+ the suite if a gate turns a decode error into a printed SKIP, so write it as
26+ an attempt loop requiring at least one decode. If the gate does NOT pass,
27+ restore the refusal in the same commit — that is the honest outcome, not a
28+ failure. COMMIT.
29+2. Re-run `a_real_aomenc_stream_with_two_tile_columns_decodes_pixel_exact` with
30+ `--loopfilter-control=0` REMOVED. `PlaneBuf`'s `tile_x1`/`tile_y1` clamps now
31+ receive real values at every call site, so this may already pass. If it does,
32+ lift BOTH the ">2 tile columns" and the "multi-tile + loop-filter" refusals
33+ in one commit — r5 established they are the same underlying reach-bound gap —
34+ and update `refusal_inventory.rs`. COMMIT.
35+3. Then tile rows, non-uniform spacing, several tile-group OBUs per frame, and
36+ `context_update_tile_id != 0` proven on a stream where it is not tile 0.
37+
38+## Note
39+r5's handoff pointed at decode.rs:11661/11673 as unfinished; r6 found those were
40+already correct and the real break was two 2-arg `set_tile_origin` calls in the
41+key-frame loop. Stale pointers in a predecessor's handoff are worth one
42+`cargo check` before you trust them.
43+
44+Merge note: main is at 53f5358. Report every refusal string you add, remove or
45+reword, verbatim, for `refusal_inventory.rs`.
46+
47+Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-tiles`; foreground
48+`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms. Sibling
49+worktrees have live agents — never build in or edit them. Never push, never
50+merge into `main`. 75-turn cap, does not reset: land small, COMMIT AT EVERY
51+GREEN STEP — this lane has now spent four rounds partly on budget management.
52+End with `lanes/tiles-r7.report.md`, VERDICT on line 1.
lanes/tiles-r7.report.mdadded+91 -0
@@ -0,0 +1,91 @@
1+VERDICT: PARTIAL -- green, stage 1 (order) + stage 2 landed, stage 3 not started (turn budget).
2+
3+## Stage 1 -- gated r6's inter tile-loop lift
4+Added `a_real_aomenc_stream_with_two_tile_columns_and_an_inter_frame_decodes_pixel_exact`
5+(`crates/ec-av1/src/stream.rs`): `--sb-size=64`, `--tile-columns=1` (2
6+columns), `--loopfilter-control=0`, `--limit=2 --kf-max-dist=1000` so frame 1
7+is a genuine inter frame, `gradients_source`'s default `speed=0.01` rotation
8+gives real motion so the tile-bounded MV stack (`MiGrid::set_tile_bounds`)
9+actually has work to do across the boundary. Confirms via a header parse that
10+aomenc really produced a >1-tile-column inter frame (not a collapsed/kf
11+fallback) before trusting a match. 20/20 pixel-exact vs ffmpeg, 0 named
12+refusals, hard `tile_hits > frames` assert.
13+
14+Building this gate found `decode_inter_frame_tile_with_cdfs`'s per-tile loop
15+(r6, commit 8899fc1) never incremented `TILE_HITS` -- only the key-frame loop
16+did (`decode.rs:4928`). Without the fix the gate's own tile-count assert
17+would have been vacuously blind on the inter path (it failed first-run:
18+"tile_hits delta was 2, expected > 2" -- both hits were from frame 0's key
19+tiles, frame 1 contributed zero visible signal despite decoding correctly).
20+Fixed by adding the same `TILE_HITS.with(|c| c.set(c.get() + 1));` call at
21+the equivalent point in the inter loop (`decode.rs:9814`, right after
22+`grid.set_tile_bounds`). Re-ran: 20/20 pixel-exact, `tile_hits` counted
23+correctly.
24+
25+Committed bd1c01f.
26+
27+## Stage 2 -- lifted >2-columns and multi-tile-loop-filter refusals
28+Charter order: re-run the key-frame 2-column gate
29+(`a_real_aomenc_stream_with_two_tile_columns_decodes_pixel_exact`) with
30+`--loopfilter-control=0` removed. Did so: 20/20 pixel-exact, confirming
31+`PlaneBuf`'s `tile_x1`/`tile_y1` clamps (real values at every call site since
32+r6) already make real deblocking across a tile boundary correct. Made this
33+permanent (flag removed for real, not just the trial run) and updated the
34+gate's doc comment.
35+
36+That gate's own known-gap note said this only proves the boundary-is-also-
37+the-frame-edge case (2 columns, tile 1 = right edge), so also added
38+`a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact`
39+(`--tile-columns=2` -> `TileCols=4`, 256x64 = four 64px superblocks, loop
40+filter ON, no bypass of the flag): proves an *interior* tile boundary and the
41+`>2 columns` case in one shot. 20/20 pixel-exact, 0 refusals.
42+
43+With both proven, lifted the `cols > 2` and `cols > 1 && loop_filter_on`
44+refusals from `decode_stream` (`crates/ec-av1/src/stream.rs`) -- they were,
45+per r5's note, the same underlying `PlaneBuf` reach-bound gap, now closed on
46+both fronts. Updated `refusal_inventory.rs`'s pinned list to match (both
47+strings removed). Tile *rows* stay refused (`tile_info.rows > 1`) --
48+unproven, untouched.
49+
50+Lifted refusals (verbatim, removed from `stream.rs` and
51+`refusal_inventory.rs`'s pinned list):
52+- "a frame with more than two tile columns (a non-last column's right-edge reach bound past column 0 is unimplemented)"
53+- "a multi-tile frame with loop filtering enabled (deblocking crosses tile boundaries by spec default; PlaneBuf's tile origin does not clip a non-last column's right-edge reach)"
54+
55+Committed 325e8e7.
56+
57+## Stage 3 -- NOT STARTED
58+Tile rows, non-uniform tile spacing, several tile-group OBUs per frame, and
59+`context_update_tile_id != 0` on a non-tile-0 stream: none attempted this
60+round (turn budget). The `tile_info.rows > 1` refusal is untouched and still
61+guards tile rows correctly (no false claim made about it).
62+deferred: tile-row gate + lift, non-uniform tile spacing, multi-tile-group
63+OBU handling, `context_update_tile_id != 0` proof -- unblocks with a fresh
64+turn budget; recipe likely `--tile-rows=1` mirroring this round's
65+`--tile-columns` approach, gated the same way (bypass gate first, then
66+`decode_stream`-level gate, then lift).
67+
68+## Files changed
69+- `crates/ec-av1/src/decode.rs` -- `TILE_HITS` increment added to the inter
70+ per-tile loop (was silently missing, made the stage-1 gate's own assert
71+ meaningless until fixed)
72+- `crates/ec-av1/src/stream.rs` -- 3 new gates (inter+2-col,
73+ 4-col+loopfilter-on, plus doc updates on the 2 pre-existing gates), the
74+ `cols > 2` and multi-tile-loop-filter refusals removed from
75+ `decode_stream`, `loop_filter_on` local removed (now unused)
76+- `crates/ec-av1/src/refusal_inventory.rs` -- 2 pinned strings removed to
77+ match
78+
79+## Commits
80+- bd1c01f test(av1): gate r6's inter tile-loop lift -- real >1-tile-column INTER stream
81+- 325e8e7 feat(av1): lift >2-tile-column and multi-tile-loop-filter refusals
82+
83+Both `cargo check -p ec-av1 --tests` clean and the scoped subset
84+(`tile mvstack refusal_inventory gate_coverage`, `EC_AV1_REQUIRE_AOMENC=1`)
85+green: 78/0 after stage 2 (was 77/0 after stage 1). `refusal_inventory`'s own
86+"capability_claims_are_declared_not_scattered" and
87+"the_decode_path_refuses_exactly_the_listed_cases" tests both pass, so the
88+pinned-list edits match the live refusal set exactly.
89+
90+Never pushed, never merged, never touched main, worked only inside
91+edith_codecs-tiles.