fourdgsShStep function

int fourdgsShStep(
  1. int bits
)

The grid pitch, in code units, that a bit depth implies.

A coefficient is a byte whatever the depth: n bits means the byte is rounded onto a grid of 2^(8 - n) code units, which leaves 2^n distinct values in a stream that is still bytes. Nothing sub-byte is packed and no decoder changes — the saving is realized by the stream codec, which has that many fewer symbols to code, and by step_sh never being applied at decode.

Implementation

int fourdgsShStep(int bits) {
  if (bits < fourdgsShMinBits || bits > fourdgsShMaxBits) {
    throw FourdgsInvalidInput(
      'an SH bit depth must be $fourdgsShMinBits..$fourdgsShMaxBits, got $bits',
    );
  }
  return 1 << (fourdgsShMaxBits - bits);
}