openjpeg_sys/
ffi.rs

1/* automatically generated by rust-bindgen 0.63.0 */
2use std::os::raw::*;
3pub const OPJ_TRUE: u32 = 1;
4pub const OPJ_FALSE: u32 = 0;
5pub const OPJ_HAVE_STDINT_H: u32 = 1;
6pub const OPJ_VERSION_MAJOR: u32 = 2;
7pub const OPJ_VERSION_MINOR: u32 = 4;
8pub const OPJ_VERSION_BUILD: u32 = 0;
9pub const OPJ_PATH_LEN: u32 = 4096;
10pub const OPJ_J2K_MAXRLVLS: u32 = 33;
11pub const OPJ_J2K_MAXBANDS: u32 = 97;
12pub const OPJ_J2K_DEFAULT_NB_SEGS: u32 = 10;
13pub const OPJ_J2K_STREAM_CHUNK_SIZE: u32 = 1048576;
14pub const OPJ_J2K_DEFAULT_HEADER_SIZE: u32 = 1000;
15pub const OPJ_J2K_MCC_DEFAULT_NB_RECORDS: u32 = 10;
16pub const OPJ_J2K_MCT_DEFAULT_NB_RECORDS: u32 = 10;
17pub const OPJ_IMG_INFO: u32 = 1;
18pub const OPJ_J2K_MH_INFO: u32 = 2;
19pub const OPJ_J2K_TH_INFO: u32 = 4;
20pub const OPJ_J2K_TCH_INFO: u32 = 8;
21pub const OPJ_J2K_MH_IND: u32 = 16;
22pub const OPJ_J2K_TH_IND: u32 = 32;
23pub const OPJ_JP2_INFO: u32 = 128;
24pub const OPJ_JP2_IND: u32 = 256;
25pub const OPJ_PROFILE_NONE: u32 = 0;
26pub const OPJ_PROFILE_0: u32 = 1;
27pub const OPJ_PROFILE_1: u32 = 2;
28pub const OPJ_PROFILE_PART2: u32 = 32768;
29pub const OPJ_PROFILE_CINEMA_2K: u32 = 3;
30pub const OPJ_PROFILE_CINEMA_4K: u32 = 4;
31pub const OPJ_PROFILE_CINEMA_S2K: u32 = 5;
32pub const OPJ_PROFILE_CINEMA_S4K: u32 = 6;
33pub const OPJ_PROFILE_CINEMA_LTS: u32 = 7;
34pub const OPJ_PROFILE_BC_SINGLE: u32 = 256;
35pub const OPJ_PROFILE_BC_MULTI: u32 = 512;
36pub const OPJ_PROFILE_BC_MULTI_R: u32 = 768;
37pub const OPJ_PROFILE_IMF_2K: u32 = 1024;
38pub const OPJ_PROFILE_IMF_4K: u32 = 1280;
39pub const OPJ_PROFILE_IMF_8K: u32 = 1536;
40pub const OPJ_PROFILE_IMF_2K_R: u32 = 1792;
41pub const OPJ_PROFILE_IMF_4K_R: u32 = 2048;
42pub const OPJ_PROFILE_IMF_8K_R: u32 = 2304;
43pub const OPJ_EXTENSION_NONE: u32 = 0;
44pub const OPJ_EXTENSION_MCT: u32 = 256;
45pub const OPJ_IMF_MAINLEVEL_MAX: u32 = 11;
46pub const OPJ_IMF_MAINLEVEL_1_MSAMPLESEC: u32 = 65;
47pub const OPJ_IMF_MAINLEVEL_2_MSAMPLESEC: u32 = 130;
48pub const OPJ_IMF_MAINLEVEL_3_MSAMPLESEC: u32 = 195;
49pub const OPJ_IMF_MAINLEVEL_4_MSAMPLESEC: u32 = 260;
50pub const OPJ_IMF_MAINLEVEL_5_MSAMPLESEC: u32 = 520;
51pub const OPJ_IMF_MAINLEVEL_6_MSAMPLESEC: u32 = 1200;
52pub const OPJ_IMF_MAINLEVEL_7_MSAMPLESEC: u32 = 2400;
53pub const OPJ_IMF_MAINLEVEL_8_MSAMPLESEC: u32 = 4800;
54pub const OPJ_IMF_MAINLEVEL_9_MSAMPLESEC: u32 = 9600;
55pub const OPJ_IMF_MAINLEVEL_10_MSAMPLESEC: u32 = 19200;
56pub const OPJ_IMF_MAINLEVEL_11_MSAMPLESEC: u32 = 38400;
57pub const OPJ_IMF_SUBLEVEL_1_MBITSSEC: u32 = 200;
58pub const OPJ_IMF_SUBLEVEL_2_MBITSSEC: u32 = 400;
59pub const OPJ_IMF_SUBLEVEL_3_MBITSSEC: u32 = 800;
60pub const OPJ_IMF_SUBLEVEL_4_MBITSSEC: u32 = 1600;
61pub const OPJ_IMF_SUBLEVEL_5_MBITSSEC: u32 = 3200;
62pub const OPJ_IMF_SUBLEVEL_6_MBITSSEC: u32 = 6400;
63pub const OPJ_IMF_SUBLEVEL_7_MBITSSEC: u32 = 12800;
64pub const OPJ_IMF_SUBLEVEL_8_MBITSSEC: u32 = 25600;
65pub const OPJ_IMF_SUBLEVEL_9_MBITSSEC: u32 = 51200;
66pub const OPJ_CINEMA_24_CS: u32 = 1302083;
67pub const OPJ_CINEMA_48_CS: u32 = 651041;
68pub const OPJ_CINEMA_24_COMP: u32 = 1041666;
69pub const OPJ_CINEMA_48_COMP: u32 = 520833;
70pub const OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG: u32 = 1;
71pub const OPJ_DPARAMETERS_DUMP_FLAG: u32 = 2;
72pub const OPJ_STREAM_READ: u32 = 1;
73pub const OPJ_STREAM_WRITE: u32 = 0;
74pub type OPJ_BOOL = c_int;
75pub type OPJ_CHAR = c_char;
76pub type OPJ_FLOAT32 = f32;
77pub type OPJ_BYTE = u8;
78pub type OPJ_UINT16 = u16;
79pub type OPJ_INT32 = i32;
80pub type OPJ_UINT32 = u32;
81pub type OPJ_UINT64 = u64;
82pub type OPJ_OFF_T = i64;
83use libc::FILE;
84pub type OPJ_SIZE_T = usize;
85#[repr(u32)]
86/// DEPRECATED: use RSIZ, `OPJ_PROFILE_*` and `OPJ_EXTENSION_*` instead
87/// Rsiz Capabilities
88#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
89pub enum RSIZ_CAPABILITIES {
90    OPJ_STD_RSIZ = 0,
91    /// Standard JPEG2000 profile
92    OPJ_CINEMA2K = 3,
93    /// Profile name for a 2K image
94    OPJ_CINEMA4K = 4,
95    /// Profile name for a 4K image
96    OPJ_MCT = 33024,
97}
98/// DEPRECATED: use RSIZ, `OPJ_PROFILE_*` and `OPJ_EXTENSION_*` instead
99/// Rsiz Capabilities
100pub use self::RSIZ_CAPABILITIES as OPJ_RSIZ_CAPABILITIES;
101#[repr(u32)]
102/// DEPRECATED: use RSIZ, `OPJ_PROFILE_*` and `OPJ_EXTENSION_*` instead
103/// Digital cinema operation mode
104#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
105pub enum CINEMA_MODE {
106    OPJ_OFF = 0,
107    /// Not Digital Cinema
108    OPJ_CINEMA2K_24 = 1,
109    /// 2K Digital Cinema at 24 fps
110    OPJ_CINEMA2K_48 = 2,
111    /// 2K Digital Cinema at 48 fps
112    OPJ_CINEMA4K_24 = 3,
113}
114/// DEPRECATED: use RSIZ, `OPJ_PROFILE_*` and `OPJ_EXTENSION_*` instead
115/// Digital cinema operation mode
116pub use self::CINEMA_MODE as OPJ_CINEMA_MODE;
117#[repr(i32)]
118/// Progression order
119#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
120pub enum PROG_ORDER {
121    ///< place-holder
122    OPJ_PROG_UNKNOWN = -1,
123    ///< layer-resolution-component-precinct order
124    OPJ_LRCP = 0,
125    ///< resolution-layer-component-precinct order
126    OPJ_RLCP = 1,
127    ///< resolution-precinct-component-layer order
128    OPJ_RPCL = 2,
129    ///< precinct-component-resolution-layer order
130    OPJ_PCRL = 3,
131    ///< component-precinct-resolution-layer order
132    OPJ_CPRL = 4,
133}
134/// Progression order
135pub use self::PROG_ORDER as OPJ_PROG_ORDER;
136#[repr(i32)]
137/// Supported image color spaces
138#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
139pub enum COLOR_SPACE {
140    ///< not supported by the library
141    OPJ_CLRSPC_UNKNOWN = -1,
142    ///< not specified in the codestream
143    OPJ_CLRSPC_UNSPECIFIED = 0,
144    ///< sRGB
145    OPJ_CLRSPC_SRGB = 1,
146    ///< grayscale
147    OPJ_CLRSPC_GRAY = 2,
148    ///< YUV
149    OPJ_CLRSPC_SYCC = 3,
150    ///< e-YCC
151    OPJ_CLRSPC_EYCC = 4,
152    ///< CMYK
153    OPJ_CLRSPC_CMYK = 5,
154}
155/// Supported image color spaces
156pub use self::COLOR_SPACE as OPJ_COLOR_SPACE;
157#[repr(i32)]
158/// Supported codec
159#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
160pub enum CODEC_FORMAT {
161    ///< place-holder
162    OPJ_CODEC_UNKNOWN = -1,
163    ///< JPEG-2000 codestream : read/write
164    OPJ_CODEC_J2K = 0,
165    ///< JPT-stream (JPEG 2000, JPIP) : read only
166    OPJ_CODEC_JPT = 1,
167    ///< JP2 file format : read/write
168    OPJ_CODEC_JP2 = 2,
169    ///< JPP-stream (JPEG 2000, JPIP) : to be coded
170    OPJ_CODEC_JPP = 3,
171    ///< JPX file format (JPEG 2000 Part-2) : to be coded
172    OPJ_CODEC_JPX = 4,
173}
174/// Supported codec
175pub use self::CODEC_FORMAT as OPJ_CODEC_FORMAT;
176/// Callback function prototype for events
177/// * `msg` —                Event message
178/// * `client_data` —        Client object where will be return the event message
179pub type opj_msg_callback = ::std::option::Option<
180    unsafe extern "C" fn(
181        msg: *const c_char,
182        client_data: *mut c_void,
183    ),
184>;
185/// Progression order changes
186///
187#[repr(C)]
188#[derive(Debug, Copy, Clone)]
189pub struct opj_poc {
190    /// Resolution num start, Component num start, given by POC
191    pub resno0: OPJ_UINT32,
192    /// Resolution num start, Component num start, given by POC
193    pub compno0: OPJ_UINT32,
194    /// Layer num end,Resolution num end, Component num end, given by POC
195    pub layno1: OPJ_UINT32,
196    /// Layer num end,Resolution num end, Component num end, given by POC
197    pub resno1: OPJ_UINT32,
198    /// Layer num end,Resolution num end, Component num end, given by POC
199    pub compno1: OPJ_UINT32,
200    /// Layer num start,Precinct num start, Precinct num end
201    pub layno0: OPJ_UINT32,
202    /// Layer num start,Precinct num start, Precinct num end
203    pub precno0: OPJ_UINT32,
204    /// Layer num start,Precinct num start, Precinct num end
205    pub precno1: OPJ_UINT32,
206    /// Progression order enum
207    pub prg1: OPJ_PROG_ORDER,
208    /// Progression order enum
209    pub prg: OPJ_PROG_ORDER,
210    /// Progression order string
211    pub progorder: [OPJ_CHAR; 5usize],
212    /// Tile number (starting at 1)
213    pub tile: OPJ_UINT32,
214    /// Start and end values for Tile width and height
215    pub tx0: OPJ_INT32,
216    /// Start and end values for Tile width and height
217    pub tx1: OPJ_INT32,
218    /// Start and end values for Tile width and height
219    pub ty0: OPJ_INT32,
220    /// Start and end values for Tile width and height
221    pub ty1: OPJ_INT32,
222    /// Start value, initialised in `pi_initialise_encode`
223    pub layS: OPJ_UINT32,
224    /// Start value, initialised in `pi_initialise_encode`
225    pub resS: OPJ_UINT32,
226    /// Start value, initialised in `pi_initialise_encode`
227    pub compS: OPJ_UINT32,
228    /// Start value, initialised in `pi_initialise_encode`
229    pub prcS: OPJ_UINT32,
230    /// End value, initialised in `pi_initialise_encode`
231    pub layE: OPJ_UINT32,
232    /// End value, initialised in `pi_initialise_encode`
233    pub resE: OPJ_UINT32,
234    /// End value, initialised in `pi_initialise_encode`
235    pub compE: OPJ_UINT32,
236    /// End value, initialised in `pi_initialise_encode`
237    pub prcE: OPJ_UINT32,
238    /// Start and end values of Tile width and height, initialised in `pi_initialise_encode`
239    pub txS: OPJ_UINT32,
240    /// Start and end values of Tile width and height, initialised in `pi_initialise_encode`
241    pub txE: OPJ_UINT32,
242    /// Start and end values of Tile width and height, initialised in `pi_initialise_encode`
243    pub tyS: OPJ_UINT32,
244    /// Start and end values of Tile width and height, initialised in `pi_initialise_encode`
245    pub tyE: OPJ_UINT32,
246    /// Start and end values of Tile width and height, initialised in `pi_initialise_encode`
247    pub dx: OPJ_UINT32,
248    /// Start and end values of Tile width and height, initialised in `pi_initialise_encode`
249    pub dy: OPJ_UINT32,
250    /// Temporary values for Tile parts, initialised in `pi_create_encode`
251    pub lay_t: OPJ_UINT32,
252    /// Temporary values for Tile parts, initialised in `pi_create_encode`
253    pub res_t: OPJ_UINT32,
254    /// Temporary values for Tile parts, initialised in `pi_create_encode`
255    pub comp_t: OPJ_UINT32,
256    /// Temporary values for Tile parts, initialised in `pi_create_encode`
257    pub prc_t: OPJ_UINT32,
258    /// Temporary values for Tile parts, initialised in `pi_create_encode`
259    pub tx0_t: OPJ_UINT32,
260    /// Temporary values for Tile parts, initialised in `pi_create_encode`
261    pub ty0_t: OPJ_UINT32,
262}
263/// Progression order changes
264pub type opj_poc_t = opj_poc;
265/// Compression parameters
266#[repr(C)]
267#[derive(Debug, Copy, Clone)]
268pub struct opj_cparameters {
269    /// size of tile: `tile_size_on` = false (not in argument) or = true (in argument)
270    pub tile_size_on: OPJ_BOOL,
271    /// `XTOsiz`
272    pub cp_tx0: c_int,
273    /// `YTOsiz`
274    pub cp_ty0: c_int,
275    /// `XTsiz`
276    pub cp_tdx: c_int,
277    /// `YTsiz`
278    pub cp_tdy: c_int,
279    /// allocation by rate/distortion
280    pub cp_disto_alloc: c_int,
281    /// allocation by fixed layer
282    pub cp_fixed_alloc: c_int,
283    /// allocation by fixed quality (PSNR)
284    pub cp_fixed_quality: c_int,
285    /// fixed layer
286    pub cp_matrice: *mut c_int,
287    /// comment for coding
288    pub cp_comment: *mut c_char,
289    /// csty : coding style
290    pub csty: c_int,
291    /// progression order (default `OPJ_LRCP`)
292    pub prog_order: OPJ_PROG_ORDER,
293    /// progression order changes
294    pub POC: [opj_poc_t; 32usize],
295    /// number of progression order changes (POC), default to 0
296    pub numpocs: OPJ_UINT32,
297    /// number of layers
298    pub tcp_numlayers: c_int,
299    /// rates of layers - might be subsequently limited by the `max_cs_size` field.
300    /// Should be decreasing. 1 can be
301    /// used as last value to indicate the last layer is lossless.
302    pub tcp_rates: [f32; 100usize],
303    /// different psnr for successive layers. Should be increasing. 0 can be
304    /// used as last value to indicate the last layer is lossless.
305    pub tcp_distoratio: [f32; 100usize],
306    /// number of resolutions
307    pub numresolution: c_int,
308    /// initial code block width, default to 64
309    pub cblockw_init: c_int,
310    /// initial code block height, default to 64
311    pub cblockh_init: c_int,
312    /// mode switch (`cblk_style`)
313    pub mode: c_int,
314    /// 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default)
315    pub irreversible: c_int,
316    /// region of interest: affected component in [0..3], -1 means no ROI
317    pub roi_compno: c_int,
318    /// region of interest: upshift value
319    pub roi_shift: c_int,
320    pub res_spec: c_int,
321    /// initial precinct width
322    pub prcw_init: [c_int; 33usize],
323    /// initial precinct height
324    pub prch_init: [c_int; 33usize],
325    /// input file name
326    pub infile: [c_char; 4096usize],
327    /// output file name
328    pub outfile: [c_char; 4096usize],
329    /// DEPRECATED. Index generation is now handled with the `opj_encode_with_info()` function. Set to NULL
330    pub index_on: c_int,
331    /// DEPRECATED. Index generation is now handled with the `opj_encode_with_info()` function. Set to NULL
332    pub index: [c_char; 4096usize],
333    /// subimage encoding: origin image offset in x direction
334    pub image_offset_x0: c_int,
335    /// subimage encoding: origin image offset in y direction
336    pub image_offset_y0: c_int,
337    /// subsampling value for dx
338    pub subsampling_dx: c_int,
339    /// subsampling value for dy
340    pub subsampling_dy: c_int,
341    /// input file format 0: PGX, 1: `PxM`, 2: BMP 3:TIF
342    pub decod_format: c_int,
343    /// output file format 0: J2K, 1: JP2, 2: JPT
344    pub cod_format: c_int,
345    /// enables writing of EPC in MH, thus activating JPWL
346    pub jpwl_epc_on: OPJ_BOOL,
347    /// error protection method for MH (0,1,16,32,37-128)
348    pub jpwl_hprot_MH: c_int,
349    /// tile number of header protection specification (>=0)
350    pub jpwl_hprot_TPH_tileno: [c_int; 16usize],
351    /// error protection methods for TPHs (0,1,16,32,37-128)
352    pub jpwl_hprot_TPH: [c_int; 16usize],
353    /// tile number of packet protection specification (>=0)
354    pub jpwl_pprot_tileno: [c_int; 16usize],
355    /// packet number of packet protection specification (>=0)
356    pub jpwl_pprot_packno: [c_int; 16usize],
357    /// error protection methods for packets (0,1,16,32,37-128)
358    pub jpwl_pprot: [c_int; 16usize],
359    /// enables writing of ESD, (0=no/1/2 bytes)
360    pub jpwl_sens_size: c_int,
361    /// sensitivity addressing size (0=auto/2/4 bytes)
362    pub jpwl_sens_addr: c_int,
363    /// sensitivity range (0-3)
364    pub jpwl_sens_range: c_int,
365    /// sensitivity method for MH (-1=no,0-7)
366    pub jpwl_sens_MH: c_int,
367    /// tile number of sensitivity specification (>=0)
368    pub jpwl_sens_TPH_tileno: [c_int; 16usize],
369    /// sensitivity methods for TPHs (-1=no,0-7)
370    pub jpwl_sens_TPH: [c_int; 16usize],
371    /// DEPRECATED: use RSIZ, `OPJ_PROFILE_*` and `MAX_COMP_SIZE` instead
372    /// Digital Cinema compliance 0-not compliant, 1-compliant
373    pub cp_cinema: OPJ_CINEMA_MODE,
374    /// Maximum size (in bytes) for each component.
375    /// If == 0, component size limitation is not considered
376    pub max_comp_size: c_int,
377    /// DEPRECATED: use RSIZ, `OPJ_PROFILE_*` and `OPJ_EXTENSION_*` instead
378    /// Profile name
379    pub cp_rsiz: OPJ_RSIZ_CAPABILITIES,
380    /// Tile part generation
381    pub tp_on: c_char,
382    /// Flag for Tile part generation
383    pub tp_flag: c_char,
384    /// MCT (multiple component transform)
385    pub tcp_mct: c_char,
386    /// Enable JPIP indexing
387    pub jpip_on: OPJ_BOOL,
388    /// Naive implementation of MCT restricted to a single reversible array based
389    ///encoding without offset concerning all the components.
390    pub mct_data: *mut c_void,
391    /// Maximum size (in bytes) for the whole codestream.
392    /// If == 0, codestream size limitation is not considered
393    /// If it does not comply with `tcp_rates`, `max_cs_size` prevails
394    /// and a warning is issued.
395    pub max_cs_size: c_int,
396    /// RSIZ value
397    ///To be used to combine `OPJ_PROFILE_*`, `OPJ_EXTENSION_*` and (sub)levels values.
398    pub rsiz: OPJ_UINT16,
399}
400/// Compression parameters
401pub type opj_cparameters_t = opj_cparameters;
402/// Decompression parameters
403#[repr(C)]
404#[derive(Copy, Clone)]
405pub struct opj_dparameters {
406    ///Set the number of highest resolution levels to be discarded.
407    ///The image resolution is effectively divided by 2 to the power of the number of discarded levels.
408    ///The reduce factor is limited by the smallest total number of decomposition levels among tiles.
409    ///if != 0, then original dimension divided by 2^(reduce);
410    ///if == 0 or not used, image is decoded to the full resolution
411    pub cp_reduce: OPJ_UINT32,
412    ///Set the maximum number of quality layers to decode.
413    ///If there are less quality layers than the specified number, all the quality layers are decoded.
414    ///if != 0, then only the first "layer" layers are decoded;
415    ///if == 0 or not used, all the quality layers are decoded
416    pub cp_layer: OPJ_UINT32,
417    /// input file name
418    pub infile: [c_char; 4096usize],
419    /// output file name
420    pub outfile: [c_char; 4096usize],
421    /// input file format 0: J2K, 1: JP2, 2: JPT
422    pub decod_format: c_int,
423    /// output file format 0: PGX, 1: `PxM`, 2: BMP
424    pub cod_format: c_int,
425    /// Decoding area left boundary
426    pub DA_x0: OPJ_UINT32,
427    /// Decoding area right boundary
428    pub DA_x1: OPJ_UINT32,
429    /// Decoding area up boundary
430    pub DA_y0: OPJ_UINT32,
431    /// Decoding area bottom boundary
432    pub DA_y1: OPJ_UINT32,
433    /// Verbose mode
434    pub m_verbose: OPJ_BOOL,
435    /// tile number of the decoded tile
436    pub tile_index: OPJ_UINT32,
437    /// Nb of tile to decode
438    pub nb_tile_to_decode: OPJ_UINT32,
439    /// activates the JPWL correction capabilities
440    pub jpwl_correct: OPJ_BOOL,
441    /// expected number of components
442    pub jpwl_exp_comps: c_int,
443    /// maximum number of tiles
444    pub jpwl_max_tiles: c_int,
445    pub flags: c_uint,
446}
447/// Decompression parameters
448pub type opj_dparameters_t = opj_dparameters;
449/// JPEG2000 codec V2.
450pub type opj_codec_t = *mut c_void;
451pub type opj_stream_read_fn = ::std::option::Option<
452    unsafe extern "C" fn(
453        p_buffer: *mut c_void,
454        p_nb_bytes: OPJ_SIZE_T,
455        p_user_data: *mut c_void,
456    ) -> OPJ_SIZE_T,
457>;
458pub type opj_stream_write_fn = ::std::option::Option<
459    unsafe extern "C" fn(
460        p_buffer: *mut c_void,
461        p_nb_bytes: OPJ_SIZE_T,
462        p_user_data: *mut c_void,
463    ) -> OPJ_SIZE_T,
464>;
465pub type opj_stream_skip_fn = ::std::option::Option<
466    unsafe extern "C" fn(
467        p_nb_bytes: OPJ_OFF_T,
468        p_user_data: *mut c_void,
469    ) -> OPJ_OFF_T,
470>;
471pub type opj_stream_seek_fn = ::std::option::Option<
472    unsafe extern "C" fn(
473        p_nb_bytes: OPJ_OFF_T,
474        p_user_data: *mut c_void,
475    ) -> OPJ_BOOL,
476>;
477pub type opj_stream_free_user_data_fn =
478    ::std::option::Option<unsafe extern "C" fn(p_user_data: *mut c_void)>;
479pub type opj_stream_t = *mut c_void;
480/// Defines a single image component
481#[repr(C)]
482#[derive(Debug, Copy, Clone)]
483pub struct opj_image_comp {
484    /// `XRsiz`: horizontal separation of a sample of ith component with respect to the reference grid
485    pub dx: OPJ_UINT32,
486    /// `YRsiz`: vertical separation of a sample of ith component with respect to the reference grid
487    pub dy: OPJ_UINT32,
488    /// data width
489    pub w: OPJ_UINT32,
490    /// data height
491    pub h: OPJ_UINT32,
492    /// x component offset compared to the whole image
493    pub x0: OPJ_UINT32,
494    /// y component offset compared to the whole image
495    pub y0: OPJ_UINT32,
496    /// precision: number of bits per component per pixel
497    pub prec: OPJ_UINT32,
498    /// image depth in bits
499    pub bpp: OPJ_UINT32,
500    /// signed (1) / unsigned (0)
501    pub sgnd: OPJ_UINT32,
502    /// number of decoded resolution
503    pub resno_decoded: OPJ_UINT32,
504    /// number of division by 2 of the out image compared to the original size of image
505    pub factor: OPJ_UINT32,
506    /// image component data
507    pub data: *mut OPJ_INT32,
508    /// alpha channel
509    pub alpha: OPJ_UINT16,
510}
511/// Defines a single image component
512pub type opj_image_comp_t = opj_image_comp;
513/// Defines image data and characteristics
514#[repr(C)]
515#[derive(Debug, Copy, Clone)]
516pub struct opj_image {
517    /// `XOsiz`: horizontal offset from the origin of the reference grid to the left side of the image area
518    pub x0: OPJ_UINT32,
519    /// `YOsiz`: vertical offset from the origin of the reference grid to the top side of the image area
520    pub y0: OPJ_UINT32,
521    /// Xsiz: width of the reference grid
522    pub x1: OPJ_UINT32,
523    /// Ysiz: height of the reference grid
524    pub y1: OPJ_UINT32,
525    /// number of components in the image
526    pub numcomps: OPJ_UINT32,
527    /// color space: sRGB, Greyscale or YUV
528    pub color_space: OPJ_COLOR_SPACE,
529    /// image components
530    pub comps: *mut opj_image_comp_t,
531    /// 'restricted' ICC profile
532    pub icc_profile_buf: *mut OPJ_BYTE,
533    /// size of ICC profile
534    pub icc_profile_len: OPJ_UINT32,
535}
536/// Defines image data and characteristics
537pub type opj_image_t = opj_image;
538/// Component parameters structure used by the `opj_image_create` function
539#[repr(C)]
540#[derive(Debug, Copy, Clone)]
541pub struct opj_image_comptparm {
542    /// `XRsiz`: horizontal separation of a sample of ith component with respect to the reference grid
543    pub dx: OPJ_UINT32,
544    /// `YRsiz`: vertical separation of a sample of ith component with respect to the reference grid
545    pub dy: OPJ_UINT32,
546    /// data width
547    pub w: OPJ_UINT32,
548    /// data height
549    pub h: OPJ_UINT32,
550    /// x component offset compared to the whole image
551    pub x0: OPJ_UINT32,
552    /// y component offset compared to the whole image
553    pub y0: OPJ_UINT32,
554    /// precision: number of bits per component per pixel
555    pub prec: OPJ_UINT32,
556    /// image depth in bits
557    pub bpp: OPJ_UINT32,
558    /// signed (1) / unsigned (0)
559    pub sgnd: OPJ_UINT32,
560}
561/// Component parameters structure used by the `opj_image_create` function
562pub type opj_image_cmptparm_t = opj_image_comptparm;
563/// Index structure : Information concerning a packet inside tile
564#[repr(C)]
565#[derive(Debug, Copy, Clone)]
566pub struct opj_packet_info {
567    /// packet start position (including SOP marker if it exists)
568    pub start_pos: OPJ_OFF_T,
569    /// end of packet header position (including EPH marker if it exists)
570    pub end_ph_pos: OPJ_OFF_T,
571    /// packet end position
572    pub end_pos: OPJ_OFF_T,
573    /// packet distorsion
574    pub disto: f64,
575}
576/// Index structure : Information concerning a packet inside tile
577pub type opj_packet_info_t = opj_packet_info;
578/// Marker structure
579#[repr(C)]
580#[derive(Debug, Copy, Clone)]
581pub struct opj_marker_info {
582    /// marker type
583    pub type_: c_ushort,
584    /// position in codestream
585    pub pos: OPJ_OFF_T,
586    /// length, marker val included
587    pub len: c_int,
588}
589/// Marker structure
590pub type opj_marker_info_t = opj_marker_info;
591/// Index structure : Information concerning tile-parts
592#[repr(C)]
593#[derive(Debug, Copy, Clone)]
594pub struct opj_tp_info {
595    /// start position of tile part
596    pub tp_start_pos: c_int,
597    /// end position of tile part header
598    pub tp_end_header: c_int,
599    /// end position of tile part
600    pub tp_end_pos: c_int,
601    /// start packet of tile part
602    pub tp_start_pack: c_int,
603    /// number of packets of tile part
604    pub tp_numpacks: c_int,
605}
606/// Index structure : Information concerning tile-parts
607pub type opj_tp_info_t = opj_tp_info;
608/// Index structure : information regarding tiles
609#[repr(C)]
610#[derive(Debug, Copy, Clone)]
611pub struct opj_tile_info {
612    /// value of thresh for each layer by tile cfr. Marcela
613    pub thresh: *mut f64,
614    /// number of tile
615    pub tileno: c_int,
616    /// start position
617    pub start_pos: c_int,
618    /// end position of the header
619    pub end_header: c_int,
620    /// end position
621    pub end_pos: c_int,
622    /// precinct number for each resolution level (width)
623    pub pw: [c_int; 33usize],
624    /// precinct number for each resolution level (height)
625    pub ph: [c_int; 33usize],
626    /// precinct size (in power of 2), in X for each resolution level
627    pub pdx: [c_int; 33usize],
628    /// precinct size (in power of 2), in Y for each resolution level
629    pub pdy: [c_int; 33usize],
630    /// information concerning packets inside tile
631    pub packet: *mut opj_packet_info_t,
632    /// number of pixels of the tile
633    pub numpix: c_int,
634    /// distortion of the tile
635    pub distotile: f64,
636    /// number of markers
637    pub marknum: c_int,
638    /// list of markers
639    pub marker: *mut opj_marker_info_t,
640    /// actual size of markers array
641    pub maxmarknum: c_int,
642    /// number of tile parts
643    pub num_tps: c_int,
644    /// information concerning tile parts
645    pub tp: *mut opj_tp_info_t,
646}
647/// Index structure : information regarding tiles
648pub type opj_tile_info_t = opj_tile_info;
649/// Index structure of the codestream
650#[repr(C)]
651#[derive(Debug, Copy, Clone)]
652pub struct opj_codestream_info {
653    /// maximum distortion reduction on the whole image (add for Marcela)
654    pub D_max: f64,
655    /// packet number
656    pub packno: c_int,
657    /// writing the packet in the index with `t2_encode_packets`
658    pub index_write: c_int,
659    /// image width
660    pub image_w: c_int,
661    /// image height
662    pub image_h: c_int,
663    /// progression order
664    pub prog: OPJ_PROG_ORDER,
665    /// tile size in x
666    pub tile_x: c_int,
667    /// tile size in y
668    pub tile_y: c_int,
669    pub tile_Ox: c_int,
670    pub tile_Oy: c_int,
671    /// number of tiles in X
672    pub tw: c_int,
673    /// number of tiles in Y
674    pub th: c_int,
675    /// component numbers
676    pub numcomps: c_int,
677    /// number of layer
678    pub numlayers: c_int,
679    /// number of decomposition for each component
680    pub numdecompos: *mut c_int,
681    /// number of markers
682    pub marknum: c_int,
683    /// list of markers
684    pub marker: *mut opj_marker_info_t,
685    /// actual size of markers array
686    pub maxmarknum: c_int,
687    /// main header position
688    pub main_head_start: c_int,
689    /// main header position
690    pub main_head_end: c_int,
691    /// codestream's size
692    pub codestream_size: c_int,
693    /// information regarding tiles inside image
694    pub tile: *mut opj_tile_info_t,
695}
696/// Index structure of the codestream
697pub type opj_codestream_info_t = opj_codestream_info;
698/// Tile-component coding parameters information
699#[repr(C)]
700#[derive(Debug, Copy, Clone)]
701pub struct opj_tccp_info {
702    /// component index
703    pub compno: OPJ_UINT32,
704    /// coding style
705    pub csty: OPJ_UINT32,
706    /// number of resolutions
707    pub numresolutions: OPJ_UINT32,
708    /// log2 of code-blocks width
709    pub cblkw: OPJ_UINT32,
710    /// log2 of code-blocks height
711    pub cblkh: OPJ_UINT32,
712    /// code-block coding style
713    pub cblksty: OPJ_UINT32,
714    /// discrete wavelet transform identifier: 0 = 9-7 irreversible, 1 = 5-3 reversible
715    pub qmfbid: OPJ_UINT32,
716    /// quantisation style
717    pub qntsty: OPJ_UINT32,
718    /// stepsizes used for quantization
719    pub stepsizes_mant: [OPJ_UINT32; 97usize],
720    /// stepsizes used for quantization
721    pub stepsizes_expn: [OPJ_UINT32; 97usize],
722    /// number of guard bits
723    pub numgbits: OPJ_UINT32,
724    /// Region Of Interest shift
725    pub roishift: OPJ_INT32,
726    /// precinct width
727    pub prcw: [OPJ_UINT32; 33usize],
728    /// precinct height
729    pub prch: [OPJ_UINT32; 33usize],
730}
731/// Tile-component coding parameters information
732pub type opj_tccp_info_t = opj_tccp_info;
733/// Tile coding parameters information
734#[repr(C)]
735#[derive(Debug, Copy, Clone)]
736pub struct opj_tile_v2_info {
737    /// number (index) of tile
738    pub tileno: c_int,
739    /// coding style
740    pub csty: OPJ_UINT32,
741    /// progression order
742    pub prg: OPJ_PROG_ORDER,
743    /// number of layers
744    pub numlayers: OPJ_UINT32,
745    /// multi-component transform identifier
746    pub mct: OPJ_UINT32,
747    /// information concerning tile component parameters
748    pub tccp_info: *mut opj_tccp_info_t,
749}
750/// Tile coding parameters information
751pub type opj_tile_info_v2_t = opj_tile_v2_info;
752/// Information structure about the codestream (FIXME should be expand and enhance)
753#[repr(C)]
754#[derive(Debug, Copy, Clone)]
755pub struct opj_codestream_info_v2 {
756    /// tile origin in x = `XTOsiz`
757    pub tx0: OPJ_UINT32,
758    /// tile origin in y = `YTOsiz`
759    pub ty0: OPJ_UINT32,
760    /// tile size in x = `XTsiz`
761    pub tdx: OPJ_UINT32,
762    /// tile size in y = `YTsiz`
763    pub tdy: OPJ_UINT32,
764    /// number of tiles in X
765    pub tw: OPJ_UINT32,
766    /// number of tiles in Y
767    pub th: OPJ_UINT32,
768    /// number of components
769    pub nbcomps: OPJ_UINT32,
770    /// Default information regarding tiles inside image
771    pub m_default_tile_info: opj_tile_info_v2_t,
772    /// information regarding tiles inside image
773    pub tile_info: *mut opj_tile_info_v2_t,
774}
775/// Information structure about the codestream (FIXME should be expand and enhance)
776pub type opj_codestream_info_v2_t = opj_codestream_info_v2;
777/// Index structure about a tile part
778#[repr(C)]
779#[derive(Debug, Copy, Clone)]
780pub struct opj_tp_index {
781    /// start position
782    pub start_pos: OPJ_OFF_T,
783    /// end position of the header
784    pub end_header: OPJ_OFF_T,
785    /// end position
786    pub end_pos: OPJ_OFF_T,
787}
788/// Index structure about a tile part
789pub type opj_tp_index_t = opj_tp_index;
790/// Index structure about a tile
791#[repr(C)]
792#[derive(Debug, Copy, Clone)]
793pub struct opj_tile_index {
794    /// tile index
795    pub tileno: OPJ_UINT32,
796    /// number of tile parts
797    pub nb_tps: OPJ_UINT32,
798    /// current nb of tile part (allocated)
799    pub current_nb_tps: OPJ_UINT32,
800    /// current tile-part index
801    pub current_tpsno: OPJ_UINT32,
802    /// information concerning tile parts
803    pub tp_index: *mut opj_tp_index_t,
804    /// number of markers
805    pub marknum: OPJ_UINT32,
806    /// list of markers
807    pub marker: *mut opj_marker_info_t,
808    /// actual size of markers array
809    pub maxmarknum: OPJ_UINT32,
810    /// packet number
811    pub nb_packet: OPJ_UINT32,
812    /// information concerning packets inside tile
813    pub packet_index: *mut opj_packet_info_t,
814}
815/// Index structure about a tile
816pub type opj_tile_index_t = opj_tile_index;
817/// Index structure of the codestream (FIXME should be expand and enhance)
818#[repr(C)]
819#[derive(Debug, Copy, Clone)]
820pub struct opj_codestream_index {
821    /// main header start position (SOC position)
822    pub main_head_start: OPJ_OFF_T,
823    /// main header end position (first SOT position)
824    pub main_head_end: OPJ_OFF_T,
825    /// codestream's size
826    pub codestream_size: OPJ_UINT64,
827    /// number of markers
828    pub marknum: OPJ_UINT32,
829    /// list of markers
830    pub marker: *mut opj_marker_info_t,
831    /// actual size of markers array
832    pub maxmarknum: OPJ_UINT32,
833    pub nb_of_tiles: OPJ_UINT32,
834    pub tile_index: *mut opj_tile_index_t,
835}
836/// Index structure of the codestream (FIXME should be expand and enhance)
837pub type opj_codestream_index_t = opj_codestream_index;
838/// Info structure of the JP2 file
839/// EXPERIMENTAL FOR THE MOMENT
840#[repr(C)]
841#[derive(Debug, Copy, Clone)]
842pub struct opj_jp2_metadata {
843    pub not_used: OPJ_INT32,
844}
845/// Info structure of the JP2 file
846/// EXPERIMENTAL FOR THE MOMENT
847pub type opj_jp2_metadata_t = opj_jp2_metadata;
848/// Index structure of the JP2 file
849/// EXPERIMENTAL FOR THE MOMENT
850#[repr(C)]
851#[derive(Debug, Copy, Clone)]
852pub struct opj_jp2_index {
853    pub not_used: OPJ_INT32,
854}
855/// Index structure of the JP2 file
856/// EXPERIMENTAL FOR THE MOMENT
857pub type opj_jp2_index_t = opj_jp2_index;
858extern "C" {
859    pub fn opj_version() -> *const c_char;
860}
861extern "C" {
862    /// Create an image
863    ///
864    /// * `numcmpts` —       number of components
865    /// * `cmptparms` —      components parameters
866    /// * `clrspc` —         image color space
867    /// @return returns      a new image structure if successful, returns NULL otherwise
868    pub fn opj_image_create(
869        numcmpts: OPJ_UINT32,
870        cmptparms: *mut opj_image_cmptparm_t,
871        clrspc: OPJ_COLOR_SPACE,
872    ) -> *mut opj_image_t;
873}
874extern "C" {
875    /// Deallocate any resources associated with an image
876    ///
877    /// * `image` —          image to be destroyed
878    pub fn opj_image_destroy(image: *mut opj_image_t);
879}
880extern "C" {
881    /// Creates an image without allocating memory for the image (used in the new version of the library).
882    ///
883    /// * `numcmpts` —     the number of components
884    /// * `cmptparms` —    the components parameters
885    /// * `clrspc` —       the image color space
886    ///
887    /// @return  a new image structure if successful, NULL otherwise.
888    pub fn opj_image_tile_create(
889        numcmpts: OPJ_UINT32,
890        cmptparms: *mut opj_image_cmptparm_t,
891        clrspc: OPJ_COLOR_SPACE,
892    ) -> *mut opj_image_t;
893}
894extern "C" {
895    /// Allocator for opj_image_t->comps[].data
896    /// To be paired with `opj_image_data_free`.
897    ///
898    /// * `size` —     number of bytes to allocate
899    ///
900    /// @return  a new pointer if successful, NULL otherwise.
901    /// @since 2.2.0
902    pub fn opj_image_data_alloc(size: OPJ_SIZE_T) -> *mut c_void;
903}
904extern "C" {
905    /// Destructor for opj_image_t->comps[].data
906    /// To be paired with `opj_image_data_alloc`.
907    ///
908    /// * `ptr` —     Pointer to free
909    ///
910    /// @since 2.2.0
911    pub fn opj_image_data_free(ptr: *mut c_void);
912}
913extern "C" {
914    /// Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
915    ///
916    /// * `p_is_input` —       if set to true then the stream will be an input stream, an output stream else.
917    ///
918    /// @return  a stream object.
919    pub fn opj_stream_default_create(p_is_input: OPJ_BOOL) -> *mut opj_stream_t;
920}
921extern "C" {
922    /// Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream.
923    ///
924    /// * `p_buffer_size` —   FIXME DOC
925    /// * `p_is_input` —       if set to true then the stream will be an input stream, an output stream else.
926    ///
927    /// @return  a stream object.
928    pub fn opj_stream_create(p_buffer_size: OPJ_SIZE_T, p_is_input: OPJ_BOOL) -> *mut opj_stream_t;
929}
930extern "C" {
931    /// Destroys a stream created by `opj_create_stream`. This function does NOT close the abstract stream. If needed the user must
932    /// close its own implementation of the stream.
933    ///
934    /// * `p_stream` —     the stream to destroy.
935    pub fn opj_stream_destroy(p_stream: *mut opj_stream_t);
936}
937extern "C" {
938    /// Sets the given function to be used as a read function.
939    /// * `p_stream` —     the stream to modify
940    /// * `p_function` —   the function to use a read function.
941    pub fn opj_stream_set_read_function(
942        p_stream: *mut opj_stream_t,
943        p_function: opj_stream_read_fn,
944    );
945}
946extern "C" {
947    /// Sets the given function to be used as a write function.
948    /// * `p_stream` —     the stream to modify
949    /// * `p_function` —   the function to use a write function.
950    pub fn opj_stream_set_write_function(
951        p_stream: *mut opj_stream_t,
952        p_function: opj_stream_write_fn,
953    );
954}
955extern "C" {
956    /// Sets the given function to be used as a skip function.
957    /// * `p_stream` —     the stream to modify
958    /// * `p_function` —   the function to use a skip function.
959    pub fn opj_stream_set_skip_function(
960        p_stream: *mut opj_stream_t,
961        p_function: opj_stream_skip_fn,
962    );
963}
964extern "C" {
965    /// Sets the given function to be used as a seek function, the stream is then seekable,
966    /// using `SEEK_SET` behavior.
967    /// * `p_stream` —     the stream to modify
968    /// * `p_function` —   the function to use a skip function.
969    pub fn opj_stream_set_seek_function(
970        p_stream: *mut opj_stream_t,
971        p_function: opj_stream_seek_fn,
972    );
973}
974extern "C" {
975    /// Sets the given data to be used as a user data for the stream.
976    /// * `p_stream` —     the stream to modify
977    /// * `p_data` —       the data to set.
978    /// * `p_function` —   the function to free `p_data` when `opj_stream_destroy()` is called.
979    pub fn opj_stream_set_user_data(
980        p_stream: *mut opj_stream_t,
981        p_data: *mut c_void,
982        p_function: opj_stream_free_user_data_fn,
983    );
984}
985extern "C" {
986    /// Sets the length of the user data for the stream.
987    ///
988    /// * `p_stream` —     the stream to modify
989    /// * `data_length` —  length of the `user_data`.
990    pub fn opj_stream_set_user_data_length(p_stream: *mut opj_stream_t, data_length: OPJ_UINT64);
991}
992extern "C" {
993    /// Create a stream from a file identified with its filename with default parameters (helper function)
994    /// * `fname` —              the filename of the file to stream
995    /// * `p_is_read_stream` —   whether the stream is a read stream (true) or not (false)
996    pub fn opj_stream_create_default_file_stream(
997        fname: *const c_char,
998        p_is_read_stream: OPJ_BOOL,
999    ) -> *mut opj_stream_t;
1000}
1001extern "C" {
1002    /// Create a stream from a file identified with its filename with a specific buffer size
1003    /// * `fname` —              the filename of the file to stream
1004    /// * `p_buffer_size` —      size of the chunk used to stream
1005    /// * `p_is_read_stream` —   whether the stream is a read stream (true) or not (false)
1006    pub fn opj_stream_create_file_stream(
1007        fname: *const c_char,
1008        p_buffer_size: OPJ_SIZE_T,
1009        p_is_read_stream: OPJ_BOOL,
1010    ) -> *mut opj_stream_t;
1011}
1012extern "C" {
1013    /// Set the info handler use by openjpeg.
1014    /// * `p_codec` —        the codec previously initialise
1015    /// * `p_callback` —     the callback function which will be used
1016    /// * `p_user_data` —    client object where will be returned the message
1017    pub fn opj_set_info_handler(
1018        p_codec: *mut opj_codec_t,
1019        p_callback: opj_msg_callback,
1020        p_user_data: *mut c_void,
1021    ) -> OPJ_BOOL;
1022}
1023extern "C" {
1024    /// Set the warning handler use by openjpeg.
1025    /// * `p_codec` —        the codec previously initialise
1026    /// * `p_callback` —     the callback function which will be used
1027    /// * `p_user_data` —    client object where will be returned the message
1028    pub fn opj_set_warning_handler(
1029        p_codec: *mut opj_codec_t,
1030        p_callback: opj_msg_callback,
1031        p_user_data: *mut c_void,
1032    ) -> OPJ_BOOL;
1033}
1034extern "C" {
1035    /// Set the error handler use by openjpeg.
1036    /// * `p_codec` —        the codec previously initialise
1037    /// * `p_callback` —     the callback function which will be used
1038    /// * `p_user_data` —    client object where will be returned the message
1039    pub fn opj_set_error_handler(
1040        p_codec: *mut opj_codec_t,
1041        p_callback: opj_msg_callback,
1042        p_user_data: *mut c_void,
1043    ) -> OPJ_BOOL;
1044}
1045extern "C" {
1046    /// Creates a J2K/JP2 decompression structure
1047    /// * `format` —         Decoder to select
1048    ///
1049    /// @return Returns a handle to a decompressor if successful, returns NULL otherwise
1050    pub fn opj_create_decompress(format: OPJ_CODEC_FORMAT) -> *mut opj_codec_t;
1051}
1052extern "C" {
1053    /// Destroy a decompressor handle
1054    ///
1055    /// * `p_codec` —          decompressor handle to destroy
1056    pub fn opj_destroy_codec(p_codec: *mut opj_codec_t);
1057}
1058extern "C" {
1059    /// Read after the codestream if necessary
1060    /// * `p_codec` —          the JPEG2000 codec to read.
1061    /// * `p_stream` —         the JPEG2000 stream.
1062    pub fn opj_end_decompress(p_codec: *mut opj_codec_t, p_stream: *mut opj_stream_t) -> OPJ_BOOL;
1063}
1064extern "C" {
1065    /// Set decoding parameters to default values
1066    /// * `parameters` —  Decompression parameters
1067    pub fn opj_set_default_decoder_parameters(parameters: *mut opj_dparameters_t);
1068}
1069extern "C" {
1070    /// Setup the decoder with decompression parameters provided by the user and with the message handler
1071    /// provided by the user.
1072    ///
1073    /// * `p_codec` —        decompressor handler
1074    /// * `parameters` —     decompression parameters
1075    ///
1076    /// @return true         if the decoder is correctly set
1077    pub fn opj_setup_decoder(
1078        p_codec: *mut opj_codec_t,
1079        parameters: *mut opj_dparameters_t,
1080    ) -> OPJ_BOOL;
1081}
1082extern "C" {
1083    /// Set strict decoding parameter for this decoder.  If strict decoding is enabled, partial bit
1084    /// streams will fail to decode.  If strict decoding is disabled, the decoder will decode partial
1085    /// bitstreams as much as possible without erroring
1086    ///
1087    /// * '`p_codec`' —        decompressor handler
1088    /// * 'strict' —         `OPJ_TRUE` to enable strict decoding, `OPJ_FALSE` to disable
1089    ///
1090    /// @return true         if the decoder is correctly set
1091    pub fn opj_decoder_set_strict_mode(p_codec: *mut opj_codec_t, strict: OPJ_BOOL) -> OPJ_BOOL;
1092}
1093extern "C" {
1094    /// Allocates worker threads for the compressor/decompressor.
1095    ///
1096    /// By default, only the main thread is used. If this function is not used,
1097    /// but the `OPJ_NUM_THREADS` environment variable is set, its value will be
1098    /// used to initialize the number of threads. The value can be either an integer
1099    /// number, or "`ALL_CPUS`". If `OPJ_NUM_THREADS` is set and this function is called,
1100    /// this function will override the behaviour of the environment variable.
1101    ///
1102    /// This function must be called after `opj_setup_decoder()` and
1103    /// before `opj_read_header()` for the decoding side, or after `opj_setup_encoder()`
1104    /// and before `opj_start_compress()` for the encoding side.
1105    ///
1106    /// * '`p_codec`' —        decompressor or compressor handler
1107    /// * '`num_threads`' —    number of threads.
1108    ///
1109    /// @return `OPJ_TRUE`     if the function is successful.
1110    pub fn opj_codec_set_threads(
1111        p_codec: *mut opj_codec_t,
1112        num_threads: c_int,
1113    ) -> OPJ_BOOL;
1114}
1115extern "C" {
1116    /// Decodes an image header.
1117    ///
1118    /// * `p_stream` —         the jpeg2000 stream.
1119    /// * `p_codec` —          the jpeg2000 codec to read.
1120    /// * `p_image` —          the image structure initialized with the characteristics of encoded image.
1121    ///
1122    /// @return true             if the main header of the codestream and the JP2 header is correctly read.
1123    pub fn opj_read_header(
1124        p_stream: *mut opj_stream_t,
1125        p_codec: *mut opj_codec_t,
1126        p_image: *mut *mut opj_image_t,
1127    ) -> OPJ_BOOL;
1128}
1129extern "C" {
1130    /// Restrict the number of components to decode.
1131    ///
1132    /// This function should be called after `opj_read_header()`.
1133    ///
1134    /// This function enables to restrict the set of decoded components to the
1135    /// specified indices.
1136    /// Note that the current implementation (`apply_color_transforms` == `OPJ_FALSE`)
1137    /// is such that neither the multi-component transform at codestream level,
1138    /// nor JP2 channel transformations will be applied.
1139    /// Consequently the indices are relative to the codestream.
1140    ///
1141    /// Note: `opj_decode_tile_data()` should not be used together with `opj_set_decoded_components()`.
1142    ///
1143    /// * `p_codec` —          the jpeg2000 codec to read.
1144    /// * `numcomps` —         Size of the `comps_indices` array.
1145    /// * `comps_indices` —    Array of numcomps values representing the indices
1146    ///                          of the components to decode (relative to the
1147    ///                          codestream, starting at 0)
1148    /// * `apply_color_transforms` —  Whether multi-component transform at codestream level
1149    ///                                 or JP2 channel transformations should be applied.
1150    ///                                 Currently this parameter should be set to `OPJ_FALSE`.
1151    ///                                 Setting it to `OPJ_TRUE` will result in an error.
1152    ///
1153    /// @return `OPJ_TRUE`         in case of success.
1154    pub fn opj_set_decoded_components(
1155        p_codec: *mut opj_codec_t,
1156        numcomps: OPJ_UINT32,
1157        comps_indices: *const OPJ_UINT32,
1158        apply_color_transforms: OPJ_BOOL,
1159    ) -> OPJ_BOOL;
1160}
1161extern "C" {
1162    /// Sets the given area to be decoded. This function should be called right after `opj_read_header` and before any tile header reading.
1163    ///
1164    /// The coordinates passed to this function should be expressed in the reference grid,
1165    /// that is to say at the highest resolution level, even if requesting the image at lower
1166    /// resolution levels.
1167    ///
1168    /// Generally `opj_set_decode_area()` should be followed by `opj_decode()`, and the
1169    /// codec cannot be re-used.
1170    /// In the particular case of an image made of a single tile, several sequences of
1171    /// calls to `opoj_set_decode_area()` and `opj_decode()` are allowed, and will bring
1172    /// performance improvements when reading an image by chunks.
1173    ///
1174    /// * `p_codec` —          the jpeg2000 codec.
1175    /// * `p_image` —          the decoded image previously set by `opj_read_header`
1176    /// * `p_start_x` —        the left position of the rectangle to decode (in image coordinates).
1177    /// * `p_end_x` —          the right position of the rectangle to decode (in image coordinates).
1178    /// * `p_start_y` —        the up position of the rectangle to decode (in image coordinates).
1179    /// * `p_end_y` —          the bottom position of the rectangle to decode (in image coordinates).
1180    ///
1181    /// @return  true            if the area could be set.
1182    pub fn opj_set_decode_area(
1183        p_codec: *mut opj_codec_t,
1184        p_image: *mut opj_image_t,
1185        p_start_x: OPJ_INT32,
1186        p_start_y: OPJ_INT32,
1187        p_end_x: OPJ_INT32,
1188        p_end_y: OPJ_INT32,
1189    ) -> OPJ_BOOL;
1190}
1191extern "C" {
1192    /// Decode an image from a JPEG-2000 codestream
1193    ///
1194    /// * `p_decompressor` —     decompressor handle
1195    /// * `p_stream` —           Input buffer stream
1196    /// * `p_image` —            the decoded image
1197    /// @return                  true if success, otherwise false
1198    pub fn opj_decode(
1199        p_decompressor: *mut opj_codec_t,
1200        p_stream: *mut opj_stream_t,
1201        p_image: *mut opj_image_t,
1202    ) -> OPJ_BOOL;
1203}
1204extern "C" {
1205    /// Get the decoded tile from the codec
1206    ///
1207    /// * `p_codec` —          the jpeg2000 codec.
1208    /// * `p_stream` —         input streamm
1209    /// * `p_image` —          output image
1210    /// * `tile_index` —       index of the tile which will be decode
1211    ///
1212    /// @return                  true if success, otherwise false
1213    pub fn opj_get_decoded_tile(
1214        p_codec: *mut opj_codec_t,
1215        p_stream: *mut opj_stream_t,
1216        p_image: *mut opj_image_t,
1217        tile_index: OPJ_UINT32,
1218    ) -> OPJ_BOOL;
1219}
1220extern "C" {
1221    /// Set the resolution factor of the decoded image
1222    /// * `p_codec` —          the jpeg2000 codec.
1223    /// * `res_factor` —       resolution factor to set
1224    ///
1225    /// @return                  true if success, otherwise false
1226    pub fn opj_set_decoded_resolution_factor(
1227        p_codec: *mut opj_codec_t,
1228        res_factor: OPJ_UINT32,
1229    ) -> OPJ_BOOL;
1230}
1231extern "C" {
1232    /// Writes a tile with the given data.
1233    ///
1234    /// * `p_codec` —              the jpeg2000 codec.
1235    /// * `p_tile_index` —         the index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence.
1236    /// * `p_data` —               pointer to the data to write. Data is arranged in sequence, `data_comp0`, then `data_comp1`, then ... NO INTERLEAVING should be set.
1237    /// * `p_data_size` —          this value os used to make sure the data being written is correct. The size must be equal to the sum for each component of
1238    ///                              `tile_width` * `tile_height` * `component_size`. `component_size` can be 1,2 or 4 bytes, depending on the precision of the given component.
1239    /// * `p_stream` —             the stream to write data to.
1240    ///
1241    /// @return  true if the data could be written.
1242    pub fn opj_write_tile(
1243        p_codec: *mut opj_codec_t,
1244        p_tile_index: OPJ_UINT32,
1245        p_data: *mut OPJ_BYTE,
1246        p_data_size: OPJ_UINT32,
1247        p_stream: *mut opj_stream_t,
1248    ) -> OPJ_BOOL;
1249}
1250extern "C" {
1251    /// Reads a tile header. This function is compulsory and allows one to know the size of the tile that will be decoded.
1252    /// The user may need to refer to the image got by `opj_read_header` to understand the size being taken by the tile.
1253    ///
1254    /// * `p_codec` —          the jpeg2000 codec.
1255    /// * `p_tile_index` —     pointer to a value that will hold the index of the tile being decoded, in case of success.
1256    /// * `p_data_size` —      pointer to a value that will hold the maximum size of the decoded data, in case of success. In case
1257    ///                          of truncated codestreams, the actual number of bytes decoded may be lower. The computation of the size is the same
1258    ///                          as depicted in `opj_write_tile`.
1259    /// * `p_tile_x0` —        pointer to a value that will hold the x0 pos of the tile (in the image).
1260    /// * `p_tile_y0` —        pointer to a value that will hold the y0 pos of the tile (in the image).
1261    /// * `p_tile_x1` —        pointer to a value that will hold the x1 pos of the tile (in the image).
1262    /// * `p_tile_y1` —        pointer to a value that will hold the y1 pos of the tile (in the image).
1263    /// * `p_nb_comps` —       pointer to a value that will hold the number of components in the tile.
1264    /// * `p_should_go_on` —   pointer to a boolean that will hold the fact that the decoding should go on. In case the
1265    ///                          codestream is over at the time of the call, the value will be set to false. The user should then stop
1266    ///                          the decoding.
1267    /// * `p_stream` —         the stream to decode.
1268    /// @return  true            if the tile header could be decoded. In case the decoding should end, the returned value is still true.
1269    ///                          returning false may be the result of a shortage of memory or an internal error.
1270    pub fn opj_read_tile_header(
1271        p_codec: *mut opj_codec_t,
1272        p_stream: *mut opj_stream_t,
1273        p_tile_index: *mut OPJ_UINT32,
1274        p_data_size: *mut OPJ_UINT32,
1275        p_tile_x0: *mut OPJ_INT32,
1276        p_tile_y0: *mut OPJ_INT32,
1277        p_tile_x1: *mut OPJ_INT32,
1278        p_tile_y1: *mut OPJ_INT32,
1279        p_nb_comps: *mut OPJ_UINT32,
1280        p_should_go_on: *mut OPJ_BOOL,
1281    ) -> OPJ_BOOL;
1282}
1283extern "C" {
1284    /// Reads a tile data. This function is compulsory and allows one to decode tile data. `opj_read_tile_header` should be called before.
1285    /// The user may need to refer to the image got by `opj_read_header` to understand the size being taken by the tile.
1286    ///
1287    /// Note: `opj_decode_tile_data()` should not be used together with `opj_set_decoded_components()`.
1288    ///
1289    /// * `p_codec` —          the jpeg2000 codec.
1290    /// * `p_tile_index` —     the index of the tile being decoded, this should be the value set by `opj_read_tile_header`.
1291    /// * `p_data` —           pointer to a memory block that will hold the decoded data.
1292    /// * `p_data_size` —      size of `p_data`. `p_data_size` should be bigger or equal to the value set by `opj_read_tile_header`.
1293    /// * `p_stream` —         the stream to decode.
1294    ///
1295    /// @return  true            if the data could be decoded.
1296    pub fn opj_decode_tile_data(
1297        p_codec: *mut opj_codec_t,
1298        p_tile_index: OPJ_UINT32,
1299        p_data: *mut OPJ_BYTE,
1300        p_data_size: OPJ_UINT32,
1301        p_stream: *mut opj_stream_t,
1302    ) -> OPJ_BOOL;
1303}
1304extern "C" {
1305    /// Creates a J2K/JP2 compression structure
1306    /// * `format` —       Coder to select
1307    /// @return              Returns a handle to a compressor if successful, returns NULL otherwise
1308    pub fn opj_create_compress(format: OPJ_CODEC_FORMAT) -> *mut opj_codec_t;
1309}
1310extern "C" {
1311    ///Set encoding parameters to default values, that means :
1312    ///<ul>
1313    ///<li>Lossless
1314    ///<li>1 tile
1315    ///<li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
1316    ///<li>Size of code-block : 64 x 64
1317    ///<li>Number of resolutions: 6
1318    ///<li>No SOP marker in the codestream
1319    ///<li>No EPH marker in the codestream
1320    ///<li>No sub-sampling in x or y direction
1321    ///<li>No mode switch activated
1322    ///<li>Progression order: LRCP
1323    ///<li>No index file
1324    ///<li>No ROI upshifted
1325    ///<li>No offset of the origin of the image
1326    ///<li>No offset of the origin of the tiles
1327    ///<li>Reversible DWT 5-3
1328    ///</ul>
1329    ///@param parameters Compression parameters
1330    pub fn opj_set_default_encoder_parameters(parameters: *mut opj_cparameters_t);
1331}
1332extern "C" {
1333    /// Setup the encoder parameters using the current image and using user parameters.
1334    /// * `p_codec` —        Compressor handle
1335    /// * `parameters` —     Compression parameters
1336    /// * `image` —          Input filled image
1337    pub fn opj_setup_encoder(
1338        p_codec: *mut opj_codec_t,
1339        parameters: *mut opj_cparameters_t,
1340        image: *mut opj_image_t,
1341    ) -> OPJ_BOOL;
1342}
1343extern "C" {
1344    /// Specify extra options for the encoder.
1345    ///
1346    /// This may be called after `opj_setup_encoder()` and before `opj_start_compress()`
1347    ///
1348    /// This is the way to add new options in a fully ABI compatible way, without
1349    /// extending the `opj_cparameters_t` structure.
1350    ///
1351    /// Currently supported options are:
1352    /// <ul>
1353    /// <li>PLT=YES/NO. Defaults to NO. If set to YES, PLT marker segments,
1354    ///     indicating the length of each packet in the tile-part header, will be
1355    ///     written. Since 2.3.2</li>
1356    /// </ul>
1357    ///
1358    /// * '`p_codec`' —        Compressor handle
1359    /// * '`p_options`' —      Compression options. This should be a NULL terminated array of strings. Each string is of the form KEY=VALUE.
1360    ///
1361    /// @return `OPJ_TRUE` in case of success.
1362    /// @since 2.3.2
1363    pub fn opj_encoder_set_extra_options(
1364        p_codec: *mut opj_codec_t,
1365        p_options: *const *const c_char,
1366    ) -> OPJ_BOOL;
1367}
1368extern "C" {
1369    /// Start to compress the current image.
1370    /// * `p_codec` —        Compressor handle
1371    /// * `p_image` —        Input filled image
1372    /// * `p_stream` —       Input stgream
1373    pub fn opj_start_compress(
1374        p_codec: *mut opj_codec_t,
1375        p_image: *mut opj_image_t,
1376        p_stream: *mut opj_stream_t,
1377    ) -> OPJ_BOOL;
1378}
1379extern "C" {
1380    /// End to compress the current image.
1381    /// * `p_codec` —        Compressor handle
1382    /// * `p_stream` —       Input stgream
1383    pub fn opj_end_compress(p_codec: *mut opj_codec_t, p_stream: *mut opj_stream_t) -> OPJ_BOOL;
1384}
1385extern "C" {
1386    /// Encode an image into a JPEG-2000 codestream
1387    /// * `p_codec` —        compressor handle
1388    /// * `p_stream` —       Output buffer stream
1389    ///
1390    /// @return              Returns true if successful, returns false otherwise
1391    pub fn opj_encode(p_codec: *mut opj_codec_t, p_stream: *mut opj_stream_t) -> OPJ_BOOL;
1392}
1393extern "C" {
1394    ///Destroy Codestream information after compression or decompression
1395    ///@param `cstr_info` Codestream information structure
1396    pub fn opj_destroy_cstr_info(cstr_info: *mut *mut opj_codestream_info_v2_t);
1397}
1398extern "C" {
1399    /// Dump the codec information into the output stream
1400    ///
1401    /// * `p_codec` —          the jpeg2000 codec.
1402    /// * `info_flag` —        type of information dump.
1403    /// * `output_stream` —    output stream where dump the information gotten from the codec.
1404    ///
1405    pub fn opj_dump_codec(
1406        p_codec: *mut opj_codec_t,
1407        info_flag: OPJ_INT32,
1408        output_stream: *mut FILE,
1409    );
1410}
1411extern "C" {
1412    /// Get the codestream information from the codec
1413    ///
1414    /// * `p_codec` —          the jpeg2000 codec.
1415    ///
1416    /// @return                  a pointer to a codestream information structure.
1417    pub fn opj_get_cstr_info(p_codec: *mut opj_codec_t) -> *mut opj_codestream_info_v2_t;
1418}
1419extern "C" {
1420    /// Get the codestream index from the codec
1421    ///
1422    /// * `p_codec` —          the jpeg2000 codec.
1423    ///
1424    /// @return                  a pointer to a codestream index structure.
1425    pub fn opj_get_cstr_index(p_codec: *mut opj_codec_t) -> *mut opj_codestream_index_t;
1426}
1427extern "C" {
1428    pub fn opj_destroy_cstr_index(p_cstr_index: *mut *mut opj_codestream_index_t);
1429}
1430extern "C" {
1431    /// Get the JP2 file information from the codec FIXME
1432    ///
1433    /// * `p_codec` —          the jpeg2000 codec.
1434    ///
1435    /// @return                  a pointer to a JP2 metadata structure.
1436    pub fn opj_get_jp2_metadata(p_codec: *mut opj_codec_t) -> *mut opj_jp2_metadata_t;
1437}
1438extern "C" {
1439    /// Get the JP2 file index from the codec FIXME
1440    ///
1441    /// * `p_codec` —          the jpeg2000 codec.
1442    ///
1443    /// @return                  a pointer to a JP2 index structure.
1444    pub fn opj_get_jp2_index(p_codec: *mut opj_codec_t) -> *mut opj_jp2_index_t;
1445}
1446extern "C" {
1447    /// Sets the MCT matrix to use.
1448    ///
1449    /// * `parameters` —       the parameters to change.
1450    /// * `pEncodingMatrix` —  the encoding matrix.
1451    /// * `p_dc_shift` —       the dc shift coefficients to use.
1452    /// * `pNbComp` —          the number of components of the image.
1453    ///
1454    /// @return  true if the parameters could be set.
1455    pub fn opj_set_MCT(
1456        parameters: *mut opj_cparameters_t,
1457        pEncodingMatrix: *mut OPJ_FLOAT32,
1458        p_dc_shift: *mut OPJ_INT32,
1459        pNbComp: OPJ_UINT32,
1460    ) -> OPJ_BOOL;
1461}
1462extern "C" {
1463    /// Returns if the library is built with thread support.
1464    /// `OPJ_TRUE` if mutex, condition, thread, thread pool are available.
1465    pub fn opj_has_thread_support() -> OPJ_BOOL;
1466}
1467extern "C" {
1468    /// Return the number of virtual CPUs
1469    pub fn opj_get_num_cpus() -> c_int;
1470}