Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test-specific clippy lints #3323

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/api/config/speedsettings.rs
Original file line number Diff line number Diff line change
@@ -354,8 +354,10 @@ impl fmt::Display for SceneDetectionSpeed {
Serialize,
Deserialize,
)]
#[cfg_attr(test, derive(Default))]
pub enum PredictionModesSetting {
/// Only simple prediction modes.
#[cfg_attr(test, default)]
Simple,
/// Search all prediction modes on key frames and simple modes on other
/// frames.
@@ -378,13 +380,6 @@ impl fmt::Display for PredictionModesSetting {
}
}

#[cfg(test)]
impl Default for PredictionModesSetting {
fn default() -> Self {
PredictionModesSetting::Simple
}
}

/// Search level for self guided restoration
#[derive(
Clone,
2 changes: 1 addition & 1 deletion src/api/test.rs
Original file line number Diff line number Diff line change
@@ -1400,7 +1400,7 @@ fn test_t35_parameter() {
}
ctx.flush();

while let Ok(_) = ctx.receive_packet() {}
while ctx.receive_packet().is_ok() {}
}

#[interpolate_test(0, 0)]
92 changes: 46 additions & 46 deletions src/context/partition_unit.rs
Original file line number Diff line number Diff line change
@@ -128,52 +128,6 @@ impl CFLParams {
}
}

#[cfg(test)]
mod test {
#[test]
fn cdf_map() {
use super::*;

let cdf = CDFContext::new(8);
let cdf_map = FieldMap { map: cdf.build_map() };
let f = &cdf.partition_cdf[2];
cdf_map.lookup(f.as_ptr() as usize);
}

use super::CFLSign;
use super::CFLSign::*;

static cfl_alpha_signs: [[CFLSign; 2]; 8] = [
[CFL_SIGN_ZERO, CFL_SIGN_NEG],
[CFL_SIGN_ZERO, CFL_SIGN_POS],
[CFL_SIGN_NEG, CFL_SIGN_ZERO],
[CFL_SIGN_NEG, CFL_SIGN_NEG],
[CFL_SIGN_NEG, CFL_SIGN_POS],
[CFL_SIGN_POS, CFL_SIGN_ZERO],
[CFL_SIGN_POS, CFL_SIGN_NEG],
[CFL_SIGN_POS, CFL_SIGN_POS],
];

static cfl_context: [[usize; 8]; 2] =
[[0, 0, 0, 1, 2, 3, 4, 5], [0, 3, 0, 1, 4, 0, 2, 5]];

#[test]
fn cfl_joint_sign() {
use super::*;

let mut cfl = CFLParams::default();
for (joint_sign, &signs) in cfl_alpha_signs.iter().enumerate() {
cfl.sign = signs;
assert!(cfl.joint_sign() as usize == joint_sign);
for uv in 0..2 {
if signs[uv] != CFL_SIGN_ZERO {
assert!(cfl.context(uv) == cfl_context[uv][joint_sign]);
}
}
}
}
}

impl<'a> ContextWriter<'a> {
fn partition_gather_horz_alike(
out: &mut [u16; 2], cdf_in: &[u16], _bsize: BlockSize,
@@ -549,3 +503,49 @@ impl<'a> BlockContext<'a> {
}
}
}

#[cfg(test)]
mod test {
#[test]
fn cdf_map() {
use super::*;

let cdf = CDFContext::new(8);
let cdf_map = FieldMap { map: cdf.build_map() };
let f = &cdf.partition_cdf[2];
cdf_map.lookup(f.as_ptr() as usize);
}

use super::CFLSign;
use super::CFLSign::*;

static cfl_alpha_signs: [[CFLSign; 2]; 8] = [
[CFL_SIGN_ZERO, CFL_SIGN_NEG],
[CFL_SIGN_ZERO, CFL_SIGN_POS],
[CFL_SIGN_NEG, CFL_SIGN_ZERO],
[CFL_SIGN_NEG, CFL_SIGN_NEG],
[CFL_SIGN_NEG, CFL_SIGN_POS],
[CFL_SIGN_POS, CFL_SIGN_ZERO],
[CFL_SIGN_POS, CFL_SIGN_NEG],
[CFL_SIGN_POS, CFL_SIGN_POS],
];

static cfl_context: [[usize; 8]; 2] =
[[0, 0, 0, 1, 2, 3, 4, 5], [0, 3, 0, 1, 4, 0, 2, 5]];

#[test]
fn cfl_joint_sign() {
use super::*;

let mut cfl = CFLParams::default();
for (joint_sign, &signs) in cfl_alpha_signs.iter().enumerate() {
cfl.sign = signs;
assert!(cfl.joint_sign() as usize == joint_sign);
for uv in 0..2 {
if signs[uv] != CFL_SIGN_ZERO {
assert!(cfl.context(uv) == cfl_context[uv][joint_sign]);
}
}
}
}
}
9 changes: 2 additions & 7 deletions src/partition.rs
Original file line number Diff line number Diff line change
@@ -126,6 +126,7 @@ pub enum PartitionType {
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(test, derive(Default))]
pub enum BlockSize {
BLOCK_4X4,
BLOCK_4X8,
@@ -139,6 +140,7 @@ pub enum BlockSize {
BLOCK_32X32,
BLOCK_32X64,
BLOCK_64X32,
#[cfg_attr(test, default)]
BLOCK_64X64,
BLOCK_64X128,
BLOCK_128X64,
@@ -176,13 +178,6 @@ impl PartialOrd for BlockSize {
}
}

#[cfg(test)]
impl Default for BlockSize {
fn default() -> Self {
BlockSize::BLOCK_64X64
}
}

impl BlockSize {
pub const BLOCK_SIZES_ALL: usize = 22;
pub const BLOCK_SIZES: usize = BlockSize::BLOCK_SIZES_ALL - 6; // BLOCK_SIZES_ALL minus 4:1 non-squares, six of them
4 changes: 2 additions & 2 deletions src/tiling/tiler.rs
Original file line number Diff line number Diff line change
@@ -363,8 +363,8 @@ pub mod test {
width: usize, height: usize,
) -> (FrameInvariants<u16>, FrameState<u16>, FrameBlocks, f64) {
// FrameInvariants aligns to the next multiple of 8, so using other values could make tests confusing
assert!(width & 7 == 0);
assert!(height & 7 == 0);
assert!(width.trailing_zeros() >= 3);
assert!(height.trailing_zeros() >= 3);
// We test only for 420 for now
let chroma_sampling = ChromaSampling::Cs420;
let config = Arc::new(EncoderConfig {