forge
Explore
Log in

Don't you dare go Hollow

A rect block's chroma warp was gated on the square prediction buffer's side, not the plane's block dims

Browse files at this commit

00a6ca0f62175febd968d99add3b5cebe7e0e9a9Ahmet Kaan GümüşParent: eec9297
  • fix
    • a rect block's chroma warp was gated on the square prediction buffer's side, not the plane's block dims
Show full message
fix(av1): a rect block's chroma warp was gated on the square prediction buffer's side, not the plane's block dims

libaom `av1_init_warp_params` (reconinter.c) bails out per PLANE at
`block_width < 8 || block_height < 8`, so the 8x4 / 4x8 chroma of a 16x8 /
8x16 luma block keeps the translational prediction even when the luma warps.
`decode_inter_block` allocates a SQUARE prediction buffer and tested
`chroma_side >= 8` -- the buffer's side -- so every rect block with a warp
(local or global) warped its chroma where libaom does not, and a 4-wide or
4-tall luma block warped its luma. Guard on `write_chroma_w/h` and
`write_w/h` instead (class rectchroma2 / narrow-block-sharp-kernel: dims read
off the enclosing square buffer).

Measured on the 2-frame cut of the 10-bit 3840x1608 stream (decode-order
PREFILT16 compare vs instrumented aomdec, frame 0 already exact): frame 1 goes
from 1317 wrong samples (Y 115, U 342, V 860) to 126 (Y 115, U 11, V 0).
crates/ec-av1/src/decode.rsmodified+20 -8
@@ -19829,6 +19829,16 @@ fn decode_inter_block(
1982919829 }
1983019830 _ => (write_w / 2, write_h / 2),
1983119831 };
19832+ // lane-midcut r3: `av1_init_warp_params` (libaom reconinter.c) bails per
19833+ // PLANE at `block_width < 8 || block_height < 8` -- on the block's own
19834+ // dims, not on the square prediction buffer this reader allocates. The
19835+ // `chroma_side >= 8` tests below read that buffer's side, so a RECT block
19836+ // whose chroma is 8x4 / 4x8 (a 16x8 / 8x16 luma block) warped its chroma
19837+ // where libaom keeps the translational prediction (class
19838+ // narrow-block-sharp-kernel / rectchroma2: dims read off the square
19839+ // buffer). Same for a 4-wide/4-tall luma block under a global warp.
19840+ let warp_luma_ok = write_w >= 8 && write_h >= 8;
19841+ let warp_chroma_ok = write_chroma_w >= 8 && write_chroma_h >= 8;
1983219842 if std::env::var_os("EC_MC_TRACE").is_some() {
1983319843 eprintln!("EC_IB px={px} py={py} side={side} w={write_w} h={write_h}");
1983419844 }
@@ -20583,7 +20593,7 @@ fn decode_inter_block(
2058320593 // lane-cwarp r1: this reference's own GLOBAL warp replaces the
2058420594 // translational tap (libaom `av1_warp_plane` with
2058520595 // `conv_params->is_compound`); the blend below is unchanged.
20586- if let Some(wp) = &warp0 {
20596+ if let Some(wp) = &warp0.as_ref().filter(|_| warp_luma_ok) {
2058720597 crate::warp::warp_affine_compound(
2058820598 wp, &py0.data, py0.true_width as i32, py0.true_height as i32,
2058920599 py0.width as i32, &mut inter0_y, px as i32, py as i32, side as i32,
@@ -20610,7 +20620,7 @@ fn decode_inter_block(
2061020620 // lane-cwarp r1: this reference's own GLOBAL warp replaces the
2061120621 // translational tap (libaom `av1_warp_plane` with
2061220622 // `conv_params->is_compound`); the blend below is unchanged.
20613- if let Some(wp) = &warp1 {
20623+ if let Some(wp) = &warp1.as_ref().filter(|_| warp_luma_ok) {
2061420624 crate::warp::warp_affine_compound(
2061520625 wp, &py1.data, py1.true_width as i32, py1.true_height as i32,
2061620626 py1.width as i32, &mut inter1_y, px as i32, py as i32, side as i32,
@@ -20660,7 +20670,7 @@ fn decode_inter_block(
2066020670 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
2066120671 // block of an 8x8 luma block stays translational.
2066220672 if let Some(wp) = &warp0 {
20663- if chroma_side >= 8 {
20673+ if warp_chroma_ok {
2066420674 crate::warp::warp_affine_compound(
2066520675 wp, &pu0.data, pu0.true_width as i32, pu0.true_height as i32,
2066620676 pu0.width as i32, &mut inter0_u, cpx as i32, cpy as i32,
@@ -20689,7 +20699,7 @@ fn decode_inter_block(
2068920699 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
2069020700 // block of an 8x8 luma block stays translational.
2069120701 if let Some(wp) = &warp1 {
20692- if chroma_side >= 8 {
20702+ if warp_chroma_ok {
2069320703 crate::warp::warp_affine_compound(
2069420704 wp, &pu1.data, pu1.true_width as i32, pu1.true_height as i32,
2069520705 pu1.width as i32, &mut inter1_u, cpx as i32, cpy as i32,
@@ -20734,7 +20744,7 @@ fn decode_inter_block(
2073420744 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
2073520745 // block of an 8x8 luma block stays translational.
2073620746 if let Some(wp) = &warp0 {
20737- if chroma_side >= 8 {
20747+ if warp_chroma_ok {
2073820748 crate::warp::warp_affine_compound(
2073920749 wp, &pv0.data, pv0.true_width as i32, pv0.true_height as i32,
2074020750 pv0.width as i32, &mut inter0_v, cpx as i32, cpy as i32,
@@ -20763,7 +20773,7 @@ fn decode_inter_block(
2076320773 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
2076420774 // block of an 8x8 luma block stays translational.
2076520775 if let Some(wp) = &warp1 {
20766- if chroma_side >= 8 {
20776+ if warp_chroma_ok {
2076720777 crate::warp::warp_affine_compound(
2076820778 wp, &pv1.data, pv1.true_width as i32, pv1.true_height as i32,
2076920779 pv1.width as i32, &mut inter1_v, cpx as i32, cpy as i32,
@@ -21858,7 +21868,9 @@ fn decode_inter_block(
2185821868 // prediction above when the reference is scaled, even though the
2185921869 // motion_mode symbol was still read and warp_params still
2186021870 // resolved. Suppress the warp, keep every symbol read.
21861- if let Some(params) = warp_params.as_ref().filter(|_| luma_scale == mc::REF_NO_SCALE) {
21871+ if let Some(params) =
21872+ warp_params.as_ref().filter(|_| luma_scale == mc::REF_NO_SCALE && warp_luma_ok)
21873+ {
2186221874 crate::warp::warp_affine(
2186321875 params, &py_ref.data, py_ref.true_width as i32, py_ref.true_height as i32,
2186421876 py_ref.width as i32, &mut pred_y, px as i32, py as i32, side as i32,
@@ -21871,7 +21883,7 @@ fn decode_inter_block(
2187121883 // in 420 that is every chroma plane of a luma block below
2187221884 // 16x16 (lane-gmaffine r4: chroma-only mismatch of a few
2187321885 // levels on both 8x8-leaf motion gates).
21874- if chroma_side >= 8 {
21886+ if warp_chroma_ok {
2187521887 crate::warp::warp_affine(
2187621888 params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32,
2187721889 pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32,