---
name: "jpcunpack.c"
section: "3"
platform: "linux"
package: "libg2c-dev"
version: "2.1.0-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/jpcunpack.c"
---

# jpcunpack.c(3)

Unpack a data field that was packed with JPEG2000.

## NAME

jpcunpack.c - Unpack a data field that was packed with JPEG2000.

## SYNOPSIS

`#include 'grib2_int.h'`\
 `#include <stdio.h>`\
 `#include <stdlib.h>`\

### Functions

int **g2c\_jpcunpackd** (unsigned char \*cpack, size\_t len, int \*idrstmpl, size\_t ndpts, double \*fld)\
 Unpack JPEG2000 compressed data into an array of doubles, using info from the GRIB2 Data Representation `Template 5.40` or 5.40000.  int **g2c\_jpcunpackf** (unsigned char \*cpack, size\_t len, int \*idrstmpl, size\_t ndpts, float \*fld)\
 Unpack JPEG2000 compressed data into an array of floats, using info from the GRIB2 Data Representation `Template 5.40` or 5.40000.  **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 Representation `Template 5.40` or 5.40000.  static int **jpcunpack\_int** (unsigned char \*cpack, **g2int** len, **g2int** \*idrstmpl, **g2int** ndpts, void \*fld, int fld\_is\_double, int verbose)\
 Unpack JPEG2000 compressed data into an array of floats or doubles, using info from the GRIB2 Data Representation `Template 5.40` or 5.40000.

## Detailed Description

Unpack a data field that was packed with JPEG2000.

stream

**Author**

Stephem Gilbert

**Date**

2003-08-27

Definition in file **jpcunpack.c**.

## Function Documentation

### int g2c\_jpcunpackd (unsigned char \* cpack, size\_t len, int \* idrstmpl, size\_t ndpts, double \* fld)

Unpack JPEG2000 compressed data into an array of doubles, using info from the GRIB2 Data Representation `Template 5.40` or 5.40000. This function is the V2 API version of **jpcunpack()** for doubles.

**Parameters**

*cpack* The packed data. \
 *len* The length of the packed data. \
 *idrstmpl* Pointer to array of values for Data Representation `Template 5.40` or 5.40000. \
 *ndpts* The number of data values to unpack. \
 *fld* A pointer that gets the unpacked data values as an array of double.

**Returns**

- •

  **G2C\_NOERROR** No error.

- •

  **G2C\_ENOMEM** Out of memory.

**Author**

Ed Hartnett

**Date**

2022-08-12

Definition at line **199** of file **jpcunpack.c**.

References **G2C\_JPEG\_DRS\_TEMPLATE\_LEN**, **jpcunpack\_int()**, and **LOG**.

### int g2c\_jpcunpackf (unsigned char \* cpack, size\_t len, int \* idrstmpl, size\_t ndpts, float \* fld)

Unpack JPEG2000 compressed data into an array of floats, using info from the GRIB2 Data Representation `Template 5.40` or 5.40000.

**Parameters**

*cpack* The packed data. \
 *len* The length of the packed data. \
 *idrstmpl* Pointer to array of values for Data Representation `Template 5.40` or 5.40000. \
 *ndpts* The number of data values to unpack. \
 *fld* A pointer that gets the unpacked data values as an array of float.

**Returns**

- •

  **G2C\_NOERROR** No error.

- •

  **G2C\_ENOMEM** Out of memory.

**Author**

Ed Hartnett

**Date**

2022-09-08

Definition at line **159** of file **jpcunpack.c**.

References **G2C\_JPEG\_DRS\_TEMPLATE\_LEN**, **jpcunpack\_int()**, and **LOG**.

### 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 Representation `Template 5.40` or 5.40000.

**Parameters**

*cpack* The packed data. \
 *len* The length of the packed data. \
 *idrstmpl* Pointer to array of values for Data Representation `Template 5.40` or 5.40000. \
 *ndpts* The number of data values to unpack. \
 *fld* A pointer that gets the unpacked data values as an array of float.

**Returns**

- •

  **G2C\_NOERROR** No error.

- •

  **G2\_JPCUNPACK\_MEM** Out of memory.

**Author**

Stephem Gilbert

**Date**

2003-08-27

Definition at line **123** of file **jpcunpack.c**.

References **G2\_JPCUNPACK\_MEM**, **jpcunpack\_int()**, and **LOG**.

Referenced by **g2c\_unpack7\_int()**.

### static int jpcunpack\_int (unsigned char \* cpack, g2int len, g2int \* idrstmpl, g2int ndpts, void \* fld, int fld\_is\_double, int verbose)` [static]`

Unpack JPEG2000 compressed data into an array of floats or doubles, using info from the GRIB2 Data Representation `Template 5.40` or 5.40000. This function is used by **jpcunpack()**, **g2c\_jpcunpackf()**, and **g2c\_jpcunpackd()**.

**Parameters**

*cpack* The packed data. \
 *len* The length of the packed data. \
 *idrstmpl* Pointer to array of values for Data Representation `Template 5.40` or 5.40000. \
 *ndpts* The number of data values to unpack. \
 *fld* A pointer that gets the unpacked data values. \
 *fld\_is\_double* Non-zero if the data are to be unpacked into a double array, otherwise data will be unpacked into a float array. \
 *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 g2c API may cause error messages to be printed in case of error. For the new g2c\_ API, no error messages will be printed - instead an error code will be returned. Call **g2c\_strerror()** to get the error message for any error code.

**Returns**

- •

  **G2C\_NOERROR** No error.

- •

  **G2C\_ENOMEM** Out of memory.

**Author**

Ed Hartnett

**Date**

2022-09-06

Definition at line **44** of file **jpcunpack.c**.

References **dec\_jpeg2000()**, **G2C\_ENOMEM**, **G2C\_NOERROR**, **int\_power()**, **LOG**, and **rdieee()**.

Referenced by **g2c\_jpcunpackd()**, **g2c\_jpcunpackf()**, and **jpcunpack()**.

## Author

Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.
