OpenJPEG  2.5.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, void *p_user_data)
 
static OPJ_UINT64 opj_get_data_length_from_file (void *p_user_data)
 
static OPJ_SIZE_T opj_write_from_file (void *p_buffer, OPJ_SIZE_T p_nb_bytes, void *p_user_data)
 
static OPJ_OFF_T opj_skip_from_file (OPJ_OFF_T p_nb_bytes, void *p_user_data)
 
static OPJ_BOOL opj_seek_from_file (OPJ_OFF_T p_nb_bytes, void *p_user_data)
 
static void opj_close_from_file (void *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_API OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode (opj_codec_t *p_codec, OPJ_BOOL strict)
 Set strict decoding parameter for this decoder. 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_encoder_set_extra_options (opj_codec_t *p_codec, const char *const *options)
 Specify extra options for the encoder. 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_close_from_file()

static void opj_close_from_file ( void *  p_user_data)
static

◆ 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.

This function must be called after opj_setup_decoder() and before opj_read_header() for the decoding side, or after opj_setup_encoder() and before opj_start_compress() for the encoding side.

Parameters
p_codecdecompressor or compressor handler
num_threadsnumber of threads.
Returns
OPJ_TRUE if the function is successful.

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)

◆ opj_create_decompress()

opj_codec_t* OPJ_CALLCONV opj_create_decompress ( OPJ_CODEC_FORMAT  format)

◆ 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_decompressordecompressor handle
p_streamInput buffer stream
p_imagethe 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_codecthe jpeg2000 codec.
p_tile_indexthe index of the tile being decoded, this should be the value set by opj_read_tile_header.
p_datapointer to a memory block that will hold the decoded data.
p_data_sizesize of p_data. p_data_size should be bigger or equal to the value set by opj_read_tile_header.
p_streamthe 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_decoder_set_strict_mode()

OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode ( opj_codec_t p_codec,
OPJ_BOOL  strict 
)

Set strict decoding parameter for this decoder.

If strict decoding is enabled, partial bit streams will fail to decode. If strict decoding is disabled, the decoder will decode partial bitstreams as much as possible without erroring

Parameters
p_codecdecompressor handler
strictOPJ_TRUE to enable strict decoding, OPJ_FALSE to disable
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.

◆ opj_destroy_codec()

void OPJ_CALLCONV opj_destroy_codec ( opj_codec_t p_codec)

Destroy a decompressor handle.

Parameters
p_codecdecompressor 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)

◆ 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_infoCodestream 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_codecthe jpeg2000 codec.
info_flagtype of information dump.
output_streamoutput 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_codeccompressor handle
p_streamOutput 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_encoder_set_extra_options()

OPJ_BOOL OPJ_CALLCONV opj_encoder_set_extra_options ( opj_codec_t p_codec,
const char *const *  p_options 
)

Specify extra options for the encoder.

This may be called after opj_setup_encoder() and before opj_start_compress()

This is the way to add new options in a fully ABI compatible way, without extending the opj_cparameters_t structure.

Currently supported options are:

  • PLT=YES/NO. Defaults to NO. If set to YES, PLT marker segments, indicating the length of each packet in the tile-part header, will be written. Since 2.4.0
  • TLM=YES/NO. Defaults to NO (except for Cinema and IMF profiles). If set to YES, TLM marker segments, indicating the length of each tile-part part will be written. Since 2.4.0
  • GUARD_BITS=value. Number of guard bits in [0,7] range. Default value is 2. 1 may be used sometimes (like in SMPTE DCP Bv2.1 Application Profile for 2K images). Since 2.5.0
Parameters
p_codecCompressor handle
p_optionsCompression options. This should be a NULL terminated array of strings. Each string is of the form KEY=VALUE.
Returns
OPJ_TRUE in case of success.
Since
2.4.0

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_codecCompressor handle
p_streamInput 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_codecthe JPEG2000 codec to read.
p_streamthe 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_codecthe 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_codecthe 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 ( void *  p_user_data)
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_codecthe jpeg2000 codec.
p_streaminput stream
p_imageoutput image
tile_indexindex 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
sizenumber 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
ptrPointer 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,
void *  p_user_data 
)
static

◆ 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_streamthe jpeg2000 stream.
p_codecthe jpeg2000 codec to read.
p_imagethe 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_codecthe jpeg2000 codec.
p_tile_indexpointer to a value that will hold the index of the tile being decoded, in case of success.
p_data_sizepointer 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_x0pointer to a value that will hold the x0 pos of the tile (in the image).
p_tile_y0pointer to a value that will hold the y0 pos of the tile (in the image).
p_tile_x1pointer to a value that will hold the x1 pos of the tile (in the image).
p_tile_y1pointer to a value that will hold the y1 pos of the tile (in the image).
p_nb_compspointer to a value that will hold the number of components in the tile.
p_should_go_onpointer 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_streamthe 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,
void *  p_user_data 
)
static

References 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_codecthe jpeg2000 codec.
p_imagethe decoded image previously set by opj_read_header
p_start_xthe left position of the rectangle to decode (in image coordinates).
p_end_xthe right position of the rectangle to decode (in image coordinates).
p_start_ythe up position of the rectangle to decode (in image coordinates).
p_end_ythe 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_codecthe jpeg2000 codec to read.
numcompsSize of the comps_indices array.
comps_indicesArray of numcomps values representing the indices of the components to decode (relative to the codestream, starting at 0)
apply_color_transformsWhether 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_codecthe jpeg2000 codec.
res_factorresolution 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)

◆ 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
parametersCompression 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_COMP_PARAM_DEFAULT_CBLOCKH, OPJ_COMP_PARAM_DEFAULT_CBLOCKW, OPJ_COMP_PARAM_DEFAULT_NUMRESOLUTION, OPJ_COMP_PARAM_DEFAULT_PROG_ORDER, OPJ_FALSE, 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_codecthe codec previously initialise
p_callbackthe callback function which will be used
p_user_dataclient 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_codecthe codec previously initialise
p_callbackthe callback function which will be used
p_user_dataclient 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
parametersthe parameters to change.
pEncodingMatrixthe encoding matrix.
p_dc_shiftthe dc shift coefficients to use.
pNbCompthe 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_codecthe codec previously initialise
p_callbackthe callback function which will be used
p_user_dataclient 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_codecdecompressor handler
parametersdecompression 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_codecCompressor handle
parametersCompression parameters
imageInput 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,
void *  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_codecCompressor handle
p_imageInput filled image
p_streamInput 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
fnamethe filename of the file to stream
p_is_read_streamwhether 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
fnamethe filename of the file to stream
p_buffer_sizesize of the chunk used to stream
p_is_read_streamwhether the stream is a read stream (true) or not (false)

References opj_close_from_file(), 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,
void *  p_user_data 
)
static

◆ 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_codecthe jpeg2000 codec.
p_tile_indexthe index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence.
p_datapointer to the data to write. Data is arranged in sequence, data_comp0, then data_comp1, then ... NO INTERLEAVING should be set.
p_data_sizethis 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_streamthe 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.