#include <string.h>
static void
_t1(rev_inv_reinterpret, Scalar)(Int* iblock, Scalar* fblock, uint n)
{
uint i;
for (i = 0; i < n; i++) {
Int x = iblock[i];
if (x < 0)
iblock[i] = (Int)((UInt)x ^ TCMASK);
}
memcpy(fblock, iblock, n * sizeof(*fblock));
}
static uint
_t2(rev_decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock)
{
uint bits = 0;
cache_align_(Int iblock[BLOCK_SIZE]);
bits++;
if (stream_read_bit(zfp->stream)) {
bits++;
if (stream_read_bit(zfp->stream)) {
bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, iblock);
_t1(rev_inv_reinterpret, Scalar)(iblock, fblock, BLOCK_SIZE);
}
else {
int emax;
bits += EBITS;
emax = (int)stream_read_bits(zfp->stream, EBITS) - EBIAS;
bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, iblock);
_t1(rev_inv_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax);
}
}
else {
uint i;
for (i = 0; i < BLOCK_SIZE; i++)
*fblock++ = 0;
if (zfp->minbits > bits) {
stream_skip(zfp->stream, zfp->minbits - bits);
bits = zfp->minbits;
}
}
return bits;
}