Skip to main content

openjp2_ctypes/
lib.rs

1/*
2 * The copyright in this software is being made available under the 2-clauses
3 * BSD License, included below. This software may be subject to other third
4 * party and contributor rights, including patent rights, and no such rights
5 * are granted under this license.
6 *
7 * Copyright (c) 2005, Herve Drolon, FreeImage Team
8 * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
9 * Copyright (c) 2012, CS Systemes d'Information, France
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 *    notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 *    notice, this list of conditions and the following disclaimer in the
19 *    documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34// The C-ABI mirror types and constants keep the C header's spellings.
35#![allow(non_snake_case)]
36#![allow(non_camel_case_types)]
37#![allow(non_upper_case_globals)]
38
39//! C-ABI mirror types and constants for the OpenJPEG `openjpeg.h` surface.
40//!
41//! The `openjp2` core depends on this crate for the C-header-shaped types it
42//! still uses internally (the migration to Rust primitives is incremental);
43//! the `openjp2-capi` crate is the only consumer that passes these types
44//! across the FFI boundary.
45
46/*
47 * The copyright in this software is being made available under the 2-clauses
48 * BSD License, included below. This software may be subject to other third
49 * party and contributor rights, including patent rights, and no such rights
50 * are granted under this license.
51 *
52 * Copyright (c) 2005, Herve Drolon, FreeImage Team
53 * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
54 * Copyright (c) 2012, CS Systemes d'Information, France
55 * All rights reserved.
56 *
57 * Redistribution and use in source and binary forms, with or without
58 * modification, are permitted provided that the following conditions
59 * are met:
60 * 1. Redistributions of source code must retain the above copyright
61 *    notice, this list of conditions and the following disclaimer.
62 * 2. Redistributions in binary form must reproduce the above copyright
63 *    notice, this list of conditions and the following disclaimer in the
64 *    documentation and/or other materials provided with the distribution.
65 *
66 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
67 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
68 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
69 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
70 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
71 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
72 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
73 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
74 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
75 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
76 * POSSIBILITY OF SUCH DAMAGE.
77 */
78
79pub type OPJ_BOOL = i32;
80pub type OPJ_FLOAT32 = f32;
81pub type OPJ_BYTE = u8;
82pub type OPJ_UINT16 = u16;
83pub type OPJ_INT32 = i32;
84pub type OPJ_UINT32 = u32;
85pub type OPJ_UINT64 = u64;
86pub type OPJ_OFF_T = i64;
87pub type OPJ_SIZE_T = usize;
88pub type opj_flag_t = u32;
89pub type RSIZ_CAPABILITIES = core::ffi::c_uint;
90pub const OPJ_MCT: RSIZ_CAPABILITIES = 33024;
91pub const OPJ_CINEMA4K: RSIZ_CAPABILITIES = 4;
92pub const OPJ_CINEMA2K: RSIZ_CAPABILITIES = 3;
93pub const OPJ_STD_RSIZ: RSIZ_CAPABILITIES = 0;
94pub type OPJ_RSIZ_CAPABILITIES = RSIZ_CAPABILITIES;
95pub type CINEMA_MODE = core::ffi::c_uint;
96pub const OPJ_CINEMA4K_24: CINEMA_MODE = 3;
97pub const OPJ_CINEMA2K_48: CINEMA_MODE = 2;
98pub const OPJ_CINEMA2K_24: CINEMA_MODE = 1;
99pub const OPJ_OFF: CINEMA_MODE = 0;
100pub type OPJ_CINEMA_MODE = CINEMA_MODE;
101pub type PROG_ORDER = core::ffi::c_int;
102pub const OPJ_CPRL: PROG_ORDER = 4;
103pub const OPJ_PCRL: PROG_ORDER = 3;
104pub const OPJ_RPCL: PROG_ORDER = 2;
105pub const OPJ_RLCP: PROG_ORDER = 1;
106pub const OPJ_LRCP: PROG_ORDER = 0;
107pub const OPJ_PROG_UNKNOWN: PROG_ORDER = -1;
108pub type OPJ_PROG_ORDER = PROG_ORDER;
109
110/// Supported image color spaces
111#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, Hash)]
112#[repr(i32)]
113pub enum COLOR_SPACE {
114  ///< not supported by the library
115  OPJ_CLRSPC_UNKNOWN = -1,
116  ///< not specified in the codestream
117  #[default]
118  OPJ_CLRSPC_UNSPECIFIED = 0,
119  ///< sRGB
120  OPJ_CLRSPC_SRGB = 1,
121  ///< grayscale
122  OPJ_CLRSPC_GRAY = 2,
123  ///< YUV
124  OPJ_CLRSPC_SYCC = 3,
125  ///< e-YCC
126  OPJ_CLRSPC_EYCC = 4,
127  ///< CMYK
128  OPJ_CLRSPC_CMYK = 5,
129}
130/// Supported image color spaces
131pub use COLOR_SPACE as OPJ_COLOR_SPACE;
132pub use COLOR_SPACE::*;
133
134/// Supported codec
135#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
136#[repr(i32)]
137pub enum CODEC_FORMAT {
138  ///< place-holder
139  OPJ_CODEC_UNKNOWN = -1,
140  ///< JPEG-2000 codestream : read/write
141  OPJ_CODEC_J2K = 0,
142  ///< JPT-stream (JPEG 2000, JPIP) : read only
143  OPJ_CODEC_JPT = 1,
144  ///< JP2 file format : read/write
145  OPJ_CODEC_JP2 = 2,
146  ///< JPP-stream (JPEG 2000, JPIP) : to be coded
147  OPJ_CODEC_JPP = 3,
148  ///< JPX file format (JPEG 2000 Part-2) : to be coded
149  OPJ_CODEC_JPX = 4,
150}
151/// Supported codec
152pub use CODEC_FORMAT as OPJ_CODEC_FORMAT;
153pub use CODEC_FORMAT::*;
154
155impl CODEC_FORMAT {
156  pub fn from_i32(num: i32) -> Self {
157    match num {
158      0 => OPJ_CODEC_J2K,
159      1 => OPJ_CODEC_JPT,
160      2 => OPJ_CODEC_JP2,
161      3 => OPJ_CODEC_JPP,
162      4 => OPJ_CODEC_JPX,
163      _ => OPJ_CODEC_UNKNOWN,
164    }
165  }
166}
167
168#[repr(C)]
169#[derive(Copy, Clone, Default, Debug)]
170pub struct opj_poc {
171  pub resno0: u32,
172  pub compno0: u32,
173  pub layno1: u32,
174  pub resno1: u32,
175  pub compno1: u32,
176  pub layno0: u32,
177  pub precno0: u32,
178  pub precno1: u32,
179  pub prg1: OPJ_PROG_ORDER,
180  pub prg: OPJ_PROG_ORDER,
181  pub progorder: [core::ffi::c_char; 5],
182  pub tile: u32,
183  pub tx0: u32,
184  pub tx1: u32,
185  pub ty0: u32,
186  pub ty1: u32,
187  pub layS: u32,
188  pub resS: u32,
189  pub compS: u32,
190  pub prcS: u32,
191  pub layE: u32,
192  pub resE: u32,
193  pub compE: u32,
194  pub prcE: u32,
195  pub txS: u32,
196  pub txE: u32,
197  pub tyS: u32,
198  pub tyE: u32,
199  pub dx: u32,
200  pub dy: u32,
201  pub lay_t: u32,
202  pub res_t: u32,
203  pub comp_t: u32,
204  pub prc_t: u32,
205  pub tx0_t: u32,
206  pub ty0_t: u32,
207}
208pub type opj_poc_t = opj_poc;
209
210use crate::consts::opj::OPJ_PATH_LEN;
211
212#[repr(C)]
213#[derive(Clone, Debug)]
214pub struct opj_dparameters {
215  pub cp_reduce: u32,
216  pub cp_layer: u32,
217  pub infile: [core::ffi::c_char; OPJ_PATH_LEN as usize],
218  pub outfile: [core::ffi::c_char; OPJ_PATH_LEN as usize],
219  pub decod_format: core::ffi::c_int,
220  pub cod_format: core::ffi::c_int,
221  pub DA_x0: u32,
222  pub DA_x1: u32,
223  pub DA_y0: u32,
224  pub DA_y1: u32,
225  pub m_verbose: OPJ_BOOL,
226  pub tile_index: u32,
227  pub nb_tile_to_decode: u32,
228  pub jpwl_correct: OPJ_BOOL,
229  pub jpwl_exp_comps: core::ffi::c_int,
230  pub jpwl_max_tiles: core::ffi::c_int,
231  pub flags: core::ffi::c_uint,
232}
233pub type opj_dparameters_t = opj_dparameters;
234
235impl Default for opj_dparameters_t {
236  fn default() -> Self {
237    Self {
238      cp_reduce: Default::default(),
239      cp_layer: Default::default(),
240      infile: [Default::default(); OPJ_PATH_LEN as usize],
241      outfile: [Default::default(); OPJ_PATH_LEN as usize],
242      decod_format: -1,
243      cod_format: -1,
244      DA_x0: Default::default(),
245      DA_x1: Default::default(),
246      DA_y0: Default::default(),
247      DA_y1: Default::default(),
248      m_verbose: Default::default(),
249      tile_index: Default::default(),
250      nb_tile_to_decode: Default::default(),
251      jpwl_correct: Default::default(),
252      jpwl_exp_comps: Default::default(),
253      jpwl_max_tiles: Default::default(),
254      flags: Default::default(),
255    }
256  }
257}
258
259impl opj_dparameters_t {
260  pub fn set_defaults(&mut self) {
261    *self = Default::default()
262  }
263}
264
265pub type opj_codec_t = *mut core::ffi::c_void;
266pub type opj_stream_read_fn = Option<
267  unsafe extern "C" fn(_: *mut core::ffi::c_void, _: usize, _: *mut core::ffi::c_void) -> usize,
268>;
269pub type opj_stream_write_fn = Option<
270  unsafe extern "C" fn(_: *mut core::ffi::c_void, _: usize, _: *mut core::ffi::c_void) -> usize,
271>;
272pub type opj_stream_skip_fn =
273  Option<unsafe extern "C" fn(_: i64, _: *mut core::ffi::c_void) -> i64>;
274pub type opj_stream_seek_fn =
275  Option<unsafe extern "C" fn(_: i64, _: *mut core::ffi::c_void) -> OPJ_BOOL>;
276pub type opj_stream_free_user_data_fn =
277  Option<unsafe extern "C" fn(_: *mut core::ffi::c_void) -> ()>;
278pub type opj_stream_t = *mut core::ffi::c_void;
279
280#[repr(C)]
281#[derive(Copy, Clone, Default)]
282pub struct opj_packet_info {
283  pub start_pos: i64,
284  pub end_ph_pos: i64,
285  pub end_pos: i64,
286  pub disto: core::ffi::c_double,
287}
288pub type opj_packet_info_t = opj_packet_info;
289
290#[repr(C)]
291#[derive(Copy, Clone, Default)]
292pub struct opj_marker_info {
293  pub type_: core::ffi::c_ushort,
294  pub pos: i64,
295  pub len: core::ffi::c_int,
296}
297pub type opj_marker_info_t = opj_marker_info;
298
299#[repr(C)]
300#[derive(Copy, Clone, Default)]
301pub struct opj_tp_index {
302  pub start_pos: i64,
303  pub end_header: i64,
304  pub end_pos: i64,
305}
306pub type opj_tp_index_t = opj_tp_index;
307
308pub mod consts {
309  /// Constants mirroring the public `openjpeg.h` defines.
310  pub mod opj {
311
312    pub const OPJ_TRUE: u32 = 1;
313    pub const OPJ_FALSE: u32 = 0;
314    /**< Maximum allowed size for filenames */
315    pub const OPJ_PATH_LEN: u32 = 4096;
316    /**< Number of maximum resolution level authorized */
317    pub const OPJ_J2K_MAXRLVLS: u32 = 33;
318    /**< Number of maximum sub-band linked to number of resolution level */
319    pub const OPJ_J2K_MAXBANDS: u32 = 3 * OPJ_J2K_MAXRLVLS - 2;
320    pub const OPJ_J2K_DEFAULT_NB_SEGS: u32 = 10;
321    /** 1 mega by default */
322    pub const OPJ_J2K_STREAM_CHUNK_SIZE: u32 = 0x100000;
323    pub const OPJ_J2K_DEFAULT_HEADER_SIZE: u32 = 1000;
324    pub const OPJ_J2K_MCC_DEFAULT_NB_RECORDS: u32 = 10;
325    pub const OPJ_J2K_MCT_DEFAULT_NB_RECORDS: u32 = 10;
326    /**< Maximum number of tile parts expected by JPWL: increase at your will */
327    pub const JPWL_MAX_NO_TILESPECS: u32 = 16;
328    /**< Maximum number of packet parts expected by JPWL: increase at your will */
329    pub const JPWL_MAX_NO_PACKSPECS: u32 = 16;
330    /**< Maximum number of JPWL markers: increase at your will */
331    pub const JPWL_MAX_NO_MARKERS: u32 = 512;
332    /**< index file name used when JPWL is on */
333    pub const JPWL_PRIVATEINDEX_NAME: &str = "jpwl_index_privatefilename";
334    /**< Expect this number of components, so you'll find better the first EPB */
335    pub const JPWL_EXPECTED_COMPONENTS: u32 = 3;
336    /**< Expect this maximum number of tiles, to avoid some crashes */
337    pub const JPWL_MAXIMUM_TILES: u32 = 8192;
338    /**< Expect this maximum number of bit errors in marker id's */
339    pub const JPWL_MAXIMUM_HAMMING: u32 = 2;
340    /**< Expect this maximum number of bytes for composition of EPBs */
341    pub const JPWL_MAXIMUM_EPB_ROOM: u32 = 65450;
342    /**< Basic image information provided to the user */
343    pub const OPJ_IMG_INFO: u32 = 1;
344    /**< Codestream information based only on the main header */
345    pub const OPJ_J2K_MH_INFO: u32 = 2;
346    /**< Tile information based on the current tile header */
347    pub const OPJ_J2K_TH_INFO: u32 = 4;
348    /**< Tile/Component information of all tiles */
349    pub const OPJ_J2K_TCH_INFO: u32 = 8;
350    /**< Codestream index based only on the main header */
351    pub const OPJ_J2K_MH_IND: u32 = 16;
352    /**< Tile index based on the current tile */
353    pub const OPJ_J2K_TH_IND: u32 = 32;
354    /**< JP2 file information */
355    pub const OPJ_JP2_INFO: u32 = 128;
356    /**< JP2 file index */
357    pub const OPJ_JP2_IND: u32 = 256;
358    /** no profile, conform to 15444-1 */
359    pub const OPJ_PROFILE_NONE: u32 = 0x0000;
360    /** Profile 0 as described in 15444-1,Table A.45 */
361    pub const OPJ_PROFILE_0: u32 = 0x0001;
362    /** Profile 1 as described in 15444-1,Table A.45 */
363    pub const OPJ_PROFILE_1: u32 = 0x0002;
364    /** At least 1 extension defined in 15444-2 (Part-2) */
365    pub const OPJ_PROFILE_PART2: u32 = 0x8000;
366    /** 2K cinema profile defined in 15444-1 AMD1 */
367    pub const OPJ_PROFILE_CINEMA_2K: u32 = 0x0003;
368    /** 4K cinema profile defined in 15444-1 AMD1 */
369    pub const OPJ_PROFILE_CINEMA_4K: u32 = 0x0004;
370    /** Scalable 2K cinema profile defined in 15444-1 AMD2 */
371    pub const OPJ_PROFILE_CINEMA_S2K: u32 = 0x0005;
372    /** Scalable 4K cinema profile defined in 15444-1 AMD2 */
373    pub const OPJ_PROFILE_CINEMA_S4K: u32 = 0x0006;
374    /** Long term storage cinema profile defined in 15444-1 AMD2 */
375    pub const OPJ_PROFILE_CINEMA_LTS: u32 = 0x0007;
376    /** Single Tile Broadcast profile defined in 15444-1 AMD3 */
377    pub const OPJ_PROFILE_BC_SINGLE: u32 = 0x0100;
378    /** Multi Tile Broadcast profile defined in 15444-1 AMD3 */
379    pub const OPJ_PROFILE_BC_MULTI: u32 = 0x0200;
380    /** Multi Tile Reversible Broadcast profile defined in 15444-1 AMD3 */
381    pub const OPJ_PROFILE_BC_MULTI_R: u32 = 0x0300;
382    /** 2K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
383    pub const OPJ_PROFILE_IMF_2K: u32 = 0x0400;
384    /** 4K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
385    pub const OPJ_PROFILE_IMF_4K: u32 = 0x0500;
386    /** 8K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */
387    pub const OPJ_PROFILE_IMF_8K: u32 = 0x0600;
388    /** 2K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
389    pub const OPJ_PROFILE_IMF_2K_R: u32 = 0x0700;
390    /** 4K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
391    pub const OPJ_PROFILE_IMF_4K_R: u32 = 0x0800;
392    /** 8K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */
393    pub const OPJ_PROFILE_IMF_8K_R: u32 = 0x0900;
394    /** No Part-2 extension */
395    pub const OPJ_EXTENSION_NONE: u32 = 0x0000;
396    /** Custom MCT support */
397    pub const OPJ_EXTENSION_MCT: u32 = 0x0100;
398
399    pub fn opj_is_cinema(v: u32) -> bool {
400      (OPJ_PROFILE_CINEMA_2K..=OPJ_PROFILE_CINEMA_S4K).contains(&v)
401    }
402
403    pub fn opj_is_storage(v: u32) -> bool {
404      v == OPJ_PROFILE_CINEMA_LTS
405    }
406
407    pub fn opj_is_broadcast(v: u32) -> bool {
408      (OPJ_PROFILE_BC_SINGLE..=(OPJ_PROFILE_BC_MULTI_R | 0x000b)).contains(&v)
409    }
410
411    pub fn opj_is_imf(v: u32) -> bool {
412      (OPJ_PROFILE_IMF_2K..=(OPJ_PROFILE_IMF_8K_R | 0x009b)).contains(&v)
413    }
414
415    pub fn opj_is_part2(v: u32) -> bool {
416      v & OPJ_PROFILE_PART2 != 0
417    }
418
419    /** Extract IMF profile without mainlevel/sublevel */
420    pub fn opj_get_imf_profile(v: u32) -> u32 {
421      v & 0xff00
422    }
423
424    /** Extract IMF main level */
425    pub fn opj_get_imf_mainlevel(v: u32) -> u32 {
426      v & 0xf
427    }
428
429    /** Extract IMF sub level */
430    pub fn opj_get_imf_sublevel(v: u32) -> u32 {
431      (v >> 4) & 0xf
432    }
433
434    /** Maximum main level */
435    pub const OPJ_IMF_MAINLEVEL_MAX: u32 = 11;
436    /** MSamples/sec for IMF main level 1 */
437    pub const OPJ_IMF_MAINLEVEL_1_MSAMPLESEC: u32 = 65;
438    /** MSamples/sec for IMF main level 2 */
439    pub const OPJ_IMF_MAINLEVEL_2_MSAMPLESEC: u32 = 130;
440    /** MSamples/sec for IMF main level 3 */
441    pub const OPJ_IMF_MAINLEVEL_3_MSAMPLESEC: u32 = 195;
442    /** MSamples/sec for IMF main level 4 */
443    pub const OPJ_IMF_MAINLEVEL_4_MSAMPLESEC: u32 = 260;
444    /** MSamples/sec for IMF main level 5 */
445    pub const OPJ_IMF_MAINLEVEL_5_MSAMPLESEC: u32 = 520;
446    /** MSamples/sec for IMF main level 6 */
447    pub const OPJ_IMF_MAINLEVEL_6_MSAMPLESEC: u32 = 1200;
448    /** MSamples/sec for IMF main level 7 */
449    pub const OPJ_IMF_MAINLEVEL_7_MSAMPLESEC: u32 = 2400;
450    /** MSamples/sec for IMF main level 8 */
451    pub const OPJ_IMF_MAINLEVEL_8_MSAMPLESEC: u32 = 4800;
452    /** MSamples/sec for IMF main level 9 */
453    pub const OPJ_IMF_MAINLEVEL_9_MSAMPLESEC: u32 = 9600;
454    /** MSamples/sec for IMF main level 10 */
455    pub const OPJ_IMF_MAINLEVEL_10_MSAMPLESEC: u32 = 19200;
456    /** MSamples/sec for IMF main level 11 */
457    pub const OPJ_IMF_MAINLEVEL_11_MSAMPLESEC: u32 = 38400;
458    /** Mbits/s for IMF sub level 1 */
459    pub const OPJ_IMF_SUBLEVEL_1_MBITSSEC: u32 = 200;
460    /** Mbits/s for IMF sub level 2 */
461    pub const OPJ_IMF_SUBLEVEL_2_MBITSSEC: u32 = 400;
462    /** Mbits/s for IMF sub level 3 */
463    pub const OPJ_IMF_SUBLEVEL_3_MBITSSEC: u32 = 800;
464    /** Mbits/s for IMF sub level 4 */
465    pub const OPJ_IMF_SUBLEVEL_4_MBITSSEC: u32 = 1600;
466    /** Mbits/s for IMF sub level 5 */
467    pub const OPJ_IMF_SUBLEVEL_5_MBITSSEC: u32 = 3200;
468    /** Mbits/s for IMF sub level 6 */
469    pub const OPJ_IMF_SUBLEVEL_6_MBITSSEC: u32 = 6400;
470    /** Mbits/s for IMF sub level 7 */
471    pub const OPJ_IMF_SUBLEVEL_7_MBITSSEC: u32 = 12800;
472    /** Mbits/s for IMF sub level 8 */
473    pub const OPJ_IMF_SUBLEVEL_8_MBITSSEC: u32 = 25600;
474    /** Mbits/s for IMF sub level 9 */
475    pub const OPJ_IMF_SUBLEVEL_9_MBITSSEC: u32 = 51200;
476    /** Maximum codestream length for 24fps */
477    pub const OPJ_CINEMA_24_CS: u32 = 1302083;
478    /** Maximum codestream length for 48fps */
479    pub const OPJ_CINEMA_48_CS: u32 = 651041;
480    /** Maximum size per color component for 2K & 4K @ 24fps */
481    pub const OPJ_CINEMA_24_COMP: u32 = 1041666;
482    /** Maximum size per color component for 2K @ 48fps */
483    pub const OPJ_CINEMA_48_COMP: u32 = 520833;
484    pub const OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG: u32 = 0x0001;
485    pub const OPJ_DPARAMETERS_DUMP_FLAG: u32 = 0x0002;
486    pub const OPJ_STREAM_READ: u32 = OPJ_TRUE;
487    pub const OPJ_STREAM_WRITE: u32 = OPJ_FALSE;
488  }
489}
490
491#[repr(C)]
492#[derive(Copy, Clone, Default)]
493pub struct opj_image_comptparm {
494  pub dx: u32,
495  pub dy: u32,
496  pub w: u32,
497  pub h: u32,
498  pub x0: u32,
499  pub y0: u32,
500  pub prec: u32,
501  pub bpp: u32,
502  pub sgnd: u32,
503}
504pub type opj_image_cmptparm_t = opj_image_comptparm;