qualia_core_db/medical/dicom_codecs/
profile.rs1#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5pub struct TransferSyntaxProfile {
6 pub preserve_original: bool,
7 pub nested_dataset: bool,
8 pub native_integer_samples: bool,
9 pub encapsulated_decode: bool,
10 pub limitation: Option<&'static str>,
11}
12
13pub fn transfer_syntax_profile(uid: &str) -> TransferSyntaxProfile {
15 let native = matches!(uid, "1.2.840.10008.1.2" | "1.2.840.10008.1.2.1");
16 let rle = uid == "1.2.840.10008.1.2.5";
17 let jpeg_base = uid == "1.2.840.10008.1.2.4.50";
18 let jpeg_ext = uid == "1.2.840.10008.1.2.4.51";
19 let jpegls = matches!(uid, "1.2.840.10008.1.2.4.80" | "1.2.840.10008.1.2.4.81");
20 let j2k = matches!(uid, "1.2.840.10008.1.2.4.90" | "1.2.840.10008.1.2.4.91");
21 let htj2k = matches!(
22 uid,
23 "1.2.840.10008.1.2.4.201" | "1.2.840.10008.1.2.4.202" | "1.2.840.10008.1.2.4.203"
24 );
25 let jxl_pixel = matches!(uid, "1.2.840.10008.1.2.4.110" | "1.2.840.10008.1.2.4.112");
26 let jxl_recomp = uid == "1.2.840.10008.1.2.4.111";
27
28 let encapsulated_known = rle || jpeg_base || jpeg_ext || jpegls || j2k || htj2k || jxl_pixel || jxl_recomp;
29 let encapsulated_decode = rle || jpeg_base || jpeg_ext || jpegls || j2k || jxl_pixel || jxl_recomp;
30
31 let limitation = if native {
32 Some("integer MONOCHROME1/2, BitsAllocated8/16/32; floats/packed1-bit/color not selected")
33 } else if rle {
34 Some("caller-buffered RLE Lossless MONOCHROME1/2,8/16bit; other RLE photometric/packed profiles unsupported")
35 } else if jpeg_base {
36 Some("caller-buffered JPEG Baseline 8-bit MONOCHROME1/2, RGB, YBR_FULL/422; corrupted/mismatched fragments fail closed")
37 } else if jpeg_ext {
38 Some("caller-buffered JPEG Extended 8-bit & pure-Rust 12-bit SOF1 DctSequential MONOCHROME1/2, RGB, YBR_FULL/422")
39 } else if jpegls {
40 Some("pure-Rust ITU-T T.87 JPEG-LS (.80 lossless / .81 near-lossless) MONOCHROME1/2, RGB/YBR, 2..=16-bit")
41 } else if j2k {
42 Some("pure-Rust ISO 15444-1 JPEG 2000 (.90 5/3 lossless, .91 9/7 & 5/3) MQ/EBCOT/RCT/ICT with multi-tile-part SOT concatenation")
43 } else if htj2k {
44 Some("HTJ2K framing/MEL/MagSgn & ITU-T T.814 Annex C CxtVLC tables implemented (decode_j2k_part10_with_annex_c_into); None table arg stays fail-closed")
45 } else if jxl_pixel {
46 Some("pure-Rust ISO 18181-1 JPEG-XL Modular (MA/WP/Palette/RCT/Squeeze), VarDCT (IDCT/CfL/Gaborish/EPF/XYB), and 12-bit multi-bucket rANS")
47 } else if jxl_recomp {
48 Some("decodes JXL pixel codestream, extracts jbrd box, and reconstructs byte-exact legacy JPEG via reconstruct_jpeg_from_jbrd")
49 } else {
50 Some("archive-only unsupported dataset transfer syntax")
51 };
52
53 TransferSyntaxProfile {
54 preserve_original: true,
55 nested_dataset: native || encapsulated_known,
56 native_integer_samples: native,
57 encapsulated_decode,
58 limitation: Some(limitation.expect("all branches populate Some")),
59 }
60}