44 void *fld,
int fld_is_double,
int verbose)
47 g2int j, ctemplen = 0 , nbits;
48 g2int ccsds_flags, ccsds_block_size, ccsds_rsi;
51 float ref, bscale, dscale;
57 LOG((2,
"aecunpack_int len %ld ndpts %ld fld_is_double %d", len, ndpts, fld_is_double));
64 ccsds_flags = idrstmpl[5];
65 ccsds_block_size = idrstmpl[6];
66 ccsds_rsi = idrstmpl[7];
72 if (!(ifld = calloc(ndpts,
sizeof(
g2int))))
75 fprintf(stderr,
"Could not allocate space in aecunpack.\n Data field NOT upacked.\n");
81 nbytes = (nbits + 7)/8;
84 ctemplen = nbytes * ndpts;
85 if ((ctemp = (
unsigned char *) malloc(ctemplen)) == NULL)
88 fprintf(stderr,
"Allocation error.\n");
93 ret =
dec_aec(cpack, len, nbits, ccsds_flags, ccsds_block_size, ccsds_rsi, ctemp, ctemplen);
99 gbits(ctemp, ifld, 0, nbytes*8, 0, ndpts);
111 for (j = 0; j < ndpts; j++)
112 dfld[j] = (((
float)ifld[j] * bscale) + ref) * dscale;
116 for (j = 0; j < ndpts; j++)
117 ffld[j] = (((
float)ifld[j] * bscale) + ref) * dscale;
128 for (j = 0; j < ndpts; j++)
133 for (j = 0; j < ndpts; j++)
166 LOG((2,
"g2c_aecunpack len %lld ndpts %lld", len, ndpts));
198 g2int len8 = len, ndpts8 = ndpts;
201 LOG((2,
"g2c_aecunpackf len %d ndpts %lld", len, ndpts));
204 idrstmpl8[i] = idrstmpl[i];
206 return aecunpack_int(cpack, len8, idrstmpl8, ndpts8, fld, 0, 0);
236 g2int len8 = len, ndpts8 = ndpts;
239 LOG((2,
"g2c_aecunpackd len %lld ndpts %lld", len, ndpts));
242 idrstmpl8[i] = idrstmpl[i];
244 return aecunpack_int(cpack, len8, idrstmpl8, ndpts8, fld, 1, 0);
int g2c_aecunpackd(unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts, double *fld)
Unpack AEC compressed data into an array of doubles, using info from the GRIB2 Data Representation Te...
g2int aecunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts, float *fld)
Unpack AEC compressed data into an array of floats, using info from the GRIB2 Data Representation Tem...
static int aecunpack_int(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts, void *fld, int fld_is_double, int verbose)
Unpack AEC compressed data into an array of floats or doubles, using info from the GRIB2 Data Represe...
int g2c_aecunpackf(unsigned char *cpack, size_t len, int *idrstmpl, size_t ndpts, float *fld)
Unpack AEC compressed data into an array of floats, using info from the GRIB2 Data Representation Tem...
int dec_aec(unsigned char *cpack, g2int len, g2int nbits, g2int flags, g2int block_size, g2int rsi, unsigned char *cfld, g2int cfldlen)
Decode an AEC code stream specified in the CCSDS 121.0-B-3 Blue Book.
void gbits(unsigned char *in, g2int *iout, g2int iskip, g2int nbits, g2int nskip, g2int n)
Unpack arbitrary size values from a packed bit string, right justifying each value in the unpacked io...
#define G2C_ENOMEM
Out of memory.
#define G2C_AEC_DRS_TEMPLATE_LEN
Length of the idrstmpl array for AEC packing.
int64_t g2int
Long integer type.
#define G2C_NOERROR
No error.
Header file with internal function prototypes NCEPLIBS-g2c library.
double int_power(double x, g2int y)
Function similar to C pow() power function.
#define LOG(e)
Ignore logging to stdout.
void rdieee(g2int *rieee, float *a, g2int num)
Read a list of real values in 32-bit IEEE floating point format.