Skip to content

Commit

Permalink
update mozjpeg, lcms2, and a few others
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Sep 25, 2023
1 parent 575370f commit 6b64758
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 52 deletions.
87 changes: 51 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion c_components/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ path = "src/profile.rs"
imageflow_c_components = {path = ".."}
lcms2-sys = "4"
libpng-sys = "1.1.7"
mozjpeg-sys = "1"
mozjpeg-sys = "2"
libz-sys = "1.0.18"


Expand Down
12 changes: 6 additions & 6 deletions imageflow_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ petgraph = "0.4" #Upgrade to 0.5
daggy = "0.5" # Upgrade to 0.6

smallvec = "1"
itertools = "0.10"
itertools = "0.11"
imgref = "1.4.1"
slotmap = "1"
base64 = "0.21.0"
Expand All @@ -44,7 +44,7 @@ libz-sys = { version="1", features = ["static"] }

jpeg-decoder ="0.3.0"

lcms2 = "5"
lcms2 = "6"
lcms2-sys = "4"
chashmap = "2.2"

Expand All @@ -59,9 +59,9 @@ imageflow_types = { path = "../imageflow_types", version = "*" }
imageflow_helpers = { path = "../imageflow_helpers", version = "*" }
imageflow_riapi = { path = "../imageflow_riapi", version = "*" }
imageflow_c_components = { path = "../c_components" }
mozjpeg = "0.9"
mozjpeg = "0.10"

mozjpeg-sys = {version = "1", features = ["nasm_simd"]}
mozjpeg-sys = {version = "2", features = ["nasm_simd"]}

evalchroma = "1"

Expand All @@ -72,8 +72,8 @@ libpng-sys = { version = "1.1.8", features = ["static", "static-libz", "libz-sys
[dev-dependencies]
hyper = "0.14"
imageflow_http_helpers = { path = "../imageflow_http_helpers", version = "*" }
dssim = "3.2.0"
criterion = "0.4"
dssim = "3.2"
criterion = "0.5"

[features]
default = []
Expand Down
17 changes: 9 additions & 8 deletions imageflow_core/src/codecs/mozjpeg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,22 @@ impl Encoder for MozjpegEncoder {
c.v_samp_factor = (max_sampling_v / v).into();
}

cinfo.set_mem_dest();
cinfo.start_compress();
let mut compressor = cinfo.start_compress(&mut self.io)
.map_err(|io_error| nerror!(ErrorKind::EncodingIoError, "{:?}", io_error))?;


let pixels_slice = unsafe {frame.pixels_slice()}.ok_or(nerror!(ErrorKind::BitmapPointerNull))?;
if frame.width() == frame.stride() {
cinfo.write_scanlines(pixels_slice);
compressor.write_scanlines(pixels_slice)
.map_err(|io_error| nerror!(ErrorKind::EncodingIoError, "{:?}", io_error))?;
} else {
let width_bytes = frame.width() * frame.fmt.bytes();
for row in pixels_slice.chunks(frame.stride()) {
cinfo.write_scanlines(&row[0..width_bytes]);
compressor.write_scanlines(&row[0..width_bytes])
.map_err(|io_error| nerror!(ErrorKind::EncodingIoError, "{:?}", io_error))?;
}
}
cinfo.finish_compress();
let data = cinfo.data_as_mut_slice()
.map_err(|_| nerror!(ErrorKind::MozjpegEncodingError, "Internal error"))?;
self.io.write_all(data).map_err(|e| FlowError::from_encoder(e))?;
compressor.finish().map_err(|io_error| nerror!(ErrorKind::EncodingIoError, "{:?}", io_error))?;

Ok(EncodeResult {
w: frame.w as i32,
Expand Down
2 changes: 1 addition & 1 deletion imageflow_helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ regex = { version = "1" } #, features = ["pattern"]
rand = "*"
rgb = "0.8"

base64 = "0.13"
base64 = "0.21"

zip = { version = "0.6", default-features = false }

Expand Down

0 comments on commit 6b64758

Please sign in to comment.