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(
19829 }19829 }
19830 _ => (write_w / 2, write_h / 2),19830 _ => (write_w / 2, write_h / 2),
19831 };19831 };
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;
19832 if std::env::var_os("EC_MC_TRACE").is_some() {19842 if std::env::var_os("EC_MC_TRACE").is_some() {
19833 eprintln!("EC_IB px={px} py={py} side={side} w={write_w} h={write_h}");19843 eprintln!("EC_IB px={px} py={py} side={side} w={write_w} h={write_h}");
19834 }19844 }
@@ -20583,7 +20593,7 @@ fn decode_inter_block(
20583 // lane-cwarp r1: this reference's own GLOBAL warp replaces the20593 // lane-cwarp r1: this reference's own GLOBAL warp replaces the
20584 // translational tap (libaom `av1_warp_plane` with20594 // translational tap (libaom `av1_warp_plane` with
20585 // `conv_params->is_compound`); the blend below is unchanged.20595 // `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) {
20587 crate::warp::warp_affine_compound(20597 crate::warp::warp_affine_compound(
20588 wp, &py0.data, py0.true_width as i32, py0.true_height as i32,20598 wp, &py0.data, py0.true_width as i32, py0.true_height as i32,
20589 py0.width as i32, &mut inter0_y, px as i32, py as i32, side as i32,20599 py0.width as i32, &mut inter0_y, px as i32, py as i32, side as i32,
@@ -20610,7 +20620,7 @@ fn decode_inter_block(
20610 // lane-cwarp r1: this reference's own GLOBAL warp replaces the20620 // lane-cwarp r1: this reference's own GLOBAL warp replaces the
20611 // translational tap (libaom `av1_warp_plane` with20621 // translational tap (libaom `av1_warp_plane` with
20612 // `conv_params->is_compound`); the blend below is unchanged.20622 // `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) {
20614 crate::warp::warp_affine_compound(20624 crate::warp::warp_affine_compound(
20615 wp, &py1.data, py1.true_width as i32, py1.true_height as i32,20625 wp, &py1.data, py1.true_width as i32, py1.true_height as i32,
20616 py1.width as i32, &mut inter1_y, px as i32, py as i32, side as i32,20626 py1.width as i32, &mut inter1_y, px as i32, py as i32, side as i32,
@@ -20660,7 +20670,7 @@ fn decode_inter_block(
20660 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma20670 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
20661 // block of an 8x8 luma block stays translational.20671 // block of an 8x8 luma block stays translational.
20662 if let Some(wp) = &warp0 {20672 if let Some(wp) = &warp0 {
20663- if chroma_side >= 8 {20673+ if warp_chroma_ok {
20664 crate::warp::warp_affine_compound(20674 crate::warp::warp_affine_compound(
20665 wp, &pu0.data, pu0.true_width as i32, pu0.true_height as i32,20675 wp, &pu0.data, pu0.true_width as i32, pu0.true_height as i32,
20666 pu0.width as i32, &mut inter0_u, cpx as i32, cpy as i32,20676 pu0.width as i32, &mut inter0_u, cpx as i32, cpy as i32,
@@ -20689,7 +20699,7 @@ fn decode_inter_block(
20689 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma20699 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
20690 // block of an 8x8 luma block stays translational.20700 // block of an 8x8 luma block stays translational.
20691 if let Some(wp) = &warp1 {20701 if let Some(wp) = &warp1 {
20692- if chroma_side >= 8 {20702+ if warp_chroma_ok {
20693 crate::warp::warp_affine_compound(20703 crate::warp::warp_affine_compound(
20694 wp, &pu1.data, pu1.true_width as i32, pu1.true_height as i32,20704 wp, &pu1.data, pu1.true_width as i32, pu1.true_height as i32,
20695 pu1.width as i32, &mut inter1_u, cpx as i32, cpy as i32,20705 pu1.width as i32, &mut inter1_u, cpx as i32, cpy as i32,
@@ -20734,7 +20744,7 @@ fn decode_inter_block(
20734 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma20744 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
20735 // block of an 8x8 luma block stays translational.20745 // block of an 8x8 luma block stays translational.
20736 if let Some(wp) = &warp0 {20746 if let Some(wp) = &warp0 {
20737- if chroma_side >= 8 {20747+ if warp_chroma_ok {
20738 crate::warp::warp_affine_compound(20748 crate::warp::warp_affine_compound(
20739 wp, &pv0.data, pv0.true_width as i32, pv0.true_height as i32,20749 wp, &pv0.data, pv0.true_width as i32, pv0.true_height as i32,
20740 pv0.width as i32, &mut inter0_v, cpx as i32, cpy as i32,20750 pv0.width as i32, &mut inter0_v, cpx as i32, cpy as i32,
@@ -20763,7 +20773,7 @@ fn decode_inter_block(
20763 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma20773 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
20764 // block of an 8x8 luma block stays translational.20774 // block of an 8x8 luma block stays translational.
20765 if let Some(wp) = &warp1 {20775 if let Some(wp) = &warp1 {
20766- if chroma_side >= 8 {20776+ if warp_chroma_ok {
20767 crate::warp::warp_affine_compound(20777 crate::warp::warp_affine_compound(
20768 wp, &pv1.data, pv1.true_width as i32, pv1.true_height as i32,20778 wp, &pv1.data, pv1.true_width as i32, pv1.true_height as i32,
20769 pv1.width as i32, &mut inter1_v, cpx as i32, cpy as i32,20779 pv1.width as i32, &mut inter1_v, cpx as i32, cpy as i32,
@@ -21858,7 +21868,9 @@ fn decode_inter_block(
21858 // prediction above when the reference is scaled, even though the21868 // prediction above when the reference is scaled, even though the
21859 // motion_mode symbol was still read and warp_params still21869 // motion_mode symbol was still read and warp_params still
21860 // resolved. Suppress the warp, keep every symbol read.21870 // 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+ {
21862 crate::warp::warp_affine(21874 crate::warp::warp_affine(
21863 params, &py_ref.data, py_ref.true_width as i32, py_ref.true_height as i32,21875 params, &py_ref.data, py_ref.true_width as i32, py_ref.true_height as i32,
21864 py_ref.width as i32, &mut pred_y, px as i32, py as i32, side as i32,21876 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(
21871 // in 420 that is every chroma plane of a luma block below21883 // in 420 that is every chroma plane of a luma block below
21872 // 16x16 (lane-gmaffine r4: chroma-only mismatch of a few21884 // 16x16 (lane-gmaffine r4: chroma-only mismatch of a few
21873 // levels on both 8x8-leaf motion gates).21885 // levels on both 8x8-leaf motion gates).
21874- if chroma_side >= 8 {21886+ if warp_chroma_ok {
21875 crate::warp::warp_affine(21887 crate::warp::warp_affine(
21876 params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32,21888 params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32,
21877 pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32,21889 pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32,