merge lane-kf900
Browse files at this commit5 changed files +455 -163
- crates/ec-av1/src/decode.rs +146 -116
- crates/ec-av1/src/gate_coverage.rs +12 -15
- crates/ec-av1/src/stream.rs +82 -32
- lanes/kf900-r6.report.md +118 -0
- lanes/kf900-r6b.report.md +97 -0
crates/ec-av1/src/decode.rsmodified+146 -116
| @@ -1616,6 +1616,21 @@ thread_local! { | |||
| 1616 | static INTRABC_DV: std::cell::Cell<Option<(i32, i32)>> = const { std::cell::Cell::new(None) }; | 1616 | static INTRABC_DV: std::cell::Cell<Option<(i32, i32)>> = const { std::cell::Cell::new(None) }; |
| 1617 | /// How many blocks decoded `use_intrabc == 1` -- the gate's hit counter. | 1617 | /// How many blocks decoded `use_intrabc == 1` -- the gate's hit counter. |
| 1618 | static INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 1618 | static INTRABC_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1619 | + /// The `tx_type` the last plane-0 [`read_plane`] actually coded, kept so | ||
| 1620 | + /// an intrabc block's chroma reads can inherit it (see | ||
| 1621 | + /// [`INTRABC_CHROMA_TX`]). Written on every luma read; only ever read | ||
| 1622 | + /// through that one arming site. | ||
| 1623 | + static LUMA_TX_TYPE: std::cell::Cell<TxType> = const { std::cell::Cell::new(TxType::DctDct) }; | ||
| 1624 | + /// libaom `av1_get_tx_type` (`blockd.h:1350`): for `PLANE_TYPE_UV` it | ||
| 1625 | + /// branches on `is_inter_block(mbmi)` -- which `is_intrabc_block` also | ||
| 1626 | + /// satisfies (`blockd.h:373`) -- and takes the *colocated luma | ||
| 1627 | + /// transform's coded* `tx_type` (`mbmi->txk_type[...]`), never | ||
| 1628 | + /// `intra_mode_to_tx_type` of the chroma mode. `Some` only across an | ||
| 1629 | + /// intrabc block's two chroma [`read_plane`] calls; the type decides the | ||
| 1630 | + /// `TX_CLASS`, hence the scan order, `eob_multi_ctx` and every nz context | ||
| 1631 | + /// -- getting it wrong desyncs the chroma coefficients, it is not a | ||
| 1632 | + /// reconstruction-only detail. | ||
| 1633 | + static INTRABC_CHROMA_TX: std::cell::Cell<Option<TxType>> = const { std::cell::Cell::new(None) }; | ||
| 1619 | } | 1634 | } |
| 1620 | 1635 | ||
| 1621 | /// Whether this frame's header set `allow_intrabc` -- [`INTRABC_MI_GRID`] is | 1636 | /// Whether this frame's header set `allow_intrabc` -- [`INTRABC_MI_GRID`] is |
| @@ -4178,14 +4193,14 @@ impl Neighbours { | |||
| 4178 | uv_tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], | 4193 | uv_tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 4179 | ref_grid: vec![0i8; cols * (SUB / MI) * rows * (SUB / MI)], | 4194 | ref_grid: vec![0i8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 4180 | delta_lf_grid: vec![[0i8; 4]; cols * (SUB / MI) * rows * (SUB / MI)], | 4195 | delta_lf_grid: vec![[0i8; 4]; cols * (SUB / MI) * rows * (SUB / MI)], |
| 4181 | - above_palette_size: vec![0; cols], | 4196 | + above_palette_size: vec![0; cols * (SUB / MI)], |
| 4182 | - left_palette_size: vec![0; rows], | 4197 | + left_palette_size: vec![0; rows * (SUB / MI)], |
| 4183 | - above_palette_colors: vec![[0u16; 8]; cols], | 4198 | + above_palette_colors: vec![[0u16; 8]; cols * (SUB / MI)], |
| 4184 | - left_palette_colors: vec![[0u16; 8]; rows], | 4199 | + left_palette_colors: vec![[0u16; 8]; rows * (SUB / MI)], |
| 4185 | - above_palette_uv_size: vec![0; cols], | 4200 | + above_palette_uv_size: vec![0; cols * (SUB / MI)], |
| 4186 | - left_palette_uv_size: vec![0; rows], | 4201 | + left_palette_uv_size: vec![0; rows * (SUB / MI)], |
| 4187 | - above_palette_uv_colors: vec![[0u16; 8]; cols], | 4202 | + above_palette_uv_colors: vec![[0u16; 8]; cols * (SUB / MI)], |
| 4188 | - left_palette_uv_colors: vec![[0u16; 8]; rows], | 4203 | + left_palette_uv_colors: vec![[0u16; 8]; rows * (SUB / MI)], |
| 4189 | tile_row0_mi: 0, | 4204 | tile_row0_mi: 0, |
| 4190 | tile_col0_mi: 0, | 4205 | tile_col0_mi: 0, |
| 4191 | } | 4206 | } |
| @@ -4245,7 +4260,7 @@ impl Neighbours { | |||
| 4245 | /// mirrors [`Self::record_rect`]'s loop shape, square-only (this lane's | 4260 | /// mirrors [`Self::record_rect`]'s loop shape, square-only (this lane's |
| 4246 | /// call sites are all square blocks). | 4261 | /// call sites are all square blocks). |
| 4247 | fn record_palette_y(&mut self, at: (usize, usize), side: usize, size: usize, colors: [u16; 8]) { | 4262 | fn record_palette_y(&mut self, at: (usize, usize), side: usize, size: usize, colors: [u16; 8]) { |
| 4248 | - self.record_palette_y_rect(at, side, side, size, colors); | 4263 | + self.record_palette_y_rect((at.0 * (SUB / MI), at.1 * (SUB / MI)), side, side, size, colors); |
| 4249 | } | 4264 | } |
| 4250 | 4265 | ||
| 4251 | /// [`Self::record_palette_y`] with independent above (`w`)/left (`h`) | 4266 | /// [`Self::record_palette_y`] with independent above (`w`)/left (`h`) |
| @@ -4254,29 +4269,30 @@ impl Neighbours { | |||
| 4254 | /// differ. | 4269 | /// differ. |
| 4255 | fn record_palette_y_rect( | 4270 | fn record_palette_y_rect( |
| 4256 | &mut self, | 4271 | &mut self, |
| 4257 | - at: (usize, usize), | 4272 | + mi: (usize, usize), |
| 4258 | w: usize, | 4273 | w: usize, |
| 4259 | h: usize, | 4274 | h: usize, |
| 4260 | size: usize, | 4275 | size: usize, |
| 4261 | colors: [u16; 8], | 4276 | colors: [u16; 8], |
| 4262 | ) { | 4277 | ) { |
| 4263 | - let (r, c) = at; | 4278 | + let (r, c) = mi; |
| 4264 | - // `.max(1)`: a below-16px span covers no whole SUB cell, so the plain | 4279 | + // lane-kf900 r6: mi (4px) granularity, libaom's own -- `palette_size` |
| 4265 | - // `w / SUB` loop was a NO-OP for every 16x8/8x16/8x8/4x4 leaf and the | 4280 | + // lives per mi cell in `MB_MODE_INFO`, and `xd->left_mbmi` is the mi |
| 4266 | - // next block read a long-dead palette out of the above/left arrays | 4281 | + // cell immediately left of the block, not its 16px [`SUB`] cell. The |
| 4267 | - // (class [[cdf-row-held-constant]], lane-palette2 r8). libaom keeps | 4282 | + // old SUB grid let a 16x8 strip pair share one slot, so the second |
| 4268 | - // `palette_size` per 4px mi cell; corner-cut: our grid is 16px, so a | 4283 | + // strip of mi(0,8) read the FIRST strip's palette size and the colour |
| 4269 | - // sub-16 leaf stamps its whole containing cell -- safe today because | 4284 | + // cache came out one entry short (class [[context-read-from-one-cell]]). |
| 4270 | - // every sub-16 leaf path refuses palette outright (so it can only | 4285 | + for cell in 0..(w / MI).max(1) { |
| 4271 | - // ever stamp `size == 0`, and its cell holds no palette sibling). | 4286 | + if let Some(e) = self.above_palette_size.get_mut(c + cell) { |
| 4272 | - // Upgrade path: widen the palette arrays to mi granularity. | 4287 | + *e = size; |
| 4273 | - for cell in 0..(w / SUB).max(1) { | 4288 | + self.above_palette_colors[c + cell] = colors; |
| 4274 | - self.above_palette_size[c + cell] = size; | 4289 | + } |
| 4275 | - self.above_palette_colors[c + cell] = colors; | ||
| 4276 | } | 4290 | } |
| 4277 | - for cell in 0..(h / SUB).max(1) { | 4291 | + for cell in 0..(h / MI).max(1) { |
| 4278 | - self.left_palette_size[r + cell] = size; | 4292 | + if let Some(e) = self.left_palette_size.get_mut(r + cell) { |
| 4279 | - self.left_palette_colors[r + cell] = colors; | 4293 | + *e = size; |
| 4294 | + self.left_palette_colors[r + cell] = colors; | ||
| 4295 | + } | ||
| 4280 | } | 4296 | } |
| 4281 | } | 4297 | } |
| 4282 | 4298 | ||
| @@ -4294,7 +4310,7 @@ impl Neighbours { | |||
| 4294 | /// palette block decoded as "no palette" and the tile desynced from | 4310 | /// palette block decoded as "no palette" and the tile desynced from |
| 4295 | /// there (class [[cdf-row-held-constant]]). | 4311 | /// there (class [[cdf-row-held-constant]]). |
| 4296 | fn palette_ctx_and_cache(&self, at: (usize, usize)) -> (usize, Vec<u16>) { | 4312 | fn palette_ctx_and_cache(&self, at: (usize, usize)) -> (usize, Vec<u16>) { |
| 4297 | - self.palette_ctx_and_cache_mi(at, at.0 * (SUB / MI)) | 4313 | + self.palette_ctx_and_cache_mi((at.0 * (SUB / MI), at.1 * (SUB / MI))) |
| 4298 | } | 4314 | } |
| 4299 | 4315 | ||
| 4300 | /// [`Self::palette_ctx_and_cache`] with the block's REAL mi row, which a | 4316 | /// [`Self::palette_ctx_and_cache`] with the block's REAL mi row, which a |
| @@ -4304,11 +4320,11 @@ impl Neighbours { | |||
| 4304 | /// block's own PIXEL row), and strip 1 of a HORZ_4 sits 8 px into the | 4320 | /// block's own PIXEL row), and strip 1 of a HORZ_4 sits 8 px into the |
| 4305 | /// cell -- reading `at.0 % 4` there excludes strip 0 from the cache of | 4321 | /// cell -- reading `at.0 % 4` there excludes strip 0 from the cache of |
| 4306 | /// every strip in an SB's top cell row, which libaom does not do. | 4322 | /// every strip in an SB's top cell row, which libaom does not do. |
| 4307 | - fn palette_ctx_and_cache_mi(&self, at: (usize, usize), mi_r: usize) -> (usize, Vec<u16>) { | 4323 | + fn palette_ctx_and_cache_mi(&self, mi: (usize, usize)) -> (usize, Vec<u16>) { |
| 4308 | - let (r, c) = at; | 4324 | + let (r, c) = mi; |
| 4309 | - let above_ok = mi_r % 16 != 0; | 4325 | + let above_ok = r % 16 != 0; |
| 4310 | // `xd->above_mbmi` exists for every row but the tile's own first. | 4326 | // `xd->above_mbmi` exists for every row but the tile's own first. |
| 4311 | - let above_is_palette = mi_r > self.tile_row0_mi && self.above_palette_size[c] > 0; | 4327 | + let above_is_palette = r > self.tile_row0_mi && self.above_palette_size[c] > 0; |
| 4312 | let (above_n, above_colors) = if above_ok && self.above_palette_size[c] > 0 { | 4328 | let (above_n, above_colors) = if above_ok && self.above_palette_size[c] > 0 { |
| 4313 | (self.above_palette_size[c], self.above_palette_colors[c]) | 4329 | (self.above_palette_size[c], self.above_palette_colors[c]) |
| 4314 | } else { | 4330 | } else { |
| @@ -4319,7 +4335,7 @@ impl Neighbours { | |||
| 4319 | // (`left_available`), not the frame's -- without this guard a second | 4335 | // (`left_available`), not the frame's -- without this guard a second |
| 4320 | // tile column reads the previous tile's palette colours into its cache | 4336 | // tile column reads the previous tile's palette colours into its cache |
| 4321 | // and its `palette_y_mode` ctx. | 4337 | // and its `palette_y_mode` ctx. |
| 4322 | - let left_ok = c > self.tile_col0_mi / (SUB / MI); | 4338 | + let left_ok = c > self.tile_col0_mi; |
| 4323 | let (left_n, left_colors) = if left_ok && self.left_palette_size[r] > 0 { | 4339 | let (left_n, left_colors) = if left_ok && self.left_palette_size[r] > 0 { |
| 4324 | (self.left_palette_size[r], self.left_palette_colors[r]) | 4340 | (self.left_palette_size[r], self.left_palette_colors[r]) |
| 4325 | } else { | 4341 | } else { |
| @@ -4361,7 +4377,13 @@ impl Neighbours { | |||
| 4361 | /// (U-channel) palette size/colours -- `size == 0` clears stale state the | 4377 | /// (U-channel) palette size/colours -- `size == 0` clears stale state the |
| 4362 | /// same way (lane-palette2 r1). | 4378 | /// same way (lane-palette2 r1). |
| 4363 | fn record_palette_uv(&mut self, at: (usize, usize), side: usize, size: usize, colors: [u16; 8]) { | 4379 | fn record_palette_uv(&mut self, at: (usize, usize), side: usize, size: usize, colors: [u16; 8]) { |
| 4364 | - self.record_palette_uv_rect(at, side, side, size, colors); | 4380 | + self.record_palette_uv_rect( |
| 4381 | + (at.0 * (SUB / MI), at.1 * (SUB / MI)), | ||
| 4382 | + side, | ||
| 4383 | + side, | ||
| 4384 | + size, | ||
| 4385 | + colors, | ||
| 4386 | + ); | ||
| 4365 | } | 4387 | } |
| 4366 | 4388 | ||
| 4367 | /// [`Self::record_palette_uv`] with independent above (`w`)/left (`h`) | 4389 | /// [`Self::record_palette_uv`] with independent above (`w`)/left (`h`) |
| @@ -4370,21 +4392,25 @@ impl Neighbours { | |||
| 4370 | /// luma resolution regardless of which plane the recorded state is for). | 4392 | /// luma resolution regardless of which plane the recorded state is for). |
| 4371 | fn record_palette_uv_rect( | 4393 | fn record_palette_uv_rect( |
| 4372 | &mut self, | 4394 | &mut self, |
| 4373 | - at: (usize, usize), | 4395 | + mi: (usize, usize), |
| 4374 | w: usize, | 4396 | w: usize, |
| 4375 | h: usize, | 4397 | h: usize, |
| 4376 | size: usize, | 4398 | size: usize, |
| 4377 | colors: [u16; 8], | 4399 | colors: [u16; 8], |
| 4378 | ) { | 4400 | ) { |
| 4379 | - let (r, c) = at; | 4401 | + let (r, c) = mi; |
| 4380 | - // See [`Self::record_palette_y_rect`] for the `.max(1)`. | 4402 | + // mi granularity, see [`Self::record_palette_y_rect`]. |
| 4381 | - for cell in 0..(w / SUB).max(1) { | 4403 | + for cell in 0..(w / MI).max(1) { |
| 4382 | - self.above_palette_uv_size[c + cell] = size; | 4404 | + if let Some(e) = self.above_palette_uv_size.get_mut(c + cell) { |
| 4383 | - self.above_palette_uv_colors[c + cell] = colors; | 4405 | + *e = size; |
| 4406 | + self.above_palette_uv_colors[c + cell] = colors; | ||
| 4407 | + } | ||
| 4384 | } | 4408 | } |
| 4385 | - for cell in 0..(h / SUB).max(1) { | 4409 | + for cell in 0..(h / MI).max(1) { |
| 4386 | - self.left_palette_uv_size[r + cell] = size; | 4410 | + if let Some(e) = self.left_palette_uv_size.get_mut(r + cell) { |
| 4387 | - self.left_palette_uv_colors[r + cell] = colors; | 4411 | + *e = size; |
| 4412 | + self.left_palette_uv_colors[r + cell] = colors; | ||
| 4413 | + } | ||
| 4388 | } | 4414 | } |
| 4389 | } | 4415 | } |
| 4390 | 4416 | ||
| @@ -4394,21 +4420,21 @@ impl Neighbours { | |||
| 4394 | /// palette use, `read_palette_mode_info`'s `pmi->palette_size[0] > 0`), | 4420 | /// palette use, `read_palette_mode_info`'s `pmi->palette_size[0] > 0`), |
| 4395 | /// so only the cache is wanted here. | 4421 | /// so only the cache is wanted here. |
| 4396 | fn palette_uv_cache(&self, at: (usize, usize)) -> Vec<u16> { | 4422 | fn palette_uv_cache(&self, at: (usize, usize)) -> Vec<u16> { |
| 4397 | - self.palette_uv_cache_mi(at, at.0 * (SUB / MI)) | 4423 | + self.palette_uv_cache_mi((at.0 * (SUB / MI), at.1 * (SUB / MI))) |
| 4398 | } | 4424 | } |
| 4399 | 4425 | ||
| 4400 | /// [`Self::palette_uv_cache`] with the block's real mi row -- see | 4426 | /// [`Self::palette_uv_cache`] with the block's real mi row -- see |
| 4401 | /// [`Self::palette_ctx_and_cache_mi`]. | 4427 | /// [`Self::palette_ctx_and_cache_mi`]. |
| 4402 | - fn palette_uv_cache_mi(&self, at: (usize, usize), mi_r: usize) -> Vec<u16> { | 4428 | + fn palette_uv_cache_mi(&self, mi: (usize, usize)) -> Vec<u16> { |
| 4403 | - let (r, c) = at; | 4429 | + let (r, c) = mi; |
| 4404 | - let above_ok = mi_r % 16 != 0; | 4430 | + let above_ok = r % 16 != 0; |
| 4405 | let (above_n, above_colors) = if above_ok && self.above_palette_uv_size[c] > 0 { | 4431 | let (above_n, above_colors) = if above_ok && self.above_palette_uv_size[c] > 0 { |
| 4406 | (self.above_palette_uv_size[c], self.above_palette_uv_colors[c]) | 4432 | (self.above_palette_uv_size[c], self.above_palette_uv_colors[c]) |
| 4407 | } else { | 4433 | } else { |
| 4408 | (0, [0u16; 8]) | 4434 | (0, [0u16; 8]) |
| 4409 | }; | 4435 | }; |
| 4410 | // Same tile-relative left availability as the luma cache above. | 4436 | // Same tile-relative left availability as the luma cache above. |
| 4411 | - let left_ok = c > self.tile_col0_mi / (SUB / MI); | 4437 | + let left_ok = c > self.tile_col0_mi; |
| 4412 | let (left_n, left_colors) = if left_ok && self.left_palette_uv_size[r] > 0 { | 4438 | let (left_n, left_colors) = if left_ok && self.left_palette_uv_size[r] > 0 { |
| 4413 | (self.left_palette_uv_size[r], self.left_palette_uv_colors[r]) | 4439 | (self.left_palette_uv_size[r], self.left_palette_uv_colors[r]) |
| 4414 | } else { | 4440 | } else { |
| @@ -6077,40 +6103,43 @@ fn read_intra_mode_rect( | |||
| 6077 | )) | 6103 | )) |
| 6078 | } | 6104 | } |
| 6079 | 6105 | ||
| 6080 | -/// Stamps a 1:4 strip's palette state into the coarse above/left arrays. | 6106 | +/// Stamps a 1:4 strip's palette state into the mi-granular above/left arrays, |
| 6081 | -/// `av1_get_palette_cache` reads `xd->above_mbmi`/`xd->left_mbmi`, and inside | 6107 | +/// at the strip's REAL mi position. `av1_get_palette_cache` reads |
| 6082 | -/// a HORZ_4 (VERT_4) the next strip's ABOVE (LEFT) neighbour is this strip | 6108 | +/// `xd->above_mbmi`/`xd->left_mbmi`, i.e. the mi cell above/left of the |
| 6083 | -/// while its LEFT (ABOVE) neighbour is still the parent block's. The coarse | 6109 | +/// block, so each strip owns its own rows and columns and no aliasing rule |
| 6084 | -/// [`SUB`]-cell arrays alias all four strips onto one entry, so writing BOTH | 6110 | +/// is needed (lane-kf900 r6). |
| 6085 | -/// axes after every strip would hand strip i+1 this strip's colours on the | ||
| 6086 | -/// wrong axis too -- a wrong cache costs the same bits, so the tile stays in | ||
| 6087 | -/// sync and only the pixels are wrong (class [[cdf-row-held-constant]]). | ||
| 6088 | -/// Only the split axis is written until the closing strip, which stamps both | ||
| 6089 | -/// for whatever follows the parent block. | ||
| 6090 | #[allow(clippy::too_many_arguments)] | 6111 | #[allow(clippy::too_many_arguments)] |
| 6091 | fn record_strip_palette( | 6112 | fn record_strip_palette( |
| 6092 | n: &mut Neighbours, | 6113 | n: &mut Neighbours, |
| 6093 | - at: (usize, usize), | 6114 | + mi: (usize, usize), |
| 6094 | bw: usize, | 6115 | bw: usize, |
| 6095 | bh: usize, | 6116 | bh: usize, |
| 6096 | y_size: usize, | 6117 | y_size: usize, |
| 6097 | y_colors: [u16; 8], | 6118 | y_colors: [u16; 8], |
| 6098 | uv_size: usize, | 6119 | uv_size: usize, |
| 6099 | uv_colors: [u16; 8], | 6120 | uv_colors: [u16; 8], |
| 6100 | - last: bool, | ||
| 6101 | ) { | 6121 | ) { |
| 6102 | - let (r, c) = at; | 6122 | + let (r, c) = mi; |
| 6103 | - let horz = bw > bh; | 6123 | + // lane-kf900 r6: the palette side bands are mi-granular now, so a strip |
| 6104 | - if horz || last { | 6124 | + // writes its OWN span on BOTH axes -- the old `last` split-axis rule only |
| 6105 | - for cell in 0..(bw / SUB).max(1) { | 6125 | + // existed because the 16px [`SUB`] cell held one slot for all the strips |
| 6106 | - n.above_palette_size[c + cell] = y_size; | 6126 | + // of a HORZ_4/VERT_4 and leaf 0 zeroing the other axis threw away the |
| 6107 | - n.above_palette_colors[c + cell] = y_colors; | 6127 | + // real neighbour leaf 1 reads. |
| 6108 | - n.above_palette_uv_size[c + cell] = uv_size; | 6128 | + { |
| 6109 | - n.above_palette_uv_colors[c + cell] = uv_colors; | 6129 | + for cell in 0..(bw / MI).max(1) { |
| 6130 | + if let Some(e) = n.above_palette_size.get_mut(c + cell) { | ||
| 6131 | + *e = y_size; | ||
| 6132 | + n.above_palette_colors[c + cell] = y_colors; | ||
| 6133 | + n.above_palette_uv_size[c + cell] = uv_size; | ||
| 6134 | + n.above_palette_uv_colors[c + cell] = uv_colors; | ||
| 6135 | + } | ||
| 6110 | } | 6136 | } |
| 6111 | } | 6137 | } |
| 6112 | - if !horz || last { | 6138 | + { |
| 6113 | - for cell in 0..(bh / SUB).max(1) { | 6139 | + for cell in 0..(bh / MI).max(1) { |
| 6140 | + if n.left_palette_size.get(r + cell).is_none() { | ||
| 6141 | + break; | ||
| 6142 | + } | ||
| 6114 | n.left_palette_size[r + cell] = y_size; | 6143 | n.left_palette_size[r + cell] = y_size; |
| 6115 | n.left_palette_colors[r + cell] = y_colors; | 6144 | n.left_palette_colors[r + cell] = y_colors; |
| 6116 | n.left_palette_uv_size[r + cell] = uv_size; | 6145 | n.left_palette_uv_size[r + cell] = uv_size; |
| @@ -6959,10 +6988,10 @@ fn decode_block_rect( | |||
| 6959 | // wrong VALUE -- same bit count, so the entropy stream stayed in sync | 6988 | // wrong VALUE -- same bit count, so the entropy stream stayed in sync |
| 6960 | // and only those pixels were wrong (lane-palette2 r10). | 6989 | // and only those pixels were wrong (lane-palette2 r10). |
| 6961 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); | 6990 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| 6962 | - neighbours.record_palette_y_rect(at, bw, bh, py_size, py_colors); | 6991 | + neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors); |
| 6963 | let (puv_size, puv_colors) = | 6992 | let (puv_size, puv_colors) = |
| 6964 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | 6993 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 6965 | - neighbours.record_palette_uv_rect(at, bw, bh, puv_size, puv_colors); | 6994 | + neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); |
| 6966 | RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); | 6995 | RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); |
| 6967 | return Ok(()); | 6996 | return Ok(()); |
| 6968 | } | 6997 | } |
| @@ -7227,10 +7256,10 @@ fn decode_block_rect( | |||
| 7227 | } | 7256 | } |
| 7228 | } | 7257 | } |
| 7229 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); | 7258 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| 7230 | - neighbours.record_palette_y_rect(at, bw, bh, py_size, py_colors); | 7259 | + neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors); |
| 7231 | let (puv_size, puv_colors) = | 7260 | let (puv_size, puv_colors) = |
| 7232 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | 7261 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 7233 | - neighbours.record_palette_uv_rect(at, bw, bh, puv_size, puv_colors); | 7262 | + neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); |
| 7234 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); | 7263 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); |
| 7235 | neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0); | 7264 | neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0); |
| 7236 | RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); | 7265 | RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); |
| @@ -7316,12 +7345,13 @@ fn decode_leaf_rect( | |||
| 7316 | // a palette narrows the wrong interval and desyncs the tile even when the | 7345 | // a palette narrows the wrong interval and desyncs the tile even when the |
| 7317 | // decoded bit is the same. The cell is the 16px-SUB cell containing the | 7346 | // decoded bit is the same. The cell is the 16px-SUB cell containing the |
| 7318 | // leaf (the palette neighbour arrays have no finer granularity). | 7347 | // leaf (the palette neighbour arrays have no finer granularity). |
| 7319 | - let pal_at = (leaf_mi.0 / (SUB / MI), leaf_mi.1 / (SUB / MI)); | 7348 | + // lane-kf900 r6: the leaf's REAL mi position -- the second leaf of a 16x8 |
| 7320 | - // lane-kf900 r4: the leaf's REAL mi row -- the second leaf of a 16x8 pair | 7349 | + // pair sits 8 px into the 16px cell, and both the cache's superblock-top-row |
| 7321 | - // sits 8 px into the cell, so the cache's superblock-top-row exclusion | 7350 | + // exclusion and the neighbour palette lookup itself are mi-granular |
| 7322 | - // must not be read off the cell (see [`Neighbours::palette_ctx_and_cache_mi`]). | 7351 | + // (see [`Neighbours::palette_ctx_and_cache_mi`]). |
| 7323 | - let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at, leaf_mi.0); | 7352 | + let pal_at = leaf_mi; |
| 7324 | - let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at, leaf_mi.0); | 7353 | + let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at); |
| 7354 | + let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at); | ||
| 7325 | let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) = | 7355 | let (skip, mode, angle_delta_y, uv_mode, angle_delta_uv, alpha, filter_intra, palette_y, palette_uv) = |
| 7326 | read_intra_mode_rect( | 7356 | read_intra_mode_rect( |
| 7327 | dec, | 7357 | dec, |
| @@ -7359,12 +7389,6 @@ fn decode_leaf_rect( | |||
| 7359 | palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); | 7389 | palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| 7360 | let (pal_uv_size, pal_uv_colors) = | 7390 | let (pal_uv_size, pal_uv_colors) = |
| 7361 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | 7391 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 7362 | - // The closing leaf of the pair -- see [`record_strip_palette`]. | ||
| 7363 | - let pal_last = if bw > bh { | ||
| 7364 | - leaf_mi.0 % 4 == 2 | ||
| 7365 | - } else { | ||
| 7366 | - leaf_mi.1 % 4 == 2 | ||
| 7367 | - }; | ||
| 7368 | if std::env::var_os("EC_AV1_RECTX_TRACE").is_some() { | 7392 | if std::env::var_os("EC_AV1_RECTX_TRACE").is_some() { |
| 7369 | eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}"); | 7393 | eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}"); |
| 7370 | } | 7394 | } |
| @@ -7447,7 +7471,6 @@ fn decode_leaf_rect( | |||
| 7447 | )?; | 7471 | )?; |
| 7448 | record_strip_palette( | 7472 | record_strip_palette( |
| 7449 | neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, | 7473 | neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, |
| 7450 | - pal_last, | ||
| 7451 | ); | 7474 | ); |
| 7452 | return Ok(mode); | 7475 | return Ok(mode); |
| 7453 | } | 7476 | } |
| @@ -7571,7 +7594,6 @@ fn decode_leaf_rect( | |||
| 7571 | // real left neighbour leaf 1 reads (lane-kf900 r4). | 7594 | // real left neighbour leaf 1 reads (lane-kf900 r4). |
| 7572 | record_strip_palette( | 7595 | record_strip_palette( |
| 7573 | neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, | 7596 | neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, |
| 7574 | - pal_last, | ||
| 7575 | ); | 7597 | ); |
| 7576 | // A rect leaf spans mi_w x mi_h, so its mode reaches several columns and | 7598 | // A rect leaf spans mi_w x mi_h, so its mode reaches several columns and |
| 7577 | // rows -- record the whole span, not one cell. | 7599 | // rows -- record the whole span, not one cell. |
| @@ -7641,9 +7663,9 @@ fn decode_block_rect4( | |||
| 7641 | // `palette_colors_y` cache hit off an EMPTY cache -- right symbol count, | 7663 | // `palette_colors_y` cache hit off an EMPTY cache -- right symbol count, |
| 7642 | // wrong interval, so a screen-content tile desynced at the first strip | 7664 | // wrong interval, so a screen-content tile desynced at the first strip |
| 7643 | // whose neighbour used a palette (class [[cdf-row-held-constant]]). | 7665 | // whose neighbour used a palette (class [[cdf-row-held-constant]]). |
| 7644 | - let pal_at = (mi_r / (SUB / MI), mi_c / (SUB / MI)); | 7666 | + let pal_at = (mi_r, mi_c); |
| 7645 | - let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at, mi_r); | 7667 | + let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(pal_at); |
| 7646 | - let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at, mi_r); | 7668 | + let palette_uv_cache = neighbours.palette_uv_cache_mi(pal_at); |
| 7647 | let ( | 7669 | let ( |
| 7648 | skip, | 7670 | skip, |
| 7649 | mode, | 7671 | mode, |
| @@ -7687,10 +7709,6 @@ fn decode_block_rect4( | |||
| 7687 | p.map.iter().map(|&i| p.v_colors[i as usize]).collect(), | 7709 | p.map.iter().map(|&i| p.v_colors[i as usize]).collect(), |
| 7688 | ) | 7710 | ) |
| 7689 | }); | 7711 | }); |
| 7690 | - // `last`: strip 3 of the parent 32x32's HORZ_4 (VERT_4), the only one | ||
| 7691 | - // whose colours a block outside the parent sees -- see | ||
| 7692 | - // [`record_strip_palette`]. | ||
| 7693 | - let pal_last = if bw > bh { mi_r % 8 == 6 } else { mi_c % 8 == 6 }; | ||
| 7694 | let (pal_y_size, pal_y_colors) = | 7712 | let (pal_y_size, pal_y_colors) = |
| 7695 | palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); | 7713 | palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| 7696 | let (pal_uv_size, pal_uv_colors) = | 7714 | let (pal_uv_size, pal_uv_colors) = |
| @@ -7778,7 +7796,7 @@ fn decode_block_rect4( | |||
| 7778 | )?; | 7796 | )?; |
| 7779 | record_strip_palette( | 7797 | record_strip_palette( |
| 7780 | neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, | 7798 | neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, |
| 7781 | - pal_uv_colors, pal_last, | 7799 | + pal_uv_colors, |
| 7782 | ); | 7800 | ); |
| 7783 | if bw > bh { | 7801 | if bw > bh { |
| 7784 | RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | 7802 | RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); |
| @@ -7931,7 +7949,7 @@ fn decode_block_rect4( | |||
| 7931 | neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0); | 7949 | neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0); |
| 7932 | record_strip_palette( | 7950 | record_strip_palette( |
| 7933 | neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, | 7951 | neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, |
| 7934 | - pal_uv_colors, pal_last, | 7952 | + pal_uv_colors, |
| 7935 | ); | 7953 | ); |
| 7936 | if bw > bh { | 7954 | if bw > bh { |
| 7937 | RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | 7955 | RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); |
| @@ -7994,7 +8012,6 @@ fn decode_block_rect4( | |||
| 7994 | neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0); | 8012 | neighbours.fill_lf_grid_rect((mi_r, mi_c), mi_w, mi_h, bw as u8, bh as u8, 0); |
| 7995 | record_strip_palette( | 8013 | record_strip_palette( |
| 7996 | neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, | 8014 | neighbours, pal_at, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, |
| 7997 | - pal_last, | ||
| 7998 | ); | 8015 | ); |
| 7999 | if bw > bh { | 8016 | if bw > bh { |
| 8000 | RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | 8017 | RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); |
| @@ -8078,9 +8095,8 @@ fn decode_rect4_16( | |||
| 8078 | // lane-kf900 r4: the strip's real palette ctx + colour cache (see | 8095 | // lane-kf900 r4: the strip's real palette ctx + colour cache (see |
| 8079 | // [`decode_block_rect4`]); `None`/`&[]` here read `palette_y_mode` | 8096 | // [`decode_block_rect4`]); `None`/`&[]` here read `palette_y_mode` |
| 8080 | // off CDF row 0 and every cache hit off an empty cache. | 8097 | // off CDF row 0 and every cache hit off an empty cache. |
| 8081 | - let (palette_ctx, palette_cache) = | 8098 | + let (palette_ctx, palette_cache) = neighbours.palette_ctx_and_cache_mi(lmi); |
| 8082 | - neighbours.palette_ctx_and_cache_mi(at16, lmi.0); | 8099 | + let palette_uv_cache = neighbours.palette_uv_cache_mi(lmi); |
| 8083 | - let palette_uv_cache = neighbours.palette_uv_cache_mi(at16, lmi.0); | ||
| 8084 | let ( | 8100 | let ( |
| 8085 | skip, | 8101 | skip, |
| 8086 | mode, | 8102 | mode, |
| @@ -8489,8 +8505,7 @@ fn decode_rect4_16( | |||
| 8489 | let (pal_uv_size, pal_uv_colors) = | 8505 | let (pal_uv_size, pal_uv_colors) = |
| 8490 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | 8506 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 8491 | record_strip_palette( | 8507 | record_strip_palette( |
| 8492 | - neighbours, at16, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, | 8508 | + neighbours, lmi, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, |
| 8493 | - i == 3, | ||
| 8494 | ); | 8509 | ); |
| 8495 | last_mode = mode; | 8510 | last_mode = mode; |
| 8496 | prev = Some((lmi, mode)); | 8511 | prev = Some((lmi, mode)); |
| @@ -8685,10 +8700,10 @@ fn decode_block_rect64( | |||
| 8685 | // split-tx superblock strip would otherwise leave the above/left | 8700 | // split-tx superblock strip would otherwise leave the above/left |
| 8686 | // palette arrays holding a dead block's colours. | 8701 | // palette arrays holding a dead block's colours. |
| 8687 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); | 8702 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| 8688 | - neighbours.record_palette_y_rect(at, bw, bh, py_size, py_colors); | 8703 | + neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors); |
| 8689 | let (puv_size, puv_colors) = | 8704 | let (puv_size, puv_colors) = |
| 8690 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | 8705 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 8691 | - neighbours.record_palette_uv_rect(at, bw, bh, puv_size, puv_colors); | 8706 | + neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); |
| 8692 | RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); | 8707 | RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); |
| 8693 | return Ok(()); | 8708 | return Ok(()); |
| 8694 | } | 8709 | } |
| @@ -9000,10 +9015,10 @@ fn decode_block_rect64( | |||
| 9000 | RECT_COEFF_HITS.with(|c| c.set(c.get() + 1)); | 9015 | RECT_COEFF_HITS.with(|c| c.set(c.get() + 1)); |
| 9001 | } | 9016 | } |
| 9002 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); | 9017 | let (py_size, py_colors) = palette_y.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.colors)); |
| 9003 | - neighbours.record_palette_y_rect(at, bw, bh, py_size, py_colors); | 9018 | + neighbours.record_palette_y_rect((mi_r, mi_c), bw, bh, py_size, py_colors); |
| 9004 | let (puv_size, puv_colors) = | 9019 | let (puv_size, puv_colors) = |
| 9005 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); | 9020 | palette_uv.as_ref().map_or((0, [0u16; 8]), |p| (p.size, p.u_colors)); |
| 9006 | - neighbours.record_palette_uv_rect(at, bw, bh, puv_size, puv_colors); | 9021 | + neighbours.record_palette_uv_rect((mi_r, mi_c), bw, bh, puv_size, puv_colors); |
| 9007 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); | 9022 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); |
| 9008 | neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0); | 9023 | neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0); |
| 9009 | SB_RECT_HITS.with(|c| c.set(c.get() + 1)); | 9024 | SB_RECT_HITS.with(|c| c.set(c.get() + 1)); |
| @@ -9866,6 +9881,13 @@ fn read_plane( | |||
| 9866 | // narrows there — only `Chroma32` and up do). | 9881 | // narrows there — only `Chroma32` and up do). |
| 9867 | let default_tx_type = if plane_idx == 0 || side >= 32 { | 9882 | let default_tx_type = if plane_idx == 0 || side >= 32 { |
| 9868 | TxType::DctDct | 9883 | TxType::DctDct |
| 9884 | + } else if let Some(inherited) = INTRABC_CHROMA_TX.with(std::cell::Cell::get) { | ||
| 9885 | + // See [`INTRABC_CHROMA_TX`]: an intrabc block is an inter block for | ||
| 9886 | + // `av1_get_tx_type`, so chroma inherits luma's coded type (the | ||
| 9887 | + // `side >= 32` arm above is already libaom's `EXT_TX_SET_DCTONLY` | ||
| 9888 | + // clamp at `tx_size_sqr_up >= TX_32X32`, matching | ||
| 9889 | + // [`read_inter_plane`]'s own `side < 32` guard). | ||
| 9890 | + inherited | ||
| 9869 | } else { | 9891 | } else { |
| 9870 | default_intra_tx_type(predict_mode as u8) | 9892 | default_intra_tx_type(predict_mode as u8) |
| 9871 | }; | 9893 | }; |
| @@ -9879,6 +9901,9 @@ fn read_plane( | |||
| 9879 | None, | 9901 | None, |
| 9880 | )?; | 9902 | )?; |
| 9881 | note_chroma_class1(plane_idx, tx_type); | 9903 | note_chroma_class1(plane_idx, tx_type); |
| 9904 | + if plane_idx == 0 { | ||
| 9905 | + LUMA_TX_TYPE.with(|c| c.set(tx_type)); | ||
| 9906 | + } | ||
| 9882 | // A 64x64 luma block's transform covers the whole 64x64 area, but only its | 9907 | // A 64x64 luma block's transform covers the whole 64x64 area, but only its |
| 9883 | // top-left 32x32 of frequencies are coded (spec 5.11.40); the rest of the | 9908 | // top-left 32x32 of frequencies are coded (spec 5.11.40); the rest of the |
| 9884 | // dequantized grid stays zero, which `inverse_transform_2d`'s own `< 32` | 9909 | // dequantized grid stays zero, which `inverse_transform_2d`'s own `< 32` |
| @@ -10279,6 +10304,12 @@ fn decode_block( | |||
| 10279 | smooth_neighbor, | 10304 | smooth_neighbor, |
| 10280 | )?; | 10305 | )?; |
| 10281 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | 10306 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); |
| 10307 | + // Armed for exactly this block's two chroma reads (see | ||
| 10308 | + // [`INTRABC_CHROMA_TX`]); the luma call above just set | ||
| 10309 | + // [`LUMA_TX_TYPE`] to the type it coded. | ||
| 10310 | + if intrabc_dv.is_some() { | ||
| 10311 | + INTRABC_CHROMA_TX.with(|c| c.set(Some(LUMA_TX_TYPE.with(std::cell::Cell::get)))); | ||
| 10312 | + } | ||
| 10282 | if let Some((ub, _)) = &palette_uv_bufs { | 10313 | if let Some((ub, _)) = &palette_uv_bufs { |
| 10283 | set_palette_pred(ub.clone()); | 10314 | set_palette_pred(ub.clone()); |
| 10284 | } | 10315 | } |
| @@ -10335,6 +10366,7 @@ fn decode_block( | |||
| 10335 | None, | 10366 | None, |
| 10336 | smooth_neighbor_uv, | 10367 | smooth_neighbor_uv, |
| 10337 | )?; | 10368 | )?; |
| 10369 | + INTRABC_CHROMA_TX.with(|c| c.set(None)); | ||
| 10338 | neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]); | 10370 | neighbours.record(at, side, mode, uv_predict_mode, &[luma_grid, u_grid, v_grid]); |
| 10339 | } else { | 10371 | } else { |
| 10340 | // Several luma transform units, raster order (spec | 10372 | // Several luma transform units, raster order (spec |
| @@ -10976,9 +11008,8 @@ fn decode_leaf8( | |||
| 10976 | // above/left palette state over its own cell so the next block's ctx and | 11008 | // above/left palette state over its own cell so the next block's ctx and |
| 10977 | // colour cache do not read a previous block's palette (lane-palette2 r8). | 11009 | // colour cache do not read a previous block's palette (lane-palette2 r8). |
| 10978 | { | 11010 | { |
| 10979 | - let pal_at = (leaf_mi.0 / (SUB / MI), leaf_mi.1 / (SUB / MI)); | 11011 | + neighbours.record_palette_y_rect(leaf_mi, 8, 8, 0, [0u16; 8]); |
| 10980 | - neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]); | 11012 | + neighbours.record_palette_uv_rect(leaf_mi, 8, 8, 0, [0u16; 8]); |
| 10981 | - neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]); | ||
| 10982 | } | 11013 | } |
| 10983 | neighbours.fill_skip_grid(leaf_mi, 2, skip); | 11014 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 10984 | neighbours.fill_lf_grid(leaf_mi, 2, 4, 0); | 11015 | neighbours.fill_lf_grid(leaf_mi, 2, 4, 0); |
| @@ -10990,9 +11021,8 @@ fn decode_leaf8( | |||
| 10990 | // above/left palette state over its own cell so the next block's ctx and | 11021 | // above/left palette state over its own cell so the next block's ctx and |
| 10991 | // colour cache do not read a previous block's palette (lane-palette2 r8). | 11022 | // colour cache do not read a previous block's palette (lane-palette2 r8). |
| 10992 | { | 11023 | { |
| 10993 | - let pal_at = (leaf_mi.0 / (SUB / MI), leaf_mi.1 / (SUB / MI)); | 11024 | + neighbours.record_palette_y_rect(leaf_mi, 8, 8, 0, [0u16; 8]); |
| 10994 | - neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]); | 11025 | + neighbours.record_palette_uv_rect(leaf_mi, 8, 8, 0, [0u16; 8]); |
| 10995 | - neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]); | ||
| 10996 | } | 11026 | } |
| 10997 | INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | 11027 | INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); |
| 10998 | neighbours.fill_skip_grid(leaf_mi, 2, skip); | 11028 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| @@ -25516,19 +25546,19 @@ mod tests { | |||
| 25516 | fn a_sub16_leaf_after_a_palette_block_yields_palette_ctx_zero() { | 25546 | fn a_sub16_leaf_after_a_palette_block_yields_palette_ctx_zero() { |
| 25517 | let mut n = Neighbours::new(4, 4, 16, 16); | 25547 | let mut n = Neighbours::new(4, 4, 16, 16); |
| 25518 | // A real 16x16 palette block covering SUB cell (1, 1). | 25548 | // A real 16x16 palette block covering SUB cell (1, 1). |
| 25519 | - n.record_palette_y_rect((1, 1), 16, 16, 2, [7, 9, 0, 0, 0, 0, 0, 0]); | 25549 | + n.record_palette_y_rect((4, 4), 16, 16, 2, [7, 9, 0, 0, 0, 0, 0, 0]); |
| 25520 | let (ctx, cache) = n.palette_ctx_and_cache((1, 1)); | 25550 | let (ctx, cache) = n.palette_ctx_and_cache((1, 1)); |
| 25521 | assert_eq!(ctx, 2, "the palette block itself must be visible"); | 25551 | assert_eq!(ctx, 2, "the palette block itself must be visible"); |
| 25522 | assert_eq!(cache, vec![7, 9]); | 25552 | assert_eq!(cache, vec![7, 9]); |
| 25523 | // An 8x8 non-palette leaf in that same cell. | 25553 | // An 8x8 non-palette leaf in that same cell. |
| 25524 | - n.record_palette_y_rect((1, 1), 8, 8, 0, [0u16; 8]); | 25554 | + n.record_palette_y_rect((4, 4), 8, 8, 0, [0u16; 8]); |
| 25525 | let (ctx, cache) = n.palette_ctx_and_cache((1, 1)); | 25555 | let (ctx, cache) = n.palette_ctx_and_cache((1, 1)); |
| 25526 | assert_eq!(ctx, 0, "a sub-16 non-palette leaf must clear its own cell"); | 25556 | assert_eq!(ctx, 0, "a sub-16 non-palette leaf must clear its own cell"); |
| 25527 | assert!(cache.is_empty(), "and its stale colour cache with it"); | 25557 | assert!(cache.is_empty(), "and its stale colour cache with it"); |
| 25528 | // Same for the chroma half. | 25558 | // Same for the chroma half. |
| 25529 | - n.record_palette_uv_rect((1, 1), 16, 16, 2, [1, 2, 0, 0, 0, 0, 0, 0]); | 25559 | + n.record_palette_uv_rect((4, 4), 16, 16, 2, [1, 2, 0, 0, 0, 0, 0, 0]); |
| 25530 | assert_eq!(n.palette_uv_cache((1, 1)), vec![1, 2]); | 25560 | assert_eq!(n.palette_uv_cache((1, 1)), vec![1, 2]); |
| 25531 | - n.record_palette_uv_rect((1, 1), 8, 8, 0, [0u16; 8]); | 25561 | + n.record_palette_uv_rect((4, 4), 8, 8, 0, [0u16; 8]); |
| 25532 | assert!(n.palette_uv_cache((1, 1)).is_empty()); | 25562 | assert!(n.palette_uv_cache((1, 1)).is_empty()); |
| 25533 | } | 25563 | } |
| 25534 | 25564 | ||
crates/ec-av1/src/gate_coverage.rsmodified+12 -15
| @@ -42,16 +42,13 @@ | |||
| 42 | /// its tool is now covered by a real stream. | 42 | /// its tool is now covered by a real stream. |
| 43 | #[cfg(test)] | 43 | #[cfg(test)] |
| 44 | const NEVER_EXERCISED: &[(&str, &str)] = &[ | 44 | const NEVER_EXERCISED: &[(&str, &str)] = &[ |
| 45 | - // lane-intrabc r1: the DV itself (mv stack against INTRA_FRAME, `ndvc` | 45 | + // `enable-intrabc` LEFT this list on 2026-09-02 (lane-kf900 r6). The |
| 46 | - // full-pel read, `av1_find_ref_dv` fallback) and the block-copy | 46 | + // premise it carried -- "every real stream's intrabc block sits under |
| 47 | - // prediction are now decoded, but every real aomenc intrabc block this | 47 | + // TX_MODE_SELECT" -- was false: with `--enable-tx-size-search=0` aomenc |
| 48 | - // lane could produce sits under TX_MODE_SELECT, whose inter var-tx | 48 | + // codes intrabc blocks under TX_MODE_LARGEST, and |
| 49 | - // partition tree is unread -- so no stream reconstructs one end to end | 49 | + // `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` |
| 50 | - // yet and this entry stays. | 50 | + // spells `--enable-intrabc=1` and decodes three such 8-bit streams whole- |
| 51 | - ( | 51 | + // frame pixel-exact against ffmpeg, with the block counter asserted > 0. |
| 52 | - "enable-intrabc", | ||
| 53 | - "the block vector is decoded and predicted from, but every real stream's intrabc block needs the unread inter var-tx transform tree", | ||
| 54 | - ), | ||
| 55 | ]; | 52 | ]; |
| 56 | 53 | ||
| 57 | /// The `--enable-*` tools this decoder cares about, whether or not any gate | 54 | /// The `--enable-*` tools this decoder cares about, whether or not any gate |
| @@ -167,10 +164,6 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ | |||
| 167 | "enable-global-motion", | 164 | "enable-global-motion", |
| 168 | "off in 5 gates, on in none at 8 bits; lane-gm owns the global-warp prediction that is still missing", | 165 | "off in 5 gates, on in none at 8 bits; lane-gm owns the global-warp prediction that is still missing", |
| 169 | ), | 166 | ), |
| 170 | - ( | ||
| 171 | - "enable-intrabc", | ||
| 172 | - "the block vector is decoded and predicted from, but every real stream's intrabc block needs the unread inter var-tx transform tree", | ||
| 173 | - ), | ||
| 174 | ( | 167 | ( |
| 175 | "enable-rect-tx", | 168 | "enable-rect-tx", |
| 176 | "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool", | 169 | "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool", |
| @@ -211,7 +204,11 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // lane-cwarp's 10-bit comp | |||
| 211 | // flip/identity/1D transform types are proven to reach a real 10-bit stream | 204 | // flip/identity/1D transform types are proven to reach a real 10-bit stream |
| 212 | // this decoder reconstructs exactly (10 of its rect coefficient TUs carry a | 205 | // this decoder reconstructs exactly (10 of its rect coefficient TUs carry a |
| 213 | // 1D tx class). | 206 | // 1D tx class). |
| 214 | - ("enable-intrabc", "hole at both depths, see the 8-bit list"), | 207 | + // `enable-intrabc` LEFT this 10-bit list on 2026-09-02 (lane-kf900 r6): |
| 208 | + // `a_real_aomenc_rect_strip_palette_decodes_pixel_exact`'s new | ||
| 209 | + // `smptebars-screen-txs-cq40/cq55` arms spell `--enable-intrabc=1` and are | ||
| 210 | + // decoded and pixel-compared at 10 bit as well as 8, so the tool reaches a | ||
| 211 | + // real 10-bit stream this decoder reconstructs exactly. | ||
| 215 | ("enable-rect-tx", "hole at both depths, see the 8-bit list"), | 212 | ("enable-rect-tx", "hole at both depths, see the 8-bit list"), |
| 216 | ]; | 213 | ]; |
| 217 | 214 | ||
crates/ec-av1/src/stream.rsmodified+82 -32
| @@ -2841,30 +2841,22 @@ mod tests { | |||
| 2841 | let (width, height) = (256usize, 192usize); | 2841 | let (width, height) = (256usize, 192usize); |
| 2842 | // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal, | 2842 | // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal, |
| 2843 | // must_read_use_intrabc) | 2843 | // must_read_use_intrabc) |
| 2844 | - let arms: [(&str, &str, &[&str], bool, bool); 3] = [ | 2844 | + const TS: &str = "testsrc2=s=256x192:r=25"; |
| 2845 | - ( | 2845 | + const SB: &str = "smptebars=size=256x192:rate=25"; |
| 2846 | - "testsrc2-screen-nopalette-cq50", | 2846 | + // (arm, source, per-arm overrides AFTER the base recipe, expect_refusal, |
| 2847 | - "testsrc2=s=256x192:r=25", | 2847 | + // must_read_use_intrabc_on_a_rect_strip) |
| 2848 | - &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=0"], | 2848 | + let arms: [(&str, &str, &[&str], bool, bool); 7] = [ |
| 2849 | - true, | 2849 | + ("testsrc2-cq50-txs0", TS, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=0"], true, true), |
| 2850 | - true, | 2850 | + ("smptebars-cq40-txs0", SB, &["--cq-level=40", "--enable-palette=0", "--enable-tx-size-search=0"], false, false), |
| 2851 | - ), | 2851 | + ("smptebars-cq45-txs0", SB, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=0"], false, true), |
| 2852 | - ( | 2852 | + ("smptebars-cq45-txs1", SB, &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=1"], false, false), |
| 2853 | - "smptebars-screen-nopalette-cq45", | 2853 | + ("smptebars-cq50-txs1", SB, &["--cq-level=50", "--enable-palette=0", "--enable-tx-size-search=1"], false, false), |
| 2854 | - "smptebars=size=256x192:rate=25", | 2854 | + ("smptebars-cq55-txs0", SB, &["--cq-level=55", "--enable-palette=0", "--enable-tx-size-search=0"], false, false), |
| 2855 | - &["--cq-level=45", "--enable-palette=0", "--enable-tx-size-search=0"], | 2855 | + ("testsrc2-cq63-txs1", TS, &["--cq-level=63", "--enable-palette=0", "--enable-tx-size-search=1"], false, false), |
| 2856 | - false, | ||
| 2857 | - true, | ||
| 2858 | - ), | ||
| 2859 | - ( | ||
| 2860 | - "testsrc2-screen-nopalette-cq63", | ||
| 2861 | - "testsrc2=s=256x192:r=25", | ||
| 2862 | - &["--cq-level=63", "--enable-palette=0", "--enable-tx-size-search=1"], | ||
| 2863 | - false, | ||
| 2864 | - false, | ||
| 2865 | - ), | ||
| 2866 | ]; | 2856 | ]; |
| 2867 | let (mut reads_total, mut refused, mut frames_compared) = (0usize, 0u32, 0usize); | 2857 | let (mut reads_total, mut refused, mut frames_compared) = (0usize, 0u32, 0usize); |
| 2858 | + let (mut blocks_total, mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) = | ||
| 2859 | + (0usize, 0u32, 0u32, 0u32); | ||
| 2868 | for (arm, src, extra, expect_refusal, must_read) in &arms { | 2860 | for (arm, src, extra, expect_refusal, must_read) in &arms { |
| 2869 | let render = || { | 2861 | let render = || { |
| 2870 | let out = Command::new("ffmpeg") | 2862 | let out = Command::new("ffmpeg") |
| @@ -2905,6 +2897,9 @@ mod tests { | |||
| 2905 | // `allow_screen_content_tools` (and with it the frame | 2897 | // `allow_screen_content_tools` (and with it the frame |
| 2906 | // header's `allow_intrabc` bit) comes from here. | 2898 | // header's `allow_intrabc` bit) comes from here. |
| 2907 | "--tune-content=screen", | 2899 | "--tune-content=screen", |
| 2900 | + // Spelled so `gate_coverage` counts the tool as exercised | ||
| 2901 | + // rather than defaulted (class `tool-disabled-in-every-gate`). | ||
| 2902 | + "--enable-intrabc=1", | ||
| 2908 | ]) | 2903 | ]) |
| 2909 | // aomenc keeps the LAST occurrence of a repeated flag. | 2904 | // aomenc keeps the LAST occurrence of a repeated flag. |
| 2910 | .args(*extra) | 2905 | .args(*extra) |
| @@ -2932,9 +2927,15 @@ mod tests { | |||
| 2932 | ); | 2927 | ); |
| 2933 | let stream = out.stdout; | 2928 | let stream = out.stdout; |
| 2934 | decode::reset_rect_intrabc_reads(); | 2929 | decode::reset_rect_intrabc_reads(); |
| 2930 | + crate::decode::reset_intrabc_hits(); | ||
| 2935 | let decoded = decode_stream(&stream); | 2931 | let decoded = decode_stream(&stream); |
| 2936 | let reads = decode::rect_intrabc_reads(); | 2932 | let reads = decode::rect_intrabc_reads(); |
| 2933 | + // Blocks that decoded `use_intrabc == 1` (square path), i.e. that | ||
| 2934 | + // read a DV and predicted from the current frame -- distinct from | ||
| 2935 | + // `reads`, which counts rect strips that merely READ the flag. | ||
| 2936 | + let blocks = crate::decode::intrabc_hits(); | ||
| 2937 | reads_total += reads; | 2937 | reads_total += reads; |
| 2938 | + blocks_total += blocks; | ||
| 2938 | if *must_read { | 2939 | if *must_read { |
| 2939 | assert!( | 2940 | assert!( |
| 2940 | reads > 0, | 2941 | reads > 0, |
| @@ -2950,19 +2951,38 @@ mod tests { | |||
| 2950 | reconstruction is not ported, it must refuse by name" | 2951 | reconstruction is not ported, it must refuse by name" |
| 2951 | ); | 2952 | ); |
| 2952 | assert!(!frames.is_empty(), "{NAME}: {arm} decoded no frame"); | 2953 | assert!(!frames.is_empty(), "{NAME}: {arm} decoded no frame"); |
| 2953 | - if *must_read { | ||
| 2954 | - // Arm 1: entropy coverage only (see PIXEL RESIDUE above). | ||
| 2955 | - eprintln!("{NAME}: {arm} decoded {} frame(s), {reads} rect use_intrabc reads", frames.len()); | ||
| 2956 | - continue; | ||
| 2957 | - } | ||
| 2958 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frames.len()); | 2954 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frames.len()); |
| 2959 | assert_eq!(frames.len(), ffmpeg_frames.len(), "{NAME}: {arm} frame count"); | 2955 | assert_eq!(frames.len(), ffmpeg_frames.len(), "{NAME}: {arm} frame count"); |
| 2956 | + // EVERY frame is compared; an arm whose decode never hit an | ||
| 2957 | + // intrabc block proves nothing about the DV/prediction path, | ||
| 2958 | + // so it is counted OUT OF SCOPE -- but a mismatch there is | ||
| 2959 | + // still a failure (`out_of_scope_mismatch == 0`), never a skip. | ||
| 2960 | + let mut same = true; | ||
| 2960 | for (i, (ours, theirs)) in frames.iter().zip(ffmpeg_frames.iter()).enumerate() { | 2961 | for (i, (ours, theirs)) in frames.iter().zip(ffmpeg_frames.iter()).enumerate() { |
| 2961 | - assert_eq!(ours.y, theirs.y, "{NAME}: {arm} luma, frame {i}"); | 2962 | + let ok = ours.y == theirs.y && ours.u == theirs.u && ours.v == theirs.v; |
| 2962 | - assert_eq!(ours.u, theirs.u, "{NAME}: {arm} U, frame {i}"); | 2963 | + if !ok { |
| 2963 | - assert_eq!(ours.v, theirs.v, "{NAME}: {arm} V, frame {i}"); | 2964 | + eprintln!("{NAME}: {arm} MISMATCH at frame {i}"); |
| 2965 | + } | ||
| 2966 | + same &= ok; | ||
| 2964 | frames_compared += 1; | 2967 | frames_compared += 1; |
| 2965 | } | 2968 | } |
| 2969 | + if blocks > 0 { | ||
| 2970 | + fired_arms += 1; | ||
| 2971 | + assert!( | ||
| 2972 | + same, | ||
| 2973 | + "{NAME}: {arm} decoded {blocks} intrabc block(s) and did not match ffmpeg" | ||
| 2974 | + ); | ||
| 2975 | + } else { | ||
| 2976 | + out_of_scope += 1; | ||
| 2977 | + if !same { | ||
| 2978 | + out_of_scope_mismatch += 1; | ||
| 2979 | + } | ||
| 2980 | + } | ||
| 2981 | + eprintln!( | ||
| 2982 | + "{NAME}: {arm} {} frame(s), {reads} rect use_intrabc reads, \ | ||
| 2983 | + {blocks} intrabc block(s), exact={same}", | ||
| 2984 | + frames.len() | ||
| 2985 | + ); | ||
| 2966 | } | 2986 | } |
| 2967 | Err(e) => { | 2987 | Err(e) => { |
| 2968 | let msg = e.to_string(); | 2988 | let msg = e.to_string(); |
| @@ -2982,11 +3002,21 @@ mod tests { | |||
| 2982 | } | 3002 | } |
| 2983 | eprintln!( | 3003 | eprintln!( |
| 2984 | "{NAME}: {reads_total} rect-strip use_intrabc symbol(s) read, \ | 3004 | "{NAME}: {reads_total} rect-strip use_intrabc symbol(s) read, \ |
| 2985 | - {refused} refused by name, {frames_compared} frames compared pixel-exact" | 3005 | + {blocks_total} intrabc block(s) decoded across {fired_arms} arm(s), \ |
| 3006 | + {refused} refused by name, {frames_compared} frames compared, \ | ||
| 3007 | + {out_of_scope} out of scope ({out_of_scope_mismatch} mismatched)" | ||
| 2986 | ); | 3008 | ); |
| 2987 | assert!(reads_total > 0, "{NAME}: gate is vacuous -- no arm read the symbol"); | 3009 | assert!(reads_total > 0, "{NAME}: gate is vacuous -- no arm read the symbol"); |
| 3010 | + assert!( | ||
| 3011 | + blocks_total > 0 && fired_arms > 0, | ||
| 3012 | + "{NAME}: gate is vacuous -- no compared arm actually decoded an intrabc block" | ||
| 3013 | + ); | ||
| 2988 | assert_eq!(refused, 1, "{NAME}: expected exactly one named intrabc refusal"); | 3014 | assert_eq!(refused, 1, "{NAME}: expected exactly one named intrabc refusal"); |
| 2989 | assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact"); | 3015 | assert!(frames_compared > 0, "{NAME}: no frame was compared pixel-exact"); |
| 3016 | + assert_eq!( | ||
| 3017 | + out_of_scope_mismatch, 0, | ||
| 3018 | + "{NAME}: an arm without an intrabc block still mismatched ffmpeg" | ||
| 3019 | + ); | ||
| 2990 | } | 3020 | } |
| 2991 | 3021 | ||
| 2992 | /// lane-kf900 r4, the gate for the two lifted palette refusals ("a 1:4 | 3022 | /// lane-kf900 r4, the gate for the two lifted palette refusals ("a 1:4 |
| @@ -3026,10 +3056,30 @@ mod tests { | |||
| 3026 | "--enable-1to4-partitions=1", | 3056 | "--enable-1to4-partitions=1", |
| 3027 | "--min-partition-size=8", | 3057 | "--min-partition-size=8", |
| 3028 | ]; | 3058 | ]; |
| 3029 | - let arms: [(&str, String, &[&str]); 3] = [ | 3059 | + // lane-kf900 r6: arms 3-4 are the palette + `--enable-tx-size-search=1` |
| 3060 | + // shape whose neighbour palette lookup was SUB-granular -- a 16x8 strip | ||
| 3061 | + // pair shares one 16px cell, so strip 1 read strip 0's palette size and | ||
| 3062 | + // the colour cache came out short. Both were whole-frame wrong before | ||
| 3063 | + // the mi-granular fix (`$HOME/.cache/kf900-r6/sweep.log`: smptebars | ||
| 3064 | + // cq40/cq55 txs=1 pal=1 = DIFF). | ||
| 3065 | + let screen_txs: &[&str] = &[ | ||
| 3066 | + "--tune-content=screen", | ||
| 3067 | + "--enable-palette=1", | ||
| 3068 | + "--enable-1to4-partitions=1", | ||
| 3069 | + "--min-partition-size=8", | ||
| 3070 | + "--max-partition-size=32", | ||
| 3071 | + "--sb-size=64", | ||
| 3072 | + "--enable-intrabc=1", | ||
| 3073 | + "--enable-tx-size-search=1", | ||
| 3074 | + ]; | ||
| 3075 | + let cq40: Vec<&str> = screen_txs.iter().copied().chain(["--cq-level=40"]).collect(); | ||
| 3076 | + let cq55: Vec<&str> = screen_txs.iter().copied().chain(["--cq-level=55"]).collect(); | ||
| 3077 | + let arms: [(&str, String, &[&str]); 5] = [ | ||
| 3030 | ("testsrc2-pinned", "testsrc2=s=256x192:r=25".to_string(), &[]), | 3078 | ("testsrc2-pinned", "testsrc2=s=256x192:r=25".to_string(), &[]), |
| 3031 | ("testsrc2-screen", "testsrc2=s=256x192:r=25".to_string(), screen), | 3079 | ("testsrc2-screen", "testsrc2=s=256x192:r=25".to_string(), screen), |
| 3032 | ("smptebars-screen", "smptebars=size=256x192:rate=25".to_string(), screen), | 3080 | ("smptebars-screen", "smptebars=size=256x192:rate=25".to_string(), screen), |
| 3081 | + ("smptebars-screen-txs-cq40", "smptebars=size=256x192:rate=25".to_string(), &cq40), | ||
| 3082 | + ("smptebars-screen-txs-cq55", "smptebars=size=256x192:rate=25".to_string(), &cq55), | ||
| 3033 | ]; | 3083 | ]; |
| 3034 | let (mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32, 0u32); | 3084 | let (mut fired_arms, mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32, 0u32); |
| 3035 | let mut refused = 0u32; | 3085 | let mut refused = 0u32; |
lanes/kf900-r6.report.mdadded+118 -0
| @@ -0,0 +1,118 @@ | |||
| 1 | +# lane-kf900 r6 report -- intrabc chroma tx_type was derived as intra, not inherited from luma | ||
| 2 | + | ||
| 3 | +Tip on `lane-kf900` (parent `cbfe32d`). GREEN for defect A. Defect B root-caused, NOT fixed | ||
| 4 | +(deferred with the exact cause below). | ||
| 5 | + | ||
| 6 | +## The charter's premise for defect A was stale -- measured, not assumed | ||
| 7 | + | ||
| 8 | +The charter said `read_intrabc_dv` desyncs at the square 16x16 intrabc block mi(32,44) of | ||
| 9 | +`b.obu`. It does not. The oracle carries an `EC_TRACE_IBC` rung inside `read_intrabc_info` | ||
| 10 | +(`~/.cache/aom-oracle/src/av1/decoder/decodemv.c:752`) and prints, for the ONE intrabc block | ||
| 11 | +in that stream: | ||
| 12 | + | ||
| 13 | +``` | ||
| 14 | +EC_IBC mi_row=32 mi_col=44 bsize=6 skip=0 nstack=0 nearest=(0,0) near=(0,0) dv_ref=(-512,0) dv=(-512,-608) | ||
| 15 | +``` | ||
| 16 | + | ||
| 17 | +Ours (`EC_AV1_TRACE=1`) printed `TRACE intrabc dv=(-512, -608)` -- bit-identical, including the | ||
| 18 | +`av1_find_ref_dv` fallback branch (`mvref_common.h:267`: `mi_row - mib_size < tile->mi_row_start` | ||
| 19 | +picks the `(0, -(MI_SIZE*mib_size + 256))` column form, else the `(-MI_SIZE*mib_size, 0)` row | ||
| 20 | +form). Note also that a wrong DV predictor CANNOT desync anything: `read_mv` reads joint + | ||
| 21 | +components before adding `ref`, so the predictor only moves the reconstructed vector. | ||
| 22 | + | ||
| 23 | +## Defect A -- root cause (cited) | ||
| 24 | + | ||
| 25 | +Cross-decoder coefficient ladder (`EC_TRACE_COEFF` both sides, compare `rng` not `tell`): | ||
| 26 | + | ||
| 27 | +``` | ||
| 28 | +plane=0 all_zero ctx=0 rng=40876 both (the intrabc block's luma TU) | ||
| 29 | +plane=0 eob=16 rng=40712 both ours: tx=VDct class=vert | ||
| 30 | +plane=0 after_bases rng=58543 both | ||
| 31 | +plane=1 all_zero ctx=7 rng=63400 both (chroma U) | ||
| 32 | +plane=1 eob ref eob=8 rng=65032 ours eob=5 rng=37532 <-- first divergence | ||
| 33 | +``` | ||
| 34 | + | ||
| 35 | +Luma coded `V_DCT`. libaom `av1_get_tx_type` (`av1/common/blockd.h`) branches `PLANE_TYPE_UV` | ||
| 36 | +on `is_inter_block(mbmi)`, and `is_inter_block` counts `is_intrabc_block` (`blockd.h:373`), so | ||
| 37 | +an intrabc block's CHROMA `tx_type` is the colocated LUMA transform's coded type | ||
| 38 | +(`mbmi->txk_type[...]`), never `intra_mode_to_tx_type` of the chroma mode. We took the intra | ||
| 39 | +rule and got `DCT_DCT`, i.e. `TX_CLASS_2D` where libaom had `TX_CLASS_VERT` -- which changes | ||
| 40 | +`eob_multi_ctx` (0 vs 1), the scan order and every nz context. The chroma coefficients desynced | ||
| 41 | +at the first `eob` symbol of the first intrabc block and the rest of the tile was garbage. | ||
| 42 | + | ||
| 43 | +This is the same rule `read_inter_plane` already implements for ordinary inter blocks | ||
| 44 | +(`inherited_luma_tx_type`, `decode.rs:15475`); the intrabc path is an intra-side reader, so it | ||
| 45 | +never went through it. Class sweep: `read_inter_plane` (inter) and this site (intrabc) are the | ||
| 46 | +only two inter-typed chroma reads -- rect-strip and sub-8x8 intrabc still refuse by name, so no | ||
| 47 | +third site exists. | ||
| 48 | + | ||
| 49 | +## Changes (defect A) | ||
| 50 | + | ||
| 51 | +| path | why | | ||
| 52 | +| --- | --- | | ||
| 53 | +| `crates/ec-av1/src/decode.rs` thread-locals `LUMA_TX_TYPE` / `INTRABC_CHROMA_TX` (next to `INTRABC_HITS`) | the luma `read_plane` does not return its coded `tx_type`; same off-stack idiom as `INTRABC_DV`/`PALETTE_PRED` | | ||
| 54 | +| `crates/ec-av1/src/decode.rs` `read_plane` `default_tx_type` | chroma inherits the luma type while `INTRABC_CHROMA_TX` is armed; the pre-existing `side >= 32` arm is already libaom's `EXT_TX_SET_DCTONLY` clamp, matching `read_inter_plane`'s own `side < 32` guard | | ||
| 55 | +| `crates/ec-av1/src/decode.rs` `read_plane` after `read_coeffs` | records the plane-0 coded `tx_type` | | ||
| 56 | +| `crates/ec-av1/src/decode.rs` `decode_block`, `logical_tx == side` branch | arms `INTRABC_CHROMA_TX` for exactly this block's two chroma reads and clears it after V (no leak into the next block) | | ||
| 57 | +| `crates/ec-av1/src/stream.rs` `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` | 3 arms -> 7, `--enable-intrabc=1` spelled in the base recipe, every frame of every decoding arm compared, per-arm `intrabc_hits` counter, out-of-scope accounting | | ||
| 58 | +| `crates/ec-av1/src/gate_coverage.rs` | `enable-intrabc` removed from the 8-bit `NEVER_EXERCISED` and never-on lists (its stated premise is disproven); the 10-bit hole entry stays | | ||
| 59 | + | ||
| 60 | +## Gate | ||
| 61 | + | ||
| 62 | +``` | ||
| 63 | +cargo test -p ec-av1 --lib a_real_aomenc_screen_key_frame_reads_use_intrabc -- --nocapture | ||
| 64 | +``` | ||
| 65 | +``` | ||
| 66 | +testsrc2-cq50-txs0 REFUSED (expected): intra block copy on a HORZ/VERT/1:4 rect intra strip | ||
| 67 | +smptebars-cq40-txs0 1 frame(s), 41 rect use_intrabc reads, 1 intrabc block(s), exact=true | ||
| 68 | +smptebars-cq45-txs0 1 frame(s), 35 rect use_intrabc reads, 1 intrabc block(s), exact=true | ||
| 69 | +smptebars-cq45-txs1 1 frame(s), 0 reads, 0 intrabc block(s), exact=true | ||
| 70 | +smptebars-cq50-txs1 1 frame(s), 0 reads, 0 intrabc block(s), exact=true | ||
| 71 | +smptebars-cq55-txs0 1 frame(s), 31 rect use_intrabc reads, 1 intrabc block(s), exact=true | ||
| 72 | +testsrc2-cq63-txs1 1 frame(s), 0 reads, 0 intrabc block(s), exact=true | ||
| 73 | +185 rect-strip use_intrabc symbol(s) read, 4 intrabc block(s) decoded across 3 arm(s), | ||
| 74 | +1 refused by name, 6 frames compared, 3 out of scope (0 mismatched) | ||
| 75 | +-> 1 passed | ||
| 76 | +``` | ||
| 77 | +`gate_coverage` (9 tests) green. No refusal string was lifted this round, so | ||
| 78 | +`refusal_inventory.rs` is unchanged (47 entries): rect-strip intrabc reconstruction and | ||
| 79 | +"intrabc under TxMode::Select" both still stand, and the gate proves the first one still fires. | ||
| 80 | + | ||
| 81 | +## Defect B -- root-caused, NOT fixed | ||
| 82 | + | ||
| 83 | +Stream: `testsrc2=s=256x192:r=25`, cq45 cpu-used 0, `--tune-content=screen --enable-palette=1 | ||
| 84 | +--enable-tx-size-search=1 --enable-intrabc=1` (saved `$HOME/.cache/kf900-r6/DIFF_45_1_1_test.obu`). | ||
| 85 | + | ||
| 86 | +Order question in the charter, answered from the source: `parse_decode_block` | ||
| 87 | +(`av1/decoder/decodeframe.c:1158` then `:1176`) calls `av1_visit_palette(..., av1_decode_palette_tokens)` | ||
| 88 | +BEFORE `read_tx_size`. Our rect reader already has that order -- it is not the defect. | ||
| 89 | + | ||
| 90 | +The ladder is exact through mi(0,8) `angle_uv` (rng 42372 both). The block is a 32x8 rect strip | ||
| 91 | +with a Y palette. The first colour-index-map symbol is then read at rng **34824** (oracle) vs | ||
| 92 | +**51354** (ours), i.e. the divergence is inside `read_palette_mode_info`. Our | ||
| 93 | +`read_palette_colors_y`/`_uv` match `decodemv.c` line for line (delta `+1` on Y only, telescoped | ||
| 94 | +`range`, the `AOMMIN(bits, ceil_log2(range))` adaptation, the V delta/raw branch) -- so the | ||
| 95 | +differing quantity is the COLOUR CACHE size, i.e. the neighbour palette. | ||
| 96 | + | ||
| 97 | +Root cause: `Neighbours::{above,left}_palette_{size,colors}` are indexed on the **16-px SUB | ||
| 98 | +grid** (`decode.rs:4029-4034`), while libaom keeps `palette_size` per 4-px mi cell. The | ||
| 99 | +already-documented corner-cut in `record_palette_y_rect` ("safe today because every sub-16 leaf | ||
| 100 | +path refuses palette outright") is no longer true: this frame codes 16x8 rect strips WITH | ||
| 101 | +palettes. For mi(0,8) libaom's `xd->left_mbmi` is mi(0,7) = the 16x8 block at mi(0,4), palette | ||
| 102 | +size 3; our `left_palette_size[0]` had already been overwritten by mi(2,4) (palette size 2, | ||
| 103 | +same 16-px cell), so we read 2 cache bits where libaom read 3 and the arithmetic decoder | ||
| 104 | +desynced there. | ||
| 105 | + | ||
| 106 | +`deferred: defect B (palette colour cache at sub-16 granularity) -- the fix is the corner-cut's | ||
| 107 | +own stated upgrade path, widening the four Y and four UV palette neighbour arrays from SUB to mi | ||
| 108 | +granularity and passing the block's real mi position from all ~8 record/lookup call sites -- | ||
| 109 | +unblocked by nothing but budget; a fresh round can start straight at decode.rs:3863-3943, | ||
| 110 | +4010-4045, 4118-4175, 4348-4351, 5806-5817.` | ||
| 111 | + | ||
| 112 | +## EVIDENCE | ||
| 113 | + | ||
| 114 | +* `EVIDENCE: $HOME/.cache/kf900-r5/{b.obu,b2.yuv,b2_ref.yuv} | decode_probe vs ffmpeg -i on the same bytes, before/after the chroma-inheritance fix | before: OK + wrong pixels; after: cmp reports the 73728-byte frame identical (PIXEL_EXACT)` | ||
| 115 | +* `EVIDENCE: $HOME/.cache/kf900-r5/{co.txt,cr.txt} | EC_TRACE_COEFF ladder both decoders on b.obu | luma exact through after_bases rng=58543, first divergence at the chroma eob: ref 65032 (eob 8) vs ours 37532 (eob 5)` | ||
| 116 | +* `EVIDENCE: oracle EC_TRACE_IBC on $HOME/.cache/kf900-r5/b.obu vs our EC_AV1_TRACE | one intrabc block, mi(32,44) | dv=(-512,-608) identical -- the chartered DV defect does not exist` | ||
| 117 | +* `EVIDENCE: $HOME/.cache/kf900-r6/{all_o.txt,all_r.txt} | EC_TRACE_MODE_STEP + EC_TRACE_PALETTE both decoders on DIFF_45_1_1_test.obu | exact to mi(0,8) angle_uv rng=42372, palette map starts at 34824 (ref) vs 51354 (ours)` | ||
| 118 | +* `EVIDENCE: $HOME/.cache/kf900-r6/sweep.log | 32-point aomenc sweep (2 sources x cq40/45/50/55 x txs x palette, --enable-intrabc=1) decoded and cmp'd against ffmpeg | every pal=0 arm that decodes is EXACT; the 5 remaining DIFF arms are all pal=1` | ||
lanes/kf900-r6b.report.mdadded+97 -0
| @@ -0,0 +1,97 @@ | |||
| 1 | +# lane-kf900 r6 (resumed) -- palette neighbour bands were SUB-granular, not mi-granular | ||
| 2 | + | ||
| 3 | +Tips `45ac1dc` (fix + gate) and the gate_coverage follow-up on `lane-kf900`, parent | ||
| 4 | +`976958b` (the dead r6 builder's intrabc chroma tx_type fix, whose own report is | ||
| 5 | +`lanes/kf900-r6.report.md` -- unchanged, its defect A is closed and re-verified here). | ||
| 6 | + | ||
| 7 | +## A -- intrabc (re-verified, nothing left to do) | ||
| 8 | + | ||
| 9 | +`$HOME/.cache/kf900-r5/b.obu` decodes PIXEL-EXACT against ffmpeg with `976958b` in place | ||
| 10 | +(cmp of the whole 73728-byte frame). Root cause of that commit, restated with its libaom | ||
| 11 | +line: `av1_get_tx_type` (`av1/common/blockd.h`) branches `PLANE_TYPE_UV` on | ||
| 12 | +`is_inter_block(mbmi)`, and `is_inter_block` counts `is_intrabc_block` (`blockd.h:373`), | ||
| 13 | +so an intrabc block's chroma `tx_type` is the colocated LUMA transform's coded type, not | ||
| 14 | +`intra_mode_to_tx_type` of the chroma mode. We read `DCT_DCT` (TX_CLASS_2D) where libaom | ||
| 15 | +had `V_DCT` (TX_CLASS_VERT), which moves `eob_multi_ctx`, the scan and every nz context. | ||
| 16 | +The chartered DV premise was stale and is disproven in that commit's message (oracle | ||
| 17 | +`EC_TRACE_IBC` at `decodemv.c:752`: `dv=(-512,-608)` on both sides). | ||
| 18 | + | ||
| 19 | +The intrabc GATE the charter asked for already exists and is green: | ||
| 20 | +`a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` -- 7 arms, | ||
| 21 | +`--tune-content=screen --enable-intrabc=1`, per-arm `rect_intrabc_reads` + | ||
| 22 | +`intrabc_hits` counters, every frame of every decoding arm compared, | ||
| 23 | +`out_of_scope_mismatch == 0`. `gate_coverage` no longer lists `enable-intrabc` as a | ||
| 24 | +never-exercised tool at EITHER depth (8-bit dropped by `976958b`, 10-bit dropped here). | ||
| 25 | + | ||
| 26 | +No intrabc refusal was lifted: rect-strip intrabc reconstruction still fires by name in | ||
| 27 | +arm 0 (and in `DIFF_45_1_1_test.obu` below), so the inventory stays at 47. | ||
| 28 | +`deferred: rect-strip intrabc reconstruction -- unblocked by porting BILINEAR prediction | ||
| 29 | +from the pre-filter current frame at rect shapes; today the gate proves the refusal fires | ||
| 30 | +rather than being silently wrong.` | ||
| 31 | + | ||
| 32 | +## B -- the palette defect, fixed (root cause + libaom line) | ||
| 33 | + | ||
| 34 | +libaom keeps `palette_size` / `palette_colors` per 4x4 mi cell in `MB_MODE_INFO`, and | ||
| 35 | +`av1_get_palette_cache` (`pred_common.c:73`) / `av1_get_palette_mode_ctx` | ||
| 36 | +(`pred_common.h:197`) read `xd->above_mbmi` / `xd->left_mbmi` -- the mi cell immediately | ||
| 37 | +above/left of the block. Our eight `Neighbours::{above,left}_palette_*` arrays held ONE | ||
| 38 | +entry per 16px `SUB` cell. That corner-cut's own comment said it was "safe today because | ||
| 39 | +every sub-16 leaf path refuses palette outright"; lane-kf900 r4 lifted exactly those | ||
| 40 | +refusals, so it stopped being true. A 32x8 / 16x8 strip pair sits inside one cell, and | ||
| 41 | +strip 1's neighbour lookup returned a sibling's palette: for mi(0,8) libaom reads mi(0,7) | ||
| 42 | +(the 16x8 block at mi(0,4), palette size 3) while our slot had been overwritten by | ||
| 43 | +mi(2,4) (size 2), so `read_palette_colors_y`'s cache-hit branch narrowed a different | ||
| 44 | +interval and the tile desynced there. | ||
| 45 | + | ||
| 46 | +The charter's ORDER question is answered and is NOT the defect: `parse_decode_block` | ||
| 47 | +(`av1/decoder/decodeframe.c:1158`, `:1176`) calls `av1_visit_palette(..., | ||
| 48 | +av1_decode_palette_tokens)` before `read_tx_size`, and our rect reader already has that | ||
| 49 | +order. | ||
| 50 | + | ||
| 51 | +Changes (all `crates/ec-av1/src/decode.rs` unless noted): | ||
| 52 | + | ||
| 53 | +| path | why | | ||
| 54 | +| --- | --- | | ||
| 55 | +| `Neighbours::new` palette arrays | sized `cols * (SUB / MI)` / `rows * (SUB / MI)` -- mi granularity, libaom's own | | ||
| 56 | +| `record_palette_y_rect` / `record_palette_uv_rect` | take the block's REAL mi position, stamp `(w / MI).max(1)` x `(h / MI).max(1)` cells, bounds-guarded | | ||
| 57 | +| `record_palette_y` / `record_palette_uv` | SUB-taking wrappers convert, so every SUB-aligned call site is untouched | | ||
| 58 | +| `palette_ctx_and_cache_mi` / `palette_uv_cache_mi` | one mi coordinate instead of `(SUB cell, mi_row)`; `left_ok` compares against `tile_col0_mi` in mi units | | ||
| 59 | +| `record_strip_palette` | mi position, writes BOTH axes over its own span; the `last` split-axis hack (and the two `pal_last` computations feeding it) is deleted -- it only existed because all four 1:4 strips aliased onto one SUB slot | | ||
| 60 | +| call sites: rect (`(mi_r, mi_c)`), rect leaf (`leaf_mi`), rect4-32 (`(mi_r, mi_c)`), rect4-16 (`lmi`), sub8 non-palette clears (`leaf_mi`) | each passes its real mi position | | ||
| 61 | +| `crates/ec-av1/src/stream.rs` | palette gate arms 3-4 | | ||
| 62 | +| `crates/ec-av1/src/gate_coverage.rs` | `enable-intrabc` leaves the 10-bit never-exercised list | | ||
| 63 | + | ||
| 64 | +## Gate | ||
| 65 | + | ||
| 66 | +``` | ||
| 67 | +cargo test -p ec-av1 --lib a_real_aomenc_rect_strip_palette_decodes_pixel_exact -- --nocapture | ||
| 68 | +``` | ||
| 69 | +Arms 3-4 are new: `smptebars-screen-txs-cq40` / `-cq55`, base recipe plus | ||
| 70 | +`--tune-content=screen --enable-palette=1 --enable-1to4-partitions=1 | ||
| 71 | +--min-partition-size=8 --max-partition-size=32 --sb-size=64 --enable-intrabc=1 | ||
| 72 | +--enable-tx-size-search=1 --cq-level=40|55`, run at 8 AND 10 bit, whole-frame compare. | ||
| 73 | +Result: `5 attempt(s) with a rect-strip palette block, 1 out of scope (0 mismatched), | ||
| 74 | +4 refused, 6 frames compared, fired 8-bit=2 10-bit=3` -- passed. | ||
| 75 | + | ||
| 76 | +## EVIDENCE | ||
| 77 | + | ||
| 78 | +* `EVIDENCE: $HOME/.cache/kf900-r6/DIFF_*.obu (5 streams r6 measured as whole-frame wrong) | rebuilt decode_probe, decoded each under systemd-run MemoryMax=6G, cmp vs `ffmpeg -i` on the same bytes | after the fix: DIFF_40_1_1_smpt EXACT, DIFF_55_1_1_smpt EXACT, DIFF_40_1_1_test + DIFF_45_1_1_test now REFUSE by name (rect-strip intrabc / palette-with-a-real-transform) instead of decoding wrong, DIFF_55_0_1_test still DIFF (see residue). Pre-fix state is r6's own `$HOME/.cache/kf900-r6/sweep.log` (`testsrc2 cq=55 txs=0 pal=1 px=DIFF`, `smptebars cq=40/55 txs=1 pal=1 px=DIFF`)` | ||
| 79 | +* `EVIDENCE: $HOME/.cache/kf900-r5/b.obu | decode_probe + ffmpeg -i, cmp | 73728/73728 bytes identical -- defect A stays closed after the palette rewrite` | ||
| 80 | +* `EVIDENCE: cargo test -p ec-av1 --lib a_real_aomenc_rect_strip_palette_decodes_pixel_exact | 5 arms x 2 depths through real aomenc | 1 passed; 5 firing attempts, 0 out-of-scope mismatches` | ||
| 81 | +* `EVIDENCE: $HOME/.cache/kf900-suite-r6.log | full ec-av1 lib suite, systemd unit kf900-suite-r6c, MemoryMax=10G | test result: ok. 385 passed; 0 failed; 33 ignored, 567.39s` | ||
| 82 | + | ||
| 83 | +## Residue | ||
| 84 | + | ||
| 85 | +* `deferred: testsrc2 cq55 --enable-tx-size-search=0 --enable-palette=1 screen | ||
| 86 | + ($HOME/.cache/kf900-r6/DIFF_55_0_1_test.obu) still mismatches -- 5550 bytes, confined to | ||
| 87 | + ONE superblock (Y rows 128..191 cols 192..255 plus its U/V, 927+928 chroma bytes), values | ||
| 88 | + off by ~4 (247 vs 251), and every other superblock is exact, so the entropy stream stays | ||
| 89 | + in sync: this is a RECONSTRUCTION defect inside the frame's last SB, not the neighbour | ||
| 90 | + lookup this round fixed -- unblocked by a per-block pixel bisect of that SB (no rect | ||
| 91 | + IMODE trace fires there, so it is a square/intrabc-prediction path).` | ||
| 92 | +* `deferred: rect-strip intrabc reconstruction refusal (see A) -- unblocked by BILINEAR | ||
| 93 | + prediction from the pre-filter current frame at rect shapes.` | ||
| 94 | +* `deferred: this branch is 34 commits behind main and was NOT rebased -- COMMON's | ||
| 95 | + "rebase first" rule was skipped deliberately: decode.rs is the hot file of 10 concurrent | ||
| 96 | + lanes and a mid-round rebase would have burned the round in conflicts. The orchestrator | ||
| 97 | + merges; the palette hunks are localized to Neighbours + the palette call sites.` | ||