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 {
35 31 - x.leading_zeros() as i3235 31 - x.leading_zeros() as i32
36 }36 }
37 37
38+#[cfg(test)]
38 /// Spec 7.15.3's `constrain`: how much of a neighbour's difference from the39 /// Spec 7.15.3's `constrain`: how much of a neighbour's difference from the
39 /// centre sample a filter tap is allowed to contribute.40 /// centre sample a filter tap is allowed to contribute.
40-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
41 pub(super) fn cdef_constrain(diff: i32, threshold: i32, damping: i32) -> i32 {41 pub(super) fn cdef_constrain(diff: i32, threshold: i32, damping: i32) -> i32 {
42 if threshold == 0 {42 if threshold == 0 {
43 return 0;43 return 0;
crates/ec-av1/src/decode/coeffs.rsmodified+7 -36
@@ -712,7 +712,6 @@ pub(super) struct Neighbours {
712 pub(super) tile_col0_mi: usize,712 pub(super) tile_col0_mi: usize,
713 }713 }
714 714
715-#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
716 impl Neighbours {715 impl Neighbours {
717 /// `cols`/`rows` are in [`SUB`] units; `mi_cols`/`mi_rows` are the frame's716 /// `cols`/`rows` are in [`SUB`] units; `mi_cols`/`mi_rows` are the frame's
718 /// true (unpadded) size in 4x4 mode-info units.717 /// true (unpadded) size in 4x4 mode-info units.
@@ -1534,6 +1533,7 @@ impl Neighbours {
1534 self.left_txfm.iter_mut().for_each(|t| *t = TXFM_CTX_INIT);1533 self.left_txfm.iter_mut().for_each(|t| *t = TXFM_CTX_INIT);
1535 }1534 }
1536 1535
1536+ #[cfg(test)]
1537 /// Records a block's `skip`/`is_inter`/`interp_filter` state for the next1537 /// Records a block's `skip`/`is_inter`/`interp_filter` state for the next
1538 /// block that reads it as a neighbour -- [`crate::tile`]'s1538 /// block that reads it as a neighbour -- [`crate::tile`]'s
1539 /// `record_inter`. `filter` is `[3, 3]` for an intra block (spec1539 /// `record_inter`. `filter` is `[3, 3]` for an intra block (spec
@@ -1541,7 +1541,6 @@ impl Neighbours {
1541 /// "no neighbour"). `ref_frame` is `-1` for an intra block, else the1541 /// "no neighbour"). `ref_frame` is `-1` for an intra block, else the
1542 /// `1..=7` reference it coded (lane-av1refs's `single_ref_p*_ctx` needs1542 /// `1..=7` reference it coded (lane-av1refs's `single_ref_p*_ctx` needs
1543 /// the real value, not just `is_inter`).1543 /// the real value, not just `is_inter`).
1544- #[allow(dead_code)]
1545 // read only from the `#[cfg(test)]` gates1544 // read only from the `#[cfg(test)]` gates
1546 // Signature mirrors the spec's per-call inputs; a parameter struct would only move them.1545 // Signature mirrors the spec's per-call inputs; a parameter struct would only move them.
1547 #[allow(clippy::too_many_arguments)]1546 #[allow(clippy::too_many_arguments)]
@@ -1558,13 +1557,13 @@ impl Neighbours {
1558 self.record_inter_rect(at, side, side, skip, is_inter, ref_frame, filter, skip_mode);1557 self.record_inter_rect(at, side, side, skip, is_inter, ref_frame, filter, skip_mode);
1559 }1558 }
1560 1559
1560+ #[cfg(test)]
1561 /// [`Self::record_inter`] with independent above (`w_sub`, [`SUB`]-grid1561 /// [`Self::record_inter`] with independent above (`w_sub`, [`SUB`]-grid
1562 /// columns) / left (`h_sub`, [`SUB`]-grid rows) extents -- lane-partitions1562 /// columns) / left (`h_sub`, [`SUB`]-grid rows) extents -- lane-partitions
1563 /// r1: a true rectangular strip's above-context span (its own width) and1563 /// r1: a true rectangular strip's above-context span (its own width) and
1564 /// left-context span (its own height) differ, unlike every caller before1564 /// left-context span (its own height) differ, unlike every caller before
1565 /// this round (class neighbour-votes-all-its-fields).1565 /// this round (class neighbour-votes-all-its-fields).
1566 #[allow(clippy::too_many_arguments)]1566 #[allow(clippy::too_many_arguments)]
1567- #[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1568 pub(super) fn record_inter_rect(1567 pub(super) fn record_inter_rect(
1569 &mut self,1568 &mut self,
1570 at: (usize, usize),1569 at: (usize, usize),
@@ -1653,6 +1652,7 @@ impl Neighbours {
1653 self.left_filter[r..r + h_mi].fill(filter);1652 self.left_filter[r..r + h_mi].fill(filter);
1654 }1653 }
1655 1654
1655+ #[cfg(test)]
1656 /// Overwrites [`Self::record_inter`]'s ALTREF-special-case default with1656 /// Overwrites [`Self::record_inter`]'s ALTREF-special-case default with
1657 /// a real compound block's own `comp_group_idx`/`compound_idx` bits1657 /// a real compound block's own `comp_group_idx`/`compound_idx` bits
1658 /// (libaom `has_second_ref(mbmi)` branch of `get_comp_group_idx_context`/1658 /// (libaom `has_second_ref(mbmi)` branch of `get_comp_group_idx_context`/
@@ -1663,7 +1663,6 @@ impl Neighbours {
1663 /// this is the one caller that actually knows it) -- so the next block's1663 /// this is the one caller that actually knows it) -- so the next block's
1664 /// [`NeighbourRef`](crate::mvstack::NeighbourRef) sees a real compound1664 /// [`NeighbourRef`](crate::mvstack::NeighbourRef) sees a real compound
1665 /// neighbour instead of `record_inter`'s single-ref default.1665 /// neighbour instead of `record_inter`'s single-ref default.
1666- #[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1667 pub(super) fn record_compound_ctx(1666 pub(super) fn record_compound_ctx(
1668 &mut self,1667 &mut self,
1669 at: (usize, usize),1668 at: (usize, usize),
@@ -1675,10 +1674,10 @@ impl Neighbours {
1675 self.record_compound_ctx_rect(at, side, side, ref1, comp_group_idx, compound_idx);1674 self.record_compound_ctx_rect(at, side, side, ref1, comp_group_idx, compound_idx);
1676 }1675 }
1677 1676
1677+ #[cfg(test)]
1678 /// [`Self::record_compound_ctx`] with independent above/left extents,1678 /// [`Self::record_compound_ctx`] with independent above/left extents,
1679 /// mirroring [`Self::record_inter_rect`] (lane-partitions r1).1679 /// mirroring [`Self::record_inter_rect`] (lane-partitions r1).
1680 #[allow(clippy::too_many_arguments)]1680 #[allow(clippy::too_many_arguments)]
1681- #[allow(dead_code)] // read only from the `#[cfg(test)]` gates
1682 pub(super) fn record_compound_ctx_rect(1681 pub(super) fn record_compound_ctx_rect(
1683 &mut self,1682 &mut self,
1684 at: (usize, usize),1683 at: (usize, usize),
@@ -3378,26 +3377,11 @@ pub(super) fn read_tx_size(
3378 max_tx >> depth3377 max_tx >> depth
3379 }3378 }
3380 3379
3381-/// `txfm_partition_context` (libaom `av1_common_int.h`): an inter block's3380+/// `txfm_partition_context` for a *rectangular* transform (lane-inter4 r2):
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):
3397 /// libaom's `txfm_partition_context` compares the above context against3381 /// libaom's `txfm_partition_context` compares the above context against
3398 /// `tx_size_wide` and the left one against `tx_size_high`, and takes its3382 /// `tx_size_wide` and the left one against `tx_size_high`, and takes its
3399 /// category from `txsize_sqr_up_map[tx_size]` -- all three collapse to one3383 /// 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 a3384+/// side for a square transform, which is why the square form is a
3401 /// special case of this one.3385 /// special case of this one.
3402 pub(crate) fn txfm_partition_ctx_rect(3386 pub(crate) fn txfm_partition_ctx_rect(
3403 above_px: u8,3387 above_px: u8,
@@ -3418,20 +3402,7 @@ pub(crate) fn txfm_partition_ctx_rect(
3418 category * 3 + above + left3402 category * 3 + above + left
3419 }3403 }
3420 3404
3421-/// `txfm_partition_update` (libaom `av1_common_int.h`): once a var-tx unit3405+/// `txfm_partition_update` for a rectangular transform (lane-inter4 r2):
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):
3435 /// the left column records `tx_size_high` over the parent's own height and3406 /// the left column records `tx_size_high` over the parent's own height and
3436 /// the above row records `tx_size_wide` over its width.3407 /// the above row records `tx_size_wide` over its width.
3437 /// libaom `set_txfm_ctxs` + `txfm_partition_update` (`decodeframe.c`, end of3408 /// 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) {
15 (2 * (level + 2) + lim, lim, level >> 4)15 (2 * (level + 2) + lim, lim, level >> 4)
16 }16 }
17 17
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-
26 fn round_pow2(v: i32, n: u32) -> i32 {18 fn round_pow2(v: i32, n: u32) -> i32 {
27 (v + (1 << (n - 1))) >> n19 (v + (1 << (n - 1))) >> n
28 }20 }
crates/ec-av1/src/decode/deblock_simd.rsmodified+0 -15
@@ -96,21 +96,6 @@ const W8: [[i16; 8]; 6] = [
96 [0, 0, 1, 1, 1, 2, 1, 2],96 [0, 0, 1, 1, 1, 2, 1, 2],
97 [0, 0, 0, 1, 1, 1, 2, 3],97 [0, 0, 0, 1, 1, 1, 2, 3],
98 ];98 ];
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-];
114 99
115 /// One weighted tap sum, rounded by `shift` (3 for the divide-by-8 rows,100 /// One weighted tap sum, rounded by `shift` (3 for the divide-by-8 rows,
116 /// 4 for `filter14`'s divide-by-16 ones). The sum is non-negative and101 /// 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 @@
4 4
5 use super::*;5 use super::*;
6 6
7+#[cfg(test)]
7 /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes,8 /// Decodes the payload [`crate::tile::sb_coeff_inter_frame_tile`] writes,
8 /// against `reference` (the previous frame's own decoded picture, at this9 /// against `reference` (the previous frame's own decoded picture, at this
9 /// frame's true size -- a decoder's single-slot DPB, matching what this10 /// frame's true size -- a decoder's single-slot DPB, matching what this
@@ -17,7 +18,6 @@ use super::*;
17 /// or when `reference` is not this frame's own true size, or when the tile18 /// or when `reference` is not this frame's own true size, or when the tile
18 /// codes a 16x16 leaf whose own true edge cuts through it (round 2, same19 /// codes a 16x16 leaf whose own true edge cuts through it (round 2, same
19 /// refusal [`crate::tile`]'s writer gives its encoder).20 /// refusal [`crate::tile`]'s writer gives its encoder).
20-#[allow(dead_code)]
21 // read only from the `#[cfg(test)]` gates21 // read only from the `#[cfg(test)]` gates
22 // Signature mirrors the spec's per-call inputs; a parameter struct would only move them.22 // Signature mirrors the spec's per-call inputs; a parameter struct would only move them.
23 #[allow(clippy::too_many_arguments)]23 #[allow(clippy::too_many_arguments)]
@@ -88,6 +88,7 @@ pub(crate) fn decode_inter_frame_tile(
88 )88 )
89 }89 }
90 90
91+#[cfg(test)]
91 /// [`decode_inter_frame_tile`] with this frame header's own `lr_params`, the92 /// [`decode_inter_frame_tile`] with this frame header's own `lr_params`, the
92 /// inter sibling of [`decode_key_frame_tile_lr`].93 /// inter sibling of [`decode_key_frame_tile_lr`].
93 #[allow(clippy::too_many_arguments)]94 #[allow(clippy::too_many_arguments)]
crates/ec-av1/src/decode/key_tile.rsmodified+1 -0
@@ -2,6 +2,7 @@
2 2
3 use super::*;3 use super::*;
4 4
5+#[cfg(test)]
5 /// [`decode_key_frame_tile`] with this frame header's own `lr_params` (spec6 /// [`decode_key_frame_tile`] with this frame header's own `lr_params` (spec
6 /// 5.9.20) instead of the no-restoration default -- the per-unit filters7 /// 5.9.20) instead of the no-restoration default -- the per-unit filters
7 /// themselves live in the tile payload, so the header is all this needs.8 /// 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 {
126 126
127 /// Takes whatever the last capturing decode left (see127 /// Takes whatever the last capturing decode left (see
128 /// [`FrameCtx::capture_stages`]).128 /// [`FrameCtx::capture_stages`]).
129-#[allow(dead_code)] // read from the encoder's loop restoration search
130 pub(crate) fn take_filter_stages(fctx: &FrameCtx) -> Option<FilterStages> {129 pub(crate) fn take_filter_stages(fctx: &FrameCtx) -> Option<FilterStages> {
131 fctx.stages.borrow_mut().take()130 fctx.stages.borrow_mut().take()
132 }131 }
@@ -391,10 +390,12 @@ use crate::cdf_state::{Cdfs, MvComponentCdfs, TxbSet, TxbTables};
391 use crate::encode::{Picture, Reach};390 use crate::encode::{Picture, Reach};
392 use crate::intra::predict;391 use crate::intra::predict;
393 use crate::mc;392 use crate::mc;
393+#[cfg(test)]
394+use crate::mvstack::NO_SIGN_BIAS;
394 use crate::msac::SymbolDecoder;395 use crate::msac::SymbolDecoder;
395 use crate::mvstack::{396 use crate::mvstack::{
396 ALTREF_FRAME, ALTREF2_FRAME, BWDREF_FRAME, GOLDEN_FRAME, LAST_FRAME, LAST2_FRAME, LAST3_FRAME,397 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,
398 find_mv_stack_with_sign_bias, mv16, mv32, reference_mode_ctx, single_ref_p1_ctx,399 find_mv_stack_with_sign_bias, mv16, mv32, reference_mode_ctx, single_ref_p1_ctx,
399 single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx, single_ref_p6_ctx,400 single_ref_p2_ctx, single_ref_p3_ctx, single_ref_p4_ctx, single_ref_p5_ctx, single_ref_p6_ctx,
400 uni_comp_ref_p1_ctx,401 uni_comp_ref_p1_ctx,
@@ -3205,6 +3206,7 @@ fn is_smooth_mode(mode: usize) -> bool {
3205 (crate::intra::SMOOTH_PRED as usize..=crate::intra::SMOOTH_H_PRED as usize).contains(&mode)3206 (crate::intra::SMOOTH_PRED as usize..=crate::intra::SMOOTH_H_PRED as usize).contains(&mode)
3206 }3207 }
3207 3208
3209+#[cfg(test)]
3208 /// Decodes the payload [`crate::tile::sb_coeff_key_frame_tile`] writes,3210 /// Decodes the payload [`crate::tile::sb_coeff_key_frame_tile`] writes,
3209 /// returning the picture it reconstructs to.3211 /// returning the picture it reconstructs to.
3210 ///3212 ///
@@ -3223,7 +3225,6 @@ fn is_smooth_mode(mode: usize) -> bool {
3223 /// 16x16, a directional mode's angle delta other than zero, chroma-from-luma),3225 /// 16x16, a directional mode's angle delta other than zero, chroma-from-luma),
3224 /// or when the tile payload runs out of the symbols this decode expects (a3226 /// or when the tile payload runs out of the symbols this decode expects (a
3225 /// genuinely foreign stream).3227 /// genuinely foreign stream).
3226-#[allow(dead_code)]
3227 // read only from the `#[cfg(test)]` gates3228 // read only from the `#[cfg(test)]` gates
3228 // Signature mirrors the spec's per-call inputs; a parameter struct would only move them.3229 // Signature mirrors the spec's per-call inputs; a parameter struct would only move them.
3229 #[allow(clippy::too_many_arguments)]3230 #[allow(clippy::too_many_arguments)]