Commit 90e25ec4 authored by Mathis Rosenhauer's avatar Mathis Rosenhauer Committed by Thomas Jahns

clean up

parent 833113b8
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])
......@@ -12,15 +12,15 @@ AM_INIT_AUTOMAKE
# 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
......@@ -31,9 +31,8 @@ AC_TYPE_UINT8_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
......@@ -4,14 +4,8 @@ encode.h encode_accessors.h decode.h
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
......@@ -73,7 +73,6 @@ struct internal_state {
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 */
......@@ -81,7 +80,6 @@ struct internal_state {
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 */
......
......@@ -204,9 +204,12 @@ static void preprocess_unsigned(struct aec_stream *strm)
{
/**
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;
......@@ -217,22 +220,21 @@ static void preprocess_unsigned(struct aec_stream *strm)
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)
......@@ -271,6 +273,7 @@ static void preprocess_signed(struct aec_stream *strm)
x++;
d++;
}
state->ref = 1;
}
static uint64_t block_fs(struct aec_stream *strm, int k)
......@@ -649,7 +652,7 @@ static int m_get_rsi_resumable(struct aec_stream *strm)
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++;
......@@ -662,11 +665,8 @@ static int m_get_rsi_resumable(struct aec_stream *strm)
}
} 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);
}
......@@ -698,16 +698,14 @@ static int m_get_block(struct aec_stream *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;
......@@ -757,45 +755,46 @@ int aec_encode_init(struct aec_stream *strm)
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));
......
......@@ -79,7 +79,7 @@ struct internal_state {
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) */
......
......@@ -61,14 +61,14 @@
#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;
......@@ -81,7 +81,7 @@ uint32_t get_lsb_16(struct aec_stream *strm)
return data;
}
uint32_t get_msb_16(struct aec_stream *strm)
uint32_t aec_get_msb_16(struct aec_stream *strm)
{
uint32_t data;
......@@ -94,7 +94,7 @@ uint32_t get_msb_16(struct aec_stream *strm)
return data;
}
uint32_t get_lsb_24(struct aec_stream *strm)
uint32_t aec_get_lsb_24(struct aec_stream *strm)
{
uint32_t data;
......@@ -108,7 +108,7 @@ uint32_t get_lsb_24(struct aec_stream *strm)
return data;
}
uint32_t get_msb_24(struct aec_stream *strm)
uint32_t aec_get_msb_24(struct aec_stream *strm)
{
uint32_t data;
......@@ -122,7 +122,7 @@ uint32_t get_msb_24(struct aec_stream *strm)
return data;
}
uint32_t get_lsb_32(struct aec_stream *strm)
uint32_t aec_get_lsb_32(struct aec_stream *strm)
{
uint32_t data;
......@@ -137,7 +137,7 @@ uint32_t get_lsb_32(struct aec_stream *strm)
return data;
}
uint32_t get_msb_32(struct aec_stream *strm)
uint32_t aec_get_msb_32(struct aec_stream *strm)
{
uint32_t data;
......@@ -152,7 +152,7 @@ uint32_t get_msb_32(struct aec_stream *strm)
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;
......@@ -177,7 +177,7 @@ void get_rsi_8(struct aec_stream *strm)
}
}
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;
......@@ -210,7 +210,7 @@ void get_rsi_lsb_16(struct aec_stream *strm)
}
}
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;
......@@ -243,7 +243,7 @@ void get_rsi_msb_16(struct aec_stream *strm)
}
}
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;
......@@ -284,7 +284,7 @@ void get_rsi_lsb_24(struct aec_stream *strm)
}
}
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;
......@@ -325,8 +325,8 @@ void get_rsi_msb_24(struct aec_stream *strm)
}
}
#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, \
......@@ -337,7 +337,7 @@ void get_rsi_msb_24(struct aec_stream *strm)
}
#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;
......@@ -386,10 +386,10 @@ void get_rsi_lsb_32(struct aec_stream *strm)
}
}
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;
......@@ -438,6 +438,6 @@ void get_rsi_msb_32(struct aec_stream *strm)
}
}
GET_RSI_NATIVE_32(lsb);
AEC_GET_RSI_NATIVE_32(lsb);
#endif /* !WORDS_BIGENDIAN */
......@@ -61,20 +61,20 @@
#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 */
......@@ -10,5 +10,4 @@ $(top_builddir)/src/libaec.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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment