Scroll to navigation

jpcpack.c(3) NCEPLIBS-g2c jpcpack.c(3)

NAME

jpcpack.c - Pack up a data field into a JPEG2000 code stream.

SYNOPSIS

#include <stdlib.h>
#include <math.h>
#include 'grib2.h'

Functions


int enc_jpeg2000 (unsigned char *, g2int, g2int, g2int, g2int, g2int, g2int, char *, g2int)
This Function encodes a grayscale image into a JPEG2000 code stream specified in the JPEG2000 Part-1 standard (i.e., ISO/IEC 15444-1) using JasPer Software version 1.500.4 (or 1.700.2) written by the University of British Columbia, Image Power Inc, and others. void jpcpack (g2float *fld, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
This subroutine packs up a data field into a JPEG2000 code stream.

Detailed Description

Pack up a data field into a JPEG2000 code stream.

Author

Stephen Gilbert

Date

2003-08-17

Definition in file jpcpack.c.

Function Documentation

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 standard (i.e., ISO/IEC 15444-1) using JasPer Software version 1.500.4 (or 1.700.2) written by the University of British Columbia, Image Power Inc, and others. JasPer is available at http://www.ece.uvic.ca/~mdadams/jasper/.

PROGRAM HISTORY LOG:

  • 2002-12-02 Gilbert
  • 2004-12-16 Gilbert - Added retry argument/option to allow option of increasing the maximum number of guard bits to the JPEG2000 algorithm.

Parameters

cin Packed matrix of Grayscale image values to encode.
width width of image.
height height of image.
nbits depth (in bits) of image. i.e number of bits used to hold each data value.
ltype indicator of lossless or lossy compression.
  • 1, for lossy compression
  • != 1, for lossless compression

ratio target compression ratio. (ratio:1) Used only when ltype == 1.
retry Pointer to option type. If 1 try increasing number of guard bits otherwise, no additional options.
outjpc Output encoded JPEG2000 code stream.
jpclen Number of bytes allocated for new JPEG2000 code stream in outjpc.

Returns

  • > 0 = Length in bytes of encoded JPEG2000 code stream
  • -3 = Error decode jpeg2000 code stream.
  • -5 = decoded image had multiple color components. Only grayscale is expected.

Note

Requires JasPer Software version 1.500.4 or 1.700.2.

Author

Stephen Gilbert

Date

2002-12-02

Definition at line 56 of file enc_jpeg2000.c.

References MAXOPTSSIZE.

Referenced by jpcpack().

void jpcpack (g2float * fld, g2int width, g2int height, g2int * idrstmpl, unsigned char * cpack, g2int * lcpack)

This subroutine packs up a data field into a JPEG2000 code stream. After the data field is scaled, and the reference value is subtracted out, it is treated as a grayscale image and passed to a JPEG2000 encoder. It also fills in GRIB2 Data Representation Template 5.40 or 5.40000 with the appropriate values.

PROGRAM HISTORY LOG:

  • 2003-08-17 Gilbert
  • 2004-11-92 Gilbert - Fixed bug encountered when packing a near constant field.
  • 2004-07-19 Gilbert - Added check on whether the jpeg2000 encoding was successful. If not, try again with different encoder options.
  • 2005-05-10 Gilbert - Imposed minimum size on cpack, used to hold encoded bit string.

Parameters

fld Contains the data values to pack.
width number of points in the x direction.
height number of points in the y direction.
idrstmpl Contains the array of values for Data Representation Template 5.40 or 5.40000.
  • 0 Reference value - ignored on input, set by jpcpack routine.
  • 1 Binary Scale Factor - used on input, unchanged by jpcpack routine.
  • 2 Decimal Scale Factor - used on input, unchanged by jpcpack routine.
  • 3 number of bits for each data value - ignored on input
  • 4 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, if idrstmpl[5]=1. Set to 255, if idrstmpl[5]=0.

cpack The packed data field.
lcpack length of packed field in cpack.

Author

Stephen Gilbert

Date

2003-08-17

Definition at line 49 of file jpcpack.c.

References enc_jpeg2000(), int_power(), mkieee(), and sbits().

Referenced by g2_addfield().

Author

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

Tue May 3 2022 Version 1.6.4