Narrow the true-edge availability clamp to the reach extension only
Browse files at this commit01cb49b6c11a8bd8f5ec02bf3d89ebb85431707cParent: f79d3fd- fix
- narrow the true-edge availability clamp to the reach extension only
1 changed file +28 -6
- crates/ec-av1/src/encode.rs +28 -6
crates/ec-av1/src/encode.rsmodified+28 -6
| @@ -506,12 +506,34 @@ impl Plane<'_> { | |||
| 506 | side: usize, | 506 | side: usize, |
| 507 | reach: Reach, | 507 | reach: Reach, |
| 508 | ) -> (Option<Vec<u8>>, Option<Vec<u8>>, Option<u8>) { | 508 | ) -> (Option<Vec<u8>>, Option<Vec<u8>>, Option<u8>) { |
| 509 | - let across = (x + if reach.above_right { 2 * side } else { side }).min(self.true_width); | 509 | + // A block's own edge (no `reach`) reads samples reconstructed as part |
| 510 | - let down = (y + if reach.below_left { 2 * side } else { side }).min(self.true_height); | 510 | + // of *some* legally-coded block, whole or not, even where that |
| 511 | - // `across`/`down` can fall at or below `x`/`y` for a block whose own | 511 | + // block's own extent straddles the true frame edge -- `has_half` |
| 512 | - // origin already sits past the true edge -- only reachable through a | 512 | + // (spec `hasRows`/`hasCols`) lets a whole block stand there, and its |
| 513 | - // partition trial priced for comparison on a split this frame's | 513 | + // full extent gets a real transform, not a garbage tail, so this |
| 514 | - // straddling quadrant will go on to refuse (see | 514 | + // reads no further than the padded coding surface. Only a `reach` |
| 515 | + // extension crosses into a block that may never be coded at all past | ||
| 516 | + // the true edge, so only it clamps to the true bound (`mi_cols`/ | ||
| 517 | + // `mi_rows` * 4), replicating past it same as spec 7.11.2.2's | ||
| 518 | + // `aboveLimit`/`leftLimit` clamp. | ||
| 519 | + let across = if reach.above_right { | ||
| 520 | + (x + 2 * side) | ||
| 521 | + .min(self.width) | ||
| 522 | + .min(self.true_width.max(x + side)) | ||
| 523 | + } else { | ||
| 524 | + (x + side).min(self.width) | ||
| 525 | + }; | ||
| 526 | + let down = if reach.below_left { | ||
| 527 | + (y + 2 * side) | ||
| 528 | + .min(self.height) | ||
| 529 | + .min(self.true_height.max(y + side)) | ||
| 530 | + } else { | ||
| 531 | + (y + side).min(self.height) | ||
| 532 | + }; | ||
| 533 | + // `across`/`down` can still fall at or below `x`/`y` for a sub-block | ||
| 534 | + // whose own origin already sits past the true edge -- only reachable | ||
| 535 | + // through a partition trial priced for comparison on a split this | ||
| 536 | + // frame's straddling quadrant will go on to refuse (see | ||
| 515 | // `a_picture_off_the_block_grid_is_refused`), never through a block | 537 | // `a_picture_off_the_block_grid_is_refused`), never through a block |
| 516 | // this encoder actually commits. Such a block has no true-edge | 538 | // this encoder actually commits. Such a block has no true-edge |
| 517 | // samples above or left of it at all, same as `y == 0`/`x == 0`. | 539 | // samples above or left of it at all, same as `y == 0`/`x == 0`. |