@@ -804,11 +804,11 @@ pub struct Frame {
804804impl Frame {
805805 /// Chroma plane is half the size of the Luma plane
806806 const fn chroma_width ( & self ) -> u16 {
807- ( self . width + 1 ) / 2
807+ self . width . div_ceil ( 2 )
808808 }
809809
810810 const fn chroma_height ( & self ) -> u16 {
811- ( self . height + 1 ) / 2
811+ self . height . div_ceil ( 2 )
812812 }
813813
814814 /// Fills an rgb buffer with the image
@@ -1136,7 +1136,7 @@ impl<R: Read> Vp8Decoder<R> {
11361136 . expect ( "Reading from &[u8] can't fail and the chunk is complete" ) ;
11371137
11381138 let size = size as usize ;
1139- let mut buf = vec ! [ [ 0 ; 4 ] ; ( size + 3 ) / 4 ] ;
1139+ let mut buf = vec ! [ [ 0 ; 4 ] ; size. div_ceil ( 4 ) ] ;
11401140 let bytes: & mut [ u8 ] = buf. as_mut_slice ( ) . as_flattened_mut ( ) ;
11411141 self . r . read_exact ( & mut bytes[ ..size] ) ?;
11421142 self . partitions [ i] . init ( buf, size) ?;
@@ -1146,7 +1146,7 @@ impl<R: Read> Vp8Decoder<R> {
11461146 let mut buf = Vec :: new ( ) ;
11471147 self . r . read_to_end ( & mut buf) ?;
11481148 let size = buf. len ( ) ;
1149- let mut chunks = vec ! [ [ 0 ; 4 ] ; ( size + 3 ) / 4 ] ;
1149+ let mut chunks = vec ! [ [ 0 ; 4 ] ; size. div_ceil ( 4 ) ] ;
11501150 chunks. as_mut_slice ( ) . as_flattened_mut ( ) [ ..size] . copy_from_slice ( & buf) ;
11511151 self . partitions [ n - 1 ] . init ( chunks, size) ?;
11521152
@@ -1293,8 +1293,8 @@ impl<R: Read> Vp8Decoder<R> {
12931293 // Almost always the first macro block, except when non exists (i.e. `width == 0`)
12941294 self . left = self . top . first ( ) . copied ( ) . unwrap_or_default ( ) ;
12951295
1296- self . mbwidth = ( self . frame . width + 15 ) / 16 ;
1297- self . mbheight = ( self . frame . height + 15 ) / 16 ;
1296+ self . mbwidth = self . frame . width . div_ceil ( 16 ) ;
1297+ self . mbheight = self . frame . height . div_ceil ( 16 ) ;
12981298
12991299 self . frame . ybuf = vec ! [ 0u8 ; self . frame. width as usize * self . frame. height as usize ] ;
13001300 self . frame . ubuf =
@@ -1307,7 +1307,7 @@ impl<R: Read> Vp8Decoder<R> {
13071307 }
13081308
13091309 let size = first_partition_size as usize ;
1310- let mut buf = vec ! [ [ 0 ; 4 ] ; ( size + 3 ) / 4 ] ;
1310+ let mut buf = vec ! [ [ 0 ; 4 ] ; size. div_ceil ( 4 ) ] ;
13111311 let bytes: & mut [ u8 ] = buf. as_mut_slice ( ) . as_flattened_mut ( ) ;
13121312 self . r . read_exact ( & mut bytes[ ..size] ) ?;
13131313
@@ -2215,7 +2215,7 @@ impl IntraMode {
22152215}
22162216
22172217fn init_top_macroblocks ( width : usize ) -> Vec < MacroBlock > {
2218- let mb_width = ( width + 15 ) / 16 ;
2218+ let mb_width = width. div_ceil ( 16 ) ;
22192219
22202220 let mb = MacroBlock {
22212221 // Section 11.3 #3
0 commit comments