Rename everything to aec
authorMathis Rosenhauer <rosenhauer@dkrz.de>
Sun, 16 Sep 2012 15:33:24 +0000 (17:33 +0200)
committerThomas Jahns <jahns@dkrz.de>
Tue, 19 Feb 2013 10:32:59 +0000 (11:32 +0100)
src/aec.c
src/aee_accessors.h [deleted file]
src/decode.c [moved from src/aed.c with 91% similarity]
src/encode.c [moved from src/aee.c with 91% similarity]
src/encode.h [moved from src/aee.h with 87% similarity]
src/encode_accessors.c [moved from src/aee_accessors.c with 91% similarity]
src/encode_accessors.h [new file with mode: 0644]
src/libaec.h [moved from src/libae.h with 60% similarity]
src/sz_compat.c
src/szlib.h

index 7c6522b..b8d6d5f 100644 (file)
--- a/src/aec.c
+++ b/src/aec.c
@@ -5,13 +5,13 @@
 #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;
@@ -25,7 +25,7 @@ int main(int argc, char *argv[])
     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)
@@ -50,13 +50,13 @@ int main(int argc, char *argv[])
             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')
@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
 
     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;
@@ -124,16 +124,16 @@ int main(int argc, char *argv[])
 
         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)
@@ -142,12 +142,12 @@ int main(int argc, char *argv[])
 
     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;
     }
 
@@ -162,11 +162,11 @@ int main(int argc, char *argv[])
         }
 
         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;
@@ -189,11 +189,11 @@ int main(int argc, char *argv[])
 
     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;
@@ -204,7 +204,7 @@ int main(int argc, char *argv[])
             fwrite(out, strm.total_out - total_out, 1, outfp);
         }
 
-        ae_encode_end(&strm);
+        aec_encode_end(&strm);
     }
 
     fclose(infp);
diff --git a/src/aee_accessors.h b/src/aee_accessors.h
deleted file mode 100644 (file)
index 943218f..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#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
similarity index 91%
rename from src/aed.c
rename to src/decode.c
index 6896e05..7e1ed8b 100644 (file)
--- a/src/aed.c
@@ -7,7 +7,7 @@
 #include <inttypes.h>
 #include <string.h>
 
-#include "libae.h"
+#include "libaec.h"
 
 #define MIN(a, b) (((a) < (b))? (a): (b))
 
@@ -20,7 +20,7 @@ typedef struct internal_state {
     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 */
@@ -42,7 +42,8 @@ typedef struct internal_state {
 } 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},
@@ -74,7 +75,7 @@ enum
     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;
@@ -84,7 +85,7 @@ static void put_msb_32(ae_streamp strm, int64_t data)
     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;
@@ -93,7 +94,7 @@ static void put_msb_24(ae_streamp strm, int64_t data)
     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;
@@ -101,7 +102,7 @@ static void put_msb_16(ae_streamp strm, int64_t 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;
@@ -111,7 +112,7 @@ static void put_lsb_32(ae_streamp strm, int64_t data)
     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;
@@ -120,7 +121,7 @@ static void put_lsb_24(ae_streamp strm, int64_t data)
     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;
@@ -128,14 +129,14 @@ static void put_lsb_16(ae_streamp strm, int64_t data)
     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;
@@ -163,7 +164,7 @@ static inline void u_put(ae_streamp strm, int64_t sample)
     }
     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 */
@@ -175,7 +176,7 @@ static inline void u_put(ae_streamp strm, int64_t sample)
     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
@@ -197,7 +198,7 @@ static inline int64_t u_get(ae_streamp strm, unsigned int n)
     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.
@@ -214,7 +215,7 @@ static inline int64_t u_get_fs(ae_streamp strm)
     return fs;
 }
 
-static inline void fast_split(ae_streamp strm)
+static inline void fast_split(aec_streamp strm)
 {
     int i, k;
     decode_state *state;
@@ -235,7 +236,7 @@ static inline void fast_split(ae_streamp strm)
     }
 }
 
-static inline void fast_zero(ae_streamp strm)
+static inline void fast_zero(aec_streamp strm)
 {
     int i = strm->state->i;
 
@@ -243,7 +244,7 @@ static inline void fast_zero(ae_streamp strm)
         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;
@@ -267,7 +268,7 @@ static inline void fast_se(ae_streamp strm)
     }
 }
 
-static inline void fast_uncomp(ae_streamp strm)
+static inline void fast_uncomp(aec_streamp strm)
 {
     int i;
 
@@ -275,7 +276,7 @@ static inline void fast_uncomp(ae_streamp strm)
         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;
@@ -283,14 +284,14 @@ int ae_decode_init(ae_streamp strm)
     /* 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;
 
@@ -298,10 +299,10 @@ int ae_decode_init(ae_streamp strm)
     {
         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;
@@ -309,7 +310,7 @@ int ae_decode_init(ae_streamp strm)
         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;
@@ -322,7 +323,7 @@ int ae_decode_init(ae_streamp strm)
         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;
@@ -333,10 +334,9 @@ int ae_decode_init(ae_streamp strm)
         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;
@@ -355,7 +355,7 @@ int ae_decode_init(ae_streamp strm)
     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++)
@@ -367,7 +367,7 @@ int ae_decode_init(ae_streamp strm)
     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;
@@ -375,12 +375,12 @@ int ae_decode_init(ae_streamp strm)
     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;
 
@@ -388,7 +388,7 @@ int ae_decode_end(ae_streamp strm)
     free(state->block);
     free(state->id_table);
     free(state);
-    return AE_OK;
+    return AEC_OK;
 }
 
 #define ASK(n)                                           \
@@ -452,7 +452,7 @@ int ae_decode_end(ae_streamp strm)
     } 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
@@ -643,10 +643,10 @@ int ae_decode(ae_streamp strm, int flush)
             break;
 
         default:
-            return AE_STREAM_ERROR;
+            return AEC_STREAM_ERROR;
         }
     }
 
 req_buffer:
-    return AE_OK;
+    return AEC_OK;
 }
similarity index 91%
rename from src/aee.c
rename to src/encode.c
index 98c42ea..9aaef18 100644 (file)
--- a/src/aee.c
@@ -1,5 +1,5 @@
 /**
- * @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);
 
 /*
  *
@@ -89,7 +89,7 @@ static inline void emitfs(encode_state *state, int fs)
 }
 
 #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;                                             \
@@ -126,7 +126,7 @@ static inline void emitfs(encode_state *state, int fs)
 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;
@@ -160,7 +160,7 @@ static void preprocess_unsigned(ae_streamp strm)
     }
 }
 
-static void preprocess_signed(ae_streamp strm)
+static void preprocess_signed(aec_streamp strm)
 {
     int i, m;
     int64_t theta, Delta, prev, sample;
@@ -202,7 +202,7 @@ static void preprocess_signed(ae_streamp strm)
  *
  */
 
-static int m_get_block(ae_streamp strm)
+static int m_get_block(aec_streamp strm)
 {
     encode_state *state = strm->state;
 
@@ -236,7 +236,7 @@ static int m_get_block(ae_streamp strm)
         {
             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);
@@ -257,7 +257,7 @@ static int m_get_block(ae_streamp 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;
@@ -270,7 +270,7 @@ static int m_get_block_cautious(ae_streamp strm)
         }
         else
         {
-            if (state->flush == AE_FLUSH)
+            if (state->flush == AEC_FLUSH)
             {
                 if (state->i > 0)
                 {
@@ -310,13 +310,13 @@ static int m_get_block_cautious(ae_streamp strm)
     }
     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;
@@ -361,7 +361,7 @@ static inline int m_check_zero_block(ae_streamp strm)
     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;
@@ -534,7 +534,7 @@ static inline int m_select_code_option(ae_streamp strm)
     }
 }
 
-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;
@@ -559,7 +559,7 @@ static inline int m_encode_splitting(ae_streamp strm)
     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;
 
@@ -569,7 +569,7 @@ static inline int m_encode_uncomp(ae_streamp strm)
     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;
@@ -588,7 +588,7 @@ static inline int m_encode_se(ae_streamp strm)
     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;
 
@@ -608,7 +608,7 @@ static inline int m_encode_zero(ae_streamp strm)
     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;
@@ -628,7 +628,7 @@ static inline int m_flush_block(ae_streamp strm)
     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;
 
@@ -653,29 +653,29 @@ static inline int m_flush_block_cautious(ae_streamp strm)
  *
  */
 
-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;
@@ -690,10 +690,10 @@ int ae_encode_init(ae_streamp strm)
         /* 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];
@@ -707,7 +707,7 @@ int ae_encode_init(ae_streamp strm)
         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];
@@ -725,7 +725,7 @@ int ae_encode_init(ae_streamp strm)
         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];
@@ -746,7 +746,7 @@ int ae_encode_init(ae_streamp strm)
         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;
@@ -764,7 +764,7 @@ int ae_encode_init(ae_streamp strm)
                                          * sizeof(uint32_t));
     if (state->block_buf == NULL)
     {
-        return AE_MEM_ERROR;
+        return AEC_MEM_ERROR;
     }
     state->block_p = state->block_buf;
 
@@ -773,7 +773,7 @@ int ae_encode_init(ae_streamp strm)
     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;
@@ -784,10 +784,10 @@ int ae_encode_init(ae_streamp strm)
     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
@@ -811,15 +811,15 @@ int ae_encode(ae_streamp strm, int flush)
         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;
 }
similarity index 87%
rename from src/aee.h
rename to src/encode.h
index 0d3070f..e3dd7fc 100644 (file)
--- a/src/aee.h
@@ -1,17 +1,17 @@
-#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 */
@@ -37,4 +37,4 @@ typedef struct internal_state {
     int flush;              /* flush option copied from argument */
 } encode_state;
 
-#endif
+#endif /* ENCODE_H */
similarity index 91%
rename from src/aee_accessors.c
rename to src/encode_accessors.c
index 391c445..9a5478b 100644 (file)
@@ -1,17 +1,17 @@
 #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;
 
@@ -25,7 +25,7 @@ uint32_t get_lsb_24(ae_streamp strm)
     return data;
 }
 
-uint32_t get_msb_24(ae_streamp strm)
+uint32_t get_msb_24(aec_streamp strm)
 {
     uint32_t data;
 
@@ -41,7 +41,7 @@ uint32_t get_msb_24(ae_streamp strm)
 
 #ifdef WORDS_BIGENDIAN
 
-uint32_t get_lsb_16(ae_streamp strm)
+uint32_t get_lsb_16(aec_streamp strm)
 {
     uint32_t data;
 
@@ -54,7 +54,7 @@ uint32_t get_lsb_16(ae_streamp strm)
     return data;
 }
 
-uint32_t get_msb_16(ae_streamp strm)
+uint32_t get_msb_16(aec_streamp strm)
 {
     uint32_t data;
 
@@ -65,7 +65,7 @@ uint32_t get_msb_16(ae_streamp strm)
     return data;
 }
 
-uint32_t get_lsb_32(ae_streamp strm)
+uint32_t get_lsb_32(aec_streamp strm)
 {
     uint32_t data;
 
@@ -80,7 +80,7 @@ uint32_t get_lsb_32(ae_streamp strm)
     return data;
 }
 
-uint32_t get_msb_32(ae_streamp strm)
+uint32_t get_msb_32(aec_streamp strm)
 {
     uint32_t data;
 
@@ -90,9 +90,9 @@ uint32_t get_msb_32(ae_streamp strm)
     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;
 
@@ -103,7 +103,7 @@ uint32_t get_lsb_16(ae_streamp strm)
     return data;
 }
 
-uint32_t get_msb_16(ae_streamp strm)
+uint32_t get_msb_16(aec_streamp strm)
 {
     uint32_t data;
 
@@ -116,7 +116,7 @@ uint32_t get_msb_16(ae_streamp strm)
     return data;
 }
 
-uint32_t get_lsb_32(ae_streamp strm)
+uint32_t get_lsb_32(aec_streamp strm)
 {
     uint32_t data;
 
@@ -127,7 +127,7 @@ uint32_t get_lsb_32(ae_streamp strm)
     return data;
 }
 
-uint32_t get_msb_32(ae_streamp strm)
+uint32_t get_msb_32(aec_streamp strm)
 {
     uint32_t data;
 
@@ -141,10 +141,10 @@ uint32_t get_msb_32(ae_streamp strm)
     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;                    \
@@ -159,7 +159,7 @@ uint32_t get_msb_32(ae_streamp strm)
     }
 
 #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;                    \
@@ -175,7 +175,7 @@ uint32_t get_msb_32(ae_streamp strm)
     }
 
 #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;                    \
@@ -193,7 +193,7 @@ uint32_t get_msb_32(ae_streamp strm)
     }
 
 #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;                    \
@@ -210,7 +210,7 @@ uint32_t get_msb_32(ae_streamp strm)
     }
 
 #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;                    \
@@ -230,7 +230,7 @@ uint32_t get_msb_32(ae_streamp strm)
     }
 
 #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;                    \
@@ -250,7 +250,7 @@ uint32_t get_msb_32(ae_streamp strm)
     }
 
 #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,                                        \
@@ -262,7 +262,7 @@ uint32_t get_msb_32(ae_streamp strm)
     }
 
 #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;                    \
@@ -284,7 +284,7 @@ uint32_t get_msb_32(ae_streamp strm)
     }
 
 #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;                    \
@@ -306,7 +306,7 @@ uint32_t get_msb_32(ae_streamp strm)
     }
 
 #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,                          \
@@ -361,7 +361,7 @@ GET_BLOCK_FUNCS(msb_16, native_16);
 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);
@@ -378,4 +378,4 @@ GET_BLOCK_FUNCS(msb_16, msb_16);
 GET_BLOCK_FUNCS(lsb_32, native_32);
 GET_BLOCK_FUNCS(msb_32, msb_32);
 
-#endif
+#endif /* not WORDS_BIGENDIAN */
diff --git a/src/encode_accessors.h b/src/encode_accessors.h
new file mode 100644 (file)
index 0000000..421cd51
--- /dev/null
@@ -0,0 +1,23 @@
+#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 */
similarity index 60%
rename from src/libae.h
rename to src/libaec.h
index 58385dd..e20907e 100644 (file)
@@ -1,12 +1,12 @@
-#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
@@ -25,33 +25,33 @@ typedef struct _ae_stream
     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
@@ -60,12 +60,12 @@ typedef ae_stream *ae_streamp;
                             * 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 */
index ea6ec03..d691734 100644 (file)
@@ -5,7 +5,7 @@
 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;
@@ -16,15 +16,15 @@ int SZ_BufftoBuffCompress(void *dest, size_t *destLen, const void *source, size_
     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;
@@ -33,7 +33,7 @@ int SZ_BufftoBuffCompress(void *dest, size_t *destLen, const void *source, size_
 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;
@@ -44,15 +44,15 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen, const void *source, siz
     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;
index 3f24a1d..45e7a0c 100644 (file)
@@ -1,18 +1,18 @@
 #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
 {