Merge branch 'simplify/s5' into simplify/w2
Browse files at this commit10 changed files +20 -107
- crates/ec-av1/src/decode/cdef.rs +1 -1
- crates/ec-av1/src/decode/coeffs.rs +7 -36
- crates/ec-av1/src/decode/deblock.rs +1 -9
- crates/ec-av1/src/decode/deblock_simd.rs +0 -15
- crates/ec-av1/src/decode/frame_tile.rs +2 -1
- crates/ec-av1/src/decode/inter_shapes.rs +0 -10
- crates/ec-av1/src/decode/key_tile.rs +1 -12
- crates/ec-av1/src/decode/mod.rs +6 -21
- crates/ec-av1/src/decode/replay.rs +1 -1
- crates/ec-av1/src/lib.rs +1 -1
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 i32 | 35 | 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 the | 39 | /// 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's | 716 | /// `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 next | 1537 | /// Records a block's `skip`/`is_inter`/`interp_filter` state for the next |
| 1538 | /// block that reads it as a neighbour -- [`crate::tile`]'s | 1538 | /// block that reads it as a neighbour -- [`crate::tile`]'s |
| 1539 | /// `record_inter`. `filter` is `[3, 3]` for an intra block (spec | 1539 | /// `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 the | 1541 | /// "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` needs | 1542 | /// `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)]` gates | 1544 | // 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`]-grid | 1561 | /// [`Self::record_inter`] with independent above (`w_sub`, [`SUB`]-grid |
| 1562 | /// columns) / left (`h_sub`, [`SUB`]-grid rows) extents -- lane-partitions | 1562 | /// columns) / left (`h_sub`, [`SUB`]-grid rows) extents -- lane-partitions |
| 1563 | /// r1: a true rectangular strip's above-context span (its own width) and | 1563 | /// r1: a true rectangular strip's above-context span (its own width) and |
| 1564 | /// left-context span (its own height) differ, unlike every caller before | 1564 | /// 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 with | 1656 | /// Overwrites [`Self::record_inter`]'s ALTREF-special-case default with |
| 1657 | /// a real compound block's own `comp_group_idx`/`compound_idx` bits | 1657 | /// 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's | 1663 | /// this is the one caller that actually knows it) -- so the next block's |
| 1664 | /// [`NeighbourRef`](crate::mvstack::NeighbourRef) sees a real compound | 1664 | /// [`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 >> depth | 3377 | max_tx >> depth |
| 3379 | } | 3378 | } |
| 3380 | 3379 | ||
| 3381 | -/// `txfm_partition_context` (libaom `av1_common_int.h`): an inter block's | 3380 | +/// `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 against | 3381 | /// libaom's `txfm_partition_context` compares the above context against |
| 3398 | /// `tx_size_wide` and the left one against `tx_size_high`, and takes its | 3382 | /// `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 one | 3383 | /// 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 |
| 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 + left | 3402 | category * 3 + above + left |
| 3419 | } | 3403 | } |
| 3420 | 3404 | ||
| 3421 | -/// `txfm_partition_update` (libaom `av1_common_int.h`): once a var-tx unit | 3405 | +/// `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 and | 3406 | /// 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 of | 3408 | /// 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) { | |||
| 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))) >> n | 19 | (v + (1 << (n - 1))) >> n |
| 28 | } | 20 | } |
| @@ -711,7 +703,7 @@ pub(super) const SCRATCH_CAP: usize = 32; | |||
| 711 | /// luma-sized allocation (every pooled buffer would drift to the largest | 703 | /// luma-sized allocation (every pooled buffer would drift to the largest |
| 712 | /// size otherwise). `None` when the pool is empty. | 704 | /// size otherwise). `None` when the pool is empty. |
| 713 | fn scratch_take(n: usize) -> Option<Vec<u16>> { | 705 | 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); |
| 715 | if p.is_empty() { | 707 | if p.is_empty() { |
| 716 | return None; | 708 | return None; |
| 717 | } | 709 | } |
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 and | 101 | /// 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 this | 9 | /// against `reference` (the previous frame's own decoded picture, at this |
| 9 | /// frame's true size -- a decoder's single-slot DPB, matching what this | 10 | /// 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 tile | 18 | /// 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, same | 19 | /// 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)]` gates | 21 | // 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`, the | 92 | /// [`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/inter_shapes.rsmodified+0 -10
| @@ -266,20 +266,10 @@ pub(crate) const INTER_BLOCK_SHAPES: [(usize, usize, usize); 18] = [ | |||
| 266 | (128, 64, 128), | 266 | (128, 64, 128), |
| 267 | ]; | 267 | ]; |
| 268 | 268 | ||
| 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 | - | ||
| 273 | thread_local! { | 269 | thread_local! { |
| 274 | pub(super) static INTER_BLOCK_SHAPE_MASK: std::cell::Cell<u32> = const { std::cell::Cell::new(0) }; | 270 | pub(super) static INTER_BLOCK_SHAPE_MASK: std::cell::Cell<u32> = const { std::cell::Cell::new(0) }; |
| 275 | } | 271 | } |
| 276 | 272 | ||
| 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 | - | ||
| 283 | /// The luma coefficient/`tx_type` table set of a whole-block rectangular | 273 | /// The luma coefficient/`tx_type` table set of a whole-block rectangular |
| 284 | /// INTER transform unit (lane-inter4 r3). `av1_get_ext_tx_set_type` splits | 274 | /// INTER transform unit (lane-inter4 r3). `av1_get_ext_tx_set_type` splits |
| 285 | /// the two shapes: a 32x16/16x32 unit has `tx_size_sqr_up == TX_32X32`, so | 275 | /// 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 @@ | |||
| 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` (spec | 6 | /// [`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 filters | 7 | /// 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. |
| @@ -183,18 +184,6 @@ thread_local! { | |||
| 183 | pub(crate) static MU_CHUNK_INTRA_IN_INTER_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 184 | pub(crate) static MU_CHUNK_INTRA_IN_INTER_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 184 | } | 185 | } |
| 185 | 186 | ||
| 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 | - | ||
| 198 | thread_local! { | 187 | thread_local! { |
| 199 | /// lane-av1h5: chunk-major chroma WALKS run for a 128-root plane block -- | 188 | /// lane-av1h5: chunk-major chroma WALKS run for a 128-root plane block -- |
| 200 | /// one per 64x64 mu chunk. libaom codes exactly 4 per unsplit 128x128 root | 189 | /// 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; | |||
| 79 | use cdef::*; | 79 | use cdef::*; |
| 80 | 80 | ||
| 81 | mod inter_shapes; | 81 | mod inter_shapes; |
| 82 | -pub use inter_shapes::*; | 82 | +pub(crate) use inter_shapes::*; |
| 83 | 83 | ||
| 84 | mod deblock; | 84 | mod deblock; |
| 85 | pub(crate) use deblock::*; | 85 | pub(crate) use deblock::*; |
| @@ -91,7 +91,7 @@ mod replay; | |||
| 91 | pub(crate) use replay::*; | 91 | pub(crate) use replay::*; |
| 92 | 92 | ||
| 93 | mod key_tile; | 93 | mod key_tile; |
| 94 | -pub use key_tile::*; | 94 | +pub(crate) use key_tile::*; |
| 95 | 95 | ||
| 96 | mod inter_ctx; | 96 | mod inter_ctx; |
| 97 | pub(crate) use inter_ctx::*; | 97 | pub(crate) use inter_ctx::*; |
| @@ -126,7 +126,6 @@ pub(crate) struct FilterStages { | |||
| 126 | 126 | ||
| 127 | /// Takes whatever the last capturing decode left (see | 127 | /// 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, |
| @@ -2276,11 +2277,6 @@ thread_local! { | |||
| 2276 | static UV_LEFT_SS_Y_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2277 | static UV_LEFT_SS_Y_READS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2277 | } | 2278 | } |
| 2278 | 2279 | ||
| 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 | - | ||
| 2284 | // lane-av1leftwit: the per-tile epoch `uv_owner` cells are stamped with. | 2280 | // lane-av1leftwit: the per-tile epoch `uv_owner` cells are stamped with. |
| 2285 | // Bumped in `Neighbours::start_tile`; never read by decode logic. | 2281 | // Bumped in `Neighbours::start_tile`; never read by decode logic. |
| 2286 | thread_local! { | 2282 | thread_local! { |
| @@ -2458,17 +2454,6 @@ thread_local! { | |||
| 2458 | static CDEF_MIXED_SKIP_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2454 | static CDEF_MIXED_SKIP_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2459 | } | 2455 | } |
| 2460 | 2456 | ||
| 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 | - | ||
| 2472 | // Which plane the in-flight INTRA reconstruction is writing (0=Y, 1=U, 2=V). | 2457 | // Which plane the in-flight INTRA reconstruction is writing (0=Y, 1=U, 2=V). |
| 2473 | // lane-av1cmpaudit: aomdec's `EC_PREDOUT8`/`EC_PREDND` print `plane=`, and | 2458 | // lane-av1cmpaudit: aomdec's `EC_PREDOUT8`/`EC_PREDND` print `plane=`, and |
| 2474 | // without the same field on our side an `EC_PREDOUT8` vs `OUR_PRED` diff of a | 2459 | // 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 { | |||
| 3221 | (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) |
| 3222 | } | 3207 | } |
| 3223 | 3208 | ||
| 3209 | +#[cfg(test)] | ||
| 3224 | /// Decodes the payload [`crate::tile::sb_coeff_key_frame_tile`] writes, | 3210 | /// Decodes the payload [`crate::tile::sb_coeff_key_frame_tile`] writes, |
| 3225 | /// returning the picture it reconstructs to. | 3211 | /// returning the picture it reconstructs to. |
| 3226 | /// | 3212 | /// |
| @@ -3239,7 +3225,6 @@ fn is_smooth_mode(mode: usize) -> bool { | |||
| 3239 | /// 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), |
| 3240 | /// or when the tile payload runs out of the symbols this decode expects (a | 3226 | /// or when the tile payload runs out of the symbols this decode expects (a |
| 3241 | /// genuinely foreign stream). | 3227 | /// genuinely foreign stream). |
| 3242 | -#[allow(dead_code)] | ||
| 3243 | // read only from the `#[cfg(test)]` gates | 3228 | // read only from the `#[cfg(test)]` gates |
| 3244 | // 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. |
| 3245 | #[allow(clippy::too_many_arguments)] | 3230 | #[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> { | |||
| 395 | /// Over [`SCRATCH_CAP`] the buffer is dropped (freed) instead -- the cap is | 395 | /// Over [`SCRATCH_CAP`] the buffer is dropped (freed) instead -- the cap is |
| 396 | /// what keeps a pool shared by every thread from being an unbounded stash. | 396 | /// what keeps a pool shared by every thread from being an unbounded stash. |
| 397 | pub(super) fn scratch_return(v: Vec<u16>) { | 397 | 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); |
| 399 | if p.len() < SCRATCH_CAP { | 399 | if p.len() < SCRATCH_CAP { |
| 400 | p.push(v); | 400 | p.push(v); |
| 401 | } | 401 | } |
crates/ec-av1/src/lib.rsmodified+1 -1
| @@ -25,7 +25,7 @@ mod autothreads; | |||
| 25 | pub mod cdf; | 25 | pub mod cdf; |
| 26 | mod cdf_state; | 26 | mod cdf_state; |
| 27 | mod compound; | 27 | mod compound; |
| 28 | -pub mod decode; | 28 | +mod decode; |
| 29 | pub mod encode; | 29 | pub mod encode; |
| 30 | pub mod encoder; | 30 | pub mod encoder; |
| 31 | #[doc(hidden)] | 31 | #[doc(hidden)] |