-AC_PREREQ([2.68])
-AC_INIT([libaec], [0.0.2], [rosenhauer@dkrz.de])
+AC_PREREQ([2.64])
+AC_INIT([libaec], [0.1.0], [rosenhauer@dkrz.de])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([config])
# Checks for programs.
AC_PROG_CC
-AC_PROG_CXX
# Checks for libraries.
AC_CHECK_LIB([aec], [aec_decode])
# Checks for header files.
-AC_CHECK_HEADERS([inttypes.h stddef.h stdlib.h string.h unistd.h])
+AC_HEADER_STDC
# Checks for typedefs, structures, and compiler characteristics.
+AC_C_BIGENDIAN
AC_C_INLINE
AC_TYPE_INT64_T
AC_TYPE_SIZE_T
# Checks for library functions.
AC_CHECK_FUNCS([memset strstr])
-AC_CONFIG_FILES([Makefile
- src/Makefile
+AC_CONFIG_FILES([Makefile \
+ src/Makefile \
tests/Makefile])
-AC_C_BIGENDIAN
AC_OUTPUT
libsz_la_SOURCES = sz_compat.c
libsz_la_LIBADD = libaec.la
-libaec_la_LDFLAGS = -version-info 0:0
-libsz_la_LDFLAGS = -version-info 0:0
include_HEADERS = libaec.h szlib.h
-bin_PROGRAMS = aec test_szcomp
-
+bin_PROGRAMS = aec
aec_LDADD = libaec.la
-test_szcomp_LDADD = libsz.la
-
aec_SOURCES = aec.c
-test_szcomp_SOURCES = test_szcomp.c
int id_len; /* bit length of code option identification key */
int (**id_table)(struct aec_stream *); /* table maps IDs to states */
void (*flush_output)(struct aec_stream *);
- 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 */
int64_t xmax; /* maximum integer for post-processing */
should be the longest possible block */
int out_blklen; /* length of output block in bytes */
int n, i; /* counter for samples */
- int se; /* set if second extension option is selected */
uint64_t acc; /* accumulator for currently used bit sequence */
int bitp; /* bit pointer to the next unused bit in
accumulator */
{
/**
Preprocess RSI of unsigned samples.
+
+ Combining preprocessing and converting to uint32_t in one loop
+ is slower due to the data dependance on x_i-1.
*/
- int64_t D;
+ uint32_t D;
struct internal_state *state = strm->state;
const uint32_t *x = state->data_raw;
uint32_t *d = state->data_pp;
while (rsi--) {
if (x[1] >= x[0]) {
D = x[1] - x[0];
- if (D <= x[0]) {
+ if (D <= x[0])
*d = 2 * D;
- } else {
+ else
*d = x[1];
- }
} else {
D = x[0] - x[1];
- if (D <= xmax - x[0]) {
+ if (D <= xmax - x[0])
*d = 2 * D - 1;
- } else {
+ else
*d = xmax - x[1];
- }
}
d++;
x++;
}
+ state->ref = 1;
}
static void preprocess_signed(struct aec_stream *strm)
x++;
d++;
}
+ state->ref = 1;
}
static uint64_t block_fs(struct aec_stream *strm, int k)
emit(state, 0, state->bits);
if (strm->avail_out > 0) {
- if (state->direct_out == 0)
+ if (!state->direct_out)
*strm->next_out++ = *state->cds;
strm->avail_out--;
strm->total_out++;
}
} while (++state->i < strm->rsi * strm->block_size);
- state->blocks_avail = strm->rsi - 1;
- if (strm->flags & AEC_DATA_PREPROCESS) {
+ if (strm->flags & AEC_DATA_PREPROCESS)
state->preprocess(strm);
- state->ref = 1;
- }
return m_check_zero_block(strm);
}
}
if (state->blocks_avail == 0) {
+ state->blocks_avail = strm->rsi - 1;
state->block = state->data_pp;
- if (strm->avail_in >= state->block_len * strm->rsi) {
+ if (strm->avail_in >= state->rsi_len) {
state->get_rsi(strm);
- state->blocks_avail = strm->rsi - 1;
-
- if (strm->flags & AEC_DATA_PREPROCESS) {
+ if (strm->flags & AEC_DATA_PREPROCESS)
state->preprocess(strm);
- state->ref = 1;
- }
+
return m_check_zero_block(strm);
} else {
state->i = 0;
if (strm->bits_per_sample <= 24
&& strm->flags & AEC_DATA_3BYTE) {
- state->block_len = 3 * strm->block_size;
+ state->rsi_len = 3;
if (strm->flags & AEC_DATA_MSB) {
- state->get_sample = get_msb_24;
- state->get_rsi = get_rsi_msb_24;
+ state->get_sample = aec_get_msb_24;
+ state->get_rsi = aec_get_rsi_msb_24;
} else {
- state->get_sample = get_lsb_24;
- state->get_rsi = get_rsi_lsb_24;
+ state->get_sample = aec_get_lsb_24;
+ state->get_rsi = aec_get_rsi_lsb_24;
}
} else {
- state->block_len = 4 * strm->block_size;
+ state->rsi_len = 4;
if (strm->flags & AEC_DATA_MSB) {
- state->get_sample = get_msb_32;
- state->get_rsi = get_rsi_msb_32;
+ state->get_sample = aec_get_msb_32;
+ state->get_rsi = aec_get_rsi_msb_32;
} else {
- state->get_sample = get_lsb_32;
- state->get_rsi = get_rsi_lsb_32;
+ state->get_sample = aec_get_lsb_32;
+ state->get_rsi = aec_get_rsi_lsb_32;
}
}
}
else if (strm->bits_per_sample > 8) {
/* 16 bit settings */
state->id_len = 4;
- state->block_len = 2 * strm->block_size;
+ state->rsi_len = 2;
if (strm->flags & AEC_DATA_MSB) {
- state->get_sample = get_msb_16;
- state->get_rsi = get_rsi_msb_16;
+ state->get_sample = aec_get_msb_16;
+ state->get_rsi = aec_get_rsi_msb_16;
} else {
- state->get_sample = get_lsb_16;
- state->get_rsi = get_rsi_lsb_16;
+ state->get_sample = aec_get_lsb_16;
+ state->get_rsi = aec_get_rsi_lsb_16;
}
} else {
/* 8 bit settings */
state->id_len = 3;
- state->block_len = strm->block_size;
+ state->rsi_len = 1;
- state->get_sample = get_8;
- state->get_rsi = get_rsi_8;
+ state->get_sample = aec_get_8;
+ state->get_rsi = aec_get_rsi_8;
}
+ state->rsi_len *= strm->rsi * strm->block_size;
if (strm->flags & AEC_DATA_SIGNED) {
state->xmin = -(1ULL << (strm->bits_per_sample - 1));
uint32_t *data_raw; /* RSI blocks of input */
int blocks_avail; /* remaining blocks in buffer */
uint32_t *block; /* current (preprocessed) input block */
- int block_len; /* input block length in byte */
+ int rsi_len; /* reference sample interval in byte */
uint8_t *cds; /* current Coded Data Set output */
uint8_t *cds_buf; /* buffer for one CDS (only used if
* strm->next_out cannot hold full CDS) */
#include "encode.h"
#include "encode_accessors.h"
-uint32_t get_8(struct aec_stream *strm)
+uint32_t aec_get_8(struct aec_stream *strm)
{
strm->avail_in--;
strm->total_in++;
return *strm->next_in++;
}
-uint32_t get_lsb_16(struct aec_stream *strm)
+uint32_t aec_get_lsb_16(struct aec_stream *strm)
{
uint32_t data;
return data;
}
-uint32_t get_msb_16(struct aec_stream *strm)
+uint32_t aec_get_msb_16(struct aec_stream *strm)
{
uint32_t data;
return data;
}
-uint32_t get_lsb_24(struct aec_stream *strm)
+uint32_t aec_get_lsb_24(struct aec_stream *strm)
{
uint32_t data;
return data;
}
-uint32_t get_msb_24(struct aec_stream *strm)
+uint32_t aec_get_msb_24(struct aec_stream *strm)
{
uint32_t data;
return data;
}
-uint32_t get_lsb_32(struct aec_stream *strm)
+uint32_t aec_get_lsb_32(struct aec_stream *strm)
{
uint32_t data;
return data;
}
-uint32_t get_msb_32(struct aec_stream *strm)
+uint32_t aec_get_msb_32(struct aec_stream *strm)
{
uint32_t data;
return data;
}
-void get_rsi_8(struct aec_stream *strm)
+void aec_get_rsi_8(struct aec_stream *strm)
{
uint32_t *out = strm->state->data_raw;
unsigned const char *in = strm->next_in;
}
}
-void get_rsi_lsb_16(struct aec_stream *strm)
+void aec_get_rsi_lsb_16(struct aec_stream *strm)
{
uint32_t *out = strm->state->data_raw;
const unsigned char *in = strm->next_in;
}
}
-void get_rsi_msb_16(struct aec_stream *strm)
+void aec_get_rsi_msb_16(struct aec_stream *strm)
{
uint32_t *out = strm->state->data_raw;
const unsigned char *in = strm->next_in;
}
}
-void get_rsi_lsb_24(struct aec_stream *strm)
+void aec_get_rsi_lsb_24(struct aec_stream *strm)
{
uint32_t *out = strm->state->data_raw;
const unsigned char *in = strm->next_in;
}
}
-void get_rsi_msb_24(struct aec_stream *strm)
+void aec_get_rsi_msb_24(struct aec_stream *strm)
{
uint32_t *out = strm->state->data_raw;
const unsigned char *in = strm->next_in;
}
}
-#define GET_RSI_NATIVE_32(BO) \
- void get_rsi_##BO##_32(struct aec_stream *strm) \
+#define AEC_GET_RSI_NATIVE_32(BO) \
+ void aec_get_rsi_##BO##_32(struct aec_stream *strm) \
{ \
int rsi = strm->rsi * strm->block_size; \
memcpy(strm->state->data_raw, \
}
#ifdef WORDS_BIGENDIAN
-void get_rsi_lsb_32(struct aec_stream *strm)
+void aec_get_rsi_lsb_32(struct aec_stream *strm)
{
uint32_t *out = strm->state->data_raw;
const unsigned char *in = strm->next_in;
}
}
-GET_RSI_NATIVE_32(msb);
+AEC_GET_RSI_NATIVE_32(msb);
#else /* !WORDS_BIGENDIAN */
-void get_rsi_msb_32(struct aec_stream *strm)
+void aec_get_rsi_msb_32(struct aec_stream *strm)
{
uint32_t *out = strm->state->data_raw;
const unsigned char *in = strm->next_in;
}
}
-GET_RSI_NATIVE_32(lsb);
+AEC_GET_RSI_NATIVE_32(lsb);
#endif /* !WORDS_BIGENDIAN */
#include "libaec.h"
-uint32_t get_8(struct aec_stream *strm);
-uint32_t get_lsb_16(struct aec_stream *strm);
-uint32_t get_msb_16(struct aec_stream *strm);
-uint32_t get_lsb_32(struct aec_stream *strm);
-uint32_t get_msb_24(struct aec_stream *strm);
-uint32_t get_lsb_24(struct aec_stream *strm);
-uint32_t get_msb_32(struct aec_stream *strm);
+uint32_t aec_get_8(struct aec_stream *strm);
+uint32_t aec_get_lsb_16(struct aec_stream *strm);
+uint32_t aec_get_msb_16(struct aec_stream *strm);
+uint32_t aec_get_lsb_32(struct aec_stream *strm);
+uint32_t aec_get_msb_24(struct aec_stream *strm);
+uint32_t aec_get_lsb_24(struct aec_stream *strm);
+uint32_t aec_get_msb_32(struct aec_stream *strm);
-void get_rsi_8(struct aec_stream *strm);
-void get_rsi_lsb_16(struct aec_stream *strm);
-void get_rsi_msb_16(struct aec_stream *strm);
-void get_rsi_lsb_24(struct aec_stream *strm);
-void get_rsi_msb_24(struct aec_stream *strm);
-void get_rsi_lsb_32(struct aec_stream *strm);
-void get_rsi_msb_32(struct aec_stream *strm);
+void aec_get_rsi_8(struct aec_stream *strm);
+void aec_get_rsi_lsb_16(struct aec_stream *strm);
+void aec_get_rsi_msb_16(struct aec_stream *strm);
+void aec_get_rsi_lsb_24(struct aec_stream *strm);
+void aec_get_rsi_msb_24(struct aec_stream *strm);
+void aec_get_rsi_lsb_32(struct aec_stream *strm);
+void aec_get_rsi_msb_32(struct aec_stream *strm);
#endif /* ENCODE_ACCESSORS_H */
check_buffer_sizes_SOURCES = check_buffer_sizes.c check_aec.h \
$(top_builddir)/src/libaec.h
-check_code_options_LDADD = libcheck_aec.la $(top_builddir)/src/libaec.la
-check_buffer_sizes_LDADD = libcheck_aec.la $(top_builddir)/src/libaec.la
+LDADD = libcheck_aec.la $(top_builddir)/src/libaec.la