If the Compression Type integer of a Channel Block is 0x50504E00020000 (Porcupine), a Porcupine (PPN) Compression Stream immediately follows the Compression Type integer, after which the end-of-channel-block marker follows the Porcupine Compression Stream.
Porcupine (PPN) is a simple lossless compression scheme for compressing bit masks (bit planes). A set of uncompressed bit planes is stored as an array of unsigned integers: the first sample of the first bit plane is the low order bit of the first integer, the first sample of the second bit plane is the second lowest order bit of the first integer, etc.
To compress the bit planes, they are demarcated (split off) from the integers (like marks on porcupine quills as transverse stripes), then each stripe is compressed with ZST.
Conceptually, this is like Zebra compression, except it is
Sample Stride specifies the number of bytes of each unsigned integer (must be 4 or 8). The integers are filled from the lowest bit up, and do not have to be fully stored: an array of
The Number of Bit Planes specifies how many bit planes are stored and compressed. Each bit plane is called a Bit Channel.
The Porcupine Compression Stream begins with a
Note: The Porcupine Compression Stream is self-contained and may be used in any file format (not just in an XRH file).
The first four bytes of a Porcupine Compression Stream store the value 0x53505000 (ASCII string SPP\0) which marks the
Start of Porcupine Stream Marker: SPP\0
The last 4 bytes of a Porcupine Compression Stream store the value 0x45505000 (ASCII string EPP\0) which marks the
End of Porcupine Stream Marker: EPP\0
The bits of a Bit Channel are expanded to one bit per byte, and the byte sequence is then compressed using ZST o (a lossless compressor, also called Zstandard).
Bit Channels are stored sequentially, one after the other, beginning with the lowest order Bit Channel. The Number of Bit Planes specifies how many Bit Channels are stored.
Each Bit Channel consists of a
The first four bytes of a Bit Channel store the value 0x53424300 (ASCII string SBC\0) which marks the
Start of Bit Channel Marker: SBC\0
The last 4 bytes of a Bit Channel store the value 0x45424300 (ASCII string EBC\0) which marks the
End of Bit Channel Marker: EBC\0
If all of the bits of a Bit Channel are the same, then a Default Value (one byte) may be stored that specifies (in its lowest bit) the value of all the bits of the Bit Channel. In that case, zero is stored in Size of ZST Code Stream (see Figure 3 above) and the single-byte Default Value is stored in place of the ZST Code Stream (immediately after the Size of ZST Code Stream, without storing a ZST Code Stream), after which the