forge
Explore
Log in

Don't you dare go Hollow

S5: decode dead_code allows removed; test-only items gated with cfg(test), unused ones deleted (sclamp, W14, square txfm_partition fns)

Browse files at this commit

14126a2d38d54f07508c6aeae43948d319f8a8efAhmet Kaan GümüşParent: e456460
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+0 -8
@@ -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 }
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/key_tile.rsmodified+1 -0
@@ -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.
crates/ec-av1/src/decode/mod.rsmodified+4 -3
@@ -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,
@@ -3205,6 +3206,7 @@ fn is_smooth_mode(mode: usize) -> bool {
32053206 (crate::intra::SMOOTH_PRED as usize..=crate::intra::SMOOTH_H_PRED as usize).contains(&mode)
32063207 }
32073208
3209+#[cfg(test)]
32083210 /// Decodes the payload [`crate::tile::sb_coeff_key_frame_tile`] writes,
32093211 /// returning the picture it reconstructs to.
32103212 ///
@@ -3223,7 +3225,6 @@ fn is_smooth_mode(mode: usize) -> bool {
32233225 /// 16x16, a directional mode's angle delta other than zero, chroma-from-luma),
32243226 /// or when the tile payload runs out of the symbols this decode expects (a
32253227 /// genuinely foreign stream).
3226-#[allow(dead_code)]
32273228 // read only from the `#[cfg(test)]` gates
32283229 // Signature mirrors the spec's per-call inputs; a parameter struct would only move them.
32293230 #[allow(clippy::too_many_arguments)]