Skip to content

Commit bc736a6

Browse files
committed
Clippy fixes
1 parent 0538735 commit bc736a6

File tree

6 files changed

+38
-32
lines changed

6 files changed

+38
-32
lines changed

src/arch/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::is_x86_feature_detected;
99

1010
/// Arch-specific implementation of YCbCr conversion. Returns the number of pixels that were
1111
/// converted.
12+
#[allow(clippy::type_complexity)]
1213
pub fn get_color_convert_line_ycbcr() -> Option<unsafe fn(&[u8], &[u8], &[u8], &mut [u8]) -> usize>
1314
{
1415
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
@@ -32,6 +33,7 @@ pub fn get_color_convert_line_ycbcr() -> Option<unsafe fn(&[u8], &[u8], &[u8], &
3233
}
3334

3435
/// Arch-specific implementation of 8x8 IDCT.
36+
#[allow(clippy::type_complexity)]
3537
pub fn get_dequantize_and_idct_block_8x8(
3638
) -> Option<unsafe fn(&[i16; 64], &[u16; 64], usize, &mut [u8])> {
3739
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]

src/decoder.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -616,14 +616,13 @@ impl<R: Read> Decoder<R> {
616616

617617
let frame = self.frame.as_ref().unwrap();
618618

619-
if {
620-
let required_mem = frame
621-
.components
622-
.len()
623-
.checked_mul(frame.output_size.width.into())
624-
.and_then(|m| m.checked_mul(frame.output_size.height.into()));
625-
required_mem.map_or(true, |m| self.decoding_buffer_size_limit < m)
626-
} {
619+
if frame
620+
.components
621+
.len()
622+
.checked_mul(frame.output_size.width.into())
623+
.and_then(|m| m.checked_mul(frame.output_size.height.into()))
624+
.map_or(true, |m| self.decoding_buffer_size_limit < m)
625+
{
627626
return Err(Error::Format(
628627
"size of decoded image exceeds maximum allowed size".to_owned(),
629628
));
@@ -779,6 +778,7 @@ impl<R: Read> Decoder<R> {
779778
}
780779
}
781780

781+
#[allow(clippy::type_complexity)]
782782
fn decode_scan(
783783
&mut self,
784784
frame: &FrameInfo,
@@ -1009,10 +1009,11 @@ impl<R: Read> Decoder<R> {
10091009
// In the event of non-interleaved streams, if we're still building the buffer out,
10101010
// keep going; don't send it yet. We also need to ensure we don't skip over the last
10111011
// row(s) of the image.
1012-
if !is_interleaved && (mcu_y + 1) * 8 < frame.image_size.height {
1013-
if (mcu_y + 1) % component.vertical_sampling_factor as u16 > 0 {
1014-
continue;
1015-
}
1012+
if !is_interleaved
1013+
&& (mcu_y + 1) * 8 < frame.image_size.height
1014+
&& (mcu_y + 1) % component.vertical_sampling_factor as u16 > 0
1015+
{
1016+
continue;
10161017
}
10171018

10181019
let coefficients_per_mcu_row = component.block_size.width as usize
@@ -1069,6 +1070,7 @@ impl<R: Read> Decoder<R> {
10691070
}
10701071
}
10711072

1073+
#[allow(clippy::too_many_arguments)]
10721074
fn decode_block<R: Read>(
10731075
reader: &mut R,
10741076
coefficients: &mut [i16; 64],
@@ -1321,6 +1323,7 @@ fn compute_image(
13211323
}
13221324
}
13231325

1326+
#[allow(clippy::type_complexity)]
13241327
pub(crate) fn choose_color_convert_func(
13251328
component_count: usize,
13261329
color_transform: ColorTransform,

src/decoder/lossless.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use std::io::Read;
21
use crate::decoder::{Decoder, MAX_COMPONENTS};
32
use crate::error::{Error, Result};
43
use crate::huffman::HuffmanDecoder;
54
use crate::marker::Marker;
65
use crate::parser::Predictor;
76
use crate::parser::{Component, FrameInfo, ScanInfo};
7+
use std::io::Read;
88

99
impl<R: Read> Decoder<R> {
1010
/// decode_scan_lossless
@@ -185,6 +185,7 @@ impl<R: Read> Decoder<R> {
185185
}
186186

187187
/// H.1.2.1
188+
#[allow(clippy::too_many_arguments)]
188189
fn predict(
189190
ra: i32,
190191
rb: i32,

src/parser.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ pub enum AppData {
9898
}
9999

100100
// http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html#Adobe
101+
#[allow(clippy::upper_case_acronyms)]
101102
#[derive(Clone, Copy, Debug, PartialEq)]
102103
pub enum AdobeColorTransform {
103104
// RGB or CMYK
@@ -523,6 +524,7 @@ pub fn parse_dqt<R: Read>(reader: &mut R) -> Result<[Option<[u16; 64]>; 4]> {
523524
}
524525

525526
// Section B.2.4.2
527+
#[allow(clippy::type_complexity)]
526528
pub fn parse_dht<R: Read>(reader: &mut R, is_baseline: Option<bool>) -> Result<(Vec<Option<HuffmanTable>>, Vec<Option<HuffmanTable>>)> {
527529
let mut length = read_length(reader, DHT)?;
528530
let mut dc_tables = vec![None, None, None, None];

src/upsampler.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,29 +84,27 @@ fn choose_upsampler(sampling_factors: (u8, u8),
8484

8585
if h1 && v1 {
8686
Ok(Box::new(UpsamplerH1V1))
87-
}
88-
else if h2 && v1 {
87+
} else if h2 && v1 {
8988
Ok(Box::new(UpsamplerH2V1))
90-
}
91-
else if h1 && v2 {
89+
} else if h1 && v2 {
9290
Ok(Box::new(UpsamplerH1V2))
93-
}
94-
else if h2 && v2 {
91+
} else if h2 && v2 {
9592
Ok(Box::new(UpsamplerH2V2))
96-
}
97-
else {
98-
if max_sampling_factors.0 % sampling_factors.0 != 0 || max_sampling_factors.1 % sampling_factors.1 != 0 {
99-
Err(Error::Unsupported(UnsupportedFeature::NonIntegerSubsamplingRatio))
100-
}
101-
else {
102-
Ok(Box::new(UpsamplerGeneric {
103-
horizontal_scaling_factor: max_sampling_factors.0 / sampling_factors.0,
104-
vertical_scaling_factor: max_sampling_factors.1 / sampling_factors.1
105-
}))
106-
}
93+
} else if max_sampling_factors.0 % sampling_factors.0 != 0
94+
|| max_sampling_factors.1 % sampling_factors.1 != 0
95+
{
96+
Err(Error::Unsupported(
97+
UnsupportedFeature::NonIntegerSubsamplingRatio,
98+
))
99+
} else {
100+
Ok(Box::new(UpsamplerGeneric {
101+
horizontal_scaling_factor: max_sampling_factors.0 / sampling_factors.0,
102+
vertical_scaling_factor: max_sampling_factors.1 / sampling_factors.1,
103+
}))
107104
}
108105
}
109106

107+
#[allow(clippy::too_many_arguments)]
110108
trait Upsample {
111109
fn upsample_row(&self,
112110
input: &[u8],

src/worker/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ enum WorkerScopeInner {
5050
not(any(target_arch = "asmjs", target_arch = "wasm32")),
5151
feature = "rayon"
5252
))]
53-
Rayon(rayon::Scoped),
53+
Rayon(Box<rayon::Scoped>),
5454
#[cfg(not(any(target_arch = "asmjs", target_arch = "wasm32")))]
5555
Multithreaded(multithreaded::MpscWorker),
5656
Immediate(immediate::ImmediateWorker),
@@ -86,7 +86,7 @@ impl WorkerScope {
8686
not(any(target_arch = "asmjs", target_arch = "wasm32")),
8787
feature = "rayon"
8888
))]
89-
WorkerScopeInner::Rayon(worker) => worker,
89+
WorkerScopeInner::Rayon(worker) => worker.as_mut(),
9090
#[cfg(not(any(target_arch = "asmjs", target_arch = "wasm32")))]
9191
WorkerScopeInner::Multithreaded(worker) => worker,
9292
WorkerScopeInner::Immediate(worker) => worker,

0 commit comments

Comments
 (0)