Grok  9.5.0
Classes | Functions | Variables
grok.cpp File Reference
#include <errno.h>
#include <stdarg.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include "grk_includes.h"

Classes

struct  GrkCodec
 

Functions

bool GRK_CALLCONV grk_initialize (const char *pluginPath, uint32_t numthreads)
 Initialize library. More...
 
GRK_API void GRK_CALLCONV grk_deinitialize ()
 De-initialize library. More...
 
GRK_API void GRK_CALLCONV grk_object_ref (grk_object *obj)
 Increment ref count. More...
 
GRK_API void GRK_CALLCONV grk_object_unref (grk_object *obj)
 
bool GRK_CALLCONV grk_set_info_handler (grk_msg_callback p_callback, void *p_user_data)
 Set info handler. More...
 
bool GRK_CALLCONV grk_set_warning_handler (grk_msg_callback p_callback, void *p_user_data)
 Set warning handler. More...
 
bool GRK_CALLCONV grk_set_error_handler (grk_msg_callback p_callback, void *p_user_data)
 Set error handler. More...
 
static size_t grk_read_from_file (void *buffer, size_t numBytes, FILE *p_file)
 
static uint64_t grk_get_data_length_from_file (FILE *p_file)
 
static size_t grk_write_to_file (void *buffer, size_t numBytes, FILE *p_file)
 
static bool grk_seek_in_file (int64_t numBytes, FILE *p_user_data)
 
const char *GRK_CALLCONV grk_version (void)
 library version More...
 
grk_image *GRK_CALLCONV grk_image_new (uint16_t numcmpts, grk_image_cmptparm *cmptparms, GRK_COLOR_SPACE clrspc, bool allocData)
 Create image. More...
 
grk_image_meta *GRK_CALLCONV grk_image_meta_new (void)
 
void GRK_CALLCONV grk_image_all_components_data_free (grk_image *image)
 Deallocate all component data for an image. More...
 
void GRK_CALLCONV grk_image_single_component_data_free (grk_image_comp *comp)
 Deallocate data for single image component. More...
 
grk_codec *GRK_CALLCONV grk_decompress_create (GRK_CODEC_FORMAT p_format, grk_stream *stream)
 Create J2K/JP2 decompression structure. More...
 
void GRK_CALLCONV grk_decompress_set_default_params (grk_dparameters *parameters)
 Initialize decompress parameters with default values. More...
 
bool GRK_CALLCONV grk_decompress_init (grk_codec *codecWrapper, grk_dparameters *parameters)
 Set up the decompressor with decompress parameters. More...
 
bool GRK_CALLCONV grk_decompress_read_header (grk_codec *codecWrapper, grk_header_info *header_info)
 Decompress JPEG 2000 header. More...
 
bool GRK_CALLCONV grk_decompress_set_window (grk_codec *codecWrapper, uint32_t start_x, uint32_t start_y, uint32_t end_x, uint32_t end_y)
 Set the given area to be decompressed. More...
 
bool GRK_CALLCONV grk_decompress (grk_codec *codecWrapper, grk_plugin_tile *tile)
 Decompress image from a JPEG 2000 code stream. More...
 
bool GRK_CALLCONV grk_decompress_tile (grk_codec *codecWrapper, uint16_t tileIndex)
 Decompress a specific tile. More...
 
bool GRK_CALLCONV grk_decompress_end (grk_codec *codecWrapper)
 End decompression. More...
 
void GRK_CALLCONV grk_dump_codec (grk_codec *codecWrapper, uint32_t info_flag, FILE *output_stream)
 Dump codec information to file. More...
 
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. More...
 
grk_image *GRK_CALLCONV grk_decompress_get_tile_image (grk_codec *codecWrapper, uint16_t tileIndex)
 Get decompressed tile image. More...
 
grk_image *GRK_CALLCONV grk_decompress_get_composited_image (grk_codec *codecWrapper)
 Get decompressed composite image. More...
 
grk_codec *GRK_CALLCONV grk_compress_create (GRK_CODEC_FORMAT p_format, grk_stream *stream)
 Creates a J2K/JP2 compression structure. More...
 
void GRK_CALLCONV grk_compress_set_default_params (grk_cparameters *parameters)
 Set compressing parameters to default values, that means : More...
 
bool GRK_CALLCONV grk_compress_init (grk_codec *codecWrapper, grk_cparameters *parameters, grk_image *p_image)
 Set up the compressor parameters using the current image and user parameters. More...
 
bool GRK_CALLCONV grk_compress_start (grk_codec *codecWrapper)
 Start compressing current image. More...
 
bool GRK_CALLCONV grk_compress (grk_codec *codecWrapper)
 Encode an image into a JPEG 2000 code stream. More...
 
bool GRK_CALLCONV grk_compress_with_plugin (grk_codec *codecWrapper, grk_plugin_tile *tile)
 Encode an image into a JPEG 2000 code stream using plugin. More...
 
bool GRK_CALLCONV grk_compress_end (grk_codec *codecWrapper)
 End to compress the current image. More...
 
bool GRK_CALLCONV grk_compress_tile (grk_codec *codecWrapper, uint16_t tileIndex, uint8_t *p_data, uint64_t data_size)
 Compress uncompressed data stored in a buffer. More...
 
static void grkFree_file (void *p_user_data)
 
grk_stream *GRK_CALLCONV grk_stream_create_file_stream (const char *fname, size_t p_size, bool is_read_stream)
 Create stream from a file identified with its filename with a specific buffer size. More...
 
GRK_API size_t GRK_CALLCONV grk_stream_get_write_mem_stream_length (grk_stream *stream)
 Get length of memory stream. More...
 
grk_stream *GRK_CALLCONV grk_stream_create_mem_stream (uint8_t *buf, size_t len, bool ownsBuffer, bool is_read_stream)
 Create stream from buffer. More...
 
grk_stream *GRK_CALLCONV grk_stream_create_mapped_file_stream (const char *fname, bool read_stream)
 Create mapped file stream. More...
 
static const char * pathSeparator ()
 
bool GRK_CALLCONV grk_plugin_load (grk_plugin_load_info info)
 Load plugin. More...
 
uint32_t GRK_CALLCONV grk_plugin_get_debug_state ()
 Get debug state of plugin. More...
 
void GRK_CALLCONV grk_plugin_cleanup (void)
 Release plugin resources. More...
 
GRK_API bool GRK_CALLCONV grk_plugin_init (grk_plugin_init_info initInfo)
 Initialize plugin. More...
 
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. More...
 
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. More...
 
GRK_API bool GRK_CALLCONV grk_plugin_is_batch_complete (void)
 Check if batch job is complete. More...
 
void GRK_CALLCONV grk_plugin_stop_batch_compress (void)
 Stop batch compress. More...
 
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. More...
 
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. More...
 
int32_t GRK_CALLCONV grk_plugin_batch_decompress (void)
 Batch decompress. More...
 
void GRK_CALLCONV grk_plugin_stop_batch_decompress (void)
 Stop batch decompress. More...
 
grk_stream *GRK_CALLCONV grk_stream_new (size_t buffer_size, bool is_input)
 Create an abstract stream. More...
 
void GRK_CALLCONV grk_stream_set_read_function (grk_stream *stream, grk_stream_read_fn p_function)
 Set the given function to be used as a read function. More...
 
void GRK_CALLCONV grk_stream_set_seek_function (grk_stream *stream, grk_stream_seek_fn p_function)
 Set the given function to be used as a seek function, the stream is then seekable. More...
 
void GRK_CALLCONV grk_stream_set_write_function (grk_stream *stream, grk_stream_write_fn p_function)
 Set the given function to be used as a write function. More...
 
void GRK_CALLCONV grk_stream_set_user_data (grk_stream *stream, void *p_data, grk_stream_free_user_data_fn p_function)
 Set the given data to be used as a user data for the stream. More...
 
void GRK_CALLCONV grk_stream_set_user_data_length (grk_stream *stream, uint64_t data_length)
 Set the length of the user data for the stream. More...
 

Variables

static bool is_plugin_initialized = false
 
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)

Encode an image into a JPEG 2000 code stream.

Parameters
codeccompressor handle
Returns
Returns true if successful, returns false otherwise

References grk_compress_with_plugin().

◆ grk_compress_create()

grk_codec* GRK_CALLCONV grk_compress_create ( GRK_CODEC_FORMAT  format,
grk_stream stream 
)

Creates a J2K/JP2 compression structure.

Parameters
formatCoder to select
streamthe JPEG 2000 stream.
Returns
Returns a handle to a compressor if successful, returns nullptr otherwise

References GRK_CODEC_J2K, GRK_CODEC_JP2, GRK_CODEC_UNKNOWN, and grk::grkFree().

◆ grk_compress_end()

bool GRK_CALLCONV grk_compress_end ( grk_codec codec)

End to compress the current image.

Parameters
codecCompressor handle

References GrkCodec::getImpl().

◆ grk_compress_init()

bool GRK_CALLCONV grk_compress_init ( grk_codec codec,
grk_cparameters parameters,
grk_image image 
)

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

Parameters
codecJPEG 2000 code stream
parameterscompression parameters
imageinput image

References GrkCodec::getImpl().

◆ grk_compress_set_default_params()

void GRK_CALLCONV grk_compress_set_default_params ( grk_cparameters parameters)

◆ grk_compress_start()

bool GRK_CALLCONV grk_compress_start ( grk_codec codec)

Start compressing current image.

Parameters
codecCompressor handle

References GrkCodec::getImpl().

◆ grk_compress_tile()

bool GRK_CALLCONV grk_compress_tile ( grk_codec codec,
uint16_t  tileIndex,
uint8_t *  data,
uint64_t  data_size 
)

Compress uncompressed data stored in a buffer.

This method should be called right after grk_compress_start, and before grk_end_compress.

Parameters
codecJPEG 2000 code stream
tileIndexthe index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence.
datapointer to the data to write. Data is arranged in planar sequence, data_comp0, data_comp1 etc, The data should NOT BE INTERLEAVED.
data_sizethis value is used to ensure 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 or 2 bytes, depending on the precision of the given component.
Returns
true if the data could be written.

References GrkCodec::getImpl().

◆ grk_compress_with_plugin()

bool GRK_CALLCONV grk_compress_with_plugin ( grk_codec codec,
grk_plugin_tile tile 
)

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

Parameters
codeccompressor handle
tileplugin tile
Returns
Returns true if successful, returns false otherwise

References GrkCodec::getImpl().

Referenced by grk_compress().

◆ grk_decompress()

bool GRK_CALLCONV grk_decompress ( grk_codec p_decompressor,
grk_plugin_tile tile 
)

Decompress image from a JPEG 2000 code stream.

Parameters
p_decompressordecompressor handle
tiletile struct from plugin
Returns
true if successful, otherwise false

References GrkCodec::getImpl().

◆ grk_decompress_create()

grk_codec* GRK_CALLCONV grk_decompress_create ( GRK_CODEC_FORMAT  format,
grk_stream stream 
)

Create J2K/JP2 decompression structure.

Parameters
formatJPEG 2000 format
streamJPEG 2000 stream.
Returns
a handle to a decompressor if successful, otherwise nullptr

References GRK_CODEC_J2K, GRK_CODEC_JP2, GRK_CODEC_UNKNOWN, and grk::grkFree().

◆ grk_decompress_end()

bool GRK_CALLCONV grk_decompress_end ( grk_codec codec)

End decompression.

Parameters
codecJPEG 2000 code stream

References GrkCodec::getImpl().

◆ grk_decompress_get_composited_image()

grk_image* GRK_CALLCONV grk_decompress_get_composited_image ( grk_codec codec)

Get decompressed composite image.

Parameters
codecJPEG 2000 code stream to read.
Returns
pointer to decompressed image

References GrkCodec::getImpl().

◆ 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
codecJPEG 2000 code stream to read.
tileIndextile index
Returns
pointer to decompressed image

References GrkCodec::getImpl().

◆ grk_decompress_init()

bool GRK_CALLCONV grk_decompress_init ( grk_codec codec,
grk_dparameters parameters 
)

Set up the decompressor with decompress parameters.

Parameters
codecdecompressor handler
parametersdecompression parameters
Returns
true if the decompressor is correctly set

References GrkCodec::getImpl().

◆ grk_decompress_read_header()

bool GRK_CALLCONV grk_decompress_read_header ( grk_codec codec,
grk_header_info header_info 
)

Decompress JPEG 2000 header.

Parameters
codecJPEG 2000 code stream to read.
header_infoinformation read from JPEG 2000 header.
imagethe image structure initialized with the characteristics of encoded image.
Returns
true if the main header of the code stream and the JP2 header is correctly read.

References GrkCodec::getImpl().

◆ grk_decompress_set_default_params()

void GRK_CALLCONV grk_decompress_set_default_params ( grk_dparameters parameters)

Initialize decompress parameters with default values.

Parameters
parametersdecompression parameters

References GRK_TILE_CACHE_NONE, and _grk_dparameters::tileCacheStrategy.

◆ grk_decompress_set_window()

bool GRK_CALLCONV grk_decompress_set_window ( grk_codec codec,
uint32_t  start_x,
uint32_t  start_y,
uint32_t  end_x,
uint32_t  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
codecJPEG 2000 code stream.
start_xleft position of the rectangle to decompress (in image coordinates).
end_xthe right position of the rectangle to decompress (in image coordinates).
start_yup position of the rectangle to decompress (in image coordinates).
end_ybottom position of the rectangle to decompress (in image coordinates).
Returns
true if the area could be set.

References GrkCodec::getImpl().

◆ grk_decompress_tile()

bool GRK_CALLCONV grk_decompress_tile ( grk_codec codec,
uint16_t  tileIndex 
)

Decompress a specific tile.

Parameters
codecJPEG 2000 code stream
tileIndexindex of the tile to be decompressed
Returns
true if successful, otherwise false

References GrkCodec::getImpl().

◆ grk_deinitialize()

GRK_API void GRK_CALLCONV grk_deinitialize ( )

De-initialize library.

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

Referenced by main().

◆ 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
codecJPEG 2000 code stream.
info_flagtype of information dump.
output_streamoutput stream where dump the information get from the codec.

References GrkCodec::getImpl().

◆ grk_get_data_length_from_file()

static uint64_t grk_get_data_length_from_file ( FILE *  p_file)
static

References GRK_FSEEK, and GRK_FTELL.

Referenced by grk_stream_create_file_stream().

◆ grk_image_all_components_data_free()

void GRK_CALLCONV grk_image_all_components_data_free ( grk_image image)

Deallocate all component data for an image.

Parameters
imageimage

References _grk_image::comps, grk_image_single_component_data_free(), and _grk_image::numcomps.

Referenced by grk::GrkImage::copyHeader(), and grk::GrkImage::~GrkImage().

◆ grk_image_meta_new()

grk_image_meta* GRK_CALLCONV grk_image_meta_new ( void  )

◆ grk_image_new()

grk_image* GRK_CALLCONV grk_image_new ( uint16_t  numcmpts,
grk_image_cmptparm cmptparms,
GRK_COLOR_SPACE  clrspc,
bool  allocData 
)

Create image.

Parameters
numcmptsnumber of components
cmptparmscomponent parameters
clrspcimage color space
allocDatatrue if data is to be allocated, otherwise false
Returns
returns a new image if successful, otherwise nullptr

◆ grk_image_single_component_data_free()

void GRK_CALLCONV grk_image_single_component_data_free ( grk_image_comp image)

◆ grk_initialize()

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

Initialize library.

Parameters
pluginPathpath to plugin
numthreadsnumber of threads to use for compress/decompress

References grk_plugin_load(), ojph::info, ThreadPool::instance(), and is_plugin_initialized.

Referenced by main().

◆ grk_object_ref()

GRK_API void GRK_CALLCONV grk_object_ref ( grk_object obj)

Increment ref count.

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

Referenced by grk::GrkImage::copyHeader().

◆ grk_object_unref()

GRK_API void GRK_CALLCONV grk_object_unref ( grk_object obj)

◆ 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_dirdirectory holding input images
output_dirdirectory holding compressed output images
compress_parameterscompress parameters
callbackcallback
Returns
0 if successful

References grk_plugin_internal_encode_callback(), 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  )

◆ 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_parameterscompress parameters
callbackcallback

References grk_plugin_internal_encode_callback(), 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_parametersdecompress parameters
callbackcallback

References decodeCallback, grk_plugin_internal_decode_callback(), 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 ( )

◆ grk_plugin_init()

GRK_API bool GRK_CALLCONV grk_plugin_init ( grk_plugin_init_info  initInfo)

◆ 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_dirinput directory holding compressed images
output_diroutput directory holding decompressed images
decompress_parametersdecompress parameters
callbackcallback
Returns
0 if successful

References decodeCallback, grk_plugin_internal_decode_callback(), 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)

◆ grk_plugin_internal_encode_callback()

void grk_plugin_internal_encode_callback ( plugin_encode_user_callback_info info)

◆ grk_plugin_is_batch_complete()

GRK_API bool GRK_CALLCONV grk_plugin_is_batch_complete ( void  )

◆ grk_plugin_load()

bool GRK_CALLCONV grk_plugin_load ( grk_plugin_load_info  info)

◆ grk_plugin_stop_batch_compress()

void GRK_CALLCONV grk_plugin_stop_batch_compress ( void  )

◆ grk_plugin_stop_batch_decompress()

void GRK_CALLCONV grk_plugin_stop_batch_decompress ( void  )

◆ grk_read_from_file()

static size_t grk_read_from_file ( void *  buffer,
size_t  numBytes,
FILE *  p_file 
)
static

◆ grk_seek_in_file()

static bool grk_seek_in_file ( int64_t  numBytes,
FILE *  p_user_data 
)
static

References GRK_FSEEK.

Referenced by grk_stream_create_file_stream().

◆ grk_set_error_handler()

bool GRK_CALLCONV grk_set_error_handler ( grk_msg_callback  p_callback,
void *  user_data 
)

Set error handler.

Parameters
p_callbackthe callback function which will be used
user_dataclient object where will be returned the message

◆ grk_set_info_handler()

bool GRK_CALLCONV grk_set_info_handler ( grk_msg_callback  p_callback,
void *  user_data 
)

Set info handler.

Parameters
p_callbackthe callback function which will be used
user_dataclient object where will be returned the message

◆ grk_set_MCT()

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.

Parameters
parametersthe parameters to change.
pEncodingMatrixthe compressing 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 GRK_EXTENSION_MCT, GRK_IS_PART2, GRK_PROFILE_PART2, grk::grkMalloc(), _grk_cparameters::irreversible, _grk_cparameters::mct, _grk_cparameters::mct_data, and _grk_cparameters::rsiz.

◆ grk_set_warning_handler()

bool GRK_CALLCONV grk_set_warning_handler ( grk_msg_callback  p_callback,
void *  user_data 
)

Set warning handler.

Parameters
p_callbackthe callback function which will be used
user_dataclient object where will be returned the message

◆ grk_stream_create_file_stream()

grk_stream* GRK_CALLCONV 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.

Parameters
fnamethe filename of the file to stream
buffer_sizesize of the chunk used to stream
is_read_streamwhether the stream is a read stream (true) or not (false)

References grk_get_data_length_from_file(), 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().

◆ grk_stream_create_mapped_file_stream()

grk_stream* GRK_CALLCONV grk_stream_create_mapped_file_stream ( const char *  fname,
bool  read_stream 
)

Create mapped file stream.

Parameters
fnamefile name
read_streamtrue if this is a read stream, otherwise false

References grk::create_mapped_file_read_stream(), and grk::create_mapped_file_write_stream().

◆ grk_stream_create_mem_stream()

grk_stream* GRK_CALLCONV grk_stream_create_mem_stream ( uint8_t *  buf,
size_t  buffer_len,
bool  ownsBuffer,
bool  is_read_stream 
)

Create stream from buffer.

Parameters
bufbuffer
buffer_lenlength of buffer
ownsBufferif true, library will delete[] buffer. Otherwise, it is the caller's responsibility to delete the buffer
is_read_streamwhether the stream is a read stream (true) or not (false)

References grk::create_mem_stream().

◆ grk_stream_get_write_mem_stream_length()

GRK_API size_t GRK_CALLCONV grk_stream_get_write_mem_stream_length ( grk_stream stream)

Get length of memory stream.

Parameters
streammemory stream

References grk::get_mem_stream_offset().

◆ grk_stream_new()

grk_stream* GRK_CALLCONV grk_stream_new ( size_t  buffer_size,
bool  is_input 
)

Create an abstract stream.

This function does nothing except allocate memory and initialize abstract stream.

Parameters
buffer_sizesize of stream's double-buffer
is_inputif set to true then the stream will be an input stream, an output stream else.
Returns
stream object.

Referenced by grk_stream_create_file_stream().

◆ grk_stream_set_read_function()

void GRK_CALLCONV grk_stream_set_read_function ( grk_stream stream,
grk_stream_read_fn  p_function 
)

Set the given function to be used as a read function.

Parameters
streamthe stream to modify
p_functionthe function to use a read function.

References GROK_STREAM_STATUS_INPUT.

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

◆ grk_stream_set_seek_function()

void GRK_CALLCONV grk_stream_set_seek_function ( grk_stream stream,
grk_stream_seek_fn  p_function 
)

Set the given function to be used as a seek function, the stream is then seekable.

Parameters
streamthe stream to modify
p_functionthe function to use a skip function.

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

◆ grk_stream_set_user_data()

void GRK_CALLCONV grk_stream_set_user_data ( grk_stream stream,
void *  data,
grk_stream_free_user_data_fn  p_function 
)

Set the given data to be used as a user data for the stream.

Parameters
streamthe stream to modify
datathe data to set.
p_functionthe function to free data when grk_object_unref() is called.

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_CALLCONV grk_stream_set_user_data_length ( grk_stream stream,
uint64_t  data_length 
)

Set the length of the user data for the stream.

Parameters
streamthe stream to modify
data_lengthlength of the user_data.

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

◆ grk_stream_set_write_function()

void GRK_CALLCONV grk_stream_set_write_function ( grk_stream stream,
grk_stream_write_fn  p_function 
)

Set the given function to be used as a write function.

Parameters
streamthe stream to modify
p_functionthe function to use a write function.

References 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

Referenced by grk::CodeStreamCompress::initCompress(), and main().

◆ grk_write_to_file()

static size_t grk_write_to_file ( void *  buffer,
size_t  numBytes,
FILE *  p_file 
)
static

◆ grkFree_file()

static void grkFree_file ( void *  p_user_data)
static

◆ pathSeparator()

static const char* pathSeparator ( )
static

Referenced by grk_plugin_load().

Variable Documentation

◆ decodeCallback

grk_plugin_decompress_callback decodeCallback = 0

◆ funcPluginIsBatchComplete

PLUGIN_IS_BATCH_COMPLETE funcPluginIsBatchComplete = nullptr

◆ is_plugin_initialized

bool is_plugin_initialized = false
static

Referenced by grk_initialize().

◆ plugin_batch_decode_method_name

const char* plugin_batch_decode_method_name = "plugin_batch_decompress"
static

◆ plugin_batch_encode_method_name

const char* plugin_batch_encode_method_name = "plugin_batch_encode"
static

◆ 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

◆ plugin_init_batch_decode_method_name

const char* plugin_init_batch_decode_method_name = "plugin_init_batch_decompress"
static

◆ 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

◆ plugin_stop_batch_decode_method_name

const char* plugin_stop_batch_decode_method_name = "plugin_stop_batch_decompress"
static

◆ plugin_stop_batch_encode_method_name

const char* plugin_stop_batch_encode_method_name = "plugin_stop_batch_encode"
static

◆ pluginLoaded

bool pluginLoaded = false

◆ userEncodeCallback

GRK_PLUGIN_COMPRESS_USER_CALLBACK userEncodeCallback = 0