Commit 04dfb2b0 authored by Vladimir Kazakov's avatar Vladimir Kazakov Committed by Thomas Daede
parent ce9245de
......@@ -44,4 +44,4 @@ jobs:
- cargo doc --verbose
- rustup component add clippy
- cargo clippy --version
- cargo clippy -- -D warnings -A clippy::absurd_extreme_comparisons -A clippy::cast_lossless -A clippy::cast_ptr_alignment -A clippy::collapsible_if -A clippy::cyclomatic_complexity -A clippy::erasing_op -A clippy::get_unwrap -A clippy::identity_op -A clippy::if_same_then_else -A clippy::len_zero -A clippy::manual_memcpy -A clippy::needless_range_loop -A clippy::neg_multiply -A clippy::precedence -A clippy::ptr_arg -A clippy::too_many_arguments -A clippy::trivially_copy_pass_by_ref -A clippy::type_complexity -A clippy::unused_io_amount -A clippy::verbose_bit_mask --verbose
- cargo clippy -- -D warnings -A clippy::absurd_extreme_comparisons -A clippy::cast_lossless -A clippy::cast_ptr_alignment -A clippy::collapsible_if -A clippy::cyclomatic_complexity -A clippy::erasing_op -A clippy::get_unwrap -A clippy::identity_op -A clippy::if_same_then_else -A clippy::len_zero -A clippy::manual_memcpy -A clippy::needless_range_loop -A clippy::neg_multiply -A clippy::precedence -A clippy::ptr_arg -A clippy::too_many_arguments -A clippy::type_complexity -A clippy::unused_io_amount -A clippy::verbose_bit_mask --verbose
......@@ -3023,9 +3023,9 @@ impl ContextWriter {
// rather than test writing and rolling back the cdf, we just count Q8 bits using the current cdf
pub fn count_lrf_switchable(&mut self, w: &dyn Writer, rs: &RestorationState,
filter: &RestorationFilter, pli: usize) -> u32 {
filter: RestorationFilter, pli: usize) -> u32 {
let nsym = &self.fc.lrf_switchable_cdf.len()-1;
match *filter {
match filter {
RestorationFilter::None => {
w.symbol_bits(0, &self.fc.lrf_switchable_cdf[..nsym])
}
......
......@@ -76,7 +76,7 @@ pub enum ObuMetaType {
}
impl ObuMetaType {
fn size(&self) -> u64 {
fn size(self) -> u64 {
use self::ObuMetaType::*;
match self {
OBU_META_HDR_CLL => 4,
......
......@@ -222,7 +222,7 @@ pub fn get_subset_predictors<T: Pixel>(
pub fn motion_estimation<T: Pixel>(
fi: &FrameInvariants<T>, fs: &FrameState<T>, bsize: BlockSize, bo: &BlockOffset,
ref_frame: usize, cmv: MotionVector, pmv: &[MotionVector; 2],
ref_frame: usize, cmv: MotionVector, pmv: [MotionVector; 2],
ref_slot: usize
) -> MotionVector {
match fi.rec_buffer.frames[fi.ref_frames[ref_frame - LAST_FRAME] as usize] {
......@@ -362,7 +362,7 @@ fn get_best_predictor<T: Pixel>(
fi: &FrameInvariants<T>,
po: &PlaneOffset, p_org: &Plane<T>, p_ref: &Plane<T>,
predictors: &[MotionVector],
bit_depth: usize, pmv: &[MotionVector; 2], lambda: u32,
bit_depth: usize, pmv: [MotionVector; 2], lambda: u32,
mvx_min: isize, mvx_max: isize, mvy_min: isize, mvy_max: isize,
blk_w: usize, blk_h: usize,
center_mv: &mut MotionVector, center_mv_cost: &mut u64) {
......@@ -386,7 +386,7 @@ fn diamond_me_search<T: Pixel>(
fi: &FrameInvariants<T>,
po: &PlaneOffset, p_org: &Plane<T>, p_ref: &Plane<T>,
predictors: &[MotionVector],
bit_depth: usize, pmv: &[MotionVector; 2], lambda: u32,
bit_depth: usize, pmv: [MotionVector; 2], lambda: u32,
mvx_min: isize, mvx_max: isize, mvy_min: isize, mvy_max: isize,
blk_w: usize, blk_h: usize,
center_mv: &mut MotionVector, center_mv_cost: &mut u64)
......@@ -440,7 +440,7 @@ fn diamond_me_search<T: Pixel>(
fn get_mv_rd_cost<T: Pixel>(
fi: &FrameInvariants<T>,
po: &PlaneOffset, p_org: &Plane<T>, p_ref: &Plane<T>, bit_depth: usize,
pmv: &[MotionVector; 2], lambda: u32,
pmv: [MotionVector; 2], lambda: u32,
mvx_min: isize, mvx_max: isize, mvy_min: isize, mvy_max: isize,
blk_w: usize, blk_h: usize,
cand_mv: MotionVector) -> u64
......@@ -471,7 +471,7 @@ fn full_search<T: Pixel>(
x_lo: isize, x_hi: isize, y_lo: isize, y_hi: isize, blk_h: usize,
blk_w: usize, p_org: &Plane<T>, p_ref: &Plane<T>, best_mv: &mut MotionVector,
lowest_cost: &mut u64, po: &PlaneOffset, step: usize, bit_depth: usize,
lambda: u32, pmv: &[MotionVector; 2], allow_high_precision_mv: bool
lambda: u32, pmv: [MotionVector; 2], allow_high_precision_mv: bool
) {
let search_range_y = (y_lo..=y_hi).step_by(step);
let search_range_x = (x_lo..=x_hi).step_by(step);
......@@ -563,7 +563,7 @@ pub fn estimate_motion_ss4<T: Pixel>(
1,
fi.sequence.bit_depth,
lambda,
&[MotionVector { row: 0, col: 0 }; 2],
[MotionVector { row: 0, col: 0 }; 2],
fi.allow_high_precision_mv
);
......@@ -616,7 +616,7 @@ pub fn estimate_motion_ss2<T: Pixel>(
1,
fi.sequence.bit_depth,
lambda,
&[MotionVector { row: 0, col: 0 }; 2],
[MotionVector { row: 0, col: 0 }; 2],
fi.allow_high_precision_mv
);
}
......
......@@ -755,12 +755,14 @@ impl ops::Div<i16> for MotionVector {
}
impl MotionVector {
pub fn quantize_to_fullpel(&self) -> MotionVector {
MotionVector{row: (self.row / 8) * 8, col: (self.col / 8) * 8}
pub fn quantize_to_fullpel(self) -> Self {
Self {
row: (self.row / 8) * 8,
col: (self.col / 8) * 8
}
}
}
pub const NEWMV_MODE_CONTEXTS: usize = 7;
pub const GLOBALMV_MODE_CONTEXTS: usize = 2;
pub const REFMV_MODE_CONTEXTS: usize = 6;
......
......@@ -45,7 +45,7 @@ pub enum RDOType {
}
impl RDOType {
pub fn needs_tx_dist(&self) -> bool {
pub fn needs_tx_dist(self) -> bool {
match self {
// Pixel-domain distortion and exact ec rate
RDOType::PixelDistRealRate => false,
......@@ -412,7 +412,7 @@ pub fn rdo_mode_decision<T: Pixel>(
let ref_slot = ref_slot_set[i] as usize;
let cmv = pmvs[ref_slot].unwrap();
let b_me = motion_estimation(fi, fs, bsize, bo, ref_frames[0], cmv, &pmv, ref_slot);
let b_me = motion_estimation(fi, fs, bsize, bo, ref_frames[0], cmv, pmv, ref_slot);
// Fill the saved motion structure.
let frame_mvs = &mut fs.frame_mvs[ref_slot as usize];
......@@ -1127,7 +1127,7 @@ fn rdo_loop_plane_error<T: Pixel>(sbo: &SuperBlockOffset, fi: &FrameInvariants<T
fs: &FrameState<T>, bc: &BlockContext,
test: &Frame<T>, pli: usize) -> u64 {
let sbo_0 = SuperBlockOffset { x: 0, y: 0 };
let sb_blocks = if fi.sequence.use_128x128_superblock {16} else {8};
let sb_blocks = if fi.sequence.use_128x128_superblock {16} else {8};
// Each direction block is 8x8 in y, potentially smaller if subsampled in chroma
// accumulating in-frame and unpadded
let mut err:u64 = 0;
......@@ -1224,7 +1224,7 @@ pub fn rdo_loop_decision<T: Pixel>(sbo: &SuperBlockOffset, fi: &FrameInvariants<
RestorationFilter::None{} => {
let err = rdo_loop_plane_error(sbo, fi, fs, &cw.bc, &lrf_input, pli);
let rate = if fi.sequence.enable_restoration {
cw.count_lrf_switchable(w, &fs.restoration, &best_lrf[pli], pli)
cw.count_lrf_switchable(w, &fs.restoration, best_lrf[pli], pli)
} else {
0 // no relative cost differeneces to different CDEF params. If cdef is on, it's a wash.
};
......@@ -1241,7 +1241,7 @@ pub fn rdo_loop_decision<T: Pixel>(sbo: &SuperBlockOffset, fi: &FrameInvariants<
&lrf_input.planes[pli].slice(&PlaneOffset{x:0, y:0}),
&mut lrf_output.planes[pli].mut_slice(&PlaneOffset{x:0, y:0}));
let err = rdo_loop_plane_error(sbo, fi, fs, &cw.bc, &lrf_output, pli);
let rate = cw.count_lrf_switchable(w, &fs.restoration, &best_lrf[pli], pli);
let rate = cw.count_lrf_switchable(w, &fs.restoration, best_lrf[pli], pli);
cost[pli] = err as f64 + fi.lambda * rate as f64 / ((1<<OD_BITRES) as f64);
cost_acc += cost[pli];
}
......@@ -1262,7 +1262,7 @@ pub fn rdo_loop_decision<T: Pixel>(sbo: &SuperBlockOffset, fi: &FrameInvariants<
if !cdef_change && !first_loop { break; }
first_loop = false;
// check for new best restoration filter if enabled
let mut lrf_change = false;
if fi.sequence.enable_restoration && lrf_any_uncoded {
......@@ -1298,7 +1298,7 @@ pub fn rdo_loop_decision<T: Pixel>(sbo: &SuperBlockOffset, fi: &FrameInvariants<
&mut lrf_output.planes[pli].mut_slice(&PlaneOffset{x:0, y:0}));
}
let err = rdo_loop_plane_error(sbo, fi, fs, &cw.bc, &lrf_output, pli);
let rate = cw.count_lrf_switchable(w, &fs.restoration, &current_lrf, pli);
let rate = cw.count_lrf_switchable(w, &fs.restoration, current_lrf, pli);
let cost = err as f64 + fi.lambda * rate as f64 / ((1<<OD_BITRES) as f64);
if best_cost[pli] < 0. || cost < best_cost[pli] {
best_cost[pli] = cost;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment