forge
Explore
Log in

Don't you dare go Hollow

The per-plane warp bail-out was gated on the square side, not the plane block's own width/height

Browse files at this commit

9385d73315fb0e11524a947e982449f9ea1e3d6fAhmet Kaan GümüşParent: e3f5bae
  • fix
    • the per-plane warp bail-out was gated on the square side, not the plane block's own width/height
Show full message
fix(av1): the per-plane warp bail-out was gated on the square side, not the plane block's own width/height

`av1_init_warp_params` (reconinter.c) returns before setting WARP_PRED when
the PLANE's own block is `block_width < 8 || block_height < 8`, so in 4:2:0
the chroma of any luma block narrower or shorter than 16 is predicted
translationally even while its luma warps. Every warp site gated that on
`chroma_side` (`side / 2`, the SQUARE side), which for an 8x16 or 16x8 luma
block is 8 while the real chroma block is 4x8 / 8x4 -- so we warped chroma
libaom convolves. Same shape on the luma side: a PARTITION_HORZ/VERT strip
is `write_w`x`write_h`, not `side`x`side`, so a 16x4 / 4x16 strip under
global motion warped where libaom does not.

Guards now read `write_chroma_w`/`write_chroma_h` (chroma) and
`write_w`/`write_h` (luma) at all 5 chroma and 3 luma warp call sites
(single-reference and both compound taps).

On the 2-frame 10-bit 1920x792 128-superblock cut, decode-order compare vs
the instrumented aomdec: frame 1 chroma residue U 98 / V 62 samples (11
superblocks, deltas -2..+3) -> 0, and both frames are now bit-exact
pre-filter AND post-filter (was 258 differing bytes).
crates/ec-av1/src/decode.rsmodified+24 -15
@@ -20563,7 +20563,7 @@ fn decode_inter_block(
20563 // lane-cwarp r1: this reference's own GLOBAL warp replaces the20563 // lane-cwarp r1: this reference's own GLOBAL warp replaces the
20564 // translational tap (libaom `av1_warp_plane` with20564 // translational tap (libaom `av1_warp_plane` with
20565 // `conv_params->is_compound`); the blend below is unchanged.20565 // `conv_params->is_compound`); the blend below is unchanged.
20566- if let Some(wp) = &warp0 {20566+ if let Some(wp) = warp0.as_ref().filter(|_| write_w >= 8 && write_h >= 8) {
20567 crate::warp::warp_affine_compound(20567 crate::warp::warp_affine_compound(
20568 wp, &py0.data, py0.true_width as i32, py0.true_height as i32,20568 wp, &py0.data, py0.true_width as i32, py0.true_height as i32,
20569 py0.width as i32, &mut inter0_y, px as i32, py as i32, side as i32,20569 py0.width as i32, &mut inter0_y, px as i32, py as i32, side as i32,
@@ -20590,7 +20590,7 @@ fn decode_inter_block(
20590 // lane-cwarp r1: this reference's own GLOBAL warp replaces the20590 // lane-cwarp r1: this reference's own GLOBAL warp replaces the
20591 // translational tap (libaom `av1_warp_plane` with20591 // translational tap (libaom `av1_warp_plane` with
20592 // `conv_params->is_compound`); the blend below is unchanged.20592 // `conv_params->is_compound`); the blend below is unchanged.
20593- if let Some(wp) = &warp1 {20593+ if let Some(wp) = warp1.as_ref().filter(|_| write_w >= 8 && write_h >= 8) {
20594 crate::warp::warp_affine_compound(20594 crate::warp::warp_affine_compound(
20595 wp, &py1.data, py1.true_width as i32, py1.true_height as i32,20595 wp, &py1.data, py1.true_width as i32, py1.true_height as i32,
20596 py1.width as i32, &mut inter1_y, px as i32, py as i32, side as i32,20596 py1.width as i32, &mut inter1_y, px as i32, py as i32, side as i32,
@@ -20640,7 +20640,7 @@ fn decode_inter_block(
20640 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma20640 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
20641 // block of an 8x8 luma block stays translational.20641 // block of an 8x8 luma block stays translational.
20642 if let Some(wp) = &warp0 {20642 if let Some(wp) = &warp0 {
20643- if chroma_side >= 8 {20643+ if write_chroma_w >= 8 && write_chroma_h >= 8 {
20644 crate::warp::warp_affine_compound(20644 crate::warp::warp_affine_compound(
20645 wp, &pu0.data, pu0.true_width as i32, pu0.true_height as i32,20645 wp, &pu0.data, pu0.true_width as i32, pu0.true_height as i32,
20646 pu0.width as i32, &mut inter0_u, cpx as i32, cpy as i32,20646 pu0.width as i32, &mut inter0_u, cpx as i32, cpy as i32,
@@ -20669,7 +20669,7 @@ fn decode_inter_block(
20669 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma20669 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
20670 // block of an 8x8 luma block stays translational.20670 // block of an 8x8 luma block stays translational.
20671 if let Some(wp) = &warp1 {20671 if let Some(wp) = &warp1 {
20672- if chroma_side >= 8 {20672+ if write_chroma_w >= 8 && write_chroma_h >= 8 {
20673 crate::warp::warp_affine_compound(20673 crate::warp::warp_affine_compound(
20674 wp, &pu1.data, pu1.true_width as i32, pu1.true_height as i32,20674 wp, &pu1.data, pu1.true_width as i32, pu1.true_height as i32,
20675 pu1.width as i32, &mut inter1_u, cpx as i32, cpy as i32,20675 pu1.width as i32, &mut inter1_u, cpx as i32, cpy as i32,
@@ -20714,7 +20714,7 @@ fn decode_inter_block(
20714 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma20714 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
20715 // block of an 8x8 luma block stays translational.20715 // block of an 8x8 luma block stays translational.
20716 if let Some(wp) = &warp0 {20716 if let Some(wp) = &warp0 {
20717- if chroma_side >= 8 {20717+ if write_chroma_w >= 8 && write_chroma_h >= 8 {
20718 crate::warp::warp_affine_compound(20718 crate::warp::warp_affine_compound(
20719 wp, &pv0.data, pv0.true_width as i32, pv0.true_height as i32,20719 wp, &pv0.data, pv0.true_width as i32, pv0.true_height as i32,
20720 pv0.width as i32, &mut inter0_v, cpx as i32, cpy as i32,20720 pv0.width as i32, &mut inter0_v, cpx as i32, cpy as i32,
@@ -20743,7 +20743,7 @@ fn decode_inter_block(
20743 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma20743 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
20744 // block of an 8x8 luma block stays translational.20744 // block of an 8x8 luma block stays translational.
20745 if let Some(wp) = &warp1 {20745 if let Some(wp) = &warp1 {
20746- if chroma_side >= 8 {20746+ if write_chroma_w >= 8 && write_chroma_h >= 8 {
20747 crate::warp::warp_affine_compound(20747 crate::warp::warp_affine_compound(
20748 wp, &pv1.data, pv1.true_width as i32, pv1.true_height as i32,20748 wp, &pv1.data, pv1.true_width as i32, pv1.true_height as i32,
20749 pv1.width as i32, &mut inter1_v, cpx as i32, cpy as i32,20749 pv1.width as i32, &mut inter1_v, cpx as i32, cpy as i32,
@@ -21839,19 +21839,28 @@ fn decode_inter_block(
21839 // motion_mode symbol was still read and warp_params still21839 // motion_mode symbol was still read and warp_params still
21840 // resolved. Suppress the warp, keep every symbol read.21840 // resolved. Suppress the warp, keep every symbol read.
21841 if let Some(params) = warp_params.as_ref().filter(|_| luma_scale == mc::REF_NO_SCALE) {21841 if let Some(params) = warp_params.as_ref().filter(|_| luma_scale == mc::REF_NO_SCALE) {
21842- crate::warp::warp_affine(21842+ // `av1_init_warp_params` is per PLANE: the luma plane's
21843- params, &py_ref.data, py_ref.true_width as i32, py_ref.true_height as i32,21843+ // own block is `write_w`x`write_h` (a PARTITION_HORZ/VERT
21844- py_ref.width as i32, &mut pred_y, px as i32, py as i32, side as i32,21844+ // strip is not `side`x`side`), so a strip under 8 px in
21845- side as i32, side as i32, 0, 0,21845+ // either direction keeps the translational prediction too.
21846- );21846+ if write_w >= 8 && write_h >= 8 {
21847+ crate::warp::warp_affine(
21848+ params, &py_ref.data, py_ref.true_width as i32, py_ref.true_height as i32,
21849+ py_ref.width as i32, &mut pred_y, px as i32, py as i32, side as i32,
21850+ side as i32, side as i32, 0, 0,
21851+ );
21852+ }
21847 // libaom `av1_init_warp_params` (reconinter.c): warp is21853 // libaom `av1_init_warp_params` (reconinter.c): warp is
21848 // per PLANE and bails out at `block_width < 8 ||21854 // per PLANE and bails out at `block_width < 8 ||
21849 // block_height < 8`, so a plane whose own block is under21855 // block_height < 8`, so a plane whose own block is under
21850 // 8x8 keeps the translational prediction built above --21856 // 8x8 keeps the translational prediction built above --
21851- // in 420 that is every chroma plane of a luma block below21857+ // in 420 that is every chroma plane whose own width or
21852- // 16x16 (lane-gmaffine r4: chroma-only mismatch of a few21858+ // height is under 8 -- `write_chroma_w`/`write_chroma_h`,
21853- // levels on both 8x8-leaf motion gates).21859+ // NOT the square `chroma_side` (lane-t900 r5: an 8x16 luma
21854- if chroma_side >= 8 {21860+ // block has `chroma_side == 8` but a 4x8 chroma block, so
21861+ // the square side warped chroma libaom predicts
21862+ // translationally; lane-gmaffine r4 for the 8x8 leaf).
21863+ if write_chroma_w >= 8 && write_chroma_h >= 8 {
21855 crate::warp::warp_affine(21864 crate::warp::warp_affine(
21856 params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32,21865 params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32,
21857 pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32,21866 pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32,