Skip to content

API: C API: Functions

Samuel Li edited this page Oct 7, 2023 · 5 revisions

Compression modes

SPERR C API supports 3 different compression modes: 1) fixed-bpp, 2) fixed-psnr, and 3) fixed-pwe.

The intended compression mode to use, thus, is passed to the C API by an integer:

mode == 1 means fixed-bpp
mode == 2 means fixed-psnr
mode == 3 means fixed-pwe

Any other mode numbers passed in will result in an error.

Compression and decompression in 2D

A pair of functions provide support for fixed-size compression in 2D:

  • sperr_comp_2d() takes in a 2D slice and produces a compressed bitstream.
  • sperr_decomp_2d() decompresses a bitstream and reconstructs a 2D slice.

Each of his pair of functions takes a relatively long list of parameters, and the best place to look up their meanings is the C header.

Note that this page documents the memory model of SPERR output, and this example code demonstrates the usage of 2D compression and decompression.

Compression and decompression in 3D

Again, a pair of functions provide support for compression and decompression in 3D:

  • sperr_comp_3d() compresses a 3D volume and produces a compressed bitstream.
  • sperr_decomp_3d() decompresses a bitstream and reconstructs a 3D volume.

Each of his pair of functions takes a relatively long list of parameters, and the best place to look up their meanings is the C header.

Note that this page documents the memory model of SPERR output, and this example code demonstrates the usage of 3D compression and decompression.

Truncate an existing 3D SPERR bitstream for progressive access

A 3D SPERR bitstream can be simply truncated to take less space and still valid for decompression, only at a lower quality. Function sperr_trunc_3d() performs this task.