NCEPLIBS-g2c  1.7.0
grib2_int.h
Go to the documentation of this file.
1 
13 #ifndef _grib2_int_H
14 #define _grib2_int_H
15 
16 #include <stdio.h>
17 #include <stdint.h>
18 #include <assert.h>
19 #include "grib2.h"
20 
21 #define ALOG2 (0.69314718)
23 #define G2C_JASPER_JPEG_FORMAT_NAME "jpc"
28 struct gtemplate
29 {
35 
40 
44 
47 
50 
54 };
55 
56 typedef struct gtemplate gtemplate;
58 /* Legacy support functions. */
59 double int_power(double x, g2int y);
60 void mkieee(float *a, g2int *rieee, g2int num);
61 void rdieee(g2int *rieee, float *a, g2int num);
62 
63 /* Get the various templates. */
65 gtemplate *extdrstemplate(g2int number, g2int *list);
67 gtemplate *extpdstemplate(g2int number, g2int *list);
69 gtemplate *extgridtemplate(g2int number, g2int *list);
70 
71 /* Packing and unpacking data. */
72 void simpack(float *fld, g2int ndpts, g2int *idrstmpl,
73  unsigned char *cpack, g2int *lcpack);
74 g2int simunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts,
75  float *fld);
76 void compack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
77  unsigned char *cpack, g2int *lcpack);
78 int comunpack(unsigned char *cpack, g2int lensec, g2int idrsnum,
79  g2int *idrstmpl, g2int ndpts, float *fld);
80 void misspack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
81  unsigned char *cpack, g2int *lcpack);
82 void cmplxpack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
83  unsigned char *cpack, g2int *lcpack);
84 g2int getpoly(unsigned char *csec3, g2int *jj, g2int *kk, g2int *mm);
85 void specpack(float *fld, g2int ndpts, g2int JJ, g2int KK, g2int MM,
86  g2int *idrstmpl, unsigned char *cpack, g2int *lcpack);
87 g2int specunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts, g2int JJ,
88  g2int KK, g2int MM, float *fld);
89 g2int getdim(unsigned char *csec3, g2int *width, g2int *height, g2int *iscan);
90 
91 int enc_png(unsigned char *data, g2int width, g2int height, g2int nbits,
92  unsigned char *pngbuf);
93 int dec_png(unsigned char *pngbuf, g2int *width, g2int *height,
94  unsigned char *cout);
95 void pngpack(float *fld, g2int width, g2int height, g2int *idrstmpl,
96  unsigned char *cpack, g2int *lcpack);
97 g2int pngunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts,
98  float *fld);
99 int enc_jpeg2000(unsigned char *cin, g2int width, g2int height, g2int nbits,
100  g2int ltype, g2int ratio, g2int retry, char *outjpc,
101  g2int jpclen);
102 int dec_jpeg2000(char *injpc, g2int bufsize, g2int *outfld);
103 void jpcpack(float *fld, g2int width, g2int height, g2int *idrstmpl,
104  unsigned char *cpack, g2int *lcpack);
105 g2int jpcunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts,
106  float *fld);
107 
108 /* Packing and unpacking bits. */
109 void gbit(unsigned char *in, g2int *iout, g2int iskip, g2int nbits);
110 void sbit(unsigned char *out, g2int *in, g2int iskip, g2int nbits);
111 void gbits(unsigned char *in, g2int *iout, g2int iskip, g2int nbits,
112  g2int nskip, g2int n);
113 void sbits(unsigned char *out, g2int *in, g2int iskip, g2int nbits,
114  g2int nskip, g2int n);
115 
116 /* Deal with grib groups. */
117 int pack_gp(g2int *kfildo, g2int *ic, g2int *nxy,
118  g2int *is523, g2int *minpk, g2int *inc, g2int *missp, g2int *misss,
119  g2int *jmin, g2int *jmax, g2int *lbit, g2int *nov,
120  g2int *ndg, g2int *lx, g2int *ibit, g2int *jbit, g2int *kbit,
121  g2int *novref, g2int *lbitref, g2int *ier);
122 
123 /* Check the message header and check for message termination. */
124 int g2c_check_msg(unsigned char *cgrib, g2int *lencurr, int verbose);
125 
126 /* Handle logging. */
127 #ifdef LOGGING
128 
129 /* To log something... */
130 void g2_log(int severity, const char *fmt, ...);
131 
133 #define LOG(e) g2_log e
134 
135 #else /* LOGGING */
136 
138 #define LOG(e)
139 
140 #endif /* LOGGING */
141 
142 #endif /* _grib2_int_H */
extpdstemplate
gtemplate * extpdstemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Product Definition Template,...
Definition: pdstemplates.c:329
gtemplate::ext
g2int * ext
Number of octets of each entry in the extension part of the template.
Definition: grib2_int.h:53
comunpack
int comunpack(unsigned char *cpack, g2int lensec, g2int idrsnum, g2int *idrstmpl, g2int ndpts, float *fld)
This subroutine unpacks a data field that was packed using a complex packing algorithm as defined in ...
Definition: comunpack.c:42
sbits
void sbits(unsigned char *out, g2int *in, g2int iskip, g2int nbits, g2int nskip, g2int n)
Store bits - put arbitrary size values into a packed bit string, taking the low order bits from each ...
Definition: gbits.c:114
getdrstemplate
gtemplate * getdrstemplate(g2int number)
This subroutine returns DRS template information for a specified Data Representation Template.
Definition: drstemplates.c:166
gtemplate::type
g2int type
The template type: 3 Grid Defintion Template.
Definition: grib2_int.h:34
extdrstemplate
gtemplate * extdrstemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Data Representation Template,...
Definition: drstemplates.c:212
rdieee
void rdieee(g2int *rieee, float *a, g2int num)
This subroutine reads a list of real values in 32-bit IEEE floating point format.
Definition: rdieee.c:21
dec_png
int dec_png(unsigned char *pngbuf, g2int *width, g2int *height, unsigned char *cout)
Decode PNG.
Definition: dec_png.c:61
jpcpack
void jpcpack(float *fld, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a data field into a JPEG2000 code stream.
Definition: jpcpack.c:253
gtemplate::needext
g2int needext
Indicates whether or not the template needs to be extended.
Definition: grib2_int.h:46
sbit
void sbit(unsigned char *out, g2int *in, g2int iskip, g2int nbits)
Store bits - put arbitrary size values into a packed bit string, taking the low order bits from each ...
Definition: gbits.c:38
extgridtemplate
gtemplate * extgridtemplate(g2int number, g2int *list)
This subroutine generates the remaining octet map for a given Grid Definition Template,...
Definition: gridtemplates.c:229
int_power
double int_power(double x, g2int y)
Function similar to C pow() power function.
Definition: int_power.c:18
gtemplate::maplen
g2int maplen
Number of entries in the static part of the template.
Definition: grib2_int.h:39
enc_png
int enc_png(unsigned char *data, g2int width, g2int height, g2int nbits, unsigned char *pngbuf)
Encode PNG.
Definition: enc_png.c:75
gbits
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...
Definition: gbits.c:57
getgridtemplate
gtemplate * getgridtemplate(g2int number)
This subroutine returns grid template information for a specified Grid Definition Template for [Secti...
Definition: gridtemplates.c:180
jpcunpack
g2int jpcunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts, float *fld)
Unpack JPEG2000 compressed data into an array of floats, using info from the GRIB2 Data Representatio...
Definition: jpcunpack.c:108
gtemplate::map
g2int * map
Number of octets of each entry in the static part of the template.
Definition: grib2_int.h:43
mkieee
void mkieee(float *a, g2int *rieee, g2int num)
This subroutine stores a list of real values in 32-bit IEEE floating point format.
Definition: mkieee.c:22
compack
void compack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a data field using a complex packing algorithm as defined in the GRIB2 docum...
Definition: compack.c:42
pack_gp
int pack_gp(g2int *kfildo, g2int *ic, g2int *nxy, g2int *is523, g2int *minpk, g2int *inc, g2int *missp, g2int *misss, g2int *jmin, g2int *jmax, g2int *lbit, g2int *nov, g2int *ndg, g2int *lx, g2int *ibit, g2int *jbit, g2int *kbit, g2int *novref, g2int *lbitref, g2int *ier)
Determines groups of variable size, but at least of size minpk, the associated max (jmax( )) and min ...
Definition: pack_gp.c:255
getpdstemplate
gtemplate * getpdstemplate(g2int number)
This subroutine returns PDS template information for a specified Product Definition Template.
Definition: pdstemplates.c:281
grib2.h
Header file for NCEPLIBS-g2c library.
getdim
g2int getdim(unsigned char *csec3, g2int *width, g2int *height, g2int *iscan)
This subroutine returns the dimensions and scanning mode of a grid definition packed in GRIB2 Grid De...
Definition: getdim.c:29
g2int
int64_t g2int
Long integer type.
Definition: grib2.h:28
gtemplate::num
g2int num
The template number.
Definition: grib2_int.h:36
specpack
void specpack(float *fld, g2int ndpts, g2int JJ, g2int KK, g2int MM, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs a spectral data field using the complex packing algorithm for spherical harmoni...
Definition: specpack.c:33
pngunpack
g2int pngunpack(unsigned char *cpack, g2int len, g2int *idrstmpl, g2int ndpts, float *fld)
This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB...
Definition: pngunpack.c:105
simunpack
g2int simunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts, float *fld)
This subroutine unpacks a data field that was packed using a simple packing algorithm as defined in t...
Definition: simunpack.c:26
gbit
void gbit(unsigned char *in, g2int *iout, g2int iskip, g2int nbits)
Get bits - unpack bits: Extract arbitrary size values from a packed bit string, right justifying each...
Definition: gbits.c:20
gtemplate::extlen
g2int extlen
Number of entries in the template extension.
Definition: grib2_int.h:49
simpack
void simpack(float *fld, g2int ndpts, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a data field using the simple packing algorithm as defined in the GRIB2 docu...
Definition: simpack.c:34
specunpack
g2int specunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts, g2int JJ, g2int KK, g2int MM, float *fld)
This subroutine unpacks a spectral data field that was packed using the complex packing algorithm for...
Definition: specunpack.c:35
misspack
void misspack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This function packs up a data field using a complex packing algorithm as defined in the GRIB2 documen...
Definition: misspack.c:42
dec_jpeg2000
int dec_jpeg2000(char *injpc, g2int bufsize, g2int *outfld)
This Function decodes a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i....
Definition: dec_jpeg2000.c:38
pngpack
void pngpack(float *fld, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a float data field into PNG image format.
Definition: pngpack.c:224
cmplxpack
void cmplxpack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a data field using a complex packing algorithm as defined in the GRIB2 docum...
Definition: cmplxpack.c:36
getpoly
g2int getpoly(unsigned char *csec3, g2int *jj, g2int *kk, g2int *mm)
This subroutine returns the J, K, and M pentagonal resolution parameters specified in a GRIB Grid Def...
Definition: getpoly.c:40
gtemplate
Struct for GRIB template.
Definition: grib2_int.h:28
g2c_check_msg
int g2c_check_msg(unsigned char *cgrib, g2int *lencurr, int verbose)
Check for 'GRIB' at the beginning of a GRIB message, and check to see if the message is already termi...
Definition: util.c:26
enc_jpeg2000
int enc_jpeg2000(unsigned char *cin, g2int width, g2int height, g2int nbits, g2int ltype, g2int ratio, g2int retry, char *outjpc, g2int jpclen)
This Function encodes a grayscale image into a JPEG2000 code stream specified in the JPEG2000 Part-1 ...
Definition: enc_jpeg2000.c:51