Skip to content

Commit a094090

Browse files
committed
remove unused imports
1 parent 246d1b9 commit a094090

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

src/decoder/lossless.rs

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use decoder::{Decoder, MAX_COMPONENTS};
2-
use error::{Error, Result, UnsupportedFeature};
3-
use huffman::{fill_default_mjpeg_tables, HuffmanDecoder, HuffmanTable};
2+
use error::{Error, Result};
3+
use huffman::HuffmanDecoder;
44
use marker::Marker;
55
use parser::Predictor;
66
use parser::{
7-
parse_app, parse_com, parse_dht, parse_dqt, parse_dri, parse_sof, parse_sos,
8-
AdobeColorTransform, AppData, CodingProcess, Component, Dimensions, EntropyCoding, FrameInfo,
9-
IccChunk, ScanInfo,
7+
Component, FrameInfo,
8+
ScanInfo,
109
};
1110
use std::io::Read;
1211

@@ -20,8 +19,8 @@ impl<R: Read> Decoder<R> {
2019
let ncomp = scan.component_indices.len();
2120
let npixel = frame.image_size.height as usize * frame.image_size.width as usize;
2221
assert!(ncomp <= MAX_COMPONENTS);
23-
let mut results = vec![vec!(0;npixel); ncomp];
24-
22+
let mut results = vec![vec!(0, npixel); ncomp];
23+
2524
let components: Vec<Component> = scan
2625
.component_indices
2726
.iter()
@@ -49,10 +48,10 @@ impl<R: Read> Decoder<R> {
4948

5049
let width = frame.image_size.width as usize;
5150
let height = frame.image_size.height as usize;
52-
51+
5352
let mut differences = vec![Vec::with_capacity(npixel); ncomp];
54-
for mcu_y in 0..height {
55-
for mcu_x in 0..width {
53+
for _mcu_y in 0..height {
54+
for _mcu_x in 0..width {
5655
if self.restart_interval > 0 {
5756
if mcus_left_until_restart == 0 {
5857
match huffman.take_marker(reader)? {
@@ -139,14 +138,13 @@ impl<R: Read> Decoder<R> {
139138
results[i][mcu_y * width + mcu_x] = result;
140139
}
141140
}
142-
143141
}
144142
} else {
145143
for mcu_y in 0..height {
146144
for mcu_x in 0..width {
147145
for (i, _component) in components.iter().enumerate() {
148146
let diff = differences[i][mcu_y * width + mcu_x];
149-
147+
150148
// The following lines could be further optimized, e.g. moving the checks
151149
// and updates of the previous values into the prediction function or
152150
// iterating such that diagonals with mcu_x + mcu_y = const are computed at
@@ -155,7 +153,8 @@ impl<R: Read> Decoder<R> {
155153
ra[i] = results[i][mcu_y * frame.image_size.width as usize + mcu_x - 1];
156154
}
157155
if mcu_y > 0 {
158-
rb[i] = results[i][(mcu_y - 1) * frame.image_size.width as usize + mcu_x];
156+
rb[i] =
157+
results[i][(mcu_y - 1) * frame.image_size.width as usize + mcu_x];
159158
if mcu_x > 0 {
160159
rc[i] = results[i]
161160
[(mcu_y - 1) * frame.image_size.width as usize + (mcu_x - 1)];
@@ -179,7 +178,6 @@ impl<R: Read> Decoder<R> {
179178
}
180179
}
181180
}
182-
183181

184182
let mut marker = huffman.take_marker(&mut self.reader)?;
185183
while let Some(Marker::RST(_)) = marker {
@@ -226,10 +224,7 @@ fn predict(
226224
result
227225
}
228226

229-
pub fn compute_image_lossless(
230-
frame: &FrameInfo,
231-
mut data: Vec<Vec<u16>>
232-
) -> Result<Vec<u8>> {
227+
pub fn compute_image_lossless(frame: &FrameInfo, mut data: Vec<Vec<u16>>) -> Result<Vec<u8>> {
233228
if data.is_empty() || data.iter().any(Vec::is_empty) {
234229
return Err(Error::Format("not all components have data".to_owned()));
235230
}
@@ -241,10 +236,8 @@ pub fn compute_image_lossless(
241236
let decoded = convert_to_u8(frame, data.remove(0));
242237
Ok(decoded)
243238
} else {
244-
let mut decoded: Vec<u16> = vec![
245-
0u16;
246-
ncomp * output_size.width as usize * output_size.height as usize
247-
];
239+
let mut decoded: Vec<u16> =
240+
vec![0u16; ncomp * output_size.width as usize * output_size.height as usize];
248241
for (x, chunk) in decoded.chunks_mut(ncomp).enumerate() {
249242
for (i, (component_data, _)) in data.iter().zip(components.iter()).enumerate() {
250243
chunk[i] = component_data[x];

0 commit comments

Comments
 (0)