44 void *fld,
int fld_is_double,
int verbose)
47 g2int j, ctemplen, nbits;
48 g2int ccsds_flags, ccsds_block_size, ccsds_rsi;
50 float ref, bscale, dscale;
57 LOG((2,
"aecunpack_int len %ld ndpts %ld fld_is_double %d", len, ndpts, fld_is_double));
63 ccsds_flags = idrstmpl[5];
64 ccsds_block_size = idrstmpl[6];
65 ccsds_rsi = idrstmpl[7];
71 if (!(ifld = calloc(ndpts,
sizeof(
g2int))))
74 fprintf(stderr,
"Could not allocate space in aecunpack.\n Data field NOT upacked.\n");
78 ctemplen = ((nbits + 7)/8) * (size_t) ndpts;
79 if ((ctemp = (
unsigned char *) malloc(ctemplen)) == NULL)
82 fprintf(stderr,
"Allocation error.\n");
85 ret =
dec_aec(cpack, len, nbits, ccsds_flags, ccsds_block_size, ccsds_rsi, ctemp, ctemplen);
88 gbits(ctemp, ifld, 0, nbits, 0, ndpts);
91 for (j = 0; j < ndpts; j++)
92 dfld[j] = (((
float)ifld[j] * bscale) + ref) * dscale;
96 for (j = 0; j < ndpts; j++)
97 ffld[j] = (((
float)ifld[j] * bscale) + ref) * dscale;
106 for (j = 0; j < ndpts; j++)
111 for (j = 0; j < ndpts; j++)
144 LOG((2,
"g2c_aecunpack len %lld ndpts %lld", len, ndpts));
176 g2int len8 = len, ndpts8 = ndpts;
179 LOG((2,
"g2c_aecunpackf len %d ndpts %lld", len, ndpts));
182 idrstmpl8[i] = idrstmpl[i];
184 return aecunpack_int(cpack, len8, idrstmpl8, ndpts8, fld, 0, 0);
214 g2int len8 = len, ndpts8 = ndpts;
217 LOG((2,
"g2c_aecunpackd len %lld ndpts %lld", len, ndpts));
220 idrstmpl8[i] = idrstmpl[i];
222 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)
This internal function will unpack AEC compressed data into an array of floats or doubles,...
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)
This Function decodes 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)
Get bits - unpack bits: Extract arbitrary size values from a packed bit string, right justifying each...
#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)
This subroutine reads a list of real values in 32-bit IEEE floating point format.