1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
/// Stream status flags (the C's `stream_status` values).
pub mod cio {
/// Stream is writable.
pub const STREAM_STATUS_OUTPUT: u32 = 0x1u32;
/// Stream is readable.
pub const STREAM_STATUS_INPUT: u32 = 0x2u32;
/// The stream end has been reached.
pub const STREAM_STATUS_END: u32 = 0x4u32;
/// A stream error occurred.
pub const STREAM_STATUS_ERROR: u32 = 0x8u32;
}
/// Event types and constants (ERROR/WARNING/INFO).
pub mod event {
/// The event severity classes emitted through the event manager
/// (and the `log` crate by default).
#[derive(Copy, Clone)]
pub enum EventType {
/// Fatal/corrupt-codestream conditions.
Error = 1,
/// Tolerated deviations.
Warning = 2,
/// Informational messages.
Info = 4,
}
impl EventType {
/// Maps the C ABI's integer event type back to the enum.
pub fn from_i32(v: i32) -> Option<Self> {
match v {
1 => Some(EventType::Error),
2 => Some(EventType::Warning),
4 => Some(EventType::Info),
_ => None,
}
}
}
/// Error event type
pub const EVT_ERROR: EventType = EventType::Error;
/// Warning event type
pub const EVT_WARNING: EventType = EventType::Warning;
/// Debug event type
pub const EVT_INFO: EventType = EventType::Info;
}
/// Enum representing JPIP box types.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
pub enum JpipBoxType {
/// No box type.
#[default]
None,
/// Codestream index
Cidx,
/// Codestream Finder Box
Cptr,
/// Manifest Box
Manf,
/// Fragment array Index box
Faix,
/// Main Header Index Table
Mhix,
/// Tile-part Index Table box
Tpix,
/// Tile header Index Table box
Thix,
/// Precinct Packet Index Table box
Ppix,
/// Packet Header index Table
Phix,
/// File Index
Fidx,
/// File Finder
Fptr,
/// Proxy boxes
Prxy,
/// Index finder box
Iptr,
/// Place holder
Phld,
/// Unknown box type
Unknown(u32),
}
impl From<u32> for JpipBoxType {
fn from(value: u32) -> Self {
match value {
0x63696478 => JpipBoxType::Cidx,
0x63707472 => JpipBoxType::Cptr,
0x6d616e66 => JpipBoxType::Manf,
0x66616978 => JpipBoxType::Faix,
0x6d686978 => JpipBoxType::Mhix,
0x74706978 => JpipBoxType::Tpix,
0x74686978 => JpipBoxType::Thix,
0x70706978 => JpipBoxType::Ppix,
0x70686978 => JpipBoxType::Phix,
0x66696478 => JpipBoxType::Fidx,
0x66707472 => JpipBoxType::Fptr,
0x70727879 => JpipBoxType::Prxy,
0x69707472 => JpipBoxType::Iptr,
0x70686c64 => JpipBoxType::Phld,
_ => JpipBoxType::Unknown(value),
}
}
}
impl JpipBoxType {
/// The four-character-code as a u32 (the JPIP box type word).
pub fn to_u32(self) -> u32 {
match self {
JpipBoxType::None => 0x00000000,
JpipBoxType::Cidx => 0x63696478,
JpipBoxType::Cptr => 0x63707472,
JpipBoxType::Manf => 0x6d616e66,
JpipBoxType::Faix => 0x66616978,
JpipBoxType::Mhix => 0x6d686978,
JpipBoxType::Tpix => 0x74706978,
JpipBoxType::Thix => 0x74686978,
JpipBoxType::Ppix => 0x70706978,
JpipBoxType::Phix => 0x70686978,
JpipBoxType::Fidx => 0x66696478,
JpipBoxType::Fptr => 0x66707472,
JpipBoxType::Prxy => 0x70727879,
JpipBoxType::Iptr => 0x69707472,
JpipBoxType::Phld => 0x70686c64,
JpipBoxType::Unknown(value) => value,
}
}
}
/// Codestream constants: coding styles, code-block styles, marker
/// values, and the tier-1/tier-2 sizing limits.
pub mod j2k {
/// Coding style: precincts per resolution.
pub const J2K_CP_CSTY_PRT: u32 = 0x01;
/// Coding style: SOP markers.
pub const J2K_CP_CSTY_SOP: u32 = 0x02;
/// Coding style: EPH markers.
pub const J2K_CP_CSTY_EPH: u32 = 0x04;
/// Component coding style: precincts per resolution.
pub const J2K_CCP_CSTY_PRT: u32 = 0x01;
/// Selective arithmetic coding bypass
pub const J2K_CCP_CBLKSTY_LAZY: u32 = 0x01;
/// Reset context probabilities on coding pass boundaries
pub const J2K_CCP_CBLKSTY_RESET: u32 = 0x02;
/// Termination on each coding pass
pub const J2K_CCP_CBLKSTY_TERMALL: u32 = 0x04;
/// Vertically stripe causal context
pub const J2K_CCP_CBLKSTY_VSC: u32 = 0x08;
/// Predictable termination
pub const J2K_CCP_CBLKSTY_PTERM: u32 = 0x10;
/// Segmentation symbols are used
pub const J2K_CCP_CBLKSTY_SEGSYM: u32 = 0x20;
/// (high throughput) HT codeblocks
pub const J2K_CCP_CBLKSTY_HT: u32 = 0x40;
/// MIXED mode HT codeblocks
pub const J2K_CCP_CBLKSTY_HTMIXED: u32 = 0x80;
/// Quantisation style: no quantisation.
pub const J2K_CCP_QNTSTY_NOQNT: u32 = 0;
/// Quantisation style: scalar derived (single value).
pub const J2K_CCP_QNTSTY_SIQNT: u32 = 1;
/// Quantisation style: scalar expounded (per band).
pub const J2K_CCP_QNTSTY_SEQNT: u32 = 2;
/// SOC marker value
pub const J2K_MS_SOC: u32 = 0xff4f;
/// SOT marker value
pub const J2K_MS_SOT: u32 = 0xff90;
/// SOD marker value
pub const J2K_MS_SOD: u32 = 0xff93;
/// EOC marker value
pub const J2K_MS_EOC: u32 = 0xffd9;
/// CAP marker value
pub const J2K_MS_CAP: u32 = 0xff50;
/// SIZ marker value
pub const J2K_MS_SIZ: u32 = 0xff51;
/// COD marker value
pub const J2K_MS_COD: u32 = 0xff52;
/// COC marker value
pub const J2K_MS_COC: u32 = 0xff53;
/// CPF marker value
pub const J2K_MS_CPF: u32 = 0xff59;
/// RGN marker value
pub const J2K_MS_RGN: u32 = 0xff5e;
/// QCD marker value
pub const J2K_MS_QCD: u32 = 0xff5c;
/// QCC marker value
pub const J2K_MS_QCC: u32 = 0xff5d;
/// POC marker value
pub const J2K_MS_POC: u32 = 0xff5f;
/// TLM marker value
pub const J2K_MS_TLM: u32 = 0xff55;
/// PLM marker value
pub const J2K_MS_PLM: u32 = 0xff57;
/// PLT marker value
pub const J2K_MS_PLT: u32 = 0xff58;
/// PPM marker value
pub const J2K_MS_PPM: u32 = 0xff60;
/// PPT marker value
pub const J2K_MS_PPT: u32 = 0xff61;
/// SOP marker value
pub const J2K_MS_SOP: u32 = 0xff91;
/// EPH marker value
pub const J2K_MS_EPH: u32 = 0xff92;
/// CRG marker value
pub const J2K_MS_CRG: u32 = 0xff63;
/// COM marker value
pub const J2K_MS_COM: u32 = 0xff64;
/// CBD marker value
pub const J2K_MS_CBD: u32 = 0xff78;
/// MCC marker value
pub const J2K_MS_MCC: u32 = 0xff75;
/// MCT marker value
pub const J2K_MS_MCT: u32 = 0xff74;
/// MCO marker value
pub const J2K_MS_MCO: u32 = 0xff77;
/// UNKNOWN marker value
pub const J2K_MS_UNK: u32 = 0;
/// EPC marker value (Part 11: JPEG 2000 for Wireless)
pub const J2K_MS_EPC: u32 = 0xff68;
/// EPB marker value (Part 11: JPEG 2000 for Wireless)
pub const J2K_MS_EPB: u32 = 0xff66;
/// ESD marker value (Part 11: JPEG 2000 for Wireless)
pub const J2K_MS_ESD: u32 = 0xff67;
/// RED marker value (Part 11: JPEG 2000 for Wireless)
pub const J2K_MS_RED: u32 = 0xff69;
/// SEC marker value (Part 8: Secure JPEG 2000)
pub const J2K_MS_SEC: u32 = 0xff65;
/// INSEC marker value (Part 8: Secure JPEG 2000)
pub const J2K_MS_INSEC: u32 = 0xff94;
/// Maximum number of POCs
pub const J2K_MAX_POCS: u32 = 32;
/// Fixed-alloc matrix: maximum layer count.
pub const J2K_TCD_MATRIX_MAX_LAYER_COUNT: i32 = 10;
/// Fixed-alloc matrix: maximum resolution count.
pub const J2K_TCD_MATRIX_MAX_RESOLUTION_COUNT: i32 = 10;
}
/// JP2 box types (the four-character big-endian box identifiers).
/// The variant names keep the C/ISO spellings (e.g. `FTYP`, `JP2H`).
#[allow(clippy::upper_case_acronyms)]
#[derive(Copy, Clone, Default, Debug, Eq, PartialEq)]
pub enum Jp2BoxType {
/// No box type
#[default]
None,
/// JPIP signature box (`'jpip'`)
JPIP,
/// JPEG 2000 signature box (`'jP '`)
JP,
/// File type box (`'ftyp'`)
FTYP,
/// JP2 header box, super-box (`'jp2h'`)
JP2H,
/// Image header box (`'ihdr'`)
IHDR,
/// Colour specification box (`'colr'`)
COLR,
/// Contiguous codestream box (`'jp2c'`)
JP2C,
/// Data entry URL box (`'url '`)
URL,
/// Palette box (`'pclr'`)
PCLR,
/// Component Mapping box (`'cmap'`)
CMAP,
/// Channel Definition box (`'cdef'`)
CDEF,
/// Data Reference box (`'dtbl'`)
DTBL,
/// Bits per component box (`'bpcc'`)
BPCC,
/// JP2 file signature box (`'jp2 '`)
JP2,
/// Resolution box, super-box (`'res '`)
RES,
/// Intellectual property box (`'jp2i'`)
JP2I,
/// XML box (`'xml '`)
XML,
/// UUID box (`'uuid'`)
UUID,
/// UUID info box, super-box (`'uinf'`)
UINF,
/// Unknown box type
Unknown(u32),
}
impl From<u32> for Jp2BoxType {
fn from(value: u32) -> Self {
match value {
0x6a706970 => Jp2BoxType::JPIP,
0x6a502020 => Jp2BoxType::JP,
0x66747970 => Jp2BoxType::FTYP,
0x6a703268 => Jp2BoxType::JP2H,
0x69686472 => Jp2BoxType::IHDR,
0x636f6c72 => Jp2BoxType::COLR,
0x6a703263 => Jp2BoxType::JP2C,
0x75726c20 => Jp2BoxType::URL,
0x70636c72 => Jp2BoxType::PCLR,
0x636d6170 => Jp2BoxType::CMAP,
0x63646566 => Jp2BoxType::CDEF,
0x6474626c => Jp2BoxType::DTBL,
0x62706363 => Jp2BoxType::BPCC,
0x6a703220 => Jp2BoxType::JP2,
0x72657320 => Jp2BoxType::RES,
0x6a703269 => Jp2BoxType::JP2I,
0x786d6c20 => Jp2BoxType::XML,
0x75756964 => Jp2BoxType::UUID,
0x75696e66 => Jp2BoxType::UINF,
_ => Jp2BoxType::Unknown(value),
}
}
}
impl Jp2BoxType {
/// Whether the box belongs in the file-level (non-`jp2h`) group.
pub fn is_file_header(&self) -> bool {
matches!(self, Jp2BoxType::JP | Jp2BoxType::FTYP | Jp2BoxType::JP2H)
}
/// Whether the box belongs inside the `jp2h` super-box.
pub fn is_image_header(&self) -> bool {
matches!(
self,
Jp2BoxType::IHDR
| Jp2BoxType::COLR
| Jp2BoxType::BPCC
| Jp2BoxType::PCLR
| Jp2BoxType::CMAP
| Jp2BoxType::CDEF
)
}
/// Converts the enum variant back into a u32 value.
pub fn to_u32(self) -> Option<u32> {
match self {
Jp2BoxType::None => None,
Jp2BoxType::JPIP => Some(0x6a706970),
Jp2BoxType::JP => Some(0x6a502020),
Jp2BoxType::FTYP => Some(0x66747970),
Jp2BoxType::JP2H => Some(0x6a703268),
Jp2BoxType::IHDR => Some(0x69686472),
Jp2BoxType::COLR => Some(0x636f6c72),
Jp2BoxType::JP2C => Some(0x6a703263),
Jp2BoxType::URL => Some(0x75726c20),
Jp2BoxType::PCLR => Some(0x70636c72),
Jp2BoxType::CMAP => Some(0x636d6170),
Jp2BoxType::CDEF => Some(0x63646566),
Jp2BoxType::DTBL => Some(0x6474626c),
Jp2BoxType::BPCC => Some(0x62706363),
Jp2BoxType::JP2 => Some(0x6a703220),
Jp2BoxType::RES => Some(0x72657320),
Jp2BoxType::JP2I => Some(0x6a703269),
Jp2BoxType::XML => Some(0x786d6c20),
Jp2BoxType::UUID => Some(0x75756964),
Jp2BoxType::UINF => Some(0x75696e66),
Jp2BoxType::Unknown(value) => Some(value),
}
}
}
/// MQ-coder constants.
pub mod mqc {
/// Number of MQ contexts.
pub const MQC_NUMCTXS: usize = 19;
/// The bypass-mode initial count sentinel.
pub const BYPASS_CT_INIT: u32 = 0xDEADBEEF;
}
/// Shared defaults (code-block size, progression, resolutions).
pub mod common {
/// Margin for a fake FFFF marker
pub const COMMON_CBLK_DATA_EXTRA: u32 = 2;
/// Default code-block width.
pub const COMP_PARAM_DEFAULT_CBLOCKW: u32 = 64;
/// Default code-block height.
pub const COMP_PARAM_DEFAULT_CBLOCKH: u32 = 64;
/// Default progression order.
pub const COMP_PARAM_DEFAULT_PROG_ORDER: i32 =
crate::j2k::ProgressionOrder::LRCP as core::ffi::c_int;
/// Default decomposition levels.
pub const COMP_PARAM_DEFAULT_NUMRESOLUTION: u32 = 6;
}
/// Tier-1 flags and context indices (significance/refinement bit
/// masks and the MQ context offsets).
pub mod t1 {
/// Fractional bits of the NMSE-decay look-up table.
pub const T1_NMSEDEC_BITS: u32 = 7;
/// Zero-coding context count.
pub const T1_NUMCTXS_ZC: u8 = 9;
/// Sign-coding context count.
pub const T1_NUMCTXS_SC: u8 = 5;
/// Magnitude-refinement context count.
pub const T1_NUMCTXS_MAG: u8 = 3;
/// Aggregation context count.
pub const T1_NUMCTXS_AGG: u8 = 1;
/// Uniform context count.
pub const T1_NUMCTXS_UNI: u8 = 1;
/// Zero-coding context index (0).
pub const T1_CTXNO_ZC: u8 = 0;
/// Sign-coding context index.
pub const T1_CTXNO_SC: u8 = T1_CTXNO_ZC + T1_NUMCTXS_ZC;
/// Magnitude-refinement context index.
pub const T1_CTXNO_MAG: u8 = T1_CTXNO_SC + T1_NUMCTXS_SC;
/// Aggregation context index.
pub const T1_CTXNO_AGG: u8 = T1_CTXNO_MAG + T1_NUMCTXS_MAG;
/// Uniform context index.
pub const T1_CTXNO_UNI: u8 = T1_CTXNO_AGG + T1_NUMCTXS_AGG;
/// Total context count.
pub const T1_NUMCTXS: u8 = T1_CTXNO_UNI + T1_NUMCTXS_UNI;
/// The NMSE-decay look-up fractional shift.
pub const T1_NMSEDEC_FRACBITS: i32 = (T1_NMSEDEC_BITS - 1) as i32;
/// Normal coding using entropy coder
pub const T1_TYPE_MQ: u8 = 0;
/// No entropy coding: information stored raw in the codestream (mode-switch RAW).
pub const T1_TYPE_RAW: u8 = 1;
/// Significance state bit for each of the eight neighbours
/// (`T1_SIGMA_0`..`T1_SIGMA_8`); the neighbour masks combine them
/// (`T1_SIGMA_NW`..`T1_SIGMA_SE`).
pub const T1_SIGMA_0: u32 = 1u32 << 0;
/// Significance state bit for neighbour 1.
pub const T1_SIGMA_1: u32 = 1u32 << 1;
/// Significance state bit for neighbour 2.
pub const T1_SIGMA_2: u32 = 1u32 << 2;
/// Significance state bit for neighbour 3.
pub const T1_SIGMA_3: u32 = 1u32 << 3;
/// Significance state bit for neighbour 4.
pub const T1_SIGMA_4: u32 = 1u32 << 4;
/// Significance state bit for neighbour 5.
pub const T1_SIGMA_5: u32 = 1u32 << 5;
/// Significance state bit for neighbour 6.
pub const T1_SIGMA_6: u32 = 1u32 << 6;
/// Significance state bit for neighbour 7.
pub const T1_SIGMA_7: u32 = 1u32 << 7;
/// Significance state bit for neighbour 8.
pub const T1_SIGMA_8: u32 = 1u32 << 8;
/// Significance state bit for neighbour 9.
pub const T1_SIGMA_9: u32 = 1u32 << 9;
/// Significance state bit for neighbour 10.
pub const T1_SIGMA_10: u32 = 1u32 << 10;
/// Significance state bit for neighbour 11.
pub const T1_SIGMA_11: u32 = 1u32 << 11;
/// Significance state bit for neighbour 12.
pub const T1_SIGMA_12: u32 = 1u32 << 12;
/// Significance state bit for neighbour 13.
pub const T1_SIGMA_13: u32 = 1u32 << 13;
/// Significance state bit for neighbour 14.
pub const T1_SIGMA_14: u32 = 1u32 << 14;
/// Significance state bit for neighbour 15.
pub const T1_SIGMA_15: u32 = 1u32 << 15;
/// Significance state bit for neighbour 16.
pub const T1_SIGMA_16: u32 = 1u32 << 16;
/// Significance state bit for neighbour 17.
pub const T1_SIGMA_17: u32 = 1u32 << 17;
/// Refinement-state bit 0.
pub const T1_CHI_0: u32 = 1u32 << 18;
/// Refinement-state bit 0 index.
pub const T1_CHI_0_I: u32 = 18;
/// Refinement-state bit 1.
pub const T1_CHI_1: u32 = 1u32 << 19;
/// Refinement-state bit 1 index.
pub const T1_CHI_1_I: u32 = 19;
/// Magnitude-refinement-state bit 0.
pub const T1_MU_0: u32 = 1u32 << 20;
/// Refinement-pass-state bit 0.
pub const T1_PI_0: u32 = 1u32 << 21;
/// Refinement-state bit 2.
pub const T1_CHI_2: u32 = 1u32 << 22;
/// Refinement-state bit 2 index.
pub const T1_CHI_2_I: u32 = 22;
/// Magnitude-refinement-state bit 1.
pub const T1_MU_1: u32 = 1u32 << 23;
/// Refinement-pass-state bit 1.
pub const T1_PI_1: u32 = 1u32 << 24;
/// Refinement-state bit 3.
pub const T1_CHI_3: u32 = 1u32 << 25;
/// Magnitude-refinement-state bit 2.
pub const T1_MU_2: u32 = 1u32 << 26;
/// Refinement-pass-state bit 2.
pub const T1_PI_2: u32 = 1u32 << 27;
/// Refinement-state bit 4.
pub const T1_CHI_4: u32 = 1u32 << 28;
/// Magnitude-refinement-state bit 3.
pub const T1_MU_3: u32 = 1u32 << 29;
/// Refinement-pass-state bit 3.
pub const T1_PI_3: u32 = 1u32 << 30;
/// Refinement-state bit 5.
pub const T1_CHI_5: u32 = 1u32 << 31;
/// Refinement-state bit 5 index.
pub const T1_CHI_5_I: u32 = 31;
/// Significance of the north-west neighbour.
pub const T1_SIGMA_NW: u32 = T1_SIGMA_0;
/// Significance of the north neighbour.
pub const T1_SIGMA_N: u32 = T1_SIGMA_1;
/// Significance of the north-east neighbour.
pub const T1_SIGMA_NE: u32 = T1_SIGMA_2;
/// Significance of the west neighbour.
pub const T1_SIGMA_W: u32 = T1_SIGMA_3;
/// Significance of the current sample.
pub const T1_SIGMA_THIS: u32 = T1_SIGMA_4;
/// Significance of the east neighbour.
pub const T1_SIGMA_E: u32 = T1_SIGMA_5;
/// Significance of the south-west neighbour.
pub const T1_SIGMA_SW: u32 = T1_SIGMA_6;
/// Significance of the south neighbour.
pub const T1_SIGMA_S: u32 = T1_SIGMA_7;
/// Significance of the south-east neighbour.
pub const T1_SIGMA_SE: u32 = T1_SIGMA_8;
/// Combined mask of all eight neighbour significance bits.
pub const T1_SIGMA_NEIGHBOURS: u32 = T1_SIGMA_NW
| T1_SIGMA_N
| T1_SIGMA_NE
| T1_SIGMA_W
| T1_SIGMA_E
| T1_SIGMA_SW
| T1_SIGMA_S
| T1_SIGMA_SE;
/// Refinement state of the current sample.
pub const T1_CHI_THIS: u32 = T1_CHI_1;
/// Refinement-state index of the current sample.
pub const T1_CHI_THIS_I: u32 = T1_CHI_1_I;
/// Magnitude-refinement state of the current sample.
pub const T1_MU_THIS: u32 = T1_MU_0;
/// Refinement-pass state of the current sample.
pub const T1_PI_THIS: u32 = T1_PI_0;
/// Refinement state of the south neighbour.
pub const T1_CHI_S: u32 = T1_CHI_2;
/// Sign LUT: west sign bit.
pub const T1_LUT_SGN_W: u32 = 1u32 << 0;
/// Significance LUT: north bit.
pub const T1_LUT_SIG_N: u32 = 1u32 << 1;
/// Sign LUT: east sign bit.
pub const T1_LUT_SGN_E: u32 = 1u32 << 2;
/// Significance LUT: west bit.
pub const T1_LUT_SIG_W: u32 = 1u32 << 3;
/// Sign LUT: north sign bit.
pub const T1_LUT_SGN_N: u32 = 1u32 << 4;
/// Significance LUT: east bit.
pub const T1_LUT_SIG_E: u32 = 1u32 << 5;
/// Sign LUT: south sign bit.
pub const T1_LUT_SGN_S: u32 = 1u32 << 6;
/// Significance LUT: south bit.
pub const T1_LUT_SIG_S: u32 = 1u32 << 7;
}
pub use common::*;
pub use event::*;
pub use j2k::*;
pub use mqc::*;
// Native names for the `openjpeg.h` constants the codec modules use
// (the C spellings stay in openjp2-ctypes; the core is C-name-free).
pub const J2K_MAXRLVLS: u32 = 33;
pub const J2K_MAXBANDS: u32 = 3 * J2K_MAXRLVLS - 2;
pub const PROFILE_CINEMA_2K: u16 = 3;
/// The codec stream buffer size (the C's `J2K_STREAM_CHUNK_SIZE`).
pub const J2K_STREAM_CHUNK_SIZE: u32 = 0x100000;
/// Dump flags for `dump_codec` (the C's `IMG_INFO` etc.).
pub const IMG_INFO: u32 = 1;
pub const J2K_MH_INFO: u32 = 2;
pub const J2K_MH_IND: u32 = 16;
pub use t1::*;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_jpip_box_type_roundtrip() {
let values = [
JpipBoxType::Cidx,
JpipBoxType::Cptr,
JpipBoxType::Manf,
JpipBoxType::Faix,
JpipBoxType::Mhix,
JpipBoxType::Tpix,
JpipBoxType::Thix,
JpipBoxType::Ppix,
JpipBoxType::Phix,
JpipBoxType::Fidx,
JpipBoxType::Fptr,
JpipBoxType::Prxy,
JpipBoxType::Iptr,
JpipBoxType::Phld,
JpipBoxType::Unknown(123),
];
for value in values.iter() {
let u32_value = value.to_u32();
let converted_value = JpipBoxType::from(u32_value);
assert_eq!(*value, converted_value);
}
}
#[test]
fn test_jp2_box_type_roundtrip() {
let variants = [
Jp2BoxType::JPIP,
Jp2BoxType::JP,
Jp2BoxType::FTYP,
Jp2BoxType::JP2H,
Jp2BoxType::IHDR,
Jp2BoxType::COLR,
Jp2BoxType::JP2C,
Jp2BoxType::URL,
Jp2BoxType::PCLR,
Jp2BoxType::CMAP,
Jp2BoxType::CDEF,
Jp2BoxType::DTBL,
Jp2BoxType::BPCC,
Jp2BoxType::JP2,
Jp2BoxType::RES,
Jp2BoxType::JP2I,
Jp2BoxType::XML,
Jp2BoxType::UUID,
Jp2BoxType::UINF,
Jp2BoxType::Unknown(123),
];
for variant in &variants {
let value = variant.to_u32().unwrap();
let roundtrip_variant = Jp2BoxType::from(value);
assert_eq!(*variant, roundtrip_variant);
}
}
}