#include <inttypes.h>
#include <string.h>
#include <getopt.h>
-#include "libae.h"
+#include "libaec.h"
#define CHUNK 1024
int main(int argc, char *argv[])
{
- ae_stream strm;
+ aec_stream strm;
uint8_t *in;
uint8_t *out;
int chunk, total_out, status, c;
strm.bit_per_sample = 8;
strm.block_size = 8;
strm.rsi = 2;
- strm.flags = AE_DATA_PREPROCESS;
+ strm.flags = AEC_DATA_PREPROCESS;
opterr = 0;
while ((c = getopt (argc, argv, "d3Mscb:B:R:J:")) != -1)
cflag = 1;
break;
case 's':
- strm.flags |= AE_DATA_SIGNED;
+ strm.flags |= AEC_DATA_SIGNED;
break;
case 'M':
- strm.flags |= AE_DATA_MSB;
+ strm.flags |= AEC_DATA_MSB;
break;
case '3':
- strm.flags |= AE_DATA_3BYTE;
+ strm.flags |= AEC_DATA_3BYTE;
break;
case '?':
if (optopt == 'b')
if (strm.bit_per_sample > 16)
{
- if (strm.bit_per_sample <= 24 && strm.flags & AE_DATA_3BYTE)
+ if (strm.bit_per_sample <= 24 && strm.flags & AEC_DATA_3BYTE)
chunk *= 3;
else
chunk *= 4;
if (dflag)
{
- if ((ext = strstr(infn, ".aee")) == NULL)
+ if ((ext = strstr(infn, ".aec")) == NULL)
{
- fprintf(stderr, "Error: input file needs to end with .aee\n");
+ fprintf(stderr, "Error: input file needs to end with .aec\n");
exit(-1);
}
strncpy(outfn, infn, ext - infn);
}
else
{
- sprintf(outfn, "%s.aee", infn);
+ sprintf(outfn, "%s.aec", infn);
}
if ((outfp = fopen(outfn, "w")) == NULL)
if (dflag)
{
- if (ae_decode_init(&strm) != AE_OK)
+ if (aec_decode_init(&strm) != AEC_OK)
return 1;
}
else
{
- if (ae_encode_init(&strm) != AE_OK)
+ if (aec_encode_init(&strm) != AEC_OK)
return 1;
}
}
if (dflag)
- status = ae_decode(&strm, AE_NO_FLUSH);
+ status = aec_decode(&strm, AEC_NO_FLUSH);
else
- status = ae_encode(&strm, AE_NO_FLUSH);
+ status = aec_encode(&strm, AEC_NO_FLUSH);
- if (status != AE_OK)
+ if (status != AEC_OK)
{
fprintf(stderr, "error is %i\n", status);
return 1;
if (dflag)
{
- ae_decode_end(&strm);
+ aec_decode_end(&strm);
}
else
{
- if ((status = ae_encode(&strm, AE_FLUSH)) != AE_OK)
+ if ((status = aec_encode(&strm, AEC_FLUSH)) != AEC_OK)
{
fprintf(stderr, "error is %i\n", status);
return 1;
fwrite(out, strm.total_out - total_out, 1, outfp);
}
- ae_encode_end(&strm);
+ aec_encode_end(&strm);
}
fclose(infp);
+++ /dev/null
-#ifndef AEE_ACCESSORS_H
-#define AEE_ACCESSORS_H
-
-#include <inttypes.h>
-#include "libae.h"
-
-uint32_t get_8(ae_streamp strm);
-uint32_t get_lsb_16(ae_streamp strm);
-uint32_t get_msb_16(ae_streamp strm);
-uint32_t get_lsb_32(ae_streamp strm);
-uint32_t get_msb_24(ae_streamp strm);
-uint32_t get_lsb_24(ae_streamp strm);
-uint32_t get_msb_32(ae_streamp strm);
-
-extern void (*get_block_funcs_8[4])(ae_streamp);
-extern void (*get_block_funcs_lsb_16[4])(ae_streamp);
-extern void (*get_block_funcs_msb_16[4])(ae_streamp);
-extern void (*get_block_funcs_lsb_24[4])(ae_streamp);
-extern void (*get_block_funcs_msb_24[4])(ae_streamp);
-extern void (*get_block_funcs_lsb_32[4])(ae_streamp);
-extern void (*get_block_funcs_msb_32[4])(ae_streamp);
-
-#endif
#include <inttypes.h>
#include <string.h>
-#include "libae.h"
+#include "libaec.h"
#define MIN(a, b) (((a) < (b))? (a): (b))
int id; /* option ID */
int id_len; /* bit length of code option identification key */
int *id_table; /* table maps IDs to states */
- void (*put_sample)(ae_streamp, int64_t);
+ void (*put_sample)(aec_streamp, int64_t);
int ref_int; /* reference sample is every ref_int samples */
int64_t last_out; /* previous output for post-processing */
int64_t xmin; /* minimum integer for post-processing */
} decode_state;
/* decoding table for the second-extension option */
-static const int second_extension[92][2] = {
+static const int second_extension[92][2] =
+{
{0, 0},
{1, 1}, {1, 1},
{2, 3}, {2, 3}, {2, 3},
M_UNCOMP_COPY,
};
-static void put_msb_32(ae_streamp strm, int64_t data)
+static void put_msb_32(aec_streamp strm, int64_t data)
{
*strm->next_out++ = data >> 24;
*strm->next_out++ = data >> 16;
strm->total_out += 4;
}
-static void put_msb_24(ae_streamp strm, int64_t data)
+static void put_msb_24(aec_streamp strm, int64_t data)
{
*strm->next_out++ = data >> 16;
*strm->next_out++ = data >> 8;
strm->total_out += 3;
}
-static void put_msb_16(ae_streamp strm, int64_t data)
+static void put_msb_16(aec_streamp strm, int64_t data)
{
*strm->next_out++ = data >> 8;
*strm->next_out++ = data;
strm->total_out += 2;
}
-static void put_lsb_32(ae_streamp strm, int64_t data)
+static void put_lsb_32(aec_streamp strm, int64_t data)
{
*strm->next_out++ = data;
*strm->next_out++ = data >> 8;
strm->total_out += 4;
}
-static void put_lsb_24(ae_streamp strm, int64_t data)
+static void put_lsb_24(aec_streamp strm, int64_t data)
{
*strm->next_out++ = data;
*strm->next_out++ = data >> 8;
strm->total_out += 3;
}
-static void put_lsb_16(ae_streamp strm, int64_t data)
+static void put_lsb_16(aec_streamp strm, int64_t data)
{
*strm->next_out++ = data;
*strm->next_out++ = data >> 8;
strm->total_out += 2;
}
-static void put_8(ae_streamp strm, int64_t data)
+static void put_8(aec_streamp strm, int64_t data)
{
*strm->next_out++ = data;
strm->avail_out--;
strm->total_out++;
}
-static inline void u_put(ae_streamp strm, int64_t sample)
+static inline void u_put(aec_streamp strm, int64_t sample)
{
int64_t x, d, th, D, lower;
decode_state *state = strm->state;
}
else
{
- if (strm->flags & AE_DATA_SIGNED)
+ if (strm->flags & AEC_DATA_SIGNED)
{
int m = 64 - strm->bit_per_sample;
/* Reference samples have to be sign extended */
state->samples_out++;
}
-static inline int64_t u_get(ae_streamp strm, unsigned int n)
+static inline int64_t u_get(aec_streamp strm, unsigned int n)
{
/**
Unsafe get n bit from input stream
return (state->acc >> state->bitp) & ((1ULL << n) - 1);
}
-static inline int64_t u_get_fs(ae_streamp strm)
+static inline int64_t u_get_fs(aec_streamp strm)
{
/**
Interpret a Fundamental Sequence from the input buffer.
return fs;
}
-static inline void fast_split(ae_streamp strm)
+static inline void fast_split(aec_streamp strm)
{
int i, k;
decode_state *state;
}
}
-static inline void fast_zero(ae_streamp strm)
+static inline void fast_zero(aec_streamp strm)
{
int i = strm->state->i;
u_put(strm, 0);
}
-static inline void fast_se(ae_streamp strm)
+static inline void fast_se(aec_streamp strm)
{
int i;
int64_t gamma, beta, ms, delta1;
}
}
-static inline void fast_uncomp(ae_streamp strm)
+static inline void fast_uncomp(aec_streamp strm)
{
int i;
u_put(strm, u_get(strm, strm->bit_per_sample));
}
-int ae_decode_init(ae_streamp strm)
+int aec_decode_init(aec_streamp strm)
{
int i, modi;
decode_state *state;
/* Some sanity checks */
if (strm->bit_per_sample > 32 || strm->bit_per_sample == 0)
{
- return AE_CONF_ERROR;
+ return AEC_CONF_ERROR;
}
/* Internal state for decoder */
state = (decode_state *) malloc(sizeof(decode_state));
if (state == NULL)
{
- return AE_MEM_ERROR;
+ return AEC_MEM_ERROR;
}
strm->state = state;
{
state->id_len = 5;
- if (strm->bit_per_sample <= 24 && strm->flags & AE_DATA_3BYTE)
+ if (strm->bit_per_sample <= 24 && strm->flags & AEC_DATA_3BYTE)
{
state->byte_per_sample = 3;
- if (strm->flags & AE_DATA_MSB)
+ if (strm->flags & AEC_DATA_MSB)
state->put_sample = put_msb_24;
else
state->put_sample = put_lsb_24;
else
{
state->byte_per_sample = 4;
- if (strm->flags & AE_DATA_MSB)
+ if (strm->flags & AEC_DATA_MSB)
state->put_sample = put_msb_32;
else
state->put_sample = put_lsb_32;
state->byte_per_sample = 2;
state->id_len = 4;
state->out_blklen = strm->block_size * 2;
- if (strm->flags & AE_DATA_MSB)
+ if (strm->flags & AEC_DATA_MSB)
state->put_sample = put_msb_16;
else
state->put_sample = put_lsb_16;
state->id_len = 3;
state->out_blklen = strm->block_size;
state->put_sample = put_8;
-
}
- if (strm->flags & AE_DATA_SIGNED)
+ if (strm->flags & AEC_DATA_SIGNED)
{
state->xmin = -(1ULL << (strm->bit_per_sample - 1));
state->xmax = (1ULL << (strm->bit_per_sample - 1)) - 1;
state->id_table = (int *)malloc(modi * sizeof(int));
if (state->id_table == NULL)
{
- return AE_MEM_ERROR;
+ return AEC_MEM_ERROR;
}
state->id_table[0] = M_LOW_ENTROPY;
for (i = 1; i < modi - 1; i++)
state->block = (int64_t *)malloc(strm->block_size * sizeof(int64_t));
if (state->block == NULL)
{
- return AE_MEM_ERROR;
+ return AEC_MEM_ERROR;
}
strm->total_in = 0;
strm->total_out = 0;
state->samples_out = 0;
state->bitp = 0;
state->fs = 0;
- state->pp = strm->flags & AE_DATA_PREPROCESS;
+ state->pp = strm->flags & AEC_DATA_PREPROCESS;
state->mode = M_ID;
- return AE_OK;
+ return AEC_OK;
}
-int ae_decode_end(ae_streamp strm)
+int aec_decode_end(aec_streamp strm)
{
decode_state *state;
free(state->block);
free(state->id_table);
free(state);
- return AE_OK;
+ return AEC_OK;
}
#define ASK(n) \
} while (0)
-int ae_decode(ae_streamp strm, int flush)
+int aec_decode(aec_streamp strm, int flush)
{
/**
Finite-state machine implementation of the adaptive entropy
break;
default:
- return AE_STREAM_ERROR;
+ return AEC_STREAM_ERROR;
}
}
req_buffer:
- return AE_OK;
+ return AEC_OK;
}
/**
- * @file aee.c
+ * @file encode.c
* @author Mathis Rosenhauer, Deutsches Klimarechenzentrum
* @section DESCRIPTION
*
#include <inttypes.h>
#include <string.h>
-#include "libae.h"
-#include "aee.h"
-#include "aee_accessors.h"
+#include "libaec.h"
+#include "encode.h"
+#include "encode_accessors.h"
/* Marker for Remainder Of Segment condition in zero block encoding */
#define ROS -1
#define MIN(a, b) (((a) < (b))? (a): (b))
-static int m_get_block(ae_streamp strm);
-static int m_get_block_cautious(ae_streamp strm);
-static int m_check_zero_block(ae_streamp strm);
-static int m_select_code_option(ae_streamp strm);
-static int m_flush_block(ae_streamp strm);
-static int m_flush_block_cautious(ae_streamp strm);
-static int m_encode_splitting(ae_streamp strm);
-static int m_encode_uncomp(ae_streamp strm);
-static int m_encode_se(ae_streamp strm);
-static int m_encode_zero(ae_streamp strm);
+static int m_get_block(aec_streamp strm);
+static int m_get_block_cautious(aec_streamp strm);
+static int m_check_zero_block(aec_streamp strm);
+static int m_select_code_option(aec_streamp strm);
+static int m_flush_block(aec_streamp strm);
+static int m_flush_block_cautious(aec_streamp strm);
+static int m_encode_splitting(aec_streamp strm);
+static int m_encode_uncomp(aec_streamp strm);
+static int m_encode_se(aec_streamp strm);
+static int m_encode_zero(aec_streamp strm);
/*
*
}
#define EMITBLOCK(ref) \
- static inline void emitblock_##ref(ae_streamp strm, int k) \
+ static inline void emitblock_##ref(aec_streamp strm, int k) \
{ \
int b; \
uint64_t a; \
EMITBLOCK(0);
EMITBLOCK(1);
-static void preprocess_unsigned(ae_streamp strm)
+static void preprocess_unsigned(aec_streamp strm)
{
int i;
int64_t theta, Delta, prev;
}
}
-static void preprocess_signed(ae_streamp strm)
+static void preprocess_signed(aec_streamp strm)
{
int i, m;
int64_t theta, Delta, prev, sample;
*
*/
-static int m_get_block(ae_streamp strm)
+static int m_get_block(aec_streamp strm)
{
encode_state *state = strm->state;
{
state->get_block(strm);
- if (strm->flags & AE_DATA_PREPROCESS)
+ if (strm->flags & AEC_DATA_PREPROCESS)
state->preprocess(strm);
return m_check_zero_block(strm);
return M_CONTINUE;
}
-static int m_get_block_cautious(ae_streamp strm)
+static int m_get_block_cautious(aec_streamp strm)
{
int j;
encode_state *state = strm->state;
}
else
{
- if (state->flush == AE_FLUSH)
+ if (state->flush == AEC_FLUSH)
{
if (state->i > 0)
{
}
while (++state->i < strm->rsi * strm->block_size);
- if (strm->flags & AE_DATA_PREPROCESS)
+ if (strm->flags & AEC_DATA_PREPROCESS)
state->preprocess(strm);
return m_check_zero_block(strm);
}
-static inline int m_check_zero_block(ae_streamp strm)
+static inline int m_check_zero_block(aec_streamp strm)
{
int i;
encode_state *state = strm->state;
return M_CONTINUE;
}
-static inline int m_select_code_option(ae_streamp strm)
+static inline int m_select_code_option(aec_streamp strm)
{
int i, j, k, this_bs, looked_bothways, direction;
uint64_t split_len, uncomp_len;
}
}
-static inline int m_encode_splitting(ae_streamp strm)
+static inline int m_encode_splitting(aec_streamp strm)
{
int i;
encode_state *state = strm->state;
return m_flush_block(strm);
}
-static inline int m_encode_uncomp(ae_streamp strm)
+static inline int m_encode_uncomp(aec_streamp strm)
{
encode_state *state = strm->state;
return m_flush_block(strm);
}
-static inline int m_encode_se(ae_streamp strm)
+static inline int m_encode_se(aec_streamp strm)
{
int i;
uint32_t d;
return m_flush_block(strm);
}
-static inline int m_encode_zero(ae_streamp strm)
+static inline int m_encode_zero(aec_streamp strm)
{
encode_state *state = strm->state;
return m_flush_block(strm);
}
-static inline int m_flush_block(ae_streamp strm)
+static inline int m_flush_block(aec_streamp strm)
{
int n;
encode_state *state = strm->state;
return M_CONTINUE;
}
-static inline int m_flush_block_cautious(ae_streamp strm)
+static inline int m_flush_block_cautious(aec_streamp strm)
{
encode_state *state = strm->state;
*
*/
-int ae_encode_init(ae_streamp strm)
+int aec_encode_init(aec_streamp strm)
{
int bs, bsi;
encode_state *state;
/* Some sanity checks */
if (strm->bit_per_sample > 32 || strm->bit_per_sample == 0)
- return AE_CONF_ERROR;
+ return AEC_CONF_ERROR;
if (strm->block_size != 8
&& strm->block_size != 16
&& strm->block_size != 32
&& strm->block_size != 64)
- return AE_CONF_ERROR;
+ return AEC_CONF_ERROR;
if (strm->rsi > 4096)
- return AE_CONF_ERROR;
+ return AEC_CONF_ERROR;
/* Internal state for encoder */
state = (encode_state *) malloc(sizeof(encode_state));
if (state == NULL)
{
- return AE_MEM_ERROR;
+ return AEC_MEM_ERROR;
}
memset(state, 0, sizeof(encode_state));
strm->state = state;
/* 24/32 input bit settings */
state->id_len = 5;
- if (strm->bit_per_sample <= 24 && strm->flags & AE_DATA_3BYTE)
+ if (strm->bit_per_sample <= 24 && strm->flags & AEC_DATA_3BYTE)
{
state->block_len = 3 * strm->block_size;
- if (strm->flags & AE_DATA_MSB)
+ if (strm->flags & AEC_DATA_MSB)
{
state->get_sample = get_msb_24;
state->get_block = get_block_funcs_msb_24[bsi];
else
{
state->block_len = 4 * strm->block_size;
- if (strm->flags & AE_DATA_MSB)
+ if (strm->flags & AEC_DATA_MSB)
{
state->get_sample = get_msb_32;
state->get_block = get_block_funcs_msb_32[bsi];
state->id_len = 4;
state->block_len = 2 * strm->block_size;
- if (strm->flags & AE_DATA_MSB)
+ if (strm->flags & AEC_DATA_MSB)
{
state->get_sample = get_msb_16;
state->get_block = get_block_funcs_msb_16[bsi];
state->get_block = get_block_funcs_8[bsi];
}
- if (strm->flags & AE_DATA_SIGNED)
+ if (strm->flags & AEC_DATA_SIGNED)
{
state->xmin = -(1ULL << (strm->bit_per_sample - 1));
state->xmax = (1ULL << (strm->bit_per_sample - 1)) - 1;
* sizeof(uint32_t));
if (state->block_buf == NULL)
{
- return AE_MEM_ERROR;
+ return AEC_MEM_ERROR;
}
state->block_p = state->block_buf;
state->cds_buf = (uint8_t *)malloc(state->cds_len);
if (state->cds_buf == NULL)
{
- return AE_MEM_ERROR;
+ return AEC_MEM_ERROR;
}
strm->total_in = 0;
state->bit_p = 8;
state->mode = m_get_block;
- return AE_OK;
+ return AEC_OK;
}
-int ae_encode(ae_streamp strm, int flush)
+int aec_encode(aec_streamp strm, int flush)
{
/**
Finite-state machine implementation of the adaptive entropy
state->cds_p = state->cds_buf;
state->direct_out = 0;
}
- return AE_OK;
+ return AEC_OK;
}
-int ae_encode_end(ae_streamp strm)
+int aec_encode_end(aec_streamp strm)
{
encode_state *state = strm->state;
free(state->block_buf);
free(state->cds_buf);
free(state);
- return AE_OK;
+ return AEC_OK;
}
-#ifndef AAE_H
-#define AAE_H
+#ifndef ENCODE_H
+#define ENCODE_H
#include <inttypes.h>
-#include "libae.h"
+#include "libaec.h"
#define M_CONTINUE 1
#define M_EXIT 0
typedef struct internal_state {
- int (*mode)(ae_streamp);
- void (*get_block)(ae_streamp);
- uint32_t (*get_sample)(ae_streamp);
- void (*preprocess)(ae_streamp);
+ int (*mode)(aec_streamp);
+ void (*get_block)(aec_streamp);
+ uint32_t (*get_sample)(aec_streamp);
+ void (*preprocess)(aec_streamp);
int id_len; /* bit length of code option identification key */
int64_t xmin; /* minimum integer for preprocessing */
int flush; /* flush option copied from argument */
} encode_state;
-#endif
+#endif /* ENCODE_H */
#include <inttypes.h>
#include <string.h>
-#include "libae.h"
-#include "aee.h"
-#include "aee_accessors.h"
+#include "libaec.h"
+#include "encode.h"
+#include "encode_accessors.h"
-uint32_t get_8(ae_streamp strm)
+uint32_t get_8(aec_streamp strm)
{
strm->avail_in--;
strm->total_in++;
return *strm->next_in++;
}
-uint32_t get_lsb_24(ae_streamp strm)
+uint32_t get_lsb_24(aec_streamp strm)
{
uint32_t data;
return data;
}
-uint32_t get_msb_24(ae_streamp strm)
+uint32_t get_msb_24(aec_streamp strm)
{
uint32_t data;
#ifdef WORDS_BIGENDIAN
-uint32_t get_lsb_16(ae_streamp strm)
+uint32_t get_lsb_16(aec_streamp strm)
{
uint32_t data;
return data;
}
-uint32_t get_msb_16(ae_streamp strm)
+uint32_t get_msb_16(aec_streamp strm)
{
uint32_t data;
return data;
}
-uint32_t get_lsb_32(ae_streamp strm)
+uint32_t get_lsb_32(aec_streamp strm)
{
uint32_t data;
return data;
}
-uint32_t get_msb_32(ae_streamp strm)
+uint32_t get_msb_32(aec_streamp strm)
{
uint32_t data;
strm->avail_in -= 4;
return data;
}
-#else /* LITTLEENDIAN */
+#else /* not WORDS_BIGENDIAN */
-uint32_t get_lsb_16(ae_streamp strm)
+uint32_t get_lsb_16(aec_streamp strm)
{
uint32_t data;
return data;
}
-uint32_t get_msb_16(ae_streamp strm)
+uint32_t get_msb_16(aec_streamp strm)
{
uint32_t data;
return data;
}
-uint32_t get_lsb_32(ae_streamp strm)
+uint32_t get_lsb_32(aec_streamp strm)
{
uint32_t data;
return data;
}
-uint32_t get_msb_32(ae_streamp strm)
+uint32_t get_msb_32(aec_streamp strm)
{
uint32_t data;
strm->avail_in -= 4;
return data;
}
-#endif
+#endif /* not WORDS_BIGENDIAN */
#define GET_BLOCK_8(BS) \
- static void get_block_8_bs_##BS(ae_streamp strm) \
+ static void get_block_8_bs_##BS(aec_streamp strm) \
{ \
int i, j; \
uint32_t *block = strm->state->block_buf; \
}
#define GET_BLOCK_NATIVE_16(BS) \
- static void get_block_native_16_bs_##BS(ae_streamp strm) \
+ static void get_block_native_16_bs_##BS(aec_streamp strm) \
{ \
int i, j; \
uint32_t *block = strm->state->block_buf; \
}
#define GET_BLOCK_LSB_16(BS) \
- static void get_block_lsb_16_bs_##BS(ae_streamp strm) \
+ static void get_block_lsb_16_bs_##BS(aec_streamp strm) \
{ \
int i, j; \
uint32_t *block = strm->state->block_buf; \
}
#define GET_BLOCK_MSB_16(BS) \
- static void get_block_msb_16_bs_##BS(ae_streamp strm) \
+ static void get_block_msb_16_bs_##BS(aec_streamp strm) \
{ \
int i, j; \
uint32_t *block = strm->state->block_buf; \
}
#define GET_BLOCK_LSB_24(BS) \
- static void get_block_lsb_24_bs_##BS(ae_streamp strm) \
+ static void get_block_lsb_24_bs_##BS(aec_streamp strm) \
{ \
int i, j; \
uint32_t *block = strm->state->block_buf; \
}
#define GET_BLOCK_MSB_24(BS) \
- static void get_block_msb_24_bs_##BS(ae_streamp strm) \
+ static void get_block_msb_24_bs_##BS(aec_streamp strm) \
{ \
int i, j; \
uint32_t *block = strm->state->block_buf; \
}
#define GET_BLOCK_NATIVE_32(BS) \
- static void get_block_native_32_bs_##BS(ae_streamp strm) \
+ static void get_block_native_32_bs_##BS(aec_streamp strm) \
{ \
memcpy(strm->state->block_buf, \
strm->next_in, \
}
#define GET_BLOCK_LSB_32(BS) \
- static void get_block_lsb_32_bs_##BS(ae_streamp strm) \
+ static void get_block_lsb_32_bs_##BS(aec_streamp strm) \
{ \
int i, j; \
uint32_t *block = strm->state->block_buf; \
}
#define GET_BLOCK_MSB_32(BS) \
- static void get_block_msb_32_bs_##BS(ae_streamp strm) \
+ static void get_block_msb_32_bs_##BS(aec_streamp strm) \
{ \
int i, j; \
uint32_t *block = strm->state->block_buf; \
}
#define GET_BLOCK_FUNCS(A, B) \
- void (*get_block_funcs_##A[])(ae_streamp) = { \
+ void (*get_block_funcs_##A[])(aec_streamp) = { \
get_block_##B##_bs_8, \
get_block_##B##_bs_16, \
get_block_##B##_bs_32, \
GET_BLOCK_FUNCS(lsb_32, lsb_32);
GET_BLOCK_FUNCS(msb_32, native_32);
-#else /* LITTLEENDIAN */
+#else /* not WORDS_BIGENDIAN */
GET_BLOCK_MSB_16(8);
GET_BLOCK_MSB_16(16);
GET_BLOCK_FUNCS(lsb_32, native_32);
GET_BLOCK_FUNCS(msb_32, msb_32);
-#endif
+#endif /* not WORDS_BIGENDIAN */
--- /dev/null
+#ifndef ENCODE_ACCESSORS_H
+#define ENCODE_ACCESSORS_H
+
+#include <inttypes.h>
+#include "libaec.h"
+
+uint32_t get_8(aec_streamp strm);
+uint32_t get_lsb_16(aec_streamp strm);
+uint32_t get_msb_16(aec_streamp strm);
+uint32_t get_lsb_32(aec_streamp strm);
+uint32_t get_msb_24(aec_streamp strm);
+uint32_t get_lsb_24(aec_streamp strm);
+uint32_t get_msb_32(aec_streamp strm);
+
+extern void (*get_block_funcs_8[4])(aec_streamp);
+extern void (*get_block_funcs_lsb_16[4])(aec_streamp);
+extern void (*get_block_funcs_msb_16[4])(aec_streamp);
+extern void (*get_block_funcs_lsb_24[4])(aec_streamp);
+extern void (*get_block_funcs_msb_24[4])(aec_streamp);
+extern void (*get_block_funcs_lsb_32[4])(aec_streamp);
+extern void (*get_block_funcs_msb_32[4])(aec_streamp);
+
+#endif /* ENCODE_ACCESSORS_H */
-#ifndef LIBAE_H
-#define LIBAE_H
+#ifndef LIBAEC_H
+#define LIBAEC_H
#include <inttypes.h>
#include <stddef.h>
struct internal_state;
-typedef struct _ae_stream
+typedef struct _aec_stream
{
const uint8_t *next_in;
size_t avail_in; /* number of bytes available at
uint32_t flags;
struct internal_state *state;
-} ae_stream;
+} aec_stream;
-typedef ae_stream *ae_streamp;
+typedef aec_stream *aec_streamp;
/* Coder flags */
-#define AE_DATA_UNSIGNED 0
-#define AE_DATA_SIGNED 1
-#define AE_DATA_3BYTE 2 /* 24 bit samples coded in 3 bytes */
-#define AE_DATA_LSB 0
-#define AE_DATA_MSB 16
-#define AE_DATA_PREPROCESS 32 /* Set if preprocessor should be used */
+#define AEC_DATA_UNSIGNED 0
+#define AEC_DATA_SIGNED 1
+#define AEC_DATA_3BYTE 2 /* 24 bit samples coded in 3 bytes */
+#define AEC_DATA_LSB 0
+#define AEC_DATA_MSB 16
+#define AEC_DATA_PREPROCESS 32 /* Set if preprocessor should be used */
/* Return codes of library functions */
-#define AE_OK 0
-#define AE_CONF_ERROR (-1)
-#define AE_STREAM_ERROR (-2)
-#define AE_DATA_ERROR (-3)
-#define AE_MEM_ERROR (-4)
+#define AEC_OK 0
+#define AEC_CONF_ERROR (-1)
+#define AEC_STREAM_ERROR (-2)
+#define AEC_DATA_ERROR (-3)
+#define AEC_MEM_ERROR (-4)
/* Options for flushing */
-#define AE_NO_FLUSH 0 /* Do not enforce output flushing. More
+#define AEC_NO_FLUSH 0 /* Do not enforce output flushing. More
* input may be provided with later
* calls. So far only relevant for
* encoding.
*/
-#define AE_FLUSH 1 /* Flush output and end encoding. The last
- * call to ae_encode() must set AE_FLUSH to
+#define AEC_FLUSH 1 /* Flush output and end encoding. The last
+ * call to aec_encode() must set AEC_FLUSH to
* drain all output.
*
* It is not possible to continue encoding
* padded with fill bits.
*/
-int ae_decode_init(ae_streamp strm);
-int ae_decode(ae_streamp strm, int flush);
-int ae_decode_end(ae_streamp strm);
+int aec_decode_init(aec_streamp strm);
+int aec_decode(aec_streamp strm, int flush);
+int aec_decode_end(aec_streamp strm);
-int ae_encode_init(ae_streamp strm);
-int ae_encode(ae_streamp strm, int flush);
-int ae_encode_end(ae_streamp strm);
+int aec_encode_init(aec_streamp strm);
+int aec_encode(aec_streamp strm, int flush);
+int aec_encode_end(aec_streamp strm);
-#endif /* LIBAE_H */
+#endif /* LIBAEC_H */
int SZ_BufftoBuffCompress(void *dest, size_t *destLen, const void *source, size_t sourceLen, SZ_com_t *param)
{
int status;
- ae_stream strm;
+ aec_stream strm;
strm.bit_per_sample = param->bits_per_pixel;
strm.block_size = param->pixels_per_block;
strm.next_out = dest;
strm.next_in = source;
- if ((status = ae_encode_init(&strm)) != AE_OK)
+ if ((status = aec_encode_init(&strm)) != AEC_OK)
return status;
- if ((status = ae_encode(&strm, AE_FLUSH)) != AE_OK)
+ if ((status = aec_encode(&strm, AEC_FLUSH)) != AEC_OK)
return status;
*destLen = strm.total_out;
- if ((status = ae_encode_end(&strm)) != AE_OK)
+ if ((status = aec_encode_end(&strm)) != AEC_OK)
return status;
return SZ_OK;
int SZ_BufftoBuffDecompress(void *dest, size_t *destLen, const void *source, size_t sourceLen, SZ_com_t *param)
{
int status;
- ae_stream strm;
+ aec_stream strm;
strm.bit_per_sample = param->bits_per_pixel;
strm.block_size = param->pixels_per_block;
strm.next_out = dest;
strm.next_in = source;
- if ((status = ae_decode_init(&strm)) != AE_OK)
+ if ((status = aec_decode_init(&strm)) != AEC_OK)
return status;
- if ((status = ae_decode(&strm, AE_FLUSH)) != AE_OK)
+ if ((status = aec_decode(&strm, AEC_FLUSH)) != AEC_OK)
return status;
*destLen = strm.total_out;
- if ((status = ae_decode_end(&strm)) != AE_OK)
+ if ((status = aec_decode_end(&strm)) != AEC_OK)
return status;
return SZ_OK;
#ifndef SZLIB_H
#define SZLIB_H
-#include "libae.h"
+#include "libaec.h"
-#define SZ_OK AE_OK
+#define SZ_OK AEC_OK
#define SZ_NO_ENCODER_ERROR -1
-#define SZ_PARAM_ERROR AE_ERRNO
-#define SZ_MEM_ERROR AE_MEM_ERROR
+#define SZ_PARAM_ERROR AEC_ERRNO
+#define SZ_MEM_ERROR AEC_MEM_ERROR
#define SZ_OUTBUFF_FULL -2
#define SZ_RAW_OPTION_MASK 128
-#define SZ_NN_OPTION_MASK AE_DATA_PREPROCESS
-#define SZ_LSB_OPTION_MASK AE_DATA_LSB
-#define SZ_MSB_OPTION_MASK AE_DATA_MSB
+#define SZ_NN_OPTION_MASK AEC_DATA_PREPROCESS
+#define SZ_LSB_OPTION_MASK AEC_DATA_LSB
+#define SZ_MSB_OPTION_MASK AEC_DATA_MSB
typedef struct SZ_com_t_s
{