|
Grok 20.3.2
|
#include <stdint.h>#include <stdio.h>#include <stdbool.h>#include <limits.h>#include "grk_config.h"Go to the source code of this file.
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. | |
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. | |
| #define GRK_API __attribute__((visibility("default"))) |
| #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().
| #define GRK_BROADCAST_LEVEL_10_MBITSSEC 25600U /** Mbits/sec for level 10 */ |
| #define GRK_BROADCAST_LEVEL_10_MSAMPLESSEC 19200U /** MSamples/sec for level 10 */ |
| #define GRK_BROADCAST_LEVEL_11_MBITSSEC 51200U /** Mbits/sec for level 11 */ |
| #define GRK_BROADCAST_LEVEL_11_MSAMPLESSEC 38400U /** MSamples/sec for level 11 */ |
| #define GRK_BROADCAST_LEVEL_1_MBITSSEC 200U /** Mbits/sec for level 1 */ |
| #define GRK_BROADCAST_LEVEL_1_MSAMPLESSEC 64U /** MSamples/sec for level 1 */ |
| #define GRK_BROADCAST_LEVEL_2_MBITSSEC 200U /** Mbits/sec for level 2 */ |
| #define GRK_BROADCAST_LEVEL_2_MSAMPLESSEC 130U /** MSamples/sec for level 2 */ |
| #define GRK_BROADCAST_LEVEL_3_MBITSSEC 200U /** Mbits/sec for level 3 */ |
| #define GRK_BROADCAST_LEVEL_3_MSAMPLESSEC 195U /** MSamples/sec for level 3 */ |
| #define GRK_BROADCAST_LEVEL_4_MBITSSEC 400U /** Mbits/sec for level 4 */ |
| #define GRK_BROADCAST_LEVEL_4_MSAMPLESSEC 260U /** MSamples/sec for level 4 */ |
| #define GRK_BROADCAST_LEVEL_5_MBITSSEC 800U /** Mbits/sec for level 5 */ |
| #define GRK_BROADCAST_LEVEL_5_MSAMPLESSEC 520U /** MSamples/sec for level 5 */ |
| #define GRK_BROADCAST_LEVEL_6_MBITSSEC 1600U /** Mbits/sec for level 6 */ |
| #define GRK_BROADCAST_LEVEL_6_MSAMPLESSEC 1200U /** MSamples/sec for level 6 */ |
| #define GRK_BROADCAST_LEVEL_7_MBITSSEC 3200U /** Mbits/sec for level 7 */ |
| #define GRK_BROADCAST_LEVEL_7_MSAMPLESSEC 2400U /** MSamples/sec for level 7 */ |
| #define GRK_BROADCAST_LEVEL_8_MBITSSEC 6400U /** Mbits/sec for level 8 */ |
| #define GRK_BROADCAST_LEVEL_8_MSAMPLESSEC 4800U /** MSamples/sec for level 8 */ |
| #define GRK_BROADCAST_LEVEL_9_MBITSSEC 12800U /** Mbits/sec for level 9 */ |
| #define GRK_BROADCAST_LEVEL_9_MSAMPLESSEC 9600U /** MSamples/sec for level 9 */ |
| #define GRK_CALLCONV |
| #define GRK_CBLKSTY_HT_MIXED 0xC0 /** mixed high throughput block coding */ |
| #define GRK_CBLKSTY_HT_ONLY 0x40 /** high throughput only block coding */ |
| #define GRK_CBLKSTY_LAZY 0x01 /** Selective arithmetic coding bypass */ |
| #define GRK_CBLKSTY_PTERM 0x10 /** Predictable termination */ |
Referenced by grk::t1::BlockCoder::compress_cblk(), and grk::t1::BlockCoder::decompressFinish().
| #define GRK_CBLKSTY_RESET 0x02 /** Reset context probabilities on coding pass boundaries */ |
| #define GRK_CBLKSTY_SEGSYM 0x20 /** Segmentation symbols are used */ |
Referenced by grk::t1::BlockCoder::checkSegSym(), and grk::t1::BlockCoder::compress_cblk().
| #define GRK_CBLKSTY_TERMALL 0x04 /** Termination on each coding pass */ |
| #define GRK_CBLKSTY_VSC 0x08 /** Vertical stripe causal context */ |
Referenced by grk::t1::BlockCoder::dec_clnpass(), grk::t1::BlockCoder::dec_clnpass_diff(), grk::t1::BlockCoder::dec_clnpass_diff_final(), grk::t1::BlockCoder::dec_sigpass(), grk::t1::BlockCoder::dec_sigpass_diff(), grk::t1::BlockCoder::dec_sigpass_diff_final(), grk::t1::BlockCoder::dec_sigpass_raw(), grk::t1::BlockCoder::enc_clnpass(), and grk::t1::BlockCoder::enc_sigpass().
| #define GRK_CINEMA_24_COMP 1041666 /** Maximum size per color component @ 24fps */ |
Referenced by grk::Profile::setCinemaParams().
| #define GRK_CINEMA_24_CS 1302083 /** Maximum code stream length @ 24fps */ |
Referenced by grk::Profile::setCinemaParams().
| #define GRK_CINEMA_48_COMP 520833 /** Maximum size per color component @ 48fps */ |
| #define GRK_CINEMA_48_CS 651041 /** Maximum code stream length @ 48fps */ |
| #define GRK_CINEMA_4K_DEFAULT_NUM_RESOLUTIONS 7 /* Default number of resolutions for 4K cinema */ |
| #define GRK_CINEMA_DCI_MAX_BANDWIDTH 250000000 |
JPEG 2000 cinema profile code stream and component size limits.
| #define GRK_CUSTOM_CIELAB_SPACE 0x0 |
Referenced by grk::FileFormatJP2Family::read_colr().
| #define GRK_DECODE_ALL (GRK_PLUGIN_DECODE_CLEAN | GRK_DECODE_HEADER | GRK_DECODE_T2 | GRK_DECODE_T1 | GRK_DECODE_POST_T1) |
| #define GRK_DECODE_HEADER (1 << 0) |
| #define GRK_DECODE_POST_T1 (1 << 3) |
Referenced by grk::TileProcessor::doPostT1().
| #define GRK_DECODE_T1 (1 << 2) |
| #define GRK_DECODE_T2 (1 << 1) |
| #define GRK_DECOMPRESS_COMPRESSION_LEVEL_DEFAULT (UINT_MAX) |
default compression level for decompression output file formats that support compression
| #define GRK_DEFAULT_CIELAB_SPACE 0x44454600 /* 'DEF' */ |
| #define GRK_EXTENSION_MCT 0x0100 /** Custom MCT support */ |
Referenced by grk_set_MCT(), grk::CodeStreamCompress::init(), and grk::CodeStreamCompress::init_header_writing().
| #define GRK_EXTENSION_NONE 0x0000 /** No Part-2 extension */ |
JPEG 2000 Part-2 extensions.
Referenced by grk::CodeStreamCompress::init().
| #define GRK_GET_IMF_OR_BROADCAST_PROFILE | ( | v | ) |
| #define GRK_GET_IMF_SUBLEVEL | ( | v | ) |
Referenced by grk::Profile::isImfCompliant().
| #define GRK_GET_LEVEL | ( | v | ) |
Referenced by grk::Profile::isBroadcastCompliant(), and grk::Profile::isImfCompliant().
| #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_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_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_IMF_SUBLEVEL_MAX 9U /** Maximum IMF sublevel */ |
| #define GRK_IMG_INFO 1 /* Basic image information provided to the user */ |
Referenced by grk::CodeStreamDecompress::dump().
| #define GRK_IS_BROADCAST | ( | v | ) |
Referenced by grk::CodeStreamCompress::init(), and grk::SIZMarker::read().
| #define GRK_IS_CINEMA | ( | v | ) |
Referenced by grk::TileProcessorCompress::canWritePocMarker(), grk::PacketIter::enable_tile_part_generation(), grk::CodeStreamCompress::init(), and grk::PacketManager::PacketManager().
| #define GRK_IS_IMF | ( | v | ) |
Referenced by grk::PacketIter::enable_tile_part_generation(), grk::CodeStreamCompress::init(), and grk::SIZMarker::read().
| #define GRK_IS_PART2 | ( | v | ) |
Referenced by grk_set_MCT(), and grk::CodeStreamCompress::init().
| #define GRK_IS_STORAGE | ( | v | ) |
Referenced by grk::CodeStreamCompress::init().
| #define GRK_JPH_RSIZ_FLAG 0x4000 /**for JPH, bit 14 of RSIZ must be set to 1 */ |
Referenced by grk::CodeStreamCompress::init().
| #define GRK_LEVEL_MAX 11U /** Maximum (main) level */ |
Referenced by grk::Profile::isBroadcastCompliant(), and grk::Profile::isImfCompliant().
| #define GRK_MAX_COMMENT_LENGTH (UINT16_MAX - 2) |
maximum Grok supported comment length
Referenced by grk::CodeStreamCompress::init(), and grk::CodeStreamCompress::write_com().
| #define GRK_MAX_CUSTOM_HEADERS 16 |
| #define GRK_MAX_DECOMP_LVLS |
Referenced by grk::TileCodingParams::readSPCodSPCoc().
| #define GRK_MAX_LAYERS 256 /* Grok maximum number of quality layers */ |
| #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().
| #define GRK_MAX_SUPPORTED_IMAGE_PRECISION 16 |
maximum Grok supported precision
Referenced by grk::GrkImage::allComponentsSanityCheck(), grk::clip(), grk::SIZMarker::read(), grk::FileFormatJP2Family::read_ihdr(), grk::FileFormatJP2Family::read_palette_clr(), and grk::CodeStreamDecompress::readCBD().
| #define GRK_MAXBANDS (3 * GRK_MAXRLVLS - 2) /* Maximum number of sub-bands allowed by standard */ |
| #define GRK_MAXRLVLS (GRK_MAX_DECOMP_LVLS + 1) /* Maximum number of resolution levels allowed by standard*/ |
Referenced by grk::LayerIncludeBuffers::clear(), grk::CodeStreamCompress::compressValidation(), grk::TileCodingParams::finalizePocs(), grk::CodeStreamCompress::init(), grk::LayerIncludeBuffers::LayerIncludeBuffers(), grk::PacketManager::PacketManager(), grk::TileCodingParams::readPoc(), grk::IncludeTracker::resetNumPrecinctsPerRes(), grk::TileComponentCodingParams::TileComponentCodingParams(), and grk::LayerIncludeBuffers::update().
| #define GRK_MH_IND 16 /** Codestream index based only on the main header */ |
Referenced by grk::CodeStreamDecompress::dump().
| #define GRK_MH_INFO 2 /* Codestream information based only on the main header */ |
Referenced by grk::CodeStreamDecompress::dump().
| #define GRK_NUM_ASOC_BOXES_SUPPORTED 256 |
maximum Grok supported number of asoc boxes
Referenced by grk::FileFormatJP2Family::serializeAsoc().
| #define GRK_NUM_COMMENTS_SUPPORTED 256 |
maximum Grok supported number of comments
Referenced by grk::CodingParams::readCom().
| #define GRK_NUM_XML_BOXES_SUPPORTED 64 |
maximum Grok supported number of XML boxes
Referenced by grk::FileFormatJP2Family::readHeader().
| #define GRK_PATH_LEN 4096 /* Grok maximum supported filename size */ |
Referenced by grk::gpup_to_grk_stream_params().
| #define GRK_PLUGIN_DECODE_CLEAN (1 << 4) |
Referenced by grk_plugin_internal_decode_callback().
| #define GRK_PLUGIN_STATE_DEBUG 0x1 |
| #define GRK_PLUGIN_STATE_DWT_QUANTIZATION 0x4 |
| #define GRK_PLUGIN_STATE_MCT_ONLY 0x8 |
Referenced by grk::TileProcessorCompress::doCompress().
| #define GRK_PLUGIN_STATE_NO_DEBUG 0x0 |
| #define GRK_PLUGIN_STATE_PRE_TR1 0x2 |
| #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_BC_MASK 0x030F /** Mask for broadcast profile including main level */ |
| #define GRK_PROFILE_BC_MULTI 0x0200 /** Multi Tile Broadcast profile defined in 15444-1 AMD3 */ |
Referenced by grk::Profile::isBroadcastCompliant().
| #define GRK_PROFILE_BC_MULTI_R 0x0300 /** Multi Tile Reversible Broadcast profile defined in 15444-1 AMD3 */ |
Referenced by grk::Profile::setBroadcastParams().
| #define GRK_PROFILE_BC_SINGLE 0x0100 /** Single Tile Broadcast profile defined in 15444-1 AMD3 */ |
Referenced by grk::Profile::isBroadcastCompliant().
| #define GRK_PROFILE_CINEMA_2K 0x0003 /** 2K cinema profile defined in 15444-1 AMD1 */ |
Referenced by grk::Profile::isCinemaCompliant(), and grk::Profile::setCinemaParams().
| #define GRK_PROFILE_CINEMA_4K 0x0004 /** 4K cinema profile defined in 15444-1 AMD1 */ |
| #define GRK_PROFILE_CINEMA_LTS 0x0007 /** Long term storage cinema profile defined in 15444-1 AMD2 */ |
Referenced by grk::SIZMarker::read().
| #define GRK_PROFILE_CINEMA_S2K 0x0005 /** Scalable 2K cinema profile defined in 15444-1 AMD2 */ |
Referenced by grk::CodeStreamCompress::init().
| #define GRK_PROFILE_CINEMA_S4K 0x0006 /** Scalable 4K cinema profile defined in 15444-1 AMD2 */ |
Referenced by grk::CodeStreamCompress::init().
| #define GRK_PROFILE_IMF_2K 0x0400 /** 2K 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 0x0500 /** 4K Single Tile Lossy 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 0x0600 /** 8K Single Tile Lossy 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 */ |
Referenced by grk::SIZMarker::read().
| #define GRK_PROFILE_NONE 0x0000 /** no profile, conform to 15444-1 */ |
Referenced by grk_compress_set_default_params(), and grk::CodeStreamCompress::init().
| #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_RANDOM_ACCESS_PLM 4 /* Disable PLM marker if present */ |
| #define GRK_RANDOM_ACCESS_PLT 1 /* Disable PLT marker if present */ |
Decompression: disable random access markers.
Referenced by grk::TileProcessor::readPLT().
| #define GRK_RANDOM_ACCESS_TLM 2 /* Disable TLM marker if present */ |
Referenced by grk::CodeStreamDecompress::readTLM().
| #define GRK_TCH_INFO 8 /** Tile/Component information of all tiles */ |
Referenced by grk::CodeStreamDecompress::dump().
| #define GRK_TH_IND 32 /** Tile index based on the current tile */ |
| #define GRK_TH_INFO 4 /* Tile information based on the current tile header */ |
| #define GRK_TILE_CACHE_ALL 2 /* cache everything */ |
| #define GRK_TILE_CACHE_IMAGE 1 /* cache final tile image */ |
Referenced by grk::TileProcessor::releaseForSwath().
| #define GRK_TILE_CACHE_LRU 4 /* LRU: release decompressed data, keep processor */ |
Referenced by grk::TileCache::evictLRU(), grk::CodeStreamDecompress::init(), and grk::TileProcessor::release().
| #define GRK_TILE_CACHE_NONE 0 /* no tile caching */ |
Grok tile cache strategy.
Referenced by grk::TileProcessor::release(), grk::TileCache::TileCache(), grk::TileProcessorCompress::TileProcessorCompress(), and grk::TileProcessor::~TileProcessor().
| typedef struct _grk_asoc grk_asoc |
| typedef enum _GRK_CHANNEL_ASSOC GRK_CHANNEL_ASSOC |
Channel association.
| typedef struct _grk_channel_definition grk_channel_definition |
| typedef struct _grk_channel_description grk_channel_description |
| typedef enum _GRK_CHANNEL_TYPE GRK_CHANNEL_TYPE |
| typedef enum _GRK_CODEC_FORMAT GRK_CODEC_FORMAT |
Grok Supported JPEG 2000 formats.
| typedef struct _grk_color grk_color |
| typedef enum _GRK_COLOR_SPACE GRK_COLOR_SPACE |
Grok supported color spaces.
| typedef struct _grk_component_mapping_comp grk_component_mapping_comp |
| typedef struct _grk_cparameters grk_cparameters |
| typedef enum _grk_data_type grk_data_type |
Grok Data types Used to specify the actual data type of Grok image components.
| 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_ENUM_COLOUR_SPACE GRK_ENUM_COLOUR_SPACE |
JPEG 2000 enumerated color spaces.
| typedef struct _grk_header_info grk_header_info |
| typedef struct _grk_image grk_image |
| typedef struct _grk_image_comp grk_image_comp |
| typedef struct _grk_image_meta grk_image_meta |
| 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.
| yBegin | first row (inclusive) of the completed band |
| yEnd | one-past-last row (exclusive) of the completed band |
| image | pointer to the image containing the completed band data |
| user_data | user data |
| typedef struct _grk_io_buf grk_io_buf |
| typedef bool(* grk_io_callback) (uint32_t worker_id, grk_io_buf buffer, void *io_user_data) |
Grok IO callback.
| worker_id | worker id |
| buffer | io buffer (see grk_io_buf) |
| io_user_data | user data |
| typedef struct _grk_io_init grk_io_init |
| typedef bool(* grk_io_pixels_callback) (uint32_t worker_id, grk_io_buf buffer, void *user_data) |
Grok IO pixels callback.
| worker_id | worker id |
| buffer | Grok io buffer (see grk_io_buf) |
| user_data | user data |
| 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.
| io_init | io initialization (see grk_io_init) |
| reclaim_callback | (see grk_io_callback) |
| io_user_data | io user data |
| reclaim_user_data | reclaim user data |
| typedef void(* grk_msg_callback) (const char *msg, void *client_data) |
Logging callback.
| msg | message |
| client_data | client data passed to callback |
| typedef struct _grk_msg_handlers grk_msg_handlers |
| typedef struct _grk_object grk_object |
| typedef struct _grk_palette_data grk_palette_data |
| typedef struct _grk_plugin_band grk_plugin_band |
| typedef struct _grk_plugin_code_block grk_plugin_code_block |
| typedef struct grk_plugin_compress_batch_info grk_plugin_compress_batch_info |
Plugin batch compress info.
| typedef uint64_t(* GRK_PLUGIN_COMPRESS_USER_CALLBACK) (grk_plugin_compress_user_callback_info *info) |
Plugin compress user callback.
| info | callback info (see grk_plugin_compress_user_callback_info) |
| typedef struct grk_plugin_compress_user_callback_info grk_plugin_compress_user_callback_info |
| typedef int32_t(* grk_plugin_decompress_callback) (grk_plugin_decompress_callback_info *info) |
Plugin decompress callback.
| info | callback info (see grk_plugin_decompress_callback_info) |
| typedef struct _grk_plugin_decompress_callback_info grk_plugin_decompress_callback_info |
| typedef struct _grk_plugin_init_info grk_plugin_init_info |
| typedef struct _grk_plugin_load_info grk_plugin_load_info |
| typedef struct _grk_plugin_pass grk_plugin_pass |
| typedef struct _grk_plugin_precinct grk_plugin_precinct |
Plugin precinct
| typedef struct _grk_plugin_resolution grk_plugin_resolution |
| typedef struct _grk_plugin_tile grk_plugin_tile |
| typedef struct grk_plugin_tile_component grk_plugin_tile_component |
| typedef struct _grk_precision grk_precision |
| typedef enum _grk_precision_mode grk_precision_mode |
Precision mode.
| typedef enum _GRK_PROG_ORDER 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
| typedef struct _grk_progression grk_progression |
| typedef struct _grk_progression_state grk_progression_state |
| typedef enum _GRK_RATE_CONTROL_ALGORITHM GRK_RATE_CONTROL_ALGORITHM |
Rate control algorithms.
| GRK_RATE_CONTROL_BISECT | bisect with all truncation points |
| GRK_RATE_CONTROL_PCRD_OPT | PCRD: bisect with only feasible truncation points |
| typedef struct _grk_raw_comp_cparameters grk_raw_comp_cparameters |
| typedef struct _grk_raw_cparameters grk_raw_cparameters |
| typedef void(* grk_stream_free_user_data_fn) (void *user_data) |
Free user data callback.
| user_data | user data |
| typedef struct _grk_stream_params grk_stream_params |
| typedef size_t(* grk_stream_read_fn) (uint8_t *buffer, size_t numBytes, void *user_data) |
Read stream callback.
| buffer | buffer to write stream to |
| numBytes | number of bytes to write to buffer |
| user_data | user data |
| typedef bool(* grk_stream_seek_fn) (uint64_t offset, void *user_data) |
Seek (absolute) callback.
| offset | absolute stream offset |
| user_data | user data |
| typedef size_t(* grk_stream_write_fn) (const uint8_t *buffer, size_t numBytes, void *user_data) |
Write stream callback.
| buffer | buffer to read stream from |
| numBytes | number of bytes to read from buffer |
| user_data | user data |
| typedef enum _GRK_SUPPORTED_FILE_FMT GRK_SUPPORTED_FILE_FMT |
All Grok supported file formats.
| typedef struct grk_swath_buffer grk_swath_buffer |
| typedef struct grk_wait_swath grk_wait_swath |
| typedef int(* GROK_INIT_DECOMPRESSORS) (grk_header_info *header_info, grk_image *image) |
Plugin init decompressors.
| enum _GRK_CHANNEL_ASSOC |
| enum _GRK_CHANNEL_TYPE |
| enum _GRK_CODEC_FORMAT |
| enum _GRK_COLOR_SPACE |
| enum _grk_data_type |
JPEG 2000 enumerated color spaces.
| enum _grk_precision_mode |
| enum _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_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.
| codec | compression codec (see grk_object) |
| tile | plugin tile data, or NULL for CPU-only encoding (see grk_plugin_tile) |
References grk::Codec::getImpl(), and grk_initialize().
| 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.
| codec | compression codec (see grk_object) |
References grk::Codec::getImpl().
| 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).
| codec | compression codec (see grk_object) |
| image | Input image for this frame (see grk_image) |
| tile | plugin tile (see grk_plugin_tile) |
References grk::Codec::getImpl().
| 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).
| codec | compression codec (see grk_object) |
References grk::Codec::getImpl().
| 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().
| stream_params | output stream description (see grk_stream_params) |
| parameters | compression settings (see grk_cparameters) |
| image | source image to compress (see grk_image) |
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_API void GRK_CALLCONV grk_compress_set_default_params | ( | grk_cparameters * | parameters | ) |
Fills a grk_cparameters struct with safe default values.
Defaults applied:
| parameters | compression 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_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.
| tile_img | tile image returned by grk_decompress_get_tile_image() |
| buf | output swath buffer (must be pre-allocated and fully populated) |
References grk::hwy_copy_tile_to_swath().
| 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.
| codec | decompression codec (see grk_object) |
| tile | plugin tile data, or NULL for CPU-only decoding (see grk_plugin_tile) |
References grk::Codec::getImpl(), and grk_initialize().
Referenced by grk::FileFormatJP2Compress::transcodeCodestream().
| 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.
| codec | decompression codec (see grk_object) |
References grk::Codec::getImpl().
| 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.
| codec | decompression codec (see grk_object) |
| tile_index | zero-based tile index (row-major within the tile grid) |
References grk::Codec::getImpl().
| 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).
| codec | decompression codec (see grk_object) |
| sample_index | sample index (0-based) |
References grk::Codec::getImpl().
| 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).
| codec | decompression codec (see grk_object) |
| sample_index | sample index (0-based) |
| tile_index | tile index within the sample (row-major) |
References grk::Codec::getImpl().
| 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).
| codec | decompression codec (see grk_object) |
| tile_index | tile index (row-major within the image tile grid) |
| wait | if true, block until the specified tile is decompressed |
References grk::Codec::getImpl().
| 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.
| stream_params | input stream description (file path, buffer, or callbacks — see grk_stream_params) |
| params | decompression options (tile range, window region, async mode, etc. — see grk_decompress_parameters) |
References grk::StreamGenerator::create(), grk::Codec::getImpl(), grk_object_unref(), grkDecompressCreate(), and grk::grklog.
Referenced by grk::FileFormatJP2Compress::transcodeCodestream().
| 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.
| codec | decompression codec (see grk_object) |
References grk::Codec::getImpl().
| 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().
| codec | decompression codec (see grk_object) |
| header_info | caller-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() |
References grk::Codec::getImpl().
Referenced by grk::FileFormatJP2Compress::transcodeCodestream().
| GRK_API bool GRK_CALLCONV grk_decompress_sample | ( | grk_object * | codec, |
| uint32_t | sample_index ) |
Decompresses a single sample (frame) by index.
| codec | decompression codec (see grk_object) |
| sample_index | sample index (0-based) |
References grk::Codec::getImpl().
| 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.
| codec | codec grk_object |
| swath | swath descriptor with tile_x0/y0/x1/y1 populated by grk_decompress_wait |
| buf | user-managed output buffer; must stay valid until grk_decompress_wait_swath_copy() returns |
References grk::Codec::getImpl().
| 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.
| codec | decompressor object |
| callback | function to invoke per completed band |
| user_data | opaque pointer forwarded to the callback |
References grk::Codec::getImpl().
| 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.
| codec | decompression codec (see grk_object) |
| state | desired progression state (see grk_progression_state); state.single_tile must be true (multi-tile update not supported) |
References grk::Codec::getImpl(), GRK_API, and GRK_CALLCONV.
| 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).
| codec | decompression codec (see grk_object) |
| tile_index | zero-based tile index (row-major within the tile grid) |
References grk::Codec::getImpl().
| 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.
| params | updated decompression parameters (see grk_decompress_parameters) |
| codec | decompression codec to update (see grk_object) |
References grk::Codec::getImpl().
| 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.
| codec | codec grk_object |
| swath | grk_wait_swath to wait for, or NULL for full wait |
References grk::Codec::getImpl().
| 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.
| codec | codec grk_object |
References grk::Codec::getImpl().
| 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_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:
| file_path | path to the file to inspect |
| format | [out] detected codec format |
References grk::detectFormat(), GRK_CODEC_UNK, and GRK_JPEG_2000_NUM_IDENTIFIER_BYTES.
| 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.
| codec | codec (decompression or compression — see grk_object) |
| info_flag | bitmask of GRK_*_INFO / GRK_*_IND flags |
| output_stream | destination FILE* (e.g. stdout, stderr, or a log file) |
References grk::Codec::getImpl().
| 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).
| compress | true for compression, false for decompression |
| prec | image component precision in bits |
| is_mct | true if multi-component transform (MCT/RCT/ICT) is applied |
| qmfbid | wavelet transform: 1 for reversible (5/3), 0 for irreversible (9/7) |
References GRK_INT_16, and GRK_INT_32.
Referenced by grk::TileProcessor::createDecompressTileComponentWindows(), and grk::TileProcessorCompress::preCompressTile().
| 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).
| image | pointer to the decompressed image |
| 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.
| meta | pointer to an existing grk_image_meta | |
| field | which metadata field to get: "geotiff", "ipr", "xmp", "iptc", "exif", "xml" | |
| [out] | data | set to internal buffer pointer (do not free) |
| [out] | len | set to buffer length |
References resolve_meta_field().
| 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.
Referenced by grk::CodeStreamDecompress::CodeStreamDecompress(), and grk::FileFormatJP2Compress::init().
| 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:
This is used for GMLJP2 metadata. The data is copied internally.
| meta | pointer to an existing grk_image_meta |
| asocs | array of association box entries |
| num_asocs | number of entries in the array |
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_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.
| meta | pointer to an existing grk_image_meta |
| field | which metadata field to set: "geotiff", "ipr", "xmp", "iptc", "exif", "xml" |
| data | pointer to source bytes (copied internally) |
| len | number of bytes to copy |
References resolve_meta_field().
| 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().
| numcmpts | number of components (e.g. 1 for grayscale, 3 for RGB) |
| cmptparms | per-component parameters array — length must be numcmpts (see grk_image_comp) |
| clrspc | image colour space (e.g. GRK_CLRSPC_SRGB, GRK_CLRSPC_GRAY — see GRK_COLOR_SPACE) |
| alloc_data | if true, allocate int32_t data buffers for all components |
References grk::GrkImage::create().
| 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.
| plugin_path | path to an optional hardware-accelerator plugin .so; pass NULL for CPU-only operation |
| num_threads | number of worker threads (0 = use all CPUs) |
| plugin_initialized | if 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_API size_t GRK_CALLCONV grk_num_workers | ( | void | ) |
Returns the number of worker threads in the core thread pool.
References TFSingleton::num_threads().
Referenced by grk::num_workers().
| 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().
| obj | Grok object (see grk_object); passing NULL is a no-op |
obj pointer (for convenience), or NULL if obj is NULL References GRK_API, and GRK_CALLCONV.
Referenced by grk::grk_ref().
| 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.
| obj | Grok 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_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.
| info | batch job description: input/output directories, compression parameters, and per-file callback (see grk_plugin_compress_batch_info) |
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_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.
References grk::minpf_get_plugin_manager(), grk::minpf_get_symbol(), plugin_batch_decode_method_name, and pluginLoaded.
| 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_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.
| compress_parameters | compression settings (see grk_cparameters) |
| callback | completion callback (see GRK_PLUGIN_COMPRESS_USER_CALLBACK) |
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_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.
| decompress_parameters | decompression settings (see grk_decompress_parameters) |
| callback | per-image completion callback (see grk_plugin_decompress_callback) |
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_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:
Returns 0 (GRK_PLUGIN_STATE_NO_DEBUG) if no plugin is loaded.
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_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.
| init_info | device ID, license key, and optional server address (see grk_plugin_init_info) |
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_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.
| input_dir | directory containing JPEG 2000 source files |
| output_dir | directory to write decompressed output files |
| decompress_parameters | shared decompression settings for all files (see grk_decompress_parameters) |
| callback | per-image result callback (see grk_plugin_decompress_callback) |
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_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.
| info | plugin path and options (see grk_plugin_load_info) |
References grk::minpf_cleanup_plugin_manager(), grk::minpf_get_dynamic_library_extension(), grk::minpf_load_from_path(), and pluginLoaded.
Referenced by grk_initialize().
| 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_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_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_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 | compression parameters to update (see grk_cparameters) |
| encoding_matrix | row-major nb_comp×nb_comp transform matrix |
| dc_shift | per-component DC shift values (array of nb_comp int32_t) |
| nb_comp | number of image components (matrix dimension) |
References GRK_EXTENSION_MCT, GRK_IS_PART2, grk::grk_malloc(), and GRK_PROFILE_PART2.
| 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.
| msg_handlers | struct of {info, warn, error} function pointers (see grk_msg_handlers) |
References GRK_API, GRK_CALLCONV, and grk::Logger::logger_.
Referenced by grk_initialize().
| 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.
References TFSingleton::get().
Referenced by grk::executor().
| 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.
| src_stream | source stream description (must be readable, see grk_stream_params) |
| dst_stream | destination stream description (must be writable, see grk_stream_params) |
| parameters | compression / transcode settings (see grk_cparameters); box-level fields (jpx_branding, write_rreq, geoboxes_after_jp2c, resolution, etc.) are honoured |
| image | source image carrying component info and metadata (see grk_image) |
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_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.
Referenced by grk::CodeStreamCompress::init().
| GRK_API uint32_t GRK_CALLCONV grk_worker_id | ( | void | ) |
Returns the TaskFlow worker id of the calling thread.
References TFSingleton::workerId().
Referenced by grk::worker_id().