Grok 20.3.2
grok.h File Reference
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <limits.h>
#include "grk_config.h"

Go to the source code of this file.

Classes

struct  _grk_msg_handlers
struct  _grk_object
struct  _grk_progression
struct  _grk_raw_comp_cparameters
struct  _grk_raw_cparameters
struct  _grk_component_mapping_comp
struct  _grk_palette_data
struct  _grk_channel_description
struct  _grk_channel_definition
struct  _grk_asoc
struct  _grk_precision
struct  _grk_progression_state
struct  _grk_io_buf
struct  _grk_io_init
struct  _grk_stream_params
struct  _grk_decompress_core_params
struct  _grk_decompress_params
struct  _grk_image_comp
struct  _grk_color
struct  _grk_image_meta
struct  _grk_image
struct  _grk_header_info
struct  grk_swath_buffer
 User-managed output buffer for asynchronous swath tile copy-and-convert. More...
struct  grk_wait_swath
 Specify swath region to wait on during asynchronous decompression. More...
struct  _grk_plugin_pass
struct  _grk_plugin_code_block
struct  _grk_plugin_precinct
 grk_plugin_precinct More...
struct  _grk_plugin_band
struct  _grk_plugin_resolution
struct  grk_plugin_tile_component
 Plugin tile component. More...
struct  _grk_plugin_tile
struct  _grk_cparameters
struct  _grk_plugin_load_info
struct  _grk_plugin_init_info
struct  grk_plugin_compress_user_callback_info
 Plugin compress user callback info. More...
struct  grk_plugin_compress_batch_info
 Plugin batch compress info. More...
struct  _grk_plugin_decompress_callback_info

Macros

#define GRK_CALLCONV
#define GRK_API   __attribute__((visibility("default")))
#define GRK_NUM_COMMENTS_SUPPORTED   256
 maximum Grok supported number of comments
#define GRK_NUM_ASOC_BOXES_SUPPORTED   256
 maximum Grok supported number of asoc boxes
#define GRK_NUM_XML_BOXES_SUPPORTED   64
 maximum Grok supported number of XML boxes
#define GRK_MAX_COMMENT_LENGTH   (UINT16_MAX - 2)
 maximum Grok supported comment length
#define GRK_MAX_SUPPORTED_IMAGE_PRECISION   16
 maximum Grok supported precision
#define GRK_BIBO_EXTRA_BITS   7
 BIBO analysis - extra bits needed to avoid overflow: Lossless: without colour transform: 4 extra bits with colour transform: 5 extra bits.
#define GRK_MAX_PASSES   (3 * (GRK_MAX_SUPPORTED_IMAGE_PRECISION + GRK_BIBO_EXTRA_BITS) - 2)
 Grok maximum number of passes.
#define GRK_PATH_LEN   4096 /* Grok maximum supported filename size */
#define GRK_MAX_LAYERS   256 /* Grok maximum number of quality layers */
#define GRK_MAX_DECOMP_LVLS
#define GRK_MAXRLVLS   (GRK_MAX_DECOMP_LVLS + 1) /* Maximum number of resolution levels allowed by standard*/
#define GRK_MAXBANDS   (3 * GRK_MAXRLVLS - 2) /* Maximum number of sub-bands allowed by standard */
#define GRK_MAX_CUSTOM_HEADERS   16
#define GRK_TILE_CACHE_NONE   0 /* no tile caching */
 Grok tile cache strategy.
#define GRK_TILE_CACHE_IMAGE   1 /* cache final tile image */
#define GRK_TILE_CACHE_ALL   2 /* cache everything */
#define GRK_TILE_CACHE_LRU   4 /* LRU: release decompressed data, keep processor */
#define GRK_RANDOM_ACCESS_PLT   1 /* Disable PLT marker if present */
 Decompression: disable random access markers.
#define GRK_RANDOM_ACCESS_TLM   2 /* Disable TLM marker if present */
#define GRK_RANDOM_ACCESS_PLM   4 /* Disable PLM marker if present */
#define GRK_DECOMPRESS_COMPRESSION_LEVEL_DEFAULT   (UINT_MAX)
 default compression level for decompression output file formats that support compression
#define GRK_DECODE_HEADER   (1 << 0)
#define GRK_DECODE_T2   (1 << 1)
#define GRK_DECODE_T1   (1 << 2)
#define GRK_DECODE_POST_T1   (1 << 3)
#define GRK_PLUGIN_DECODE_CLEAN   (1 << 4)
#define GRK_DECODE_ALL   (GRK_PLUGIN_DECODE_CLEAN | GRK_DECODE_HEADER | GRK_DECODE_T2 | GRK_DECODE_T1 | GRK_DECODE_POST_T1)
#define GRK_IMG_INFO   1 /* Basic image information provided to the user */
#define GRK_MH_INFO   2 /* Codestream information based only on the main header */
#define GRK_TH_INFO   4 /* Tile information based on the current tile header */
#define GRK_TCH_INFO   8 /** Tile/Component information of all tiles */
#define GRK_MH_IND   16 /** Codestream index based only on the main header */
#define GRK_TH_IND   32 /** Tile index based on the current tile */
#define GRK_CBLKSTY_LAZY   0x01 /** Selective arithmetic coding bypass */
#define GRK_CBLKSTY_RESET   0x02 /** Reset context probabilities on coding pass boundaries */
#define GRK_CBLKSTY_TERMALL   0x04 /** Termination on each coding pass */
#define GRK_CBLKSTY_VSC   0x08 /** Vertical stripe causal context */
#define GRK_CBLKSTY_PTERM   0x10 /** Predictable termination */
#define GRK_CBLKSTY_SEGSYM   0x20 /** Segmentation symbols are used */
#define GRK_CBLKSTY_HT_ONLY   0x40 /** high throughput only block coding */
#define GRK_CBLKSTY_HT_MIXED   0xC0 /** mixed high throughput block coding */
#define GRK_JPH_RSIZ_FLAG   0x4000 /**for JPH, bit 14 of RSIZ must be set to 1 */
#define GRK_PROFILE_NONE   0x0000 /** no profile, conform to 15444-1 */
#define GRK_PROFILE_0   0x0001 /** Profile 0 as described in 15444-1,Table A.45 */
#define GRK_PROFILE_1   0x0002 /** Profile 1 as described in 15444-1,Table A.45 */
#define GRK_PROFILE_CINEMA_2K   0x0003 /** 2K cinema profile defined in 15444-1 AMD1 */
#define GRK_PROFILE_CINEMA_4K   0x0004 /** 4K cinema profile defined in 15444-1 AMD1 */
#define GRK_PROFILE_CINEMA_S2K   0x0005 /** Scalable 2K cinema profile defined in 15444-1 AMD2 */
#define GRK_PROFILE_CINEMA_S4K   0x0006 /** Scalable 4K cinema profile defined in 15444-1 AMD2 */
#define GRK_PROFILE_CINEMA_LTS   0x0007 /** Long term storage cinema profile defined in 15444-1 AMD2 */
#define GRK_PROFILE_BC_SINGLE   0x0100 /** Single Tile Broadcast profile defined in 15444-1 AMD3 */
#define GRK_PROFILE_BC_MULTI   0x0200 /** Multi Tile Broadcast profile defined in 15444-1 AMD3 */
#define GRK_PROFILE_BC_MULTI_R   0x0300 /** Multi Tile Reversible Broadcast profile defined in 15444-1 AMD3 */
#define GRK_PROFILE_BC_MASK   0x030F /** Mask for broadcast profile including main level */
#define GRK_PROFILE_IMF_2K   0x0400 /** 2K Single Tile Lossy IMF profile defined in 15444-1 AMD8 */
#define GRK_PROFILE_IMF_4K   0x0500 /** 4K Single Tile Lossy IMF profile defined in 15444-1 AMD8 */
#define GRK_PROFILE_IMF_8K   0x0600 /** 8K Single Tile Lossy IMF profile defined in 15444-1 AMD8 */
#define GRK_PROFILE_IMF_2K_R   0x0700 /** 2K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD8 */
#define GRK_PROFILE_IMF_4K_R   0x0800 /** 4K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD8 */
#define GRK_PROFILE_IMF_8K_R   0x0900 /** 8K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD8 */
#define GRK_PROFILE_MASK   0x0FFF /** Mask for profile bits */
#define GRK_PROFILE_PART2   0x8000 /** At least 1 extension defined in 15444-2 (Part-2) */
#define GRK_PROFILE_PART2_EXTENSIONS_MASK   0x3FFF /* Mask for Part-2 extension bits */
#define GRK_EXTENSION_NONE   0x0000 /** No Part-2 extension */
 JPEG 2000 Part-2 extensions.
#define GRK_EXTENSION_MCT   0x0100 /** Custom MCT support */
#define GRK_IS_PART2(v)
#define GRK_IS_CINEMA(v)
#define GRK_IS_STORAGE(v)
#define GRK_GET_IMF_OR_BROADCAST_PROFILE(v)
#define GRK_LEVEL_MAX   11U /** Maximum (main) level */
#define GRK_GET_LEVEL(v)
#define GRK_IS_BROADCAST(v)
#define GRK_BROADCAST_LEVEL_1_MBITSSEC   200U /** Mbits/sec for level 1 */
#define GRK_BROADCAST_LEVEL_2_MBITSSEC   200U /** Mbits/sec for level 2 */
#define GRK_BROADCAST_LEVEL_3_MBITSSEC   200U /** Mbits/sec for level 3 */
#define GRK_BROADCAST_LEVEL_4_MBITSSEC   400U /** Mbits/sec for level 4 */
#define GRK_BROADCAST_LEVEL_5_MBITSSEC   800U /** Mbits/sec for level 5 */
#define GRK_BROADCAST_LEVEL_6_MBITSSEC   1600U /** Mbits/sec for level 6 */
#define GRK_BROADCAST_LEVEL_7_MBITSSEC   3200U /** Mbits/sec for level 7 */
#define GRK_BROADCAST_LEVEL_8_MBITSSEC   6400U /** Mbits/sec for level 8 */
#define GRK_BROADCAST_LEVEL_9_MBITSSEC   12800U /** Mbits/sec for level 9 */
#define GRK_BROADCAST_LEVEL_10_MBITSSEC   25600U /** Mbits/sec for level 10 */
#define GRK_BROADCAST_LEVEL_11_MBITSSEC   51200U /** Mbits/sec for level 11 */
#define GRK_BROADCAST_LEVEL_1_MSAMPLESSEC   64U /** MSamples/sec for level 1 */
#define GRK_BROADCAST_LEVEL_2_MSAMPLESSEC   130U /** MSamples/sec for level 2 */
#define GRK_BROADCAST_LEVEL_3_MSAMPLESSEC   195U /** MSamples/sec for level 3 */
#define GRK_BROADCAST_LEVEL_4_MSAMPLESSEC   260U /** MSamples/sec for level 4 */
#define GRK_BROADCAST_LEVEL_5_MSAMPLESSEC   520U /** MSamples/sec for level 5 */
#define GRK_BROADCAST_LEVEL_6_MSAMPLESSEC   1200U /** MSamples/sec for level 6 */
#define GRK_BROADCAST_LEVEL_7_MSAMPLESSEC   2400U /** MSamples/sec for level 7 */
#define GRK_BROADCAST_LEVEL_8_MSAMPLESSEC   4800U /** MSamples/sec for level 8 */
#define GRK_BROADCAST_LEVEL_9_MSAMPLESSEC   9600U /** MSamples/sec for level 9 */
#define GRK_BROADCAST_LEVEL_10_MSAMPLESSEC   19200U /** MSamples/sec for level 10 */
#define GRK_BROADCAST_LEVEL_11_MSAMPLESSEC   38400U /** MSamples/sec for level 11 */
#define GRK_IS_IMF(v)
#define GRK_IMF_MAINLEVEL_1_MSAMPLESSEC   65U /** MSamples/sec for main level 1 */
#define GRK_IMF_MAINLEVEL_2_MSAMPLESSEC   130U /** MSamples/sec for main level 2 */
#define GRK_IMF_MAINLEVEL_3_MSAMPLESSEC   195U /** MSamples/sec for main level 3 */
#define GRK_IMF_MAINLEVEL_4_MSAMPLESSEC   260U /** MSamples/sec for main level 4 */
#define GRK_IMF_MAINLEVEL_5_MSAMPLESSEC   520U /** MSamples/sec for main level 5 */
#define GRK_IMF_MAINLEVEL_6_MSAMPLESSEC   1200U /** MSamples/sec for main level 6 */
#define GRK_IMF_MAINLEVEL_7_MSAMPLESSEC   2400U /** MSamples/sec for main level 7 */
#define GRK_IMF_MAINLEVEL_8_MSAMPLESSEC   4800U /** MSamples/sec for main level 8 */
#define GRK_IMF_MAINLEVEL_9_MSAMPLESSEC   9600U /** MSamples/sec for main level 9 */
#define GRK_IMF_MAINLEVEL_10_MSAMPLESSEC   19200U /** MSamples/sec for main level 10 */
#define GRK_IMF_MAINLEVEL_11_MSAMPLESSEC   38400U /** MSamples/sec for main level 11 */
#define GRK_IMF_SUBLEVEL_MAX   9U /** Maximum IMF sublevel */
#define GRK_GET_IMF_SUBLEVEL(v)
#define GRK_IMF_SUBLEVEL_1_MBITSSEC   200U /** Mbits/s for IMF sub level 1 */
 Maximum compressed bit rate (Mbits/s) per IMF sub level.
#define GRK_IMF_SUBLEVEL_2_MBITSSEC   400U /** Mbits/s for IMF sub level 2 */
#define GRK_IMF_SUBLEVEL_3_MBITSSEC   800U /** Mbits/s for IMF sub level 3 */
#define GRK_IMF_SUBLEVEL_4_MBITSSEC   1600U /** Mbits/s for IMF sub level 4 */
#define GRK_IMF_SUBLEVEL_5_MBITSSEC   3200U /** Mbits/s for IMF sub level 5 */
#define GRK_IMF_SUBLEVEL_6_MBITSSEC   6400U /** Mbits/s for IMF sub level 6 */
#define GRK_IMF_SUBLEVEL_7_MBITSSEC   12800U /** Mbits/s for IMF sub level 7 */
#define GRK_IMF_SUBLEVEL_8_MBITSSEC   25600U /** Mbits/s for IMF sub level 8 */
#define GRK_IMF_SUBLEVEL_9_MBITSSEC   51200U /** Mbits/s for IMF sub level 9 */
#define GRK_CINEMA_DCI_MAX_BANDWIDTH   250000000
 JPEG 2000 cinema profile code stream and component size limits.
#define GRK_CINEMA_24_CS   1302083 /** Maximum code stream length @ 24fps */
#define GRK_CINEMA_24_COMP   1041666 /** Maximum size per color component @ 24fps */
#define GRK_CINEMA_48_CS   651041 /** Maximum code stream length @ 48fps */
#define GRK_CINEMA_48_COMP   520833 /** Maximum size per color component @ 48fps */
#define GRK_CINEMA_4K_DEFAULT_NUM_RESOLUTIONS   7 /* Default number of resolutions for 4K cinema */
#define GRK_CUSTOM_CIELAB_SPACE   0x0
#define GRK_DEFAULT_CIELAB_SPACE   0x44454600 /* 'DEF' */
#define GRK_PLUGIN_STATE_NO_DEBUG   0x0
 No debug is done on plugin.
#define GRK_PLUGIN_STATE_DEBUG   0x1
#define GRK_PLUGIN_STATE_PRE_TR1   0x2
#define GRK_PLUGIN_STATE_DWT_QUANTIZATION   0x4
#define GRK_PLUGIN_STATE_MCT_ONLY   0x8

Typedefs

typedef enum _GRK_PROG_ORDER GRK_PROG_ORDER
 Environment variables.
typedef enum _GRK_COLOR_SPACE GRK_COLOR_SPACE
 Grok supported color spaces.
typedef enum _GRK_ENUM_COLOUR_SPACE GRK_ENUM_COLOUR_SPACE
 JPEG 2000 enumerated color spaces.
typedef void(* grk_msg_callback) (const char *msg, void *client_data)
 Logging callback.
typedef struct _grk_msg_handlers grk_msg_handlers
typedef struct _grk_object grk_object
typedef struct _grk_progression grk_progression
typedef struct _grk_raw_comp_cparameters grk_raw_comp_cparameters
typedef struct _grk_raw_cparameters grk_raw_cparameters
typedef enum _GRK_RATE_CONTROL_ALGORITHM GRK_RATE_CONTROL_ALGORITHM
 Rate control algorithms.
typedef enum _GRK_SUPPORTED_FILE_FMT GRK_SUPPORTED_FILE_FMT
 All Grok supported file formats.
typedef enum _GRK_CODEC_FORMAT GRK_CODEC_FORMAT
 Grok Supported JPEG 2000 formats.
typedef struct _grk_component_mapping_comp grk_component_mapping_comp
typedef struct _grk_palette_data grk_palette_data
typedef enum _GRK_CHANNEL_TYPE GRK_CHANNEL_TYPE
typedef enum _GRK_CHANNEL_ASSOC GRK_CHANNEL_ASSOC
 Channel association.
typedef struct _grk_channel_description grk_channel_description
typedef struct _grk_channel_definition grk_channel_definition
typedef struct _grk_asoc grk_asoc
typedef enum _grk_precision_mode grk_precision_mode
 Precision mode.
typedef struct _grk_precision grk_precision
typedef struct _grk_progression_state grk_progression_state
typedef struct _grk_io_buf grk_io_buf
typedef struct _grk_io_init grk_io_init
typedef bool(* grk_io_callback) (uint32_t worker_id, grk_io_buf buffer, void *io_user_data)
 Grok IO callback.
typedef void(* grk_io_register_reclaim_callback) (grk_io_init io_init, grk_io_callback reclaim_callback, void *io_user_data, void *reclaim_user_data)
 Grok IO register reclaim callback.
typedef bool(* grk_io_pixels_callback) (uint32_t worker_id, grk_io_buf buffer, void *user_data)
 Grok IO pixels callback.
typedef size_t(* grk_stream_read_fn) (uint8_t *buffer, size_t numBytes, void *user_data)
 Read stream callback.
typedef size_t(* grk_stream_write_fn) (const uint8_t *buffer, size_t numBytes, void *user_data)
 Write stream callback.
typedef bool(* grk_stream_seek_fn) (uint64_t offset, void *user_data)
 Seek (absolute) callback.
typedef void(* grk_stream_free_user_data_fn) (void *user_data)
 Free user data callback.
typedef struct _grk_stream_params grk_stream_params
typedef struct _grk_image grk_image
typedef bool(* grk_io_band_callback) (uint32_t yBegin, uint32_t yEnd, grk_image *image, void *user_data)
 Callback invoked when a horizontal band of the decompressed image is ready for writing.
typedef void(* grk_decompress_callback) (void *codec, uint16_t tile_index, grk_image *tile_image, uint8_t reduction, void *user_data)
 Callback called when decompression of a tile has completed.
typedef struct _grk_decompress_core_params grk_decompress_core_params
typedef struct _grk_decompress_params grk_decompress_parameters
typedef enum _grk_data_type grk_data_type
 Grok Data types Used to specify the actual data type of Grok image components.
typedef struct _grk_image_comp grk_image_comp
typedef struct _grk_color grk_color
typedef struct _grk_image_meta grk_image_meta
typedef struct _grk_header_info grk_header_info
typedef struct grk_swath_buffer grk_swath_buffer
typedef struct grk_wait_swath grk_wait_swath
typedef struct _grk_plugin_pass grk_plugin_pass
typedef struct _grk_plugin_code_block grk_plugin_code_block
typedef struct _grk_plugin_precinct grk_plugin_precinct
 grk_plugin_precinct
typedef struct _grk_plugin_band grk_plugin_band
typedef struct _grk_plugin_resolution grk_plugin_resolution
typedef struct grk_plugin_tile_component grk_plugin_tile_component
typedef struct _grk_plugin_tile grk_plugin_tile
typedef struct _grk_cparameters grk_cparameters
typedef struct _grk_plugin_load_info grk_plugin_load_info
typedef struct _grk_plugin_init_info grk_plugin_init_info
typedef struct grk_plugin_compress_user_callback_info grk_plugin_compress_user_callback_info
typedef uint64_t(* GRK_PLUGIN_COMPRESS_USER_CALLBACK) (grk_plugin_compress_user_callback_info *info)
 Plugin compress user callback.
typedef struct grk_plugin_compress_batch_info grk_plugin_compress_batch_info
 Plugin batch compress info.
typedef int(* GROK_INIT_DECOMPRESSORS) (grk_header_info *header_info, grk_image *image)
 Plugin init decompressors.
typedef struct _grk_plugin_decompress_callback_info grk_plugin_decompress_callback_info
typedef int32_t(* grk_plugin_decompress_callback) (grk_plugin_decompress_callback_info *info)
 Plugin decompress callback.

Enumerations

enum  _GRK_PROG_ORDER {
  GRK_PROG_UNKNOWN = -1 , GRK_LRCP = 0 , GRK_RLCP = 1 , GRK_RPCL = 2 ,
  GRK_PCRL = 3 , GRK_CPRL = 4 , GRK_NUM_PROGRESSION_ORDERS = 5
}
 Environment variables. More...
enum  _GRK_COLOR_SPACE {
  GRK_CLRSPC_UNKNOWN = 0 , GRK_CLRSPC_SRGB = 2 , GRK_CLRSPC_GRAY = 3 , GRK_CLRSPC_SYCC = 4 ,
  GRK_CLRSPC_EYCC = 5 , GRK_CLRSPC_CMYK = 6 , GRK_CLRSPC_DEFAULT_CIE = 7 , GRK_CLRSPC_CUSTOM_CIE = 8 ,
  GRK_CLRSPC_ICC = 9
}
 Grok supported color spaces. More...
enum  _GRK_ENUM_COLOUR_SPACE {
  GRK_ENUM_CLRSPC_UNKNOWN = 0xFFFFFFFF , GRK_ENUM_CLRSPC_BILEVEL1 = 0 , GRK_ENUM_CLRSPC_YCBCR1 = 1 , GRK_ENUM_CLRSPC_YCBCR2 = 3 ,
  GRK_ENUM_CLRSPC_YCBCR3 = 4 , GRK_ENUM_CLRSPC_PHOTO_YCC = 9 , GRK_ENUM_CLRSPC_CMY = 11 , GRK_ENUM_CLRSPC_CMYK = 12 ,
  GRK_ENUM_CLRSPC_YCCK = 13 , GRK_ENUM_CLRSPC_CIE = 14 , GRK_ENUM_CLRSPC_BILEVEL2 = 15 , GRK_ENUM_CLRSPC_SRGB = 16 ,
  GRK_ENUM_CLRSPC_GRAY = 17 , GRK_ENUM_CLRSPC_SYCC = 18 , GRK_ENUM_CLRSPC_CIEJAB = 19 , GRK_ENUM_CLRSPC_ESRGB = 20 ,
  GRK_ENUM_CLRSPC_ROMMRGB = 21 , GRK_ENUM_CLRSPC_YPBPR60 = 22 , GRK_ENUM_CLRSPC_YPBPR50 = 23 , GRK_ENUM_CLRSPC_EYCC = 24
}
 JPEG 2000 enumerated color spaces. More...
enum  _GRK_RATE_CONTROL_ALGORITHM { GRK_RATE_CONTROL_BISECT , GRK_RATE_CONTROL_PCRD_OPT }
 Rate control algorithms. More...
enum  _GRK_SUPPORTED_FILE_FMT {
  GRK_FMT_UNK , GRK_FMT_J2K , GRK_FMT_JP2 , GRK_FMT_PXM ,
  GRK_FMT_PGX , GRK_FMT_PAM , GRK_FMT_BMP , GRK_FMT_TIF ,
  GRK_FMT_RAW , GRK_FMT_PNG , GRK_FMT_RAWL , GRK_FMT_JPG ,
  GRK_FMT_MJ2
}
 All Grok supported file formats. More...
enum  _GRK_CODEC_FORMAT { GRK_CODEC_UNK , GRK_CODEC_J2K , GRK_CODEC_JP2 , GRK_CODEC_MJ2 }
 Grok Supported JPEG 2000 formats. More...
enum  _GRK_CHANNEL_TYPE { GRK_CHANNEL_TYPE_COLOUR = 0 , GRK_CHANNEL_TYPE_OPACITY = 1 , GRK_CHANNEL_TYPE_PREMULTIPLIED_OPACITY = 2 , GRK_CHANNEL_TYPE_UNSPECIFIED = 65535U }
enum  _GRK_CHANNEL_ASSOC {
  GRK_CHANNEL_ASSOC_WHOLE_IMAGE = 0 , GRK_CHANNEL_ASSOC_COLOUR_1 = 1 , GRK_CHANNEL_ASSOC_COLOUR_2 = 2 , GRK_CHANNEL_ASSOC_COLOUR_3 = 3 ,
  GRK_CHANNEL_ASSOC_UNASSOCIATED = 65535U
}
 Channel association. More...
enum  _grk_precision_mode { GRK_PREC_MODE_CLIP , GRK_PREC_MODE_SCALE }
 Precision mode. More...
enum  _grk_data_type {
  GRK_INT_32 , GRK_INT_16 , GRK_INT_8 , GRK_FLOAT ,
  GRK_DOUBLE
}
 Grok Data types Used to specify the actual data type of Grok image components. More...

Functions

GRK_API const char *GRK_CALLCONV grk_version (void)
 Gets the Grok library version string.
GRK_API bool GRK_CALLCONV grk_detect_format (const char *file_path, GRK_CODEC_FORMAT *format)
 Detect the JPEG 2000 codec format of a file by reading its magic bytes.
GRK_API void GRK_CALLCONV grk_initialize (const char *plugin_path, uint32_t num_threads, bool *plugin_initialized)
 Initializes the Grok library.
GRK_API void GRK_CALLCONV grk_deinitialize (void)
 Deinitialize the Grok library.
GRK_API grk_object *GRK_CALLCONV grk_object_ref (grk_object *obj)
 Increments the reference count on a Grok object.
GRK_API void GRK_CALLCONV grk_object_unref (grk_object *obj)
 Decrements the reference count on a Grok object.
GRK_API void GRK_CALLCONV grk_set_msg_handlers (grk_msg_handlers msg_handlers)
 Installs application-defined log message handlers.
GRK_API grk_image *GRK_CALLCONV grk_image_new (uint16_t numcmpts, grk_image_comp *cmptparms, GRK_COLOR_SPACE clrspc, bool alloc_data)
 Allocates a new Grok image with the specified component layout.
GRK_API grk_data_type GRK_CALLCONV grk_get_data_type (bool compress, uint8_t prec, bool is_mct, uint8_t qmfbid, bool fast_mct)
 Determine the data type used by Grok for image component data.
GRK_API grk_image_meta *GRK_CALLCONV grk_image_meta_new (void)
 Allocates an empty image metadata object.
GRK_API bool GRK_CALLCONV grk_image_meta_set_field (grk_image_meta *meta, const char *field, const uint8_t *data, size_t len)
 Set a metadata buffer on a grk_image_meta object.
GRK_API bool GRK_CALLCONV grk_image_meta_get_field (grk_image_meta *meta, const char *field, uint8_t **data, size_t *len)
 Get a metadata buffer from a grk_image_meta object.
GRK_API bool GRK_CALLCONV grk_image_meta_set_asocs (grk_image_meta *meta, const grk_asoc *asocs, uint32_t num_asocs)
 Set association boxes on a grk_image_meta object for writing.
GRK_API grk_object *GRK_CALLCONV grk_decompress_init (grk_stream_params *stream_params, grk_decompress_parameters *params)
 Creates and initializes a JPEG 2000 decompressor.
GRK_API bool GRK_CALLCONV grk_decompress_update (grk_decompress_parameters *params, grk_object *codec)
 Updates decompression parameters on an already-initialized codec.
GRK_API grk_progression_state GRK_CALLCONV grk_decompress_get_progression_state (grk_object *codec, uint16_t tile_index)
 Retrieves the current progression state for a cached tile.
GRK_API bool GRK_CALLCONV grk_decompress_set_progression_state (grk_object *codec, grk_progression_state state)
 Applies a new progression state to one or all cached tiles.
GRK_API bool GRK_CALLCONV grk_decompress_read_header (grk_object *codec, grk_header_info *header_info)
 Reads and parses the JPEG 2000 image header.
GRK_API grk_image *GRK_CALLCONV grk_decompress_get_tile_image (grk_object *codec, uint16_t tile_index, bool wait)
 Gets decompressed tile image by tile index.
GRK_API grk_image *GRK_CALLCONV grk_decompress_get_image (grk_object *codec)
 Gets the composite decompressed image.
GRK_API void GRK_CALLCONV grk_decompress_set_band_callback (grk_object *codec, grk_io_band_callback callback, void *user_data)
 Set a band-completion callback on the decompressor.
GRK_API bool GRK_CALLCONV grk_image_is_post_process_no_op (grk_image *image)
 Checks whether the image requires post-processing (palette, ICC, colour space conversion, precision override, or upsampling).
GRK_API bool GRK_CALLCONV grk_decompress (grk_object *codec, grk_plugin_tile *tile)
 Starts (or continues) decompression of the JPEG 2000 image.
GRK_API void GRK_CALLCONV grk_decompress_wait (grk_object *codec, grk_wait_swath *swath)
 Waits for an asynchronous decompression to complete.
GRK_API void GRK_CALLCONV grk_decompress_schedule_swath_copy (grk_object *codec, const grk_wait_swath *swath, grk_swath_buffer *buf)
 Schedule tile-to-swath copies for a completed swath.
GRK_API void GRK_CALLCONV grk_decompress_wait_swath_copy (grk_object *codec)
 Wait for all in-flight swath copy tasks to complete.
GRK_API void GRK_CALLCONV grk_copy_tile_to_swath (const grk_image *tile_img, const grk_swath_buffer *buf)
 Copy a single decoded tile image into a swath buffer using Highway SIMD.
GRK_API bool GRK_CALLCONV grk_decompress_tile (grk_object *codec, uint16_t tile_index)
 Decompresses a single tile by index.
GRK_API uint32_t GRK_CALLCONV grk_decompress_num_samples (grk_object *codec)
 Gets the number of samples (frames) in the codec container.
GRK_API bool GRK_CALLCONV grk_decompress_sample (grk_object *codec, uint32_t sample_index)
 Decompresses a single sample (frame) by index.
GRK_API grk_image *GRK_CALLCONV grk_decompress_get_sample_image (grk_object *codec, uint32_t sample_index)
 Gets the decompressed image for a specific sample (frame).
GRK_API grk_image *GRK_CALLCONV grk_decompress_get_sample_tile_image (grk_object *codec, uint32_t sample_index, uint16_t tile_index)
 Gets a decompressed tile image from a specific sample (frame).
GRK_API void GRK_CALLCONV grk_compress_set_default_params (grk_cparameters *parameters)
 Fills a grk_cparameters struct with safe default values.
GRK_API grk_object *GRK_CALLCONV grk_compress_init (grk_stream_params *stream_params, grk_cparameters *parameters, grk_image *image)
 Creates and initializes a JPEG 2000 compressor.
GRK_API uint64_t GRK_CALLCONV grk_compress (grk_object *codec, grk_plugin_tile *tile)
 Compresses the image into a JPEG 2000 codestream.
GRK_API uint64_t GRK_CALLCONV grk_compress_frame (grk_object *codec, grk_image *image, grk_plugin_tile *tile)
 Compresses an additional frame into a multi-frame container (MJ2).
GRK_API bool GRK_CALLCONV grk_compress_finish (grk_object *codec)
 Finalizes a multi-frame compress container (e.g.
GRK_API uint64_t GRK_CALLCONV grk_compress_get_compressed_length (grk_object *codec)
 Gets the total compressed length (bytes written to output stream/buffer).
GRK_API uint64_t GRK_CALLCONV grk_transcode (grk_stream_params *src_stream, grk_stream_params *dst_stream, grk_cparameters *parameters, grk_image *image)
 Transcodes a JPEG 2000 file by rewriting JP2 boxes while copying the codestream verbatim.
GRK_API void GRK_CALLCONV grk_dump_codec (grk_object *codec, uint32_t info_flag, FILE *output_stream)
 Dumps codec diagnostic information to a stream.
GRK_API bool GRK_CALLCONV grk_set_MCT (grk_cparameters *parameters, const float *encoding_matrix, const int32_t *dc_shift, uint32_t nb_comp)
 Installs a custom Multi-Component Transform (MCT) matrix.
GRK_API bool GRK_CALLCONV grk_plugin_load (grk_plugin_load_info info)
 Loads a hardware-accelerator plugin (.so / .dll).
GRK_API void GRK_CALLCONV grk_plugin_cleanup (void)
 Unloads the plugin and releases all plugin-owned resources.
GRK_API uint32_t GRK_CALLCONV grk_plugin_get_debug_state ()
 Returns the current debug state bitmask of the loaded plugin.
GRK_API bool GRK_CALLCONV grk_plugin_init (grk_plugin_init_info init_info)
 Initializes a loaded plugin with a device and license.
GRK_API int32_t GRK_CALLCONV grk_plugin_compress (grk_cparameters *compress_parameters, GRK_PLUGIN_COMPRESS_USER_CALLBACK callback)
 Compresses a single image using the loaded hardware plugin.
GRK_API int32_t GRK_CALLCONV grk_plugin_batch_compress (grk_plugin_compress_batch_info info)
 Compresses a directory of images in batch using the hardware plugin.
GRK_API void GRK_CALLCONV grk_plugin_wait_for_batch_complete (void)
 Blocks until all pending plugin batch jobs have completed.
GRK_API void GRK_CALLCONV grk_plugin_stop_batch_compress (void)
 Requests cancellation of a running batch compress operation.
GRK_API int32_t GRK_CALLCONV grk_plugin_decompress (grk_decompress_parameters *decompress_parameters, grk_plugin_decompress_callback callback)
 Decompresses a single JPEG 2000 image using the loaded hardware plugin.
GRK_API 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)
 Initialises a batch plugin decompress operation but does not start it.
GRK_API int32_t GRK_CALLCONV grk_plugin_batch_decompress (void)
 Starts (resumes) the queued batch decompress operation.
GRK_API void GRK_CALLCONV grk_plugin_stop_batch_decompress (void)
 Requests cancellation of a running batch decompress operation.
GRK_API void *GRK_CALLCONV grk_thread_pool (void)
 Returns an opaque handle to the core thread-pool executor.
GRK_API size_t GRK_CALLCONV grk_num_workers (void)
 Returns the number of worker threads in the core thread pool.
GRK_API uint32_t GRK_CALLCONV grk_worker_id (void)
 Returns the TaskFlow worker id of the calling thread.

Macro Definition Documentation

◆ GRK_API

◆ GRK_BIBO_EXTRA_BITS

#define GRK_BIBO_EXTRA_BITS   7

BIBO analysis - extra bits needed to avoid overflow: Lossless: without colour transform: 4 extra bits with colour transform: 5 extra bits.

Lossy: 1 extra bit

Worst-case scenario is lossless with colour transform : add 5 more bits to prec to avoid overflow. Add two more bits for good measure.

Referenced by grk::TileProcessor::decompress_synch_plugin_with_host().

◆ GRK_BROADCAST_LEVEL_10_MBITSSEC

#define GRK_BROADCAST_LEVEL_10_MBITSSEC   25600U /** Mbits/sec for level 10 */

◆ GRK_BROADCAST_LEVEL_10_MSAMPLESSEC

#define GRK_BROADCAST_LEVEL_10_MSAMPLESSEC   19200U /** MSamples/sec for level 10 */

◆ GRK_BROADCAST_LEVEL_11_MBITSSEC

#define GRK_BROADCAST_LEVEL_11_MBITSSEC   51200U /** Mbits/sec for level 11 */

◆ GRK_BROADCAST_LEVEL_11_MSAMPLESSEC

#define GRK_BROADCAST_LEVEL_11_MSAMPLESSEC   38400U /** MSamples/sec for level 11 */

◆ GRK_BROADCAST_LEVEL_1_MBITSSEC

#define GRK_BROADCAST_LEVEL_1_MBITSSEC   200U /** Mbits/sec for level 1 */

◆ GRK_BROADCAST_LEVEL_1_MSAMPLESSEC

#define GRK_BROADCAST_LEVEL_1_MSAMPLESSEC   64U /** MSamples/sec for level 1 */

◆ GRK_BROADCAST_LEVEL_2_MBITSSEC

#define GRK_BROADCAST_LEVEL_2_MBITSSEC   200U /** Mbits/sec for level 2 */

◆ GRK_BROADCAST_LEVEL_2_MSAMPLESSEC

#define GRK_BROADCAST_LEVEL_2_MSAMPLESSEC   130U /** MSamples/sec for level 2 */

◆ GRK_BROADCAST_LEVEL_3_MBITSSEC

#define GRK_BROADCAST_LEVEL_3_MBITSSEC   200U /** Mbits/sec for level 3 */

◆ GRK_BROADCAST_LEVEL_3_MSAMPLESSEC

#define GRK_BROADCAST_LEVEL_3_MSAMPLESSEC   195U /** MSamples/sec for level 3 */

◆ GRK_BROADCAST_LEVEL_4_MBITSSEC

#define GRK_BROADCAST_LEVEL_4_MBITSSEC   400U /** Mbits/sec for level 4 */

◆ GRK_BROADCAST_LEVEL_4_MSAMPLESSEC

#define GRK_BROADCAST_LEVEL_4_MSAMPLESSEC   260U /** MSamples/sec for level 4 */

◆ GRK_BROADCAST_LEVEL_5_MBITSSEC

#define GRK_BROADCAST_LEVEL_5_MBITSSEC   800U /** Mbits/sec for level 5 */

◆ GRK_BROADCAST_LEVEL_5_MSAMPLESSEC

#define GRK_BROADCAST_LEVEL_5_MSAMPLESSEC   520U /** MSamples/sec for level 5 */

◆ GRK_BROADCAST_LEVEL_6_MBITSSEC

#define GRK_BROADCAST_LEVEL_6_MBITSSEC   1600U /** Mbits/sec for level 6 */

◆ GRK_BROADCAST_LEVEL_6_MSAMPLESSEC

#define GRK_BROADCAST_LEVEL_6_MSAMPLESSEC   1200U /** MSamples/sec for level 6 */

◆ GRK_BROADCAST_LEVEL_7_MBITSSEC

#define GRK_BROADCAST_LEVEL_7_MBITSSEC   3200U /** Mbits/sec for level 7 */

◆ GRK_BROADCAST_LEVEL_7_MSAMPLESSEC

#define GRK_BROADCAST_LEVEL_7_MSAMPLESSEC   2400U /** MSamples/sec for level 7 */

◆ GRK_BROADCAST_LEVEL_8_MBITSSEC

#define GRK_BROADCAST_LEVEL_8_MBITSSEC   6400U /** Mbits/sec for level 8 */

◆ GRK_BROADCAST_LEVEL_8_MSAMPLESSEC

#define GRK_BROADCAST_LEVEL_8_MSAMPLESSEC   4800U /** MSamples/sec for level 8 */

◆ GRK_BROADCAST_LEVEL_9_MBITSSEC

#define GRK_BROADCAST_LEVEL_9_MBITSSEC   12800U /** Mbits/sec for level 9 */

◆ GRK_BROADCAST_LEVEL_9_MSAMPLESSEC

#define GRK_BROADCAST_LEVEL_9_MSAMPLESSEC   9600U /** MSamples/sec for level 9 */

◆ GRK_CALLCONV

◆ GRK_CBLKSTY_HT_MIXED

#define GRK_CBLKSTY_HT_MIXED   0xC0 /** mixed high throughput block coding */

◆ GRK_CBLKSTY_HT_ONLY

#define GRK_CBLKSTY_HT_ONLY   0x40 /** high throughput only block coding */

◆ GRK_CBLKSTY_LAZY

◆ GRK_CBLKSTY_PTERM

#define GRK_CBLKSTY_PTERM   0x10 /** Predictable termination */

◆ GRK_CBLKSTY_RESET

#define GRK_CBLKSTY_RESET   0x02 /** Reset context probabilities on coding pass boundaries */

◆ GRK_CBLKSTY_SEGSYM

#define GRK_CBLKSTY_SEGSYM   0x20 /** Segmentation symbols are used */

◆ GRK_CBLKSTY_TERMALL

#define GRK_CBLKSTY_TERMALL   0x04 /** Termination on each coding pass */

◆ GRK_CBLKSTY_VSC

◆ GRK_CINEMA_24_COMP

#define GRK_CINEMA_24_COMP   1041666 /** Maximum size per color component @ 24fps */

◆ GRK_CINEMA_24_CS

#define GRK_CINEMA_24_CS   1302083 /** Maximum code stream length @ 24fps */

◆ GRK_CINEMA_48_COMP

#define GRK_CINEMA_48_COMP   520833 /** Maximum size per color component @ 48fps */

◆ GRK_CINEMA_48_CS

#define GRK_CINEMA_48_CS   651041 /** Maximum code stream length @ 48fps */

◆ GRK_CINEMA_4K_DEFAULT_NUM_RESOLUTIONS

#define GRK_CINEMA_4K_DEFAULT_NUM_RESOLUTIONS   7 /* Default number of resolutions for 4K cinema */

◆ GRK_CINEMA_DCI_MAX_BANDWIDTH

#define GRK_CINEMA_DCI_MAX_BANDWIDTH   250000000

JPEG 2000 cinema profile code stream and component size limits.

◆ GRK_CUSTOM_CIELAB_SPACE

#define GRK_CUSTOM_CIELAB_SPACE   0x0

◆ GRK_DECODE_ALL

◆ GRK_DECODE_HEADER

#define GRK_DECODE_HEADER   (1 << 0)

◆ GRK_DECODE_POST_T1

#define GRK_DECODE_POST_T1   (1 << 3)

◆ GRK_DECODE_T1

#define GRK_DECODE_T1   (1 << 2)

◆ GRK_DECODE_T2

#define GRK_DECODE_T2   (1 << 1)

◆ GRK_DECOMPRESS_COMPRESSION_LEVEL_DEFAULT

#define GRK_DECOMPRESS_COMPRESSION_LEVEL_DEFAULT   (UINT_MAX)

default compression level for decompression output file formats that support compression

◆ GRK_DEFAULT_CIELAB_SPACE

#define GRK_DEFAULT_CIELAB_SPACE   0x44454600 /* 'DEF' */

◆ GRK_EXTENSION_MCT

#define GRK_EXTENSION_MCT   0x0100 /** Custom MCT support */

◆ GRK_EXTENSION_NONE

#define GRK_EXTENSION_NONE   0x0000 /** No Part-2 extension */

JPEG 2000 Part-2 extensions.

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

◆ GRK_GET_IMF_OR_BROADCAST_PROFILE

◆ GRK_GET_IMF_SUBLEVEL

#define GRK_GET_IMF_SUBLEVEL ( v)
Value:
(((v) >> 4) & 0xf)

Referenced by grk::Profile::isImfCompliant().

◆ GRK_GET_LEVEL

#define GRK_GET_LEVEL ( v)

◆ GRK_IMF_MAINLEVEL_10_MSAMPLESSEC

#define GRK_IMF_MAINLEVEL_10_MSAMPLESSEC   19200U /** MSamples/sec for main level 10 */

◆ GRK_IMF_MAINLEVEL_11_MSAMPLESSEC

#define GRK_IMF_MAINLEVEL_11_MSAMPLESSEC   38400U /** MSamples/sec for main level 11 */

◆ GRK_IMF_MAINLEVEL_1_MSAMPLESSEC

#define GRK_IMF_MAINLEVEL_1_MSAMPLESSEC   65U /** MSamples/sec for main level 1 */

◆ GRK_IMF_MAINLEVEL_2_MSAMPLESSEC

#define GRK_IMF_MAINLEVEL_2_MSAMPLESSEC   130U /** MSamples/sec for main level 2 */

◆ GRK_IMF_MAINLEVEL_3_MSAMPLESSEC

#define GRK_IMF_MAINLEVEL_3_MSAMPLESSEC   195U /** MSamples/sec for main level 3 */

◆ GRK_IMF_MAINLEVEL_4_MSAMPLESSEC

#define GRK_IMF_MAINLEVEL_4_MSAMPLESSEC   260U /** MSamples/sec for main level 4 */

◆ GRK_IMF_MAINLEVEL_5_MSAMPLESSEC

#define GRK_IMF_MAINLEVEL_5_MSAMPLESSEC   520U /** MSamples/sec for main level 5 */

◆ GRK_IMF_MAINLEVEL_6_MSAMPLESSEC

#define GRK_IMF_MAINLEVEL_6_MSAMPLESSEC   1200U /** MSamples/sec for main level 6 */

◆ GRK_IMF_MAINLEVEL_7_MSAMPLESSEC

#define GRK_IMF_MAINLEVEL_7_MSAMPLESSEC   2400U /** MSamples/sec for main level 7 */

◆ GRK_IMF_MAINLEVEL_8_MSAMPLESSEC

#define GRK_IMF_MAINLEVEL_8_MSAMPLESSEC   4800U /** MSamples/sec for main level 8 */

◆ GRK_IMF_MAINLEVEL_9_MSAMPLESSEC

#define GRK_IMF_MAINLEVEL_9_MSAMPLESSEC   9600U /** MSamples/sec for main level 9 */

◆ GRK_IMF_SUBLEVEL_1_MBITSSEC

#define GRK_IMF_SUBLEVEL_1_MBITSSEC   200U /** Mbits/s for IMF sub level 1 */

Maximum compressed bit rate (Mbits/s) per IMF sub level.

◆ GRK_IMF_SUBLEVEL_2_MBITSSEC

#define GRK_IMF_SUBLEVEL_2_MBITSSEC   400U /** Mbits/s for IMF sub level 2 */

◆ GRK_IMF_SUBLEVEL_3_MBITSSEC

#define GRK_IMF_SUBLEVEL_3_MBITSSEC   800U /** Mbits/s for IMF sub level 3 */

◆ GRK_IMF_SUBLEVEL_4_MBITSSEC

#define GRK_IMF_SUBLEVEL_4_MBITSSEC   1600U /** Mbits/s for IMF sub level 4 */

◆ GRK_IMF_SUBLEVEL_5_MBITSSEC

#define GRK_IMF_SUBLEVEL_5_MBITSSEC   3200U /** Mbits/s for IMF sub level 5 */

◆ GRK_IMF_SUBLEVEL_6_MBITSSEC

#define GRK_IMF_SUBLEVEL_6_MBITSSEC   6400U /** Mbits/s for IMF sub level 6 */

◆ GRK_IMF_SUBLEVEL_7_MBITSSEC

#define GRK_IMF_SUBLEVEL_7_MBITSSEC   12800U /** Mbits/s for IMF sub level 7 */

◆ GRK_IMF_SUBLEVEL_8_MBITSSEC

#define GRK_IMF_SUBLEVEL_8_MBITSSEC   25600U /** Mbits/s for IMF sub level 8 */

◆ GRK_IMF_SUBLEVEL_9_MBITSSEC

#define GRK_IMF_SUBLEVEL_9_MBITSSEC   51200U /** Mbits/s for IMF sub level 9 */

◆ GRK_IMF_SUBLEVEL_MAX

#define GRK_IMF_SUBLEVEL_MAX   9U /** Maximum IMF sublevel */

◆ GRK_IMG_INFO

#define GRK_IMG_INFO   1 /* Basic image information provided to the user */

◆ GRK_IS_BROADCAST

#define GRK_IS_BROADCAST ( v)
Value:
(((v) >= GRK_PROFILE_BC_SINGLE) && ((v) <= (GRK_PROFILE_BC_MULTI_R | 0x000b)) && \
(((v) & 0xf) <= 0xb))
#define GRK_PROFILE_BC_MULTI_R
Definition grok.h:1925
#define GRK_PROFILE_BC_SINGLE
Definition grok.h:1923

Referenced by grk::CodeStreamCompress::init(), and grk::SIZMarker::read().

◆ GRK_IS_CINEMA

#define GRK_IS_CINEMA ( v)

◆ GRK_IS_IMF

#define GRK_IS_IMF ( v)
Value:
(((v) >= GRK_PROFILE_IMF_2K) && ((v) <= (GRK_PROFILE_IMF_8K_R | 0x009b)) && \
(((v) & 0xf) <= 0xb) && (((v) & 0xf0) <= 0x90))
#define GRK_PROFILE_IMF_8K_R
Definition grok.h:1935
#define GRK_PROFILE_IMF_2K
Definition grok.h:1928

Referenced by grk::PacketIter::enable_tile_part_generation(), grk::CodeStreamCompress::init(), and grk::SIZMarker::read().

◆ GRK_IS_PART2

#define GRK_IS_PART2 ( v)
Value:
#define GRK_PROFILE_PART2
Definition grok.h:1938

Referenced by grk_set_MCT(), and grk::CodeStreamCompress::init().

◆ GRK_IS_STORAGE

#define GRK_IS_STORAGE ( v)
Value:
#define GRK_PROFILE_CINEMA_LTS
Definition grok.h:1921

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

◆ GRK_JPH_RSIZ_FLAG

#define GRK_JPH_RSIZ_FLAG   0x4000 /**for JPH, bit 14 of RSIZ must be set to 1 */

◆ GRK_LEVEL_MAX

#define GRK_LEVEL_MAX   11U /** Maximum (main) level */

◆ GRK_MAX_COMMENT_LENGTH

#define GRK_MAX_COMMENT_LENGTH   (UINT16_MAX - 2)

maximum Grok supported comment length

Referenced by grk::CodeStreamCompress::init(), and grk::CodeStreamCompress::write_com().

◆ GRK_MAX_CUSTOM_HEADERS

#define GRK_MAX_CUSTOM_HEADERS   16

◆ GRK_MAX_DECOMP_LVLS

#define GRK_MAX_DECOMP_LVLS
Value:
32 /* Maximum number of decomposition levels allowed by standard \
*/

Referenced by grk::TileCodingParams::readSPCodSPCoc().

◆ GRK_MAX_LAYERS

#define GRK_MAX_LAYERS   256 /* Grok maximum number of quality layers */

◆ GRK_MAX_PASSES

#define GRK_MAX_PASSES   (3 * (GRK_MAX_SUPPORTED_IMAGE_PRECISION + GRK_BIBO_EXTRA_BITS) - 2)

Grok maximum number of passes.

Referenced by grk::gpup_tile_to_grk(), and grk::grk_tile_to_gpup().

◆ GRK_MAX_SUPPORTED_IMAGE_PRECISION

◆ GRK_MAXBANDS

#define GRK_MAXBANDS   (3 * GRK_MAXRLVLS - 2) /* Maximum number of sub-bands allowed by standard */

◆ GRK_MAXRLVLS

◆ GRK_MH_IND

#define GRK_MH_IND   16 /** Codestream index based only on the main header */

◆ GRK_MH_INFO

#define GRK_MH_INFO   2 /* Codestream information based only on the main header */

◆ GRK_NUM_ASOC_BOXES_SUPPORTED

#define GRK_NUM_ASOC_BOXES_SUPPORTED   256

maximum Grok supported number of asoc boxes

Referenced by grk::FileFormatJP2Family::serializeAsoc().

◆ GRK_NUM_COMMENTS_SUPPORTED

#define GRK_NUM_COMMENTS_SUPPORTED   256

maximum Grok supported number of comments

Referenced by grk::CodingParams::readCom().

◆ GRK_NUM_XML_BOXES_SUPPORTED

#define GRK_NUM_XML_BOXES_SUPPORTED   64

maximum Grok supported number of XML boxes

Referenced by grk::FileFormatJP2Family::readHeader().

◆ GRK_PATH_LEN

#define GRK_PATH_LEN   4096 /* Grok maximum supported filename size */

◆ GRK_PLUGIN_DECODE_CLEAN

#define GRK_PLUGIN_DECODE_CLEAN   (1 << 4)

◆ GRK_PLUGIN_STATE_DEBUG

◆ GRK_PLUGIN_STATE_DWT_QUANTIZATION

#define GRK_PLUGIN_STATE_DWT_QUANTIZATION   0x4

◆ GRK_PLUGIN_STATE_MCT_ONLY

#define GRK_PLUGIN_STATE_MCT_ONLY   0x8

◆ GRK_PLUGIN_STATE_NO_DEBUG

#define GRK_PLUGIN_STATE_NO_DEBUG   0x0

No debug is done on plugin.

Production setting.

Referenced by grk_plugin_get_debug_state().

◆ GRK_PLUGIN_STATE_PRE_TR1

◆ GRK_PROFILE_0

#define GRK_PROFILE_0   0x0001 /** Profile 0 as described in 15444-1,Table A.45 */

◆ GRK_PROFILE_1

#define GRK_PROFILE_1   0x0002 /** Profile 1 as described in 15444-1,Table A.45 */

◆ GRK_PROFILE_BC_MASK

#define GRK_PROFILE_BC_MASK   0x030F /** Mask for broadcast profile including main level */

◆ GRK_PROFILE_BC_MULTI

#define GRK_PROFILE_BC_MULTI   0x0200 /** Multi Tile Broadcast profile defined in 15444-1 AMD3 */

◆ GRK_PROFILE_BC_MULTI_R

#define GRK_PROFILE_BC_MULTI_R   0x0300 /** Multi Tile Reversible Broadcast profile defined in 15444-1 AMD3 */

◆ GRK_PROFILE_BC_SINGLE

#define GRK_PROFILE_BC_SINGLE   0x0100 /** Single Tile Broadcast profile defined in 15444-1 AMD3 */

◆ GRK_PROFILE_CINEMA_2K

#define GRK_PROFILE_CINEMA_2K   0x0003 /** 2K cinema profile defined in 15444-1 AMD1 */

◆ GRK_PROFILE_CINEMA_4K

#define GRK_PROFILE_CINEMA_4K   0x0004 /** 4K cinema profile defined in 15444-1 AMD1 */

◆ GRK_PROFILE_CINEMA_LTS

#define GRK_PROFILE_CINEMA_LTS   0x0007 /** Long term storage cinema profile defined in 15444-1 AMD2 */

Referenced by grk::SIZMarker::read().

◆ GRK_PROFILE_CINEMA_S2K

#define GRK_PROFILE_CINEMA_S2K   0x0005 /** Scalable 2K cinema profile defined in 15444-1 AMD2 */

◆ GRK_PROFILE_CINEMA_S4K

#define GRK_PROFILE_CINEMA_S4K   0x0006 /** Scalable 4K cinema profile defined in 15444-1 AMD2 */

◆ GRK_PROFILE_IMF_2K

#define GRK_PROFILE_IMF_2K   0x0400 /** 2K Single Tile Lossy IMF profile defined in 15444-1 AMD8 */

◆ GRK_PROFILE_IMF_2K_R

#define GRK_PROFILE_IMF_2K_R   0x0700 /** 2K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD8 */

◆ GRK_PROFILE_IMF_4K

#define GRK_PROFILE_IMF_4K   0x0500 /** 4K Single Tile Lossy IMF profile defined in 15444-1 AMD8 */

◆ GRK_PROFILE_IMF_4K_R

#define GRK_PROFILE_IMF_4K_R   0x0800 /** 4K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD8 */

◆ GRK_PROFILE_IMF_8K

#define GRK_PROFILE_IMF_8K   0x0600 /** 8K Single Tile Lossy IMF profile defined in 15444-1 AMD8 */

◆ GRK_PROFILE_IMF_8K_R

#define GRK_PROFILE_IMF_8K_R   0x0900 /** 8K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD8 */

◆ GRK_PROFILE_MASK

#define GRK_PROFILE_MASK   0x0FFF /** Mask for profile bits */

Referenced by grk::SIZMarker::read().

◆ GRK_PROFILE_NONE

#define GRK_PROFILE_NONE   0x0000 /** no profile, conform to 15444-1 */

◆ GRK_PROFILE_PART2

#define GRK_PROFILE_PART2   0x8000 /** At least 1 extension defined in 15444-2 (Part-2) */

◆ GRK_PROFILE_PART2_EXTENSIONS_MASK

#define GRK_PROFILE_PART2_EXTENSIONS_MASK   0x3FFF /* Mask for Part-2 extension bits */

◆ GRK_RANDOM_ACCESS_PLM

#define GRK_RANDOM_ACCESS_PLM   4 /* Disable PLM marker if present */

◆ GRK_RANDOM_ACCESS_PLT

#define GRK_RANDOM_ACCESS_PLT   1 /* Disable PLT marker if present */

Decompression: disable random access markers.

Referenced by grk::TileProcessor::readPLT().

◆ GRK_RANDOM_ACCESS_TLM

#define GRK_RANDOM_ACCESS_TLM   2 /* Disable TLM marker if present */

◆ GRK_TCH_INFO

#define GRK_TCH_INFO   8 /** Tile/Component information of all tiles */

◆ GRK_TH_IND

#define GRK_TH_IND   32 /** Tile index based on the current tile */

◆ GRK_TH_INFO

#define GRK_TH_INFO   4 /* Tile information based on the current tile header */

◆ GRK_TILE_CACHE_ALL

◆ GRK_TILE_CACHE_IMAGE

#define GRK_TILE_CACHE_IMAGE   1 /* cache final tile image */

◆ GRK_TILE_CACHE_LRU

#define GRK_TILE_CACHE_LRU   4 /* LRU: release decompressed data, keep processor */

◆ GRK_TILE_CACHE_NONE

#define GRK_TILE_CACHE_NONE   0 /* no tile caching */

Typedef Documentation

◆ grk_asoc

typedef struct _grk_asoc grk_asoc

◆ GRK_CHANNEL_ASSOC

Channel association.

◆ grk_channel_definition

typedef struct _grk_channel_definition grk_channel_definition

◆ grk_channel_description

typedef struct _grk_channel_description grk_channel_description

◆ GRK_CHANNEL_TYPE

◆ GRK_CODEC_FORMAT

Grok Supported JPEG 2000 formats.

◆ grk_color

typedef struct _grk_color grk_color

◆ GRK_COLOR_SPACE

Grok supported color spaces.

◆ grk_component_mapping_comp

typedef struct _grk_component_mapping_comp grk_component_mapping_comp

◆ grk_cparameters

typedef struct _grk_cparameters grk_cparameters

◆ grk_data_type

Grok Data types Used to specify the actual data type of Grok image components.

◆ grk_decompress_callback

typedef void(* grk_decompress_callback) (void *codec, uint16_t tile_index, grk_image *tile_image, uint8_t reduction, void *user_data)

Callback called when decompression of a tile has completed.

◆ grk_decompress_core_params

typedef struct _grk_decompress_core_params grk_decompress_core_params

◆ grk_decompress_parameters

typedef struct _grk_decompress_params grk_decompress_parameters

◆ GRK_ENUM_COLOUR_SPACE

JPEG 2000 enumerated color spaces.

◆ grk_header_info

typedef struct _grk_header_info grk_header_info

◆ grk_image

typedef struct _grk_image grk_image

◆ grk_image_comp

typedef struct _grk_image_comp grk_image_comp

◆ grk_image_meta

◆ grk_io_band_callback

typedef bool(* grk_io_band_callback) (uint32_t yBegin, uint32_t yEnd, grk_image *image, void *user_data)

Callback invoked when a horizontal band of the decompressed image is ready for writing.

Parameters
yBeginfirst row (inclusive) of the completed band
yEndone-past-last row (exclusive) of the completed band
imagepointer to the image containing the completed band data
user_datauser data

◆ grk_io_buf

typedef struct _grk_io_buf grk_io_buf

◆ grk_io_callback

typedef bool(* grk_io_callback) (uint32_t worker_id, grk_io_buf buffer, void *io_user_data)

Grok IO callback.

Parameters
worker_idworker id
bufferio buffer (see grk_io_buf)
io_user_datauser data

◆ grk_io_init

typedef struct _grk_io_init grk_io_init

◆ grk_io_pixels_callback

typedef bool(* grk_io_pixels_callback) (uint32_t worker_id, grk_io_buf buffer, void *user_data)

Grok IO pixels callback.

Parameters
worker_idworker id
bufferGrok io buffer (see grk_io_buf)
user_datauser data

◆ grk_io_register_reclaim_callback

typedef void(* grk_io_register_reclaim_callback) (grk_io_init io_init, grk_io_callback reclaim_callback, void *io_user_data, void *reclaim_user_data)

Grok IO register reclaim callback.

Parameters
io_initio initialization (see grk_io_init)
reclaim_callback(see grk_io_callback)
io_user_dataio user data
reclaim_user_datareclaim user data

◆ grk_msg_callback

typedef void(* grk_msg_callback) (const char *msg, void *client_data)

Logging callback.

Parameters
msgmessage
client_dataclient data passed to callback

◆ grk_msg_handlers

typedef struct _grk_msg_handlers grk_msg_handlers

◆ grk_object

typedef struct _grk_object grk_object

◆ grk_palette_data

typedef struct _grk_palette_data grk_palette_data

◆ grk_plugin_band

typedef struct _grk_plugin_band grk_plugin_band

◆ grk_plugin_code_block

typedef struct _grk_plugin_code_block grk_plugin_code_block

◆ grk_plugin_compress_batch_info

typedef struct grk_plugin_compress_batch_info grk_plugin_compress_batch_info

Plugin batch compress info.

◆ GRK_PLUGIN_COMPRESS_USER_CALLBACK

typedef uint64_t(* GRK_PLUGIN_COMPRESS_USER_CALLBACK) (grk_plugin_compress_user_callback_info *info)

Plugin compress user callback.

Parameters
infocallback info (see grk_plugin_compress_user_callback_info)

◆ grk_plugin_compress_user_callback_info

typedef struct grk_plugin_compress_user_callback_info grk_plugin_compress_user_callback_info

◆ grk_plugin_decompress_callback

typedef int32_t(* grk_plugin_decompress_callback) (grk_plugin_decompress_callback_info *info)

Plugin decompress callback.

Parameters
infocallback info (see grk_plugin_decompress_callback_info)
Returns
0 if successful, otherwise return error code

◆ grk_plugin_decompress_callback_info

typedef struct _grk_plugin_decompress_callback_info grk_plugin_decompress_callback_info

◆ grk_plugin_init_info

◆ grk_plugin_load_info

typedef struct _grk_plugin_load_info grk_plugin_load_info

◆ grk_plugin_pass

typedef struct _grk_plugin_pass grk_plugin_pass

◆ grk_plugin_precinct

◆ grk_plugin_resolution

typedef struct _grk_plugin_resolution grk_plugin_resolution

◆ grk_plugin_tile

typedef struct _grk_plugin_tile grk_plugin_tile

◆ grk_plugin_tile_component

typedef struct grk_plugin_tile_component grk_plugin_tile_component

◆ grk_precision

typedef struct _grk_precision grk_precision

◆ grk_precision_mode

Precision mode.

◆ GRK_PROG_ORDER

Environment variables.

Set this environment variable to enable various levels of debug logging levels: 1 - 5 level 1 provides only error logging level 3 provides error, warning and information logging

GRK_DEBUG

Progression orders

◆ grk_progression

typedef struct _grk_progression grk_progression

◆ grk_progression_state

typedef struct _grk_progression_state grk_progression_state

◆ GRK_RATE_CONTROL_ALGORITHM

Rate control algorithms.

Parameters
GRK_RATE_CONTROL_BISECTbisect with all truncation points
GRK_RATE_CONTROL_PCRD_OPTPCRD: bisect with only feasible truncation points

◆ grk_raw_comp_cparameters

typedef struct _grk_raw_comp_cparameters grk_raw_comp_cparameters

◆ grk_raw_cparameters

typedef struct _grk_raw_cparameters grk_raw_cparameters

◆ grk_stream_free_user_data_fn

typedef void(* grk_stream_free_user_data_fn) (void *user_data)

Free user data callback.

Parameters
user_datauser data

◆ grk_stream_params

typedef struct _grk_stream_params grk_stream_params

◆ grk_stream_read_fn

typedef size_t(* grk_stream_read_fn) (uint8_t *buffer, size_t numBytes, void *user_data)

Read stream callback.

Parameters
bufferbuffer to write stream to
numBytesnumber of bytes to write to buffer
user_datauser data

◆ grk_stream_seek_fn

typedef bool(* grk_stream_seek_fn) (uint64_t offset, void *user_data)

Seek (absolute) callback.

Parameters
offsetabsolute stream offset
user_datauser data

◆ grk_stream_write_fn

typedef size_t(* grk_stream_write_fn) (const uint8_t *buffer, size_t numBytes, void *user_data)

Write stream callback.

Parameters
bufferbuffer to read stream from
numBytesnumber of bytes to read from buffer
user_datauser data

◆ GRK_SUPPORTED_FILE_FMT

All Grok supported file formats.

◆ grk_swath_buffer

typedef struct grk_swath_buffer grk_swath_buffer

◆ grk_wait_swath

typedef struct grk_wait_swath grk_wait_swath

◆ GROK_INIT_DECOMPRESSORS

typedef int(* GROK_INIT_DECOMPRESSORS) (grk_header_info *header_info, grk_image *image)

Plugin init decompressors.

Enumeration Type Documentation

◆ _GRK_CHANNEL_ASSOC

Channel association.

Enumerator
GRK_CHANNEL_ASSOC_WHOLE_IMAGE 
GRK_CHANNEL_ASSOC_COLOUR_1 
GRK_CHANNEL_ASSOC_COLOUR_2 
GRK_CHANNEL_ASSOC_COLOUR_3 
GRK_CHANNEL_ASSOC_UNASSOCIATED 

◆ _GRK_CHANNEL_TYPE

Enumerator
GRK_CHANNEL_TYPE_COLOUR 
GRK_CHANNEL_TYPE_OPACITY 
GRK_CHANNEL_TYPE_PREMULTIPLIED_OPACITY 
GRK_CHANNEL_TYPE_UNSPECIFIED 

◆ _GRK_CODEC_FORMAT

Grok Supported JPEG 2000 formats.

Enumerator
GRK_CODEC_UNK 
GRK_CODEC_J2K 

unknown format

GRK_CODEC_JP2 

JPEG 2000 code-stream.

GRK_CODEC_MJ2 

JPEG 2000 JP2 file format.

Motion JPEG 2000

◆ _GRK_COLOR_SPACE

Grok supported color spaces.

Enumerator
GRK_CLRSPC_UNKNOWN 
GRK_CLRSPC_SRGB 

unknown

GRK_CLRSPC_GRAY 

sRGB

GRK_CLRSPC_SYCC 

grayscale

GRK_CLRSPC_EYCC 

standard YCC (YUV)

GRK_CLRSPC_CMYK 

extended YCC

GRK_CLRSPC_DEFAULT_CIE 

CMYK.

GRK_CLRSPC_CUSTOM_CIE 

default CIE LAB

GRK_CLRSPC_ICC 

custom CIE LAB

◆ _grk_data_type

Grok Data types Used to specify the actual data type of Grok image components.

Enumerator
GRK_INT_32 
GRK_INT_16 
GRK_INT_8 
GRK_FLOAT 
GRK_DOUBLE 

◆ _GRK_ENUM_COLOUR_SPACE

JPEG 2000 enumerated color spaces.

Enumerator
GRK_ENUM_CLRSPC_UNKNOWN 
GRK_ENUM_CLRSPC_BILEVEL1 
GRK_ENUM_CLRSPC_YCBCR1 
GRK_ENUM_CLRSPC_YCBCR2 
GRK_ENUM_CLRSPC_YCBCR3 
GRK_ENUM_CLRSPC_PHOTO_YCC 
GRK_ENUM_CLRSPC_CMY 
GRK_ENUM_CLRSPC_CMYK 
GRK_ENUM_CLRSPC_YCCK 
GRK_ENUM_CLRSPC_CIE 
GRK_ENUM_CLRSPC_BILEVEL2 
GRK_ENUM_CLRSPC_SRGB 
GRK_ENUM_CLRSPC_GRAY 
GRK_ENUM_CLRSPC_SYCC 
GRK_ENUM_CLRSPC_CIEJAB 
GRK_ENUM_CLRSPC_ESRGB 
GRK_ENUM_CLRSPC_ROMMRGB 
GRK_ENUM_CLRSPC_YPBPR60 
GRK_ENUM_CLRSPC_YPBPR50 
GRK_ENUM_CLRSPC_EYCC 

◆ _grk_precision_mode

Precision mode.

Enumerator
GRK_PREC_MODE_CLIP 
GRK_PREC_MODE_SCALE 

◆ _GRK_PROG_ORDER

Environment variables.

Set this environment variable to enable various levels of debug logging levels: 1 - 5 level 1 provides only error logging level 3 provides error, warning and information logging

GRK_DEBUG

Progression orders

Enumerator
GRK_PROG_UNKNOWN 
GRK_LRCP 

unknown progression order

GRK_RLCP 

layer-resolution-component-precinct order

GRK_RPCL 

resolution-layer-component-precinct order

GRK_PCRL 

resolution-precinct-component-layer order

GRK_CPRL 

precinct-component-resolution-layer order

GRK_NUM_PROGRESSION_ORDERS 

component-precinct-resolution-layer order

◆ _GRK_RATE_CONTROL_ALGORITHM

Rate control algorithms.

Parameters
GRK_RATE_CONTROL_BISECTbisect with all truncation points
GRK_RATE_CONTROL_PCRD_OPTPCRD: bisect with only feasible truncation points
Enumerator
GRK_RATE_CONTROL_BISECT 
GRK_RATE_CONTROL_PCRD_OPT 

◆ _GRK_SUPPORTED_FILE_FMT

All Grok supported file formats.

Enumerator
GRK_FMT_UNK 
GRK_FMT_J2K 
GRK_FMT_JP2 
GRK_FMT_PXM 
GRK_FMT_PGX 
GRK_FMT_PAM 
GRK_FMT_BMP 
GRK_FMT_TIF 
GRK_FMT_RAW 
GRK_FMT_PNG 
GRK_FMT_RAWL 
GRK_FMT_JPG 
GRK_FMT_MJ2 

Function Documentation

◆ grk_compress()

GRK_API uint64_t GRK_CALLCONV grk_compress ( grk_object * codec,
grk_plugin_tile * tile )

Compresses the image into a JPEG 2000 codestream.

Performs the full encode pipeline (MCT, DWT, T1, rate control, T2) and writes the result to the output stream supplied to grk_compress_init().

The tile parameter is only used when a hardware-accelerator plugin performs some encoding stages; pass NULL for CPU-only encoding.

Parameters
codeccompression codec (see grk_object)
tileplugin tile data, or NULL for CPU-only encoding (see grk_plugin_tile)
Returns
number of bytes written to the output stream, or 0 on failure

References grk::Codec::getImpl(), and grk_initialize().

◆ grk_compress_finish()

GRK_API bool GRK_CALLCONV grk_compress_finish ( grk_object * codec)

Finalizes a multi-frame compress container (e.g.

writes MJ2 moov box). For single-image formats this is a no-op.

Parameters
codeccompression codec (see grk_object)
Returns
true if successful, otherwise false

References grk::Codec::getImpl().

◆ grk_compress_frame()

GRK_API uint64_t GRK_CALLCONV grk_compress_frame ( grk_object * codec,
grk_image * image,
grk_plugin_tile * tile )

Compresses an additional frame into a multi-frame container (MJ2).

For single-image formats (JP2, J2K) this returns 0 (unsupported).

Parameters
codeccompression codec (see grk_object)
imageInput image for this frame (see grk_image)
tileplugin tile (see grk_plugin_tile)
Returns
number of bytes written if successful, 0 otherwise

References grk::Codec::getImpl().

◆ grk_compress_get_compressed_length()

GRK_API uint64_t GRK_CALLCONV grk_compress_get_compressed_length ( grk_object * codec)

Gets the total compressed length (bytes written to output stream/buffer).

Parameters
codeccompression codec (see grk_object)
Returns
compressed length in bytes, or 0 on failure

References grk::Codec::getImpl().

◆ grk_compress_init()

GRK_API grk_object *GRK_CALLCONV grk_compress_init ( grk_stream_params * stream_params,
grk_cparameters * parameters,
grk_image * image )

Creates and initializes a JPEG 2000 compressor.

Allocates and prepares all compression state for the provided image. The output destination (file, buffer, or callbacks) is described by stream_params. Encoding parameters (tile size, DWT levels, quality layers, etc.) are taken from parameters — call grk_compress_set_default_params() first to populate defaults.

The image must remain valid until grk_compress() completes. The returned codec object must be released with grk_object_unref().

Parameters
stream_paramsoutput stream description (see grk_stream_params)
parameterscompression settings (see grk_cparameters)
imagesource image to compress (see grk_image)
Returns
pointer to an opaque grk_object on success, NULL on failure (invalid parameters, unsupported image, OOM)

References grk::StreamGenerator::create(), grk::Codec::getImpl(), GRK_CODEC_J2K, GRK_CODEC_JP2, GRK_CODEC_MJ2, grk_compress_create(), GRK_FMT_J2K, GRK_FMT_JP2, GRK_FMT_MJ2, grk_object_unref(), grk::grklog, and grkStartCompress().

◆ grk_compress_set_default_params()

GRK_API void GRK_CALLCONV grk_compress_set_default_params ( grk_cparameters * parameters)

Fills a grk_cparameters struct with safe default values.

Defaults applied:

  • No rate constraints (lossless)
  • Tile size: entire image (single tile)
  • Codeblock size: 64×64
  • Precinct size: 2^15×2^15 (effectively no sub-precincts)
  • Number of DWT resolutions: 6
  • 1 quality layer
  • No SOP / EPH markers
  • No ROI upshift
  • No mode switches (no LAZY, RESET, etc.)
  • Progression order: LRCP
  • Reversible 5-3 DWT
  • Multi-component transform enabled (when 3+ components present)
  • Image origin (0,0); tile origin (0,0); no POC
  • Sub-sampling: dx=1, dy=1
Parameters
parameterscompression parameter block to initialise (see grk_cparameters); must not be NULL

References grk::GRK_COMP_PARAM_DEFAULT_CBLOCKH, grk::GRK_COMP_PARAM_DEFAULT_CBLOCKW, grk::GRK_DEFAULT_NUMRESOLUTION, grk::GRK_DEFAULT_PROG_ORDER, GRK_FMT_UNK, GRK_PROFILE_NONE, and GRK_PROG_UNKNOWN.

◆ grk_copy_tile_to_swath()

GRK_API void GRK_CALLCONV grk_copy_tile_to_swath ( const grk_image * tile_img,
const grk_swath_buffer * buf )

Copy a single decoded tile image into a swath buffer using Highway SIMD.

A low-level, synchronous alternative to grk_decompress_schedule_swath_copy() for callers that manage their own threading. Copies the source component data from tile_img into buf, clipping to buf's x/y window, applying band_map re-ordering, alpha promotion, and type conversion (int32 → prec/sgnd).

Thread-safe: multiple tiles may be copied into the same buf concurrently provided they write to non-overlapping output regions.

Parameters
tile_imgtile image returned by grk_decompress_get_tile_image()
bufoutput swath buffer (must be pre-allocated and fully populated)

References grk::hwy_copy_tile_to_swath().

◆ grk_decompress()

GRK_API bool GRK_CALLCONV grk_decompress ( grk_object * codec,
grk_plugin_tile * tile )

Starts (or continues) decompression of the JPEG 2000 image.

For synchronous decoding (asynchronous = false): blocks until all requested tiles are decompressed. After return, component data is available via grk_decompress_get_image() or grk_decompress_get_tile_image().

For asynchronous decoding (asynchronous = true): returns immediately after scheduling decompression tasks on the Taskflow executor. Use grk_decompress_wait() to synchronize on individual swath regions, and grk_decompress_schedule_swath_copy() + grk_decompress_wait_swath_copy() to copy decoded data into an output buffer.

The tile parameter is only used when integrating a hardware- accelerator plugin; pass NULL for CPU-only decoding.

Parameters
codecdecompression codec (see grk_object)
tileplugin tile data, or NULL for CPU-only decoding (see grk_plugin_tile)
Returns
true if successful (sync) or if scheduling succeeded (async)

References grk::Codec::getImpl(), and grk_initialize().

Referenced by grk::FileFormatJP2Compress::transcodeCodestream().

◆ grk_decompress_get_image()

GRK_API grk_image *GRK_CALLCONV grk_decompress_get_image ( grk_object * codec)

Gets the composite decompressed image.

Returns the composited output image (all tiles merged). Only valid after full decompression completes (grk_decompress_wait with null swath). Requires skip_allocate_composite=false in decompress parameters for data to be present. For per-tile access, prefer grk_decompress_get_tile_image() instead.

Parameters
codecdecompression codec (see grk_object)
Returns
pointer to grk_image

References grk::Codec::getImpl().

◆ grk_decompress_get_progression_state()

GRK_API grk_progression_state GRK_CALLCONV grk_decompress_get_progression_state ( grk_object * codec,
uint16_t tile_index )

Retrieves the current progression state for a cached tile.

A progression state describes how many quality layers have been decoded for each resolution level in a given tile. This is used to implement incremental / partial-quality decompression: decode a tile at reduced quality, inspect it, then decode more layers on demand.

Returns a zero-initialised struct if the tile has not been decompressed yet or is not in the tile cache.

Parameters
codecdecompression codec (see grk_object)
tile_indexzero-based tile index (row-major within the tile grid)
Returns
current grk_progression_state for the tile; all-zeros if the tile has not been decoded

References grk::Codec::getImpl().

◆ grk_decompress_get_sample_image()

GRK_API grk_image *GRK_CALLCONV grk_decompress_get_sample_image ( grk_object * codec,
uint32_t sample_index )

Gets the decompressed image for a specific sample (frame).

Parameters
codecdecompression codec (see grk_object)
sample_indexsample index (0-based)
Returns
pointer to grk_image, or NULL if sample not decompressed

References grk::Codec::getImpl().

◆ grk_decompress_get_sample_tile_image()

GRK_API grk_image *GRK_CALLCONV grk_decompress_get_sample_tile_image ( grk_object * codec,
uint32_t sample_index,
uint16_t tile_index )

Gets a decompressed tile image from a specific sample (frame).

Useful for multi-frame containers (MJ2) where each frame may have multiple tiles. The sample must have been decompressed first via grk_decompress() (for sample 0) or grk_decompress_sample() (for subsequent samples).

Parameters
codecdecompression codec (see grk_object)
sample_indexsample index (0-based)
tile_indextile index within the sample (row-major)
Returns
pointer to grk_image for the tile, or NULL if not available

References grk::Codec::getImpl().

◆ grk_decompress_get_tile_image()

GRK_API grk_image *GRK_CALLCONV grk_decompress_get_tile_image ( grk_object * codec,
uint16_t tile_index,
bool wait )

Gets decompressed tile image by tile index.

Returns per-tile decoded data after decompression completes. Works for both single-tile and multi-tile images. The tile index is: tile_y * num_tile_cols + tile_x (use grk_wait_swath output fields to compute).

Parameters
codecdecompression codec (see grk_object)
tile_indextile index (row-major within the image tile grid)
waitif true, block until the specified tile is decompressed
Returns
pointer to grk_image for the tile, or NULL if tile not available

References grk::Codec::getImpl().

◆ grk_decompress_init()

GRK_API grk_object *GRK_CALLCONV grk_decompress_init ( grk_stream_params * stream_params,
grk_decompress_parameters * params )

Creates and initializes a JPEG 2000 decompressor.

Opens the source stream and reads enough of the header to determine the codec type (J2K codestream or JP2 file-format). The returned object holds all decompressor state and must be released with grk_object_unref() when the caller is done with it.

This function does NOT read the full image header; call grk_decompress_read_header() next to populate grk_header_info.

Parameters
stream_paramsinput stream description (file path, buffer, or callbacks — see grk_stream_params)
paramsdecompression options (tile range, window region, async mode, etc. — see grk_decompress_parameters)
Returns
pointer to an opaque grk_object on success, NULL on failure (bad stream, unsupported format, OOM)

References grk::StreamGenerator::create(), grk::Codec::getImpl(), grk_object_unref(), grkDecompressCreate(), and grk::grklog.

Referenced by grk::FileFormatJP2Compress::transcodeCodestream().

◆ grk_decompress_num_samples()

GRK_API uint32_t GRK_CALLCONV grk_decompress_num_samples ( grk_object * codec)

Gets the number of samples (frames) in the codec container.

For single-image formats (JP2, J2K) this returns 1. For multi-frame formats (MJ2) this returns the number of video samples.

Parameters
codecdecompression codec (see grk_object)
Returns
number of samples

References grk::Codec::getImpl().

◆ grk_decompress_read_header()

GRK_API bool GRK_CALLCONV grk_decompress_read_header ( grk_object * codec,
grk_header_info * header_info )

Reads and parses the JPEG 2000 image header.

Must be called after grk_decompress_init() and before grk_decompress(). Populates header_info with image dimensions, tile grid, component descriptions, color space, bit-depths, ICC profile pointer, and progression/quality layer counts.

For asynchronous decoding: the image dimensions reported here reflect the full unscaled image; the async scheduler uses them when computing tile ranges for grk_decompress_wait().

Parameters
codecdecompression codec (see grk_object)
header_infocaller-allocated struct to receive header data (see grk_header_info); may be NULL if the caller only needs to prime the codec for grk_decompress()
Returns
true if the codestream main header (and JP2 superbox, if present) were read successfully; false on I/O or parse error

References grk::Codec::getImpl().

Referenced by grk::FileFormatJP2Compress::transcodeCodestream().

◆ grk_decompress_sample()

GRK_API bool GRK_CALLCONV grk_decompress_sample ( grk_object * codec,
uint32_t sample_index )

Decompresses a single sample (frame) by index.

Parameters
codecdecompression codec (see grk_object)
sample_indexsample index (0-based)
Returns
true if successful, otherwise false

References grk::Codec::getImpl().

◆ grk_decompress_schedule_swath_copy()

GRK_API void GRK_CALLCONV grk_decompress_schedule_swath_copy ( grk_object * codec,
const grk_wait_swath * swath,
grk_swath_buffer * buf )

Schedule tile-to-swath copies for a completed swath.

Call after grk_decompress_wait() returns for the given swath. For each tile in the swath, a Taskflow task is submitted to the library executor that converts the internal int32_t planar tile data into the user-supplied output buffer using Highway SIMD (clamp + right-shift to target precision).

Tiles whose decompression Taskflow future is still in flight (ahead of the current swath due to parallel scheduling) have their copy task chained as a Taskflow continuation, so the copy runs as soon as the tile is ready.

The output buffer (grk_swath_buffer) uses BSQ layout (one plane per component). Call grk_decompress_wait_swath_copy() to wait for all scheduled copies before accessing buf->data.

Parameters
codeccodec grk_object
swathswath descriptor with tile_x0/y0/x1/y1 populated by grk_decompress_wait
bufuser-managed output buffer; must stay valid until grk_decompress_wait_swath_copy() returns

References grk::Codec::getImpl().

◆ grk_decompress_set_band_callback()

GRK_API void GRK_CALLCONV grk_decompress_set_band_callback ( grk_object * codec,
grk_io_band_callback callback,
void * user_data )

Set a band-completion callback on the decompressor.

Must be called after grk_decompress_read_header() but before grk_decompress(). When set, the decompressor invokes the callback as each tile row completes, enabling incremental writing of decompressed image bands.

Parameters
codecdecompressor object
callbackfunction to invoke per completed band
user_dataopaque pointer forwarded to the callback

References grk::Codec::getImpl().

◆ grk_decompress_set_progression_state()

GRK_API bool GRK_CALLCONV grk_decompress_set_progression_state ( grk_object * codec,
grk_progression_state state )

Applies a new progression state to one or all cached tiles.

When state.single_tile is true, only the tile at state.tile_index is updated. The maximum number of quality layers to decode for each resolution level is taken from state.layers_per_resolution. If the new limit differs from the current one, the tile is marked dirty so that a subsequent grk_decompress() call re-decodes it with the new layer budget.

Typical use: decode a full swath quickly with 1 layer, then apply more layers on demand for specific tiles.

Parameters
codecdecompression codec (see grk_object)
statedesired progression state (see grk_progression_state); state.single_tile must be true (multi-tile update not supported)
Returns
true if the tile was found in the cache and the state was stored; false if single_tile is false, the tile is not cached, or the codec has no decompressor

References grk::Codec::getImpl(), GRK_API, and GRK_CALLCONV.

◆ grk_decompress_tile()

GRK_API bool GRK_CALLCONV grk_decompress_tile ( grk_object * codec,
uint16_t tile_index )

Decompresses a single tile by index.

Decodes only the tile at tile_index without decompressing the entire image. Useful for random-access workflows where only a subset of tiles is needed. The tile index is row-major: tile_y * num_tile_cols + tile_x.

After this returns, retrieve the decoded image via grk_decompress_get_tile_image(codec, tile_index, false).

Parameters
codecdecompression codec (see grk_object)
tile_indexzero-based tile index (row-major within the tile grid)
Returns
true if the tile was decoded successfully, false on error

References grk::Codec::getImpl().

◆ grk_decompress_update()

GRK_API bool GRK_CALLCONV grk_decompress_update ( grk_decompress_parameters * params,
grk_object * codec )

Updates decompression parameters on an already-initialized codec.

Allows changing parameters (e.g. decoding region, reduce factor, quality layers) after grk_decompress_init() but before the first grk_decompress() call. Not all parameters can be changed mid-stream; refer to grk_decompress_parameters for which fields are live-updatable.

Parameters
paramsupdated decompression parameters (see grk_decompress_parameters)
codecdecompression codec to update (see grk_object)
Returns
true if parameters were applied successfully, false otherwise

References grk::Codec::getImpl().

◆ grk_decompress_wait()

GRK_API void GRK_CALLCONV grk_decompress_wait ( grk_object * codec,
grk_wait_swath * swath )

Waits for an asynchronous decompression to complete.

If swath is non-null: waits for all tiles covering the swath region, then populates swath->tile_x0/y0/x1/y1 and swath->num_tile_cols with the tile grid indices. Use these with grk_decompress_get_tile_image() to retrieve per-tile data.

If swath is null: waits for the entire decompression to complete (all tiles, all post-processing). No tile coordinates are output.

Parameters
codeccodec grk_object
swathgrk_wait_swath to wait for, or NULL for full wait

References grk::Codec::getImpl().

◆ grk_decompress_wait_swath_copy()

GRK_API void GRK_CALLCONV grk_decompress_wait_swath_copy ( grk_object * codec)

Wait for all in-flight swath copy tasks to complete.

Blocks until every copy task submitted by grk_decompress_schedule_swath_copy() has finished. After this returns, buf->data is fully populated and safe to access.

Parameters
codeccodec grk_object

References grk::Codec::getImpl().

◆ grk_deinitialize()

GRK_API void GRK_CALLCONV grk_deinitialize ( void )

Deinitialize the Grok library.

Cleans up the plugin and thread pool. Call at the end of main() to ensure GPU resources are freed before CUDA runtime unloads.

References TFSingleton::destroy(), and grk_plugin_cleanup().

◆ grk_detect_format()

GRK_API bool GRK_CALLCONV grk_detect_format ( const char * file_path,
GRK_CODEC_FORMAT * format )

Detect the JPEG 2000 codec format of a file by reading its magic bytes.

Reads the first bytes of the file and returns the detected format:

  • GRK_CODEC_JP2 for JP2 or JPH container files
  • GRK_CODEC_J2K for raw codestream files (J2K, J2C, JPC)
  • GRK_CODEC_MJ2 for Motion JPEG 2000 files
Parameters
file_pathpath to the file to inspect
format[out] detected codec format
Returns
true if a valid JPEG 2000 format was detected, false otherwise

References grk::detectFormat(), GRK_CODEC_UNK, and GRK_JPEG_2000_NUM_IDENTIFIER_BYTES.

◆ grk_dump_codec()

GRK_API void GRK_CALLCONV grk_dump_codec ( grk_object * codec,
uint32_t info_flag,
FILE * output_stream )

Dumps codec diagnostic information to a stream.

Writes human-readable codec state (image dimensions, tile grid, progression order, codestream indices, etc.) to output_stream. Useful for debugging and conformance testing.

The info_flag controls which sections are emitted; combine the GRK_IMG_INFO, GRK_MH_INFO, GRK_TH_INFO, GRK_TCH_INFO, GRK_MH_IND, and GRK_TH_IND flags as needed.

Parameters
codeccodec (decompression or compression — see grk_object)
info_flagbitmask of GRK_*_INFO / GRK_*_IND flags
output_streamdestination FILE* (e.g. stdout, stderr, or a log file)

References grk::Codec::getImpl().

◆ grk_get_data_type()

GRK_API grk_data_type GRK_CALLCONV grk_get_data_type ( bool compress,
uint8_t prec,
bool is_mct,
uint8_t qmfbid,
bool fast_mct )

Determine the data type used by Grok for image component data.

Returns the data type (GRK_INT_32 or GRK_INT_16) that Grok will use for storing image component data during compression or decompression, assuming standard conditions (whole-tile decoding, num_resolutions > 1).

Parameters
compresstrue for compression, false for decompression
precimage component precision in bits
is_mcttrue if multi-component transform (MCT/RCT/ICT) is applied
qmfbidwavelet transform: 1 for reversible (5/3), 0 for irreversible (9/7)
Returns
GRK_INT_16 if the 16-bit path will be used, GRK_INT_32 otherwise

References GRK_INT_16, and GRK_INT_32.

Referenced by grk::TileProcessor::createDecompressTileComponentWindows(), and grk::TileProcessorCompress::preCompressTile().

◆ grk_image_is_post_process_no_op()

GRK_API bool GRK_CALLCONV grk_image_is_post_process_no_op ( grk_image * image)

Checks whether the image requires post-processing (palette, ICC, colour space conversion, precision override, or upsampling).

Parameters
imagepointer to the decompressed image
Returns
true if all post-processing steps are no-ops

◆ grk_image_meta_get_field()

GRK_API bool GRK_CALLCONV grk_image_meta_get_field ( grk_image_meta * meta,
const char * field,
uint8_t ** data,
size_t * len )

Get a metadata buffer from a grk_image_meta object.

Returns a pointer to the internal buffer for the specified metadata field. The pointer is valid for the lifetime of the grk_image_meta object.

Parameters
metapointer to an existing grk_image_meta
fieldwhich metadata field to get: "geotiff", "ipr", "xmp", "iptc", "exif", "xml"
[out]dataset to internal buffer pointer (do not free)
[out]lenset to buffer length
Returns
true on success (even if data is NULL/empty), false on invalid field

References resolve_meta_field().

◆ grk_image_meta_new()

GRK_API grk_image_meta *GRK_CALLCONV grk_image_meta_new ( void )

Allocates an empty image metadata object.

Returns a heap-allocated grk_image_meta that holds optional metadata (ICC profile, XMP, IPTC, EXIF) to associate with an image before compression. Free with grk_object_unref() when done.

Returns
pointer to newly allocated grk_image_meta, or NULL on OOM

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

◆ grk_image_meta_set_asocs()

GRK_API bool GRK_CALLCONV grk_image_meta_set_asocs ( grk_image_meta * meta,
const grk_asoc * asocs,
uint32_t num_asocs )

Set association boxes on a grk_image_meta object for writing.

The asoc array uses a flattened tree representation:

  • Level 0 entries are top-level association boxes
  • Level N entries are children of the most recent level N-1 entry Each entry has a label and optionally XML content.

This is used for GMLJP2 metadata. The data is copied internally.

Parameters
metapointer to an existing grk_image_meta
asocsarray of association box entries
num_asocsnumber of entries in the array
Returns
true on success, false on OOM or invalid input

References _grk_image_meta::asoc_boxes, _grk_asoc::label, _grk_asoc::level, _grk_image_meta::num_asoc_boxes, _grk_asoc::xml, and _grk_asoc::xml_len.

◆ grk_image_meta_set_field()

GRK_API bool GRK_CALLCONV grk_image_meta_set_field ( grk_image_meta * meta,
const char * field,
const uint8_t * data,
size_t len )

Set a metadata buffer on a grk_image_meta object.

Copies len bytes from data into the specified metadata field, replacing any existing data. The previous buffer (if any) is freed.

Parameters
metapointer to an existing grk_image_meta
fieldwhich metadata field to set: "geotiff", "ipr", "xmp", "iptc", "exif", "xml"
datapointer to source bytes (copied internally)
lennumber of bytes to copy
Returns
true on success, false on invalid field name or OOM

References resolve_meta_field().

◆ grk_image_new()

GRK_API grk_image *GRK_CALLCONV grk_image_new ( uint16_t numcmpts,
grk_image_comp * cmptparms,
GRK_COLOR_SPACE clrspc,
bool alloc_data )

Allocates a new Grok image with the specified component layout.

Creates an image whose component geometry is described by cmptparms. Each entry in cmptparms specifies width, height, bit-depth, signedness, and sub-sampling factors for one component.

When alloc_data is true, a contiguous int32_t data block is allocated for every component; when false, the component data pointers are NULL and the caller must supply them before passing the image to grk_compress_init().

The returned image is reference-counted. Release with grk_object_unref().

Parameters
numcmptsnumber of components (e.g. 1 for grayscale, 3 for RGB)
cmptparmsper-component parameters array — length must be numcmpts (see grk_image_comp)
clrspcimage colour space (e.g. GRK_CLRSPC_SRGB, GRK_CLRSPC_GRAY — see GRK_COLOR_SPACE)
alloc_dataif true, allocate int32_t data buffers for all components
Returns
pointer to newly allocated grk_image, or NULL on failure

References grk::GrkImage::create().

◆ grk_initialize()

GRK_API void GRK_CALLCONV grk_initialize ( const char * plugin_path,
uint32_t num_threads,
bool * plugin_initialized )

Initializes the Grok library.

Must be called once before any other Grok API function. It is safe to call multiple times; subsequent calls are no-ops unless the library was shut down.

Sets up the Taskflow thread pool used by all async decompress/compress operations. Pass num_threads = 0 to use all available logical CPUs. The thread pool persists for the lifetime of the process.

Parameters
plugin_pathpath to an optional hardware-accelerator plugin .so; pass NULL for CPU-only operation
num_threadsnumber of worker threads (0 = use all CPUs)
plugin_initializedif non-NULL, set to true when a plugin was loaded and initialized successfully, false otherwise

References TFSingleton::create(), debugCallback(), errorCallback(), grk_plugin_load(), grk_set_msg_handlers(), grk::grklog, infoCallback(), initMutex, initState_, grk::Logger::logger_, traceCallback(), and warningCallback().

Referenced by grk_compress(), grk_decompress(), and grk_transcode().

◆ grk_num_workers()

GRK_API size_t GRK_CALLCONV grk_num_workers ( void )

Returns the number of worker threads in the core thread pool.

Returns
total number of threads (including the driver thread)

References TFSingleton::num_threads().

Referenced by grk::num_workers().

◆ grk_object_ref()

GRK_API grk_object *GRK_CALLCONV grk_object_ref ( grk_object * obj)

Increments the reference count on a Grok object.

Call this when you want to share ownership of a codec or image object across multiple owners. Each call to grk_object_ref() must be matched by exactly one call to grk_object_unref().

Parameters
objGrok object (see grk_object); passing NULL is a no-op
Returns
the same obj pointer (for convenience), or NULL if obj is NULL

References GRK_API, and GRK_CALLCONV.

Referenced by grk::grk_ref().

◆ grk_object_unref()

GRK_API void GRK_CALLCONV grk_object_unref ( grk_object * obj)

Decrements the reference count on a Grok object.

When the reference count reaches zero the object (codec or image) is destroyed and all associated decompressor/compressor resources are freed. The caller must not access the object after this call if its count reaches zero.

For a decompressor codec: completes any in-flight async tasks before destroying the object. For an image: frees component data buffers.

Parameters
objGrok object (see grk_object); passing NULL is a no-op

References GRK_API, and GRK_CALLCONV.

Referenced by grk_compress_init(), grk_decompress_init(), grk_transcode(), grk::grk_unref(), and grk::FileFormatJP2Compress::transcodeCodestream().

◆ grk_plugin_batch_compress()

GRK_API int32_t GRK_CALLCONV grk_plugin_batch_compress ( grk_plugin_compress_batch_info info)

Compresses a directory of images in batch using the hardware plugin.

Scans info.input_dir for supported source images, compresses each one with plugin acceleration, and writes results to info.output_dir. A per-image info.callback is invoked for each file to allow custom output naming and post-processing.

Parameters
infobatch job description: input/output directories, compression parameters, and per-file callback (see grk_plugin_compress_batch_info)
Returns
0 if all files were queued successfully, non-zero on error

References _gpup_compress_batch_info::callback, _gpup_compress_batch_info::compress_parameters, grk_plugin_internal_encode_callback(), grk::grk_to_gpup_compress_params(), _gpup_compress_batch_info::input_dir, grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), _gpup_compress_batch_info::output_dir, plugin_batch_encode_method_name, pluginLoaded, s_originalCompressParams, and userEncodeCallback.

◆ grk_plugin_batch_decompress()

GRK_API int32_t GRK_CALLCONV grk_plugin_batch_decompress ( void )

Starts (resumes) the queued batch decompress operation.

Begins processing files registered by grk_plugin_init_batch_decompress(). Returns immediately; use grk_plugin_wait_for_batch_complete() (or poll via callbacks) to track completion.

Returns
0 on success, non-zero if the batch was not initialised or a fatal scheduling error occurred

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

◆ grk_plugin_cleanup()

GRK_API void GRK_CALLCONV grk_plugin_cleanup ( void )

Unloads the plugin and releases all plugin-owned resources.

Signals the plugin to drain any in-flight GPU/FPGA work, then closes the shared library handle. Call before process exit or before loading a different plugin version.

Safe to call even if no plugin is loaded (no-op in that case).

References grk::minpf_cleanup_plugin_manager(), and pluginLoaded.

Referenced by grk_deinitialize(), and GrkCleanup::~GrkCleanup().

◆ grk_plugin_compress()

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

Compresses a single image using the loaded hardware plugin.

Uses the plugin-accelerated T1 encoder. For CPU-only encoding use grk_compress() instead. The callback is invoked on completion with the compressed byte count and any error code.

Parameters
compress_parameterscompression settings (see grk_cparameters)
callbackcompletion callback (see GRK_PLUGIN_COMPRESS_USER_CALLBACK)
Returns
0 on success, non-zero error code on failure

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

◆ grk_plugin_decompress()

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

Decompresses a single JPEG 2000 image using the loaded hardware plugin.

Uses plugin-accelerated T1 entropy decoding. For CPU-only decoding use grk_decompress() instead. The callback is invoked on completion.

Parameters
decompress_parametersdecompression settings (see grk_decompress_parameters)
callbackper-image completion callback (see grk_plugin_decompress_callback)
Returns
0 on success, non-zero error code on failure

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

◆ grk_plugin_get_debug_state()

GRK_API uint32_t GRK_CALLCONV grk_plugin_get_debug_state ( )

Returns the current debug state bitmask of the loaded plugin.

The returned value is a combination of GRK_PLUGIN_STATE_* flags:

  • GRK_PLUGIN_STATE_NO_DEBUG (0x0) — production mode, no debug output
  • GRK_PLUGIN_STATE_DEBUG (0x1) — T1 debug comparisons enabled
  • GRK_PLUGIN_STATE_PRE_TR1 (0x2) — pre-T1 DWT/MCT data compared
  • GRK_PLUGIN_STATE_DWT_QUANTIZATION (0x4) — DWT quantisation compared
  • GRK_PLUGIN_STATE_MCT_ONLY (0x8) — only MCT stage compared

Returns 0 (GRK_PLUGIN_STATE_NO_DEBUG) if no plugin is loaded.

Returns
bitmask of active GRK_PLUGIN_STATE_* flags

References GRK_PLUGIN_STATE_NO_DEBUG, 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::TileProcessorCompress::doCompress(), grk::TileProcessor::init(), grk::TileProcessorCompress::pcrdBisectFeasible(), grk::TileProcessorCompress::pcrdBisectSimple(), grk::TileProcessorCompress::syncPluginCodeBlockData(), and grk::tile_equals().

◆ grk_plugin_init()

GRK_API bool GRK_CALLCONV grk_plugin_init ( grk_plugin_init_info init_info)

Initializes a loaded plugin with a device and license.

Must be called after grk_plugin_load() and before any compress or decompress operation that uses the plugin. Connects the plugin to the specified accelerator device and validates the license string.

Parameters
init_infodevice ID, license key, and optional server address (see grk_plugin_init_info)
Returns
true if the plugin accepted the device and license, false on invalid license, device unavailable, or no plugin loaded

References _grk_plugin_init_info::device_id, _gpup_init_info::deviceId, GRK_API, GRK_CALLCONV, _gpup_init_info::license, _grk_plugin_init_info::license, grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), plugin_init_method_name, pluginLoaded, _gpup_init_info::server, _grk_plugin_init_info::server, _gpup_init_info::verbose, and _grk_plugin_init_info::verbose.

◆ grk_plugin_init_batch_decompress()

GRK_API 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 )

Initialises a batch plugin decompress operation but does not start it.

Sets up a batch decompression pipeline: scans input_dir, pairs each file with decompress_parameters, and registers callback for per-file results. Call grk_plugin_batch_decompress() to start decoding.

Parameters
input_dirdirectory containing JPEG 2000 source files
output_dirdirectory to write decompressed output files
decompress_parametersshared decompression settings for all files (see grk_decompress_parameters)
callbackper-image result callback (see grk_plugin_decompress_callback)
Returns
0 on success, non-zero on error (missing directory, bad parameters)

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

◆ grk_plugin_load()

GRK_API bool GRK_CALLCONV grk_plugin_load ( grk_plugin_load_info info)

Loads a hardware-accelerator plugin (.so / .dll).

Should be called after grk_initialize(), before grk_compress_init() or grk_decompress_init(). The plugin extends Grok with GPU or FPGA acceleration for T1 entropy coding. If loading fails, Grok falls back to CPU-only operation transparently.

Only one plugin may be loaded at a time. Call grk_plugin_cleanup() to unload the current plugin before loading a new one.

Parameters
infoplugin path and options (see grk_plugin_load_info)
Returns
true if the plugin was loaded and its ABI version is compatible, false otherwise

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

Referenced by grk_initialize().

◆ grk_plugin_stop_batch_compress()

GRK_API void GRK_CALLCONV grk_plugin_stop_batch_compress ( void )

Requests cancellation of a running batch compress operation.

Sets a stop flag that causes the batch scheduler to skip remaining queued files. Already-in-flight jobs are allowed to complete. Call grk_plugin_wait_for_batch_complete() after this to ensure a clean shutdown.

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

◆ grk_plugin_stop_batch_decompress()

GRK_API void GRK_CALLCONV grk_plugin_stop_batch_decompress ( void )

Requests cancellation of a running batch decompress operation.

Sets a stop flag that causes the batch scheduler to skip remaining files. Already-in-flight jobs complete normally. After calling this, wait for grk_plugin_wait_for_batch_complete() before accessing output.

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

◆ grk_plugin_wait_for_batch_complete()

GRK_API void GRK_CALLCONV grk_plugin_wait_for_batch_complete ( void )

Blocks until all pending plugin batch jobs have completed.

Should be called after grk_plugin_batch_compress() returns to ensure all asynchronously queued compression tasks have finished before the caller inspects output files or calls grk_plugin_cleanup().

References funcPluginWaitForBatchComplete, GRK_API, GRK_CALLCONV, grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), plugin_wait_for_batch_complete_method_name, and pluginLoaded.

◆ grk_set_MCT()

GRK_API bool GRK_CALLCONV grk_set_MCT ( grk_cparameters * parameters,
const float * encoding_matrix,
const int32_t * dc_shift,
uint32_t nb_comp )

Installs a custom Multi-Component Transform (MCT) matrix.

Overrides the default RGB→YCbCr colour transform with a user-supplied floating-point matrix. The matrix must be square (nb_comp × nb_comp) stored in row-major order. A matching DC shift vector (one value per component) is applied after the transform.

Only meaningful for compression; ignored for decompression. Must be called before grk_compress_init().

Parameters
parameterscompression parameters to update (see grk_cparameters)
encoding_matrixrow-major nb_comp×nb_comp transform matrix
dc_shiftper-component DC shift values (array of nb_comp int32_t)
nb_compnumber of image components (matrix dimension)
Returns
true if the matrix was stored successfully, false on invalid input

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

◆ grk_set_msg_handlers()

GRK_API void GRK_CALLCONV grk_set_msg_handlers ( grk_msg_handlers msg_handlers)

Installs application-defined log message handlers.

Replaces the default handlers (which print to stderr/stdout) with user-supplied callbacks for info, warning, and error messages. Call before grk_initialize() or at any point to change handlers. Passing a NULL function pointer for any handler restores the default behaviour for that level.

Parameters
msg_handlersstruct of {info, warn, error} function pointers (see grk_msg_handlers)

References GRK_API, GRK_CALLCONV, and grk::Logger::logger_.

Referenced by grk_initialize().

◆ grk_thread_pool()

GRK_API void *GRK_CALLCONV grk_thread_pool ( void )

Returns an opaque handle to the core thread-pool executor.

The handle is a pointer to the internal tf::Executor. Cast it back with the helpers in grk_thread_pool.h (C++ only) or use grk_num_workers() / grk_worker_id() from C.

Returns
opaque executor handle, or NULL if the library is not initialised

References TFSingleton::get().

Referenced by grk::executor().

◆ grk_transcode()

GRK_API uint64_t GRK_CALLCONV grk_transcode ( grk_stream_params * src_stream,
grk_stream_params * dst_stream,
grk_cparameters * parameters,
grk_image * image )

Transcodes a JPEG 2000 file by rewriting JP2 boxes while copying the codestream verbatim.

Opens the source stream, parses box headers to locate the contiguous codestream (JP2C) box, then writes a new JP2 file to dst_stream using the metadata from image and the box-level settings in parameters (branding, resolution, geoboxes placement, etc.). The raw J2K codestream is copied byte-for-byte from source to destination without re-encoding.

The image must carry the desired output metadata in its grk_image_meta (XMP, IPTC, EXIF, GeoTIFF, IPR, XML, association boxes, channel definitions, colour space, ICC profile, etc.). Populate these fields before calling this function — typically by decompressing the source header with grk_decompress_read_header(), then modifying the metadata as needed.

Parameters
src_streamsource stream description (must be readable, see grk_stream_params)
dst_streamdestination stream description (must be writable, see grk_stream_params)
parameterscompression / transcode settings (see grk_cparameters); box-level fields (jpx_branding, write_rreq, geoboxes_after_jp2c, resolution, etc.) are honoured
imagesource image carrying component info and metadata (see grk_image)
Returns
number of bytes written to the destination stream, or 0 on failure

References grk::StreamGenerator::create(), grk::Codec::getImpl(), GRK_CODEC_JP2, grk_compress_create(), GRK_FMT_JP2, grk_initialize(), grk_object_unref(), and grk::grklog.

◆ grk_version()

GRK_API const char *GRK_CALLCONV grk_version ( void )

Gets the Grok library version string.

Returns a null-terminated string of the form "MAJOR.MINOR.PATCH" (e.g. "10.0.5"). The string is statically allocated; do not free it.

Returns
null-terminated version string

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

◆ grk_worker_id()

GRK_API uint32_t GRK_CALLCONV grk_worker_id ( void )

Returns the TaskFlow worker id of the calling thread.

Returns
worker id if called from inside a TaskFlow task, 0 otherwise

References TFSingleton::workerId().

Referenced by grk::worker_id().