Skip to content

Commit

Permalink
Update mozjpeg to 0.10
Browse files Browse the repository at this point in the history
mozjpeg-sys versions < 2.0 have been yanked.
  • Loading branch information
alexmoon committed Jul 26, 2024
1 parent c5a56bd commit 74a98ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion nokhwa-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ default-features = false
optional = true

[dependencies.mozjpeg]
version = "0.9"
version = "0.10"
optional = true

[package.metadata.docs.rs]
Expand Down
19 changes: 13 additions & 6 deletions nokhwa-core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1501,9 +1501,9 @@ pub fn mjpeg_to_rgb(data: &[u8], rgba: bool) -> Result<Vec<u8>, NokhwaError> {
}
};

let scanlines_res: Option<Vec<u8>> = jpeg_decompress.read_scanlines_flat();
let scanlines_res = jpeg_decompress.read_scanlines();
// assert!(jpeg_decompress.finish_decompress());
if !jpeg_decompress.finish_decompress() {
if jpeg_decompress.finish().is_err() {
return Err(NokhwaError::ProcessFrameError {
src: FrameFormat::MJPEG,
destination: "RGB888".to_string(),
Expand All @@ -1512,8 +1512,8 @@ pub fn mjpeg_to_rgb(data: &[u8], rgba: bool) -> Result<Vec<u8>, NokhwaError> {
}

match scanlines_res {
Some(pixels) => Ok(pixels),
None => Err(NokhwaError::ProcessFrameError {
Ok(pixels) => Ok(pixels),
Err(_) => Err(NokhwaError::ProcessFrameError {
src: FrameFormat::MJPEG,
destination: "RGB888".to_string(),
error: "Failed to get read readlines into RGB888 pixels!".to_string(),
Expand Down Expand Up @@ -1573,9 +1573,16 @@ pub fn buf_mjpeg_to_rgb(data: &[u8], dest: &mut [u8], rgba: bool) -> Result<(),
});
}

jpeg_decompress.read_scanlines_flat_into(dest);
if jpeg_decompress.read_scanlines_into(dest).is_err() {
return Err(NokhwaError::ProcessFrameError {
src: FrameFormat::MJPEG,
destination: "RGB888".to_string(),
error: "Failed to get read readlines into RGB888 pixels!".to_string(),
});
}

// assert!(jpeg_decompress.finish_decompress());
if !jpeg_decompress.finish_decompress() {
if jpeg_decompress.finish().is_err() {
return Err(NokhwaError::ProcessFrameError {
src: FrameFormat::MJPEG,
destination: "RGB888".to_string(),
Expand Down

0 comments on commit 74a98ac

Please sign in to comment.