@@ -378,7 +378,7 @@ impl<W: JfifWrite> Encoder<W> {
378378 const MARKER : & [ u8 ; 12 ] = b"ICC_PROFILE\0 " ;
379379 const MAX_CHUNK_LENGTH : usize = 65535 - 2 - 12 - 2 ;
380380
381- let num_chunks = ceil_div ( data. len ( ) , MAX_CHUNK_LENGTH ) ;
381+ let num_chunks = data. len ( ) . div_ceil ( MAX_CHUNK_LENGTH ) ;
382382
383383 // Sequence number is stored as a byte and starts with 1
384384 if num_chunks >= 255 {
@@ -692,8 +692,8 @@ impl<W: JfifWrite> Encoder<W> {
692692 let width = image. width ( ) ;
693693 let height = image. height ( ) ;
694694
695- let num_cols = ceil_div ( usize:: from ( width) , 8 * max_h_sampling) ;
696- let num_rows = ceil_div ( usize:: from ( height) , 8 * max_v_sampling) ;
695+ let num_cols = usize:: from ( width) . div_ceil ( 8 * max_h_sampling) ;
696+ let num_rows = usize:: from ( height) . div_ceil ( 8 * max_v_sampling) ;
697697
698698 let buffer_width = num_cols * 8 * max_h_sampling;
699699 let buffer_size = buffer_width * 8 * max_v_sampling;
@@ -966,8 +966,8 @@ impl<W: JfifWrite> Encoder<W> {
966966
967967 let ( max_h_sampling, max_v_sampling) = self . get_max_sampling_size ( ) ;
968968
969- let num_cols = ceil_div ( usize:: from ( width) , 8 * max_h_sampling) * max_h_sampling;
970- let num_rows = ceil_div ( usize:: from ( height) , 8 * max_v_sampling) * max_v_sampling;
969+ let num_cols = usize:: from ( width) . div_ceil ( 8 * max_h_sampling) * max_h_sampling;
970+ let num_rows = usize:: from ( height) . div_ceil ( 8 * max_v_sampling) * max_v_sampling;
971971
972972 debug_assert ! ( num_cols > 0 ) ;
973973 debug_assert ! ( num_rows > 0 ) ;
@@ -991,8 +991,8 @@ impl<W: JfifWrite> Encoder<W> {
991991 }
992992 }
993993
994- let num_cols = ceil_div ( usize:: from ( width) , 8 ) ;
995- let num_rows = ceil_div ( usize:: from ( height) , 8 ) ;
994+ let num_cols = usize:: from ( width) . div_ceil ( 8 ) ;
995+ let num_rows = usize:: from ( height) . div_ceil ( 8 ) ;
996996
997997 debug_assert ! ( num_cols > 0 ) ;
998998 debug_assert ! ( num_rows > 0 ) ;
@@ -1003,8 +1003,8 @@ impl<W: JfifWrite> Encoder<W> {
10031003 let h_scale = max_h_sampling / component. horizontal_sampling_factor as usize ;
10041004 let v_scale = max_v_sampling / component. vertical_sampling_factor as usize ;
10051005
1006- let cols = ceil_div ( num_cols, h_scale) ;
1007- let rows = ceil_div ( num_rows, v_scale) ;
1006+ let cols = num_cols. div_ceil ( h_scale) ;
1007+ let rows = num_rows. div_ceil ( v_scale) ;
10081008
10091009 debug_assert ! ( cols > 0 ) ;
10101010 debug_assert ! ( rows > 0 ) ;
@@ -1223,10 +1223,6 @@ fn get_block(
12231223 block
12241224}
12251225
1226- fn ceil_div ( value : usize , div : usize ) -> usize {
1227- value / div + usize:: from ( value % div != 0 )
1228- }
1229-
12301226fn get_num_bits ( mut value : i16 ) -> u8 {
12311227 if value < 0 {
12321228 value = -value;
0 commit comments