@@ -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