grok.cpp File Reference
`#include <sys/stat.h>`
`#include <unistd.h>`
`#include <sys/mman.h>`
`#include <fcntl.h>`
`#include "grk_includes.h"`

## Classes

struct | GrkCodec

## Functions

static bool | grk_compress_start (grk_codec *codec)
| Start compressing image.
static grk_stream * | grk_stream_create_file_stream (const char *fname, size_t buffer_size, bool is_read_stream)
| Create stream from a file identified with its filename with a specific buffer size.
static grk_stream * | grk_stream_new (size_t buffer_size, bool is_input)
grk_codec * | grk_decompress_create (grk_stream *stream)
bool GRK_CALLCONV | grk_initialize (const char *pluginPath, uint32_t numthreads)
| Initialize library.
GRK_API void GRK_CALLCONV | grk_deinitialize ()
| De-initialize library.
GRK_API grk_object *GRK_CALLCONV | grk_object_ref (grk_object *obj)
| Increment ref count.
GRK_API void GRK_CALLCONV | grk_object_unref (grk_object *obj)
GRK_API void GRK_CALLCONV | grk_set_msg_handlers (grk_msg_callback info_callback, void *info_user_data, grk_msg_callback warn_callback, void *warn_user_data, grk_msg_callback error_callback, void *error_user_data)
static size_t | grk_read_from_file (uint8_t *buffer, size_t numBytes, void *p_file)
static uint64_t | grk_get_data_length_from_file (void *filePtr)
static size_t | grk_write_to_file (const uint8_t *buffer, size_t numBytes, void *p_file)
static bool | grk_seek_in_file (uint64_t numBytes, void *p_user_data)
const char *GRK_CALLCONV | grk_version (void)
| Library version.
grk_image *GRK_CALLCONV | grk_image_new (uint16_t numcmpts, grk_image_comp *cmptparms, GRK_COLOR_SPACE clrspc)
| Create image.
grk_image_meta *GRK_CALLCONV | grk_image_meta_new (void)
bool GRK_CALLCONV | grk_decompress_buffer_detect_format (uint8_t *buffer, size_t len, GRK_CODEC_FORMAT *fmt)
| Detect jpeg 2000 format from buffer Format is either GRK_FMT_J2K or GRK_FMT_JP2.
bool GRK_CALLCONV | grk_decompress_detect_format (const char *fileName, GRK_CODEC_FORMAT *fmt)
| Detect jpeg 2000 format from file Format is either GRK_FMT_J2K or GRK_FMT_JP2.
static grk_codec * | grk_decompress_create_from_buffer (uint8_t *buf, size_t len)
static grk_codec * | grk_decompress_create_from_file (const char *file_name)
void GRK_CALLCONV | grk_decompress_set_default_params (grk_decompress_core_params *parameters)
| Initialize decompress parameters with default values.
grk_codec *GRK_CALLCONV | grk_decompress_init (grk_stream_params *stream_params, grk_decompress_core_params *core_params)
| Initialize decompressor.
bool GRK_CALLCONV | grk_decompress_read_header (grk_codec *codecWrapper, grk_header_info *header_info)
| Decompress JPEG 2000 header.
bool GRK_CALLCONV | grk_decompress_set_window (grk_codec *codecWrapper, float start_x, float start_y, float end_x, float end_y)
| Set the given area to be decompressed.
bool GRK_CALLCONV | grk_decompress (grk_codec *codecWrapper, grk_plugin_tile *tile)
| Decompress image from a JPEG 2000 code stream.
bool GRK_CALLCONV | grk_decompress_tile (grk_codec *codecWrapper, uint16_t tileIndex)
| Decompress a specific tile.
void GRK_CALLCONV | grk_dump_codec (grk_codec *codecWrapper, uint32_t info_flag, FILE *output_stream)
| Dump codec information to file.
bool GRK_CALLCONV | grk_set_MCT (grk_cparameters *parameters, float *pEncodingMatrix, int32_t *p_dc_shift, uint32_t pNbComp)
| Set the MCT matrix to use.
grk_image *GRK_CALLCONV | grk_decompress_get_tile_image (grk_codec *codecWrapper, uint16_t tileIndex)
| Get decompressed tile image.
grk_image *GRK_CALLCONV | grk_decompress_get_composited_image (grk_codec *codecWrapper)
| Get decompressed composite image.
grk_codec *GRK_CALLCONV | grk_compress_create (GRK_CODEC_FORMAT p_format, grk_stream *stream)
void GRK_CALLCONV | grk_compress_set_default_params (grk_cparameters *parameters)
| Set compressing parameters to default values:
grk_codec *GRK_CALLCONV | grk_compress_init (grk_stream_params *stream_params, grk_cparameters *parameters, grk_image *p_image)
| Set up the compressor parameters using the current image and user parameters.
bool GRK_CALLCONV | grk_compress (grk_codec *codecWrapper, grk_plugin_tile *tile)
| Compress an image into a JPEG 2000 code stream using plugin.
static void | grkFree_file (void *p_user_data)
static const char * | pathSeparator ()
bool GRK_CALLCONV | grk_plugin_load (grk_plugin_load_info info)
| Load plugin.
uint32_t GRK_CALLCONV | grk_plugin_get_debug_state ()
| Get debug state of plugin.
void GRK_CALLCONV | grk_plugin_cleanup (void)
| Release plugin resources.
GRK_API bool GRK_CALLCONV | grk_plugin_init (grk_plugin_init_info initInfo)
| Initialize plugin.
void | grk_plugin_internal_encode_callback (plugin_encode_user_callback_info *info)
int32_t GRK_CALLCONV | grk_plugin_compress (grk_cparameters *compress_parameters, GRK_PLUGIN_COMPRESS_USER_CALLBACK callback)
| Compress with plugin.
int32_t GRK_CALLCONV | grk_plugin_batch_compress (const char *input_dir, const char *output_dir, grk_cparameters *compress_parameters, GRK_PLUGIN_COMPRESS_USER_CALLBACK callback)
| Batch compress with plugin.
GRK_API bool GRK_CALLCONV | grk_plugin_is_batch_complete (void)
| Check if batch job is complete.
void GRK_CALLCONV | grk_plugin_stop_batch_compress (void)
| Stop batch compress.
int32_t | grk_plugin_internal_decode_callback (PluginDecodeCallbackInfo *info)
int32_t GRK_CALLCONV | grk_plugin_decompress (grk_decompress_parameters *decompress_parameters, grk_plugin_decompress_callback callback)
| Decompress with plugin.
int32_t GRK_CALLCONV | grk_plugin_init_batch_decompress (const char *input_dir, const char *output_dir, grk_decompress_parameters *decompress_parameters, grk_plugin_decompress_callback callback)
| Initialize batch decompress.
int32_t GRK_CALLCONV | grk_plugin_batch_decompress (void)
| Initiate batch decompress.
void GRK_CALLCONV | grk_plugin_stop_batch_decompress (void)
| Stop batch decompress.
void | grk_stream_set_read_function (grk_stream *stream, grk_stream_read_fn func)
| Set read function.
void | grk_stream_set_seek_function (grk_stream *stream, grk_stream_seek_fn func)
| Set (absolute) seek function (stream must be seekable)
void | grk_stream_set_write_function (grk_stream *stream, grk_stream_write_fn func)
| Set write function.
void | grk_stream_set_user_data (grk_stream *stream, void *p_data, grk_stream_free_user_data_fn func)
| Set user data for JPEG 2000 stream.
void | grk_stream_set_user_data_length (grk_stream *stream, uint64_t data_length)
| Set the length of the user data for the stream.

## Variables

static bool | is_plugin_initialized = false
static const char * | JP2_RFC3745_MAGIC = "\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a"
static const char * | J2K_CODESTREAM_MAGIC = "\xff\x4f\xff\x51"
static const char * | plugin_get_debug_state_method_name = "plugin_get_debug_state"
static const char * | plugin_init_method_name = "plugin_init"
static const char * | plugin_encode_method_name = "plugin_encode"
static const char * | plugin_batch_encode_method_name = "plugin_batch_encode"
static const char * | plugin_stop_batch_encode_method_name = "plugin_stop_batch_encode"
static const char * | plugin_is_batch_complete_method_name = "plugin_is_batch_complete"
static const char * | plugin_decode_method_name = "plugin_decompress"
static const char * | plugin_init_batch_decode_method_name = "plugin_init_batch_decompress"
static const char * | plugin_batch_decode_method_name = "plugin_batch_decompress"
static const char * | plugin_stop_batch_decode_method_name = "plugin_stop_batch_decompress"
bool | pluginLoaded = false
GRK_PLUGIN_COMPRESS_USER_CALLBACK | userEncodeCallback = 0
PLUGIN_IS_BATCH_COMPLETE | funcPluginIsBatchComplete = nullptr
grk_plugin_decompress_callback | decodeCallback = 0

## Function Documentation

## grk_compress()

bool GRK_CALLCONV grk_compress | ( | grk_codec * | codec,
|  | grk_plugin_tile * | tile
| ) |  |

Compress an image into a JPEG 2000 code stream using plugin.

Parameters

  codec | compression codec
  tile | plugin tile

Returns
  Returns true if successful, returns false otherwise

References GrkCodec::getImpl(), and grk::grk_read().

## grk_compress_create()

grk_codec *GRK_CALLCONV grk_compress_create | ( | GRK_CODEC_FORMAT | p_format,
|  | grk_stream * | stream
| ) |  |

References GrkCodec::compressor_, grk::BufferedStream::getImpl(), GRK_CODEC_J2K, GRK_CODEC_JP2, grk::grk_read(), and GrkCodec::obj.

Referenced by grk_compress_init().

## grk_compress_init()

grk_codec *GRK_CALLCONV grk_compress_init | ( | grk_stream_params * | stream_params,
|  | grk_cparameters * | parameters,
|  | grk_image * | p_image
| ) |  |

Set up the compressor parameters using the current image and user parameters.

Parameters

  codec | compression codec
  parameters | compression parameters
  image | input image

References _grk_stream_params::buf, grk::create_mem_stream(), _grk_stream_params::file, GrkCodec::getImpl(), GRK_CODEC_J2K, GRK_CODEC_JP2, grk_compress_create(), grk_compress_start(), grk::GRK_ERROR(), GRK_FMT_J2K, GRK_FMT_JP2, grk_object_unref(), grk::grk_read(), grk_stream_create_file_stream(), and _grk_stream_params::len.

## grk_compress_set_default_params()

void GRK_CALLCONV grk_compress_set_default_params | ( | grk_cparameters * | parameters | ) |

Set compressing parameters to default values:

Lossless Single tile Size of precinct : 2^15 x 2^15 (i.e. single precinct) Size of code block : 64 x 64 Number of resolutions: 6 No SOP marker in the code stream No EPH marker in the code stream No mode switches Progression order: LRCP No ROI upshifted Image origin lies at (0,0) Tile origin lies at (0,0) Reversible DWT 5-3 transform

Parameters

  parameters | Compression parameters

References grk::GRK_COMP_PARAM_DEFAULT_CBLOCKH, grk::GRK_COMP_PARAM_DEFAULT_CBLOCKW, grk::GRK_COMP_PARAM_DEFAULT_NUMRESOLUTION, grk::GRK_COMP_PARAM_DEFAULT_PROG_ORDER, GRK_FMT_UNK, GRK_PROFILE_NONE, and grk::grk_read().

## grk_compress_start()

static bool grk_compress_start | ( | grk_codec * | codec | ) |

static

Start compressing image.

Parameters

  codec | compression codec

References GrkCodec::getImpl(), and grk::grk_read().

Referenced by grk_compress_init().

## grk_decompress()

bool GRK_CALLCONV grk_decompress | ( | grk_codec * | codec,
|  | grk_plugin_tile * | tile
| ) |  |

Decompress image from a JPEG 2000 code stream.

Parameters

  codec | decompression codec
  tile | tile struct from plugin

Returns
  true if successful, otherwise false

References GrkCodec::getImpl(), and grk::grk_read().

## grk_decompress_buffer_detect_format()

bool GRK_CALLCONV grk_decompress_buffer_detect_format | ( | uint8_t * | buffer,
|  | size_t | len,
|  | GRK_CODEC_FORMAT * | fmt
| ) |  |

Detect jpeg 2000 format from buffer Format is either GRK_FMT_J2K or GRK_FMT_JP2.

Parameters

  buffer | buffer
  len | buffer length
  fmt | pointer to detected format

Returns
  true if format was detected, otherwise false

References GRK_CODEC_J2K, GRK_CODEC_JP2, GRK_CODEC_UNK, grk::GRK_ERROR(), grk::grk_read(), J2K_CODESTREAM_MAGIC, and JP2_RFC3745_MAGIC.

Referenced by grk::create_mapped_file_read_stream(), grk::create_mem_stream(), grk_decompress_detect_format(), and grk_stream_create_file_stream().

## grk_decompress_create()

grk_codec * grk_decompress_create | ( | grk_stream * | stream | ) |

References GrkCodec::decompressor_, grk::BufferedStream::getImpl(), GRK_CODEC_J2K, GRK_CODEC_UNK, grk::GRK_ERROR(), grk::grk_read(), and GrkCodec::obj.

Referenced by grk_decompress_create_from_buffer(), and grk_decompress_create_from_file().

## grk_decompress_create_from_buffer()

static grk_codec * grk_decompress_create_from_buffer | ( | uint8_t * | buf,
|  | size_t | len
| ) |  |

static

References grk::create_mem_stream(), grk_decompress_create(), and grk::GRK_ERROR().

Referenced by grk_decompress_init().

## grk_decompress_create_from_file()

static grk_codec * grk_decompress_create_from_file | ( | const char * | file_name | ) |

static

References grk::create_mapped_file_read_stream(), grk_decompress_create(), grk::GRK_ERROR(), grk_object_unref(), and grk::grk_read().

Referenced by grk_decompress_init().

## grk_decompress_detect_format()

bool GRK_CALLCONV grk_decompress_detect_format | ( | const char * | fileName,
|  | GRK_CODEC_FORMAT * | fmt
| ) |  |

Detect jpeg 2000 format from file Format is either GRK_FMT_J2K or GRK_FMT_JP2.

Parameters

  fileName | file name
  fmt | pointer to detected format

Returns
  true if format was detected, otherwise false

References grk_decompress_buffer_detect_format(), and grk::grk_read().

## grk_decompress_get_composited_image()

grk_image *GRK_CALLCONV grk_decompress_get_composited_image | ( | grk_codec * | codec | ) |

Get decompressed composite image.

Parameters

  codec | decompression codec

Returns
  pointer to decompressed image

References GrkCodec::getImpl(), and grk::grk_read().

## grk_decompress_get_tile_image()

grk_image *GRK_CALLCONV grk_decompress_get_tile_image | ( | grk_codec * | codec,
|  | uint16_t | tileIndex
| ) |  |

Get decompressed tile image.

Parameters

  codec | decompression codec
  tileIndex | tile index

Returns
  pointer to decompressed image

References GrkCodec::getImpl(), and grk::grk_read().

## grk_decompress_init()

grk_codec *GRK_CALLCONV grk_decompress_init | ( | grk_stream_params * | stream_params,
|  | grk_decompress_core_params * | core_params
| ) |  |

Initialize decompressor.

Parameters

  stream_params | source stream parameters
  core_params | decompress core parameters

Returns
  grk_codec* if successful, otherwise NULL

References _grk_stream_params::buf, _grk_stream_params::file, GrkCodec::getImpl(), grk_decompress_create_from_buffer(), grk_decompress_create_from_file(), grk_object_unref(), grk::grk_read(), and _grk_stream_params::len.

## grk_decompress_read_header()

bool GRK_CALLCONV grk_decompress_read_header | ( | grk_codec * | codec,
|  | grk_header_info * | header_info
| ) |  |

Decompress JPEG 2000 header.

Parameters

  codec | decompression codec
  header_info | information read from JPEG 2000 header.

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

References GrkCodec::getImpl(), and grk::grk_read().

## grk_decompress_set_default_params()

void GRK_CALLCONV grk_decompress_set_default_params | ( | grk_decompress_core_params * | parameters | ) |

Initialize decompress parameters with default values.

Parameters

  parameters | decompression parameters

References GRK_RANDOM_ACCESS_PLM, GRK_RANDOM_ACCESS_PLT, GRK_RANDOM_ACCESS_TLM, grk::grk_read(), and GRK_TILE_CACHE_NONE.

## grk_decompress_set_window()

bool GRK_CALLCONV grk_decompress_set_window | ( | grk_codec * | codec,
|  | float | start_x,
|  | float | start_y,
|  | float | end_x,
|  | float | end_y
| ) |  |

Set the given area to be decompressed.

This function should be called right after grk_decompress_read_header is called, and before any tile header is read.

Parameters

  codec | decompression codec
  start_x | left position of the rectangle to decompress (in image coordinates).
  end_x | the right position of the rectangle to decompress (in image coordinates).
  start_y | up position of the rectangle to decompress (in image coordinates).
  end_y | bottom position of the rectangle to decompress (in image coordinates).

Returns
  true if the area could be set.

References GrkCodec::getImpl(), and grk::grk_read().

## grk_decompress_tile()

bool GRK_CALLCONV grk_decompress_tile | ( | grk_codec * | codec,
|  | uint16_t | tileIndex
| ) |  |

Decompress a specific tile.

Parameters

  codec | decompression codec
  tileIndex | index of the tile to be decompressed

Returns
  true if successful, otherwise false

References GrkCodec::getImpl(), and grk::grk_read().

## grk_deinitialize()

GRK_API void GRK_CALLCONV grk_deinitialize | ( |  | ) |

De-initialize library.

References grk_plugin_cleanup(), and ExecSingleton::release().

## grk_dump_codec()

void GRK_CALLCONV grk_dump_codec | ( | grk_codec * | codec,
|  | uint32_t | info_flag,
|  | FILE * | output_stream
| ) |  |

Dump codec information to file.

Parameters

  codec | decompression codec
  info_flag | type of information dump.
  output_stream | codec information is dumped to output stream

References GrkCodec::getImpl(), and grk::grk_read().

## grk_get_data_length_from_file()

static uint64_t grk_get_data_length_from_file | ( | void * | filePtr | ) |

static

References GRK_FSEEK, GRK_FTELL, and grk::grk_read().

Referenced by grk_stream_create_file_stream().

## grk_image_meta_new()

grk_image_meta *GRK_CALLCONV grk_image_meta_new | ( | void |  | ) |

Referenced by grk::CodeStreamDecompress::CodeStreamDecompress(), and grk::FileFormatCompress::init().

## grk_image_new()

grk_image *GRK_CALLCONV grk_image_new | ( | uint16_t | numcmpts,
|  | grk_image_comp * | cmptparms,
|  | GRK_COLOR_SPACE | clrspc
| ) |  |

Create image.

Parameters

  numcmpts | number of components
  cmptparms | component parameters
  clrspc | image color space

Returns
  returns a new image if successful, otherwise nullptr

References grk::GrkImage::create(), and grk::grk_read().

## grk_initialize()

bool GRK_CALLCONV grk_initialize | ( | const char * | pluginPath,
|  | uint32_t | numthreads
| ) |  |

Initialize library.

Parameters

  pluginPath | path to plugin
  numthreads | number of threads to use for compress/decompress

References grk_plugin_load(), grk::grk_read(), ExecSingleton::instance(), is_plugin_initialized, and _grk_plugin_load_info::pluginPath.

## grk_object_ref()

GRK_API grk_object *GRK_CALLCONV grk_object_ref | ( | grk_object * | obj | ) |

Increment ref count.

References _grk_object::wrapper.

Referenced by grk::GrkImage::copyHeader(), and grk::FileFormatCompress::init().

## grk_object_unref()

GRK_API void GRK_CALLCONV grk_object_unref | ( | grk_object * | obj | ) |

References grk::GrkObjectWrapper::unref(), and _grk_object::wrapper.

Referenced by grk::GrkImage::cieLabToRGB(), grk::CodeStreamDecompress::createOutputImage(), grk::TileProcessor::generateImage(), grk_compress_init(), grk_decompress_create_from_file(), grk_decompress_init(), grk::TileProcessor::release(), grk::GrkImage::sycc420_to_rgb(), grk::GrkImage::sycc422_to_rgb(), grk::GrkImage::sycc444_to_rgb(), grk::CodeStream::~CodeStream(), grk::CodeStreamDecompress::~CodeStreamDecompress(), grk::FileFormatCompress::~FileFormatCompress(), GrkCodec::~GrkCodec(), grk::GrkImage::~GrkImage(), grk::Strip::~Strip(), and grk::TileCache::~TileCache().

## grk_plugin_batch_compress()

int32_t GRK_CALLCONV grk_plugin_batch_compress | ( | const char * | input_dir,
|  | const char * | output_dir,
|  | grk_cparameters * | compress_parameters,
|  | GRK_PLUGIN_COMPRESS_USER_CALLBACK | callback
| ) |  |

Batch compress with plugin.

Parameters

  input_dir | directory holding input images
  output_dir | directory holding compressed output images
  compress_parameters | compress parameters
  callback | callback

Returns
  0 if successful

References grk_plugin_internal_encode_callback(), grk::grk_read(), grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), plugin_batch_encode_method_name, pluginLoaded, and userEncodeCallback.

## grk_plugin_batch_decompress()

int32_t GRK_CALLCONV grk_plugin_batch_decompress | ( | void |  | ) |

Initiate batch decompress.

References grk::grk_read(), grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), plugin_batch_decode_method_name, and pluginLoaded.

## grk_plugin_cleanup()

void GRK_CALLCONV grk_plugin_cleanup | ( | void |  | ) |

Release plugin resources.

References grk::minpf_cleanup_plugin_manager(), and pluginLoaded.

Referenced by grk_deinitialize().

## grk_plugin_compress()

int32_t GRK_CALLCONV grk_plugin_compress | ( | grk_cparameters * | compress_parameters,
|  | GRK_PLUGIN_COMPRESS_USER_CALLBACK | callback
| ) |  |

Compress with plugin.

Parameters

  compress_parameters | compress parameters
  callback | callback

References grk_plugin_internal_encode_callback(), grk::grk_read(), grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), plugin_encode_method_name, pluginLoaded, and userEncodeCallback.

## grk_plugin_decompress()

int32_t GRK_CALLCONV grk_plugin_decompress | ( | grk_decompress_parameters * | decompress_parameters,
|  | grk_plugin_decompress_callback | callback
| ) |  |

Decompress with plugin.

Parameters

  decompress_parameters | decompress parameters
  callback | callback

References decodeCallback, grk_plugin_internal_decode_callback(), grk::grk_read(), grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), plugin_decode_method_name, and pluginLoaded.

## grk_plugin_get_debug_state()

uint32_t GRK_CALLCONV grk_plugin_get_debug_state | ( |  | ) |

Get debug state of plugin.

References GRK_PLUGIN_STATE_NO_DEBUG, grk::grk_read(), grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), plugin_get_debug_state_method_name, and pluginLoaded.

Referenced by grk::compress_synch_with_plugin(), grk::TileProcessor::doCompress(), grk::TileProcessor::init(), grk::TileProcessor::pcrdBisectFeasible(), grk::TileProcessor::pcrdBisectSimple(), and grk::tile_equals().

## grk_plugin_init()

GRK_API bool GRK_CALLCONV grk_plugin_init | ( | grk_plugin_init_info | initInfo | ) |

Initialize plugin.

References grk::grk_read(), grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), plugin_init_method_name, and pluginLoaded.

## grk_plugin_init_batch_decompress()

int32_t GRK_CALLCONV grk_plugin_init_batch_decompress | ( | const char * | input_dir,
|  | const char * | output_dir,
|  | grk_decompress_parameters * | decompress_parameters,
|  | grk_plugin_decompress_callback | callback
| ) |  |

Initialize batch decompress.

Parameters

  input_dir | input directory holding compressed images
  output_dir | output directory holding decompressed images
  decompress_parameters | decompress parameters
  callback | callback

Returns
  0 if successful

References decodeCallback, grk_plugin_internal_decode_callback(), grk::grk_read(), grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), plugin_init_batch_decode_method_name, and pluginLoaded.

## grk_plugin_internal_decode_callback()

int32_t grk_plugin_internal_decode_callback | ( | PluginDecodeCallbackInfo * | info | ) |

References decodeCallback, and grk::grk_read().

Referenced by grk_plugin_decompress(), and grk_plugin_init_batch_decompress().

## grk_plugin_internal_encode_callback()

void grk_plugin_internal_encode_callback | ( | plugin_encode_user_callback_info * | info | ) |

References grk::grk_read(), and userEncodeCallback.

Referenced by grk_plugin_batch_compress(), and grk_plugin_compress().

## grk_plugin_is_batch_complete()

GRK_API bool GRK_CALLCONV grk_plugin_is_batch_complete | ( | void |  | ) |

Check if batch job is complete.

References funcPluginIsBatchComplete, grk::grk_read(), grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), plugin_is_batch_complete_method_name, and pluginLoaded.

## grk_plugin_load()

bool GRK_CALLCONV grk_plugin_load | ( | grk_plugin_load_info | info | ) |

Load plugin.

Parameters

  info | plugin loading info

References grk::grk_read(), grk::minpf_cleanup_plugin_manager(), grk::minpf_get_dynamic_library_extension(), grk::minpf_load_from_path(), pathSeparator(), and pluginLoaded.

Referenced by grk_initialize().

## grk_plugin_stop_batch_compress()

void GRK_CALLCONV grk_plugin_stop_batch_compress | ( | void |  | ) |

Stop batch compress.

References grk::grk_read(), grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), plugin_stop_batch_encode_method_name, and pluginLoaded.

## grk_plugin_stop_batch_decompress()

void GRK_CALLCONV grk_plugin_stop_batch_decompress | ( | void |  | ) |

Stop batch decompress.

References grk::grk_read(), grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), plugin_stop_batch_decode_method_name, and pluginLoaded.

## grk_read_from_file()

static size_t grk_read_from_file | ( | uint8_t * | buffer,
|  | size_t | numBytes,
|  | void * | p_file
| ) |  |

static

References grk::grk_read().

Referenced by grk_stream_create_file_stream().

## grk_seek_in_file()

static bool grk_seek_in_file | ( | uint64_t | numBytes,
|  | void * | p_user_data
| ) |  |

static

References GRK_FSEEK, and grk::grk_read().

Referenced by grk_stream_create_file_stream().

## grk_set_MCT()

bool GRK_CALLCONV grk_set_MCT | ( | grk_cparameters * | parameters,
|  | float * | encodingMatrix,
|  | int32_t * | dc_shift,
|  | uint32_t | nbComp
| ) |  |

Set the MCT matrix to use.

Parameters

  parameters | the parameters to change.
  encodingMatrix | the compressing matrix.
  dc_shift | the dc shift coefficients to use.
  nbComp | the number of components of the image.

Returns
  true if the parameters could be set.

References GRK_EXTENSION_MCT, GRK_IS_PART2, grk::grk_malloc(), GRK_PROFILE_PART2, and grk::grk_read().

## grk_set_msg_handlers()

GRK_API void GRK_CALLCONV grk_set_msg_handlers | ( | grk_msg_callback | info_callback,
|  | void * | info_user_data,
|  | grk_msg_callback | warn_callback,
|  | void * | warn_user_data,
|  | grk_msg_callback | error_callback,
|  | void * | error_user_data
| ) |  |

References grk::logger::error_data_, grk::logger::error_handler, grk::grk_read(), grk::logger::info_data_, grk::logger::info_handler, grk::logger::logger_, grk::logger::warning_data_, and grk::logger::warning_handler.

## grk_stream_create_file_stream()

static grk_stream * grk_stream_create_file_stream | ( | const char * | fname,
|  | size_t | buffer_size,
|  | bool | is_read_stream
| ) |  |

static

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

Parameters

  fname | the name of the file to stream
  buffer_size | size of the chunk used to stream
  is_read_stream | whether the stream is a read stream (true) or not (false)

References grk::BufferedStream::getImpl(), grk_decompress_buffer_detect_format(), grk::GRK_ERROR(), grk_get_data_length_from_file(), grk::grk_read(), grk_read_from_file(), grk_seek_in_file(), grk_stream_new(), grk_stream_set_read_function(), grk_stream_set_seek_function(), grk_stream_set_user_data(), grk_stream_set_user_data_length(), grk_stream_set_write_function(), grk_write_to_file(), and grkFree_file().

Referenced by grk_compress_init().

## grk_stream_new()

static grk_stream * grk_stream_new | ( | size_t | buffer_size,
|  | bool | is_input
| ) |  |

static

References grk::grk_read().

Referenced by grk_stream_create_file_stream().

## grk_stream_set_read_function()

void grk_stream_set_read_function | ( | grk_stream * | stream,
|  | grk_stream_read_fn | func
| ) |  |

Set read function.

Parameters

  stream | JPEG 2000 stream
  func | read function

References grk::BufferedStream::getImpl(), grk::grk_read(), and GROK_STREAM_STATUS_INPUT.

Referenced by grk_stream_create_file_stream(), and grk::set_up_mem_stream().

## grk_stream_set_seek_function()

void grk_stream_set_seek_function | ( | grk_stream * | stream,
|  | grk_stream_seek_fn | func
| ) |  |

Set (absolute) seek function (stream must be seekable)

Parameters

  stream | JPEG 2000 stream
  func | (absolute) seek function.

References grk::BufferedStream::getImpl(), and grk::grk_read().

Referenced by grk_stream_create_file_stream(), and grk::set_up_mem_stream().

## grk_stream_set_user_data()

void grk_stream_set_user_data | ( | grk_stream * | stream,
|  | void * | data,
|  | grk_stream_free_user_data_fn | func
| ) |  |

Set user data for JPEG 2000 stream.

Parameters

  stream | JPEG 2000 stream
  data | user data
  func | function to free data when grk_object_unref() is called.

References grk::BufferedStream::getImpl(), and grk::grk_read().

Referenced by grk::create_mapped_file_read_stream(), grk::create_mapped_file_write_stream(), grk::create_mem_stream(), and grk_stream_create_file_stream().

## grk_stream_set_user_data_length()

void grk_stream_set_user_data_length | ( | grk_stream * | stream,
|  | uint64_t | data_length
| ) |  |

Set the length of the user data for the stream.

Parameters

  stream | JPEG 2000 stream
  data_length | length of data.

References grk::BufferedStream::getImpl(), and grk::grk_read().

Referenced by grk_stream_create_file_stream(), and grk::set_up_mem_stream().

## grk_stream_set_write_function()

void grk_stream_set_write_function | ( | grk_stream * | stream,
|  | grk_stream_write_fn | func
| ) |  |

Set write function.

Parameters

  stream | JPEG 2000 stream
  func | write function

References grk::BufferedStream::getImpl(), grk::grk_read(), and GROK_STREAM_STATUS_OUTPUT.

Referenced by grk_stream_create_file_stream(), and grk::set_up_mem_stream().

## grk_version()

const char *GRK_CALLCONV grk_version | ( | void |  | ) |

Library version.

References grk::grk_read().

Referenced by grk::CodeStreamCompress::init().

## grk_write_to_file()

static size_t grk_write_to_file | ( | const uint8_t * | buffer,
|  | size_t | numBytes,
|  | void * | p_file
| ) |  |

static

References grk::grk_read().

Referenced by grk_stream_create_file_stream().

## grkFree_file()

static void grkFree_file | ( | void * | p_user_data | ) |

static

References grk::grk_read().

Referenced by grk_stream_create_file_stream().

## pathSeparator()

static const char * pathSeparator | ( |  | ) |

static

Referenced by grk_plugin_load().

## Variable Documentation

## decodeCallback

grk_plugin_decompress_callback decodeCallback = 0

Referenced by grk_plugin_decompress(), grk_plugin_init_batch_decompress(), and grk_plugin_internal_decode_callback().

## funcPluginIsBatchComplete

PLUGIN_IS_BATCH_COMPLETE funcPluginIsBatchComplete = nullptr

Referenced by grk_plugin_is_batch_complete().

## is_plugin_initialized

bool is_plugin_initialized = false

static

Referenced by grk_initialize().

## J2K_CODESTREAM_MAGIC

const char* J2K_CODESTREAM_MAGIC = "\xff\x4f\xff\x51"

static

Referenced by grk_decompress_buffer_detect_format().

## JP2_RFC3745_MAGIC

const char* JP2_RFC3745_MAGIC = "\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a"

static

Referenced by grk_decompress_buffer_detect_format().

## plugin_batch_decode_method_name

const char* plugin_batch_decode_method_name = "plugin_batch_decompress"

static

Referenced by grk_plugin_batch_decompress().

## plugin_batch_encode_method_name

const char* plugin_batch_encode_method_name = "plugin_batch_encode"

static

Referenced by grk_plugin_batch_compress().

## plugin_decode_method_name

const char* plugin_decode_method_name = "plugin_decompress"

static

Referenced by grk_plugin_decompress().

## plugin_encode_method_name

const char* plugin_encode_method_name = "plugin_encode"

static

Referenced by grk_plugin_compress().

## plugin_get_debug_state_method_name

const char* plugin_get_debug_state_method_name = "plugin_get_debug_state"

static

Referenced by grk_plugin_get_debug_state().

## plugin_init_batch_decode_method_name

const char* plugin_init_batch_decode_method_name = "plugin_init_batch_decompress"

static

Referenced by grk_plugin_init_batch_decompress().

## plugin_init_method_name

const char* plugin_init_method_name = "plugin_init"

static

Referenced by grk_plugin_init().

## plugin_is_batch_complete_method_name

const char* plugin_is_batch_complete_method_name = "plugin_is_batch_complete"

static

Referenced by grk_plugin_is_batch_complete().

## plugin_stop_batch_decode_method_name

const char* plugin_stop_batch_decode_method_name = "plugin_stop_batch_decompress"

static

Referenced by grk_plugin_stop_batch_decompress().

## plugin_stop_batch_encode_method_name

const char* plugin_stop_batch_encode_method_name = "plugin_stop_batch_encode"

static

Referenced by grk_plugin_stop_batch_compress().

## pluginLoaded

bool pluginLoaded = false

Referenced by grk_plugin_batch_compress(), grk_plugin_batch_decompress(), grk_plugin_cleanup(), grk_plugin_compress(), grk_plugin_decompress(), grk_plugin_get_debug_state(), grk_plugin_init(), grk_plugin_init_batch_decompress(), grk_plugin_is_batch_complete(), grk_plugin_load(), grk_plugin_stop_batch_compress(), and grk_plugin_stop_batch_decompress().

## userEncodeCallback

GRK_PLUGIN_COMPRESS_USER_CALLBACK userEncodeCallback = 0

Referenced by grk_plugin_batch_compress(), grk_plugin_compress(), and grk_plugin_internal_encode_callback().