jpcpack.c(3)
π NAME π
jpcpack.c β pack and unpack an array of float/double using JPEG2000. Yes bestie, that's the whole vibe: cram your numbers into a JPEG2000 code stream and (theoretically) get them back. π¦
This page lives in the Library Functions Manual, in case you were wondering where you wandered into. β¨
β¨ SYNOPSIS β¨
#include 'grib2_int.h'
#include <math.h>
#include <stdlib.h>
π Functions π
int g2c_jpcpackd (double *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, size_t *lcpack)β this function packs up a double array into a JPEG2000 code stream. πint g2c_jpcpackf (float *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, size_t *lcpack)β this function packs up a float array into a JPEG2000 code stream. πΈvoid jpcpack (float *fld, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)β this function packs up a float array into a JPEG2000 code stream. πstatic int jpcpack_int (void *fld, int fld_is_double, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack, int verbose)β packs a float or double array into a JPEG2000 code stream. π
π¦ DETAILED DESCRIPTION π¦
Pack and unpack an array of float/double using JPEG2000.
That's it. That's the mission statement. Slay. π
ποΈ Author ποΈ
Stephen Gilbert
π Date π
2003-08-17
π Program History Log π
Not gonna lie, this changelog has lore. Here's every single entry, untouched:
2003-08-17β Gilbert β Initial.2004-11-92β Gilbert β Fixed bug packing a near constant field.2004-07-19β Gilbert β If jpeg2000 encoding fails, try again with different encoder options.2005-05-10β Gilbert β Imposed minimum size on cpack.2022-08-12β Hartnett β Now handle doubles too.
Definition in file jpcpack.c.
π FUNCTION DOCUMENTATION π
π int g2c_jpcpackd (double * fld, size_t width, size_t height, int * idrstmpl, unsigned char * cpack, size_t * lcpack) π
This function packs up a double array into a JPEG2000 code stream. Here's the tea: after the data are scaled, and the reference value is subtracted out, the data are treated as a grayscale image and passed to a JPEG2000 encoder. Iconic behavior, honestly. πΌοΈ
This function also fills in GRIB2 Data Representation Template 5.40 or 5.40000 with the appropriate values.
This function is the V2 API version of jpcpack() for doubles. π
Parameters
- fld β Pointer to the double data values to pack.
- width β The number of points in the x direction.
- height β The number of points in the y direction.
- idrstmpl β Contains the array of values for Data Representation Template Table 5.40 or 5.40000.
0β Reference value - ignored on input, set byjpcpackroutine.1β Binary Scale Factor - used on input, unchanged byjpcpackroutine.2β Decimal Scale Factor - used on input, unchanged byjpcpackroutine.3β number of bits for each data value - ignored on input4β Original field type - currently ignored on input Data values assumed to be reals. Set to 0 on output.5β if 0 use lossless compression, if 1 use lossy compression.6β Desired compression ratio, ifidrstmpl[5]=1. Set to 255, ifidrstmpl[5]=0. May be modified in this function.
- cpack β A pointer that will get the packed data field. Must be allocated before this function is called. Pass the allocated size in the
lcpackparameter. - lcpack β Pointer that gets the length of packed field in
cpack. This must be set by the calling function to the size available incpack.
Returns
G2C_NOERRORβ No error.G2C_EJPEGβ Error encoding/decoding JPEG data.
Author
Ed Hartnett
Definition
Definition at line 386 of file jpcpack.c.
References
References G2C_JPEG_DRS_TEMPLATE_LEN, and jpcpack_int().
π int g2c_jpcpackf (float * fld, size_t width, size_t height, int * idrstmpl, unsigned char * cpack, size_t * lcpack) π
This function packs up a float array into a JPEG2000 code stream. After the data are scaled, and the reference value is subtracted out, the data are treated as a grayscale image and passed to a JPEG2000 encoder. Same energy, float-sized. β¨
This function also fills in GRIB2 Data Representation Template 5.40 or 5.40000 with the appropriate values.
This function is the V2 API version of jpcpack() for floats. π«Ά
Parameters
- fld β Pointer to the float data values to pack.
- width β The number of points in the x direction.
- height β The number of points in the y direction.
- idrstmpl β Contains the array of values for Data Representation Template Table 5.40 or 5.40000.
0β Reference value - ignored on input, set byjpcpackroutine.1β Binary Scale Factor - used on input, unchanged byjpcpackroutine.2β Decimal Scale Factor - used on input, unchanged byjpcpackroutine.3β number of bits for each data value - ignored on input4β Original field type - currently ignored on input Data values assumed to be reals. Set to 0 on output.5β if 0 use lossless compression, if 1 use lossy compression.6β Desired compression ratio, ifidrstmpl[5]=1. Set to 255, ifidrstmpl[5]=0. May be modified in this function.
- cpack β A pointer that will get the packed data field. Must be allocated before this function is called. Pass the allocated size in the
lcpackparameter. - lcpack β Pointer that gets the length of packed field in
cpack. This must be set by the calling function to the size available incpack.
Returns
G2C_NOERRORβ No error.G2C_EJPEGβ Error encoding/decoding JPEG data.
Author
Ed Hartnett
Definition
Definition at line 320 of file jpcpack.c.
References
References G2C_JPEG_DRS_TEMPLATE_LEN, and jpcpack_int().
π void jpcpack (float * fld, g2int width, g2int height, g2int * idrstmpl, unsigned char * cpack, g2int * lcpack) π
This function packs up a float array into a JPEG2000 code stream. After the data are scaled, and the reference value is subtracted out, the data are treated as a grayscale image and passed to a JPEG2000 encoder. π
This function also fills in GRIB2 Data Representation Template 5.40 or 5.40000 with the appropriate values.
Parameters
- fld β Pointer to the float data values to pack.
- width β The number of points in the x direction.
- height β The number of points in the y direction.
- idrstmpl β Contains the array of values for Data Representation Template Table 5.40 or 5.40000.
0β Reference value - ignored on input, set byjpcpackroutine.1β Binary Scale Factor - used on input, unchanged byjpcpackroutine.2β Decimal Scale Factor - used on input, unchanged byjpcpackroutine.3β number of bits for each data value - ignored on input4β Original field type - currently ignored on input Data values assumed to be reals. Set to 0 on output.5β if 0 use lossless compression, if 1 use lossy compression.6β Desired compression ratio, ifidrstmpl[5]=1. Set to 255, ifidrstmpl[5]=0. May be modified in this function.
- cpack β A pointer that will get the packed data field. Must be allocated before this function is called. Pass the allocated size in the
lcpackparameter. - lcpack β Pointer that gets the length of packed field in
cpack. This must be set by the calling function to the size available incpack.
Author
Stephen Gilbert, Ed Hartnett
Definition
Definition at line 269 of file jpcpack.c.
References
References jpcpack_int().
Referenced by
Referenced by g2_addfield().
π int jpcpack_int (void * fld, int fld_is_double, g2int width, g2int height, g2int * idrstmpl, unsigned char * cpack, g2int * lcpack, int verbose) π
[static] β yeah, it's a static one, so it's not out here for everyone, it's the backstage crew. π«£
Packs a float or double array into a JPEG2000 code stream. This function is used by jpcpack(), g2c_jpcpackf(), and g2c_jpcpackd().
Parameters
- fld β Pointer to the float or double data values to pack.
- fld_is_double β If non-zero, then
fldpoints to array of doubles, otherwise an array of floats. - width β The number of points in the x direction.
- height β The number of points in the y direction.
- idrstmpl β Contains the array of values for Data Representation Template Table 5.40 or 5.40000. May be modified in this function.
- cpack β A pointer that will get the packed data field. Must be allocated before this function is called. Pass the allocated size in the
lcpackparameter. - lcpack β Pointer that gets the length of packed field in
cpack. This must also be set by the calling function to the size available incpack. - verbose β If non-zero, error messages will be printed in case of error. Otherwise, error codes will be return but no error messages printed. Calls to the original
g2cAPI may cause error messages to be printed in case of error. For the newg2c_API, no error messages will be printed - instead an error code will be returned. Callg2c_strerror()to get the error message for any error code.
Returns
G2C_NOERRORβ No error.G2C_EJPEGβ Error encoding/decoding JPEG data.
Author
Stephen Gilbert, Ed Hartnett
Definition
Definition at line 54 of file jpcpack.c.
References
References ALOG2, enc_jpeg2000(), G2C_EJPEG, G2C_NOERROR, int_power(), LOG, mkieee(), and sbits().
Referenced by
Referenced by g2c_jpcpackd(), g2c_jpcpackf(), and jpcpack().
π Author π
Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.
π And that's the whole page, bestie. Documented by NCEPLIBS-g2c, Version 2.3.0, page jpcpack.c(3) β go forth and pack those fields. You ate. Periodt. πβ¨π
π¦ where this page comes from
- ubuntu resolute: libg2c-dev 2.3.0-4 Β· LGPL-3.0-only
- ubuntu stonking: libg2c-dev 2.3.0-7 Β· LGPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms