Alternative University

Computer Science

Raster Image Storage

Higher Precision Extended Range

XRH File Format 1.0

Channels (Image Planes)

The rest of an XRH file, following the Channel Names block, is pixel data stored as image planes (channels). All image planes are the same width and height (have the same number of scanlines and the same number of samples per scanline).

Subsampling of channels is not supported. If you need to shrink some of the channels more, specify more compression for those channels instead of discarding samples. That always results in better quality for the same amount of shrinking.

Each channel is stored as a block of bytes, referred to as a Channel Block. Channel Blocks are stored one after the other, to the end of the file.

Figure 1:  XRH 1.0 file with three Channel Blocks, the first Channel Block storing red intensity values (samples), the second Channel Block storing green samples, and the third Channel Block storing blue samples.

Each Channel Block begins with a 4-byte start-of-channel-block marker, followed with a 64-bit Size integer, followed with a 32-bit Sample Stride integer, followed with a 64-bit Compression Type integer, followed with data (samples) for that channel, which is followed with a 4-byte end-of-channel-block marker, which is followed with the next Channel Block if there is a next Channel Block.

Figure 2:  Channel Block (image plane) of an XRH 1.0 file. All fields are fixed width except for the Data (samples). The size of the Data equals the Size (of the entire block) minus 28, because 28 is the sum of the sizes of all the fields other than the Data.

The first four bytes of a Channel Block store the value 0x53434200 (ASCII string SCB\0) which marks the start-of-channel-block.

Start of Channel Block Marker:  SCB\0

The next 8 bytes of a Channel Block are a Size integer that specifies the total size (number of bytes) of the entire Channel Block including the Size integer and the start and end markers. The entire block may be skipped by offsetting that many bytes from the beginning of the Channel Block (to the next Channel Block).

Note that the Size integer of a Channel Block is 8 bytes, not 4 bytes. It is a 64-bit integer. And keep in mind that all multi-byte numbers, including this Size integer, are stored in Big Endian format (network byte order).

Immediately after the Size integer, the next 4 bytes store an integer that specifies the number of bytes of each channel sample. This must be 4 for 32-bit floating point, or 8 for 64-bit floating point. We refer to this as the Sample Stride.

The next 8 bytes after the Sample Stride is an unsigned 64-bit integer that specifies the Compression Type of the Channel Block, which must be one of the following values:

Zebra  : 
SZ219  : 
Channel Compression Type
(unsigned integer)

Other Compression Type numbers are reserved for compression methods that are not yet supported.

If the Compression Type integer is 0x5A4201000000 (Zebra), the Data of the Channel Block consists of a lossless Zebra compression stream. That will be discussed in the Zebra compression page.

If the Compression Type integer is 0x535A02010900 (SZ219), the Data of the Channel Block consists of a lossy SZ version 2.1.9 compression stream. That will be discussed in the SZ219 compression page.

Immediately after the Data (after the compressed data stream), the last 4 bytes of the Channel Block store 0x45434200 (ASCII string ECB\0) as the end-of-channel-block marker.

End of Channel Block Marker:  ECB\0

< Previous: Channel Names    
    Next: Zebra Compression >

Return to Computer Science

Return to Alternative University

Copyright © 2020 Arc Math Software, All rights reserved
Arc Math Software, P.O. Box 221190, Sacramento CA 95822 USA   Contact
2020–Nov–25  19:46  UTC