Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mozjpeg to 0.10 #178

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading