Improve compatibility with HDF5 - all checks passed
authorMathis Rosenhauer <rosenhauer@dkrz.de>
Thu, 4 Oct 2012 15:23:30 +0000 (17:23 +0200)
committerThomas Jahns <jahns@dkrz.de>
Tue, 19 Feb 2013 10:33:00 +0000 (11:33 +0100)
src/libaec.h
src/sz_compat.c
src/szlib.h

index 1587857..91c8485 100644 (file)
@@ -30,19 +30,18 @@ struct aec_stream {
 };
 
 /* Sample data description flags */
-#define AEC_DATA_UNSIGNED     0  /* Samples are unsigned integers (default) */
-#define AEC_DATA_SIGNED       1  /* Samples are signed. Telling libaec
+#define AEC_DATA_SIGNED 1        /* Samples are signed. Telling libaec
                                   * this results in a slightly better
-                                  * compression ratio.
+                                  * compression ratio. Default is
+                                  * unsigned.
                                   */
-#define AEC_DATA_3BYTE        2  /* 24 bit samples are coded in 3 bytes */
-#define AEC_DATA_MSB         16  /* Samples are stored with their most
+#define AEC_DATA_3BYTE 2         /* 24 bit samples are coded in 3 bytes */
+#define AEC_DATA_MSB 4           /* Samples are stored with their most
                                   * significant bit first. This has
                                   * nothing to do with the endianness
-                                  * of the host.
+                                  * of the host. Default is LSB.
                                   */
-#define AEC_DATA_LSB          0  /* Samples are stored LSB first (default) */
-#define AEC_DATA_PREPROCESS  32  /* Set if preprocessor should be used */
+#define AEC_DATA_PREPROCESS 8    /* Set if preprocessor should be used */
 
 /* Return codes of library functions */
 #define AEC_OK            0
index 7e32ea2..b61818a 100644 (file)
@@ -3,6 +3,24 @@
 #include "szlib.h"
 #include "libaec.h"
 
+#define NOPTS 129
+
+static int convert_options(int sz_opts)
+{
+    int co[NOPTS];
+    int i;
+    int opts = 0;
+
+    memset(co, 0, sizeof(int) * NOPTS);
+    co[SZ_MSB_OPTION_MASK] = AEC_DATA_MSB;
+    co[SZ_NN_OPTION_MASK] = AEC_DATA_PREPROCESS;
+
+    for (i = 1; i < NOPTS; i <<= 1)
+        opts |= co[i];
+
+    return opts;
+}
+
 int SZ_BufftoBuffCompress(void *dest, size_t *destLen,
                           const void *source, size_t sourceLen,
                           SZ_com_t *param)
@@ -13,7 +31,7 @@ int SZ_BufftoBuffCompress(void *dest, size_t *destLen,
     strm.bit_per_sample = param->bits_per_pixel;
     strm.block_size = param->pixels_per_block;
     strm.rsi = param->pixels_per_scanline / param->pixels_per_block;
-    strm.flags = param->options_mask;
+    strm.flags = convert_options(param->options_mask);
     strm.avail_in = sourceLen;
     strm.avail_out = *destLen;
     strm.next_out = dest;
@@ -37,7 +55,7 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen,
     strm.bit_per_sample = param->bits_per_pixel;
     strm.block_size = param->pixels_per_block;
     strm.rsi = param->pixels_per_scanline / param->pixels_per_block;
-    strm.flags = param->options_mask;
+    strm.flags = convert_options(param->options_mask);
     strm.avail_in = sourceLen;
     strm.avail_out = *destLen;
     strm.next_out = dest;
@@ -50,3 +68,8 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen,
     *destLen = strm.total_out;
     return SZ_OK;
 }
+
+int SZ_encoder_enabled(void)
+{
+    return 1;
+}
index 5ce9e65..4ad55cf 100644 (file)
@@ -3,16 +3,24 @@
 
 #include "libaec.h"
 
+#define SZ_ALLOW_K13_OPTION_MASK         1
+#define SZ_CHIP_OPTION_MASK              2
+#define SZ_EC_OPTION_MASK                4
+#define SZ_LSB_OPTION_MASK               8
+#define SZ_MSB_OPTION_MASK              16
+#define SZ_NN_OPTION_MASK               32
+#define SZ_RAW_OPTION_MASK             128
+
 #define SZ_OK AEC_OK
 #define SZ_NO_ENCODER_ERROR -1
 #define SZ_PARAM_ERROR AEC_CONF_ERROR
 #define SZ_MEM_ERROR AEC_MEM_ERROR
 #define SZ_OUTBUFF_FULL -2
 
-#define SZ_RAW_OPTION_MASK 128
-#define SZ_NN_OPTION_MASK AEC_DATA_PREPROCESS
-#define SZ_LSB_OPTION_MASK AEC_DATA_LSB
-#define SZ_MSB_OPTION_MASK AEC_DATA_MSB
+#define SZ_MAX_PIXELS_PER_BLOCK 32
+#define SZ_MAX_BLOCKS_PER_SCANLINE 128
+#define SZ_MAX_PIXELS_PER_SCANLINE                              \
+    (SZ_MAX_BLOCKS_PER_SCANLINE) * (SZ_MAX_PIXELS_PER_BLOCK)
 
 typedef struct SZ_com_t_s
 {
@@ -29,4 +37,6 @@ int SZ_BufftoBuffDecompress(void *dest, size_t *destLen,
                             const void *source, size_t sourceLen,
                             SZ_com_t *param);
 
+int SZ_encoder_enabled(void);
+
 #endif /* SZLIB_H */