forge
Explore
Log in

Don't you dare go Hollow

Narrow the true-edge availability clamp to the reach extension only

Browse files at this commit

01cb49b6c11a8bd8f5ec02bf3d89ebb85431707cAhmet Kaan GümüşParent: f79d3fd
  • fix
    • narrow the true-edge availability clamp to the reach extension only
Show full message
fix(av1): narrow the true-edge availability clamp to the reach extension only

A block's own edge read (no `reach`) can land on a block that is legally
whole despite straddling the true frame edge (spec hasRows/hasCols, this
crate's has_half): such a block gets a real transform over its full
padded extent, not a garbage tail, and both this encoder and a real
decoder reconstruct it that way, so clamping that base read to the true
bound (mi_cols*4/mi_rows*4) was wrong -- verified by comparing against a
worktree at the prior commit: it moved the first luma mismatch in both
a_frame_round_trips_at_its_own_size (1920x1080) and
an_854x480_picture_round_trips_through_its_padding earlier in the frame
instead of fixing them, gate unchanged at 124/3/4 either way. Only a
`reach` extension (above-right/below-left) crosses into a block that may
never be coded past the true edge at all, so only that portion still
clamps to true_width/true_height; re-verified against the same baseline
worktree that this leaves the three pre-existing failures at their exact
prior mismatch positions (byte-for-byte), i.e. a true no-op for them,
while still fixing the genuine reach-based true-edge case this lane's
prior commit targeted.
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 own511+ // block's own extent straddles the true frame edge -- `has_half`
512- // origin already sits past the true edge -- only reachable through a512+ // (spec `hasRows`/`hasCols`) lets a whole block stand there, and its
513- // partition trial priced for comparison on a split this frame's513+ // full extent gets a real transform, not a garbage tail, so this
514- // straddling quadrant will go on to refuse (see514+ // 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 block537 // `a_picture_off_the_block_grid_is_refused`), never through a block
516 // this encoder actually commits. Such a block has no true-edge538 // 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`.