forge
Explore
Log in

Don't you dare go Hollow

One warp_plane_allowed() gate for the per-plane 8px bail-out, with a hit counter

Browse files at this commit

3aa99eb389eee90c1df1faf61600b3b5e7833a85Ahmet Kaan GümüşParent: d5c0a13
  • refactor
    • one warp_plane_allowed() gate for the per-plane 8px bail-out, with a hit counter
Show full message
refactor(av1): one warp_plane_allowed() gate for the per-plane 8px bail-out, with a hit counter

The five chroma and three luma warp call sites now route their
`av1_init_warp_params` bail-out through one helper that counts every
suppression, so a gate can prove a stream really carries the shape (the
square `side`/`chroma_side` can be 8 while the plane's own block is 4 wide).
No behaviour change: the conditions are the ones the previous commit
installed. Re-measured after the refactor -- the 2-frame cut stays exact on
both frames, and the 16-frame cut stays exact on decode-order frames 0..13
(14 and 15 unchanged at 14 / 24 differing bytes).
crates/ec-av1/src/decode.rsmodified+35 -8
@@ -262,6 +262,33 @@ thread_local! {
262262 static CDEF_IDX_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
263263 }
264264
265+// How many times a warp was suppressed for one PLANE because that plane's own
266+// block is narrower or shorter than 8 (`av1_init_warp_params`'s own bail-out,
267+// reconinter.c) -- the gate's proof that a stream really carries the shape,
268+// since the square `side`/`chroma_side` can be 8 or more while the plane's
269+// true block is 4 wide (an 8x16 luma block's 4x8 chroma).
270+thread_local! {
271+ static WARP_PLANE_SUPPRESS_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
272+}
273+
274+/// Current value of [`WARP_PLANE_SUPPRESS_HITS`].
275+pub(crate) fn warp_plane_suppress_hits() -> usize {
276+ WARP_PLANE_SUPPRESS_HITS.with(|c| c.get())
277+}
278+
279+/// `av1_init_warp_params` (libaom reconinter.c): warp is decided per PLANE and
280+/// bails out at `block_width < 8 || block_height < 8`, so the plane's OWN
281+/// block dimensions decide it -- never the square `side`/`chroma_side`, which
282+/// for a rectangular luma block (8x16, 16x8) or a PARTITION_HORZ/VERT strip is
283+/// bigger than the real block in one axis.
284+fn warp_plane_allowed(w: usize, h: usize) -> bool {
285+ if w >= 8 && h >= 8 {
286+ return true;
287+ }
288+ WARP_PLANE_SUPPRESS_HITS.with(|c| c.set(c.get() + 1));
289+ false
290+}
291+
265292 /// Current value of [`CDEF_IDX_HITS`].
266293 pub(crate) fn cdef_idx_hits() -> usize {
267294 CDEF_IDX_HITS.with(|c| c.get())
@@ -20563,7 +20590,7 @@ fn decode_inter_block(
2056320590 // lane-cwarp r1: this reference's own GLOBAL warp replaces the
2056420591 // translational tap (libaom `av1_warp_plane` with
2056520592 // `conv_params->is_compound`); the blend below is unchanged.
20566- if let Some(wp) = warp0.as_ref().filter(|_| write_w >= 8 && write_h >= 8) {
20593+ if let Some(wp) = warp0.as_ref().filter(|_| warp_plane_allowed(write_w, write_h)) {
2056720594 crate::warp::warp_affine_compound(
2056820595 wp, &py0.data, py0.true_width as i32, py0.true_height as i32,
2056920596 py0.width as i32, &mut inter0_y, px as i32, py as i32, side as i32,
@@ -20590,7 +20617,7 @@ fn decode_inter_block(
2059020617 // lane-cwarp r1: this reference's own GLOBAL warp replaces the
2059120618 // translational tap (libaom `av1_warp_plane` with
2059220619 // `conv_params->is_compound`); the blend below is unchanged.
20593- if let Some(wp) = warp1.as_ref().filter(|_| write_w >= 8 && write_h >= 8) {
20620+ if let Some(wp) = warp1.as_ref().filter(|_| warp_plane_allowed(write_w, write_h)) {
2059420621 crate::warp::warp_affine_compound(
2059520622 wp, &py1.data, py1.true_width as i32, py1.true_height as i32,
2059620623 py1.width as i32, &mut inter1_y, px as i32, py as i32, side as i32,
@@ -20640,7 +20667,7 @@ fn decode_inter_block(
2064020667 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
2064120668 // block of an 8x8 luma block stays translational.
2064220669 if let Some(wp) = &warp0 {
20643- if write_chroma_w >= 8 && write_chroma_h >= 8 {
20670+ if warp_plane_allowed(write_chroma_w, write_chroma_h) {
2064420671 crate::warp::warp_affine_compound(
2064520672 wp, &pu0.data, pu0.true_width as i32, pu0.true_height as i32,
2064620673 pu0.width as i32, &mut inter0_u, cpx as i32, cpy as i32,
@@ -20669,7 +20696,7 @@ fn decode_inter_block(
2066920696 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
2067020697 // block of an 8x8 luma block stays translational.
2067120698 if let Some(wp) = &warp1 {
20672- if write_chroma_w >= 8 && write_chroma_h >= 8 {
20699+ if warp_plane_allowed(write_chroma_w, write_chroma_h) {
2067320700 crate::warp::warp_affine_compound(
2067420701 wp, &pu1.data, pu1.true_width as i32, pu1.true_height as i32,
2067520702 pu1.width as i32, &mut inter1_u, cpx as i32, cpy as i32,
@@ -20714,7 +20741,7 @@ fn decode_inter_block(
2071420741 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
2071520742 // block of an 8x8 luma block stays translational.
2071620743 if let Some(wp) = &warp0 {
20717- if write_chroma_w >= 8 && write_chroma_h >= 8 {
20744+ if warp_plane_allowed(write_chroma_w, write_chroma_h) {
2071820745 crate::warp::warp_affine_compound(
2071920746 wp, &pv0.data, pv0.true_width as i32, pv0.true_height as i32,
2072020747 pv0.width as i32, &mut inter0_v, cpx as i32, cpy as i32,
@@ -20743,7 +20770,7 @@ fn decode_inter_block(
2074320770 // narrower/shorter than 8 (`block_width < 8`), so a 4x4 chroma
2074420771 // block of an 8x8 luma block stays translational.
2074520772 if let Some(wp) = &warp1 {
20746- if write_chroma_w >= 8 && write_chroma_h >= 8 {
20773+ if warp_plane_allowed(write_chroma_w, write_chroma_h) {
2074720774 crate::warp::warp_affine_compound(
2074820775 wp, &pv1.data, pv1.true_width as i32, pv1.true_height as i32,
2074920776 pv1.width as i32, &mut inter1_v, cpx as i32, cpy as i32,
@@ -21843,7 +21870,7 @@ fn decode_inter_block(
2184321870 // own block is `write_w`x`write_h` (a PARTITION_HORZ/VERT
2184421871 // strip is not `side`x`side`), so a strip under 8 px in
2184521872 // either direction keeps the translational prediction too.
21846- if write_w >= 8 && write_h >= 8 {
21873+ if warp_plane_allowed(write_w, write_h) {
2184721874 crate::warp::warp_affine(
2184821875 params, &py_ref.data, py_ref.true_width as i32, py_ref.true_height as i32,
2184921876 py_ref.width as i32, &mut pred_y, px as i32, py as i32, side as i32,
@@ -21860,7 +21887,7 @@ fn decode_inter_block(
2186021887 // block has `chroma_side == 8` but a 4x8 chroma block, so
2186121888 // the square side warped chroma libaom predicts
2186221889 // translationally; lane-gmaffine r4 for the 8x8 leaf).
21863- if write_chroma_w >= 8 && write_chroma_h >= 8 {
21890+ if warp_plane_allowed(write_chroma_w, write_chroma_h) {
2186421891 crate::warp::warp_affine(
2186521892 params, &pu_ref.data, pu_ref.true_width as i32, pu_ref.true_height as i32,
2186621893 pu_ref.width as i32, &mut pred_u, cpx as i32, cpy as i32, chroma_side as i32,