trim_i8_decode

Function trim_i8_decode 

Source
pub fn trim_i8_decode(d: &[u8], f: &mut [i8], nbits: u32) -> Option<usize>
Expand description

Decode small integers from bytes, with a fixed size per value.

Decode the provided bytes d into the signed integers f, using nbits bits per value. Exactly as many bytes as necessary are read from d in order to fill the slice f entirely. The actual number of bytes read from d is returned. None is returned if any of the following happens:

  • Source buffer is not large enough.
  • An invalid encoding (-2^(nbits-1)) is encountered.
  • Some bits are unused in the last byte and are not all zero.

The number of bits per coefficient (nbits) MUST lie between 2 and 8 (inclusive).