Skip to content

Commit

Permalink
crates/jpeg: Fix some errors from #148 (comment)
Browse files Browse the repository at this point in the history
Only one left that's causing a panic, I should probably hardcode that as a hard error if I can't fix
  • Loading branch information
etemesi254 committed Dec 23, 2023
1 parent 181a35b commit 1f943d8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions crates/zune-jpeg/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ impl SampleRatios {
pub fn sample(self) -> usize {
match self {
SampleRatios::HV => 4,
SampleRatios::V => 2,
SampleRatios::H => 2,
SampleRatios::V | SampleRatios::H => 2,
SampleRatios::None => 1
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/zune-jpeg/src/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ pub(crate) fn parse_app14<T: ZReaderTrait>(
decoder.stream.skip(5);
// get color transform
let transform = decoder.stream.get_u8();
// https://exiftool.org/TagNames/JPEG.html#Adobe
match transform {
0 => decoder.input_colorspace = ColorSpace::CMYK,
1 => decoder.input_colorspace = ColorSpace::YCbCr,
Expand Down
4 changes: 3 additions & 1 deletion crates/zune-jpeg/src/mcu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ impl<T: ZReaderTrait> JpegDecoder<T> {
&mut upsampler_scratch_space
)?;
}
assert_eq!(pixels_written, pixels.len());
// it may happen that some images don't have the whole buffer
// so we can't panic in case of that
// assert_eq!(pixels_written, pixels.len());

trace!("Finished decoding image");

Expand Down

0 comments on commit 1f943d8

Please sign in to comment.