int dflag = 0;
chunk = CHUNK;
- strm.bit_per_sample = 8;
+ strm.bits_per_sample = 8;
strm.block_size = 8;
strm.rsi = 2;
strm.flags = AEC_DATA_PREPROCESS;
chunk = atoi(optarg);
break;
case 'B':
- strm.bit_per_sample = atoi(optarg);
+ strm.bits_per_sample = atoi(optarg);
break;
case 'J':
strm.block_size = atoi(optarg);
exit(-1);
}
- if (strm.bit_per_sample > 16)
+ if (strm.bits_per_sample > 16)
{
- if (strm.bit_per_sample <= 24 && strm.flags & AEC_DATA_3BYTE)
+ if (strm.bits_per_sample <= 24 && strm.flags & AEC_DATA_3BYTE)
chunk *= 3;
else
chunk *= 4;
}
- else if (strm.bit_per_sample > 8)
+ else if (strm.bits_per_sample > 8)
{
chunk *= 2;
}
state->last_out = state->buf[0]; \
\
if (strm->flags & AEC_DATA_SIGNED) { \
- m = 1ULL << (strm->bit_per_sample - 1); \
+ m = 1ULL << (strm->bits_per_sample - 1); \
/* Reference samples have to be sign extended */ \
state->last_out = (state->last_out ^ m) - m; \
} \
struct internal_state *state = strm->state;
state->buf[state->buf_i++] = s;
- strm->avail_out -= state->byte_per_sample;
- strm->total_out += state->byte_per_sample;
+ strm->avail_out -= state->bytes_per_sample;
+ strm->total_out += state->bytes_per_sample;
if (state->buf_i == state->buf_size) {
state->flush_output(strm);
k = state->id - 1;
if (state->ref)
- put_sample(strm, direct_get(strm, strm->bit_per_sample));
+ put_sample(strm, direct_get(strm, strm->bits_per_sample));
for (i = state->ref; i < strm->block_size; i++)
state->block[i] = direct_get_fs(strm) << k;
int i;
for (i = 0; i < strm->block_size; i++)
- put_sample(strm, direct_get(strm, strm->bit_per_sample));
+ put_sample(strm, direct_get(strm, strm->bits_per_sample));
}
static uint32_t bits_ask(struct aec_stream *strm, int n)
static uint32_t copysample(struct aec_stream *strm)
{
- if (bits_ask(strm, strm->bit_per_sample) == 0
+ if (bits_ask(strm, strm->bits_per_sample) == 0
|| strm->avail_out == 0)
return 0;
- put_sample(strm, bits_get(strm, strm->bit_per_sample));
- bits_drop(strm, strm->bit_per_sample);
+ put_sample(strm, bits_get(strm, strm->bits_per_sample));
+ bits_drop(strm, strm->bits_per_sample);
return 1;
}
else
state->i = zero_blocks * strm->block_size;
- if (strm->avail_out >= state->i * state->byte_per_sample) {
+ if (strm->avail_out >= state->i * state->bytes_per_sample) {
fast_zero(strm);
state->mode = m_id;
return M_CONTINUE;
int i, modi;
struct internal_state *state;
- if (strm->bit_per_sample > 32 || strm->bit_per_sample == 0)
+ if (strm->bits_per_sample > 32 || strm->bits_per_sample == 0)
return AEC_CONF_ERROR;
state = (struct internal_state *) malloc(sizeof(struct internal_state));
strm->state = state;
- if (strm->bit_per_sample > 16) {
+ if (strm->bits_per_sample > 16) {
state->id_len = 5;
- if (strm->bit_per_sample <= 24 && strm->flags & AEC_DATA_3BYTE) {
- state->byte_per_sample = 3;
+ if (strm->bits_per_sample <= 24 && strm->flags & AEC_DATA_3BYTE) {
+ state->bytes_per_sample = 3;
if (strm->flags & AEC_DATA_MSB)
state->flush_output = flush_msb_24;
else
state->flush_output = flush_lsb_24;
} else {
- state->byte_per_sample = 4;
+ state->bytes_per_sample = 4;
if (strm->flags & AEC_DATA_MSB)
state->flush_output = flush_msb_32;
else
state->flush_output = flush_lsb_32;
}
state->out_blklen = strm->block_size
- * state->byte_per_sample;
+ * state->bytes_per_sample;
}
- else if (strm->bit_per_sample > 8) {
- state->byte_per_sample = 2;
+ else if (strm->bits_per_sample > 8) {
+ state->bytes_per_sample = 2;
state->id_len = 4;
state->out_blklen = strm->block_size * 2;
if (strm->flags & AEC_DATA_MSB)
else
state->flush_output = flush_lsb_16;
} else {
- state->byte_per_sample = 1;
+ state->bytes_per_sample = 1;
state->id_len = 3;
state->out_blklen = strm->block_size;
state->flush_output = flush_8;
}
if (strm->flags & AEC_DATA_SIGNED) {
- state->xmin = -(1ULL << (strm->bit_per_sample - 1));
- state->xmax = (1ULL << (strm->bit_per_sample - 1)) - 1;
+ state->xmin = -(1ULL << (strm->bits_per_sample - 1));
+ state->xmax = (1ULL << (strm->bits_per_sample - 1)) - 1;
} else {
state->xmin = 0;
- state->xmax = (1ULL << strm->bit_per_sample) - 1;
+ state->xmax = (1ULL << strm->bits_per_sample) - 1;
}
state->ref_int = strm->block_size * strm->rsi;
- state->in_blklen = (strm->block_size * strm->bit_per_sample
+ state->in_blklen = (strm->block_size * strm->bits_per_sample
+ state->id_len) / 8 + 1;
modi = 1UL << state->id_len;
int fs; /* last fundamental sequence in accumulator */
int ref; /* 1 if current block has reference sample */
int pp; /* 1 if postprocessor has to be used */
- int byte_per_sample;
+ int bytes_per_sample;
int *se_table;
uint32_t *buf;
uint32_t buf_i;
struct internal_state *state = strm->state;
uint32_t *d = state->data_pp;
int32_t *x = (int32_t *)state->data_raw;
- uint64_t m = 1ULL << (strm->bit_per_sample - 1);
+ uint64_t m = 1ULL << (strm->bits_per_sample - 1);
int64_t xmax = state->xmax;
int64_t xmin = state->xmin;
uint32_t rsi = strm->rsi * strm->block_size - 1;
Length of CDS encoded with splitting option and optimal k.
In Rice coding each sample in a block of samples is split at
- the same position into k LSB and bit_per_sample - k MSB. The
+ the same position into k LSB and bits_per_sample - k MSB. The
LSB part is left binary and the MSB part is coded as a
fundamental sequence a.k.a. unary (see CCSDS 121.0-B-2). The
function of the length of the Coded Data Set (CDS) depending on
if (state->ref)
{
- emit(state, state->block[0], strm->bit_per_sample);
+ emit(state, state->block[0], strm->bits_per_sample);
emitblock_fs_1(strm, k);
if (k)
emitblock_1(strm, k);
struct internal_state *state = strm->state;
emit(state, (1U << state->id_len) - 1, state->id_len);
- emitblock_0(strm, strm->bit_per_sample);
+ emitblock_0(strm, strm->bits_per_sample);
return m_flush_block(strm);
}
emit(state, 1, state->id_len + 1);
if (state->ref)
- emit(state, state->block[0], strm->bit_per_sample);
+ emit(state, state->block[0], strm->bits_per_sample);
for (i = 0; i < strm->block_size; i+= 2) {
d = state->block[i] + state->block[i + 1];
emit(state, 0, state->id_len + 1);
if (state->zero_ref)
- emit(state, state->zero_ref_sample, strm->bit_per_sample);
+ emit(state, state->zero_ref_sample, strm->bits_per_sample);
if (state->zero_blocks == ROS)
emitfs(state, 4);
struct internal_state *state = strm->state;
uncomp_len = (strm->block_size - state->ref)
- * strm->bit_per_sample;
+ * strm->bits_per_sample;
split_len = assess_splitting_option(strm);
se_len = assess_se_option(split_len, strm);
{
struct internal_state *state;
- if (strm->bit_per_sample > 32 || strm->bit_per_sample == 0)
+ if (strm->bits_per_sample > 32 || strm->bits_per_sample == 0)
return AEC_CONF_ERROR;
if (strm->block_size != 8
memset(state, 0, sizeof(struct internal_state));
strm->state = state;
- if (strm->bit_per_sample > 16) {
+ if (strm->bits_per_sample > 16) {
/* 24/32 input bit settings */
state->id_len = 5;
- if (strm->bit_per_sample <= 24
+ if (strm->bits_per_sample <= 24
&& strm->flags & AEC_DATA_3BYTE) {
state->block_len = 3 * strm->block_size;
if (strm->flags & AEC_DATA_MSB) {
}
}
}
- else if (strm->bit_per_sample > 8) {
+ else if (strm->bits_per_sample > 8) {
/* 16 bit settings */
state->id_len = 4;
state->block_len = 2 * strm->block_size;
}
if (strm->flags & AEC_DATA_SIGNED) {
- state->xmin = -(1ULL << (strm->bit_per_sample - 1));
- state->xmax = (1ULL << (strm->bit_per_sample - 1)) - 1;
+ state->xmin = -(1ULL << (strm->bits_per_sample - 1));
+ state->xmax = (1ULL << (strm->bits_per_sample - 1)) - 1;
state->preprocess = preprocess_signed;
} else {
state->xmin = 0;
- state->xmax = (1ULL << strm->bit_per_sample) - 1;
+ state->xmax = (1ULL << strm->bits_per_sample) - 1;
state->preprocess = preprocess_unsigned;
}
unsigned char *next_out;
size_t avail_out; /* remaining free space at next_out */
size_t total_out; /* total number of bytes output so far */
- int bit_per_sample; /* resolution in bits per sample (n =
+ int bits_per_sample; /* resolution in bits per sample (n =
* 1, ..., 32)
*/
int block_size; /* block size in samples */
interleave = param->bits_per_pixel == 32 || param->bits_per_pixel == 64;
if (interleave) {
- strm.bit_per_sample = 8;
+ strm.bits_per_sample = 8;
buf = malloc(sourceLen);
if (buf == NULL)
return SZ_MEM_ERROR;
interleave_buffer(buf, source, sourceLen, param->bits_per_pixel / 8);
} else {
- strm.bit_per_sample = param->bits_per_pixel;
+ strm.bits_per_sample = param->bits_per_pixel;
buf = (void *)source;
}
- pixel_size = bits_to_bytes(strm.bit_per_sample);
+ pixel_size = bits_to_bytes(strm.bits_per_sample);
if (pad_scanline) {
scanlines = (sourceLen / pixel_size + param->pixels_per_scanline - 1)
extra_buffer = pad_scanline || deinterleave;
if (deinterleave)
- strm.bit_per_sample = 8;
+ strm.bits_per_sample = 8;
else
- strm.bit_per_sample = param->bits_per_pixel;
+ strm.bits_per_sample = param->bits_per_pixel;
- pixel_size = bits_to_bytes(strm.bit_per_sample);
+ pixel_size = bits_to_bytes(strm.bits_per_sample);
if (extra_buffer) {
if (pad_scanline) {
{
struct aec_stream *strm = state->strm;
- if (strm->bit_per_sample > 16) {
+ if (strm->bits_per_sample > 16) {
state->id_len = 5;
- if (strm->bit_per_sample <= 24 && strm->flags & AEC_DATA_3BYTE) {
- state->byte_per_sample = 3;
+ if (strm->bits_per_sample <= 24 && strm->flags & AEC_DATA_3BYTE) {
+ state->bytes_per_sample = 3;
} else {
- state->byte_per_sample = 4;
+ state->bytes_per_sample = 4;
}
}
- else if (strm->bit_per_sample > 8) {
+ else if (strm->bits_per_sample > 8) {
state->id_len = 4;
- state->byte_per_sample = 2;
+ state->bytes_per_sample = 2;
} else {
state->id_len = 3;
- state->byte_per_sample = 1;
+ state->bytes_per_sample = 1;
}
if (strm->flags & AEC_DATA_MSB)
state->out = out_lsb;
if (strm->flags & AEC_DATA_SIGNED) {
- state->xmin = -(1ULL << (strm->bit_per_sample - 1));
- state->xmax = (1ULL << (strm->bit_per_sample - 1)) - 1;
+ state->xmin = -(1ULL << (strm->bits_per_sample - 1));
+ state->xmax = (1ULL << (strm->bits_per_sample - 1)) - 1;
} else {
state->xmin = 0;
- state->xmax = (1ULL << strm->bit_per_sample) - 1;
+ state->xmax = (1ULL << strm->bits_per_sample) - 1;
}
return 0;
avail_out = 1;
total_out = 0;
strm->next_in = state->ubuf;
- strm->avail_in = state->byte_per_sample;
+ strm->avail_in = state->bytes_per_sample;
strm->avail_out = 1;
strm->next_out = state->cbuf;
while ((avail_in || avail_out) && total_out < state->cbuf_len) {
if (strm->avail_in == 0 && avail_in) {
- n_in += state->byte_per_sample;
+ n_in += state->bytes_per_sample;
if (n_in < state->buf_len) {
- strm->avail_in = state->byte_per_sample;
+ strm->avail_in = state->bytes_per_sample;
strm->next_in = state->ubuf + n_in;
} else {
avail_in = 0;
strm->avail_in = 1;
strm->next_in = state->cbuf;
- strm->avail_out = state->byte_per_sample;
+ strm->avail_out = state->bytes_per_sample;
strm->next_out = state->obuf;
status = aec_decode_init(strm);
total_out = 0;
strm->next_in = state->cbuf;
strm->avail_in = 1;
- strm->avail_out = state->byte_per_sample;
+ strm->avail_out = state->bytes_per_sample;
strm->next_out = state->obuf;
while ((avail_in || avail_out) && total_out < state->buf_len) {
if (strm->total_out - total_out > 0
&& total_out < state->buf_len) {
total_out = strm->total_out;
- strm->avail_out = state->byte_per_sample;
+ strm->avail_out = state->bytes_per_sample;
strm->next_out = state->obuf + total_out;
avail_out = 1;
} else {
struct test_state {
int (* codec)(struct test_state *state);
int id_len;
- int byte_per_sample;
+ int bytes_per_sample;
unsigned char *ubuf;
unsigned char *cbuf;
unsigned char *obuf;
for (bs = 8; bs <= 64; bs *= 2) {
state->strm->block_size = bs;
- state->strm->rsi = state->buf_len / (bs * state->byte_per_sample);
+ state->strm->rsi = state->buf_len / (bs * state->bytes_per_sample);
status = encode_decode_large(state);
if (status)
tmp = state->ibuf_len;
for (bs = 8; bs <= 64; bs *= 2) {
state->strm->block_size = bs;
- state->strm->rsi = state->buf_len / (bs * state->byte_per_sample);
+ state->strm->rsi = state->buf_len / (bs * state->bytes_per_sample);
state->ibuf_len = state->buf_len - 2 * bs + 4;
status = encode_decode_large(state);
if (status)
int status, size;
unsigned char *tmp;
- size = state->byte_per_sample;
+ size = state->bytes_per_sample;
for (tmp = state->ubuf;
tmp < state->ubuf + state->buf_len;
- tmp += 2 * state->byte_per_sample) {
+ tmp += 2 * state->bytes_per_sample) {
state->out(tmp, state->xmax, size);
state->out(tmp + size, state->xmin, size);
}
strm.flags = AEC_DATA_PREPROCESS;
state.strm = &strm;
- strm.bit_per_sample = 32;
+ strm.bits_per_sample = 32;
update_state(&state);
status = check_rsi(&state);
for (bs = 8; bs <= 64; bs *= 2) {
state->strm->block_size = bs;
- max_rsi = state->buf_len / (bs * state->byte_per_sample);
+ max_rsi = state->buf_len / (bs * state->bytes_per_sample);
if (max_rsi > 4096)
max_rsi = 4096;
int status, size;
unsigned char *tmp;
- size = state->byte_per_sample;
+ size = state->bytes_per_sample;
for (tmp = state->ubuf;
tmp < state->ubuf + state->buf_len;
- tmp += 4 * state->byte_per_sample) {
+ tmp += 4 * state->bytes_per_sample) {
state->out(tmp, state->xmin + (1ULL << (k - 1)) - 1, size);
state->out(tmp + size, state->xmin, size);
state->out(tmp + 2 * size, state->xmin + (1ULL << (k + 1)) - 1, size);
int status, size;
unsigned char *tmp;
- size = state->byte_per_sample;
+ size = state->bytes_per_sample;
for (tmp = state->ubuf;
tmp < state->ubuf + state->buf_len;
- tmp += 2 * state->byte_per_sample) {
+ tmp += 2 * state->bytes_per_sample) {
state->out(tmp, state->xmax, size);
state->out(tmp + size, state->xmin, size);
}
int status, size;
unsigned char *tmp;
- size = state->byte_per_sample;
+ size = state->bytes_per_sample;
for (tmp = state->ubuf;
tmp < state->ubuf + state->buf_len;
- tmp += 4 * state->byte_per_sample) {
+ tmp += 4 * state->bytes_per_sample) {
state->out(tmp, state->xmin + 2, size);
state->out(tmp + size, state->xmin, size);
state->out(tmp + 2 * size, state->xmin, size);
int status, size;
unsigned char *tmp;
- size = state->byte_per_sample;
+ size = state->bytes_per_sample;
for (tmp = state->ubuf;
tmp < state->ubuf + state->buf_len;
int k, status, bps;
for (bps = 8; bps <= 32; bps += 8) {
- state->strm->bit_per_sample = bps;
+ state->strm->bits_per_sample = bps;
if (bps == 24)
state->strm->flags |= AEC_DATA_3BYTE;
else