OpenJPEG  2.5.0
Data Structures | Macros | Typedefs | Enumerations
jp2.h File Reference

The JPEG-2000 file format Reader/Writer (JP2) More...

Go to the source code of this file.

Data Structures

struct  opj_jp2_cdef_info
 Channel description: channel index, type, association. More...
 
struct  opj_jp2_cdef
 Channel descriptions and number of descriptions. More...
 
struct  opj_jp2_cmap_comp
 Component mappings: channel index, mapping type, palette index. More...
 
struct  opj_jp2_pclr
 Palette data: table entries, palette columns. More...
 
struct  opj_jp2_color
 Collector for ICC profile, palette, component mapping, channel description. More...
 
struct  opj_jp2_comps
 JP2 component. More...
 
struct  opj_jp2
 JPEG-2000 file format reader/writer. More...
 
struct  opj_jp2_box
 JP2 Box. More...
 
struct  opj_jp2_header_handler
 
struct  opj_jp2_img_header_writer_handler
 

Macros

#define JP2_JP   0x6a502020
 JPEG 2000 signature box. More...
 
#define JP2_FTYP   0x66747970
 File type box. More...
 
#define JP2_JP2H   0x6a703268
 JP2 header box (super-box) More...
 
#define JP2_IHDR   0x69686472
 Image header box. More...
 
#define JP2_COLR   0x636f6c72
 Colour specification box. More...
 
#define JP2_JP2C   0x6a703263
 Contiguous codestream box. More...
 
#define JP2_URL   0x75726c20
 Data entry URL box. More...
 
#define JP2_PCLR   0x70636c72
 Palette box. More...
 
#define JP2_CMAP   0x636d6170
 Component Mapping box. More...
 
#define JP2_CDEF   0x63646566
 Channel Definition box. More...
 
#define JP2_DTBL   0x6474626c
 Data Reference box. More...
 
#define JP2_BPCC   0x62706363
 Bits per component box. More...
 
#define JP2_JP2   0x6a703220
 File type fields. More...
 

Typedefs

typedef struct opj_jp2_cdef_info opj_jp2_cdef_info_t
 Channel description: channel index, type, association. More...
 
typedef struct opj_jp2_cdef opj_jp2_cdef_t
 Channel descriptions and number of descriptions. More...
 
typedef struct opj_jp2_cmap_comp opj_jp2_cmap_comp_t
 Component mappings: channel index, mapping type, palette index. More...
 
typedef struct opj_jp2_pclr opj_jp2_pclr_t
 Palette data: table entries, palette columns. More...
 
typedef struct opj_jp2_color opj_jp2_color_t
 Collector for ICC profile, palette, component mapping, channel description. More...
 
typedef struct opj_jp2_comps opj_jp2_comps_t
 JP2 component. More...
 
typedef struct opj_jp2 opj_jp2_t
 JPEG-2000 file format reader/writer. More...
 
typedef struct opj_jp2_box opj_jp2_box_t
 JP2 Box. More...
 
typedef struct opj_jp2_header_handler opj_jp2_header_handler_t
 
typedef struct opj_jp2_img_header_writer_handler opj_jp2_img_header_writer_handler_t
 

Enumerations

enum  JP2_STATE {
  JP2_STATE_NONE = 0x0, JP2_STATE_SIGNATURE = 0x1, JP2_STATE_FILE_TYPE = 0x2, JP2_STATE_HEADER = 0x4,
  JP2_STATE_CODESTREAM = 0x8, JP2_STATE_END_CODESTREAM = 0x10, JP2_STATE_UNKNOWN = 0x7fffffff
}
 < Resolution box (super-box) More...
 
enum  JP2_IMG_STATE { JP2_IMG_STATE_NONE = 0x0, JP2_IMG_STATE_UNKNOWN = 0x7fffffff }
 

Functions

Exported functions
void opj_jp2_setup_decoder (opj_jp2_t *jp2, opj_dparameters_t *parameters)
 Setup the decoder decoding parameters using user parameters. More...
 
void opj_jp2_decoder_set_strict_mode (opj_jp2_t *jp2, OPJ_BOOL strict)
 Set the strict mode parameter. More...
 
OPJ_BOOL opj_jp2_set_threads (opj_jp2_t *jp2, OPJ_UINT32 num_threads)
 Allocates worker threads for the compressor/decompressor. More...
 
OPJ_BOOL opj_jp2_decode (opj_jp2_t *jp2, opj_stream_private_t *p_stream, opj_image_t *p_image, opj_event_mgr_t *p_manager)
 Decode an image from a JPEG-2000 file stream. More...
 
OPJ_BOOL opj_jp2_setup_encoder (opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_t *image, opj_event_mgr_t *p_manager)
 Setup the encoder parameters using the current image and using user parameters. More...
 
OPJ_BOOL opj_jp2_encode (opj_jp2_t *jp2, opj_stream_private_t *stream, opj_event_mgr_t *p_manager)
 Encode an image into a JPEG-2000 file stream. More...
 
OPJ_BOOL opj_jp2_start_compress (opj_jp2_t *jp2, opj_stream_private_t *stream, opj_image_t *p_image, opj_event_mgr_t *p_manager)
 Starts a compression scheme, i.e. More...
 
OPJ_BOOL opj_jp2_end_compress (opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t *p_manager)
 Ends the compression procedures and possibiliy add data to be read after the codestream. More...
 
OPJ_BOOL opj_jp2_end_decompress (opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t *p_manager)
 Ends the decompression procedures and possibiliy add data to be read after the codestream. More...
 
OPJ_BOOL opj_jp2_read_header (opj_stream_private_t *p_stream, opj_jp2_t *jp2, opj_image_t **p_image, opj_event_mgr_t *p_manager)
 Reads a jpeg2000 file header structure. More...
 
OPJ_BOOL opj_jp2_set_decoded_components (opj_jp2_t *jp2, OPJ_UINT32 numcomps, const OPJ_UINT32 *comps_indices, opj_event_mgr_t *p_manager)
 Sets the indices of the components to decode. More...
 
OPJ_BOOL opj_jp2_read_tile_header (opj_jp2_t *p_jp2, OPJ_UINT32 *p_tile_index, OPJ_UINT32 *p_data_size, OPJ_INT32 *p_tile_x0, OPJ_INT32 *p_tile_y0, OPJ_INT32 *p_tile_x1, OPJ_INT32 *p_tile_y1, OPJ_UINT32 *p_nb_comps, OPJ_BOOL *p_go_on, opj_stream_private_t *p_stream, opj_event_mgr_t *p_manager)
 Reads a tile header. More...
 
OPJ_BOOL opj_jp2_write_tile (opj_jp2_t *p_jp2, OPJ_UINT32 p_tile_index, OPJ_BYTE *p_data, OPJ_UINT32 p_data_size, opj_stream_private_t *p_stream, opj_event_mgr_t *p_manager)
 Writes a tile. More...
 
OPJ_BOOL opj_jp2_decode_tile (opj_jp2_t *p_jp2, OPJ_UINT32 p_tile_index, OPJ_BYTE *p_data, OPJ_UINT32 p_data_size, opj_stream_private_t *p_stream, opj_event_mgr_t *p_manager)
 Decode tile data. More...
 
opj_jp2_topj_jp2_create (OPJ_BOOL p_is_decoder)
 Creates a jpeg2000 file decompressor. More...
 
void opj_jp2_destroy (opj_jp2_t *jp2)
 Destroy a JP2 decompressor handle. More...
 
OPJ_BOOL opj_jp2_set_decode_area (opj_jp2_t *p_jp2, opj_image_t *p_image, OPJ_INT32 p_start_x, OPJ_INT32 p_start_y, OPJ_INT32 p_end_x, OPJ_INT32 p_end_y, opj_event_mgr_t *p_manager)
 Sets the given area to be decoded. More...
 
OPJ_BOOL opj_jp2_get_tile (opj_jp2_t *p_jp2, opj_stream_private_t *p_stream, opj_image_t *p_image, opj_event_mgr_t *p_manager, OPJ_UINT32 tile_index)
 
OPJ_BOOL opj_jp2_set_decoded_resolution_factor (opj_jp2_t *p_jp2, OPJ_UINT32 res_factor, opj_event_mgr_t *p_manager)
 
OPJ_BOOL opj_jp2_encoder_set_extra_options (opj_jp2_t *p_jp2, const char *const *p_options, opj_event_mgr_t *p_manager)
 Specify extra options for the encoder. More...
 
void jp2_dump (opj_jp2_t *p_jp2, OPJ_INT32 flag, FILE *out_stream)
 Dump some elements from the JP2 decompression structure . More...
 
opj_codestream_info_v2_tjp2_get_cstr_info (opj_jp2_t *p_jp2)
 Get the codestream info from a JPEG2000 codec. More...
 
opj_codestream_index_tjp2_get_cstr_index (opj_jp2_t *p_jp2)
 Get the codestream index from a JPEG2000 codec. More...
 

Detailed Description

The JPEG-2000 file format Reader/Writer (JP2)

Macro Definition Documentation

◆ JP2_BPCC

#define JP2_BPCC   0x62706363

Bits per component box.

◆ JP2_CDEF

#define JP2_CDEF   0x63646566

Channel Definition box.

◆ JP2_CMAP

#define JP2_CMAP   0x636d6170

Component Mapping box.

◆ JP2_COLR

#define JP2_COLR   0x636f6c72

Colour specification box.

◆ JP2_DTBL

#define JP2_DTBL   0x6474626c

Data Reference box.

◆ JP2_FTYP

#define JP2_FTYP   0x66747970

File type box.

◆ JP2_IHDR

#define JP2_IHDR   0x69686472

Image header box.

◆ JP2_JP

#define JP2_JP   0x6a502020

JPEG 2000 signature box.

◆ JP2_JP2

#define JP2_JP2   0x6a703220

File type fields.

◆ JP2_JP2C

#define JP2_JP2C   0x6a703263

Contiguous codestream box.

◆ JP2_JP2H

#define JP2_JP2H   0x6a703268

JP2 header box (super-box)

◆ JP2_PCLR

#define JP2_PCLR   0x70636c72

Palette box.

◆ JP2_URL

#define JP2_URL   0x75726c20

Data entry URL box.

Typedef Documentation

◆ opj_jp2_box_t

typedef struct opj_jp2_box opj_jp2_box_t

JP2 Box.

◆ opj_jp2_cdef_info_t

Channel description: channel index, type, association.

◆ opj_jp2_cdef_t

typedef struct opj_jp2_cdef opj_jp2_cdef_t

Channel descriptions and number of descriptions.

◆ opj_jp2_cmap_comp_t

Component mappings: channel index, mapping type, palette index.

◆ opj_jp2_color_t

Collector for ICC profile, palette, component mapping, channel description.

◆ opj_jp2_comps_t

JP2 component.

◆ opj_jp2_header_handler_t

◆ opj_jp2_img_header_writer_handler_t

◆ opj_jp2_pclr_t

typedef struct opj_jp2_pclr opj_jp2_pclr_t

Palette data: table entries, palette columns.

◆ opj_jp2_t

typedef struct opj_jp2 opj_jp2_t

JPEG-2000 file format reader/writer.

Enumeration Type Documentation

◆ JP2_IMG_STATE

Enumerator
JP2_IMG_STATE_NONE 
JP2_IMG_STATE_UNKNOWN 

◆ JP2_STATE

enum JP2_STATE

< Resolution box (super-box)

< Intellectual property box < XML box < UUID box < UUID info box (super-box) < UUID list box

Enumerator
JP2_STATE_NONE 
JP2_STATE_SIGNATURE 
JP2_STATE_FILE_TYPE 
JP2_STATE_HEADER 
JP2_STATE_CODESTREAM 
JP2_STATE_END_CODESTREAM 
JP2_STATE_UNKNOWN 

Function Documentation

◆ jp2_dump()

void jp2_dump ( opj_jp2_t p_jp2,
OPJ_INT32  flag,
FILE *  out_stream 
)

Dump some elements from the JP2 decompression structure .

Parameters
p_jp2the jp2 codec.
flagflag to describe what elements are dump.
out_streamoutput stream where dump the elements.

References opj_jp2::j2k, and j2k_dump().

Referenced by opj_create_decompress().

◆ jp2_get_cstr_index()

opj_codestream_index_t* jp2_get_cstr_index ( opj_jp2_t p_jp2)

Get the codestream index from a JPEG2000 codec.

Parameters
p_jp2jp2 codec.
Returns
the codestream index extract from the jpg2000 codec

References opj_jp2::j2k, and j2k_get_cstr_index().

Referenced by opj_create_decompress().

◆ jp2_get_cstr_info()

opj_codestream_info_v2_t* jp2_get_cstr_info ( opj_jp2_t p_jp2)

Get the codestream info from a JPEG2000 codec.

Parameters
p_jp2jp2 codec.
Returns
the codestream information extract from the jpg2000 codec

References opj_jp2::j2k, and j2k_get_cstr_info().

Referenced by opj_create_decompress().

◆ opj_jp2_create()

opj_jp2_t* opj_jp2_create ( OPJ_BOOL  p_is_decoder)

◆ opj_jp2_decode()

OPJ_BOOL opj_jp2_decode ( opj_jp2_t jp2,
opj_stream_private_t p_stream,
opj_image_t p_image,
opj_event_mgr_t p_manager 
)

◆ opj_jp2_decode_tile()

OPJ_BOOL opj_jp2_decode_tile ( opj_jp2_t p_jp2,
OPJ_UINT32  p_tile_index,
OPJ_BYTE p_data,
OPJ_UINT32  p_data_size,
opj_stream_private_t p_stream,
opj_event_mgr_t p_manager 
)

Decode tile data.

Parameters
p_jp2the jpeg2000 codec.
p_tile_indexFIXME DOC
p_dataFIXME DOC
p_data_sizeFIXME DOC
p_streamthe stream to write data to.
p_managerthe user event manager.
Returns
FIXME DOC

References opj_jp2::j2k, and opj_j2k_decode_tile().

Referenced by opj_create_decompress().

◆ opj_jp2_decoder_set_strict_mode()

void opj_jp2_decoder_set_strict_mode ( opj_jp2_t jp2,
OPJ_BOOL  strict 
)

Set the strict mode parameter.

When strict mode is enabled, the entire bitstream must be decoded or an error is returned. When it is disabled, the decoder will decode partial bitstreams.

Parameters
jp2JP2 decompressor handle
strictOPJ_TRUE for strict mode

References opj_jp2::j2k, and opj_j2k_decoder_set_strict_mode().

Referenced by opj_create_decompress().

◆ opj_jp2_destroy()

void opj_jp2_destroy ( opj_jp2_t jp2)

◆ opj_jp2_encode()

OPJ_BOOL opj_jp2_encode ( opj_jp2_t jp2,
opj_stream_private_t stream,
opj_event_mgr_t p_manager 
)

Encode an image into a JPEG-2000 file stream.

Parameters
jp2JP2 compressor handle
streamOutput buffer stream
p_managerevent manager
Returns
Returns true if successful, returns false otherwise

References opj_jp2::j2k, and opj_j2k_encode().

Referenced by opj_create_compress().

◆ opj_jp2_encoder_set_extra_options()

OPJ_BOOL opj_jp2_encoder_set_extra_options ( opj_jp2_t p_jp2,
const char *const *  p_options,
opj_event_mgr_t p_manager 
)

Specify extra options for the encoder.

Parameters
p_jp2the jpeg2000 codec.
p_optionsoptions
p_managerthe user event manager
See also
opj_encoder_set_extra_options() for more details.

References opj_jp2::j2k, and opj_j2k_encoder_set_extra_options().

Referenced by opj_create_compress().

◆ opj_jp2_end_compress()

OPJ_BOOL opj_jp2_end_compress ( opj_jp2_t jp2,
opj_stream_private_t cio,
opj_event_mgr_t p_manager 
)

Ends the compression procedures and possibiliy add data to be read after the codestream.

References opj_jp2::j2k, opj_jp2::m_procedure_list, OPJ_FALSE, opj_j2k_end_compress(), opj_jp2_exec(), and opj_jp2_setup_end_header_writing().

Referenced by opj_create_compress().

◆ opj_jp2_end_decompress()

OPJ_BOOL opj_jp2_end_decompress ( opj_jp2_t jp2,
opj_stream_private_t cio,
opj_event_mgr_t p_manager 
)

Ends the decompression procedures and possibiliy add data to be read after the codestream.

References opj_jp2::j2k, opj_jp2::m_procedure_list, OPJ_FALSE, opj_j2k_end_decompress(), opj_jp2_exec(), and opj_jp2_setup_end_header_reading().

Referenced by opj_create_decompress().

◆ opj_jp2_get_tile()

OPJ_BOOL opj_jp2_get_tile ( opj_jp2_t p_jp2,
opj_stream_private_t p_stream,
opj_image_t p_image,
opj_event_mgr_t p_manager,
OPJ_UINT32  tile_index 
)

◆ opj_jp2_read_header()

OPJ_BOOL opj_jp2_read_header ( opj_stream_private_t p_stream,
opj_jp2_t jp2,
opj_image_t **  p_image,
opj_event_mgr_t p_manager 
)

Reads a jpeg2000 file header structure.

Parameters
p_streamthe stream to read data from.
jp2the jpeg2000 file header structure.
p_imageFIXME DOC
p_managerthe user event manager.
Returns
true if the box is valid.

References EVT_ERROR, opj_jp2::has_ihdr, opj_jp2::has_jp2h, opj_jp2::j2k, opj_jp2::m_procedure_list, opj_jp2::m_validation_list, opj_event_msg(), OPJ_FALSE, opj_j2k_read_header(), opj_jp2_exec(), opj_jp2_setup_decoding_validation(), and opj_jp2_setup_header_reading().

Referenced by opj_create_decompress().

◆ opj_jp2_read_tile_header()

OPJ_BOOL opj_jp2_read_tile_header ( opj_jp2_t p_jp2,
OPJ_UINT32 p_tile_index,
OPJ_UINT32 p_data_size,
OPJ_INT32 p_tile_x0,
OPJ_INT32 p_tile_y0,
OPJ_INT32 p_tile_x1,
OPJ_INT32 p_tile_y1,
OPJ_UINT32 p_nb_comps,
OPJ_BOOL p_go_on,
opj_stream_private_t p_stream,
opj_event_mgr_t p_manager 
)

Reads a tile header.

Parameters
p_jp2the jpeg2000 codec.
p_tile_indexFIXME DOC
p_data_sizeFIXME DOC
p_tile_x0FIXME DOC
p_tile_y0FIXME DOC
p_tile_x1FIXME DOC
p_tile_y1FIXME DOC
p_nb_compsFIXME DOC
p_go_onFIXME DOC
p_streamthe stream to write data to.
p_managerthe user event manager.

References opj_jp2::j2k, and opj_j2k_read_tile_header().

Referenced by opj_create_decompress().

◆ opj_jp2_set_decode_area()

OPJ_BOOL opj_jp2_set_decode_area ( opj_jp2_t p_jp2,
opj_image_t p_image,
OPJ_INT32  p_start_x,
OPJ_INT32  p_start_y,
OPJ_INT32  p_end_x,
OPJ_INT32  p_end_y,
opj_event_mgr_t p_manager 
)

Sets the given area to be decoded.

This function should be called right after opj_read_header and before any tile header reading.

Parameters
p_jp2the jpeg2000 codec.
p_imageFIXME DOC
p_start_xthe left position of the rectangle to decode (in image coordinates).
p_start_ythe up position of the rectangle to decode (in image coordinates).
p_end_xthe right position of the rectangle to decode (in image coordinates).
p_end_ythe bottom position of the rectangle to decode (in image coordinates).
p_managerthe user event manager
Returns
true if the area could be set.

References opj_jp2::j2k, and opj_j2k_set_decode_area().

Referenced by opj_create_decompress().

◆ opj_jp2_set_decoded_components()

OPJ_BOOL opj_jp2_set_decoded_components ( opj_jp2_t jp2,
OPJ_UINT32  numcomps,
const OPJ_UINT32 comps_indices,
opj_event_mgr_t p_manager 
)

Sets the indices of the components to decode.

Parameters
jp2JP2 decompressor handle
numcompsNumber of components to decode.
comps_indicesArray of num_compts indices (numbering starting at 0) corresponding to the components to decode.
p_managerEvent manager;
Returns
OPJ_TRUE in case of success.

References opj_jp2::j2k, and opj_j2k_set_decoded_components().

Referenced by opj_create_decompress().

◆ opj_jp2_set_decoded_resolution_factor()

OPJ_BOOL opj_jp2_set_decoded_resolution_factor ( opj_jp2_t p_jp2,
OPJ_UINT32  res_factor,
opj_event_mgr_t p_manager 
)

◆ opj_jp2_set_threads()

OPJ_BOOL opj_jp2_set_threads ( opj_jp2_t jp2,
OPJ_UINT32  num_threads 
)

Allocates worker threads for the compressor/decompressor.

Parameters
jp2JP2 decompressor handle
num_threadsNumber of threads.
Returns
OPJ_TRUE in case of success.

References opj_jp2::j2k, and opj_j2k_set_threads().

Referenced by opj_create_compress(), and opj_create_decompress().

◆ opj_jp2_setup_decoder()

void opj_jp2_setup_decoder ( opj_jp2_t jp2,
opj_dparameters_t parameters 
)

Setup the decoder decoding parameters using user parameters.

Decoding parameters are returned in jp2->j2k->cp.

Parameters
jp2JP2 decompressor handle
parametersdecompression parameters

References opj_jp2::color, opj_dparameters::flags, opj_jp2::ignore_pclr_cmap_cdef, opj_jp2::j2k, opj_jp2_color::jp2_has_colr, OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG, and opj_j2k_setup_decoder().

Referenced by opj_create_decompress().

◆ opj_jp2_setup_encoder()

OPJ_BOOL opj_jp2_setup_encoder ( opj_jp2_t jp2,
opj_cparameters_t parameters,
opj_image_t image,
opj_event_mgr_t p_manager 
)

◆ opj_jp2_start_compress()

OPJ_BOOL opj_jp2_start_compress ( opj_jp2_t jp2,
opj_stream_private_t stream,
opj_image_t p_image,
opj_event_mgr_t p_manager 
)

Starts a compression scheme, i.e.

validates the codec parameters, writes the header.

Parameters
jp2the jpeg2000 file codec.
streamthe stream object.
p_imageFIXME DOC
p_managerFIXME DOC
Returns
true if the codec is valid.

References opj_jp2::j2k, opj_jp2::m_procedure_list, opj_jp2::m_validation_list, OPJ_FALSE, opj_j2k_start_compress(), opj_jp2_exec(), opj_jp2_setup_encoding_validation(), and opj_jp2_setup_header_writing().

Referenced by opj_create_compress().

◆ opj_jp2_write_tile()

OPJ_BOOL opj_jp2_write_tile ( opj_jp2_t p_jp2,
OPJ_UINT32  p_tile_index,
OPJ_BYTE p_data,
OPJ_UINT32  p_data_size,
opj_stream_private_t p_stream,
opj_event_mgr_t p_manager 
)

Writes a tile.

Parameters
p_jp2the jpeg2000 codec.
p_tile_indexFIXME DOC
p_dataFIXME DOC
p_data_sizeFIXME DOC
p_streamthe stream to write data to.
p_managerthe user event manager.

References opj_jp2::j2k, and opj_j2k_write_tile().

Referenced by opj_create_compress().