diff --git a/bindings/rust/examples/initialize_grok.rs b/bindings/rust/examples/initialize_grok.rs index ca25241d0..50bd3d785 100644 --- a/bindings/rust/examples/initialize_grok.rs +++ b/bindings/rust/examples/initialize_grok.rs @@ -45,11 +45,11 @@ fn cleanup(grk_cparameters: *mut _grk_cparameters) { } fn initialize_grk() -> Result<(), GrokError> { - let num_workers = 0; // Pass 0 for number of worker threads + let num_threads = 0; // Pass 0 for number of worker threads let verbose = true; // Example: set verbose to true unsafe { - grk_initialize(ptr::null(), num_workers, verbose); + grk_initialize(ptr::null(), num_threads, verbose); } Ok(()) diff --git a/src/lib/codec/jp2/GrkCompress.cpp b/src/lib/codec/jp2/GrkCompress.cpp index 49dda77b8..15dff5324 100644 --- a/src/lib/codec/jp2/GrkCompress.cpp +++ b/src/lib/codec/jp2/GrkCompress.cpp @@ -931,7 +931,7 @@ GrkRC GrkCompress::pluginMain(int argc, char* argv[], CompressInitParams* initPa #endif initParams->initialized = true; // load plugin but do not actually create codec - if(!grk_initialize(initParams->pluginPath, initParams->parameters.num_workers, + if(!grk_initialize(initParams->pluginPath, initParams->parameters.num_threads, initParams->parameters.verbose)) { return GrkRCFail; @@ -1204,7 +1204,7 @@ GrkRC GrkCompress::parseCommandLine(int argc, char* argv[], CompressInitParams* parameters->rate_control_algorithm = (GRK_RATE_CONTROL_ALGORITHM)rateControlAlgorithm; } if(numThreadsOpt->count() > 0) - parameters->num_workers = numThreads; + parameters->num_threads = numThreads; if(deviceIdOpt->count() > 0) parameters->device_id = deviceId; if(durationOpt->count() > 0) diff --git a/src/lib/codec/jp2/GrkDecompress.cpp b/src/lib/codec/jp2/GrkDecompress.cpp index 7238d2126..370af43f9 100644 --- a/src/lib/codec/jp2/GrkDecompress.cpp +++ b/src/lib/codec/jp2/GrkDecompress.cpp @@ -832,7 +832,7 @@ GrkRC GrkDecompress::parseCommandLine(int argc, char* argv[], DecompressInitPara if(precisionOpt->count() > 0 && !parsePrecision(precision.c_str(), parameters)) return GrkRCParseArgsFailed; if(numThreadsOpt->count() > 0) - parameters->num_workers = numThreads; + parameters->num_threads = numThreads; if(decodeRegionOpt->count() > 0) { size_t size_optarg = (size_t)strlen(decodeRegion.c_str()) + 1U; @@ -984,7 +984,7 @@ GrkRC GrkDecompress::pluginMain(int argc, char* argv[], DecompressInitParams* in #endif initParams->initialized = true; // loads plugin but does not actually create codec - grk_initialize(initParams->pluginPath, initParams->parameters.num_workers, + grk_initialize(initParams->pluginPath, initParams->parameters.num_threads, initParams->parameters.verbose); // create codec @@ -1153,8 +1153,8 @@ bool GrkDecompress::encodeInit(grk_plugin_decompress_callback_info* info) else if(cod_format == GRK_FMT_JPG || cod_format == GRK_FMT_PNG) compression_level = parameters->compression_level; if(!imageFormat->encodeInit(info->image, outfileStr, compression_level, - info->decompressor_parameters->num_workers - ? info->decompressor_parameters->num_workers + info->decompressor_parameters->num_threads + ? info->decompressor_parameters->num_threads : std::thread::hardware_concurrency())) { spdlog::error("Outfile {} not generated", outfileStr); diff --git a/src/lib/core/grok.h b/src/lib/core/grok.h index 821fde30d..cac6a4bd1 100644 --- a/src/lib/core/grok.h +++ b/src/lib/core/grok.h @@ -64,13 +64,13 @@ extern "C" { */ typedef enum _GRK_PROG_ORDER { - GRK_PROG_UNKNOWN = -1, /** unknown progression order */ - GRK_LRCP = 0, /** layer-resolution-component-precinct order */ - GRK_RLCP = 1, /** resolution-layer-component-precinct order */ - GRK_RPCL = 2, /** resolution-precinct-component-layer order */ - GRK_PCRL = 3, /** precinct-component-resolution-layer order */ - GRK_CPRL = 4, /** component-precinct-resolution-layer order */ - GRK_NUM_PROGRESSION_ORDERS = 5 /** number of possible progression orders */ + GRK_PROG_UNKNOWN = -1, /** unknown progression order */ + GRK_LRCP = 0, /** layer-resolution-component-precinct order */ + GRK_RLCP = 1, /** resolution-layer-component-precinct order */ + GRK_RPCL = 2, /** resolution-precinct-component-layer order */ + GRK_PCRL = 3, /** precinct-component-resolution-layer order */ + GRK_CPRL = 4, /** component-precinct-resolution-layer order */ + GRK_NUM_PROGRESSION_ORDERS = 5 /** number of possible progression orders */ } GRK_PROG_ORDER; /** @@ -78,15 +78,15 @@ typedef enum _GRK_PROG_ORDER */ typedef enum _GRK_COLOR_SPACE { - GRK_CLRSPC_UNKNOWN = 0, /** unknown */ - GRK_CLRSPC_SRGB = 2, /** sRGB */ - GRK_CLRSPC_GRAY = 3, /** grayscale */ - GRK_CLRSPC_SYCC = 4, /** standard YCC (YUV) */ - GRK_CLRSPC_EYCC = 5, /** extended YCC */ - GRK_CLRSPC_CMYK = 6, /** CMYK */ - GRK_CLRSPC_DEFAULT_CIE = 7, /** default CIE LAB */ - GRK_CLRSPC_CUSTOM_CIE = 8, /** custom CIE LAB */ - GRK_CLRSPC_ICC = 9 /** ICC profile */ + GRK_CLRSPC_UNKNOWN = 0, /** unknown */ + GRK_CLRSPC_SRGB = 2, /** sRGB */ + GRK_CLRSPC_GRAY = 3, /** grayscale */ + GRK_CLRSPC_SYCC = 4, /** standard YCC (YUV) */ + GRK_CLRSPC_EYCC = 5, /** extended YCC */ + GRK_CLRSPC_CMYK = 6, /** CMYK */ + GRK_CLRSPC_DEFAULT_CIE = 7, /** default CIE LAB */ + GRK_CLRSPC_CUSTOM_CIE = 8, /** custom CIE LAB */ + GRK_CLRSPC_ICC = 9 /** ICC profile */ } GRK_COLOR_SPACE; /** @@ -94,26 +94,26 @@ typedef enum _GRK_COLOR_SPACE */ typedef enum _GRK_ENUM_COLOUR_SPACE { - GRK_ENUM_CLRSPC_UNKNOWN = 0xFFFFFFFF, /* unknown */ - GRK_ENUM_CLRSPC_BILEVEL1 = 0, /* bilevel 1 */ - GRK_ENUM_CLRSPC_YCBCR1 = 1, /* YCbCr 4:2:2 */ - GRK_ENUM_CLRSPC_YCBCR2 = 3, /* YCbCr 4:4:4 */ - GRK_ENUM_CLRSPC_YCBCR3 = 4, /* YCbCr 4:2:0 */ - GRK_ENUM_CLRSPC_PHOTO_YCC = 9, /* Kodak PhotoYCC */ - GRK_ENUM_CLRSPC_CMY = 11, /* cyan, magenta, yellow */ - GRK_ENUM_CLRSPC_CMYK = 12, /* cyan, magenta, yellow, black */ - GRK_ENUM_CLRSPC_YCCK = 13, /* YCCK */ - GRK_ENUM_CLRSPC_CIE = 14, /* CIE Lab (L*, a*, b*) */ - GRK_ENUM_CLRSPC_BILEVEL2 = 15, /* bilevel 2 */ - GRK_ENUM_CLRSPC_SRGB = 16, /* sRGB */ - GRK_ENUM_CLRSPC_GRAY = 17, /* grayscale */ - GRK_ENUM_CLRSPC_SYCC = 18, /* standard YCC */ - GRK_ENUM_CLRSPC_CIEJAB = 19, /* CIEJAB */ - GRK_ENUM_CLRSPC_ESRGB = 20, /* e-sRGB */ - GRK_ENUM_CLRSPC_ROMMRGB = 21, /* Reference Output Medium Metric RGB */ - GRK_ENUM_CLRSPC_YPBPR60 = 22, /* YPbPr 60 */ - GRK_ENUM_CLRSPC_YPBPR50 = 23, /* YPbPr 50 */ - GRK_ENUM_CLRSPC_EYCC = 24, /* extended YCC */ + GRK_ENUM_CLRSPC_UNKNOWN = 0xFFFFFFFF, /* unknown */ + GRK_ENUM_CLRSPC_BILEVEL1 = 0, /* bilevel 1 */ + GRK_ENUM_CLRSPC_YCBCR1 = 1, /* YCbCr 4:2:2 */ + GRK_ENUM_CLRSPC_YCBCR2 = 3, /* YCbCr 4:4:4 */ + GRK_ENUM_CLRSPC_YCBCR3 = 4, /* YCbCr 4:2:0 */ + GRK_ENUM_CLRSPC_PHOTO_YCC = 9, /* Kodak PhotoYCC */ + GRK_ENUM_CLRSPC_CMY = 11, /* cyan, magenta, yellow */ + GRK_ENUM_CLRSPC_CMYK = 12, /* cyan, magenta, yellow, black */ + GRK_ENUM_CLRSPC_YCCK = 13, /* YCCK */ + GRK_ENUM_CLRSPC_CIE = 14, /* CIE Lab (L*, a*, b*) */ + GRK_ENUM_CLRSPC_BILEVEL2 = 15, /* bilevel 2 */ + GRK_ENUM_CLRSPC_SRGB = 16, /* sRGB */ + GRK_ENUM_CLRSPC_GRAY = 17, /* grayscale */ + GRK_ENUM_CLRSPC_SYCC = 18, /* standard YCC */ + GRK_ENUM_CLRSPC_CIEJAB = 19, /* CIEJAB */ + GRK_ENUM_CLRSPC_ESRGB = 20, /* e-sRGB */ + GRK_ENUM_CLRSPC_ROMMRGB = 21, /* Reference Output Medium Metric RGB */ + GRK_ENUM_CLRSPC_YPBPR60 = 22, /* YPbPr 60 */ + GRK_ENUM_CLRSPC_YPBPR50 = 23, /* YPbPr 50 */ + GRK_ENUM_CLRSPC_EYCC = 24, /* extended YCC */ } GRK_ENUM_COLOUR_SPACE; /** @@ -176,12 +176,12 @@ typedef void (*grk_msg_callback)(const char* msg, void* client_data); */ typedef struct _grk_msg_handlers { - grk_msg_callback info_callback; - void* info_data; - grk_msg_callback warn_callback; - void* warn_data; - grk_msg_callback error_callback; - void* error_data; + grk_msg_callback info_callback; + void* info_data; + grk_msg_callback warn_callback; + void* warn_data; + grk_msg_callback error_callback; + void* error_data; } grk_msg_handlers; /** @@ -190,7 +190,7 @@ typedef struct _grk_msg_handlers */ typedef struct _grk_object { - void* wrapper; /* opaque wrapper */ + void* wrapper; /* opaque wrapper */ } grk_object; /** @@ -199,46 +199,46 @@ typedef struct _grk_object */ typedef struct _grk_progression { - GRK_PROG_ORDER progression; /* progression */ - char progression_str[5]; /* progression as string */ - GRK_PROG_ORDER specified_compression_poc_prog; /* compression specified POC*/ - uint32_t tileno; /* tile number */ - - /** tile dimensions */ - uint32_t tx0; /* tile x0 */ - uint32_t ty0; /* tile y0 */ - uint32_t tx1; /* tile x1 */ - uint32_t ty1; /* tile y1 */ - - /** progression order bounds specified by POC */ - uint16_t comp_s; /* component start */ - uint16_t comp_e; /* component end */ - uint8_t res_s; /* resolution start */ - uint8_t res_e; /* resolution end */ - uint64_t prec_s; /* precinct start */ - uint64_t prec_e; /* precinct end */ - uint16_t lay_s; /* layer start */ - uint16_t lay_e; /* layer end */ - uint16_t tp_comp_s; /* tile part component start */ - uint16_t tp_comp_e; /* tile part component end */ - uint8_t tp_res_s; /* tile part resolution start */ - uint8_t tp_res_e; /* tile part resolution end */ - uint64_t tp_prec_e; /* tile part precinct end */ - uint16_t tp_lay_e; /* tile part layer end */ - uint32_t tp_tx_s; /* tile part x start */ - uint32_t tp_tx_e; /* tile part x end */ - uint32_t tp_ty_s; /* tile part y start */ - uint32_t tp_ty_e; /* tile part y end */ - uint32_t dx; /* dx */ - uint32_t dy; /* dy */ - - /* temporary POC variables */ - uint16_t comp_temp; /* component */ - uint8_t res_temp; /* resolution */ - uint64_t prec_temp; /* precinct */ - uint16_t lay_temp; /* layer */ - uint32_t tx0_temp; /* x0 */ - uint32_t ty0_temp; /* y0 */ + GRK_PROG_ORDER progression; /* progression */ + char progression_str[5]; /* progression as string */ + GRK_PROG_ORDER specified_compression_poc_prog; /* compression specified POC*/ + uint32_t tileno; /* tile number */ + + /** tile dimensions */ + uint32_t tx0; /* tile x0 */ + uint32_t ty0; /* tile y0 */ + uint32_t tx1; /* tile x1 */ + uint32_t ty1; /* tile y1 */ + + /** progression order bounds specified by POC */ + uint16_t comp_s; /* component start */ + uint16_t comp_e; /* component end */ + uint8_t res_s; /* resolution start */ + uint8_t res_e; /* resolution end */ + uint64_t prec_s; /* precinct start */ + uint64_t prec_e; /* precinct end */ + uint16_t lay_s; /* layer start */ + uint16_t lay_e; /* layer end */ + uint16_t tp_comp_s; /* tile part component start */ + uint16_t tp_comp_e; /* tile part component end */ + uint8_t tp_res_s; /* tile part resolution start */ + uint8_t tp_res_e; /* tile part resolution end */ + uint64_t tp_prec_e; /* tile part precinct end */ + uint16_t tp_lay_e; /* tile part layer end */ + uint32_t tp_tx_s; /* tile part x start */ + uint32_t tp_tx_e; /* tile part x end */ + uint32_t tp_ty_s; /* tile part y start */ + uint32_t tp_ty_e; /* tile part y end */ + uint32_t dx; /* dx */ + uint32_t dy; /* dy */ + + /* temporary POC variables */ + uint16_t comp_temp; /* component */ + uint8_t res_temp; /* resolution */ + uint64_t prec_temp; /* precinct */ + uint16_t lay_temp; /* layer */ + uint32_t tx0_temp; /* x0 */ + uint32_t ty0_temp; /* y0 */ } grk_progression; /** @@ -247,8 +247,8 @@ typedef struct _grk_progression */ typedef struct _grk_raw_comp_cparameters { - uint8_t dx; /** subsampling in X direction */ - uint8_t dy; /** subsampling in Y direction */ + uint8_t dx; /** subsampling in X direction */ + uint8_t dy; /** subsampling in Y direction */ } grk_raw_comp_cparameters; /** @@ -257,12 +257,12 @@ typedef struct _grk_raw_comp_cparameters */ typedef struct _grk_raw_cparameters { - uint32_t width; /** width */ - uint32_t height; /** height */ - uint16_t numcomps; /** number of components */ - uint8_t prec; /** bit depth */ - bool sgnd; /** signed/unsigned */ - grk_raw_comp_cparameters* comps; /** component parameters array */ + uint32_t width; /** width */ + uint32_t height; /** height */ + uint16_t numcomps; /** number of components */ + uint8_t prec; /** bit depth */ + bool sgnd; /** signed/unsigned */ + grk_raw_comp_cparameters* comps; /** component parameters array */ } grk_raw_cparameters; /** @@ -272,8 +272,8 @@ typedef struct _grk_raw_cparameters */ typedef enum _GRK_RATE_CONTROL_ALGORITHM { - GRK_RATE_CONTROL_BISECT, - GRK_RATE_CONTROL_PCRD_OPT + GRK_RATE_CONTROL_BISECT, + GRK_RATE_CONTROL_PCRD_OPT } GRK_RATE_CONTROL_ALGORITHM; /** @@ -281,19 +281,19 @@ typedef enum _GRK_RATE_CONTROL_ALGORITHM */ typedef enum _GRK_SUPPORTED_FILE_FMT { - GRK_FMT_UNK, /* unknown */ - GRK_FMT_J2K, /* J2K */ - GRK_FMT_JP2, /* JP2 */ - GRK_FMT_PXM, /* PXM */ - GRK_FMT_PGX, /* PGX */ - GRK_FMT_PAM, /* PAM */ - GRK_FMT_BMP, /* BMP */ - GRK_FMT_TIF, /* TIF */ - GRK_FMT_RAW, /* RAW Big Endian */ - GRK_FMT_PNG, /* PNG */ - GRK_FMT_RAWL, /* RAW Little Endian */ - GRK_FMT_JPG, /* JPG */ - GRK_FMT_YUV /* YUV */ + GRK_FMT_UNK, /* unknown */ + GRK_FMT_J2K, /* J2K */ + GRK_FMT_JP2, /* JP2 */ + GRK_FMT_PXM, /* PXM */ + GRK_FMT_PGX, /* PGX */ + GRK_FMT_PAM, /* PAM */ + GRK_FMT_BMP, /* BMP */ + GRK_FMT_TIF, /* TIF */ + GRK_FMT_RAW, /* RAW Big Endian */ + GRK_FMT_PNG, /* PNG */ + GRK_FMT_RAWL, /* RAW Little Endian */ + GRK_FMT_JPG, /* JPG */ + GRK_FMT_YUV /* YUV */ } GRK_SUPPORTED_FILE_FMT; /** @@ -301,10 +301,10 @@ typedef enum _GRK_SUPPORTED_FILE_FMT */ typedef enum _GRK_CODEC_FORMAT { - GRK_CODEC_UNK, /** unknown format */ - GRK_CODEC_J2K, /** JPEG 2000 code-stream */ - GRK_CODEC_JP2, /** JPEG 2000 JP2 file format */ - GRK_CODEC_MJ2 /** Motion JPEG 2000 */ + GRK_CODEC_UNK, /** unknown format */ + GRK_CODEC_J2K, /** JPEG 2000 code-stream */ + GRK_CODEC_JP2, /** JPEG 2000 JP2 file format */ + GRK_CODEC_MJ2 /** Motion JPEG 2000 */ } GRK_CODEC_FORMAT; #define GRK_PATH_LEN 4096 /* Grok maximum supported filename size */ @@ -314,11 +314,11 @@ typedef enum _GRK_CODEC_FORMAT * Note: range for number of decomposition levels is 0-32 * Accordingly, range for number of resolution levels is 1-33 */ -#define GRK_MAX_DECOMP_LVLS \ - 32 /* Maximum number of decomposition levels allowed by standard \ - */ +#define GRK_MAX_DECOMP_LVLS \ + 32 /* Maximum number of decomposition levels allowed by standard \ + */ #define GRK_MAXRLVLS \ - (GRK_MAX_DECOMP_LVLS + 1) /* Maximum number of resolution levels allowed by standard*/ + (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 */ /** @@ -330,9 +330,9 @@ typedef enum _GRK_CODEC_FORMAT */ typedef struct _grk_component_mapping_comp { - uint16_t component; /* component index */ - uint8_t mapping_type; /* mapping type : 1 if mapped to paletted LUT otherwise 0 */ - uint8_t palette_column; /* palette LUT column if mapped to palette */ + uint16_t component; /* component index */ + uint8_t mapping_type; /* mapping type : 1 if mapped to paletted LUT otherwise 0 */ + uint8_t palette_column; /* palette LUT column if mapped to palette */ } grk_component_mapping_comp; /** @@ -341,12 +341,12 @@ typedef struct _grk_component_mapping_comp */ typedef struct _grk_palette_data { - int32_t* lut; /* LUT */ - uint16_t num_entries; /* number of LUT entries */ - grk_component_mapping_comp* component_mapping; /* component mapping array*/ - uint8_t num_channels; /* number of channels */ - bool* channel_sign; /* channel signed array */ - uint8_t* channel_prec; /* channel precision array */ + int32_t* lut; /* LUT */ + uint16_t num_entries; /* number of LUT entries */ + grk_component_mapping_comp* component_mapping; /* component mapping array*/ + uint8_t num_channels; /* number of channels */ + bool* channel_sign; /* channel signed array */ + uint8_t* channel_prec; /* channel precision array */ } grk_palette_data; /*** @@ -359,10 +359,10 @@ typedef struct _grk_palette_data /* @brief Channel type */ typedef enum _GRK_CHANNEL_TYPE { - GRK_CHANNEL_TYPE_COLOUR = 0, /* colour */ - GRK_CHANNEL_TYPE_OPACITY = 1, /* opacity */ - GRK_CHANNEL_TYPE_PREMULTIPLIED_OPACITY = 2, /* premultiplied opacity */ - GRK_CHANNEL_TYPE_UNSPECIFIED = 65535U /* unspecified */ + GRK_CHANNEL_TYPE_COLOUR = 0, /* colour */ + GRK_CHANNEL_TYPE_OPACITY = 1, /* opacity */ + GRK_CHANNEL_TYPE_PREMULTIPLIED_OPACITY = 2, /* premultiplied opacity */ + GRK_CHANNEL_TYPE_UNSPECIFIED = 65535U /* unspecified */ } GRK_CHANNEL_TYPE; /** @@ -370,11 +370,11 @@ typedef enum _GRK_CHANNEL_TYPE */ typedef enum _GRK_CHANNEL_ASSOC { - GRK_CHANNEL_ASSOC_WHOLE_IMAGE = 0, /* whole image */ - GRK_CHANNEL_ASSOC_COLOUR_1 = 1, /* colour 1 */ - GRK_CHANNEL_ASSOC_COLOUR_2 = 2, /* colour 2 */ - GRK_CHANNEL_ASSOC_COLOUR_3 = 3, /* colour 3 */ - GRK_CHANNEL_ASSOC_UNASSOCIATED = 65535U /* unassociated */ + GRK_CHANNEL_ASSOC_WHOLE_IMAGE = 0, /* whole image */ + GRK_CHANNEL_ASSOC_COLOUR_1 = 1, /* colour 1 */ + GRK_CHANNEL_ASSOC_COLOUR_2 = 2, /* colour 2 */ + GRK_CHANNEL_ASSOC_COLOUR_3 = 3, /* colour 3 */ + GRK_CHANNEL_ASSOC_UNASSOCIATED = 65535U /* unassociated */ } GRK_CHANNEL_ASSOC; /** @@ -383,9 +383,9 @@ typedef enum _GRK_CHANNEL_ASSOC */ typedef struct _grk_channel_description { - uint16_t channel; /* channel */ - uint16_t typ; /* type */ - uint16_t asoc; /* association */ + uint16_t channel; /* channel */ + uint16_t typ; /* type */ + uint16_t asoc; /* association */ } grk_channel_description; /** @@ -394,8 +394,8 @@ typedef struct _grk_channel_description */ typedef struct _grk_channel_definition { - grk_channel_description* descriptions; /* channel description array */ - uint16_t num_channel_descriptions; /* size of channel description array */ + grk_channel_description* descriptions; /* channel description array */ + uint16_t num_channel_descriptions; /* size of channel description array */ } grk_channel_definition; /** @@ -404,10 +404,10 @@ typedef struct _grk_channel_definition */ typedef struct _grk_asoc { - uint32_t level; /* level: 0 for root level */ - const char* label; /* label */ - uint8_t* xml; /* xml */ - uint32_t xml_len; /* xml length */ + uint32_t level; /* level: 0 for root level */ + const char* label; /* label */ + uint8_t* xml; /* xml */ + uint32_t xml_len; /* xml length */ } grk_asoc; /** @@ -416,8 +416,8 @@ typedef struct _grk_asoc */ typedef enum _grk_precision_mode { - GRK_PREC_MODE_CLIP, /* clip */ - GRK_PREC_MODE_SCALE /* scale */ + GRK_PREC_MODE_CLIP, /* clip */ + GRK_PREC_MODE_SCALE /* scale */ } grk_precision_mode; /** @@ -426,8 +426,8 @@ typedef enum _grk_precision_mode */ typedef struct _grk_precision { - uint8_t prec; /* precision */ - grk_precision_mode mode; /* mode */ + uint8_t prec; /* precision */ + grk_precision_mode mode; /* mode */ } grk_precision; /** @@ -437,12 +437,12 @@ typedef struct _grk_precision */ typedef struct _grk_progression_state { - uint8_t num_resolutions; - uint16_t layers_per_resolution[33]; - uint16_t numcomps; - uint16_t comp[256]; - bool single_tile; - uint16_t tile_index; + uint8_t num_resolutions; + uint16_t layers_per_resolution[33]; + uint16_t numcomps; + uint16_t comp[256]; + bool single_tile; + uint16_t tile_index; } grk_progression_state; /** @@ -451,12 +451,12 @@ typedef struct _grk_progression_state */ typedef struct _grk_io_buf { - uint8_t* data; /* data */ - size_t offset; /* offset */ - size_t len; /* length */ - size_t alloc_len; /* allocated length */ - bool pooled; /* pooled */ - uint32_t index; /* index */ + uint8_t* data; /* data */ + size_t offset; /* offset */ + size_t len; /* length */ + size_t alloc_len; /* allocated length */ + bool pooled; /* pooled */ + uint32_t index; /* index */ } grk_io_buf; /** @@ -465,7 +465,7 @@ typedef struct _grk_io_buf */ typedef struct _grk_io_init { - uint32_t max_pooled_requests; /* max pooled requests */ + uint32_t max_pooled_requests; /* max pooled requests */ } grk_io_init; @@ -535,24 +535,25 @@ typedef void (*grk_stream_free_user_data_fn)(void* user_data); */ typedef struct _grk_stream_params { - /* 1. File */ - const char* file; /* file */ - size_t file_offset; /* offset into file */ - - /* 2. Buffer */ - uint8_t* buf; /* buffer */ - size_t buf_len; /* buffer length */ - /* length of compressed stream (set by compressor, not client) */ - size_t buf_compressed_len; /* buffer compressed length */ - - /* 3. Callback */ - grk_stream_read_fn read_fn; /* read function */ - grk_stream_write_fn write_fn; /* write function */ - grk_stream_seek_fn seek_fn; /* seek function */ - grk_stream_free_user_data_fn free_user_data_fn; /* optional */ - void* user_data; /* user data */ - size_t stream_len; /* must be set for read stream */ - size_t double_buffer_len; /* optional - default value is 1024 * 1024 */ + size_t initial_offset; /* initial offset into stream */ + + /* 1. File */ + const char* file; /* file */ + + /* 2. Buffer */ + uint8_t* buf; /* buffer */ + size_t buf_len; /* buffer length */ + /* length of compressed stream (set by compressor, not client) */ + size_t buf_compressed_len; /* buffer compressed length */ + + /* 3. Callback */ + grk_stream_read_fn read_fn; /* read function */ + grk_stream_write_fn write_fn; /* write function */ + grk_stream_seek_fn seek_fn; /* seek function */ + grk_stream_free_user_data_fn free_user_data_fn; /* optional */ + void* user_data; /* user data */ + size_t stream_len; /* must be set for read stream */ + size_t double_buffer_len; /* optional - default value is 1024 * 1024 */ } grk_stream_params; /** @@ -574,7 +575,9 @@ typedef void (*grk_decompress_callback)(void* codec, uint16_t tile_index, grk_im /** * Decompression: toggle random access markers */ +#define GRK_RANDOM_ACCESS_PLT 1 /* use PLT marker if present */ #define GRK_RANDOM_ACCESS_TLM 2 /* use TLM marker if present */ +#define GRK_RANDOM_ACCESS_PLM 4 /* use PLM marker if present */ /** * @struct grk_decompress_core_params @@ -582,28 +585,28 @@ typedef void (*grk_decompress_callback)(void* codec, uint16_t tile_index, grk_im */ typedef struct _grk_decompress_core_params { - /** - * Set the number of highest resolution levels to be discarded. - * The image resolution is effectively divided by 2 to the power of the number of discarded - * levels. The reduce factor is limited by the smallest total number of decomposition levels - * across tiles. If value is greater than zero, then the image is decoded to original dimension - * divided by 2^(reduce). If the value is equal to zero or not set, then the image is - * decompressed at full resolution - */ - uint8_t reduce; - /** - * Set the maximum number of quality layers to decompress. - * If there are fewer quality layers than the specified number, all quality layers will be - * decompressed. If value is non-zero, then only these specified layers are decompressed. - * If value is zero or not set, then all the quality layers are decompressed - */ - uint16_t layers_to_decompress; - uint32_t tile_cache_strategy; /* tile cache strategy */ - uint32_t disable_random_access_flags; /* disable random access flags */ - bool skip_alloc_composite; /* skip allocate composite image data for multi-tile */ - grk_io_pixels_callback io_buffer_callback; /* IO buffer callback */ - void* io_user_data; /* IO user data */ - grk_io_register_reclaim_callback io_register_client_callback; /* IO register client callback */ + /** + * Set the number of highest resolution levels to be discarded. + * The image resolution is effectively divided by 2 to the power of the number of discarded + * levels. The reduce factor is limited by the smallest total number of decomposition levels + * across tiles. If value is greater than zero, then the image is decoded to original dimension + * divided by 2^(reduce). If the value is equal to zero or not set, then the image is decompressed + * at full resolution + */ + uint8_t reduce; + /** + * Set the maximum number of quality layers to decompress. + * If there are fewer quality layers than the specified number, all quality layers will be + * decompressed. If value is non-zero, then only these specified layers are decompressed. + * If value is zero or not set, then all the quality layers are decompressed + */ + uint16_t layers_to_decompress; + uint32_t tile_cache_strategy; /* tile cache strategy */ + uint32_t disable_random_access_flags; /* disable random access flags */ + bool skip_alloc_composite; /* skip allocate composite image data for multi-tile */ + grk_io_pixels_callback io_buffer_callback; /* IO buffer callback */ + void* io_user_data; /* IO user data */ + grk_io_register_reclaim_callback io_register_client_callback; /* IO register client callback */ } grk_decompress_core_params; /** @@ -618,41 +621,41 @@ typedef struct _grk_decompress_core_params */ typedef struct _grk_decompress_params { - grk_decompress_core_params core; /* core parameters */ - bool asynchronous; /* if true then decompression is executed asynchronously */ - grk_decompress_callback decompress_callback; /* callback for asynchronous decompression */ - void* decompress_callback_user_data; /* user data passed to callback for asynchronous - decompression */ - char infile[GRK_PATH_LEN]; /* input file */ - char outfile[GRK_PATH_LEN]; /* output file */ - GRK_CODEC_FORMAT decod_format; /* input decode format */ - GRK_SUPPORTED_FILE_FMT cod_format; /* output code format */ - double dw_x0; /* decompress window left boundary*/ - double dw_x1; /* decompress window right boundary*/ - double dw_y0; /* decompress window top boundary*/ - double dw_y1; /* decompress window bottom boundary*/ - uint16_t dtw_x0; /* decompress tile window left boundary*/ - uint16_t dtw_x1; /* decompress tile window right boundary*/ - uint16_t dtw_y0; /* decompress tile window top boundary*/ - uint16_t dtw_y1; /* decompress tile window bottom boundary*/ - uint16_t tile_index; /* index of decompressed tile*/ - bool single_tile_decompress; /* single tile decompress */ - grk_precision* precision; /* precision array */ - uint32_t num_precision; /* size of precision array*/ - bool force_rgb; /* force output to sRGB */ - bool upsample; /* upsample components according to their dx and dy values*/ - bool split_pnm; /* split output components to different files for PNM */ - bool io_xml; /* serialize XML metedata to disk*/ - uint32_t compression; /* compression */ - uint32_t compression_level; /* compression "quality" - meaning depends on output file format */ - bool verbose; /* verbose output */ - uint32_t duration; /* duration of decompression in seconds */ - uint32_t repeats; /* number of repetitions */ - uint32_t num_workers; /* number of CPU worker threads */ - - uint32_t kernel_build_options; /* plugin OpenCL kernel build options */ - int32_t device_id; /* plugin device ID */ - void* user_data; /* plugin user data */ + grk_decompress_core_params core; /* core parameters */ + bool asynchronous; /* if true then decompression is executed asynchronously */ + grk_decompress_callback decompress_callback; /* callback for asynchronous decompression */ + void* decompress_callback_user_data; /* user data passed to callback for asynchronous + decompression */ + char infile[GRK_PATH_LEN]; /* input file */ + char outfile[GRK_PATH_LEN]; /* output file */ + GRK_CODEC_FORMAT decod_format; /* input decode format */ + GRK_SUPPORTED_FILE_FMT cod_format; /* output code format */ + double dw_x0; /* decompress window left boundary*/ + double dw_x1; /* decompress window right boundary*/ + double dw_y0; /* decompress window top boundary*/ + double dw_y1; /* decompress window bottom boundary*/ + uint16_t dtw_x0; /* decompress tile window left boundary*/ + uint16_t dtw_x1; /* decompress tile window right boundary*/ + uint16_t dtw_y0; /* decompress tile window top boundary*/ + uint16_t dtw_y1; /* decompress tile window bottom boundary*/ + uint16_t tile_index; /* index of decompressed tile*/ + bool single_tile_decompress; /* single tile decompress */ + grk_precision* precision; /* precision array */ + uint32_t num_precision; /* size of precision array*/ + bool force_rgb; /* force output to sRGB */ + bool upsample; /* upsample components according to their dx and dy values*/ + bool split_pnm; /* split output components to different files for PNM */ + bool io_xml; /* serialize XML metedata to disk*/ + uint32_t compression; /* compression */ + uint32_t compression_level; /* compression "quality" - meaning depends on output file format */ + bool verbose; /* verbose output */ + uint32_t duration; /* duration of decompression in seconds */ + uint32_t repeats; /* number of repetitions */ + uint32_t num_threads; /* number of CPU threads */ + + uint32_t kernel_build_options; /* plugin OpenCL kernel build options */ + int32_t device_id; /* plugin device ID */ + void* user_data; /* plugin user data */ } grk_decompress_parameters; /** @@ -661,20 +664,20 @@ typedef struct _grk_decompress_params */ typedef struct _grk_image_comp { - uint32_t x0; /* x offset relative to whole image */ - uint32_t y0; /* y offset relative to whole image */ - uint32_t w; /* width */ - uint32_t stride; /* stride */ - uint32_t h; /* height */ - uint8_t dx; /* horizontal separation of component samples with respect to reference grid */ - uint8_t dy; /* vertical separation of component samples with respect to reference grid */ - uint8_t prec; /* precision */ - bool sgnd; /* true if component data is signed */ - GRK_CHANNEL_TYPE type; /* channel type */ - GRK_CHANNEL_ASSOC association; /* channel association */ - uint16_t crg_x; /* CRG x */ - uint16_t crg_y; /* CRG x */ - int32_t* data; /* component data */ + uint32_t x0; /* x offset relative to whole image */ + uint32_t y0; /* y offset relative to whole image */ + uint32_t w; /* width */ + uint32_t stride; /* stride */ + uint32_t h; /* height */ + uint8_t dx; /* horizontal separation of component samples with respect to reference grid */ + uint8_t dy; /* vertical separation of component samples with respect to reference grid */ + uint8_t prec; /* precision */ + bool sgnd; /* true if component data is signed */ + GRK_CHANNEL_TYPE type; /* channel type */ + GRK_CHANNEL_ASSOC association; /* channel association */ + uint16_t crg_x; /* CRG x */ + uint16_t crg_y; /* CRG x */ + int32_t* data; /* component data */ } grk_image_comp; /** @@ -683,12 +686,12 @@ typedef struct _grk_image_comp */ typedef struct _grk_color { - uint8_t* icc_profile_buf; /* ICC profile buffer */ - uint32_t icc_profile_len; /* ICC profile length */ - char* icc_profile_name; /* ICC profile name */ - grk_channel_definition* channel_definition; /* channel definition */ - grk_palette_data* palette; /* palette */ - bool has_colour_specification_box; /* true if colour specification box present*/ + uint8_t* icc_profile_buf; /* ICC profile buffer */ + uint32_t icc_profile_len; /* ICC profile length */ + char* icc_profile_name; /* ICC profile name */ + grk_channel_definition* channel_definition; /* channel definition */ + grk_palette_data* palette; /* palette */ + bool has_colour_specification_box; /* true if colour specification box present*/ } grk_color; /** @@ -697,12 +700,12 @@ typedef struct _grk_color */ typedef struct _grk_image_meta { - grk_object obj; /* object */ - grk_color color; /* color */ - uint8_t* iptc_buf; /* IPTC buffer */ - size_t iptc_len; /* IPTC length */ - uint8_t* xmp_buf; /* XMP buffer */ - size_t xmp_len; /* XMP length */ + grk_object obj; /* object */ + grk_color color; /* color */ + uint8_t* iptc_buf; /* IPTC buffer */ + size_t iptc_len; /* IPTC length */ + uint8_t* xmp_buf; /* XMP buffer */ + size_t xmp_len; /* XMP length */ } grk_image_meta; /** @@ -713,37 +716,37 @@ typedef struct _grk_image_meta */ typedef struct _grk_image { - grk_object obj; /* object */ - uint32_t x0; /* image horizontal offset from origin of reference grid */ - uint32_t y0; /* image vertical offset from origin of reference grid */ - uint32_t x1; /* image right boundary in reference grid*/ - uint32_t y1; /* image bottom boundary in reference grid */ - uint16_t numcomps; /* number of components */ - GRK_COLOR_SPACE color_space; /* color space */ - bool palette_applied; /* true if palette applied */ - bool channel_definition_applied; /* true if channel definition applied */ - bool has_capture_resolution; /* true if capture resolution present*/ - double capture_resolution[2]; /* capture resolution */ - bool has_display_resolution; /* true if display resolution present*/ - double display_resolution[2]; /* display resolution */ - GRK_SUPPORTED_FILE_FMT decompress_fmt; /* decompress format */ - bool force_rgb; /* force RGB */ - bool upsample; /* upsample */ - grk_precision* precision; /* precision */ - uint32_t num_precision; /* number of precision */ - bool has_multiple_tiles; /* has multiple tiles */ - bool split_by_component; /* split by component */ - uint16_t decompress_num_comps; /* decompress number of components */ - uint32_t decompress_width; /* decompress width */ - uint32_t decompress_height; /* decompress height */ - uint8_t decompress_prec; /* decompress precision */ - GRK_COLOR_SPACE decompress_colour_space; /* decompress colour space */ - grk_io_buf interleaved_data; /* interleaved data */ - uint32_t rows_per_strip; /* for storage to output format */ - uint32_t rows_per_task; /* for scheduling */ - uint64_t packed_row_bytes; /* packed row bytes */ - grk_image_meta* meta; /* image meta data */ - grk_image_comp* comps; /* components array */ + grk_object obj; /* object */ + uint32_t x0; /* image horizontal offset from origin of reference grid */ + uint32_t y0; /* image vertical offset from origin of reference grid */ + uint32_t x1; /* image right boundary in reference grid*/ + uint32_t y1; /* image bottom boundary in reference grid */ + uint16_t numcomps; /* number of components */ + GRK_COLOR_SPACE color_space; /* color space */ + bool palette_applied; /* true if palette applied */ + bool channel_definition_applied; /* true if channel definition applied */ + bool has_capture_resolution; /* true if capture resolution present*/ + double capture_resolution[2]; /* capture resolution */ + bool has_display_resolution; /* true if display resolution present*/ + double display_resolution[2]; /* display resolution */ + GRK_SUPPORTED_FILE_FMT decompress_fmt; /* decompress format */ + bool force_rgb; /* force RGB */ + bool upsample; /* upsample */ + grk_precision* precision; /* precision */ + uint32_t num_precision; /* number of precision */ + bool has_multiple_tiles; /* has multiple tiles */ + bool split_by_component; /* split by component */ + uint16_t decompress_num_comps; /* decompress number of components */ + uint32_t decompress_width; /* decompress width */ + uint32_t decompress_height; /* decompress height */ + uint8_t decompress_prec; /* decompress precision */ + GRK_COLOR_SPACE decompress_colour_space; /* decompress colour space */ + grk_io_buf interleaved_data; /* interleaved data */ + uint32_t rows_per_strip; /* for storage to output format */ + uint32_t rows_per_task; /* for scheduling */ + uint64_t packed_row_bytes; /* packed row bytes */ + grk_image_meta* meta; /* image meta data */ + grk_image_comp* comps; /* components array */ } grk_image; /** @@ -752,58 +755,58 @@ typedef struct _grk_image */ typedef struct _grk_header_info { - /************************************************************ - Variables below are populated by library after reading header - *************************************************************/ - grk_image header_image; - uint32_t cblockw_init; /* nominal code block width, default 64 */ - uint32_t cblockh_init; /* nominal code block height, default 64 */ - bool irreversible; /* true if image compressed irreversibly*/ - uint8_t mct; /* multi-component transform */ - uint16_t rsiz; /* RSIZ */ - uint8_t numresolutions; /* number of resolutions */ - GRK_PROG_ORDER prog_order; /* progression order */ - /******************************************************************************** - coding style - Can be specified in main header COD segment, - tile header COD segment, and tile component COC segment. - Important note: we assume that coding style does not vary across tile components - *********************************************************************************/ - uint8_t csty; - /************************************************************************************ - code block style - Can be specified in main header COD segment, and can be overridden in a tile header. - Important note: we assume that code block style does not vary across tiles - ************************************************************************************/ - uint8_t cblk_sty; - uint32_t prcw_init[GRK_MAXRLVLS]; /* nominal precinct width */ - uint32_t prch_init[GRK_MAXRLVLS]; /* nominal precinct height */ - uint32_t tx0; /* XTOsiz */ - uint32_t ty0; /* YTOsiz */ - uint32_t t_width; /* XTsiz */ - uint32_t t_height; /* YTsiz */ - uint16_t t_grid_width; /* tile grid width */ - uint16_t t_grid_height; /* tile grid height */ - uint16_t num_layers; /* number of layers */ - uint8_t* xml_data; /* XML data - will remain valid until codec destroyed */ - size_t xml_data_len; /* XML data length */ - size_t num_comments; /* number of comments */ - char* comment[GRK_NUM_COMMENTS_SUPPORTED]; /* comment */ - uint16_t comment_len[GRK_NUM_COMMENTS_SUPPORTED]; /* comment length */ - bool is_binary_comment[GRK_NUM_COMMENTS_SUPPORTED]; /* is binary comment */ - grk_asoc asocs[GRK_NUM_ASOC_BOXES_SUPPORTED]; /* associations */ - uint32_t num_asocs; /* number of associations */ - - /************************************************************** - Variables below are set by client only if decompressing to file - **************************************************************/ - GRK_SUPPORTED_FILE_FMT decompress_fmt; /* decompress format */ - bool force_rgb; /* force RGB */ - bool upsample; /* upsample */ - grk_precision* precision; /* precision */ - uint32_t num_precision; /* number of precision */ - bool split_by_component; /* split by component */ - bool single_tile_decompress; /* single tile decompress */ + /************************************************************ + Variables below are populated by library after reading header + *************************************************************/ + grk_image header_image; + uint32_t cblockw_init; /* nominal code block width, default 64 */ + uint32_t cblockh_init; /* nominal code block height, default 64 */ + bool irreversible; /* true if image compressed irreversibly*/ + uint8_t mct; /* multi-component transform */ + uint16_t rsiz; /* RSIZ */ + uint8_t numresolutions; /* number of resolutions */ + GRK_PROG_ORDER prog_order; /* progression order */ + /******************************************************************************** + coding style + Can be specified in main header COD segment, + tile header COD segment, and tile component COC segment. + Important note: we assume that coding style does not vary across tile components + *********************************************************************************/ + uint8_t csty; + /************************************************************************************ + code block style + Can be specified in main header COD segment, and can be overridden in a tile header. + Important note: we assume that code block style does not vary across tiles + ************************************************************************************/ + uint8_t cblk_sty; + uint32_t prcw_init[GRK_MAXRLVLS]; /* nominal precinct width */ + uint32_t prch_init[GRK_MAXRLVLS]; /* nominal precinct height */ + uint32_t tx0; /* XTOsiz */ + uint32_t ty0; /* YTOsiz */ + uint32_t t_width; /* XTsiz */ + uint32_t t_height; /* YTsiz */ + uint16_t t_grid_width; /* tile grid width */ + uint16_t t_grid_height; /* tile grid height */ + uint16_t num_layers; /* number of layers */ + uint8_t* xml_data; /* XML data - will remain valid until codec destroyed */ + size_t xml_data_len; /* XML data length */ + size_t num_comments; /* number of comments */ + char* comment[GRK_NUM_COMMENTS_SUPPORTED]; /* comment */ + uint16_t comment_len[GRK_NUM_COMMENTS_SUPPORTED]; /* comment length */ + bool is_binary_comment[GRK_NUM_COMMENTS_SUPPORTED]; /* is binary comment */ + grk_asoc asocs[GRK_NUM_ASOC_BOXES_SUPPORTED]; /* associations */ + uint32_t num_asocs; /* number of associations */ + + /************************************************************** + Variables below are set by client only if decompressing to file + **************************************************************/ + GRK_SUPPORTED_FILE_FMT decompress_fmt; /* decompress format */ + bool force_rgb; /* force RGB */ + bool upsample; /* upsample */ + grk_precision* precision; /* precision */ + uint32_t num_precision; /* number of precision */ + bool split_by_component; /* split by component */ + bool single_tile_decompress; /* single tile decompress */ } grk_header_info; /** @@ -812,9 +815,9 @@ typedef struct _grk_header_info */ typedef struct _grk_plugin_pass { - double distortion_decrease; /* distortion decrease up to and including this pass */ - size_t rate; /* rate up to and including this pass */ - size_t length; /* stream length for this pass */ + double distortion_decrease; /* distortion decrease up to and including this pass */ + size_t rate; /* rate up to and including this pass */ + size_t length; /* stream length for this pass */ } grk_plugin_pass; /** @@ -823,20 +826,20 @@ typedef struct _grk_plugin_pass */ typedef struct _grk_plugin_code_block { - /************************** - debug info - **************************/ - uint32_t x0, y0, x1, y1; /* x0, y0, x1, y1 */ - unsigned int* context_stream; /* context stream */ - /***************************/ - - uint32_t num_pix; /* number of pixels */ - uint8_t* compressed_data; /* compressed data */ - uint32_t compressed_data_length; /* compressed data length */ - uint8_t num_bit_planes; /* number of bit planes */ - uint8_t num_passes; /* number of passes */ - grk_plugin_pass passes[GRK_MAX_PASSES]; /* passes */ - unsigned int sorted_index; /* sorted index */ + /************************** + debug info + **************************/ + uint32_t x0, y0, x1, y1; /* x0, y0, x1, y1 */ + unsigned int* context_stream; /* context stream */ + /***************************/ + + uint32_t num_pix; /* number of pixels */ + uint8_t* compressed_data; /* compressed data */ + uint32_t compressed_data_length; /* compressed data length */ + uint8_t num_bit_planes; /* number of bit planes */ + uint8_t num_passes; /* number of passes */ + grk_plugin_pass passes[GRK_MAX_PASSES]; /* passes */ + unsigned int sorted_index; /* sorted index */ } grk_plugin_code_block; /** @@ -845,8 +848,8 @@ typedef struct _grk_plugin_code_block */ typedef struct _grk_plugin_precinct { - uint64_t num_blocks; /* number of blocks */ - grk_plugin_code_block** blocks; /* blocks */ + uint64_t num_blocks; /* number of blocks */ + grk_plugin_code_block** blocks; /* blocks */ } grk_plugin_precinct; /** @@ -855,10 +858,10 @@ typedef struct _grk_plugin_precinct */ typedef struct _grk_plugin_band { - uint8_t orientation; /* orientation */ - uint64_t num_precincts; /* number of precincts */ - grk_plugin_precinct** precincts; /* precincts */ - float stepsize; /* stepsize */ + uint8_t orientation; /* orientation */ + uint64_t num_precincts; /* number of precincts */ + grk_plugin_precinct** precincts; /* precincts */ + float stepsize; /* stepsize */ } grk_plugin_band; /** @@ -867,9 +870,9 @@ typedef struct _grk_plugin_band */ typedef struct _grk_plugin_resolution { - uint8_t level; /* level */ - uint8_t num_bands; /* number of bands */ - grk_plugin_band** band; /* band */ + uint8_t level; /* level */ + uint8_t num_bands; /* number of bands */ + grk_plugin_band** band; /* band */ } grk_plugin_resolution; /** @@ -878,8 +881,8 @@ typedef struct _grk_plugin_resolution */ typedef struct grk_plugin_tile_component { - uint8_t numresolutions; /* number of resolutions */ - grk_plugin_resolution** resolutions; /* resolutions */ + uint8_t numresolutions; /* number of resolutions */ + grk_plugin_resolution** resolutions; /* resolutions */ } grk_plugin_tile_component; #define GRK_DECODE_HEADER (1 << 0) @@ -887,9 +890,8 @@ typedef struct grk_plugin_tile_component #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_DECODE_ALL \ + (GRK_PLUGIN_DECODE_CLEAN | GRK_DECODE_HEADER | GRK_DECODE_T2 | GRK_DECODE_T1 | GRK_DECODE_POST_T1) /** * @struct grk_plugin_tile @@ -897,9 +899,9 @@ typedef struct grk_plugin_tile_component */ typedef struct _grk_plugin_tile { - uint32_t decompress_flags; /* decompress flags */ - uint16_t num_components; /* number of components */ - grk_plugin_tile_component** tile_components; /* tile components */ + uint32_t decompress_flags; /* decompress flags */ + uint16_t num_components; /* number of components */ + grk_plugin_tile_component** tile_components; /* tile components */ } grk_plugin_tile; /** @@ -911,10 +913,10 @@ GRK_API const char* GRK_CALLCONV grk_version(void); * @brief Initializes Grok library * Must be called before any Grok API calls * @param pluginPath path to plugin - * @param num_workers number of worker threads to use for compress/decompress + * @param num_threads number of threads to use for compress/decompress * @param verbose true if verbose output requested */ -GRK_API bool GRK_CALLCONV grk_initialize(const char* pluginPath, uint32_t num_workers, +GRK_API bool GRK_CALLCONV grk_initialize(const char* pluginPath, uint32_t num_threads, bool verbose); /** @@ -1078,11 +1080,11 @@ GRK_API bool GRK_CALLCONV grk_decompress_tile(grk_object* codec, uint16_t tile_i */ typedef struct _grk_synthesis { - bool do_synthesis; /* do synthesis */ - uint32_t width; /* width */ - uint32_t height; /* height */ - uint8_t precision; /* precision */ - uint16_t numcomps; /* number of components */ + bool do_synthesis; /* do synthesis */ + uint32_t width; /* width */ + uint32_t height; /* height */ + uint8_t precision; /* precision */ + uint16_t numcomps; /* number of components */ } grk_synthesis; /** @@ -1091,93 +1093,93 @@ typedef struct _grk_synthesis */ typedef struct _grk_cparameters { - bool tile_size_on; /* tile size on */ - uint32_t tx0; /* XTOsiz */ - uint32_t ty0; /* YTOsiz */ - uint32_t t_width; /* XTsiz */ - uint32_t t_height; /* YTsiz */ - uint16_t numlayers; /* number of layers */ - /** rate control allocation by rate/distortion curve */ - bool allocation_by_rate_distortion; /* allocation by rate distortion */ - /** layers rates expressed as compression ratios. - * They might be subsequently limited by the max_cs_size field */ - double layer_rate[GRK_MAX_LAYERS]; /* layer rate */ - bool allocation_by_quality; /* rate control allocation by fixed_PSNR quality */ - double layer_distortion[GRK_MAX_LAYERS]; /* layer PSNR values */ - char* comment[GRK_NUM_COMMENTS_SUPPORTED]; /* comment */ - uint16_t comment_len[GRK_NUM_COMMENTS_SUPPORTED]; /* comment length */ - bool is_binary_comment[GRK_NUM_COMMENTS_SUPPORTED]; /* is binary comment */ - size_t num_comments; /* number of comments */ - uint8_t csty; /* coding style */ - uint8_t numgbits; /* number of guard bits */ - GRK_PROG_ORDER prog_order; /* progression order (default LRCP)*/ - grk_progression progression[GRK_MAXRLVLS]; /* progression array */ - uint32_t numpocs; /* number of progression order changes (POCs) */ - uint8_t numresolution; /* number of resolutions */ - uint32_t cblockw_init; /* nominal code block width (default 64) */ - uint32_t cblockh_init; /* nominal code block height (default 64) */ - uint8_t cblk_sty; /* code block style */ - bool irreversible; /* true if irreversible compression enabled, default false */ - /** region of interest: affected component in [0..3]; - * -1 indicates no ROI */ - int32_t roi_compno; /* ROI component number */ - uint32_t roi_shift; /* ROI upshift */ - /* number of precinct size specifications */ - uint32_t res_spec; /* res spec */ - uint32_t prcw_init[GRK_MAXRLVLS]; /* nominal precinct width */ - uint32_t prch_init[GRK_MAXRLVLS]; /* nominal precinct height */ - char infile[GRK_PATH_LEN]; /* input file */ - char outfile[GRK_PATH_LEN]; /* output file */ - uint32_t image_offset_x0; /* image offset x0 */ - uint32_t image_offset_y0; /* image offset y0 */ - uint8_t subsampling_dx; /* subsampling dx */ - uint8_t subsampling_dy; /* subsampling dy */ - GRK_SUPPORTED_FILE_FMT decod_format; /* input decode format */ - GRK_SUPPORTED_FILE_FMT cod_format; /* output code format */ - grk_raw_cparameters raw_cp; /* raw parameters */ - bool enable_tile_part_generation; /* enable tile part generation */ - uint8_t new_tile_part_progression_divider; /* new tile part progression divider */ - uint8_t mct; /* MCT */ - /** Naive implementation of MCT restricted to a single reversible array based - compressing without offset concerning all the components. */ - void* mct_data; /* MCT data */ - /** - * Maximum size (in bytes) for the whole code stream. - * If equal to zero, code stream size limitation is not considered - * If it does not comply with layer_rate, max_cs_size prevails - * and a warning is issued. - * */ - uint64_t max_cs_size; /* max code stream size */ - /** - * Maximum size (in bytes) for each component. - * If == 0, component size limitation is not considered - * */ - uint64_t max_comp_size; /* max component size */ - /** RSIZ value - To be used to combine GRK_PROFILE_*, GRK_EXTENSION_* and (sub)levels values. */ - uint16_t rsiz; /* RSIZ */ - uint16_t framerate; /* frame rate */ - - bool write_capture_resolution_from_file; /* write capture resolution from file */ - double capture_resolution_from_file[2]; /* capture resolution from file */ - bool write_capture_resolution; /* write capture resolution */ - double capture_resolution[2]; /* capture resolution */ - bool write_display_resolution; /* write display resolution */ - double display_resolution[2]; /* display resolution */ - - bool apply_icc; /* apply ICC */ - - GRK_RATE_CONTROL_ALGORITHM rate_control_algorithm; /* rate control algorithm */ - uint32_t num_workers; /* number of worker threads */ - int32_t device_id; /* device ID */ - uint32_t duration; /* duration seconds */ - uint32_t kernel_build_options; /* kernel build options */ - uint32_t repeats; /* repeats */ - bool write_plt; /* write PLT */ - bool write_tlm; /* write TLM */ - bool verbose; /* verbose */ - bool shared_memory_interface; /* shared memory interface */ - grk_synthesis synth; /* synthesis */ + bool tile_size_on; /* tile size on */ + uint32_t tx0; /* XTOsiz */ + uint32_t ty0; /* YTOsiz */ + uint32_t t_width; /* XTsiz */ + uint32_t t_height; /* YTsiz */ + uint16_t numlayers; /* number of layers */ + /** rate control allocation by rate/distortion curve */ + bool allocation_by_rate_distortion; /* allocation by rate distortion */ + /** layers rates expressed as compression ratios. + * They might be subsequently limited by the max_cs_size field */ + double layer_rate[GRK_MAX_LAYERS]; /* layer rate */ + bool allocation_by_quality; /* rate control allocation by fixed_PSNR quality */ + double layer_distortion[GRK_MAX_LAYERS]; /* layer PSNR values */ + char* comment[GRK_NUM_COMMENTS_SUPPORTED]; /* comment */ + uint16_t comment_len[GRK_NUM_COMMENTS_SUPPORTED]; /* comment length */ + bool is_binary_comment[GRK_NUM_COMMENTS_SUPPORTED]; /* is binary comment */ + size_t num_comments; /* number of comments */ + uint8_t csty; /* coding style */ + uint8_t numgbits; /* number of guard bits */ + GRK_PROG_ORDER prog_order; /* progression order (default LRCP)*/ + grk_progression progression[GRK_MAXRLVLS]; /* progression array */ + uint32_t numpocs; /* number of progression order changes (POCs) */ + uint8_t numresolution; /* number of resolutions */ + uint32_t cblockw_init; /* nominal code block width (default 64) */ + uint32_t cblockh_init; /* nominal code block height (default 64) */ + uint8_t cblk_sty; /* code block style */ + bool irreversible; /* true if irreversible compression enabled, default false */ + /** region of interest: affected component in [0..3]; + * -1 indicates no ROI */ + int32_t roi_compno; /* ROI component number */ + uint32_t roi_shift; /* ROI upshift */ + /* number of precinct size specifications */ + uint32_t res_spec; /* res spec */ + uint32_t prcw_init[GRK_MAXRLVLS]; /* nominal precinct width */ + uint32_t prch_init[GRK_MAXRLVLS]; /* nominal precinct height */ + char infile[GRK_PATH_LEN]; /* input file */ + char outfile[GRK_PATH_LEN]; /* output file */ + uint32_t image_offset_x0; /* image offset x0 */ + uint32_t image_offset_y0; /* image offset y0 */ + uint8_t subsampling_dx; /* subsampling dx */ + uint8_t subsampling_dy; /* subsampling dy */ + GRK_SUPPORTED_FILE_FMT decod_format; /* input decode format */ + GRK_SUPPORTED_FILE_FMT cod_format; /* output code format */ + grk_raw_cparameters raw_cp; /* raw parameters */ + bool enable_tile_part_generation; /* enable tile part generation */ + uint8_t new_tile_part_progression_divider; /* new tile part progression divider */ + uint8_t mct; /* MCT */ + /** Naive implementation of MCT restricted to a single reversible array based + compressing without offset concerning all the components. */ + void* mct_data; /* MCT data */ + /** + * Maximum size (in bytes) for the whole code stream. + * If equal to zero, code stream size limitation is not considered + * If it does not comply with layer_rate, max_cs_size prevails + * and a warning is issued. + * */ + uint64_t max_cs_size; /* max code stream size */ + /** + * Maximum size (in bytes) for each component. + * If == 0, component size limitation is not considered + * */ + uint64_t max_comp_size; /* max component size */ + /** RSIZ value + To be used to combine GRK_PROFILE_*, GRK_EXTENSION_* and (sub)levels values. */ + uint16_t rsiz; /* RSIZ */ + uint16_t framerate; /* frame rate */ + + bool write_capture_resolution_from_file; /* write capture resolution from file */ + double capture_resolution_from_file[2]; /* capture resolution from file */ + bool write_capture_resolution; /* write capture resolution */ + double capture_resolution[2]; /* capture resolution */ + bool write_display_resolution; /* write display resolution */ + double display_resolution[2]; /* display resolution */ + + bool apply_icc; /* apply ICC */ + + GRK_RATE_CONTROL_ALGORITHM rate_control_algorithm; /* rate control algorithm */ + uint32_t num_threads; /* number of threads */ + int32_t device_id; /* device ID */ + uint32_t duration; /* duration seconds */ + uint32_t kernel_build_options; /* kernel build options */ + uint32_t repeats; /* repeats */ + bool write_plt; /* write PLT */ + bool write_tlm; /* write TLM */ + bool verbose; /* verbose */ + bool shared_memory_interface; /* shared memory interface */ + grk_synthesis synth; /* synthesis */ } grk_cparameters; /** @@ -1285,21 +1287,21 @@ GRK_API bool GRK_CALLCONV grk_set_MCT(grk_cparameters* parameters, float* encodi #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 */ + 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 */ + 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 */ + 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 */ + 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 */ + 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 */ @@ -1367,16 +1369,16 @@ GRK_API bool GRK_CALLCONV grk_set_MCT(grk_cparameters* parameters, float* encodi */ #define GRK_GET_IMF_OR_BROADCAST_PROFILE(v) \ - ((v) & 0x0f00) /** Extract profile without mainlevel/sublevel */ + ((v) & 0x0f00) /** Extract profile without mainlevel/sublevel */ #define GRK_LEVEL_MAX 11U /** Maximum (main) level */ #define GRK_GET_LEVEL(v) ((v) & 0xf) /** Extract (main) level */ /******* BROADCAST **********************************************************/ -#define GRK_IS_BROADCAST(v) \ - (((v) >= GRK_PROFILE_BC_SINGLE) && ((v) <= (GRK_PROFILE_BC_MULTI_R | 0x000b)) && \ - (((v) & 0xf) <= 0xb)) +#define GRK_IS_BROADCAST(v) \ + (((v) >= GRK_PROFILE_BC_SINGLE) && ((v) <= (GRK_PROFILE_BC_MULTI_R | 0x000b)) && \ + (((v) & 0xf) <= 0xb)) /* Maximum component sampling Rate (Mbits/sec) per level */ #define GRK_BROADCAST_LEVEL_1_MBITSSEC 200U /** Mbits/sec for level 1 */ @@ -1405,9 +1407,9 @@ GRK_API bool GRK_CALLCONV grk_set_MCT(grk_cparameters* parameters, float* encodi /********IMF *****************************************************************/ -#define GRK_IS_IMF(v) \ - (((v) >= GRK_PROFILE_IMF_2K) && ((v) <= (GRK_PROFILE_IMF_8K_R | 0x009b)) && \ - (((v) & 0xf) <= 0xb) && (((v) & 0xf0) <= 0x90)) +#define GRK_IS_IMF(v) \ + (((v) >= GRK_PROFILE_IMF_2K) && ((v) <= (GRK_PROFILE_IMF_8K_R | 0x009b)) && \ + (((v) & 0xf) <= 0xb) && (((v) & 0xf0) <= 0x90)) /* Maximum component sampling rate (MSamples/sec) per main level */ #define GRK_IMF_MAINLEVEL_1_MSAMPLESSEC 65U /** MSamples/sec for main level 1 */ @@ -1468,8 +1470,8 @@ GRK_API bool GRK_CALLCONV grk_set_MCT(grk_cparameters* parameters, float* encodi */ typedef struct _grk_plugin_load_info { - const char* pluginPath; /* plugin path */ - bool verbose; /* verbose */ + const char* pluginPath; /* plugin path */ + bool verbose; /* verbose */ } grk_plugin_load_info; /** @@ -1520,10 +1522,10 @@ GRK_API uint32_t GRK_CALLCONV grk_plugin_get_debug_state(); */ typedef struct _grk_plugin_init_info { - int32_t device_id; /* device ID */ - bool verbose; /* verbose */ - const char* license; /* license */ - const char* server; /* server */ + int32_t device_id; /* device ID */ + bool verbose; /* verbose */ + const char* license; /* license */ + const char* server; /* server */ } grk_plugin_init_info; /** @@ -1538,15 +1540,15 @@ GRK_API bool GRK_CALLCONV grk_plugin_init(grk_plugin_init_info init_info); */ typedef struct grk_plugin_compress_user_callback_info { - const char* input_file_name; /* input file name */ - bool output_file_name_is_relative; /* output file name is relative */ - const char* output_file_name; /* output file name */ - grk_cparameters* compressor_parameters; /* compressor parameters */ - grk_image* image; /* image */ - grk_plugin_tile* tile; /* tile */ - grk_stream_params stream_params; /* stream parameters */ - unsigned int error_code; /* error code */ - bool transfer_exif_tags; /* transfer EXIF tags */ + const char* input_file_name; /* input file name */ + bool output_file_name_is_relative; /* output file name is relative */ + const char* output_file_name; /* output file name */ + grk_cparameters* compressor_parameters; /* compressor parameters */ + grk_image* image; /* image */ + grk_plugin_tile* tile; /* tile */ + grk_stream_params stream_params; /* stream parameters */ + unsigned int error_code; /* error code */ + bool transfer_exif_tags; /* transfer EXIF tags */ } grk_plugin_compress_user_callback_info; /** @@ -1560,10 +1562,10 @@ typedef uint64_t (*GRK_PLUGIN_COMPRESS_USER_CALLBACK)(grk_plugin_compress_user_c */ typedef struct grk_plugin_compress_batch_info { - const char* input_dir; /* input directory */ - const char* output_dir; /* output directory */ - grk_cparameters* compress_parameters; /* compress parameters */ - GRK_PLUGIN_COMPRESS_USER_CALLBACK callback; /* callback */ + const char* input_dir; /* input directory */ + const char* output_dir; /* output directory */ + grk_cparameters* compress_parameters; /* compress parameters */ + GRK_PLUGIN_COMPRESS_USER_CALLBACK callback; /* callback */ } grk_plugin_compress_batch_info; /** @@ -1603,25 +1605,25 @@ typedef int (*GROK_INIT_DECOMPRESSORS)(grk_header_info* header_info, grk_image* */ typedef struct _grk_plugin_decompress_callback_info { - size_t device_id; /* device ID */ - GROK_INIT_DECOMPRESSORS init_decompressors_func; /* init decompressors func */ - const char* input_file_name; /* input file name */ - const char* output_file_name; /* output file name */ - /* input file format 0: J2K, 1: JP2 */ - GRK_CODEC_FORMAT decod_format; /* decode format */ - /* output file format 0: PGX, 1: PxM, 2: BMP etc */ - GRK_SUPPORTED_FILE_FMT cod_format; /* code format */ - grk_object* codec; /* codec */ - grk_header_info header_info; /* header info */ - grk_decompress_parameters* decompressor_parameters; /* decompressor parameters */ - grk_image* image; /* image */ - bool plugin_owns_image; /* plugin owns image */ - grk_plugin_tile* tile; /* tile */ - unsigned int error_code; /* error code */ - uint32_t decompress_flags; /* decompress flags */ - uint32_t full_image_x0; /* full image x0 */ - uint32_t full_image_y0; /* full image y0 */ - void* user_data; /* user data */ + size_t device_id; /* device ID */ + GROK_INIT_DECOMPRESSORS init_decompressors_func; /* init decompressors func */ + const char* input_file_name; /* input file name */ + const char* output_file_name; /* output file name */ + /* input file format 0: J2K, 1: JP2 */ + GRK_CODEC_FORMAT decod_format; /* decode format */ + /* output file format 0: PGX, 1: PxM, 2: BMP etc */ + GRK_SUPPORTED_FILE_FMT cod_format; /* code format */ + grk_object* codec; /* codec */ + grk_header_info header_info; /* header info */ + grk_decompress_parameters* decompressor_parameters; /* decompressor parameters */ + grk_image* image; /* image */ + bool plugin_owns_image; /* plugin owns image */ + grk_plugin_tile* tile; /* tile */ + unsigned int error_code; /* error code */ + uint32_t decompress_flags; /* decompress flags */ + uint32_t full_image_x0; /* full image x0 */ + uint32_t full_image_y0; /* full image y0 */ + void* user_data; /* user data */ } grk_plugin_decompress_callback_info; /**