Merge branch 'main' into lane-palette
Browse files at this commit11 changed files +1535 -114
- crates/ec-av1/src/decode.rs +154 -26
- crates/ec-av1/src/mvstack.rs +33 -3
- crates/ec-av1/src/refusal_inventory.rs +1 -4
- crates/ec-av1/src/stream.rs +948 -81
- lanes/tiles-r5.charter.md +44 -0
- lanes/tiles-r6.charter.md +40 -0
- lanes/tiles-r6.report.md +81 -0
- lanes/tiles-r7.charter.md +52 -0
- lanes/tiles-r7.report.md +91 -0
- lanes/tiles-r8.charter.md +48 -0
- lanes/tiles-r8.report.md +43 -0
crates/ec-av1/src/decode.rsmodified+154 -26
| @@ -3220,6 +3220,13 @@ struct PlaneBuf { | ||
| 3220 | 3220 | /// right/bottom reach bound is still open, tracked in the report. |
| 3221 | 3221 | tile_x0: usize, |
| 3222 | 3222 | tile_y0: usize, |
| 3223 | + /// lane-tiles r5: this plane's own tile's right/bottom pixel bound | |
| 3224 | + /// (exclusive) -- a non-last tile column/row's own reach must stop at | |
| 3225 | + /// its own SB-aligned tile boundary. `width`/`height` (this plane's | |
| 3226 | + /// full padded extent) for the single-tile/last-tile case, matching the | |
| 3227 | + /// old unclipped behaviour exactly. | |
| 3228 | + tile_x1: usize, | |
| 3229 | + tile_y1: usize, | |
| 3223 | 3230 | } |
| 3224 | 3231 | |
| 3225 | 3232 | /// One entry per `MV_REFERENCE_FRAME` (index 0/1 unused -- `NONE`/ |
| @@ -3235,9 +3242,11 @@ impl PlaneBuf { | ||
| 3235 | 3242 | /// [`Self::tile_y0`]) before that tile's own superblock walk. `x0`/`y0` |
| 3236 | 3243 | /// are already in this plane's own units (luma pixels for `y`, chroma |
| 3237 | 3244 | /// pixels — halved — for `u`/`v`). |
| 3238 | - fn set_tile_origin(&mut self, x0: usize, y0: usize) { | |
| 3245 | + fn set_tile_origin(&mut self, x0: usize, y0: usize, x1: usize, y1: usize) { | |
| 3239 | 3246 | self.tile_x0 = x0; |
| 3240 | 3247 | self.tile_y0 = y0; |
| 3248 | + self.tile_x1 = x1; | |
| 3249 | + self.tile_y1 = y1; | |
| 3241 | 3250 | } |
| 3242 | 3251 | |
| 3243 | 3252 | fn edges( |
| @@ -3253,14 +3262,16 @@ impl PlaneBuf { | ||
| 3253 | 3262 | } else { |
| 3254 | 3263 | own_across |
| 3255 | 3264 | } |
| 3256 | - .min(self.width); | |
| 3265 | + .min(self.width) | |
| 3266 | + .min(self.tile_x1); | |
| 3257 | 3267 | let own_down = y + side.min(self.true_height.saturating_sub(y)); |
| 3258 | 3268 | let down = if reach.below_left { |
| 3259 | 3269 | own_down + side.min(self.true_height.saturating_sub(own_down)) |
| 3260 | 3270 | } else { |
| 3261 | 3271 | own_down |
| 3262 | 3272 | } |
| 3263 | - .min(self.height); | |
| 3273 | + .min(self.height) | |
| 3274 | + .min(self.tile_y1); | |
| 3264 | 3275 | let above = (y > self.tile_y0 && across > x) |
| 3265 | 3276 | .then(|| self.data[(y - 1) * self.width + x..][..across - x].to_vec()); |
| 3266 | 3277 | let left = (x > self.tile_x0 && down > y).then(|| { |
| @@ -3290,14 +3301,16 @@ impl PlaneBuf { | ||
| 3290 | 3301 | } else { |
| 3291 | 3302 | own_across |
| 3292 | 3303 | } |
| 3293 | - .min(self.width); | |
| 3304 | + .min(self.width) | |
| 3305 | + .min(self.tile_x1); | |
| 3294 | 3306 | let own_down = y + bh.min(self.true_height.saturating_sub(y)); |
| 3295 | 3307 | let down = if reach.below_left { |
| 3296 | 3308 | own_down + bh.min(self.true_height.saturating_sub(own_down)) |
| 3297 | 3309 | } else { |
| 3298 | 3310 | own_down |
| 3299 | 3311 | } |
| 3300 | - .min(self.height); | |
| 3312 | + .min(self.height) | |
| 3313 | + .min(self.tile_y1); | |
| 3301 | 3314 | let above = (y > self.tile_y0 && across > x) |
| 3302 | 3315 | .then(|| self.data[(y - 1) * self.width + x..][..across - x].to_vec()); |
| 3303 | 3316 | let left = (x > self.tile_x0 && down > y).then(|| { |
| @@ -5231,6 +5244,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 5231 | 5244 | true_height, |
| 5232 | 5245 | tile_x0: 0, |
| 5233 | 5246 | tile_y0: 0, |
| 5247 | + tile_x1: width, | |
| 5248 | + tile_y1: height, | |
| 5234 | 5249 | }; |
| 5235 | 5250 | let mut u = PlaneBuf { |
| 5236 | 5251 | data: vec![0u8; width * height / 4], |
| @@ -5240,6 +5255,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 5240 | 5255 | true_height: true_height / 2, |
| 5241 | 5256 | tile_x0: 0, |
| 5242 | 5257 | tile_y0: 0, |
| 5258 | + tile_x1: width / 2, | |
| 5259 | + tile_y1: height / 2, | |
| 5243 | 5260 | }; |
| 5244 | 5261 | let mut v = PlaneBuf { |
| 5245 | 5262 | data: vec![0u8; width * height / 4], |
| @@ -5249,6 +5266,8 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 5249 | 5266 | true_height: true_height / 2, |
| 5250 | 5267 | tile_x0: 0, |
| 5251 | 5268 | tile_y0: 0, |
| 5269 | + tile_x1: width / 2, | |
| 5270 | + tile_y1: height / 2, | |
| 5252 | 5271 | }; |
| 5253 | 5272 | |
| 5254 | 5273 | let scan32 = default_scan(TX32); |
| @@ -5301,9 +5320,24 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 5301 | 5320 | } |
| 5302 | 5321 | let mut dec = SymbolDecoder::new(tile_bytes); |
| 5303 | 5322 | neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize); |
| 5304 | - y.set_tile_origin(mi_col0 as usize * 4, mi_row0 as usize * 4); | |
| 5305 | - u.set_tile_origin(mi_col0 as usize * 2, mi_row0 as usize * 2); | |
| 5306 | - v.set_tile_origin(mi_col0 as usize * 2, mi_row0 as usize * 2); | |
| 5323 | + y.set_tile_origin( | |
| 5324 | + mi_col0 as usize * 4, | |
| 5325 | + mi_row0 as usize * 4, | |
| 5326 | + (mi_col1 as usize * 4).min(y.width), | |
| 5327 | + (mi_row1 as usize * 4).min(y.height), | |
| 5328 | + ); | |
| 5329 | + u.set_tile_origin( | |
| 5330 | + mi_col0 as usize * 2, | |
| 5331 | + mi_row0 as usize * 2, | |
| 5332 | + (mi_col1 as usize * 2).min(u.width), | |
| 5333 | + (mi_row1 as usize * 2).min(u.height), | |
| 5334 | + ); | |
| 5335 | + v.set_tile_origin( | |
| 5336 | + mi_col0 as usize * 2, | |
| 5337 | + mi_row0 as usize * 2, | |
| 5338 | + (mi_col1 as usize * 2).min(v.width), | |
| 5339 | + (mi_row1 as usize * 2).min(v.height), | |
| 5340 | + ); | |
| 5307 | 5341 | TILE_HITS.with(|c| c.set(c.get() + 1)); |
| 5308 | 5342 | |
| 5309 | 5343 | for sb_r in sb_r0..sb_r1 { |
| @@ -9868,8 +9902,14 @@ pub fn decode_inter_frame_tile( | ||
| 9868 | 9902 | enable_dual_filter: bool, |
| 9869 | 9903 | reference_select: bool, |
| 9870 | 9904 | ) -> Result<Picture> { |
| 9905 | + let single_tile = TileInfo { | |
| 9906 | + mi_col_starts: vec![0, mi_cols], | |
| 9907 | + mi_row_starts: vec![0, mi_rows], | |
| 9908 | + ..TileInfo::default() | |
| 9909 | + }; | |
| 9871 | 9910 | decode_inter_frame_tile_with_cdfs( |
| 9872 | - data, | |
| 9911 | + &[data], | |
| 9912 | + &single_tile, | |
| 9873 | 9913 | mi_cols, |
| 9874 | 9914 | mi_rows, |
| 9875 | 9915 | base_q_idx, |
| @@ -9910,7 +9950,8 @@ pub fn decode_inter_frame_tile( | ||
| 9910 | 9950 | /// `primary_ref_frame == PRIMARY_REF_NONE` too (an error-resilient stream), |
| 9911 | 9951 | /// so `None` is a real case here, not only a convenience default. |
| 9912 | 9952 | pub(crate) fn decode_inter_frame_tile_with_cdfs( |
| 9913 | - data: &[u8], | |
| 9953 | + tiles: &[&[u8]], | |
| 9954 | + tile_info: &TileInfo, | |
| 9914 | 9955 | mi_cols: u32, |
| 9915 | 9956 | mi_rows: u32, |
| 9916 | 9957 | base_q_idx: u8, |
| @@ -10000,6 +10041,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 10000 | 10041 | true_height: reference.height, |
| 10001 | 10042 | tile_x0: 0, |
| 10002 | 10043 | tile_y0: 0, |
| 10044 | + tile_x1: reference.width, | |
| 10045 | + tile_y1: reference.height, | |
| 10003 | 10046 | }; |
| 10004 | 10047 | let ref_u = PlaneBuf { |
| 10005 | 10048 | data: reference.u.clone(), |
| @@ -10009,6 +10052,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 10009 | 10052 | true_height: reference.height / 2, |
| 10010 | 10053 | tile_x0: 0, |
| 10011 | 10054 | tile_y0: 0, |
| 10055 | + tile_x1: reference.width / 2, | |
| 10056 | + tile_y1: reference.height / 2, | |
| 10012 | 10057 | }; |
| 10013 | 10058 | let ref_v = PlaneBuf { |
| 10014 | 10059 | data: reference.v.clone(), |
| @@ -10018,6 +10063,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 10018 | 10063 | true_height: reference.height / 2, |
| 10019 | 10064 | tile_x0: 0, |
| 10020 | 10065 | tile_y0: 0, |
| 10066 | + tile_x1: reference.width / 2, | |
| 10067 | + tile_y1: reference.height / 2, | |
| 10021 | 10068 | }; |
| 10022 | 10069 | // Every non-`LAST_FRAME` reference this frame header's own `ref_frame_idx` |
| 10023 | 10070 | // names a live DPB slot for (lane-av1refs: generalised from the old |
| @@ -10039,6 +10086,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 10039 | 10086 | true_height: g.height, |
| 10040 | 10087 | tile_x0: 0, |
| 10041 | 10088 | tile_y0: 0, |
| 10089 | + tile_x1: g.width, | |
| 10090 | + tile_y1: g.height, | |
| 10042 | 10091 | }, |
| 10043 | 10092 | PlaneBuf { |
| 10044 | 10093 | data: g.u.clone(), |
| @@ -10048,6 +10097,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 10048 | 10097 | true_height: g.height / 2, |
| 10049 | 10098 | tile_x0: 0, |
| 10050 | 10099 | tile_y0: 0, |
| 10100 | + tile_x1: g.width / 2, | |
| 10101 | + tile_y1: g.height / 2, | |
| 10051 | 10102 | }, |
| 10052 | 10103 | PlaneBuf { |
| 10053 | 10104 | data: g.v.clone(), |
| @@ -10057,6 +10108,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 10057 | 10108 | true_height: g.height / 2, |
| 10058 | 10109 | tile_x0: 0, |
| 10059 | 10110 | tile_y0: 0, |
| 10111 | + tile_x1: g.width / 2, | |
| 10112 | + tile_y1: g.height / 2, | |
| 10060 | 10113 | }, |
| 10061 | 10114 | ) |
| 10062 | 10115 | }) |
| @@ -10072,6 +10125,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 10072 | 10125 | true_height, |
| 10073 | 10126 | tile_x0: 0, |
| 10074 | 10127 | tile_y0: 0, |
| 10128 | + tile_x1: width, | |
| 10129 | + tile_y1: height, | |
| 10075 | 10130 | }; |
| 10076 | 10131 | let mut u = PlaneBuf { |
| 10077 | 10132 | data: vec![0u8; width * height / 4], |
| @@ -10081,6 +10136,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 10081 | 10136 | true_height: true_height / 2, |
| 10082 | 10137 | tile_x0: 0, |
| 10083 | 10138 | tile_y0: 0, |
| 10139 | + tile_x1: width / 2, | |
| 10140 | + tile_y1: height / 2, | |
| 10084 | 10141 | }; |
| 10085 | 10142 | let mut v = PlaneBuf { |
| 10086 | 10143 | data: vec![0u8; width * height / 4], |
| @@ -10090,6 +10147,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 10090 | 10147 | true_height: true_height / 2, |
| 10091 | 10148 | tile_x0: 0, |
| 10092 | 10149 | tile_y0: 0, |
| 10150 | + tile_x1: width / 2, | |
| 10151 | + tile_y1: height / 2, | |
| 10093 | 10152 | }; |
| 10094 | 10153 | |
| 10095 | 10154 | let scan32 = default_scan(TX32); |
| @@ -10097,18 +10156,8 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 10097 | 10156 | let scan8 = default_scan(TX8); |
| 10098 | 10157 | let scan4 = default_scan(TX4); |
| 10099 | 10158 | |
| 10100 | - let mut cdfs = initial_cdfs.unwrap_or_else(|| Cdfs::new(q_ctx_of(base_q_idx))); | |
| 10101 | - let mut dec = SymbolDecoder::new(data); | |
| 10102 | - // lane-comppin r9: tile-entry range, the earliest point comparable | |
| 10103 | - // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the | |
| 10104 | - // first ladder rung before any symbol (partition or otherwise) is read. | |
| 10105 | - if std::env::var_os("EC_AV1_TELL").is_some() { | |
| 10106 | - eprintln!( | |
| 10107 | - "TELL label=tile_init tell={} range={}", | |
| 10108 | - dec.debug_bitpos(), | |
| 10109 | - dec.debug_state().0 | |
| 10110 | - ); | |
| 10111 | - } | |
| 10159 | + let base_cdfs = initial_cdfs.unwrap_or_else(|| Cdfs::new(q_ctx_of(base_q_idx))); | |
| 10160 | + let mut result_cdfs = base_cdfs.clone(); | |
| 10112 | 10161 | let mut neighbours = Neighbours::new( |
| 10113 | 10162 | cols as usize * 2, |
| 10114 | 10163 | rows as usize * 2, |
| @@ -10117,9 +10166,73 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 10117 | 10166 | ); |
| 10118 | 10167 | let mut grid = MiGrid::new(mi_cols as usize, mi_rows as usize); |
| 10119 | 10168 | |
| 10120 | - for sb_r in 0..sb_rows { | |
| 10169 | + // lane-tiles r6: mirrors decode_key_frame_tile_with_cdfs's own per-tile | |
| 10170 | + // loop (spec 5.11.2 decode_tile / 7.20 exit_symbol) -- each tile gets | |
| 10171 | + // its own fresh SymbolDecoder over its own byte range and its own fresh | |
| 10172 | + // copy of the frame's initial CDFs; only context_update_tile_id's own | |
| 10173 | + // end-of-tile adapted table becomes the frame's own output. | |
| 10174 | + for (tile_idx, &data) in tiles.iter().enumerate() { | |
| 10175 | + let tile_num = tile_idx as u32; | |
| 10176 | + let (trow, tcol) = (tile_num / tile_info.cols, tile_num % tile_info.cols); | |
| 10177 | + let mi_row0 = tile_info.mi_row_starts[trow as usize]; | |
| 10178 | + let mi_row1 = tile_info.mi_row_starts[trow as usize + 1]; | |
| 10179 | + let mi_col0 = tile_info.mi_col_starts[tcol as usize]; | |
| 10180 | + let mi_col1 = tile_info.mi_col_starts[tcol as usize + 1]; | |
| 10181 | + let (sb_r0, sb_r1) = ( | |
| 10182 | + (mi_row0 / SB_MI).min(sb_rows), | |
| 10183 | + mi_row1.div_ceil(SB_MI).min(sb_rows), | |
| 10184 | + ); | |
| 10185 | + let (sb_c0, sb_c1) = ( | |
| 10186 | + (mi_col0 / SB_MI).min(sb_cols), | |
| 10187 | + mi_col1.div_ceil(SB_MI).min(sb_cols), | |
| 10188 | + ); | |
| 10189 | + let mut cdfs = base_cdfs.clone(); | |
| 10190 | + let mut dec = SymbolDecoder::new(data); | |
| 10191 | + // lane-comppin r9: tile-entry range, the earliest point comparable | |
| 10192 | + // against aomdec's own `r->ec.rng` right after `aom_reader_init` -- the | |
| 10193 | + // first ladder rung before any symbol (partition or otherwise) is read. | |
| 10194 | + if std::env::var_os("EC_AV1_TELL").is_some() { | |
| 10195 | + eprintln!( | |
| 10196 | + "TELL label=tile_init tell={} range={}", | |
| 10197 | + dec.debug_bitpos(), | |
| 10198 | + dec.debug_state().0 | |
| 10199 | + ); | |
| 10200 | + } | |
| 10201 | + neighbours.start_tile(mi_row0 as usize, mi_col0 as usize, mi_col1 as usize); | |
| 10202 | + y.set_tile_origin( | |
| 10203 | + mi_col0 as usize * 4, | |
| 10204 | + mi_row0 as usize * 4, | |
| 10205 | + (mi_col1 as usize * 4).min(y.width), | |
| 10206 | + (mi_row1 as usize * 4).min(y.height), | |
| 10207 | + ); | |
| 10208 | + u.set_tile_origin( | |
| 10209 | + mi_col0 as usize * 2, | |
| 10210 | + mi_row0 as usize * 2, | |
| 10211 | + (mi_col1 as usize * 2).min(u.width), | |
| 10212 | + (mi_row1 as usize * 2).min(u.height), | |
| 10213 | + ); | |
| 10214 | + v.set_tile_origin( | |
| 10215 | + mi_col0 as usize * 2, | |
| 10216 | + mi_row0 as usize * 2, | |
| 10217 | + (mi_col1 as usize * 2).min(v.width), | |
| 10218 | + (mi_row1 as usize * 2).min(v.height), | |
| 10219 | + ); | |
| 10220 | + // lane-tiles r6: an MV candidate scan (mvstack.rs's grid.get) must | |
| 10221 | + // not reach across a tile boundary any more than intra prediction's | |
| 10222 | + // PlaneBuf reach does -- bounding the shared grid's own read window | |
| 10223 | + // per tile is equivalent to threading tile bounds through every | |
| 10224 | + // find_mv_stack* call site (all four read through this one grid). | |
| 10225 | + grid.set_tile_bounds( | |
| 10226 | + mi_row0 as usize, | |
| 10227 | + mi_col0 as usize, | |
| 10228 | + mi_row1 as usize, | |
| 10229 | + mi_col1 as usize, | |
| 10230 | + ); | |
| 10231 | + TILE_HITS.with(|c| c.set(c.get() + 1)); | |
| 10232 | + | |
| 10233 | + for sb_r in sb_r0..sb_r1 { | |
| 10121 | 10234 | neighbours.start_row(); |
| 10122 | - for sb_c in 0..sb_cols { | |
| 10235 | + for sb_c in sb_c0..sb_c1 { | |
| 10123 | 10236 | CDEF_TRANSMITTED.with(|c| c.set(false)); |
| 10124 | 10237 | let sb_at = (sb_r as usize * 4, sb_c as usize * 4); |
| 10125 | 10238 | let sb_ctx = neighbours.partition_ctx(sb_at, SB); |
| @@ -11309,6 +11422,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 11309 | 11422 | } |
| 11310 | 11423 | } |
| 11311 | 11424 | |
| 11425 | + if tile_num == tile_info.context_update_tile_id { | |
| 11426 | + result_cdfs = cdfs; | |
| 11427 | + } | |
| 11428 | + } | |
| 11429 | + | |
| 11312 | 11430 | // lane-comppin r4: pre-loop-filter decode-order dump, matching aomdec's |
| 11313 | 11431 | // own EC_AV1_PREFILT_DUMP shape (decodeframe.c ~5451) -- diffs against |
| 11314 | 11432 | // that isolate whether a decode-order frame's mismatch already exists |
| @@ -11346,7 +11464,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 11346 | 11464 | u: u.data, |
| 11347 | 11465 | v: v.data, |
| 11348 | 11466 | }, |
| 11349 | - cdfs, | |
| 11467 | + result_cdfs, | |
| 11350 | 11468 | motion_field, |
| 11351 | 11469 | )); |
| 11352 | 11470 | } |
| @@ -11365,7 +11483,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 11365 | 11483 | u: crop(&u, fw / 2, fh / 2), |
| 11366 | 11484 | v: crop(&v, fw / 2, fh / 2), |
| 11367 | 11485 | }, |
| 11368 | - cdfs, | |
| 11486 | + result_cdfs, | |
| 11369 | 11487 | motion_field, |
| 11370 | 11488 | )) |
| 11371 | 11489 | } |
| @@ -12034,6 +12152,8 @@ mod tests { | ||
| 12034 | 12152 | true_height: height / scale, |
| 12035 | 12153 | tile_x0: 0, |
| 12036 | 12154 | tile_y0: 0, |
| 12155 | + tile_x1: width / scale, | |
| 12156 | + tile_y1: height / scale, | |
| 12037 | 12157 | }; |
| 12038 | 12158 | let ref_y = PlaneBuf { |
| 12039 | 12159 | data: ref_pattern.clone(), |
| @@ -12043,6 +12163,8 @@ mod tests { | ||
| 12043 | 12163 | true_height: height, |
| 12044 | 12164 | tile_x0: 0, |
| 12045 | 12165 | tile_y0: 0, |
| 12166 | + tile_x1: width, | |
| 12167 | + tile_y1: height, | |
| 12046 | 12168 | }; |
| 12047 | 12169 | let ref_u = ref_plane(2); |
| 12048 | 12170 | let ref_v = ref_plane(2); |
| @@ -12055,6 +12177,8 @@ mod tests { | ||
| 12055 | 12177 | true_height: height, |
| 12056 | 12178 | tile_x0: 0, |
| 12057 | 12179 | tile_y0: 0, |
| 12180 | + tile_x1: width, | |
| 12181 | + tile_y1: height, | |
| 12058 | 12182 | }; |
| 12059 | 12183 | let mut u = PlaneBuf { |
| 12060 | 12184 | data: vec![0u8; (width / 2) * (height / 2)], |
| @@ -12064,6 +12188,8 @@ mod tests { | ||
| 12064 | 12188 | true_height: height / 2, |
| 12065 | 12189 | tile_x0: 0, |
| 12066 | 12190 | tile_y0: 0, |
| 12191 | + tile_x1: width / 2, | |
| 12192 | + tile_y1: height / 2, | |
| 12067 | 12193 | }; |
| 12068 | 12194 | let mut v = PlaneBuf { |
| 12069 | 12195 | data: vec![0u8; (width / 2) * (height / 2)], |
| @@ -12073,6 +12199,8 @@ mod tests { | ||
| 12073 | 12199 | true_height: height / 2, |
| 12074 | 12200 | tile_x0: 0, |
| 12075 | 12201 | tile_y0: 0, |
| 12202 | + tile_x1: width / 2, | |
| 12203 | + tile_y1: height / 2, | |
| 12076 | 12204 | }; |
| 12077 | 12205 | |
| 12078 | 12206 | let mut cdfs = Cdfs::new(q_ctx_of(100)); |
crates/ec-av1/src/mvstack.rsmodified+33 -3
| @@ -177,6 +177,15 @@ pub struct MiGrid { | ||
| 177 | 177 | cols: usize, |
| 178 | 178 | rows: usize, |
| 179 | 179 | 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, | |
| 180 | 189 | } |
| 181 | 190 | |
| 182 | 191 | impl MiGrid { |
| @@ -186,9 +195,24 @@ impl MiGrid { | ||
| 186 | 195 | cols, |
| 187 | 196 | rows, |
| 188 | 197 | cells: vec![None; cols * rows], |
| 198 | + tile_row0: 0, | |
| 199 | + tile_col0: 0, | |
| 200 | + tile_row1: rows, | |
| 201 | + tile_col1: cols, | |
| 189 | 202 | } |
| 190 | 203 | } |
| 191 | 204 | |
| 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 | + | |
| 192 | 216 | /// Records the unit at `(row, col)`. Out-of-range coordinates are a |
| 193 | 217 | /// no-op — the caller only ever addresses units inside the grid it built. |
| 194 | 218 | pub fn set(&mut self, row: usize, col: usize, info: MiInfo) { |
| @@ -197,10 +221,16 @@ impl MiGrid { | ||
| 197 | 221 | } |
| 198 | 222 | } |
| 199 | 223 | |
| 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`]). | |
| 202 | 226 | 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 | + { | |
| 204 | 234 | self.cells[row * self.cols + col].as_ref() |
| 205 | 235 | } else { |
| 206 | 236 | None |
crates/ec-av1/src/refusal_inventory.rsmodified+1 -4
| @@ -39,6 +39,7 @@ const REFUSALS: &[&str] = &[ | ||
| 39 | 39 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 40 | 40 | "a 32x32 partition type this decoder does not code (value={part32})", |
| 41 | 41 | "a Golomb tail longer than this decoder reads", |
| 42 | + "a stream whose bit depth is not 8 (this decoder reconstructs into 8-bit planes)", | |
| 42 | 43 | "a tx_type symbol outside its CDF's own set: {t}", |
| 43 | 44 | "an INTER 32x32 partition type this decoder does not code (value={part32})", |
| 44 | 45 | "a superblock-level partition type other than NONE or SPLIT (this decoder's intra tile path codes only those two at 64x64)", |
| @@ -51,10 +52,6 @@ const REFUSALS: &[&str] = &[ | ||
| 51 | 52 | "a frame naming primary_ref_frame at a reference slot with no saved CDF state", |
| 52 | 53 | "a frame with delta_q_present or delta_lf_present set (this decoder never reads the per-superblock delta symbols)", |
| 53 | 54 | "a frame with loop restoration enabled (this decoder never reads the per-unit lr symbols)", |
| 54 | - "a frame with more than one tile row (only tile columns are proven pixel-exact so far)", | |
| 55 | - "a frame with more than two tile columns (a non-last column's right-edge reach bound past column 0 is unimplemented)", | |
| 56 | - "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)", | |
| 57 | - "an inter frame with more than one tile (the inter tile-decode path has no per-tile loop, only key frames do)", | |
| 58 | 55 | "a frame with no mode-info grid", |
| 59 | 56 | "a frame with segmentation enabled (this decoder never reads a per-block segment_id symbol)", |
| 60 | 57 | "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", |
crates/ec-av1/src/stream.rsmodified+948 -81
| @@ -120,9 +120,14 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 120 | 120 | let ObuKind::Frame(header, tiles) = obu.kind else { |
| 121 | 121 | continue; |
| 122 | 122 | }; |
| 123 | - let tile = tiles.first().ok_or_else(|| { | |
| 124 | - Error::unsupported("AV1 decode_stream", "a frame OBU with no tile group") | |
| 125 | - })?; | |
| 123 | + // Every tile is decoded below through `tile_bufs`; this only rejects a | |
| 124 | + // frame OBU that carries no tile group at all. | |
| 125 | + if tiles.is_empty() { | |
| 126 | + return Err(Error::unsupported( | |
| 127 | + "AV1 decode_stream", | |
| 128 | + "a frame OBU with no tile group", | |
| 129 | + )); | |
| 130 | + } | |
| 126 | 131 | // `read_cdef` (spec `decodeframe.c`, called at the first non-skip |
| 127 | 132 | // block of each 64x64) only reads a literal `cdef_idx` when |
| 128 | 133 | // `cdef_bits > 0`; at `cdef_bits == 0` there is nothing to read (a |
| @@ -165,6 +170,25 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 165 | 170 | // intrabc call at all -- that symbol is intra-frame-only). A |
| 166 | 171 | // genuine palette/intrabc use still refuses by name deeper in the |
| 167 | 172 | // block readers, so no whole-frame refusal is needed here anymore. |
| 173 | + // Both AV1 files in this box's own library (a 2160p HDR10 encode and a | |
| 174 | + // 1080p one, probed 2026-08-30 through `examples/decode_probe`) are | |
| 175 | + // `yuv420p10le`, and every buffer this decoder reconstructs into -- | |
| 176 | + // `Picture`'s `y`/`u`/`v` -- is `Vec<u8>`. A 10- or 12-bit stream would | |
| 177 | + // therefore be reconstructed into 8-bit samples and compared against a | |
| 178 | + // 10-bit reference, which is silent wrongness rather than a desync: no | |
| 179 | + // symbol goes unread, the pixels are just quietly truncated. Refuse it | |
| 180 | + // by name until the planes are widened. `bit_depth` defaults to 8 when | |
| 181 | + // no sequence header has been seen, which is the existing behaviour for | |
| 182 | + // every fixture in this crate. | |
| 183 | + if parser | |
| 184 | + .sequence_header() | |
| 185 | + .is_some_and(|seq| seq.color_config.bit_depth != 8) | |
| 186 | + { | |
| 187 | + return Err(Error::unsupported( | |
| 188 | + "AV1 decode_stream", | |
| 189 | + "a stream whose bit depth is not 8 (this decoder reconstructs into 8-bit planes)", | |
| 190 | + )); | |
| 191 | + } | |
| 168 | 192 | if header.delta.q_present || header.delta.lf_present { |
| 169 | 193 | return Err(Error::unsupported( |
| 170 | 194 | "AV1 decode_stream", |
| @@ -277,66 +301,37 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 277 | 301 | // of `skip_mode_frame`, plain average blend), so the old blanket |
| 278 | 302 | // `skip_mode_present` refusal is gone. |
| 279 | 303 | // `context_update_tile_id` (spec `decode_tile`/`exit_symbol`) names |
| 280 | - // which tile's end-of-tile adapted CDFs become the frame's own; this | |
| 281 | - // decoder still only ever *keeps* tile 0's adapted table (see the | |
| 282 | - // `context_update_tile_id != 0` refusal further down), so any frame | |
| 283 | - // naming a different tile there is refused rather than silently | |
| 284 | - // forwarding the wrong tile's table. | |
| 304 | + // which tile's end-of-tile adapted CDFs become the frame's own. | |
| 305 | + // lane-tiles r8: this comment used to claim a `!= 0` refusal existed | |
| 306 | + // "further down" -- it did not (`decode.rs` reads | |
| 307 | + // `tile_info.context_update_tile_id` generically at both the | |
| 308 | + // key-frame and inter-frame tile loops' `result_cdfs = cdfs` sites, | |
| 309 | + // never hardcoded to tile 0); stale documentation, not a real gap. | |
| 310 | + // `a_real_aomenc_stream_with_four_tile_rows_decodes_pixel_exact` | |
| 311 | + // hard-asserts a live aomenc stream naming tile 1/2/3 decodes | |
| 312 | + // pixel-exact, so the capability is now proven as well as described | |
| 313 | + // correctly. | |
| 285 | 314 | // |
| 286 | - // lane-tiles r4: the multi-tile refusal itself is now scoped, not | |
| 287 | - // blanket. `decode_key_frame_tile_with_cdfs` genuinely loops every | |
| 288 | - // tile (r2/r3), proven pixel-exact by | |
| 289 | - // `a_real_aomenc_stream_with_two_tile_columns_decodes_pixel_exact` | |
| 290 | - // (2 tile columns, `--loopfilter-control=0`) -- but that gate's own | |
| 291 | - // doc comment names two gaps it deliberately sidesteps, so this | |
| 292 | - // refusal keeps refusing exactly those: | |
| 293 | - // - `decode_inter_frame_tile_with_cdfs` takes one `&[u8]` tile | |
| 294 | - // payload, not a `tiles: &[&[u8]]` list -- it has no per-tile | |
| 295 | - // loop at all, so an inter frame with >1 tile is still refused | |
| 296 | - // unconditionally. | |
| 297 | - // - Deblocking crosses tile boundaries by spec default (AV1 has | |
| 298 | - // no `loop_filter_across_tiles_enabled`-style flag at all -- | |
| 299 | - // confirmed absent from `ec-av1-syntax`'s `loop_filter_params` | |
| 300 | - // read, spec 5.9.11 has no such field either), but `PlaneBuf`'s | |
| 301 | - // `tile_x0`/`tile_y0` origin only ever clips a tile's own | |
| 302 | - // left/top reach, not a non-last column's right-edge reach -- | |
| 303 | - // so a key frame with `loop_filter.level` non-zero (deblocking | |
| 304 | - // actually on) still refuses. | |
| 305 | - // - The proven gate is 2 tile *columns*, 1 tile *row*; a | |
| 306 | - // non-last column's right-edge reach bound past column 0 is | |
| 307 | - // unimplemented for 3+ columns (r3's own known gap), so `cols` | |
| 308 | - // is capped at 2. Tile rows are untested this round, so `rows` | |
| 309 | - // stays capped at 1. | |
| 310 | - let loop_filter_on = header.loop_filter.level.iter().any(|&l| l != 0); | |
| 311 | - if header.frame_type != FrameType::Key && header.tile_info.cols > 1 { | |
| 312 | - return Err(Error::unsupported( | |
| 313 | - "AV1 decode_stream", | |
| 314 | - "an inter frame with more than one tile (the inter tile-decode path has no per-tile loop, only key frames do)", | |
| 315 | - )); | |
| 316 | - } | |
| 317 | - if header.tile_info.rows > 1 { | |
| 318 | - return Err(Error::unsupported( | |
| 319 | - "AV1 decode_stream", | |
| 320 | - "a frame with more than one tile row (only tile columns are proven pixel-exact so far)", | |
| 321 | - )); | |
| 322 | - } | |
| 323 | - if header.tile_info.cols > 2 { | |
| 324 | - return Err(Error::unsupported( | |
| 325 | - "AV1 decode_stream", | |
| 326 | - "a frame with more than two tile columns (a non-last column's right-edge reach bound past column 0 is unimplemented)", | |
| 327 | - )); | |
| 328 | - } | |
| 329 | - if header.tile_info.cols > 1 && loop_filter_on { | |
| 330 | - return Err(Error::unsupported( | |
| 331 | - "AV1 decode_stream", | |
| 332 | - "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)", | |
| 333 | - )); | |
| 334 | - } | |
| 315 | + // lane-tiles r4/r6/r7/r8: the multi-tile refusal itself is scoped, | |
| 316 | + // not blanket. `decode_key_frame_tile_with_cdfs` and (r6) | |
| 317 | + // `decode_inter_frame_tile_with_cdfs` both genuinely loop every | |
| 318 | + // tile, `mvstack.rs`'s `MiGrid` is bounded per tile | |
| 319 | + // (`MiGrid::set_tile_bounds`), and `PlaneBuf`'s `tile_x0/y0/x1/y1` | |
| 320 | + // origin receives real values at every call site (r6's | |
| 321 | + // `set_tile_origin` sweep). r7 proved the two remaining | |
| 322 | + // tile-*column* gaps closed (inter frames, >2 columns with loop | |
| 323 | + // filtering on). r8 proved tile *rows* the same way: the per-tile | |
| 324 | + // loop's row math (`tile_num / tile_info.cols`, | |
| 325 | + // `mi_row_starts`/`set_tile_origin`'s `y0`/`y1`) is exactly | |
| 326 | + // symmetric with the column path already proven, and | |
| 327 | + // `a_real_aomenc_stream_with_two_tile_rows_decodes_pixel_exact` | |
| 328 | + // (bypass gate, loop filter ON) confirmed it: 20/20 pixel-exact. | |
| 329 | + // `a_real_aomenc_stream_with_two_tile_rows_decodes_through_decode_ | |
| 330 | + // stream` below re-proves it through this entry point. Tile columns | |
| 331 | + // and tile rows (any count, loop filter on) are no longer capped. | |
| 335 | 332 | // `Tile::offset` is relative to the buffer `parse_obu` was handed |
| 336 | 333 | // (`&data[pos..]` at the time this OBU was parsed), so it is relative |
| 337 | 334 | // to `obu_offset`, not to `data` as a whole. |
| 338 | - let start = obu_offset + tile.offset; | |
| 339 | - let tile_bytes = data.get(start..start + tile.size).ok_or(Error::NeedMore)?; | |
| 340 | 335 | let tile_bufs: Vec<&[u8]> = tiles |
| 341 | 336 | .iter() |
| 342 | 337 | .map(|t| { |
| @@ -472,7 +467,8 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | ||
| 472 | 467 | ) |
| 473 | 468 | }); |
| 474 | 469 | decode_inter_frame_tile_with_cdfs( |
| 475 | - tile_bytes, | |
| 470 | + &tile_bufs, | |
| 471 | + &header.tile_info, | |
| 476 | 472 | header.mi_cols, |
| 477 | 473 | header.mi_rows, |
| 478 | 474 | header.quantization.base_q_idx, |
| @@ -6132,7 +6128,7 @@ mod tests { | ||
| 6132 | 6128 | } |
| 6133 | 6129 | } |
| 6134 | 6130 | |
| 6135 | - /// lane-tiles r3: a real two-tile-column aomenc key frame, decoded | |
| 6131 | + /// lane-tiles r3/r7: a real two-tile-column aomenc key frame, decoded | |
| 6136 | 6132 | /// through [`decode_key_frame_tile_with_cdfs`] directly with the whole |
| 6137 | 6133 | /// `tiles: &[&[u8]]` list -- `decode_stream`'s `cols > 1 || rows > 1` |
| 6138 | 6134 | /// refusal (this file, ~line 292) still fires for any stream this wide, |
| @@ -6144,7 +6140,12 @@ mod tests { | ||
| 6144 | 6140 | /// also the frame's own right edge -- the known gap (`PlaneBuf`'s |
| 6145 | 6141 | /// tile_x0/tile_y0 only clip left/top reach, not a non-last column's |
| 6146 | 6142 | /// right-edge reach) does not apply to this fixture; it would to a |
| 6147 | - /// 3+-column one. Tile count itself is a structural aomenc param, not | |
| 6143 | + /// 3+-column one, proven separately by the four-tile-column gate below. | |
| 6144 | + /// r7: `--loopfilter-control=0` REMOVED per the charter -- `PlaneBuf`'s | |
| 6145 | + /// `tile_x1`/`tile_y1` clamps now receive real values at every call site | |
| 6146 | + /// (r6's `set_tile_origin` sweep), so this gate now proves real | |
| 6147 | + /// deblocking across the tile boundary too, not just decode with it off. | |
| 6148 | + /// Tile count itself is a structural aomenc param, not | |
| 6148 | 6149 | /// RD-dependent content, but this decoder's chroma smooth/paeth gap |
| 6149 | 6150 | /// (`decode.rs` "a smooth or paeth chroma mode (round 2)", unrelated to |
| 6150 | 6151 | /// tiles, pre-dating this lane) is content-dependent -- no aomenc flag |
| @@ -6225,7 +6226,6 @@ mod tests { | ||
| 6225 | 6226 | // into the next tile's still-undecoded/differently- |
| 6226 | 6227 | // origined samples. Off here since deblocking itself is |
| 6227 | 6228 | // not what this gate is proving. |
| 6228 | - "--loopfilter-control=0", | |
| 6229 | 6229 | "--enable-rect-partitions=0", |
| 6230 | 6230 | "--enable-ab-partitions=0", |
| 6231 | 6231 | "--enable-1to4-partitions=0", |
| @@ -6366,19 +6366,26 @@ mod tests { | ||
| 6366 | 6366 | ); |
| 6367 | 6367 | } |
| 6368 | 6368 | |
| 6369 | - /// lane-tiles r4: the same real two-tile-column stream as the gate | |
| 6370 | - /// above, this time run through `decode_stream` itself -- the entry | |
| 6371 | - /// point real callers use, not the `decode_key_frame_tile_with_cdfs` | |
| 6372 | - /// bypass. Proves the `cols > 1` refusal is actually lifted (not just | |
| 6373 | - /// that the underlying per-tile loop works) for the scoped case this | |
| 6374 | - /// round proved safe: 2 tile columns, 1 tile row, key frame, loop | |
| 6375 | - /// filtering off (`--loopfilter-control=0` stays -- deblocking crosses | |
| 6376 | - /// tile boundaries by spec default and `PlaneBuf` cannot bound a | |
| 6377 | - /// non-last column's right-edge reach yet, see the refusal's own doc | |
| 6378 | - /// comment above `decode_stream`). | |
| 6369 | + /// lane-tiles r8 stage 1: the same bypass-the-refusal pattern as the | |
| 6370 | + /// two-tile-column gate above, this time for tile ROWS -- `decode_stream` | |
| 6371 | + /// still refuses any `tile_info.rows > 1` stream, so this gate calls | |
| 6372 | + /// [`decode_key_frame_tile_with_cdfs`] directly to prove the underlying | |
| 6373 | + /// per-tile loop (already row/col-generic: `tile_num / tile_info.cols` | |
| 6374 | + /// gives the row, `mi_row_starts`/`set_tile_origin`'s `y0`/`y1` are | |
| 6375 | + /// exactly symmetric with the column gate's `x0`/`x1`) actually decodes | |
| 6376 | + /// both tile rows pixel-exact before the refusal is lifted. 64x128 is | |
| 6377 | + /// one 64px superblock wide and two tall with `--tile-rows=1` | |
| 6378 | + /// (`TileRows=2`, `--tile-columns=0` keeps `cols=1` so only the row axis | |
| 6379 | + /// is under test). Loop filter is left ON (no | |
| 6380 | + /// `--loopfilter-control=0`) per the charter -- deblocking crosses tile | |
| 6381 | + /// row boundaries by spec default exactly as it crosses column ones, and | |
| 6382 | + /// `deblock_plane` runs once over the whole decoded picture after every | |
| 6383 | + /// tile is in, with no tile-axis distinction, so there is no reason to | |
| 6384 | + /// expect the row boundary to behave differently from the column one r7 | |
| 6385 | + /// already proved -- this gate is what actually proves it either way. | |
| 6379 | 6386 | #[test] |
| 6380 | - fn a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream() { | |
| 6381 | - const NAME: &str = "a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream"; | |
| 6387 | + fn a_real_aomenc_stream_with_two_tile_rows_decodes_pixel_exact() { | |
| 6388 | + const NAME: &str = "a_real_aomenc_stream_with_two_tile_rows_decodes_pixel_exact"; | |
| 6382 | 6389 | if !have_ffmpeg() { |
| 6383 | 6390 | eprintln!("SKIP {NAME}: no ffmpeg"); |
| 6384 | 6391 | return; |
| @@ -6387,7 +6394,200 @@ mod tests { | ||
| 6387 | 6394 | eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); |
| 6388 | 6395 | return; |
| 6389 | 6396 | } |
| 6390 | - let (width, height) = (128usize, 64usize); | |
| 6397 | + let (width, height) = (64usize, 128usize); | |
| 6398 | + let mut matched = 0u32; | |
| 6399 | + let mut named_refusals = 0u32; | |
| 6400 | + for attempt in 0..20u32 { | |
| 6401 | + let seed = 42 + attempt; | |
| 6402 | + let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | |
| 6403 | + let y4m = Command::new("ffmpeg") | |
| 6404 | + .args([ | |
| 6405 | + "-v", | |
| 6406 | + "error", | |
| 6407 | + "-f", | |
| 6408 | + "lavfi", | |
| 6409 | + "-i", | |
| 6410 | + &source, | |
| 6411 | + "-pix_fmt", | |
| 6412 | + "yuv420p", | |
| 6413 | + "-f", | |
| 6414 | + "yuv4mpegpipe", | |
| 6415 | + "-", | |
| 6416 | + ]) | |
| 6417 | + .stdin(Stdio::null()) | |
| 6418 | + .stdout(Stdio::piped()) | |
| 6419 | + .stderr(Stdio::piped()) | |
| 6420 | + .output() | |
| 6421 | + .expect("ffmpeg failed to run"); | |
| 6422 | + assert!( | |
| 6423 | + y4m.status.success(), | |
| 6424 | + "ffmpeg fixture: {}", | |
| 6425 | + String::from_utf8_lossy(&y4m.stderr) | |
| 6426 | + ); | |
| 6427 | + let mut child = Command::new(aomenc_path()) | |
| 6428 | + .args([ | |
| 6429 | + "--codec=av1", | |
| 6430 | + "--passes=1", | |
| 6431 | + "--end-usage=q", | |
| 6432 | + "--cq-level=45", | |
| 6433 | + "--cpu-used=0", | |
| 6434 | + "--limit=1", | |
| 6435 | + "--kf-max-dist=1000", | |
| 6436 | + "--threads=1", | |
| 6437 | + "--row-mt=0", | |
| 6438 | + "--tile-columns=0", | |
| 6439 | + "--tile-rows=1", | |
| 6440 | + // This decoder hardcodes SB_MI=16 (64px) superblocks | |
| 6441 | + // everywhere; without this aomenc's own default 128x128 | |
| 6442 | + // superblock makes 64x128 exactly ONE superblock tall, | |
| 6443 | + // so `--tile-rows=1` has nothing to split. | |
| 6444 | + "--sb-size=64", | |
| 6445 | + "--enable-rect-partitions=0", | |
| 6446 | + "--enable-ab-partitions=0", | |
| 6447 | + "--enable-1to4-partitions=0", | |
| 6448 | + "--enable-filter-intra=0", | |
| 6449 | + "--enable-smooth-intra=0", | |
| 6450 | + "--enable-paeth-intra=0", | |
| 6451 | + "--enable-directional-intra=0", | |
| 6452 | + "--enable-angle-delta=0", | |
| 6453 | + "--enable-tx-size-search=0", | |
| 6454 | + "--enable-cdef=0", | |
| 6455 | + "--enable-restoration=0", | |
| 6456 | + "--max-partition-size=32", | |
| 6457 | + "--min-partition-size=32", | |
| 6458 | + "--enable-palette=0", | |
| 6459 | + "--enable-intrabc=0", | |
| 6460 | + "--enable-cfl-intra=0", | |
| 6461 | + "--obu", | |
| 6462 | + "-o", | |
| 6463 | + "-", | |
| 6464 | + "-", | |
| 6465 | + ]) | |
| 6466 | + .stdin(Stdio::piped()) | |
| 6467 | + .stdout(Stdio::piped()) | |
| 6468 | + .stderr(Stdio::piped()) | |
| 6469 | + .spawn() | |
| 6470 | + .expect("aomenc failed to start"); | |
| 6471 | + child | |
| 6472 | + .stdin | |
| 6473 | + .take() | |
| 6474 | + .expect("aomenc stdin") | |
| 6475 | + .write_all(&y4m.stdout) | |
| 6476 | + .expect("writing y4m to aomenc"); | |
| 6477 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 6478 | + assert!( | |
| 6479 | + out.status.success(), | |
| 6480 | + "aomenc refused the fixture: {}", | |
| 6481 | + String::from_utf8_lossy(&out.stderr) | |
| 6482 | + ); | |
| 6483 | + let stream = out.stdout; | |
| 6484 | + | |
| 6485 | + let mut parser = Av1Parser::new(); | |
| 6486 | + let mut pos = 0usize; | |
| 6487 | + let mut frame = None; | |
| 6488 | + while pos < stream.len() { | |
| 6489 | + let obu_offset = pos; | |
| 6490 | + let obu = parser.parse_obu(&stream[pos..]).unwrap(); | |
| 6491 | + pos += obu.total_size; | |
| 6492 | + if let ObuKind::Frame(header, tiles) = obu.kind { | |
| 6493 | + frame = Some((header, tiles, obu_offset)); | |
| 6494 | + break; | |
| 6495 | + } | |
| 6496 | + } | |
| 6497 | + let (header, tiles, obu_offset) = frame.expect("stream has a Frame OBU"); | |
| 6498 | + assert!( | |
| 6499 | + header.tile_info.rows > 1, | |
| 6500 | + "{NAME}: aomenc did not actually split into >1 tile row (rows={}, seed {seed})", | |
| 6501 | + header.tile_info.rows | |
| 6502 | + ); | |
| 6503 | + assert_eq!( | |
| 6504 | + tiles.len(), | |
| 6505 | + header.tile_info.rows as usize, | |
| 6506 | + "{NAME}: expected one tile per row (cols=1, seed {seed})" | |
| 6507 | + ); | |
| 6508 | + let tile_bufs: Vec<&[u8]> = tiles | |
| 6509 | + .iter() | |
| 6510 | + .map(|t| &stream[obu_offset + t.offset..obu_offset + t.offset + t.size]) | |
| 6511 | + .collect(); | |
| 6512 | + | |
| 6513 | + let enable_filter_intra = parser | |
| 6514 | + .sequence_header() | |
| 6515 | + .is_some_and(|seq| seq.enable_filter_intra); | |
| 6516 | + let enable_edge_filter = parser | |
| 6517 | + .sequence_header() | |
| 6518 | + .is_some_and(|seq| seq.enable_intra_edge_filter); | |
| 6519 | + | |
| 6520 | + let before = crate::decode::tile_hits(); | |
| 6521 | + let picture = match decode_key_frame_tile_with_cdfs( | |
| 6522 | + &tile_bufs, | |
| 6523 | + &header.tile_info, | |
| 6524 | + header.mi_cols, | |
| 6525 | + header.mi_rows, | |
| 6526 | + header.quantization.base_q_idx, | |
| 6527 | + header.frame_width, | |
| 6528 | + header.frame_height, | |
| 6529 | + enable_filter_intra, | |
| 6530 | + enable_edge_filter, | |
| 6531 | + &header.cdef, | |
| 6532 | + &header.loop_filter, | |
| 6533 | + None, | |
| 6534 | + header.tx_mode == TxMode::Select, | |
| 6535 | + header.reduced_tx_set, | |
| 6536 | + header.allow_screen_content_tools, | |
| 6537 | + header.allow_intrabc, | |
| 6538 | + ) { | |
| 6539 | + Err(e) => { | |
| 6540 | + let msg = e.to_string(); | |
| 6541 | + assert!( | |
| 6542 | + msg.contains("unsupported"), | |
| 6543 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | |
| 6544 | + ); | |
| 6545 | + named_refusals += 1; | |
| 6546 | + eprintln!("seed {seed} refusal: {msg}"); | |
| 6547 | + continue; | |
| 6548 | + } | |
| 6549 | + Ok((picture, _end_cdfs)) => picture, | |
| 6550 | + }; | |
| 6551 | + let hits = crate::decode::tile_hits() - before; | |
| 6552 | + assert!( | |
| 6553 | + hits > 1, | |
| 6554 | + "{NAME}: tile_hits delta was {hits}, expected >1 -- both tile rows must actually \ | |
| 6555 | + decode, not just tile 0 (seed {seed})" | |
| 6556 | + ); | |
| 6557 | + | |
| 6558 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | |
| 6559 | + assert_eq!(picture.y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | |
| 6560 | + assert_eq!(picture.u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | |
| 6561 | + assert_eq!(picture.v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | |
| 6562 | + matched += 1; | |
| 6563 | + } | |
| 6564 | + assert!( | |
| 6565 | + matched > 0, | |
| 6566 | + "{NAME}: every attempt refused ({named_refusals} refusals); the gate never decoded \ | |
| 6567 | + a two-tile-row stream" | |
| 6568 | + ); | |
| 6569 | + eprintln!( | |
| 6570 | + "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20" | |
| 6571 | + ); | |
| 6572 | + } | |
| 6573 | + | |
| 6574 | + /// lane-tiles r8 stage 2/3: the same two-tile-row stream as the bypass | |
| 6575 | + /// gate above, this time through `decode_stream` itself -- the entry | |
| 6576 | + /// point real callers use, with the `rows > 1` refusal lifted (same | |
| 6577 | + /// commit) so this actually reaches the tile decode instead of | |
| 6578 | + /// refusing by name. Loop filter ON, no `--loopfilter-control=0`. | |
| 6579 | + #[test] | |
| 6580 | + fn a_real_aomenc_stream_with_two_tile_rows_decodes_through_decode_stream() { | |
| 6581 | + const NAME: &str = "a_real_aomenc_stream_with_two_tile_rows_decodes_through_decode_stream"; | |
| 6582 | + if !have_ffmpeg() { | |
| 6583 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 6584 | + return; | |
| 6585 | + } | |
| 6586 | + if !have_aomenc() { | |
| 6587 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 6588 | + return; | |
| 6589 | + } | |
| 6590 | + let (width, height) = (64usize, 128usize); | |
| 6391 | 6591 | let mut matched = 0u32; |
| 6392 | 6592 | let mut named_refusals = 0u32; |
| 6393 | 6593 | for attempt in 0..20u32 { |
| @@ -6419,10 +6619,9 @@ mod tests { | ||
| 6419 | 6619 | "--kf-max-dist=1000", |
| 6420 | 6620 | "--threads=1", |
| 6421 | 6621 | "--row-mt=0", |
| 6422 | - "--tile-columns=1", | |
| 6423 | - "--tile-rows=0", | |
| 6622 | + "--tile-columns=0", | |
| 6623 | + "--tile-rows=1", | |
| 6424 | 6624 | "--sb-size=64", |
| 6425 | - "--loopfilter-control=0", | |
| 6426 | 6625 | "--enable-rect-partitions=0", |
| 6427 | 6626 | "--enable-ab-partitions=0", |
| 6428 | 6627 | "--enable-1to4-partitions=0", |
| @@ -6480,7 +6679,7 @@ mod tests { | ||
| 6480 | 6679 | let hits = crate::decode::tile_hits() - before; |
| 6481 | 6680 | assert!( |
| 6482 | 6681 | hits > 1, |
| 6483 | - "{NAME}: tile_hits delta was {hits}, expected >1 -- both tiles must actually \ | |
| 6682 | + "{NAME}: tile_hits delta was {hits}, expected >1 -- both tile rows must actually \ | |
| 6484 | 6683 | decode, not just tile 0 (seed {seed})" |
| 6485 | 6684 | ); |
| 6486 | 6685 | assert_eq!(pictures.len(), 1, "{NAME}: expected exactly 1 picture (seed {seed})"); |
| @@ -6494,7 +6693,675 @@ mod tests { | ||
| 6494 | 6693 | assert!( |
| 6495 | 6694 | matched > 0, |
| 6496 | 6695 | "{NAME}: every attempt refused ({named_refusals} refusals); decode_stream never \ |
| 6497 | - decoded a two-tile-column stream" | |
| 6696 | + decoded a two-tile-row stream" | |
| 6697 | + ); | |
| 6698 | + eprintln!( | |
| 6699 | + "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20" | |
| 6700 | + ); | |
| 6701 | + } | |
| 6702 | + | |
| 6703 | + /// lane-tiles r7: the `>2 tile columns` refusal's own capability, proven | |
| 6704 | + /// separately from the 2-column gate above -- `--tile-columns=2` gives | |
| 6705 | + /// aomenc `TileCols=4` (log2), a real non-last-column right-edge case the | |
| 6706 | + /// 2-column fixture cannot exercise (there tile 1 IS the frame's right | |
| 6707 | + /// edge). 256x64 is four 64x64 superblocks wide with `--sb-size=64`, so | |
| 6708 | + /// each tile column is exactly one superblock. Loop filtering stays ON | |
| 6709 | + /// (no `--loopfilter-control=0`) to prove the same reach-bound fix also | |
| 6710 | + /// covers deblocking across an *interior* tile boundary, not just the | |
| 6711 | + /// 2-column case's boundary-that-is-also-the-frame-edge. | |
| 6712 | + #[test] | |
| 6713 | + fn a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact() { | |
| 6714 | + const NAME: &str = "a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact"; | |
| 6715 | + if !have_ffmpeg() { | |
| 6716 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 6717 | + return; | |
| 6718 | + } | |
| 6719 | + if !have_aomenc() { | |
| 6720 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 6721 | + return; | |
| 6722 | + } | |
| 6723 | + let (width, height) = (256usize, 64usize); | |
| 6724 | + let mut matched = 0u32; | |
| 6725 | + let mut named_refusals = 0u32; | |
| 6726 | + for attempt in 0..20u32 { | |
| 6727 | + let seed = 42 + attempt; | |
| 6728 | + let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | |
| 6729 | + let y4m = Command::new("ffmpeg") | |
| 6730 | + .args([ | |
| 6731 | + "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | |
| 6732 | + "yuv4mpegpipe", "-", | |
| 6733 | + ]) | |
| 6734 | + .stdin(Stdio::null()) | |
| 6735 | + .stdout(Stdio::piped()) | |
| 6736 | + .stderr(Stdio::piped()) | |
| 6737 | + .output() | |
| 6738 | + .expect("ffmpeg failed to run"); | |
| 6739 | + assert!( | |
| 6740 | + y4m.status.success(), | |
| 6741 | + "ffmpeg fixture: {}", | |
| 6742 | + String::from_utf8_lossy(&y4m.stderr) | |
| 6743 | + ); | |
| 6744 | + let mut child = Command::new(aomenc_path()) | |
| 6745 | + .args([ | |
| 6746 | + "--codec=av1", | |
| 6747 | + "--passes=1", | |
| 6748 | + "--end-usage=q", | |
| 6749 | + "--cq-level=45", | |
| 6750 | + "--cpu-used=0", | |
| 6751 | + "--limit=1", | |
| 6752 | + "--kf-max-dist=1000", | |
| 6753 | + "--threads=1", | |
| 6754 | + "--row-mt=0", | |
| 6755 | + "--tile-columns=2", | |
| 6756 | + "--tile-rows=0", | |
| 6757 | + "--sb-size=64", | |
| 6758 | + "--enable-rect-partitions=0", | |
| 6759 | + "--enable-ab-partitions=0", | |
| 6760 | + "--enable-1to4-partitions=0", | |
| 6761 | + "--enable-filter-intra=0", | |
| 6762 | + "--enable-smooth-intra=0", | |
| 6763 | + "--enable-paeth-intra=0", | |
| 6764 | + "--enable-directional-intra=0", | |
| 6765 | + "--enable-angle-delta=0", | |
| 6766 | + "--enable-tx-size-search=0", | |
| 6767 | + "--enable-cdef=0", | |
| 6768 | + "--enable-restoration=0", | |
| 6769 | + "--max-partition-size=32", | |
| 6770 | + "--min-partition-size=32", | |
| 6771 | + "--enable-palette=0", | |
| 6772 | + "--enable-intrabc=0", | |
| 6773 | + "--enable-cfl-intra=0", | |
| 6774 | + "--obu", | |
| 6775 | + "-o", | |
| 6776 | + "-", | |
| 6777 | + "-", | |
| 6778 | + ]) | |
| 6779 | + .stdin(Stdio::piped()) | |
| 6780 | + .stdout(Stdio::piped()) | |
| 6781 | + .stderr(Stdio::piped()) | |
| 6782 | + .spawn() | |
| 6783 | + .expect("aomenc failed to start"); | |
| 6784 | + child | |
| 6785 | + .stdin | |
| 6786 | + .take() | |
| 6787 | + .expect("aomenc stdin") | |
| 6788 | + .write_all(&y4m.stdout) | |
| 6789 | + .expect("writing y4m to aomenc"); | |
| 6790 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 6791 | + assert!( | |
| 6792 | + out.status.success(), | |
| 6793 | + "aomenc refused the fixture: {}", | |
| 6794 | + String::from_utf8_lossy(&out.stderr) | |
| 6795 | + ); | |
| 6796 | + let stream = out.stdout; | |
| 6797 | + | |
| 6798 | + let mut parser = Av1Parser::new(); | |
| 6799 | + let mut pos = 0usize; | |
| 6800 | + let mut frame = None; | |
| 6801 | + while pos < stream.len() { | |
| 6802 | + let obu_offset = pos; | |
| 6803 | + let obu = parser.parse_obu(&stream[pos..]).unwrap(); | |
| 6804 | + pos += obu.total_size; | |
| 6805 | + if let ObuKind::Frame(header, tiles) = obu.kind { | |
| 6806 | + frame = Some((header, tiles, obu_offset)); | |
| 6807 | + break; | |
| 6808 | + } | |
| 6809 | + } | |
| 6810 | + let (header, tiles, obu_offset) = frame.expect("stream has a Frame OBU"); | |
| 6811 | + assert!( | |
| 6812 | + header.tile_info.cols > 2, | |
| 6813 | + "{NAME}: aomenc did not actually split into >2 tile columns (cols={}, seed {seed})", | |
| 6814 | + header.tile_info.cols | |
| 6815 | + ); | |
| 6816 | + assert_eq!( | |
| 6817 | + tiles.len(), | |
| 6818 | + header.tile_info.cols as usize, | |
| 6819 | + "{NAME}: expected one tile per column (seed {seed})" | |
| 6820 | + ); | |
| 6821 | + let tile_bufs: Vec<&[u8]> = tiles | |
| 6822 | + .iter() | |
| 6823 | + .map(|t| &stream[obu_offset + t.offset..obu_offset + t.offset + t.size]) | |
| 6824 | + .collect(); | |
| 6825 | + | |
| 6826 | + let enable_filter_intra = parser | |
| 6827 | + .sequence_header() | |
| 6828 | + .is_some_and(|seq| seq.enable_filter_intra); | |
| 6829 | + let enable_edge_filter = parser | |
| 6830 | + .sequence_header() | |
| 6831 | + .is_some_and(|seq| seq.enable_intra_edge_filter); | |
| 6832 | + | |
| 6833 | + let before = crate::decode::tile_hits(); | |
| 6834 | + let picture = match decode_key_frame_tile_with_cdfs( | |
| 6835 | + &tile_bufs, | |
| 6836 | + &header.tile_info, | |
| 6837 | + header.mi_cols, | |
| 6838 | + header.mi_rows, | |
| 6839 | + header.quantization.base_q_idx, | |
| 6840 | + header.frame_width, | |
| 6841 | + header.frame_height, | |
| 6842 | + enable_filter_intra, | |
| 6843 | + enable_edge_filter, | |
| 6844 | + &header.cdef, | |
| 6845 | + &header.loop_filter, | |
| 6846 | + None, | |
| 6847 | + header.tx_mode == TxMode::Select, | |
| 6848 | + header.reduced_tx_set, | |
| 6849 | + header.allow_screen_content_tools, | |
| 6850 | + header.allow_intrabc, | |
| 6851 | + ) { | |
| 6852 | + Err(e) => { | |
| 6853 | + let msg = e.to_string(); | |
| 6854 | + assert!( | |
| 6855 | + msg.contains("unsupported"), | |
| 6856 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | |
| 6857 | + ); | |
| 6858 | + named_refusals += 1; | |
| 6859 | + eprintln!("seed {seed} refusal: {msg}"); | |
| 6860 | + continue; | |
| 6861 | + } | |
| 6862 | + Ok((picture, _end_cdfs)) => picture, | |
| 6863 | + }; | |
| 6864 | + let hits = crate::decode::tile_hits() - before; | |
| 6865 | + assert!( | |
| 6866 | + hits > 2, | |
| 6867 | + "{NAME}: tile_hits delta was {hits}, expected >2 -- all four tiles must actually \ | |
| 6868 | + decode, not just a subset (seed {seed})" | |
| 6869 | + ); | |
| 6870 | + | |
| 6871 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | |
| 6872 | + assert_eq!(picture.y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | |
| 6873 | + assert_eq!(picture.u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | |
| 6874 | + assert_eq!(picture.v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | |
| 6875 | + matched += 1; | |
| 6876 | + } | |
| 6877 | + assert!( | |
| 6878 | + matched > 0, | |
| 6879 | + "{NAME}: every attempt refused ({named_refusals} refusals); the gate never decoded \ | |
| 6880 | + a four-tile-column stream" | |
| 6881 | + ); | |
| 6882 | + eprintln!( | |
| 6883 | + "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20" | |
| 6884 | + ); | |
| 6885 | + } | |
| 6886 | + | |
| 6887 | + /// lane-tiles r8: the tile-*row* analogue of the four-tile-column gate | |
| 6888 | + /// above -- `--tile-rows=2` gives aomenc `TileRows=4` (log2; uniform | |
| 6889 | + /// tile spacing is always a power of two, so this is the smallest count | |
| 6890 | + /// that has an interior row neither the top nor bottom frame edge, | |
| 6891 | + /// mirroring why the column gate needed 4 columns rather than 3). 64x256 | |
| 6892 | + /// is four 64x64 superblocks tall with `--sb-size=64`, one per tile row. | |
| 6893 | + /// Loop filter ON, run through `decode_stream` itself since the | |
| 6894 | + /// `rows > 1` refusal is already lifted by this commit. Also settles a | |
| 6895 | + /// stale documentation claim found while writing this gate: the old | |
| 6896 | + /// comment above `decode_stream`'s multi-tile block said | |
| 6897 | + /// `context_update_tile_id != 0` was refused "further down" -- no such | |
| 6898 | + /// refusal exists (`decode.rs` reads `tile_info.context_update_tile_id` | |
| 6899 | + /// generically, never hardcoded to tile 0), and this fixture's own | |
| 6900 | + /// aomenc runs pick 1/2/3 as often as 0 (RD-driven tile-size heuristic), | |
| 6901 | + /// all 20/20 pixel-exact -- so the capability was already there, | |
| 6902 | + /// undocumented and unproven; hard-asserted here so the proof can't go | |
| 6903 | + /// unnoticed if it stops firing. | |
| 6904 | + #[test] | |
| 6905 | + fn a_real_aomenc_stream_with_four_tile_rows_decodes_pixel_exact() { | |
| 6906 | + const NAME: &str = "a_real_aomenc_stream_with_four_tile_rows_decodes_pixel_exact"; | |
| 6907 | + if !have_ffmpeg() { | |
| 6908 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 6909 | + return; | |
| 6910 | + } | |
| 6911 | + if !have_aomenc() { | |
| 6912 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 6913 | + return; | |
| 6914 | + } | |
| 6915 | + let (width, height) = (64usize, 256usize); | |
| 6916 | + let mut matched = 0u32; | |
| 6917 | + let mut named_refusals = 0u32; | |
| 6918 | + let mut saw_nonzero_context_update_tile_id = false; | |
| 6919 | + for attempt in 0..20u32 { | |
| 6920 | + let seed = 42 + attempt; | |
| 6921 | + let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | |
| 6922 | + let y4m = Command::new("ffmpeg") | |
| 6923 | + .args([ | |
| 6924 | + "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | |
| 6925 | + "yuv4mpegpipe", "-", | |
| 6926 | + ]) | |
| 6927 | + .stdin(Stdio::null()) | |
| 6928 | + .stdout(Stdio::piped()) | |
| 6929 | + .stderr(Stdio::piped()) | |
| 6930 | + .output() | |
| 6931 | + .expect("ffmpeg failed to run"); | |
| 6932 | + assert!( | |
| 6933 | + y4m.status.success(), | |
| 6934 | + "ffmpeg fixture: {}", | |
| 6935 | + String::from_utf8_lossy(&y4m.stderr) | |
| 6936 | + ); | |
| 6937 | + let mut child = Command::new(aomenc_path()) | |
| 6938 | + .args([ | |
| 6939 | + "--codec=av1", | |
| 6940 | + "--passes=1", | |
| 6941 | + "--end-usage=q", | |
| 6942 | + "--cq-level=45", | |
| 6943 | + "--cpu-used=0", | |
| 6944 | + "--limit=1", | |
| 6945 | + "--kf-max-dist=1000", | |
| 6946 | + "--threads=1", | |
| 6947 | + "--row-mt=0", | |
| 6948 | + "--tile-columns=0", | |
| 6949 | + "--tile-rows=2", | |
| 6950 | + "--sb-size=64", | |
| 6951 | + "--enable-rect-partitions=0", | |
| 6952 | + "--enable-ab-partitions=0", | |
| 6953 | + "--enable-1to4-partitions=0", | |
| 6954 | + "--enable-filter-intra=0", | |
| 6955 | + "--enable-smooth-intra=0", | |
| 6956 | + "--enable-paeth-intra=0", | |
| 6957 | + "--enable-directional-intra=0", | |
| 6958 | + "--enable-angle-delta=0", | |
| 6959 | + "--enable-tx-size-search=0", | |
| 6960 | + "--enable-cdef=0", | |
| 6961 | + "--enable-restoration=0", | |
| 6962 | + "--max-partition-size=32", | |
| 6963 | + "--min-partition-size=32", | |
| 6964 | + "--enable-palette=0", | |
| 6965 | + "--enable-intrabc=0", | |
| 6966 | + "--enable-cfl-intra=0", | |
| 6967 | + "--obu", | |
| 6968 | + "-o", | |
| 6969 | + "-", | |
| 6970 | + "-", | |
| 6971 | + ]) | |
| 6972 | + .stdin(Stdio::piped()) | |
| 6973 | + .stdout(Stdio::piped()) | |
| 6974 | + .stderr(Stdio::piped()) | |
| 6975 | + .spawn() | |
| 6976 | + .expect("aomenc failed to start"); | |
| 6977 | + child | |
| 6978 | + .stdin | |
| 6979 | + .take() | |
| 6980 | + .expect("aomenc stdin") | |
| 6981 | + .write_all(&y4m.stdout) | |
| 6982 | + .expect("writing y4m to aomenc"); | |
| 6983 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 6984 | + assert!( | |
| 6985 | + out.status.success(), | |
| 6986 | + "aomenc refused the fixture: {}", | |
| 6987 | + String::from_utf8_lossy(&out.stderr) | |
| 6988 | + ); | |
| 6989 | + let stream = out.stdout; | |
| 6990 | + | |
| 6991 | + let mut parser = Av1Parser::new(); | |
| 6992 | + let mut pos = 0usize; | |
| 6993 | + let mut rows_seen = 0u32; | |
| 6994 | + while pos < stream.len() { | |
| 6995 | + let obu = parser.parse_obu(&stream[pos..]).unwrap(); | |
| 6996 | + pos += obu.total_size; | |
| 6997 | + if let ObuKind::Frame(header, _) = &obu.kind { | |
| 6998 | + rows_seen = header.tile_info.rows; | |
| 6999 | + if header.tile_info.context_update_tile_id != 0 { | |
| 7000 | + saw_nonzero_context_update_tile_id = true; | |
| 7001 | + } | |
| 7002 | + } | |
| 7003 | + } | |
| 7004 | + assert!( | |
| 7005 | + rows_seen > 2, | |
| 7006 | + "{NAME}: aomenc did not actually split into >2 tile rows (rows={rows_seen}, seed {seed})" | |
| 7007 | + ); | |
| 7008 | + | |
| 7009 | + let before = crate::decode::tile_hits(); | |
| 7010 | + let pictures = match decode_stream(&stream) { | |
| 7011 | + Err(e) => { | |
| 7012 | + let msg = e.to_string(); | |
| 7013 | + assert!( | |
| 7014 | + msg.contains("unsupported"), | |
| 7015 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | |
| 7016 | + ); | |
| 7017 | + named_refusals += 1; | |
| 7018 | + eprintln!("seed {seed} refusal: {msg}"); | |
| 7019 | + continue; | |
| 7020 | + } | |
| 7021 | + Ok(pictures) => pictures, | |
| 7022 | + }; | |
| 7023 | + let hits = crate::decode::tile_hits() - before; | |
| 7024 | + assert!( | |
| 7025 | + hits > 2, | |
| 7026 | + "{NAME}: tile_hits delta was {hits}, expected >2 -- all four tile rows must \ | |
| 7027 | + actually decode, not just a subset (seed {seed})" | |
| 7028 | + ); | |
| 7029 | + assert_eq!(pictures.len(), 1, "{NAME}: expected exactly 1 picture (seed {seed})"); | |
| 7030 | + | |
| 7031 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | |
| 7032 | + assert_eq!(pictures[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | |
| 7033 | + assert_eq!(pictures[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | |
| 7034 | + assert_eq!(pictures[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | |
| 7035 | + matched += 1; | |
| 7036 | + } | |
| 7037 | + assert!( | |
| 7038 | + matched > 0, | |
| 7039 | + "{NAME}: every attempt refused ({named_refusals} refusals); the gate never decoded \ | |
| 7040 | + a four-tile-row stream" | |
| 7041 | + ); | |
| 7042 | + assert!( | |
| 7043 | + saw_nonzero_context_update_tile_id, | |
| 7044 | + "{NAME}: every attempt named context_update_tile_id=0 -- this sweep proves nothing \ | |
| 7045 | + about the != 0 case (see the stale-refusal note above `decode_stream`'s multi-tile \ | |
| 7046 | + comment: aomenc's own tile-size heuristic picks it, seen 1/2/3 live in a prior probe \ | |
| 7047 | + run of this exact fixture, so a 20-attempt window not seeing it is the gate's own bug)" | |
| 7048 | + ); | |
| 7049 | + eprintln!( | |
| 7050 | + "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20" | |
| 7051 | + ); | |
| 7052 | + } | |
| 7053 | + | |
| 7054 | + /// lane-tiles r4/r7: the same real two-tile-column stream as the | |
| 7055 | + /// bypass gate above, this time run through `decode_stream` itself -- | |
| 7056 | + /// the entry point real callers use. Proves the `cols > 1` refusal is | |
| 7057 | + /// actually lifted (not just that the underlying per-tile loop works) | |
| 7058 | + /// for a key frame; `--loopfilter-control=0` stays here for its own | |
| 7059 | + /// sake (isolating the entry-point wiring from deblocking), but r7's | |
| 7060 | + /// `a_real_aomenc_stream_with_four_tile_columns_decodes_pixel_exact` | |
| 7061 | + /// bypass gate now proves loop filtering ON across a tile boundary too, | |
| 7062 | + /// and the `cols > 1 && loop_filter_on` / `cols > 2` refusals this | |
| 7063 | + /// comment used to describe are gone from `decode_stream`. | |
| 7064 | + #[test] | |
| 7065 | + fn a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream() { | |
| 7066 | + const NAME: &str = "a_real_aomenc_stream_with_two_tile_columns_decodes_through_decode_stream"; | |
| 7067 | + if !have_ffmpeg() { | |
| 7068 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 7069 | + return; | |
| 7070 | + } | |
| 7071 | + if !have_aomenc() { | |
| 7072 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 7073 | + return; | |
| 7074 | + } | |
| 7075 | + let (width, height) = (128usize, 64usize); | |
| 7076 | + let mut matched = 0u32; | |
| 7077 | + let mut named_refusals = 0u32; | |
| 7078 | + for attempt in 0..20u32 { | |
| 7079 | + let seed = 42 + attempt; | |
| 7080 | + let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | |
| 7081 | + let y4m = Command::new("ffmpeg") | |
| 7082 | + .args([ | |
| 7083 | + "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | |
| 7084 | + "yuv4mpegpipe", "-", | |
| 7085 | + ]) | |
| 7086 | + .stdin(Stdio::null()) | |
| 7087 | + .stdout(Stdio::piped()) | |
| 7088 | + .stderr(Stdio::piped()) | |
| 7089 | + .output() | |
| 7090 | + .expect("ffmpeg failed to run"); | |
| 7091 | + assert!( | |
| 7092 | + y4m.status.success(), | |
| 7093 | + "ffmpeg fixture: {}", | |
| 7094 | + String::from_utf8_lossy(&y4m.stderr) | |
| 7095 | + ); | |
| 7096 | + let mut child = Command::new(aomenc_path()) | |
| 7097 | + .args([ | |
| 7098 | + "--codec=av1", | |
| 7099 | + "--passes=1", | |
| 7100 | + "--end-usage=q", | |
| 7101 | + "--cq-level=45", | |
| 7102 | + "--cpu-used=0", | |
| 7103 | + "--limit=1", | |
| 7104 | + "--kf-max-dist=1000", | |
| 7105 | + "--threads=1", | |
| 7106 | + "--row-mt=0", | |
| 7107 | + "--tile-columns=1", | |
| 7108 | + "--tile-rows=0", | |
| 7109 | + "--sb-size=64", | |
| 7110 | + "--loopfilter-control=0", | |
| 7111 | + "--enable-rect-partitions=0", | |
| 7112 | + "--enable-ab-partitions=0", | |
| 7113 | + "--enable-1to4-partitions=0", | |
| 7114 | + "--enable-filter-intra=0", | |
| 7115 | + "--enable-smooth-intra=0", | |
| 7116 | + "--enable-paeth-intra=0", | |
| 7117 | + "--enable-directional-intra=0", | |
| 7118 | + "--enable-angle-delta=0", | |
| 7119 | + "--enable-tx-size-search=0", | |
| 7120 | + "--enable-cdef=0", | |
| 7121 | + "--enable-restoration=0", | |
| 7122 | + "--max-partition-size=32", | |
| 7123 | + "--min-partition-size=32", | |
| 7124 | + "--enable-palette=0", | |
| 7125 | + "--enable-intrabc=0", | |
| 7126 | + "--enable-cfl-intra=0", | |
| 7127 | + "--obu", | |
| 7128 | + "-o", | |
| 7129 | + "-", | |
| 7130 | + "-", | |
| 7131 | + ]) | |
| 7132 | + .stdin(Stdio::piped()) | |
| 7133 | + .stdout(Stdio::piped()) | |
| 7134 | + .stderr(Stdio::piped()) | |
| 7135 | + .spawn() | |
| 7136 | + .expect("aomenc failed to start"); | |
| 7137 | + child | |
| 7138 | + .stdin | |
| 7139 | + .take() | |
| 7140 | + .expect("aomenc stdin") | |
| 7141 | + .write_all(&y4m.stdout) | |
| 7142 | + .expect("writing y4m to aomenc"); | |
| 7143 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 7144 | + assert!( | |
| 7145 | + out.status.success(), | |
| 7146 | + "aomenc refused the fixture: {}", | |
| 7147 | + String::from_utf8_lossy(&out.stderr) | |
| 7148 | + ); | |
| 7149 | + let stream = out.stdout; | |
| 7150 | + | |
| 7151 | + let before = crate::decode::tile_hits(); | |
| 7152 | + let pictures = match decode_stream(&stream) { | |
| 7153 | + Err(e) => { | |
| 7154 | + let msg = e.to_string(); | |
| 7155 | + assert!( | |
| 7156 | + msg.contains("unsupported"), | |
| 7157 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | |
| 7158 | + ); | |
| 7159 | + named_refusals += 1; | |
| 7160 | + eprintln!("seed {seed} refusal: {msg}"); | |
| 7161 | + continue; | |
| 7162 | + } | |
| 7163 | + Ok(pictures) => pictures, | |
| 7164 | + }; | |
| 7165 | + let hits = crate::decode::tile_hits() - before; | |
| 7166 | + assert!( | |
| 7167 | + hits > 1, | |
| 7168 | + "{NAME}: tile_hits delta was {hits}, expected >1 -- both tiles must actually \ | |
| 7169 | + decode, not just tile 0 (seed {seed})" | |
| 7170 | + ); | |
| 7171 | + assert_eq!(pictures.len(), 1, "{NAME}: expected exactly 1 picture (seed {seed})"); | |
| 7172 | + | |
| 7173 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | |
| 7174 | + assert_eq!(pictures[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | |
| 7175 | + assert_eq!(pictures[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | |
| 7176 | + assert_eq!(pictures[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | |
| 7177 | + matched += 1; | |
| 7178 | + } | |
| 7179 | + assert!( | |
| 7180 | + matched > 0, | |
| 7181 | + "{NAME}: every attempt refused ({named_refusals} refusals); decode_stream never \ | |
| 7182 | + decoded a two-tile-column stream" | |
| 7183 | + ); | |
| 7184 | + eprintln!( | |
| 7185 | + "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20" | |
| 7186 | + ); | |
| 7187 | + } | |
| 7188 | + | |
| 7189 | + /// lane-tiles r7: the gate stage 2 (r6, commit 8899fc1) shipped without | |
| 7190 | + /// -- a real >1-tile-column stream with a genuine INTER frame (not just | |
| 7191 | + /// the key-frame-only two-column gate above), decoded through | |
| 7192 | + /// `decode_stream` itself. Same recipe as the key-frame gate | |
| 7193 | + /// (`--sb-size=64`, `--tile-columns=1`, `--loopfilter-control=0`, the | |
| 7194 | + /// same feature-disable envelope so the gate isolates the tile loop, not | |
| 7195 | + /// an unrelated unimplemented mode) plus `--limit=2 --kf-max-dist=1000` | |
| 7196 | + /// so frame 1 is a real inter frame, and `gradients_source`'s default | |
| 7197 | + /// `speed=0.01` rotation (undisturbed -- not overridden by the tail) | |
| 7198 | + /// gives it genuine motion against frame 0, so `decode_inter_frame_tile_ | |
| 7199 | + /// with_cdfs`'s new per-tile loop and `MiGrid`'s per-tile bound actually | |
| 7200 | + /// have to walk a live MV stack across the tile-column boundary, not | |
| 7201 | + /// just replay skip/zero-mv blocks. Bounded with `duration=0.08` (2 | |
| 7202 | + /// frames at rate=25) per the class in ledger | |
| 7203 | + /// `refusal-claim-disproved-by-its-own-gate`/`gate-loader-slurps-whole- | |
| 7204 | + /// file` (never leave an ffmpeg/lavfi generate unbounded). | |
| 7205 | + #[test] | |
| 7206 | + fn a_real_aomenc_stream_with_two_tile_columns_and_an_inter_frame_decodes_pixel_exact() { | |
| 7207 | + const NAME: &str = | |
| 7208 | + "a_real_aomenc_stream_with_two_tile_columns_and_an_inter_frame_decodes_pixel_exact"; | |
| 7209 | + if !have_ffmpeg() { | |
| 7210 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 7211 | + return; | |
| 7212 | + } | |
| 7213 | + if !have_aomenc() { | |
| 7214 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 7215 | + return; | |
| 7216 | + } | |
| 7217 | + let (width, height) = (128usize, 64usize); | |
| 7218 | + let frames = 2usize; | |
| 7219 | + let mut matched = 0u32; | |
| 7220 | + let mut named_refusals = 0u32; | |
| 7221 | + for attempt in 0..20u32 { | |
| 7222 | + let seed = 42 + attempt; | |
| 7223 | + let source = gradients_source(seed, width, height, "duration=0.08:rate=25"); | |
| 7224 | + let y4m = Command::new("ffmpeg") | |
| 7225 | + .args([ | |
| 7226 | + "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | |
| 7227 | + "yuv4mpegpipe", "-", | |
| 7228 | + ]) | |
| 7229 | + .stdin(Stdio::null()) | |
| 7230 | + .stdout(Stdio::piped()) | |
| 7231 | + .stderr(Stdio::piped()) | |
| 7232 | + .output() | |
| 7233 | + .expect("ffmpeg failed to run"); | |
| 7234 | + assert!( | |
| 7235 | + y4m.status.success(), | |
| 7236 | + "ffmpeg fixture: {}", | |
| 7237 | + String::from_utf8_lossy(&y4m.stderr) | |
| 7238 | + ); | |
| 7239 | + let mut child = Command::new(aomenc_path()) | |
| 7240 | + .args([ | |
| 7241 | + "--codec=av1", | |
| 7242 | + "--passes=1", | |
| 7243 | + "--end-usage=q", | |
| 7244 | + "--cq-level=45", | |
| 7245 | + "--cpu-used=0", | |
| 7246 | + &format!("--limit={frames}"), | |
| 7247 | + "--kf-max-dist=1000", | |
| 7248 | + "--lag-in-frames=0", | |
| 7249 | + "--auto-alt-ref=0", | |
| 7250 | + "--threads=1", | |
| 7251 | + "--row-mt=0", | |
| 7252 | + "--tile-columns=1", | |
| 7253 | + "--tile-rows=0", | |
| 7254 | + "--sb-size=64", | |
| 7255 | + "--loopfilter-control=0", | |
| 7256 | + "--max-reference-frames=3", | |
| 7257 | + "--reduced-reference-set=1", | |
| 7258 | + "--enable-warped-motion=0", | |
| 7259 | + "--enable-obmc=0", | |
| 7260 | + "--enable-masked-comp=0", | |
| 7261 | + "--enable-interintra-comp=0", | |
| 7262 | + "--enable-dist-wtd-comp=0", | |
| 7263 | + "--enable-diff-wtd-comp=0", | |
| 7264 | + "--enable-onesided-comp=0", | |
| 7265 | + "--enable-interintra-wedge=0", | |
| 7266 | + "--enable-smooth-interintra=0", | |
| 7267 | + "--enable-ref-frame-mvs=0", | |
| 7268 | + "--enable-rect-partitions=0", | |
| 7269 | + "--enable-ab-partitions=0", | |
| 7270 | + "--enable-1to4-partitions=0", | |
| 7271 | + "--enable-filter-intra=0", | |
| 7272 | + "--enable-smooth-intra=0", | |
| 7273 | + "--enable-paeth-intra=0", | |
| 7274 | + "--enable-directional-intra=0", | |
| 7275 | + "--enable-angle-delta=0", | |
| 7276 | + "--enable-tx-size-search=0", | |
| 7277 | + "--enable-cdef=0", | |
| 7278 | + "--enable-restoration=0", | |
| 7279 | + "--max-partition-size=32", | |
| 7280 | + "--min-partition-size=32", | |
| 7281 | + "--enable-palette=0", | |
| 7282 | + "--enable-intrabc=0", | |
| 7283 | + "--enable-cfl-intra=0", | |
| 7284 | + "--obu", | |
| 7285 | + "-o", | |
| 7286 | + "-", | |
| 7287 | + "-", | |
| 7288 | + ]) | |
| 7289 | + .stdin(Stdio::piped()) | |
| 7290 | + .stdout(Stdio::piped()) | |
| 7291 | + .stderr(Stdio::piped()) | |
| 7292 | + .spawn() | |
| 7293 | + .expect("aomenc failed to start"); | |
| 7294 | + child | |
| 7295 | + .stdin | |
| 7296 | + .take() | |
| 7297 | + .expect("aomenc stdin") | |
| 7298 | + .write_all(&y4m.stdout) | |
| 7299 | + .expect("writing y4m to aomenc"); | |
| 7300 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 7301 | + assert!( | |
| 7302 | + out.status.success(), | |
| 7303 | + "aomenc refused the fixture: {}", | |
| 7304 | + String::from_utf8_lossy(&out.stderr) | |
| 7305 | + ); | |
| 7306 | + let stream = out.stdout; | |
| 7307 | + | |
| 7308 | + // Confirm aomenc actually split into >1 tile column and that | |
| 7309 | + // frame 1 is a real inter frame before trusting a pixel match -- | |
| 7310 | + // otherwise a match could mean "tiles collapsed to 1" or "frame | |
| 7311 | + // 1 fell back to key", not "the inter tile loop ran". | |
| 7312 | + let mut parser = Av1Parser::new(); | |
| 7313 | + let mut pos = 0usize; | |
| 7314 | + let mut saw_multi_tile_inter = false; | |
| 7315 | + while pos < stream.len() { | |
| 7316 | + let obu = parser.parse_obu(&stream[pos..]).unwrap(); | |
| 7317 | + pos += obu.total_size; | |
| 7318 | + if let ObuKind::Frame(header, _) = obu.kind | |
| 7319 | + && header.frame_type != FrameType::Key | |
| 7320 | + && header.tile_info.cols > 1 | |
| 7321 | + { | |
| 7322 | + saw_multi_tile_inter = true; | |
| 7323 | + } | |
| 7324 | + } | |
| 7325 | + assert!( | |
| 7326 | + saw_multi_tile_inter, | |
| 7327 | + "{NAME}: seed {seed} never produced a >1-tile-column inter frame (aomenc \ | |
| 7328 | + collapsed tiling or coded frame 1 as key)" | |
| 7329 | + ); | |
| 7330 | + | |
| 7331 | + let before = crate::decode::tile_hits(); | |
| 7332 | + let pictures = match decode_stream(&stream) { | |
| 7333 | + Err(e) => { | |
| 7334 | + let msg = e.to_string(); | |
| 7335 | + assert!( | |
| 7336 | + msg.contains("unsupported"), | |
| 7337 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | |
| 7338 | + ); | |
| 7339 | + named_refusals += 1; | |
| 7340 | + eprintln!("seed {seed} refusal: {msg}"); | |
| 7341 | + continue; | |
| 7342 | + } | |
| 7343 | + Ok(pictures) => pictures, | |
| 7344 | + }; | |
| 7345 | + let hits = crate::decode::tile_hits() - before; | |
| 7346 | + assert!( | |
| 7347 | + hits > frames, | |
| 7348 | + "{NAME}: tile_hits delta was {hits}, expected > {frames} -- both tiles of both \ | |
| 7349 | + frames must actually decode (seed {seed})" | |
| 7350 | + ); | |
| 7351 | + assert_eq!(pictures.len(), frames, "{NAME}: expected {frames} pictures (seed {seed})"); | |
| 7352 | + | |
| 7353 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frames); | |
| 7354 | + for (i, (got, want)) in pictures.iter().zip(&ffmpeg_frames).enumerate() { | |
| 7355 | + assert_eq!(got.y, want.y, "{NAME}: seed {seed} frame {i} luma vs ffmpeg"); | |
| 7356 | + assert_eq!(got.u, want.u, "{NAME}: seed {seed} frame {i} U vs ffmpeg"); | |
| 7357 | + assert_eq!(got.v, want.v, "{NAME}: seed {seed} frame {i} V vs ffmpeg"); | |
| 7358 | + } | |
| 7359 | + matched += 1; | |
| 7360 | + } | |
| 7361 | + assert!( | |
| 7362 | + matched > 0, | |
| 7363 | + "{NAME}: every attempt refused ({named_refusals} refusals); decode_stream never \ | |
| 7364 | + decoded a two-tile-column inter frame" | |
| 6498 | 7365 | ); |
| 6499 | 7366 | eprintln!( |
| 6500 | 7367 | "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20" |
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. |
lanes/tiles-r8.charter.mdadded+48 -0
| @@ -0,0 +1,48 @@ | ||
| 1 | +# lane-tiles r8 — tile rows | |
| 2 | + | |
| 3 | +At 5255492. r7 is MERGED into main (93d9510); main is at 92d8beb or later. | |
| 4 | +Read `lanes/tiles-r7.report.md` first. Start with `git merge main` — main has | |
| 5 | +since landed a `bit_depth != 8` refusal, three reworded partition refusals and | |
| 6 | +a dead-binding cleanup in `decode_stream`; resolve, suite green, commit, and | |
| 7 | +only then start new work. | |
| 8 | + | |
| 9 | +## The round: tile ROWS | |
| 10 | +`tile_info.rows > 1` is still refused in `decode_stream`, correctly and with no | |
| 11 | +false claim attached. Close it the exact way r7 closed columns, in this order — | |
| 12 | +each step committed before the next begins: | |
| 13 | + | |
| 14 | +1. **Bypass gate first.** A gate that drives the tile decode directly, below | |
| 15 | + `decode_stream`, so the refusal cannot short-circuit the code the gate is | |
| 16 | + supposed to be measuring. That is class [[refusal-short-circuits-its-own-code]] | |
| 17 | + and it cost this project a round already: lane-lr's report claimed symbols | |
| 18 | + were read while its own counter said 0/40, because the refusal ran first. | |
| 19 | +2. **`decode_stream`-level gate**, pixel-exact vs ffmpeg, loop filter ON. | |
| 20 | + Deblocking crosses tile ROW boundaries by spec default just as it crosses | |
| 21 | + column ones — do not add a `--loopfilter-control=0` bypass, and if the | |
| 22 | + horizontal boundary fails, that is the round's real finding. | |
| 23 | +3. **Then, and only then, lift the refusal**, and update | |
| 24 | + `refusal_inventory.rs`'s pinned list in the same commit. | |
| 25 | + | |
| 26 | +Recipe: `--tile-rows=1` (→ TileRows=2) mirroring r7's `--tile-columns`, and a | |
| 27 | +fixture at least 128 px tall so two rows of 64px superblocks actually exist. | |
| 28 | +Verify from a header parse that aomenc really emitted TileRows=2 before | |
| 29 | +trusting any pixel match — r7 did this and it is why its numbers hold. Hard- | |
| 30 | +assert `tile_hits`: r7 found `decode_inter_frame_tile_with_cdfs` never | |
| 31 | +incremented `TILE_HITS`, so an assert there was vacuously blind. Check the | |
| 32 | +row path has the same increment before you rely on it. | |
| 33 | + | |
| 34 | +A branch that lifts a refusal without a gate does not merge to main. | |
| 35 | + | |
| 36 | +## If turns remain | |
| 37 | +`context_update_tile_id != 0`, several tile-group OBUs per frame, non-uniform | |
| 38 | +tile spacing — in that order. Each is a refusal today; each needs a gate before | |
| 39 | +a lift. | |
| 40 | + | |
| 41 | +Hard rules: `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-tiles`; foreground | |
| 42 | +`nice -n 19 cargo ... -j4`; every `cargo test` a timeout >= 600000 ms; fixtures | |
| 43 | +through `gradients_source(seed, w, h, tail)` and every ffmpeg generate bounded | |
| 44 | +with `-t`; `EC_AV1_REQUIRE_AOMENC=1`; aomenc `--threads=1 --row-mt=0 | |
| 45 | +--sb-size=64` (this decoder hardcodes 64px superblocks). Sibling worktrees have | |
| 46 | +live agents — never build in or edit them. Never push, never merge into main. | |
| 47 | +75-turn cap, does not reset: COMMIT AT EVERY GREEN STEP. End with | |
| 48 | +`lanes/tiles-r8.report.md`, VERDICT on line 1. |
lanes/tiles-r8.report.mdadded+43 -0
| @@ -0,0 +1,43 @@ | ||
| 1 | +VERDICT: PASS -- merged main, tile-rows refusal closed the r7 way (bypass gate, decode_stream gate loop-filter ON, then lift), plus a bonus finding: context_update_tile_id != 0 was already working and undocumented, now proven and correctly described. All scoped suite green throughout. | |
| 2 | + | |
| 3 | +## Merge | |
| 4 | +`git merge main` at d145dea (main was at 92d8beb, a fast-forwardable dead-binding cleanup on top of the already-merged lane-tiles history plus the `bit_depth != 8` refusal from a sibling lane) resolved with no conflicts (`ort` strategy, clean). Suite (`tile mvstack refusal_inventory gate_coverage`, `EC_AV1_REQUIRE_AOMENC=1`) 80/0 immediately after. Committed ef641d9. | |
| 5 | + | |
| 6 | +## Stage 1 -- bypass gate (tile rows, below decode_stream) | |
| 7 | +`a_real_aomenc_stream_with_two_tile_rows_decodes_pixel_exact` (`crates/ec-av1/src/stream.rs`): 64x128, `--tile-rows=1` (`TileRows=2`), `--sb-size=64`, calls `decode_key_frame_tile_with_cdfs` directly since `decode_stream` still refused `tile_info.rows > 1` at this point. Loop filter left ON (no `--loopfilter-control=0`) per the charter -- `deblock_plane` runs once over the whole decoded picture with no tile-axis distinction, and the per-tile loop's row math (`tile_num / tile_info.cols`, `mi_row_starts`, `set_tile_origin`'s `y0`/`y1`) is exactly symmetric with the column path r7 already proved. 20/20 pixel-exact vs ffmpeg, 0 named refusals, hard `tile_hits > 1` assert. Confirmed via header parse that aomenc really emitted `rows=2` before trusting any match. | |
| 8 | + | |
| 9 | +Committed d6b4d51. | |
| 10 | + | |
| 11 | +## Stage 2/3 -- decode_stream gate + refusal lift (same commit) | |
| 12 | +Lifted `decode_stream`'s `tile_info.rows > 1` refusal and, in the same commit, added `a_real_aomenc_stream_with_two_tile_rows_decodes_through_decode_stream` (same fixture, calls `decode_stream` itself, hard `tile_hits > 1` assert) -- 20/20 pixel-exact, 0 refusals. Updated `refusal_inventory.rs`'s pinned list to drop the matching string (`capability_claims_are_declared_not_scattered` and `the_decode_path_refuses_exactly_the_listed_cases` both pass, confirming the pinned list now matches the live refusal set). This mirrors r6/r7's ordering exactly: the decode_stream-level gate can only pass once the refusal it exercises is gone, so lift and gate ship together. | |
| 13 | + | |
| 14 | +Committed 491af97. | |
| 15 | + | |
| 16 | +## Extra: interior tile-row boundary (mirroring r7's four-column rigor) | |
| 17 | +Two tile rows only exercises the edge case (row 1 is also the frame's bottom edge), same shape as r6's original two-column gate before r7's four-column gate proved an interior boundary. Uniform tile spacing is always a power of two, so the smallest row count with a genuine interior boundary is 4 (`--tile-rows=2` -> `TileRows=4`). Added `a_real_aomenc_stream_with_four_tile_rows_decodes_pixel_exact` (64x256, loop filter ON, through `decode_stream`) -- 20/20 pixel-exact, 0 refusals, hard `tile_hits > 2` assert. | |
| 18 | + | |
| 19 | +Committed 8d73fc2. | |
| 20 | + | |
| 21 | +## Bonus finding: stale refusal-claim comment (context_update_tile_id) | |
| 22 | +While writing the four-tile-row gate's doc comment I checked the charter's next-up item (`context_update_tile_id != 0`) against the actual code and found `decode_stream`'s multi-tile comment claiming a `context_update_tile_id != 0` refusal existed "further down" in the file -- grepped the whole crate for `context_update_tile_id` and no such refusal exists anywhere; `decode.rs` reads `tile_info.context_update_tile_id` generically (never hardcoded to tile 0) at both the key-frame and inter-frame tile loops' `result_cdfs = cdfs` sites. Probed live with an eprintln on the four-tile-row gate's own 20-seed sweep: aomenc's RD-driven tile-size heuristic picked `context_update_tile_id` in {0,1,2,3} across the runs (seed 42 -> 2, seed 48 -> 1, seed 55 -> 3, etc.), and every one of those 20 attempts was pixel-exact. So the capability was already fully working, just undocumented and unproven -- not a real gap, a stale comment (class [[stale-premise-lanes]]). Removed the debug eprintln, fixed the comment to describe the real (generic) behaviour, and added a hard `saw_nonzero_context_update_tile_id` assert to the four-tile-row gate so this proof can't silently regress unnoticed. This closes the charter's first "if turns remain" item without any code change to `decode.rs` -- it was already correct. | |
| 23 | + | |
| 24 | +Committed 013cb58. | |
| 25 | + | |
| 26 | +## If turns remain (unchanged from charter, genuinely open) | |
| 27 | +`context_update_tile_id != 0` is now CLOSED (see above, no code change needed, already correct). Still open, in charter order: several tile-group OBUs per frame, non-uniform tile spacing. Neither attempted this round (turn budget). Each is a refusal today (grep for `"a frame OBU with no tile group"` and non-uniform-spacing handling in `frame.rs`'s tile_info parse -- not investigated this round for staleness the way `context_update_tile_id` was, so do that check first before assuming either still needs real work). | |
| 28 | +deferred: several-tile-group-OBUs-per-frame gate + lift, non-uniform tile spacing gate + lift -- unblocks with a fresh turn budget; check both for the same "already-correct, comment-stale" possibility before building new decode machinery, the way this round found `context_update_tile_id` was. | |
| 29 | + | |
| 30 | +## Files changed | |
| 31 | +- `crates/ec-av1/src/stream.rs` -- 3 new gates (two-tile-row bypass, two-tile-row through `decode_stream`, four-tile-row interior boundary), `tile_info.rows > 1` refusal removed from `decode_stream`, multi-tile doc comment updated (rows closed + `context_update_tile_id` stale-claim correction), hard assert added proving `context_update_tile_id != 0` fires and matches | |
| 32 | +- `crates/ec-av1/src/refusal_inventory.rs` -- 1 pinned string removed (tile rows) to match the lifted refusal | |
| 33 | + | |
| 34 | +## Commits | |
| 35 | +- ef641d9 merge main into lane-tiles (r8 start) | |
| 36 | +- d6b4d51 test(av1): gate tile rows below decode_stream's refusal (bypass) | |
| 37 | +- 491af97 feat(av1): lift the tile-rows refusal, gated through decode_stream | |
| 38 | +- 8d73fc2 test(av1): interior tile-row boundary gate (four rows), mirroring r7's four-column gate | |
| 39 | +- 013cb58 docs+test(av1): drop the stale context_update_tile_id refusal claim, hard-assert it live | |
| 40 | + | |
| 41 | +Scoped suite (`tile mvstack refusal_inventory gate_coverage`, `EC_AV1_REQUIRE_AOMENC=1`) 82/0 green after every commit in this round. `cargo check -p ec-av1 --tests` clean throughout. | |
| 42 | + | |
| 43 | +Never pushed, never merged, never touched main, worked only inside edith_codecs-tiles. `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-tiles` used for every build/test. |