Skip to content

Commit

Permalink
Fix broken huffman decode table
Browse files Browse the repository at this point in the history
When pre-generating the huffman decode table there are values that don't
decode to anything. Just ignore those.
  • Loading branch information
pedrocr committed Nov 8, 2020
1 parent 6b3d2d1 commit 619eff2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/decoders/ljpeg/huffman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,12 @@ impl HuffTable {
break;
}
}
let idx = self.valptr[l] as usize + (code as usize - (self.mincode[l] as usize)) as usize;
(l as u32,self.huffval[idx],self.shiftval[idx])
if l >= 17 {
(0, 0, 0)
} else {
let idx = self.valptr[l] as usize + (code as usize - (self.mincode[l] as usize)) as usize;
(l as u32,self.huffval[idx],self.shiftval[idx])
}
}

pub fn huff_diff(&self, pump: &mut dyn BitPump, input: (u32,u32,u32)) -> i32 {
Expand Down

0 comments on commit 619eff2

Please sign in to comment.