Skip to content

Commit a6a46b2

Browse files
committed
fix: clippy warnings, fmt, set version to 0.1.0
- Apply div_ceil(), remove redundant clone(), collapse nested if-let - cargo fmt (alignment in codec.rs orientation match) - Set version to 0.1.0 for first crates.io publish
1 parent 606babc commit a6a46b2

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "zenavif"
3-
version = "0.1.4"
3+
version = "0.1.0"
44
edition = "2024"
55
rust-version = "1.93"
66
license = "AGPL-3.0-only OR LicenseRef-Imazen-Commercial"

src/codec.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ impl AvifDecodeJob {
18071807
}
18081808
if let Some(px) = self.limits.max_pixels {
18091809
// Convert pixels to megapixels (round up to avoid zero).
1810-
let mp = ((px + 999_999) / 1_000_000).min(u32::MAX as u64) as u32;
1810+
let mp = px.div_ceil(1_000_000).min(u32::MAX as u64) as u32;
18111811
cfg.parser_total_megapixels_limit = Some(mp);
18121812
}
18131813
if let Some(frames) = self.limits.max_frames {
@@ -2135,7 +2135,7 @@ impl<'a> zencodec::decode::DecodeJob<'a> for AvifDecodeJob {
21352135
loop_count: anim_info.loop_count,
21362136
preferred: preferred.to_vec(),
21372137
current_frame: None,
2138-
limits: self.limits.clone(),
2138+
limits: self.limits,
21392139
accumulated_ms: 0,
21402140
})
21412141
}
@@ -2180,12 +2180,12 @@ fn orientation_to_avif(orientation: zencodec::Orientation) -> (Option<u8>, Optio
21802180
match orientation {
21812181
Orientation::Identity => (None, None),
21822182
Orientation::FlipH => (Some(0), Some(0)), // mirror=0, no rotation
2183-
Orientation::Rotate180 => (Some(2), None), // 180° CCW
2184-
Orientation::FlipV => (Some(2), Some(0)), // mirror=0, 180° CCW
2185-
Orientation::Transpose => (Some(1), Some(0)), // mirror=0, 90° CCW
2186-
Orientation::Rotate90 => (Some(3), None), // 270° CCW = 90° CW
2187-
Orientation::Transverse => (Some(3), Some(0)), // mirror=0, 270° CCW
2188-
Orientation::Rotate270 => (Some(1), None), // 90° CCW = 270° CW
2183+
Orientation::Rotate180 => (Some(2), None), // 180° CCW
2184+
Orientation::FlipV => (Some(2), Some(0)), // mirror=0, 180° CCW
2185+
Orientation::Transpose => (Some(1), Some(0)), // mirror=0, 90° CCW
2186+
Orientation::Rotate90 => (Some(3), None), // 270° CCW = 90° CW
2187+
Orientation::Transverse => (Some(3), Some(0)), // mirror=0, 270° CCW
2188+
Orientation::Rotate270 => (Some(1), None), // 90° CCW = 270° CW
21892189
_ => (None, None),
21902190
}
21912191
}
@@ -2510,20 +2510,21 @@ impl zencodec::decode::Decode for AvifDecoder<'_> {
25102510
// Attach gain map / depth map as typed extras only when opted in.
25112511
// Metadata (`ImageInfo.supplements`, `GainMapPresence`) is always
25122512
// populated regardless — only the heavy data blobs are gated.
2513-
if self.extract_gain_map {
2514-
if let Some(gm) = native_info.gain_map {
2515-
if let Some(metadata) = convert_gain_map_info(&gm) {
2516-
let source = zencodec::gainmap::GainMapSource::new(
2517-
gm.gain_map_data,
2518-
zencodec::ImageFormat::Avif,
2519-
metadata,
2520-
);
2521-
output = output.with_extras(source);
2522-
}
2523-
}
2524-
if let Some(dm) = native_info.depth_map {
2525-
output = output.with_extras(dm);
2526-
}
2513+
if self.extract_gain_map
2514+
&& let Some(gm) = native_info.gain_map
2515+
&& let Some(metadata) = convert_gain_map_info(&gm)
2516+
{
2517+
let source = zencodec::gainmap::GainMapSource::new(
2518+
gm.gain_map_data,
2519+
zencodec::ImageFormat::Avif,
2520+
metadata,
2521+
);
2522+
output = output.with_extras(source);
2523+
}
2524+
if self.extract_gain_map
2525+
&& let Some(dm) = native_info.depth_map
2526+
{
2527+
output = output.with_extras(dm);
25272528
}
25282529
Ok(output)
25292530
}

0 commit comments

Comments
 (0)