@@ -804,11 +804,11 @@ pub struct Frame {
804
804
impl Frame {
805
805
/// Chroma plane is half the size of the Luma plane
806
806
const fn chroma_width ( & self ) -> u16 {
807
- ( self . width + 1 ) / 2
807
+ self . width . div_ceil ( 2 )
808
808
}
809
809
810
810
const fn chroma_height ( & self ) -> u16 {
811
- ( self . height + 1 ) / 2
811
+ self . height . div_ceil ( 2 )
812
812
}
813
813
814
814
/// Fills an rgb buffer with the image
@@ -1136,7 +1136,7 @@ impl<R: Read> Vp8Decoder<R> {
1136
1136
. expect ( "Reading from &[u8] can't fail and the chunk is complete" ) ;
1137
1137
1138
1138
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 ) ] ;
1140
1140
let bytes: & mut [ u8 ] = buf. as_mut_slice ( ) . as_flattened_mut ( ) ;
1141
1141
self . r . read_exact ( & mut bytes[ ..size] ) ?;
1142
1142
self . partitions [ i] . init ( buf, size) ?;
@@ -1146,7 +1146,7 @@ impl<R: Read> Vp8Decoder<R> {
1146
1146
let mut buf = Vec :: new ( ) ;
1147
1147
self . r . read_to_end ( & mut buf) ?;
1148
1148
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 ) ] ;
1150
1150
chunks. as_mut_slice ( ) . as_flattened_mut ( ) [ ..size] . copy_from_slice ( & buf) ;
1151
1151
self . partitions [ n - 1 ] . init ( chunks, size) ?;
1152
1152
@@ -1293,8 +1293,8 @@ impl<R: Read> Vp8Decoder<R> {
1293
1293
// Almost always the first macro block, except when non exists (i.e. `width == 0`)
1294
1294
self . left = self . top . first ( ) . copied ( ) . unwrap_or_default ( ) ;
1295
1295
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 ) ;
1298
1298
1299
1299
self . frame . ybuf = vec ! [ 0u8 ; self . frame. width as usize * self . frame. height as usize ] ;
1300
1300
self . frame . ubuf =
@@ -1307,7 +1307,7 @@ impl<R: Read> Vp8Decoder<R> {
1307
1307
}
1308
1308
1309
1309
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 ) ] ;
1311
1311
let bytes: & mut [ u8 ] = buf. as_mut_slice ( ) . as_flattened_mut ( ) ;
1312
1312
self . r . read_exact ( & mut bytes[ ..size] ) ?;
1313
1313
@@ -2215,7 +2215,7 @@ impl IntraMode {
2215
2215
}
2216
2216
2217
2217
fn init_top_macroblocks ( width : usize ) -> Vec < MacroBlock > {
2218
- let mb_width = ( width + 15 ) / 16 ;
2218
+ let mb_width = width. div_ceil ( 16 ) ;
2219
2219
2220
2220
let mb = MacroBlock {
2221
2221
// Section 11.3 #3
0 commit comments