The assignment to the variable p, which is the previous value in the chain, does not take into account the size of each sample. As we are on a u8 buffer, the previous value should be offset by sample byte count * sample size yet we only jump by sample size.
- let p = u16::from_ne_bytes(buf[i - samples..][..2].try_into().unwrap());
+ let p = u16::from_ne_bytes(buf[i - 2 * samples..][..2].try_into().unwrap());
Found this while working on #240, and pushed a fix on there.
The code responsible for rebuilding a predicted row is wrong for images using more that 8 bits per channel:
https://github.com/image-rs/image-tiff/blob/de6d9cf131850662b418bc2a21ca0823ba23b68a/src/decoder/mod.rs#L259-L283
The assignment to the variable
p
, which is the previous value in the chain, does not take into account the size of each sample. As we are on au8
buffer, the previous value should be offset bysample byte count * sample size
yet we only jump bysample size
.Found this while working on #240, and pushed a fix on there.