OpenJPEG 2.3.0

Functions
openjpeg.c File Reference
`#include "opj_includes.h"`

## Functions
OPJ_BOOL OPJ_CALLCONV | opj_set_info_handler (opj_codec_t *p_codec, opj_msg_callback p_callback, void *p_user_data)
| Set the info handler use by openjpeg. More...
OPJ_BOOL OPJ_CALLCONV | opj_set_warning_handler (opj_codec_t *p_codec, opj_msg_callback p_callback, void *p_user_data)
| Set the warning handler use by openjpeg. More...
OPJ_BOOL OPJ_CALLCONV | opj_set_error_handler (opj_codec_t *p_codec, opj_msg_callback p_callback, void *p_user_data)
| Set the error handler use by openjpeg. More...
static OPJ_SIZE_T | opj_read_from_file (void *p_buffer, OPJ_SIZE_T p_nb_bytes, FILE *p_file)
static OPJ_UINT64 | opj_get_data_length_from_file (FILE *p_file)
static OPJ_SIZE_T | opj_write_from_file (void *p_buffer, OPJ_SIZE_T p_nb_bytes, FILE *p_file)
static OPJ_OFF_T | opj_skip_from_file (OPJ_OFF_T p_nb_bytes, FILE *p_user_data)
static OPJ_BOOL | opj_seek_from_file (OPJ_OFF_T p_nb_bytes, FILE *p_user_data)
const char *OPJ_CALLCONV | opj_version (void)
opj_codec_t *OPJ_CALLCONV | opj_create_decompress (OPJ_CODEC_FORMAT p_format)
| Creates a J2K/JP2 decompression structure. More...
void OPJ_CALLCONV | opj_set_default_decoder_parameters (opj_dparameters_t *parameters)
| Set decoding parameters to default values. More...
OPJ_BOOL OPJ_CALLCONV | opj_codec_set_threads (opj_codec_t *p_codec, int num_threads)
| Allocates worker threads for the compressor/decompressor. More...
OPJ_BOOL OPJ_CALLCONV | opj_setup_decoder (opj_codec_t *p_codec, opj_dparameters_t *parameters)
| Setup the decoder with decompression parameters provided by the user and with the message handler provided by the user. More...
OPJ_BOOL OPJ_CALLCONV | opj_read_header (opj_stream_t *p_stream, opj_codec_t *p_codec, opj_image_t **p_image)
| Decodes an image header. More...
OPJ_BOOL OPJ_CALLCONV | opj_set_decoded_components (opj_codec_t *p_codec, OPJ_UINT32 numcomps, const OPJ_UINT32 *comps_indices, OPJ_BOOL apply_color_transforms)
| Restrict the number of components to decode. More...
OPJ_BOOL OPJ_CALLCONV | opj_decode (opj_codec_t *p_codec, opj_stream_t *p_stream, opj_image_t *p_image)
| Decode an image from a JPEG-2000 codestream. More...
OPJ_BOOL OPJ_CALLCONV | opj_set_decode_area (opj_codec_t *p_codec, 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)
| Sets the given area to be decoded. More...
OPJ_BOOL OPJ_CALLCONV | opj_read_tile_header (opj_codec_t *p_codec, opj_stream_t *p_stream, 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_should_go_on)
| Reads a tile header. More...
OPJ_BOOL OPJ_CALLCONV | opj_decode_tile_data (opj_codec_t *p_codec, OPJ_UINT32 p_tile_index, OPJ_BYTE *p_data, OPJ_UINT32 p_data_size, opj_stream_t *p_stream)
| Reads a tile data. More...
OPJ_BOOL OPJ_CALLCONV | opj_get_decoded_tile (opj_codec_t *p_codec, opj_stream_t *p_stream, opj_image_t *p_image, OPJ_UINT32 tile_index)
| Get the decoded tile from the codec. More...
OPJ_BOOL OPJ_CALLCONV | opj_set_decoded_resolution_factor (opj_codec_t *p_codec, OPJ_UINT32 res_factor)
| Set the resolution factor of the decoded image. More...
opj_codec_t *OPJ_CALLCONV | opj_create_compress (OPJ_CODEC_FORMAT p_format)
| Creates a J2K/JP2 compression structure. More...
void OPJ_CALLCONV | opj_set_default_encoder_parameters (opj_cparameters_t *parameters)
| Set encoding parameters to default values, that means : More...
OPJ_BOOL OPJ_CALLCONV | opj_setup_encoder (opj_codec_t *p_codec, opj_cparameters_t *parameters, opj_image_t *p_image)
| Setup the encoder parameters using the current image and using user parameters. More...
OPJ_BOOL OPJ_CALLCONV | opj_start_compress (opj_codec_t *p_codec, opj_image_t *p_image, opj_stream_t *p_stream)
| Start to compress the current image. More...
OPJ_BOOL OPJ_CALLCONV | opj_encode (opj_codec_t *p_info, opj_stream_t *p_stream)
| Encode an image into a JPEG-2000 codestream. More...
OPJ_BOOL OPJ_CALLCONV | opj_end_compress (opj_codec_t *p_codec, opj_stream_t *p_stream)
| End to compress the current image. More...
OPJ_BOOL OPJ_CALLCONV | opj_end_decompress (opj_codec_t *p_codec, opj_stream_t *p_stream)
| Read after the codestream if necessary. More...
OPJ_BOOL OPJ_CALLCONV | opj_set_MCT (opj_cparameters_t *parameters, OPJ_FLOAT32 *pEncodingMatrix, OPJ_INT32 *p_dc_shift, OPJ_UINT32 pNbComp)
| Sets the MCT matrix to use. More...
OPJ_BOOL OPJ_CALLCONV | opj_write_tile (opj_codec_t *p_codec, OPJ_UINT32 p_tile_index, OPJ_BYTE *p_data, OPJ_UINT32 p_data_size, opj_stream_t *p_stream)
| Writes a tile with the given data. More...
void OPJ_CALLCONV | opj_destroy_codec (opj_codec_t *p_codec)
| Destroy a decompressor handle. More...
void OPJ_CALLCONV | opj_dump_codec (opj_codec_t *p_codec, OPJ_INT32 info_flag, FILE *output_stream)
| Dump the codec information into the output stream. More...
opj_codestream_info_v2_t *OPJ_CALLCONV | opj_get_cstr_info (opj_codec_t *p_codec)
| Get the codestream information from the codec. More...
void OPJ_CALLCONV | opj_destroy_cstr_info (opj_codestream_info_v2_t **cstr_info)
| Destroy Codestream information after compression or decompression. More...
opj_codestream_index_t *OPJ_CALLCONV | opj_get_cstr_index (opj_codec_t *p_codec)
| Get the codestream index from the codec. More...
void OPJ_CALLCONV | opj_destroy_cstr_index (opj_codestream_index_t **p_cstr_index)
opj_stream_t *OPJ_CALLCONV | opj_stream_create_default_file_stream (const char *fname, OPJ_BOOL p_is_read_stream)
| Create a stream from a file identified with its filename with default parameters (helper function) More...
opj_stream_t *OPJ_CALLCONV | opj_stream_create_file_stream (const char *fname, OPJ_SIZE_T p_size, OPJ_BOOL p_is_read_stream)
| Create a stream from a file identified with its filename with a specific buffer size. More...
void *OPJ_CALLCONV | opj_image_data_alloc (OPJ_SIZE_T size)
| Allocator for opj_image_t->comps[].data To be paired with opj_image_data_free. More...
void OPJ_CALLCONV | opj_image_data_free (void *ptr)
| Destructor for opj_image_t->comps[].data To be paired with opj_image_data_alloc. More...

## Function Documentation

## ◆ opj_codec_set_threads()

OPJ_BOOL OPJ_CALLCONV opj_codec_set_threads | ( | opj_codec_t * | p_codec,
|  | int | num_threads
| ) |  |

Allocates worker threads for the compressor/decompressor.

By default, only the main thread is used. If this function is not used, but the OPJ_NUM_THREADS environment variable is set, its value will be used to initialize the number of threads. The value can be either an integer number, or "ALL_CPUS". If OPJ_NUM_THREADS is set and this function is called, this function will override the behaviour of the environment variable.

Note: currently only has effect on the decompressor.

Parameters

  p_codec | decompressor handler
  num_threads | number of threads.

Returns
  OPJ_TRUE if the decoder is correctly set

References opj_codec_private::m_codec, OPJ_FALSE, and opj_codec_private::opj_set_threads.

## ◆ opj_create_compress()

opj_codec_t* OPJ_CALLCONV opj_create_compress | ( | OPJ_CODEC_FORMAT | format | ) |

Creates a J2K/JP2 compression structure.

Parameters

  format | Coder to select

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

References opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_compression, opj_codec_private::m_event_mgr, opj_calloc(), OPJ_CODEC_J2K, OPJ_CODEC_JP2, OPJ_CODEC_JPT, OPJ_CODEC_UNKNOWN, OPJ_FALSE, opj_free(), opj_j2k_create_compress(), opj_j2k_destroy(), opj_j2k_encode(), opj_j2k_end_compress(), opj_j2k_setup_encoder(), opj_j2k_start_compress(), opj_j2k_write_tile(), opj_jp2_create(), opj_jp2_destroy(), opj_jp2_encode(), opj_jp2_end_compress(), opj_jp2_setup_encoder(), opj_jp2_start_compress(), opj_jp2_write_tile(), and opj_set_default_event_handler().

## ◆ opj_create_decompress()

opj_codec_t* OPJ_CALLCONV opj_create_decompress | ( | OPJ_CODEC_FORMAT | format | ) |

Creates a J2K/JP2 decompression structure.

Parameters

  format | Decoder to select

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

References opj_codec_private::is_decompressor, j2k_dump(), j2k_get_cstr_index(), j2k_get_cstr_info(), jp2_dump(), jp2_get_cstr_index(), jp2_get_cstr_info(), opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_decompression, opj_codec_private::m_event_mgr, opj_calloc(), OPJ_CODEC_J2K, OPJ_CODEC_JP2, OPJ_CODEC_JPT, OPJ_CODEC_UNKNOWN, opj_codec_private::opj_dump_codec, opj_free(), opj_codec_private::opj_get_codec_index, opj_codec_private::opj_get_codec_info, opj_j2k_create_decompress(), opj_j2k_decode(), opj_j2k_decode_tile(), opj_j2k_destroy(), opj_j2k_end_decompress(), opj_j2k_get_tile(), opj_j2k_read_header(), opj_j2k_read_tile_header(), opj_j2k_set_decode_area(), opj_j2k_set_decoded_components(), opj_j2k_set_decoded_resolution_factor(), opj_j2k_set_threads(), opj_j2k_setup_decoder(), opj_jp2_create(), opj_jp2_decode(), opj_jp2_decode_tile(), opj_jp2_destroy(), opj_jp2_end_decompress(), opj_jp2_get_tile(), opj_jp2_read_header(), opj_jp2_read_tile_header(), opj_jp2_set_decode_area(), opj_jp2_set_decoded_components(), opj_jp2_set_decoded_resolution_factor(), opj_jp2_set_threads(), opj_jp2_setup_decoder(), opj_set_default_event_handler(), opj_codec_private::opj_set_threads, and OPJ_TRUE.

Referenced by j2k_to_pnm().

## ◆ opj_decode()

OPJ_BOOL OPJ_CALLCONV opj_decode | ( | opj_codec_t * | p_decompressor,
|  | opj_stream_t * | p_stream,
|  | opj_image_t * | p_image
| ) |  |

Decode an image from a JPEG-2000 codestream.

Parameters

  p_decompressor | decompressor handle
  p_stream | Input buffer stream
  p_image | the decoded image

Returns
  true if success, otherwise false

References opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_decompression, opj_codec_private::m_event_mgr, and OPJ_FALSE.

Referenced by j2k_to_pnm().

## ◆ opj_decode_tile_data()

OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data | ( | opj_codec_t * | p_codec,
|  | OPJ_UINT32 | p_tile_index,
|  | OPJ_BYTE * | p_data,
|  | OPJ_UINT32 | p_data_size,
|  | opj_stream_t * | p_stream
| ) |  |

Reads a tile data.

This function is compulsory and allows one to decode tile data. opj_read_tile_header should be called before. The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.

Note: opj_decode_tile_data() should not be used together with opj_set_decoded_components().

Parameters

  p_codec | the jpeg2000 codec.
  p_tile_index | the index of the tile being decoded, this should be the value set by opj_read_tile_header.
  p_data | pointer to a memory block that will hold the decoded data.
  p_data_size | size of p_data. p_data_size should be bigger or equal to the value set by opj_read_tile_header.
  p_stream | the stream to decode.

Returns
  true if the data could be decoded.

References opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_decompression, opj_codec_private::m_event_mgr, and OPJ_FALSE.

## ◆ opj_destroy_codec()

void OPJ_CALLCONV opj_destroy_codec | ( | opj_codec_t * | p_codec | ) |

Destroy a decompressor handle.

Parameters

  p_codec | decompressor handle to destroy

References opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_compression, opj_codec_private::m_decompression, and opj_free().

Referenced by j2k_to_pnm().

## ◆ opj_destroy_cstr_index()

void OPJ_CALLCONV opj_destroy_cstr_index | ( | opj_codestream_index_t ** | p_cstr_index | ) |

References j2k_destroy_cstr_index().

## ◆ opj_destroy_cstr_info()

void OPJ_CALLCONV opj_destroy_cstr_info | ( | opj_codestream_info_v2_t ** | cstr_info | ) |

Destroy Codestream information after compression or decompression.

Parameters

  cstr_info | Codestream information structure

References opj_free().

Referenced by j2k_get_cstr_info().

## ◆ opj_dump_codec()

void OPJ_CALLCONV opj_dump_codec | ( | opj_codec_t * | p_codec,
|  | OPJ_INT32 | info_flag,
|  | FILE * | output_stream
| ) |  |

Dump the codec information into the output stream.

Parameters

  p_codec | the jpeg2000 codec.
  info_flag | type of information dump.
  output_stream | output stream where dump the information gotten from the codec.

References opj_codec_private::m_codec, and opj_codec_private::opj_dump_codec.

## ◆ opj_encode()

OPJ_BOOL OPJ_CALLCONV opj_encode | ( | opj_codec_t * | p_codec,
|  | opj_stream_t * | p_stream
| ) |  |

Encode an image into a JPEG-2000 codestream.

Parameters

  p_codec | compressor handle
  p_stream | Output buffer stream

Returns
  Returns true if successful, returns false otherwise

References opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_compression, opj_codec_private::m_event_mgr, and OPJ_FALSE.

## ◆ opj_end_compress()

OPJ_BOOL OPJ_CALLCONV opj_end_compress | ( | opj_codec_t * | p_codec,
|  | opj_stream_t * | p_stream
| ) |  |

End to compress the current image.

Parameters

  p_codec | Compressor handle
  p_stream | Input stgream

References opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_compression, opj_codec_private::m_event_mgr, and OPJ_FALSE.

## ◆ opj_end_decompress()

OPJ_BOOL OPJ_CALLCONV opj_end_decompress | ( | opj_codec_t * | p_codec,
|  | opj_stream_t * | p_stream
| ) |  |

Read after the codestream if necessary.

Parameters

  p_codec | the JPEG2000 codec to read.
  p_stream | the JPEG2000 stream.

References opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_decompression, opj_codec_private::m_event_mgr, and OPJ_FALSE.

Referenced by j2k_to_pnm().

## ◆ opj_get_cstr_index()

opj_codestream_index_t* OPJ_CALLCONV opj_get_cstr_index | ( | opj_codec_t * | p_codec | ) |

Get the codestream index from the codec.

Parameters

  p_codec | the jpeg2000 codec.

Returns
  a pointer to a codestream index structure.

References opj_codec_private::m_codec, and opj_codec_private::opj_get_codec_index.

## ◆ opj_get_cstr_info()

opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info | ( | opj_codec_t * | p_codec | ) |

Get the codestream information from the codec.

Parameters

  p_codec | the jpeg2000 codec.

Returns
  a pointer to a codestream information structure.

References opj_codec_private::m_codec, and opj_codec_private::opj_get_codec_info.

## ◆ opj_get_data_length_from_file()

static OPJ_UINT64 opj_get_data_length_from_file | ( | FILE * | p_file | ) |
| static

References OPJ_FSEEK, and OPJ_FTELL.

Referenced by opj_stream_create_file_stream().

## ◆ opj_get_decoded_tile()

OPJ_BOOL OPJ_CALLCONV opj_get_decoded_tile | ( | opj_codec_t * | p_codec,
|  | opj_stream_t * | p_stream,
|  | opj_image_t * | p_image,
|  | OPJ_UINT32 | tile_index
| ) |  |

Get the decoded tile from the codec.

Parameters

  p_codec | the jpeg2000 codec.
  p_stream | input streamm
  p_image | output image
  tile_index | index of the tile which will be decode

Returns
  true if success, otherwise false

References opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_decompression, opj_codec_private::m_event_mgr, and OPJ_FALSE.

## ◆ opj_image_data_alloc()

void* OPJ_CALLCONV opj_image_data_alloc | ( | OPJ_SIZE_T | size | ) |

Allocator for opj_image_t->comps[].data To be paired with opj_image_data_free.

Parameters

  size | number of bytes to allocate

Returns
  a new pointer if successful, NULL otherwise.

Since
  2.2.0

References opj_aligned_malloc().

Referenced by opj_alloc_tile_component_data(), opj_image_create(), opj_j2k_update_image_data(), opj_jp2_apply_pclr(), and opj_tcd_decode_tile().

## ◆ opj_image_data_free()

void OPJ_CALLCONV opj_image_data_free | ( | void * | ptr | ) |

Destructor for opj_image_t->comps[].data To be paired with opj_image_data_alloc.

Parameters

  ptr | Pointer to free

Since
  2.2.0

References opj_aligned_free().

Referenced by opj_alloc_tile_component_data(), opj_copy_image_header(), opj_image_destroy(), opj_j2k_decode_tiles(), opj_j2k_get_tile(), opj_j2k_move_data_from_codec_to_output_image(), opj_jp2_apply_pclr(), opj_tcd_decode_tile(), opj_tcd_free_tile(), and opj_tcd_init_tile().

## ◆ opj_read_from_file()

static OPJ_SIZE_T opj_read_from_file | ( | void * | p_buffer,
|  | OPJ_SIZE_T | p_nb_bytes,
|  | FILE * | p_file
| ) |  |
| static

Referenced by opj_stream_create_file_stream().

## ◆ opj_read_header()

OPJ_BOOL OPJ_CALLCONV opj_read_header | ( | opj_stream_t * | p_stream,
|  | opj_codec_t * | p_codec,
|  | opj_image_t ** | p_image
| ) |  |

Decodes an image header.

Parameters

  p_stream | the jpeg2000 stream.
  p_codec | the jpeg2000 codec to read.
  p_image | the image structure initialized with the characteristics of encoded image.

Returns
  true if the main header of the codestream and the JP2 header is correctly read.

References EVT_ERROR, opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_decompression, opj_codec_private::m_event_mgr, opj_event_msg(), and OPJ_FALSE.

Referenced by j2k_to_pnm().

## ◆ opj_read_tile_header()

OPJ_BOOL OPJ_CALLCONV opj_read_tile_header | ( | opj_codec_t * | p_codec,
|  | opj_stream_t * | p_stream,
|  | 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_should_go_on
| ) |  |

Reads a tile header.

This function is compulsory and allows one to know the size of the tile that will be decoded. The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile.

Parameters

  p_codec | the jpeg2000 codec.
  p_tile_index | pointer to a value that will hold the index of the tile being decoded, in case of success.
  p_data_size | pointer to a value that will hold the maximum size of the decoded data, in case of success. In case of truncated codestreams, the actual number of bytes decoded may be lower. The computation of the size is the same as depicted in opj_write_tile.
  p_tile_x0 | pointer to a value that will hold the x0 pos of the tile (in the image).
  p_tile_y0 | pointer to a value that will hold the y0 pos of the tile (in the image).
  p_tile_x1 | pointer to a value that will hold the x1 pos of the tile (in the image).
  p_tile_y1 | pointer to a value that will hold the y1 pos of the tile (in the image).
  p_nb_comps | pointer to a value that will hold the number of components in the tile.
  p_should_go_on | pointer to a boolean that will hold the fact that the decoding should go on. In case the codestream is over at the time of the call, the value will be set to false. The user should then stop the decoding.
  p_stream | the stream to decode.

Returns
  true if the tile header could be decoded. In case the decoding should end, the returned value is still true. returning false may be the result of a shortage of memory or an internal error.

References opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_decompression, opj_codec_private::m_event_mgr, and OPJ_FALSE.

## ◆ opj_seek_from_file()

static OPJ_BOOL opj_seek_from_file | ( | OPJ_OFF_T | p_nb_bytes,
|  | FILE * | p_user_data
| ) |  |
| static

References OPJ_ARG_NOT_USED, OPJ_FALSE, OPJ_FSEEK, and OPJ_TRUE.

Referenced by opj_stream_create_file_stream().

## ◆ opj_set_decode_area()

OPJ_BOOL OPJ_CALLCONV opj_set_decode_area | ( | opj_codec_t * | p_codec,
|  | 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
| ) |  |

Sets the given area to be decoded.

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

The coordinates passed to this function should be expressed in the reference grid, that is to say at the highest resolution level, even if requesting the image at lower resolution levels.

Generally opj_set_decode_area() should be followed by opj_decode(), and the codec cannot be re-used. In the particular case of an image made of a single tile, several sequences of calls to opoj_set_decode_area() and opj_decode() are allowed, and will bring performance improvements when reading an image by chunks.

Parameters

  p_codec | the jpeg2000 codec.
  p_image | the decoded image previously setted by opj_read_header
  p_start_x | the left position of the rectangle to decode (in image coordinates).
  p_end_x | the right position of the rectangle to decode (in image coordinates).
  p_start_y | the up position of the rectangle to decode (in image coordinates).
  p_end_y | the bottom position of the rectangle to decode (in image coordinates).

Returns
  true if the area could be set.

References opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_decompression, opj_codec_private::m_event_mgr, and OPJ_FALSE.

Referenced by j2k_to_pnm().

## ◆ opj_set_decoded_components()

OPJ_BOOL OPJ_CALLCONV opj_set_decoded_components | ( | opj_codec_t * | p_codec,
|  | OPJ_UINT32 | numcomps,
|  | const OPJ_UINT32 * | comps_indices,
|  | OPJ_BOOL | apply_color_transforms
| ) |  |

Restrict the number of components to decode.

This function should be called after opj_read_header().

This function enables to restrict the set of decoded components to the specified indices. Note that the current implementation (apply_color_transforms == OPJ_FALSE) is such that neither the multi-component transform at codestream level, nor JP2 channel transformations will be applied. Consequently the indices are relative to the codestream.

Note: opj_decode_tile_data() should not be used together with opj_set_decoded_components().

Parameters

  p_codec | the jpeg2000 codec to read.
  numcomps | Size of the comps_indices array.
  comps_indices | Array of numcomps values representing the indices of the components to decode (relative to the codestream, starting at 0)
  apply_color_transforms | Whether multi-component transform at codestream level or JP2 channel transformations should be applied. Currently this parameter should be set to OPJ_FALSE. Setting it to OPJ_TRUE will result in an error.

Returns
  OPJ_TRUE in case of success.

References EVT_ERROR, opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_decompression, opj_codec_private::m_event_mgr, opj_event_msg(), and OPJ_FALSE.

## ◆ opj_set_decoded_resolution_factor()

OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor | ( | opj_codec_t * | p_codec,
|  | OPJ_UINT32 | res_factor
| ) |  |

Set the resolution factor of the decoded image.

Parameters

  p_codec | the jpeg2000 codec.
  res_factor | resolution factor to set

Returns
  true if success, otherwise false

References opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_decompression, opj_codec_private::m_event_mgr, and OPJ_FALSE.

## ◆ opj_set_default_decoder_parameters()

void OPJ_CALLCONV opj_set_default_decoder_parameters | ( | opj_dparameters_t * | parameters | ) |

Set decoding parameters to default values.

Parameters

  parameters | Decompression parameters

References opj_dparameters::cod_format, opj_dparameters::cp_layer, opj_dparameters::cp_reduce, opj_dparameters::decod_format, opj_dparameters::flags, opj_dparameters::jpwl_correct, opj_dparameters::jpwl_exp_comps, JPWL_EXPECTED_COMPONENTS, opj_dparameters::jpwl_max_tiles, JPWL_MAXIMUM_TILES, and OPJ_FALSE.

Referenced by j2k_to_pnm().

## ◆ opj_set_default_encoder_parameters()

void OPJ_CALLCONV opj_set_default_encoder_parameters | ( | opj_cparameters_t * | parameters | ) |

Set encoding parameters to default values, that means :

- Lossless
- 1 tile
- Size of precinct : 2^15 x 2^15 (means 1 precinct)
- Size of code-block : 64 x 64
- Number of resolutions: 6
- No SOP marker in the codestream
- No EPH marker in the codestream
- No sub-sampling in x or y direction
- No mode switch activated
- Progression order: LRCP
- No index file
- No ROI upshifted
- No offset of the origin of the image
- No offset of the origin of the tiles
- Reversible DWT 5-3

Parameters

  parameters | Compression parameters

References opj_cparameters::cblockh_init, opj_cparameters::cblockw_init, opj_cparameters::cod_format, opj_cparameters::cp_cinema, opj_cparameters::cp_disto_alloc, opj_cparameters::cp_fixed_alloc, opj_cparameters::cp_fixed_quality, opj_cparameters::cp_rsiz, opj_cparameters::decod_format, opj_cparameters::jpip_on, opj_cparameters::jpwl_epc_on, opj_cparameters::jpwl_hprot_MH, opj_cparameters::jpwl_hprot_TPH, opj_cparameters::jpwl_hprot_TPH_tileno, JPWL_MAX_NO_PACKSPECS, JPWL_MAX_NO_TILESPECS, opj_cparameters::jpwl_pprot, opj_cparameters::jpwl_pprot_packno, opj_cparameters::jpwl_pprot_tileno, opj_cparameters::jpwl_sens_addr, opj_cparameters::jpwl_sens_MH, opj_cparameters::jpwl_sens_range, opj_cparameters::jpwl_sens_size, opj_cparameters::jpwl_sens_TPH, opj_cparameters::jpwl_sens_TPH_tileno, opj_cparameters::max_comp_size, opj_cparameters::numresolution, OPJ_FALSE, OPJ_LRCP, OPJ_OFF, OPJ_PROFILE_NONE, OPJ_STD_RSIZ, opj_cparameters::prog_order, opj_cparameters::roi_compno, opj_cparameters::rsiz, opj_cparameters::subsampling_dx, opj_cparameters::subsampling_dy, opj_cparameters::tcp_numlayers, opj_cparameters::tcp_rates, and opj_cparameters::tp_on.

## ◆ opj_set_error_handler()

OPJ_BOOL OPJ_CALLCONV opj_set_error_handler | ( | opj_codec_t * | p_codec,
|  | opj_msg_callback | p_callback,
|  | void * | p_user_data
| ) |  |

Set the error handler use by openjpeg.

Parameters

  p_codec | the codec previously initialise
  p_callback | the callback function which will be used
  p_user_data | client object where will be returned the message

References opj_event_mgr::error_handler, opj_event_mgr::m_error_data, opj_codec_private::m_event_mgr, OPJ_FALSE, and OPJ_TRUE.

Referenced by j2k_to_pnm().

## ◆ opj_set_info_handler()

OPJ_BOOL OPJ_CALLCONV opj_set_info_handler | ( | opj_codec_t * | p_codec,
|  | opj_msg_callback | p_callback,
|  | void * | p_user_data
| ) |  |

Set the info handler use by openjpeg.

Parameters

  p_codec | the codec previously initialise
  p_callback | the callback function which will be used
  p_user_data | client object where will be returned the message

References opj_event_mgr::info_handler, opj_codec_private::m_event_mgr, opj_event_mgr::m_info_data, OPJ_FALSE, and OPJ_TRUE.

Referenced by j2k_to_pnm().

## ◆ opj_set_MCT()

OPJ_BOOL OPJ_CALLCONV opj_set_MCT | ( | opj_cparameters_t * | parameters,
|  | OPJ_FLOAT32 * | pEncodingMatrix,
|  | OPJ_INT32 * | p_dc_shift,
|  | OPJ_UINT32 | pNbComp
| ) |  |

Sets the MCT matrix to use.

Parameters

  parameters | the parameters to change.
  pEncodingMatrix | the encoding matrix.
  p_dc_shift | the dc shift coefficients to use.
  pNbComp | the number of components of the image.

Returns
  true if the parameters could be set.

References opj_cparameters::irreversible, opj_cparameters::mct_data, OPJ_EXTENSION_MCT, OPJ_FALSE, OPJ_IS_PART2, opj_malloc(), OPJ_PROFILE_PART2, OPJ_TRUE, opj_cparameters::rsiz, and opj_cparameters::tcp_mct.

## ◆ opj_set_warning_handler()

OPJ_BOOL OPJ_CALLCONV opj_set_warning_handler | ( | opj_codec_t * | p_codec,
|  | opj_msg_callback | p_callback,
|  | void * | p_user_data
| ) |  |

Set the warning handler use by openjpeg.

Parameters

  p_codec | the codec previously initialise
  p_callback | the callback function which will be used
  p_user_data | client object where will be returned the message

References opj_codec_private::m_event_mgr, opj_event_mgr::m_warning_data, OPJ_FALSE, OPJ_TRUE, and opj_event_mgr::warning_handler.

Referenced by j2k_to_pnm().

## ◆ opj_setup_decoder()

OPJ_BOOL OPJ_CALLCONV opj_setup_decoder | ( | opj_codec_t * | p_codec,
|  | opj_dparameters_t * | parameters
| ) |  |

Setup the decoder with decompression parameters provided by the user and with the message handler provided by the user.

Parameters

  p_codec | decompressor handler
  parameters | decompression parameters

Returns
  true if the decoder is correctly set

References EVT_ERROR, opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_decompression, opj_codec_private::m_event_mgr, opj_event_msg(), OPJ_FALSE, and OPJ_TRUE.

Referenced by j2k_to_pnm().

## ◆ opj_setup_encoder()

OPJ_BOOL OPJ_CALLCONV opj_setup_encoder | ( | opj_codec_t * | p_codec,
|  | opj_cparameters_t * | parameters,
|  | opj_image_t * | image
| ) |  |

Setup the encoder parameters using the current image and using user parameters.

Parameters

  p_codec | Compressor handle
  parameters | Compression parameters
  image | Input filled image

References opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_compression, opj_codec_private::m_event_mgr, and OPJ_FALSE.

## ◆ opj_skip_from_file()

static OPJ_OFF_T opj_skip_from_file | ( | OPJ_OFF_T | p_nb_bytes,
|  | FILE * | p_user_data
| ) |  |
| static

References OPJ_FSEEK.

Referenced by opj_stream_create_file_stream().

## ◆ opj_start_compress()

OPJ_BOOL OPJ_CALLCONV opj_start_compress | ( | opj_codec_t * | p_codec,
|  | opj_image_t * | p_image,
|  | opj_stream_t * | p_stream
| ) |  |

Start to compress the current image.

Parameters

  p_codec | Compressor handle
  p_image | Input filled image
  p_stream | Input stgream

References opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_compression, opj_codec_private::m_event_mgr, and OPJ_FALSE.

## ◆ opj_stream_create_default_file_stream()

opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream | ( | const char * | fname,
|  | OPJ_BOOL | p_is_read_stream
| ) |  |

Create a stream from a file identified with its filename with default parameters (helper function)

Parameters

  fname | the filename of the file to stream
  p_is_read_stream | whether the stream is a read stream (true) or not (false)

References OPJ_J2K_STREAM_CHUNK_SIZE, and opj_stream_create_file_stream().

Referenced by j2k_to_pnm().

## ◆ opj_stream_create_file_stream()

opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream | ( | const char * | fname,
|  | OPJ_SIZE_T | p_buffer_size,
|  | OPJ_BOOL | p_is_read_stream
| ) |  |

Create a stream from a file identified with its filename with a specific buffer size.

Parameters

  fname | the filename of the file to stream
  p_buffer_size | size of the chunk used to stream
  p_is_read_stream | whether the stream is a read stream (true) or not (false)

References opj_get_data_length_from_file(), opj_read_from_file(), opj_seek_from_file(), opj_skip_from_file(), opj_stream_create(), opj_stream_set_read_function(), opj_stream_set_seek_function(), opj_stream_set_skip_function(), opj_stream_set_user_data(), opj_stream_set_user_data_length(), opj_stream_set_write_function(), and opj_write_from_file().

Referenced by opj_stream_create_default_file_stream().

## ◆ opj_version()

const char* OPJ_CALLCONV opj_version | ( | void |  | ) |

Referenced by opj_j2k_setup_encoder().

## ◆ opj_write_from_file()

static OPJ_SIZE_T opj_write_from_file | ( | void * | p_buffer,
|  | OPJ_SIZE_T | p_nb_bytes,
|  | FILE * | p_file
| ) |  |
| static

Referenced by opj_stream_create_file_stream().

## ◆ opj_write_tile()

OPJ_BOOL OPJ_CALLCONV opj_write_tile | ( | opj_codec_t * | p_codec,
|  | OPJ_UINT32 | p_tile_index,
|  | OPJ_BYTE * | p_data,
|  | OPJ_UINT32 | p_data_size,
|  | opj_stream_t * | p_stream
| ) |  |

Writes a tile with the given data.

Parameters

  p_codec | the jpeg2000 codec.
  p_tile_index | the index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence.
  p_data | pointer to the data to write. Data is arranged in sequence, data_comp0, then data_comp1, then ... NO INTERLEAVING should be set.
  p_data_size | this value os used to make sure the data being written is correct. The size must be equal to the sum for each component of tile_width * tile_height * component_size. component_size can be 1,2 or 4 bytes, depending on the precision of the given component.
  p_stream | the stream to write data to.

Returns
  true if the data could be written.

References opj_codec_private::is_decompressor, opj_codec_private::m_codec, opj_codec_private::m_codec_data, opj_codec_private::m_compression, opj_codec_private::m_event_mgr, and OPJ_FALSE.