Skip to content

Commit d205a0c

Browse files
committed
Propagate the block size constraint up to the caller
1 parent ae65aea commit d205a0c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/vp8.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,7 +1647,7 @@ impl<R: Read> Vp8Decoder<R> {
16471647

16481648
fn read_coefficients(
16491649
&mut self,
1650-
block: &mut [i32],
1650+
block: &mut [i32; 16],
16511651
p: usize,
16521652
plane: usize,
16531653
complexity: usize,
@@ -1656,7 +1656,6 @@ impl<R: Read> Vp8Decoder<R> {
16561656
) -> Result<bool, DecodingError> {
16571657
// perform bounds checks once up front,
16581658
// so that the compiler doesn't have to insert them in the hot loop below
1659-
let block = &mut block[..16];
16601659
assert!(complexity <= 2);
16611660

16621661
let first = if plane == 0 { 1usize } else { 0usize };
@@ -1763,7 +1762,8 @@ impl<R: Read> Vp8Decoder<R> {
17631762
let mut left = self.left.complexity[y + 1];
17641763
for x in 0usize..4 {
17651764
let i = x + y * 4;
1766-
let block = &mut blocks[i * 16..i * 16 + 16];
1765+
let block = &mut blocks[i * 16..][..16];
1766+
let block: &mut [i32; 16] = block.try_into().unwrap();
17671767

17681768
let complexity = self.top[mbx].complexity[x + 1] + left;
17691769
let dcq = self.segment[sindex].ydc;
@@ -1790,7 +1790,8 @@ impl<R: Read> Vp8Decoder<R> {
17901790

17911791
for x in 0usize..2 {
17921792
let i = x + y * 2 + if j == 5 { 16 } else { 20 };
1793-
let block = &mut blocks[i * 16..i * 16 + 16];
1793+
let block = &mut blocks[i * 16..][..16];
1794+
let block: &mut [i32; 16] = block.try_into().unwrap();
17941795

17951796
let complexity = self.top[mbx].complexity[x + j] + left;
17961797
let dcq = self.segment[sindex].uvdc;

0 commit comments

Comments
 (0)