Skip to content

Commit

Permalink
Fix new clippy lints for Rust 1.66
Browse files Browse the repository at this point in the history
  • Loading branch information
shssoichiro committed Dec 24, 2022
1 parent 9b74158 commit 1c8c772
Show file tree
Hide file tree
Showing 29 changed files with 121 additions and 157 deletions.
3 changes: 1 addition & 2 deletions src/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ pub fn apply_ssim_boost(
// C3 sqrt(C1^2 + svar * dvar)
let rsqrt = ssim_boost_rsqrt((C1 * C1) + svar * dvar);
((input as u64
* (((RATIO * (svar + dvar + C2) as u64) * rsqrt.norm as u64)
>> RATIO_SHIFT))
* (((RATIO * (svar + dvar + C2)) * rsqrt.norm as u64) >> RATIO_SHIFT))
>> rsqrt.shift) as u32
}

Expand Down
4 changes: 2 additions & 2 deletions src/api/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ impl<T: Pixel> ContextInner<T> {
output_frameno,
segmentation: fs.segmentation,
});
for i in 0..(REF_FRAMES as usize) {
for i in 0..REF_FRAMES {
if (fi.refresh_frame_flags & (1 << i)) != 0 {
coded_data.lookahead_rec_buffer.frames[i] = Some(Arc::clone(&rfs));
coded_data.lookahead_rec_buffer.deblock[i] = fs.deblock;
Expand Down Expand Up @@ -808,7 +808,7 @@ impl<T: Pixel> ContextInner<T> {
output_frameno,
segmentation: fs.segmentation,
});
for i in 0..(REF_FRAMES as usize) {
for i in 0..REF_FRAMES {
if (fi.refresh_frame_flags & (1 << i)) != 0 {
coded_data.lookahead_rec_buffer.frames[i] = Some(Arc::clone(&rfs));
coded_data.lookahead_rec_buffer.deblock[i] = fs.deblock;
Expand Down
2 changes: 1 addition & 1 deletion src/asm/shared/transform/inverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn call_inverse_hbd_func<T: Pixel>(
unsafe {
func(
output.data_ptr_mut() as *mut _,
T::to_asm_stride(output.plane_cfg.stride) as isize,
T::to_asm_stride(output.plane_cfg.stride),
copied.data.as_mut_ptr() as *mut _,
eob as i32 - 1,
);
Expand Down
7 changes: 3 additions & 4 deletions src/asm/x86/dist/sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ pub fn get_weighted_sse<T: Pixel>(
T::to_asm_stride(dst.plane_cfg.stride),
scale.as_ptr(),
(scale_stride * size_of_element(scale)) as isize,
) as u64
+ (den >> 1))
) + (den >> 1))
/ den
},
None => call_rust(),
Expand All @@ -140,9 +139,9 @@ pub fn get_weighted_sse<T: Pixel>(
Some(func) => unsafe {
((func)(
src.data_ptr() as *const _,
T::to_asm_stride(src.plane_cfg.stride) as isize,
T::to_asm_stride(src.plane_cfg.stride),
dst.data_ptr() as *const _,
T::to_asm_stride(dst.plane_cfg.stride) as isize,
T::to_asm_stride(dst.plane_cfg.stride),
scale.as_ptr(),
(scale_stride * size_of_element(scale)) as isize,
) + (den >> 1))
Expand Down
2 changes: 1 addition & 1 deletion src/asm/x86/lrf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ unsafe fn sgrproj_box_ab_8_avx2(
let p = _mm256_max_epi32(
_mm256_setzero_si256(),
_mm256_sub_epi32(
_mm256_mullo_epi32(scaled_ssq, _mm256_set1_epi32(n as i32)),
_mm256_mullo_epi32(scaled_ssq, _mm256_set1_epi32(n)),
_mm256_madd_epi16(scaled_sum, scaled_sum),
),
);
Expand Down
8 changes: 4 additions & 4 deletions src/asm/x86/predict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ pub fn dispatch_predict_intra<T: Pixel>(
);
// From dav1d, dx and dy are the distance from the predicted block to the frame edge
let (dx, dy) = (
(bw as isize - dst.rect().x as isize) as libc::c_int,
(bh as isize - dst.rect().y as isize) as libc::c_int,
(bw as isize - dst.rect().x) as libc::c_int,
(bh as isize - dst.rect().y) as libc::c_int,
);

if angle <= 90 {
Expand Down Expand Up @@ -371,8 +371,8 @@ pub fn dispatch_predict_intra<T: Pixel>(
);
// From dav1d, dx and dy are the distance from the predicted block to the frame edge
let (dx, dy) = (
(bw as isize - dst.rect().x as isize) as libc::c_int,
(bh as isize - dst.rect().y as isize) as libc::c_int,
(bw as isize - dst.rect().x) as libc::c_int,
(bh as isize - dst.rect().y) as libc::c_int,
);

if angle <= 90 {
Expand Down
2 changes: 1 addition & 1 deletion src/bin/rav1e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn process_frame<T: Pixel, D: Decoder>(
let (ret, emit_pass_data) = match pkt_wrapped {
Ok(pkt) => {
output_file.write_frame(
pkt.input_frameno as u64,
pkt.input_frameno,
pkt.data.as_ref(),
pkt.frame_type,
);
Expand Down
2 changes: 1 addition & 1 deletion src/bin/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl ProgressInfo {

// Elapsed time in seconds
pub fn elapsed_time(&self) -> u64 {
Instant::now().duration_since(self.time_started).as_secs() as u64
Instant::now().duration_since(self.time_started).as_secs()
}

// Number of frames of given type which appear in the video
Expand Down
7 changes: 3 additions & 4 deletions src/cdef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ pub(crate) mod rust {
fn constrain(diff: i32, threshold: i32, damping: i32) -> i32 {
if threshold != 0 {
let shift = cmp::max(0, damping - msb(threshold));
let magnitude =
cmp::min(diff.abs(), cmp::max(0, threshold - (diff.abs() >> shift)));
let magnitude = (threshold - (diff.abs() >> shift)).clamp(0, diff.abs());

if diff < 0 {
-magnitude
Expand Down Expand Up @@ -234,7 +233,7 @@ pub(crate) mod rust {
} else {
let xsize = (8 >> xdec) as isize;
let ysize = (8 >> ydec) as isize;
let coeff_shift = bit_depth as usize - 8;
let coeff_shift = bit_depth - 8;
let cdef_pri_taps = [[4, 2], [3, 3]];
let cdef_sec_taps = [[2, 1], [2, 1]];
let pri_taps =
Expand Down Expand Up @@ -341,7 +340,7 @@ pub fn cdef_analyze_superblock<T: Pixel>(
fi: &FrameInvariants<T>, in_frame: &Frame<T>, blocks: &TileBlocks<'_>,
sbo: TileSuperBlockOffset,
) -> CdefDirections {
let coeff_shift = fi.sequence.bit_depth as usize - 8;
let coeff_shift = fi.sequence.bit_depth - 8;
let mut dir: CdefDirections =
CdefDirections { dir: [[0; 8]; 8], var: [[0; 8]; 8] };
// Each direction block is 8x8 in y, and direction computation only looks at y
Expand Down
22 changes: 11 additions & 11 deletions src/context/block_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ impl<'a> BlockContext<'a> {
(tx_size.width() as u8, tx_size.height() as u8)
};

let above_ctx = &mut self.above_tx_context[bo.0.x..bo.0.x + n4_w as usize];
let above_ctx = &mut self.above_tx_context[bo.0.x..bo.0.x + n4_w];
let left_ctx =
&mut self.left_tx_context[bo.y_in_sb()..bo.y_in_sb() + n4_h as usize];
&mut self.left_tx_context[bo.y_in_sb()..bo.y_in_sb() + n4_h];

for v in above_ctx[0..n4_w].iter_mut() {
*v = tx_w;
Expand Down Expand Up @@ -1009,7 +1009,7 @@ impl<'a> ContextWriter<'a> {
let inc = cmp::min(-max_row_offs + row_offset + 1, cand.n4_h as isize);
assert!(inc >= 0);
weight = cmp::max(weight, inc as u32);
*processed_rows = (inc as isize) - row_offset - 1;
*processed_rows = inc - row_offset - 1;
}

if Self::add_ref_mv_candidate(
Expand Down Expand Up @@ -1075,7 +1075,7 @@ impl<'a> ContextWriter<'a> {
let inc = cmp::min(-max_col_offs + col_offset + 1, cand.n4_w as isize);
assert!(inc >= 0);
weight = cmp::max(weight, inc as u32);
*processed_cols = (inc as isize) - col_offset - 1;
*processed_cols = inc - col_offset - 1;
}

if Self::add_ref_mv_candidate(
Expand Down Expand Up @@ -1403,13 +1403,13 @@ impl<'a> ContextWriter<'a> {
* (8 * MI_SIZE) as isize
+ border_h;
mv.this_mv.row =
(mv.this_mv.row as isize).max(mvy_min).min(mvy_max) as i16;
(mv.this_mv.row as isize).clamp(mvy_min, mvy_max) as i16;
mv.this_mv.col =
(mv.this_mv.col as isize).max(mvx_min).min(mvx_max) as i16;
(mv.this_mv.col as isize).clamp(mvx_min, mvx_max) as i16;
mv.comp_mv.row =
(mv.comp_mv.row as isize).max(mvy_min).min(mvy_max) as i16;
(mv.comp_mv.row as isize).clamp(mvy_min, mvy_max) as i16;
mv.comp_mv.col =
(mv.comp_mv.col as isize).max(mvx_min).min(mvx_max) as i16;
(mv.comp_mv.col as isize).clamp(mvx_min, mvx_max) as i16;
}

mode_context
Expand Down Expand Up @@ -1906,7 +1906,7 @@ impl<'a> ContextWriter<'a> {
&mut self.fc.eob_extra_cdf[txs_ctx][plane_type][(eob_pt - 3) as usize];
symbol_with_update!(self, w, bit, cdf, 2);
for i in 1..eob_offset_bits {
eob_shift = eob_offset_bits as u16 - 1 - i as u16;
eob_shift = eob_offset_bits - 1 - i;
bit = u32::from((eob_extra & (1 << eob_shift)) != 0);
w.bit(bit as u16);
}
Expand Down Expand Up @@ -1942,7 +1942,7 @@ impl<'a> ContextWriter<'a> {
symbol_with_update!(
self,
w,
(cmp::min(u32::cast_from(level), 3) - 1) as u32,
cmp::min(u32::cast_from(level), 3) - 1,
&mut self.fc.coeff_base_eob_cdf[txs_ctx][plane_type]
[coeff_ctx as usize],
3
Expand All @@ -1951,7 +1951,7 @@ impl<'a> ContextWriter<'a> {
symbol_with_update!(
self,
w,
(cmp::min(u32::cast_from(level), 3)) as u32,
cmp::min(u32::cast_from(level), 3),
&mut self.fc.coeff_base_cdf[txs_ctx][plane_type][coeff_ctx as usize],
4
);
Expand Down
2 changes: 1 addition & 1 deletion src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub fn mv_joint_horizontal(joint_type: MvJointType) -> bool {
#[inline(always)]
pub const fn mv_class_base(mv_class: usize) -> u32 {
if mv_class != MV_CLASS_0 {
(CLASS0_SIZE << (mv_class as usize + 2)) as u32
(CLASS0_SIZE << (mv_class + 2)) as u32
} else {
0
}
Expand Down
2 changes: 1 addition & 1 deletion src/context/partition_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ impl<'a> BlockContext<'a> {

assert!(bsize.is_sqr());

(left * 2 + above) as usize + bsl as usize * PARTITION_PLOFFSET
(left * 2 + above) as usize + bsl * PARTITION_PLOFFSET
}

/// # Panics
Expand Down
8 changes: 4 additions & 4 deletions src/context/transform_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,8 @@ impl<'a> ContextWriter<'a> {
let max_tx_high = max_tx_size.height() as u8;
let has_above = bo.0.y > 0;
let has_left = bo.0.x > 0;
let mut above = self.bc.above_tx_context[bo.0.x] >= max_tx_wide as u8;
let mut left = self.bc.left_tx_context[bo.y_in_sb()] >= max_tx_high as u8;
let mut above = self.bc.above_tx_context[bo.0.x] >= max_tx_wide;
let mut left = self.bc.left_tx_context[bo.y_in_sb()] >= max_tx_high;

if has_above {
let above_blk = self.bc.blocks.above_of(bo);
Expand Down Expand Up @@ -716,7 +716,7 @@ impl<'a> ContextWriter<'a> {

let max_tx_size: TxSize = bsize.tx_size().sqr_up();
let category: usize = (tx_size.sqr_up() != max_tx_size) as usize
+ (TxSize::TX_SIZES as usize - 1 - max_tx_size as usize) * 2;
+ (TxSize::TX_SIZES - 1 - max_tx_size as usize) * 2;

debug_assert!(category < TXFM_PARTITION_CONTEXTS);

Expand Down Expand Up @@ -807,7 +807,7 @@ impl<'a> ContextWriter<'a> {
eob_to_pos_small[eob] as u32
} else {
let e = cmp::min((eob - 1) >> 5, 16);
eob_to_pos_large[e as usize] as u32
eob_to_pos_large[e] as u32
};
assert!(eob as i32 >= k_eob_group_start[t as usize] as i32);
*extra = eob as u32 - k_eob_group_start[t as usize] as u32;
Expand Down
22 changes: 8 additions & 14 deletions src/deblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,8 @@ fn sse_size4<T: Pixel>(

// mask4 sets the dividing line for filter vs no filter
// nhev4 sets the dividing line between narrow2 and narrow4
let mask =
clamp(mask4(p1, p0, q0, q1, bd - 8), 1, MAX_LOOP_FILTER + 1) as usize;
let nhev =
clamp(nhev4(p1, p0, q0, q1, bd - 8), mask, MAX_LOOP_FILTER + 1) as usize;
let mask = clamp(mask4(p1, p0, q0, q1, bd - 8), 1, MAX_LOOP_FILTER + 1);
let nhev = clamp(nhev4(p1, p0, q0, q1, bd - 8), mask, MAX_LOOP_FILTER + 1);

// sse for each; short-circuit the 'special' no-op cases.
let sse_none = stride_sse(&a, &none);
Expand Down Expand Up @@ -596,11 +594,9 @@ fn sse_size6<T: Pixel>(
// flat6 decides between wide and narrow filters (unrelated to level)
// nhev4 sets the dividing line between narrow2 and narrow4
let mask =
clamp(mask6(p2, p1, p0, q0, q1, q2, bd - 8), 1, MAX_LOOP_FILTER + 1)
as usize;
clamp(mask6(p2, p1, p0, q0, q1, q2, bd - 8), 1, MAX_LOOP_FILTER + 1);
let flatp = flat6(p2, p1, p0, q0, q1, q2) <= flat;
let nhev =
clamp(nhev4(p1, p0, q0, q1, bd - 8), mask, MAX_LOOP_FILTER + 1) as usize;
let nhev = clamp(nhev4(p1, p0, q0, q1, bd - 8), mask, MAX_LOOP_FILTER + 1);

// sse for each; short-circuit the 'special' no-op cases.
let sse_none = stride_sse(&a, &none);
Expand Down Expand Up @@ -800,10 +796,9 @@ fn sse_size8<T: Pixel>(
mask8(p3, p2, p1, p0, q0, q1, q2, q3, bd - 8),
1,
MAX_LOOP_FILTER + 1,
) as usize;
);
let flatp = flat8(p3, p2, p1, p0, q0, q1, q2, q3) <= flat;
let nhev =
clamp(nhev4(p1, p0, q0, q1, bd - 8), mask, MAX_LOOP_FILTER + 1) as usize;
let nhev = clamp(nhev4(p1, p0, q0, q1, bd - 8), mask, MAX_LOOP_FILTER + 1);

// sse for each; short-circuit the 'special' no-op cases.
let sse_none = stride_sse(&a, &none);
Expand Down Expand Up @@ -1058,11 +1053,10 @@ fn sse_size14<T: Pixel>(
mask8(p3, p2, p1, p0, q0, q1, q2, q3, bd - 8),
1,
MAX_LOOP_FILTER + 1,
) as usize;
);
let flat8p = flat8(p3, p2, p1, p0, q0, q1, q2, q3) <= flat;
let flat14p = flat14_outer(p6, p5, p4, p0, q0, q4, q5, q6) <= flat;
let nhev =
clamp(nhev4(p1, p0, q0, q1, bd - 8), mask, MAX_LOOP_FILTER + 1) as usize;
let nhev = clamp(nhev4(p1, p0, q0, q1, bd - 8), mask, MAX_LOOP_FILTER + 1);

// sse for each; short-circuit the 'special' no-op cases.
let sse_none = stride_sse(&a, &none);
Expand Down
30 changes: 12 additions & 18 deletions src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ pub struct ReferenceFrame<T: Pixel> {

#[derive(Debug, Clone, Default)]
pub struct ReferenceFramesSet<T: Pixel> {
pub frames: [Option<Arc<ReferenceFrame<T>>>; REF_FRAMES as usize],
pub deblock: [DeblockState; REF_FRAMES as usize],
pub frames: [Option<Arc<ReferenceFrame<T>>>; REF_FRAMES],
pub deblock: [DeblockState; REF_FRAMES],
}

impl<T: Pixel> ReferenceFramesSet<T> {
Expand Down Expand Up @@ -1223,7 +1223,7 @@ impl<T: Pixel> FrameInvariants<T> {

fn pick_strength_from_q(&mut self, qps: &QuantizerParameters) {
self.cdef_damping = 3 + (self.base_q_idx >> 6);
let q = bexp64(qps.log_target_q as i64 + q57(QSCALE)) as f32;
let q = bexp64(qps.log_target_q + q57(QSCALE)) as f32;
/* These coefficients were trained on libaom. */
let (y_f1, y_f2, uv_f1, uv_f2) = if !self.intra_only {
(
Expand Down Expand Up @@ -2836,17 +2836,11 @@ fn encode_partition_bottomup<T: Pixel, W: Writer>(

let four_partitions = [
tile_bo,
TileBlockOffset(BlockOffset { x: tile_bo.0.x + hbsw, y: tile_bo.0.y }),
TileBlockOffset(BlockOffset { x: tile_bo.0.x, y: tile_bo.0.y + hbsh }),
TileBlockOffset(BlockOffset {
x: tile_bo.0.x + hbsw as usize,
y: tile_bo.0.y,
}),
TileBlockOffset(BlockOffset {
x: tile_bo.0.x,
y: tile_bo.0.y + hbsh as usize,
}),
TileBlockOffset(BlockOffset {
x: tile_bo.0.x + hbsw as usize,
y: tile_bo.0.y + hbsh as usize,
x: tile_bo.0.x + hbsw,
y: tile_bo.0.y + hbsh,
}),
];
let partitions = get_sub_partitions(&four_partitions, partition);
Expand Down Expand Up @@ -3235,16 +3229,16 @@ fn encode_partition_topdown<T: Pixel, W: Writer>(
let four_partitions = [
tile_bo,
TileBlockOffset(BlockOffset {
x: tile_bo.0.x + hbsw as usize,
x: tile_bo.0.x + hbsw,
y: tile_bo.0.y,
}),
TileBlockOffset(BlockOffset {
x: tile_bo.0.x,
y: tile_bo.0.y + hbsh as usize,
y: tile_bo.0.y + hbsh,
}),
TileBlockOffset(BlockOffset {
x: tile_bo.0.x + hbsw as usize,
y: tile_bo.0.y + hbsh as usize,
x: tile_bo.0.x + hbsw,
y: tile_bo.0.y + hbsh,
}),
];
let partitions = get_sub_partitions(&four_partitions, partition);
Expand Down Expand Up @@ -3890,7 +3884,7 @@ pub fn update_rec_buffer<T: Pixel>(
output_frameno,
segmentation: fs.segmentation,
});
for i in 0..(REF_FRAMES as usize) {
for i in 0..REF_FRAMES {
if (fi.refresh_frame_flags & (1 << i)) != 0 {
fi.rec_buffer.frames[i] = Some(Arc::clone(&rfs));
fi.rec_buffer.deblock[i] = fs.deblock;
Expand Down
Loading

0 comments on commit 1c8c772

Please sign in to comment.