Module dsi_bitstream::codes
source · Expand description
Traits for reading and writing instantaneous codes.
This modules contains code for reading and writing instantaneous codes. Codewords are uniformely indexed from 0 for codes. For example, the first few words of unary, γ, and δ codes are:
| Arg | unary | γ | δ |
|---|---|---|---|
| 0 | 1 | 1 | 1 |
| 1 | 01 | 010 | 0100 |
| 2 | 001 | 011 | 0101 |
| 3 | 0001 | 00100 | 01100 |
| 4 | 00001 | 00101 | 01101 |
| 5 | 000001 | 00110 | 01110 |
| 6 | 0000001 | 00111 | 01111 |
| 7 | 00000001 | 0001000 | 00100000 |
Each code is implemented as a pair of traits for reading and writing
(e.g., GammaReadParam and GammaWriteParam). The traits for
reading depend on BitRead, whereas
the traits for writing depend on BitWrite.
The traits ending with Param make it possible to specify parameters—for
example, whether to use decoding tables. Usually, one whould instead pull
in scope non-parametric traits such as GammaRead and GammaWrite,
for which defaults are provided using the mechanism described in the
params module.
Note that if you are using decoding tables, you must ensure that the
peek_bits method of your
BitRead implementation returns a sufficient
number of bits: if it does not, an assertion will be triggered in test
mode, but behavior will be unpredictable otherwise. This is unfortunately
difficult to check statically. To stay on the safe side, we recommend
to use a read word of at least 16 bits.
Re-exports§
pub use gamma::len_gamma;pub use gamma::len_gamma_param;pub use gamma::GammaRead;pub use gamma::GammaReadParam;pub use gamma::GammaWrite;pub use gamma::GammaWriteParam;pub use delta::len_delta;pub use delta::len_delta_param;pub use delta::DeltaRead;pub use delta::DeltaReadParam;pub use delta::DeltaWrite;pub use delta::DeltaWriteParam;pub use minimal_binary::len_minimal_binary;pub use minimal_binary::MinimalBinaryRead;pub use minimal_binary::MinimalBinaryWrite;pub use zeta::len_zeta;pub use zeta::len_zeta_param;pub use zeta::ZetaRead;pub use zeta::ZetaReadParam;pub use zeta::ZetaWrite;pub use zeta::ZetaWriteParam;pub use golomb::len_golomb;pub use golomb::GolombRead;pub use golomb::GolombWrite;pub use rice::len_rice;pub use rice::RiceRead;pub use rice::RiceWrite;
Modules§
- Elias δ code.
- Elias γ code.
- Golomb codes.
- Minimal binary codes.
- Mechanisms for selecting parameters.
- Rice codes.
- Boldi–Vigna ζ codes.