Skip to content

Commit d012c6c

Browse files
Apply fmt
1 parent 46b3b47 commit d012c6c

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

src/jpeg/decoder.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
1-
use std::ops::{Range, RangeInclusive};
21
use crate::{
32
eof,
43
jpeg::grammar::{
4+
Component,
5+
EncodingProcess,
6+
HuffmanTable,
57
Jpeg,
68
Marker,
9+
QuantizationTable,
10+
StartOfFrame,
11+
StartOfScan,
12+
JFIF,
713
},
814
read,
915
util::read_bytes::{
1016
U16_BYTES,
1117
U8_BYTES,
1218
},
1319
};
14-
use anyhow::{anyhow, ensure, Result};
15-
use crate::jpeg::grammar::{Component, EncodingProcess, HuffmanTable, JFIF, QuantizationTable, StartOfFrame, StartOfScan};
20+
use anyhow::{
21+
anyhow,
22+
ensure,
23+
Result,
24+
};
25+
use std::ops::{
26+
Range,
27+
RangeInclusive,
28+
};
1629

1730
#[derive(Debug)]
1831
pub struct JpegDecoder<'a> {
@@ -153,7 +166,6 @@ impl<'a> JpegDecoder<'a> {
153166

154167
self.cursor = offset + length;
155168

156-
157169
Ok(huffman_table)
158170
}
159171

@@ -162,7 +174,9 @@ impl<'a> JpegDecoder<'a> {
162174
let length = self.read_u16()?;
163175

164176
let number_of_image_components = self.read_u8()?;
165-
let components = self.read_vec(number_of_image_components as usize, |this| Ok((this.read_u8()?, this.read_u8()?)))?;
177+
let components = self.read_vec(number_of_image_components as usize, |this| {
178+
Ok((this.read_u8()?, this.read_u8()?))
179+
})?;
166180

167181
let start_of_scan = StartOfScan {
168182
components,
@@ -190,7 +204,6 @@ impl<'a> JpegDecoder<'a> {
190204
Ok(range)
191205
}
192206

193-
194207
eof!();
195208
read!(read_u8, u8, U8_BYTES);
196209
read!(read_u16, u16, U16_BYTES);

src/jpeg/grammar.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ use crate::image::grammar::{
22
ColorType,
33
ImageExt,
44
};
5-
use std::borrow::Cow;
6-
use std::ops::{Range, RangeInclusive};
75
use anyhow::bail;
6+
use std::{
7+
borrow::Cow,
8+
ops::{
9+
Range,
10+
RangeInclusive,
11+
},
12+
};
813

914
pub type Marker = u16;
1015

@@ -24,7 +29,7 @@ impl QuantizationTable {
2429
pub const fn precision(&self) -> Precision {
2530
match self.flag >> 4 == 1 {
2631
false => Precision::Eight,
27-
true => Precision::Sixteen
32+
true => Precision::Sixteen,
2833
}
2934
}
3035

@@ -62,7 +67,7 @@ impl TryFrom<u8> for EncodingProcess {
6267
9 => Self::ArithmeticExtendedSequentialDCT,
6368
10 => Self::ArithmeticProgressiveDCT,
6469
11 => Self::ArithmeticLossless,
65-
foreign => bail!("Encountered foreign encoding process: {foreign}")
70+
foreign => bail!("Encountered foreign encoding process: {foreign}"),
6671
};
6772

6873
Ok(res)

0 commit comments

Comments
 (0)