forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'simplify/s5' into simplify/w2

Browse files at this commit

5cb9eafcdd9fb5dd90250c71df91ee8d09544b27Ahmet Kaan GümüşParent: 2df256214126a2
crates/ec-av1/src/decode/cdef.rsmodified+1 -1
@@ -35,9 +35,9 @@ fn cdef_msb(x: i32) -> i32 {
3535 31 - x.leading_zeros() as i32
3636 }
3737
38+#[cfg(test)]
3839 /// Spec 7.15.3's `constrain`: how much of a neighbour's difference from the
3940 /// centre sample a filter tap is allowed to contribute.
40-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
4141 pub(super) fn cdef_constrain(diff: i32, threshold: i32, damping: i32) -> i32 {
4242 if threshold == 0 {
4343 return 0;
crates/ec-av1/src/decode/coeffs.rsmodified+7 -36
@@ -712,7 +712,6 @@ pub(super) struct Neighbours {
712712 pub(super) tile_col0_mi: usize,
713713 }
714714
715-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
716715 impl Neighbours {
717716 /// `cols`/`rows` are in [`SUB`] units; `mi_cols`/`mi_rows` are the frame's
718717 /// true (unpadded) size in 4x4 mode-info units.
@@ -1534,6 +1533,7 @@ impl Neighbours {
15341533 self.left_txfm.iter_mut().for_each(|t| *t = TXFM_CTX_INIT);
15351534 }
15361535
1536+ #[cfg(test)]
15371537 /// Records a block's `skip`/`is_inter`/`interp_filter` state for the next
15381538 /// block that reads it as a neighbour -- [`crate::tile`]'s
15391539 /// `record_inter`. `filter` is `[3, 3]` for an intra block (spec
@@ -1541,7 +1541,6 @@ impl Neighbours {
15411541 /// "no neighbour"). `ref_frame` is `-1` for an intra block, else the
15421542 /// `1..=7` reference it coded (lane-av1refs's `single_ref_p*_ctx` needs
15431543 /// the real value, not just `is_inter`).
1544- #[allow(dead_code)]
15451544 // read only from the `#[cfg(test)]` gates
15461545 // Signature mirrors the spec's per-call inputs; a parameter struct would only move them.
15471546 #[allow(clippy::too_many_arguments)]
@@ -1558,13 +1557,13 @@ impl Neighbours {
15581557 self.record_inter_rect(at, side, side, skip, is_inter, ref_frame, filter, skip_mode);
15591558 }
15601559
1560+ #[cfg(test)]
15611561 /// [`Self::record_inter`] with independent above (`w_sub`, [`SUB`]-grid
15621562 /// columns) / left (`h_sub`, [`SUB`]-grid rows) extents -- lane-partitions
15631563 /// r1: a true rectangular strip's above-context span (its own width) and
15641564 /// left-context span (its own height) differ, unlike every caller before
15651565 /// this round (class neighbour-votes-all-its-fields).
15661566 #[allow(clippy::too_many_arguments)]
1567- #[allow(dead_code)] // read only from the `#[cfg(test)]` gates
15681567 pub(super) fn record_inter_rect(
15691568 &mut self,
15701569 at: (usize, usize),
@@ -1653,6 +1652,7 @@ impl Neighbours {
16531652 self.left_filter[r..r + h_mi].fill(filter);
16541653 }
16551654
1655+ #[cfg(test)]
16561656 /// Overwrites [`Self::record_inter`]'s ALTREF-special-case default with
16571657 /// a real compound block's own `comp_group_idx`/`compound_idx` bits
16581658 /// (libaom `has_second_ref(mbmi)` branch of `get_comp_group_idx_context`/
@@ -1663,7 +1663,6 @@ impl Neighbours {
16631663 /// this is the one caller that actually knows it) -- so the next block's
16641664 /// [`NeighbourRef`](crate::mvstack::NeighbourRef) sees a real compound
16651665 /// neighbour instead of `record_inter`'s single-ref default.
1666- #[allow(dead_code)] // read only from the `#[cfg(test)]` gates
16671666 pub(super) fn record_compound_ctx(
16681667 &mut self,
16691668 at: (usize, usize),
@@ -1675,10 +1674,10 @@ impl Neighbours {
16751674 self.record_compound_ctx_rect(at, side, side, ref1, comp_group_idx, compound_idx);
16761675 }
16771676
1677+ #[cfg(test)]
16781678 /// [`Self::record_compound_ctx`] with independent above/left extents,
16791679 /// mirroring [`Self::record_inter_rect`] (lane-partitions r1).
16801680 #[allow(clippy::too_many_arguments)]
1681- #[allow(dead_code)] // read only from the `#[cfg(test)]` gates
16821681 pub(super) fn record_compound_ctx_rect(
16831682 &mut self,
16841683 at: (usize, usize),
@@ -3378,26 +3377,11 @@ pub(super) fn read_tx_size(
33783377 max_tx >> depth
33793378 }
33803379
3381-/// `txfm_partition_context` (libaom `av1_common_int.h`): an inter block's
3382-/// `txfm_split` context -- a category from the block's own largest square
3383-/// transform and whether this unit already sits below it, times three, plus
3384-/// the two neighbour terms (whether the transform last written above/left of
3385-/// this unit is narrower/shorter than the unit itself).
3386-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
3387-pub(super) fn txfm_partition_ctx(
3388- above_px: u8,
3389- left_px: u8,
3390- blk_max_px: usize,
3391- tx_px: usize,
3392-) -> usize {
3393- txfm_partition_ctx_rect(above_px, left_px, blk_max_px, tx_px, tx_px)
3394-}
3395-
3396-/// [`txfm_partition_ctx`] for a *rectangular* transform (lane-inter4 r2):
3380+/// `txfm_partition_context` for a *rectangular* transform (lane-inter4 r2):
33973381 /// libaom's `txfm_partition_context` compares the above context against
33983382 /// `tx_size_wide` and the left one against `tx_size_high`, and takes its
33993383 /// category from `txsize_sqr_up_map[tx_size]` -- all three collapse to one
3400-/// side for a square transform, which is why the square form above is a
3384+/// side for a square transform, which is why the square form is a
34013385 /// special case of this one.
34023386 pub(crate) fn txfm_partition_ctx_rect(
34033387 above_px: u8,
@@ -3418,20 +3402,7 @@ pub(crate) fn txfm_partition_ctx_rect(
34183402 category * 3 + above + left
34193403 }
34203404
3421-/// `txfm_partition_update` (libaom `av1_common_int.h`): once a var-tx unit
3422-/// resolves, every mi cell its *parent* unit (`txb_px`) spans records the
3423-/// resolved transform's own size.
3424-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
3425-pub(super) fn txfm_partition_update(
3426- n: &mut Neighbours,
3427- at_mi: (usize, usize),
3428- tx_px: usize,
3429- txb_px: usize,
3430-) {
3431- txfm_partition_update_rect(n, at_mi, (tx_px, tx_px), (txb_px, txb_px));
3432-}
3433-
3434-/// [`txfm_partition_update`] for a rectangular transform (lane-inter4 r2):
3405+/// `txfm_partition_update` for a rectangular transform (lane-inter4 r2):
34353406 /// the left column records `tx_size_high` over the parent's own height and
34363407 /// the above row records `tx_size_wide` over its width.
34373408 /// libaom `set_txfm_ctxs` + `txfm_partition_update` (`decodeframe.c`, end of
crates/ec-av1/src/decode/deblock.rsmodified+1 -9
@@ -15,14 +15,6 @@ fn deblock_thresholds(level: i32, sharpness: u8) -> (i32, i32, i32) {
1515 (2 * (level + 2) + lim, lim, level >> 4)
1616 }
1717
18-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
19-pub(super) fn sclamp(v: i32, fctx: &crate::decode::FrameCtx) -> i32 {
20- // libaom's `signed_char_clamp_high`: the clamp range scales with
21- // `128 << (bit_depth - 8)` alongside the centering constant below.
22- let scale = 1i32 << (bit_depth(fctx) - 8);
23- v.clamp(-128 * scale, 128 * scale - 1)
24-}
25-
2618 fn round_pow2(v: i32, n: u32) -> i32 {
2719 (v + (1 << (n - 1))) >> n
2820 }
@@ -711,7 +703,7 @@ pub(super) const SCRATCH_CAP: usize = 32;
711703 /// luma-sized allocation (every pooled buffer would drift to the largest
712704 /// size otherwise). `None` when the pool is empty.
713705 fn scratch_take(n: usize) -> Option<Vec<u16>> {
714- let mut p = PLANE_SCRATCH.lock().unwrap();
706+ let mut p = PLANE_SCRATCH.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
715707 if p.is_empty() {
716708 return None;
717709 }
crates/ec-av1/src/decode/deblock_simd.rsmodified+0 -15
@@ -96,21 +96,6 @@ const W8: [[i16; 8]; 6] = [
9696 [0, 0, 1, 1, 1, 2, 1, 2],
9797 [0, 0, 0, 1, 1, 1, 2, 3],
9898 ];
99-#[allow(dead_code)] // superseded by the running-sum rows; kept as the weights' statement
100-const W14: [[i16; 14]; 12] = [
101- [7, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0],
102- [5, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
103- [4, 1, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0],
104- [3, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0],
105- [2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0],
106- [1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 0],
107- [0, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1],
108- [0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2],
109- [0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 3],
110- [0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 1, 4],
111- [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 5],
112- [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 7],
113-];
11499
115100 /// One weighted tap sum, rounded by `shift` (3 for the divide-by-8 rows,
116101 /// 4 for `filter14`'s divide-by-16 ones). The sum is non-negative and
crates/ec-av1/src/decode/frame_tile.rsmodified+2 -1
@@ -4,6 +4,7 @@
44
55 use super::*;
66
7+#[cfg(test)]
78 /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes,
89 /// against `reference` (the previous frame's own decoded picture, at this
910 /// frame's true size -- a decoder's single-slot DPB, matching what this
@@ -17,7 +18,6 @@ use super::*;
1718 /// or when `reference` is not this frame's own true size, or when the tile
1819 /// codes a 16x16 leaf whose own true edge cuts through it (round 2, same
1920 /// refusal [`crate::tile`]'s writer gives its encoder).
20-#[allow(dead_code)]
2121 // read only from the `#[cfg(test)]` gates
2222 // Signature mirrors the spec's per-call inputs; a parameter struct would only move them.
2323 #[allow(clippy::too_many_arguments)]
@@ -88,6 +88,7 @@ pub(crate) fn decode_inter_frame_tile(
8888 )
8989 }
9090
91+#[cfg(test)]
9192 /// [`decode_inter_frame_tile`] with this frame header's own `lr_params`, the
9293 /// inter sibling of [`decode_key_frame_tile_lr`].
9394 #[allow(clippy::too_many_arguments)]
crates/ec-av1/src/decode/inter_shapes.rsmodified+0 -10
@@ -266,20 +266,10 @@ pub(crate) const INTER_BLOCK_SHAPES: [(usize, usize, usize); 18] = [
266266 (128, 64, 128),
267267 ];
268268
269-/// Bit 31 of [`inter_block_shape_mask`]: a `(side, write_w, write_h)` triple
270-/// outside [`INTER_BLOCK_SHAPES`].
271-pub const INTER_BLOCK_SHAPE_UNLISTED: u32 = 1 << 31;
272-
273269 thread_local! {
274270 pub(super) static INTER_BLOCK_SHAPE_MASK: std::cell::Cell<u32> = const { std::cell::Cell::new(0) };
275271 }
276272
277-/// Which of [`INTER_BLOCK_SHAPES`] this THREAD has decoded (thread-local, so a
278-/// gate reading it sees only the streams it decoded itself).
279-pub fn inter_block_shape_mask() -> u32 {
280- INTER_BLOCK_SHAPE_MASK.with(std::cell::Cell::get)
281-}
282-
283273 /// The luma coefficient/`tx_type` table set of a whole-block rectangular
284274 /// INTER transform unit (lane-inter4 r3). `av1_get_ext_tx_set_type` splits
285275 /// the two shapes: a 32x16/16x32 unit has `tx_size_sqr_up == TX_32X32`, so
crates/ec-av1/src/decode/key_tile.rsmodified+1 -12
@@ -2,6 +2,7 @@
22
33 use super::*;
44
5+#[cfg(test)]
56 /// [`decode_key_frame_tile`] with this frame header's own `lr_params` (spec
67 /// 5.9.20) instead of the no-restoration default -- the per-unit filters
78 /// themselves live in the tile payload, so the header is all this needs.
@@ -183,18 +184,6 @@ thread_local! {
183184 pub(crate) static MU_CHUNK_INTRA_IN_INTER_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
184185 }
185186
186-/// Current value of [`MU_CHUNK_COMPOUND_UNITS`], for a gate's before/after
187-/// delta.
188-pub fn mu_chunk_compound_units() -> usize {
189- MU_CHUNK_COMPOUND_UNITS.with(std::cell::Cell::get)
190-}
191-
192-/// Current value of [`MU_CHUNK_INTRA_IN_INTER_UNITS`], for a gate's
193-/// before/after delta.
194-pub fn mu_chunk_intra_in_inter_units() -> usize {
195- MU_CHUNK_INTRA_IN_INTER_UNITS.with(std::cell::Cell::get)
196-}
197-
198187 thread_local! {
199188 /// lane-av1h5: chunk-major chroma WALKS run for a 128-root plane block --
200189 /// one per 64x64 mu chunk. libaom codes exactly 4 per unsplit 128x128 root
crates/ec-av1/src/decode/mod.rsmodified+6 -21
@@ -79,7 +79,7 @@ mod cdef;
7979 use cdef::*;
8080
8181 mod inter_shapes;
82-pub use inter_shapes::*;
82+pub(crate) use inter_shapes::*;
8383
8484 mod deblock;
8585 pub(crate) use deblock::*;
@@ -91,7 +91,7 @@ mod replay;
9191 pub(crate) use replay::*;
9292
9393 mod key_tile;
94-pub use key_tile::*;
94+pub(crate) use key_tile::*;
9595
9696 mod inter_ctx;
9797 pub(crate) use inter_ctx::*;
@@ -126,7 +126,6 @@ pub(crate) struct FilterStages {
126126
127127 /// Takes whatever the last capturing decode left (see
128128 /// [`FrameCtx::capture_stages`]).
129-#[allow(dead_code)] // read from the encoder's loop restoration search
130129 pub(crate) fn take_filter_stages(fctx: &FrameCtx) -> Option<FilterStages> {
131130 fctx.stages.borrow_mut().take()
132131 }
@@ -391,10 +390,12 @@ use crate::cdf_state::{Cdfs, MvComponentCdfs, TxbSet, TxbTables};
391390 use crate::encode::{Picture, Reach};
392391 use crate::intra::predict;
393392 use crate::mc;
393+#[cfg(test)]
394+use crate::mvstack::NO_SIGN_BIAS;
394395 use crate::msac::SymbolDecoder;
395396 use crate::mvstack::{
396397 ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, LAST3_FRAME,
397- MiGrid, MiInfo, NO_REF1, NO_SIGN_BIAS, NeighbourRef, SignBiasTable, comp_reference_type_ctx,
398+ MiGrid, MiInfo, NO_REF1, NeighbourRef, SignBiasTable, comp_reference_type_ctx,
398399 find_mv_stack_with_sign_bias, mv16, mv32, reference_mode_ctx, single_ref_p1_ctx,
399400 single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx, single_ref_p6_ctx,
400401 uni_comp_ref_p1_ctx,
@@ -2276,11 +2277,6 @@ thread_local! {
22762277 static UV_LEFT_SS_Y_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
22772278 }
22782279
2279-/// Current value of [`UV_LEFT_SS_Y_READS`].
2280-pub fn uv_left_ss_y_reads() -> usize {
2281- UV_LEFT_SS_Y_READS.with(|c| c.get())
2282-}
2283-
22842280 // lane-av1leftwit: the per-tile epoch `uv_owner` cells are stamped with.
22852281 // Bumped in `Neighbours::start_tile`; never read by decode logic.
22862282 thread_local! {
@@ -2458,17 +2454,6 @@ thread_local! {
24582454 static CDEF_MIXED_SKIP_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
24592455 }
24602456
2461-/// Current value of `CDEF_MIXED_SKIP_UNITS`.
2462-pub fn cdef_mixed_skip_units() -> usize {
2463- CDEF_MIXED_SKIP_UNITS.with(|c| c.get())
2464-}
2465-
2466-/// How many 8x8 CDEF units [`apply_cdef`] visited whose skip band no coded
2467-/// block wrote this frame -- a writer gap, always a defect (lane-cdefstrip r1).
2468-pub fn cdef_unwritten_skip_units() -> usize {
2469- CDEF_UNWRITTEN_SKIP_UNITS.with(|c| c.get())
2470-}
2471-
24722457 // Which plane the in-flight INTRA reconstruction is writing (0=Y, 1=U, 2=V).
24732458 // lane-av1cmpaudit: aomdec's `EC_PREDOUT8`/`EC_PREDND` print `plane=`, and
24742459 // without the same field on our side an `EC_PREDOUT8` vs `OUR_PRED` diff of a
@@ -3221,6 +3206,7 @@ fn is_smooth_mode(mode: usize) -> bool {
32213206 (crate::intra::SMOOTH_PRED as usize..=crate::intra::SMOOTH_H_PRED as usize).contains(&mode)
32223207 }
32233208
3209+#[cfg(test)]
32243210 /// Decodes the payload [`crate::tile::sb_coeff_key_frame_tile`] writes,
32253211 /// returning the picture it reconstructs to.
32263212 ///
@@ -3239,7 +3225,6 @@ fn is_smooth_mode(mode: usize) -> bool {
32393225 /// 16x16, a directional mode's angle delta other than zero, chroma-from-luma),
32403226 /// or when the tile payload runs out of the symbols this decode expects (a
32413227 /// genuinely foreign stream).
3242-#[allow(dead_code)]
32433228 // read only from the `#[cfg(test)]` gates
32443229 // Signature mirrors the spec's per-call inputs; a parameter struct would only move them.
32453230 #[allow(clippy::too_many_arguments)]
crates/ec-av1/src/decode/replay.rsmodified+1 -1
@@ -395,7 +395,7 @@ pub(super) fn crop_owned(plane: PlaneBuf<'_>, w: usize, h: usize) -> Vec<u16> {
395395 /// Over [`SCRATCH_CAP`] the buffer is dropped (freed) instead -- the cap is
396396 /// what keeps a pool shared by every thread from being an unbounded stash.
397397 pub(super) fn scratch_return(v: Vec<u16>) {
398- let mut p = PLANE_SCRATCH.lock().unwrap();
398+ let mut p = PLANE_SCRATCH.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
399399 if p.len() < SCRATCH_CAP {
400400 p.push(v);
401401 }
crates/ec-av1/src/lib.rsmodified+1 -1
@@ -25,7 +25,7 @@ mod autothreads;
2525 pub mod cdf;
2626 mod cdf_state;
2727 mod compound;
28-pub mod decode;
28+mod decode;
2929 pub mod encode;
3030 pub mod encoder;
3131 #[doc(hidden)]