# J2K - JPEG-2000 codestream reader/writer

## Classes
struct | opj_cp
struct | opj_j2k
struct | opj_stepsize
struct | opj_tccp
struct | opj_tcp
## Defines
#define | J2K_CCP_CBLKSTY_LAZY 0x01
#define | J2K_CCP_CBLKSTY_PTERM 0x10
#define | J2K_CCP_CBLKSTY_RESET 0x02
#define | J2K_CCP_CBLKSTY_SEGSYM 0x20
#define | J2K_CCP_CBLKSTY_TERMALL 0x04
#define | J2K_CCP_CBLKSTY_VSC 0x08
#define | J2K_CCP_CSTY_PRT 0x01
#define | J2K_CCP_QNTSTY_NOQNT 0
#define | J2K_CCP_QNTSTY_SEQNT 2
#define | J2K_CCP_QNTSTY_SIQNT 1
#define | J2K_CP_CSTY_EPH 0x04
#define | J2K_CP_CSTY_PRT 0x01
#define | J2K_CP_CSTY_SOP 0x02
#define | J2K_MS_COC 0xff53
#define | J2K_MS_COD 0xff52
#define | J2K_MS_COM 0xff64
#define | J2K_MS_CRG 0xff63
#define | J2K_MS_EOC 0xffd9
#define | J2K_MS_EPH 0xff92
#define | J2K_MS_PLM 0xff57
#define | J2K_MS_PLT 0xff58
#define | J2K_MS_POC 0xff5f
#define | J2K_MS_PPM 0xff60
#define | J2K_MS_PPT 0xff61
#define | J2K_MS_QCC 0xff5d
#define | J2K_MS_QCD 0xff5c
#define | J2K_MS_RGN 0xff5e
#define | J2K_MS_SIZ 0xff51
#define | J2K_MS_SOC 0xff4f
#define | J2K_MS_SOD 0xff93
#define | J2K_MS_SOP 0xff91
#define | J2K_MS_SOT 0xff90
#define | J2K_MS_TLM 0xff55
## Typedefs
typedef enum J2K_STATUS | J2K_STATUS
typedef enum T2_MODE | J2K_T2_MODE
typedef struct opj_cp | opj_cp_t
typedef struct opj_j2k | opj_j2k_t
typedef struct opj_stepsize | opj_stepsize_t
typedef struct opj_tccp | opj_tccp_t
typedef struct opj_tcp | opj_tcp_t
## Enumerations
enum | J2K_STATUS { J2K_STATE_MHSOC = 0x0001, J2K_STATE_MHSIZ = 0x0002, J2K_STATE_MH = 0x0004, J2K_STATE_TPHSOT = 0x0008, J2K_STATE_TPH = 0x0010, J2K_STATE_MT = 0x0020, J2K_STATE_NEOC = 0x0040, J2K_STATE_ERR = 0x0080 }
enum | T2_MODE { THRESH_CALC = 0, FINAL_PASS = 1 }
## Exported functions
char * | j2k_convert_progression_order (OPJ_PROG_ORDER prg_order)
opj_j2k_t * | j2k_create_compress (opj_common_ptr cinfo)
opj_j2k_t * | j2k_create_decompress (opj_common_ptr cinfo)
opj_image_t * | j2k_decode (opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *cstr_info)
opj_image_t * | j2k_decode_jpt_stream (opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *cstr_info)
void | j2k_destroy_compress (opj_j2k_t *j2k)
void | j2k_destroy_decompress (opj_j2k_t *j2k)
bool | j2k_encode (opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info)
void | j2k_setup_decoder (opj_j2k_t *j2k, opj_dparameters_t *parameters)
void | j2k_setup_encoder (opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_t *image)

## Detailed Description

## Define Documentation

#define J2K_CCP_CBLKSTY_LAZY 0x01

#define J2K_CCP_CBLKSTY_PTERM 0x10

#define J2K_CCP_CBLKSTY_RESET 0x02

#define J2K_CCP_CBLKSTY_SEGSYM 0x20

#define J2K_CCP_CBLKSTY_TERMALL 0x04

#define J2K_CCP_CBLKSTY_VSC 0x08

#define J2K_CCP_CSTY_PRT 0x01

#define J2K_CCP_QNTSTY_NOQNT 0

#define J2K_CCP_QNTSTY_SEQNT 2

#define J2K_CCP_QNTSTY_SIQNT 1

#define J2K_CP_CSTY_EPH 0x04

#define J2K_CP_CSTY_PRT 0x01

#define J2K_CP_CSTY_SOP 0x02

#define J2K_MS_COC 0xff53

COC marker value

#define J2K_MS_COD 0xff52

COD marker value

#define J2K_MS_COM 0xff64

COM marker value

#define J2K_MS_CRG 0xff63

CRG marker value

#define J2K_MS_EOC 0xffd9

EOC marker value

#define J2K_MS_EPH 0xff92

EPH marker value

#define J2K_MS_PLM 0xff57

PLM marker value

#define J2K_MS_PLT 0xff58

PLT marker value

#define J2K_MS_POC 0xff5f

POC marker value

#define J2K_MS_PPM 0xff60

PPM marker value

#define J2K_MS_PPT 0xff61

PPT marker value

#define J2K_MS_QCC 0xff5d

QCC marker value

#define J2K_MS_QCD 0xff5c

QCD marker value

#define J2K_MS_RGN 0xff5e

RGN marker value

#define J2K_MS_SIZ 0xff51

SIZ marker value

#define J2K_MS_SOC 0xff4f

SOC marker value

#define J2K_MS_SOD 0xff93

SOD marker value

#define J2K_MS_SOP 0xff91

SOP marker value

#define J2K_MS_SOT 0xff90

SOT marker value

#define J2K_MS_TLM 0xff55

TLM marker value

## Typedef Documentation

typedef enum J2K_STATUS J2K_STATUS

Values that specify the status of the decoding process when decoding the main header. These values may be combined with a | operator.

typedef enum T2_MODE J2K_T2_MODE

T2 encoding mode

typedef struct opj_cp opj_cp_t

Coding parameters

typedef struct opj_j2k opj_j2k_t

JPEG-2000 codestream reader/writer

typedef struct opj_stepsize opj_stepsize_t

Quantization stepsize

typedef struct opj_tccp opj_tccp_t

Tile-component coding parameters

typedef struct opj_tcp opj_tcp_t

Tile coding parameters : this structure is used to store coding/decoding parameters common to all tiles (information like COD, COC in main header)

## Enumeration Type Documentation

enum J2K_STATUS

Values that specify the status of the decoding process when decoding the main header. These values may be combined with a | operator.

Enumerator:

  J2K_STATE_MHSOC | a SOC marker is expected
  J2K_STATE_MHSIZ | a SIZ marker is expected
  J2K_STATE_MH | the decoding process is in the main header
  J2K_STATE_TPHSOT | the decoding process is in a tile part header and expects a SOT marker
  J2K_STATE_TPH | the decoding process is in a tile part header
  J2K_STATE_MT | the EOC marker has just been read
  J2K_STATE_NEOC | the decoding process must not expect a EOC marker because the codestream is truncated
  J2K_STATE_ERR | the decoding process has encountered an error

enum T2_MODE

T2 encoding mode

Enumerator:

  THRESH_CALC |
  FINAL_PASS | Function called in Rate allocation process

## Function Documentation

char* j2k_convert_progression_order | ( | OPJ_PROG_ORDER | prg_order | ) |

Converts an enum type progression order to string type

opj_j2k_t* j2k_create_compress | ( | opj_common_ptr | cinfo | ) |

Creates a J2K compression structure

Parameters:

  | cinfo | Codec context info

Returns:
  Returns a handle to a J2K compressor if successful, returns NULL otherwise

opj_j2k_t* j2k_create_decompress | ( | opj_common_ptr | cinfo | ) |

Creates a J2K decompression structure

Parameters:

  | cinfo | Codec context info

Returns:
  Returns a handle to a J2K decompressor if successful, returns NULL otherwise

opj_image_t* j2k_decode | ( | opj_j2k_t * | j2k,
|  | opj_cio_t * | cio,
|  | opj_codestream_info_t * | cstr_info |
| ) |  |  |

Decode an image from a JPEG-2000 codestream

Parameters:

  | j2k | J2K decompressor handle
  | cio | Input buffer stream
  | cstr_info | Codestream information structure if required, NULL otherwise

Returns:
  Returns a decoded image if successful, returns NULL otherwise

opj_image_t* j2k_decode_jpt_stream | ( | opj_j2k_t * | j2k,
|  | opj_cio_t * | cio,
|  | opj_codestream_info_t * | cstr_info |
| ) |  |  |

Decode an image form a JPT-stream (JPEG 2000, JPIP)

Parameters:

  | j2k | J2K decompressor handle
  | cio | Input buffer stream
  | cstr_info | Codestream information structure if required, NULL otherwise

Returns:
  Returns a decoded image if successful, returns NULL otherwise

void j2k_destroy_compress | ( | opj_j2k_t * | j2k | ) |

Destroy a J2K compressor handle

Parameters:

  | j2k | J2K compressor handle to destroy

void j2k_destroy_decompress | ( | opj_j2k_t * | j2k | ) |

Destroy a J2K decompressor handle

Parameters:

  | j2k | J2K decompressor handle to destroy

bool j2k_encode | ( | opj_j2k_t * | j2k,
|  | opj_cio_t * | cio,
|  | opj_image_t * | image,
|  | opj_codestream_info_t * | cstr_info |
| ) |  |  |

Encode an image into a JPEG-2000 codestream

Parameters:

  | j2k | J2K compressor handle
  | cio | Output buffer stream
  | image | Image to encode
  | cstr_info | Codestream information structure if required, NULL otherwise

Returns:
  Returns true if successful, returns false otherwise

void j2k_setup_decoder | ( | opj_j2k_t * | j2k,
|  | opj_dparameters_t * | parameters |
| ) |  |  |

Setup the decoder decoding parameters using user parameters. Decoding parameters are returned in j2k->cp.

Parameters:

  | j2k | J2K decompressor handle
  | parameters | decompression parameters

void j2k_setup_encoder | ( | opj_j2k_t * | j2k,
|  | opj_cparameters_t * | parameters,
|  | opj_image_t * | image |
| ) |  |  |

Setup the encoder parameters using the current image and using user parameters. Coding parameters are returned in j2k->cp.

Parameters:

  | j2k | J2K compressor handle
  | parameters | compression parameters
  | image | input filled image