Commit 160ea631 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cgribexlib update

parent 5490f8b4
/* Automatically generated by m214003 at 2013-01-29, do not edit */
/* Automatically generated by m214003 at 2013-02-05, do not edit */
/* CGRIBEXLIB_VERSION="1.6.0" */
......@@ -1714,6 +1714,7 @@ void encode_double_array_unrolled(int numBits, size_t packStart, size_t datasize
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
/*
#if ((__GNUC__ >= 4) || (__ICC >= 1100) || defined (__clang__))
#define _ENABLE_SIMD
#include <immintrin.h>
......@@ -1724,6 +1725,7 @@ void encode_double_array_unrolled(int numBits, size_t packStart, size_t datasize
#define _ENABLE_SSE4_1
#endif
#endif
*/
#undef _ENABLE_AVX
#undef _ENABLE_SSE4_1
......@@ -9898,10 +9900,11 @@ extern "C" {
#endif
#if defined (HAVE_LIBAEC)
# define AEC_FLAGS (AEC_DATA_MSB | AEC_DATA_PREPROCESS)
# define AEC_FLAGS (AEC_DATA_MSB | AEC_DATA_PREPROCESS)
#else
# define OPTIONS_MASK (SZ_RAW_OPTION_MASK | SZ_MSB_OPTION_MASK | SZ_NN_OPTION_MASK)
#endif
# define PIXELS_PER_BLOCK (8)
# define PIXELS_PER_SCANLINE (PIXELS_PER_BLOCK*128)
......@@ -9909,6 +9912,18 @@ extern "C" {
# define MIN_SIZE (256)
#endif
#define Z_SZIP 128
#define Z_AEC 130
#define SetLen3(var, offset, value) ((var[offset+0] = 0xFF & (value >> 16)), \
(var[offset+1] = 0xFF & (value >> 8)), \
(var[offset+2] = 0xFF & (value )))
#define SetLen4(var, offset, value) ((var[offset+0] = 0xFF & (value >> 24)), \
(var[offset+1] = 0xFF & (value >> 16)), \
(var[offset+2] = 0xFF & (value >> 8)), \
(var[offset+3] = 0xFF & (value )))
int gribGetZip(long recsize, unsigned char *gribbuffer, long *urecsize)
{
......@@ -9943,7 +9958,7 @@ int gribGetZip(long recsize, unsigned char *gribbuffer, long *urecsize)
if ( lcompress )
{
compress = BDS_Z;
if ( compress == 128 )
if ( compress == Z_SZIP || compress == Z_AEC )
{
gribsize = gribrec_len(bds[14], bds[15], bds[16]);
}
......@@ -9997,10 +10012,12 @@ int gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
int bds_len, bds_nbits, bds_flag, lspherc, lcomplex,/* lcompress,*/ bds_ubits;
int bds_head = 11;
int bds_ext = 0;
int bds_zoffset = 12;
int bds_zoffset, bds_zstart;
unsigned char *pbuf = NULL;
if ( llarge ) bds_zoffset = 14;
bds_zstart = 14;
bds_zoffset = 12;
if ( llarge ) bds_zoffset += 2;
bds_len = BDS_Len;
bds_len = correct_bdslen(bds_len, gribLen, bds-dbuf);
......@@ -10021,18 +10038,20 @@ int gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
}
return (rec_len);
}
#if defined (HAVE_LIBSZ)
if ( bds_nbits == 24 )
bits_per_sample = 8;
else
#endif
bits_per_sample = bds_nbits;
#if defined (HAVE_LIBAEC)
strm.bits_per_sample = bits_per_sample;
strm.block_size = PIXELS_PER_BLOCK;
strm.rsi = PIXELS_PER_SCANLINE / PIXELS_PER_BLOCK;
strm.flags = AEC_FLAGS;
strm.block_size = PIXELS_PER_BLOCK;
strm.rsi = PIXELS_PER_SCANLINE / PIXELS_PER_BLOCK;
strm.flags = AEC_FLAGS;
if ( bds_nbits == 24 ) strm.flags |= AEC_DATA_3BYTE;
#else
sz_param.options_mask = OPTIONS_MASK;
sz_param.bits_per_pixel = bits_per_sample;
......@@ -10069,6 +10088,7 @@ int gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
source = bds + datstart;
dest = sbuf;
#if defined (HAVE_LIBSZ)
if ( bds_nbits == 24 )
{
long nelem;
......@@ -10082,6 +10102,7 @@ int gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
}
source = pbuf;
}
#endif
#if defined (HAVE_LIBAEC)
strm.next_in = source;
......@@ -10090,7 +10111,7 @@ int gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
strm.avail_out = destLen;
status = aec_buffer_encode(&strm);
if (status != AEC_OK)
if ( status != AEC_OK )
Warning("AEC ERROR: %d code %3d level %3d", status, PDS_Parameter, PDS_Level2);
destLen = strm.total_out;
......@@ -10136,7 +10157,7 @@ int gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
*/
/* memcpy(bds + datstart + bds_zoffset, source, destLen); */
/*
fprintf(stderr, "z>>> %d %d %d %d <<<\n", (int) bds[0+datstart+bds_zoffset],
fprintf(stderr, "z>>> %d %d %d %d <<<\n", (int) bds[0+datstart+bds_zoffset],
(int)bds[1+datstart+bds_zoffset], (int)bds[2+datstart+bds_zoffset], (int)bds[3+datstart+bds_zoffset]);
*/
if ( llarge )
......@@ -10148,40 +10169,27 @@ int gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
}
gribLenOld = gribLenOld / (-120);
gribLenOld = JP23SET - gribLenOld + 1;
bds[14] = 0xFF & (gribLenOld >> 16);
bds[15] = 0xFF & (gribLenOld >> 8);
bds[16] = 0xFF & (gribLenOld);
bds[17] = 0xFF & (sourceLen >> 24);
bds[18] = 0xFF & (sourceLen >> 16);
bds[19] = 0xFF & (sourceLen >> 8);
bds[20] = 0xFF & (sourceLen);
bds[21] = 0xFF & (destLen >> 24);
bds[22] = 0xFF & (destLen >> 16);
bds[23] = 0xFF & (destLen >> 8);
bds[24] = 0xFF & (destLen);
SetLen3(bds, bds_zstart, gribLenOld);
SetLen4(bds, bds_zstart+3, sourceLen);
SetLen4(bds, bds_zstart+7, destLen);
}
else
{
bds[14] = 0xFF & (gribLenOld >> 16);
bds[15] = 0xFF & (gribLenOld >> 8);
bds[16] = 0xFF & (gribLenOld);
bds[17] = 0xFF & (sourceLen >> 16);
bds[18] = 0xFF & (sourceLen >> 8);
bds[19] = 0xFF & (sourceLen);
bds[20] = 0xFF & (destLen >> 16);
bds[21] = 0xFF & (destLen >> 8);
bds[22] = 0xFF & (destLen);
SetLen3(bds, bds_zstart, gribLenOld);
SetLen3(bds, bds_zstart+3, sourceLen);
SetLen3(bds, bds_zstart+6, destLen);
}
bdsLen = datstart + bds_zoffset + destLen;
bds[11] = 0;
bds[12] = 0;
BDS_Z = 128;
#if defined (HAVE_LIBAEC)
BDS_Z = Z_AEC;
#else
BDS_Z = Z_SZIP;
#endif
BDS_Flag += 16;
if ( (bdsLen%2) == 1 )
......@@ -10190,9 +10198,7 @@ int gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
bds[bdsLen++] = 0;
}
bds[0] = 0xFF & (bdsLen >> 16);
bds[1] = 0xFF & (bdsLen >> 8);
bds[2] = 0xFF & (bdsLen);
SetLen3(bds, 0, bdsLen);
gribLen = (bds - dbuf) + bdsLen;
......@@ -10219,21 +10225,15 @@ int gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
itemp = gribLen / (-120);
itemp = JP23SET - itemp + 1;
dbuf[4] = 0xFF & (itemp >> 16);
dbuf[5] = 0xFF & (itemp >> 8);
dbuf[6] = 0xFF & (itemp);
SetLen3(dbuf, 4, itemp);
bdslen = gribLen - bdslen;
bds[0] = 0xFF & (bdsLen >> 16);
bds[1] = 0xFF & (bdsLen >> 8);
bds[2] = 0xFF & (bdsLen);
SetLen3(bds, 0, bdsLen);
}
else
{
dbuf[4] = 0xFF & (gribLen >> 16);
dbuf[5] = 0xFF & (gribLen >> 8);
dbuf[6] = 0xFF & (gribLen);
SetLen3(dbuf, 4, gribLen);
}
}
/*
......@@ -10273,7 +10273,7 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
int /* bds_len, */ bds_nbits, bds_flag, lspherc, lcomplex /*, lcompress*/;
int bds_head = 11;
int bds_ext = 0;
int bds_zoffset = 12;
int bds_zoffset, bds_zstart;
int datstart = 0;
int llarge = FALSE;
......@@ -10284,10 +10284,13 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
return (0);
}
recLen = gribrec_len(bds[14], bds[15], bds[16]);
bds_zstart = 14;
recLen = gribrec_len(bds[bds_zstart], bds[bds_zstart+1], bds[bds_zstart+2]);
if ( recLen > JP23SET ) llarge = TRUE;
if ( llarge ) bds_zoffset = 14;
bds_zoffset = 12;
if ( llarge ) bds_zoffset += 2;
/* bds_len = BDS_Len; */
bds_nbits = BDS_NumBits;
......@@ -10327,7 +10330,7 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
}
dest = bds + datstart;
if ( llarge )
if ( llarge )
destLen = ((size_t) ((bds[17]<<24)+(bds[18]<<16)+(bds[19]<<8)+bds[20]));
else
destLen = ((size_t) ((bds[17]<<16)+(bds[18]<<8)+bds[19]));
......@@ -10349,16 +10352,19 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
SZ_com_t sz_param; /* szip parameter block */
#endif
#if defined (HAVE_LIBSZ)
if ( bds_nbits == 24 )
bits_per_sample = 8;
else
#endif
bits_per_sample = bds_nbits;
#if defined (HAVE_LIBAEC)
strm.bits_per_sample = bits_per_sample;
strm.block_size = PIXELS_PER_BLOCK;
strm.rsi = PIXELS_PER_SCANLINE / PIXELS_PER_BLOCK;
strm.flags = AEC_FLAGS;
strm.bits_per_sample = bits_per_sample;
strm.block_size = PIXELS_PER_BLOCK;
strm.rsi = PIXELS_PER_SCANLINE / PIXELS_PER_BLOCK;
strm.flags = AEC_FLAGS;
if ( bds_nbits == 24 ) strm.flags |= AEC_DATA_3BYTE;
#else
sz_param.options_mask = OPTIONS_MASK;
sz_param.bits_per_pixel = bits_per_sample;
......@@ -10378,9 +10384,9 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
tmpLen = destLen;
#if defined (HAVE_LIBAEC)
strm.next_in = source;
strm.avail_in = sourceLen;
strm.next_out = dest;
strm.next_in = source;
strm.avail_in = sourceLen;
strm.next_out = dest;
strm.avail_out = tmpLen;
status = aec_buffer_decode(&strm);
......@@ -10411,7 +10417,8 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
if ( tmpLen != destLen )
Warning("unzip size differ: code %3d level %3d ibuflen %ld ubuflen %ld",
PDS_Parameter, PDS_Level2, (long) destLen, (long) tmpLen);
#if defined (HAVE_LIBSZ)
if ( bds_nbits == 24 )
{
long nelem;
......@@ -10427,7 +10434,8 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
memcpy(dest, pbuf, tmpLen);
free(pbuf);
}
#endif
bds_ubits = BDS_Flag & 15;
BDS_Flag -= bds_ubits;
......@@ -10437,9 +10445,7 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
bds[bdsLen++] = 0;
}
bds[0] = 0xFF & (bdsLen >> 16);
bds[1] = 0xFF & (bdsLen >> 8);
bds[2] = 0xFF & (bdsLen);
SetLen3(bds, 0, bdsLen);
gribLen = (bds - dbuf) + bdsLen;
......@@ -10468,21 +10474,15 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
itemp = gribLen / (-120);
itemp = JP23SET - itemp + 1;
dbuf[4] = 0xFF & (itemp >> 16);
dbuf[5] = 0xFF & (itemp >> 8);
dbuf[6] = 0xFF & (itemp);
SetLen3(dbuf, 4, itemp);
bdsLen = gribLen - bdsLen;
bds[0] = 0xFF & (bdsLen >> 16);
bds[1] = 0xFF & (bdsLen >> 8);
bds[2] = 0xFF & (bdsLen);
SetLen3(bds, 0, bdsLen);
}
else
{
dbuf[4] = 0xFF & (recLen >> 16);
dbuf[5] = 0xFF & (recLen >> 8);
dbuf[6] = 0xFF & (recLen);
SetLen3(dbuf, 4, recLen);
}
/*
fprintf(stderr, "recLen, gribLen, bdsLen %d %d %d\n", recLen, gribLen, bdsLen);
......@@ -10495,14 +10495,14 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
#else
if ( libszwarn )
{
Warning("Decompression disabled, szlib not available!");
Warning("Decompression disabled, szlib or libaec not available!");
libszwarn = 0;
}
#endif
return (gribLen);
}
static const char grb_libvers[] = "1.6.0" " of ""Jan 29 2013"" ""10:43:15";
static const char grb_libvers[] = "1.6.0" " of ""Feb 5 2013"" ""13:19:33";
const char *
cgribexLibraryVersion(void)
{
......
Supports Markdown
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