heic 0.1.4

Pure Rust HEIC/HEIF image decoder with SIMD acceleration
Documentation
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
//! Auxiliary image types and depth map extraction.
//!
//! HEIF files can contain auxiliary images linked to the primary image via
//! `auxl` item references. Each auxiliary image has an `auxC` property box
//! containing a URN string that identifies its type.
//!
//! This module provides:
//! - [`AuxiliaryImageType`]: enum for known auxiliary image types
//! - [`DepthRepresentationInfo`]: parsed depth representation metadata
//! - Depth map extraction via [`DecoderConfig::decode_depth`](crate::DecoderConfig::decode_depth)

use alloc::string::String;
use alloc::vec::Vec;

/// Identifies the type of an auxiliary image in a HEIF container.
///
/// Auxiliary images are linked to the primary image via `auxl` references
/// and identified by a URN string in their `auxC` property box.
///
/// # Known URNs
///
/// | Type | URN |
/// |------|-----|
/// | Alpha | `urn:mpeg:hevc:2015:auxid:1` or `urn:mpeg:mpegB:cicp:systems:auxiliary:alpha` |
/// | Depth | `urn:mpeg:hevc:2015:auxid:2` or `urn:mpeg:mpegB:cicp:systems:auxiliary:depth` |
/// | Portrait matte | `urn:com:apple:photo:2018:aux:portraiteffectsmatte` |
/// | HDR gain map | `urn:com:apple:photo:2020:aux:hdrgainmap` |
/// | Skin matte | `urn:com:apple:photo:2019:aux:semanticskinmatte` |
/// | Teeth matte | `urn:com:apple:photo:2019:aux:semanticteethmatte` |
/// | Hair matte | `urn:com:apple:photo:2019:aux:semantichairmatte` |
/// | Glasses matte | `urn:com:apple:photo:2020:aux:semanticglassesmatte` |
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum AuxiliaryImageType {
    /// Alpha plane (`urn:mpeg:hevc:2015:auxid:1`)
    Alpha,
    /// Depth map (`urn:mpeg:hevc:2015:auxid:2`)
    Depth,
    /// Portrait effects matte (`urn:com:apple:photo:2018:aux:portraiteffectsmatte`)
    PortraitMatte,
    /// HDR gain map (`urn:com:apple:photo:2020:aux:hdrgainmap`)
    HdrGainMap,
    /// Semantic skin matte (`urn:com:apple:photo:2019:aux:semanticskinmatte`)
    SkinMatte,
    /// Semantic teeth matte (`urn:com:apple:photo:2019:aux:semanticteethmatte`)
    TeethMatte,
    /// Semantic hair matte (`urn:com:apple:photo:2019:aux:semantichairmatte`)
    HairMatte,
    /// Semantic glasses matte (`urn:com:apple:photo:2020:aux:semanticglassesmatte`)
    GlassesMatte,
    /// Unknown auxiliary type with its raw URN string
    Other(String),
}

impl AuxiliaryImageType {
    /// Parse an auxiliary type from a URN string (from `auxC` box).
    #[must_use]
    pub fn from_urn(urn: &str) -> Self {
        match urn {
            "urn:mpeg:hevc:2015:auxid:1" | "urn:mpeg:mpegB:cicp:systems:auxiliary:alpha" => {
                Self::Alpha
            }
            "urn:mpeg:hevc:2015:auxid:2" | "urn:mpeg:mpegB:cicp:systems:auxiliary:depth" => {
                Self::Depth
            }
            "urn:com:apple:photo:2018:aux:portraiteffectsmatte" => Self::PortraitMatte,
            "urn:com:apple:photo:2020:aux:hdrgainmap" => Self::HdrGainMap,
            "urn:com:apple:photo:2019:aux:semanticskinmatte" => Self::SkinMatte,
            "urn:com:apple:photo:2019:aux:semanticteethmatte" => Self::TeethMatte,
            "urn:com:apple:photo:2019:aux:semantichairmatte" => Self::HairMatte,
            "urn:com:apple:photo:2020:aux:semanticglassesmatte" => Self::GlassesMatte,
            other => Self::Other(String::from(other)),
        }
    }

    /// The canonical URN string for this auxiliary type.
    ///
    /// For [`Other`](Self::Other), returns the stored string.
    #[must_use]
    pub fn urn(&self) -> &str {
        match self {
            Self::Alpha => "urn:mpeg:hevc:2015:auxid:1",
            Self::Depth => "urn:mpeg:hevc:2015:auxid:2",
            Self::PortraitMatte => "urn:com:apple:photo:2018:aux:portraiteffectsmatte",
            Self::HdrGainMap => "urn:com:apple:photo:2020:aux:hdrgainmap",
            Self::SkinMatte => "urn:com:apple:photo:2019:aux:semanticskinmatte",
            Self::TeethMatte => "urn:com:apple:photo:2019:aux:semanticteethmatte",
            Self::HairMatte => "urn:com:apple:photo:2019:aux:semantichairmatte",
            Self::GlassesMatte => "urn:com:apple:photo:2020:aux:semanticglassesmatte",
            Self::Other(s) => s.as_str(),
        }
    }
}

impl core::fmt::Display for AuxiliaryImageType {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::Alpha => write!(f, "Alpha"),
            Self::Depth => write!(f, "Depth"),
            Self::PortraitMatte => write!(f, "PortraitMatte"),
            Self::HdrGainMap => write!(f, "HdrGainMap"),
            Self::SkinMatte => write!(f, "SkinMatte"),
            Self::TeethMatte => write!(f, "TeethMatte"),
            Self::HairMatte => write!(f, "HairMatte"),
            Self::GlassesMatte => write!(f, "GlassesMatte"),
            Self::Other(s) => write!(f, "Other({s})"),
        }
    }
}

/// How the depth values in a depth auxiliary image should be interpreted.
///
/// Defined by ISO/IEC 23008-12 depth representation SEI and auxC subtype data.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[non_exhaustive]
pub enum DepthRepresentationType {
    /// Uniform inverse Z (type 0) -- default for most iPhone depth maps
    #[default]
    UniformInverseZ,
    /// Uniform disparity (type 1)
    UniformDisparity,
    /// Uniform Z (type 2)
    UniformZ,
    /// Nonuniform disparity (type 3)
    NonuniformDisparity,
}

impl DepthRepresentationType {
    /// Parse from the integer code in the depth representation info.
    #[must_use]
    pub fn from_code(code: u8) -> Option<Self> {
        match code {
            0 => Some(Self::UniformInverseZ),
            1 => Some(Self::UniformDisparity),
            2 => Some(Self::UniformZ),
            3 => Some(Self::NonuniformDisparity),
            _ => None,
        }
    }

    /// Integer code for this representation type.
    #[must_use]
    pub fn code(self) -> u8 {
        match self {
            Self::UniformInverseZ => 0,
            Self::UniformDisparity => 1,
            Self::UniformZ => 2,
            Self::NonuniformDisparity => 3,
        }
    }
}

impl core::fmt::Display for DepthRepresentationType {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::UniformInverseZ => write!(f, "UniformInverseZ"),
            Self::UniformDisparity => write!(f, "UniformDisparity"),
            Self::UniformZ => write!(f, "UniformZ"),
            Self::NonuniformDisparity => write!(f, "NonuniformDisparity"),
        }
    }
}

/// Depth representation information parsed from auxC subtype data.
///
/// The auxC box for depth auxiliary images may contain additional bytes
/// after the null-terminated URN that describe the depth representation.
/// This follows the ISO/IEC 23008-12 depth representation info structure.
///
/// iPhone depth maps typically use `UniformInverseZ` with
/// z_near/z_far describing the scene depth range.
#[derive(Debug, Clone, Default)]
#[non_exhaustive]
pub struct DepthRepresentationInfo {
    /// Near clipping plane distance. `None` if not specified.
    pub z_near: Option<f64>,
    /// Far clipping plane distance. `None` if not specified.
    pub z_far: Option<f64>,
    /// Minimum disparity value. `None` if not specified.
    pub d_min: Option<f64>,
    /// Maximum disparity value. `None` if not specified.
    pub d_max: Option<f64>,
    /// How the depth values should be interpreted.
    pub representation_type: DepthRepresentationType,
}

/// Decoded depth map from a HEIF auxiliary depth image.
///
/// The pixel data is grayscale (single channel), representing depth or
/// disparity values. Interpretation depends on
/// [`DepthRepresentationInfo::representation_type`].
///
/// Bit depths of 8 and 10 are common. The `bit_depth` field indicates
/// how many bits are significant in each `u16` sample.
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct DepthMap {
    /// Grayscale depth pixels as u16 samples.
    ///
    /// For 8-bit depth maps, values are in `[0, 255]`.
    /// For 10-bit depth maps, values are in `[0, 1023]`.
    pub data: Vec<u16>,
    /// Width in pixels
    pub width: u32,
    /// Height in pixels
    pub height: u32,
    /// Significant bits per sample (typically 8 or 10)
    pub bit_depth: u8,
    /// Depth representation metadata
    pub depth_info: DepthRepresentationInfo,
}

/// Descriptor for an auxiliary image found in the container.
///
/// Returned by [`DecoderConfig::auxiliary_images`](crate::DecoderConfig::auxiliary_images).
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct AuxiliaryImageDescriptor {
    /// The type of this auxiliary image
    pub aux_type: AuxiliaryImageType,
    /// Item ID in the HEIF container (for advanced use)
    pub item_id: u32,
    /// Image dimensions (width, height) if known from `ispe` box.
    /// May be `None` if the item lacks spatial extent metadata.
    pub dimensions: Option<(u32, u32)>,
}

/// A decoded segmentation matte from a HEIC file.
///
/// iPhone cameras store portrait mattes, skin/hair/teeth/glasses mattes
/// as monochrome HEVC auxiliary images. Each matte is a grayscale mask
/// scaled to 8-bit.
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct SegmentationMatte {
    /// Grayscale mask pixels (u8, 0 = background, 255 = foreground).
    pub data: alloc::vec::Vec<u8>,
    /// Matte width in pixels.
    pub width: u32,
    /// Matte height in pixels.
    pub height: u32,
    /// What this matte segments.
    pub matte_type: AuxiliaryImageType,
}

/// Parse depth representation info from the auxC subtype bytes
/// (the bytes after the null-terminated URN in the auxC box content).
///
/// Format (ISO/IEC 23008-12, A.3):
/// ```text
/// depth_representation_type: u8
/// flags: u8
///   bit 0: z_near_flag
///   bit 1: z_far_flag
///   bit 2: d_min_flag
///   bit 3: d_max_flag
/// If z_near_flag: z_near as DepthRepValueSigned (4 bytes: i16 mantissa + u8 exponent + u8 sign)
/// If z_far_flag:  z_far  as DepthRepValueSigned
/// If d_min_flag:  d_min  as DepthRepValueSigned
/// If d_max_flag:  d_max  as DepthRepValueSigned
/// ```
pub(crate) fn parse_depth_representation_info(subtype_data: &[u8]) -> DepthRepresentationInfo {
    if subtype_data.len() < 2 {
        return DepthRepresentationInfo::default();
    }

    let rep_type_code = subtype_data[0];
    let representation_type = DepthRepresentationType::from_code(rep_type_code)
        .unwrap_or(DepthRepresentationType::UniformInverseZ);

    let flags = subtype_data[1];
    let z_near_flag = (flags & 0x01) != 0;
    let z_far_flag = (flags & 0x02) != 0;
    let d_min_flag = (flags & 0x04) != 0;
    let d_max_flag = (flags & 0x08) != 0;

    let mut pos = 2;

    let z_near = if z_near_flag {
        parse_depth_rep_value(subtype_data, &mut pos)
    } else {
        None
    };

    let z_far = if z_far_flag {
        parse_depth_rep_value(subtype_data, &mut pos)
    } else {
        None
    };

    let d_min = if d_min_flag {
        parse_depth_rep_value(subtype_data, &mut pos)
    } else {
        None
    };

    let d_max = if d_max_flag {
        parse_depth_rep_value(subtype_data, &mut pos)
    } else {
        None
    };

    DepthRepresentationInfo {
        z_near,
        z_far,
        d_min,
        d_max,
        representation_type,
    }
}

/// Parse a single DepthRepValueSigned from a byte slice.
///
/// Format: `mantissa(i16) | exponent(u8) | sign(u8)`
/// Value = (-1)^sign * mantissa * 2^exponent
///
/// Returns `None` if not enough data.
fn parse_depth_rep_value(data: &[u8], pos: &mut usize) -> Option<f64> {
    if *pos + 4 > data.len() {
        return None;
    }

    let mantissa = i16::from_be_bytes([data[*pos], data[*pos + 1]]);
    let exponent = data[*pos + 2];
    let sign = data[*pos + 3];
    *pos += 4;

    // value = (-1)^sign * mantissa * 2^exponent
    let value = (mantissa as f64) * pow2_f64(exponent as i32);
    if sign != 0 { Some(-value) } else { Some(value) }
}

/// Compute 2^exp for a non-negative integer exponent, no_std compatible.
fn pow2_f64(exp: i32) -> f64 {
    if exp == 0 {
        1.0
    } else if exp > 0 && exp < 64 {
        (1u64 << exp as u32) as f64
    } else {
        // Fallback for large or negative exponents
        let mut result = 1.0f64;
        if exp > 0 {
            for _ in 0..exp {
                result *= 2.0;
            }
        } else {
            for _ in 0..(-exp) {
                result *= 0.5;
            }
        }
        result
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_auxiliary_type_from_urn_alpha() {
        assert_eq!(
            AuxiliaryImageType::from_urn("urn:mpeg:hevc:2015:auxid:1"),
            AuxiliaryImageType::Alpha
        );
        assert_eq!(
            AuxiliaryImageType::from_urn("urn:mpeg:mpegB:cicp:systems:auxiliary:alpha"),
            AuxiliaryImageType::Alpha
        );
    }

    #[test]
    fn test_auxiliary_type_from_urn_depth() {
        assert_eq!(
            AuxiliaryImageType::from_urn("urn:mpeg:hevc:2015:auxid:2"),
            AuxiliaryImageType::Depth
        );
        assert_eq!(
            AuxiliaryImageType::from_urn("urn:mpeg:mpegB:cicp:systems:auxiliary:depth"),
            AuxiliaryImageType::Depth
        );
    }

    #[test]
    fn test_auxiliary_type_from_urn_apple_types() {
        assert_eq!(
            AuxiliaryImageType::from_urn("urn:com:apple:photo:2018:aux:portraiteffectsmatte"),
            AuxiliaryImageType::PortraitMatte
        );
        assert_eq!(
            AuxiliaryImageType::from_urn("urn:com:apple:photo:2020:aux:hdrgainmap"),
            AuxiliaryImageType::HdrGainMap
        );
        assert_eq!(
            AuxiliaryImageType::from_urn("urn:com:apple:photo:2019:aux:semanticskinmatte"),
            AuxiliaryImageType::SkinMatte
        );
        assert_eq!(
            AuxiliaryImageType::from_urn("urn:com:apple:photo:2019:aux:semanticteethmatte"),
            AuxiliaryImageType::TeethMatte
        );
        assert_eq!(
            AuxiliaryImageType::from_urn("urn:com:apple:photo:2019:aux:semantichairmatte"),
            AuxiliaryImageType::HairMatte
        );
        assert_eq!(
            AuxiliaryImageType::from_urn("urn:com:apple:photo:2020:aux:semanticglassesmatte"),
            AuxiliaryImageType::GlassesMatte
        );
    }

    #[test]
    fn test_auxiliary_type_from_urn_unknown() {
        let t = AuxiliaryImageType::from_urn("urn:example:custom:type");
        assert_eq!(
            t,
            AuxiliaryImageType::Other(String::from("urn:example:custom:type"))
        );
    }

    #[test]
    fn test_auxiliary_type_from_urn_empty() {
        let t = AuxiliaryImageType::from_urn("");
        assert_eq!(t, AuxiliaryImageType::Other(String::from("")));
    }

    #[test]
    fn test_auxiliary_type_roundtrip() {
        let types = [
            AuxiliaryImageType::Alpha,
            AuxiliaryImageType::Depth,
            AuxiliaryImageType::PortraitMatte,
            AuxiliaryImageType::HdrGainMap,
            AuxiliaryImageType::SkinMatte,
            AuxiliaryImageType::TeethMatte,
            AuxiliaryImageType::HairMatte,
            AuxiliaryImageType::GlassesMatte,
        ];
        for t in &types {
            let urn = t.urn();
            let parsed = AuxiliaryImageType::from_urn(urn);
            assert_eq!(&parsed, t, "roundtrip failed for {t}");
        }
    }

    #[test]
    fn test_depth_representation_type_from_code() {
        assert_eq!(
            DepthRepresentationType::from_code(0),
            Some(DepthRepresentationType::UniformInverseZ)
        );
        assert_eq!(
            DepthRepresentationType::from_code(1),
            Some(DepthRepresentationType::UniformDisparity)
        );
        assert_eq!(
            DepthRepresentationType::from_code(2),
            Some(DepthRepresentationType::UniformZ)
        );
        assert_eq!(
            DepthRepresentationType::from_code(3),
            Some(DepthRepresentationType::NonuniformDisparity)
        );
        assert_eq!(DepthRepresentationType::from_code(4), None);
        assert_eq!(DepthRepresentationType::from_code(255), None);
    }

    #[test]
    fn test_depth_representation_type_roundtrip() {
        for code in 0..4 {
            let t = DepthRepresentationType::from_code(code).unwrap();
            assert_eq!(t.code(), code);
        }
    }

    #[test]
    fn test_parse_depth_representation_info_empty() {
        let info = parse_depth_representation_info(&[]);
        assert_eq!(
            info.representation_type,
            DepthRepresentationType::UniformInverseZ
        );
        assert!(info.z_near.is_none());
        assert!(info.z_far.is_none());
        assert!(info.d_min.is_none());
        assert!(info.d_max.is_none());
    }

    #[test]
    fn test_parse_depth_representation_info_type_only() {
        // Type=2 (UniformZ), no flags
        let info = parse_depth_representation_info(&[2, 0]);
        assert_eq!(info.representation_type, DepthRepresentationType::UniformZ);
        assert!(info.z_near.is_none());
    }

    #[test]
    fn test_parse_depth_representation_info_with_z_near_far() {
        // Type=0 (UniformInverseZ), flags=0x03 (z_near + z_far)
        // z_near: mantissa=100 (0x0064), exponent=0, sign=0 => 100.0
        // z_far:  mantissa=500 (0x01F4), exponent=0, sign=0 => 500.0
        let data = [
            0,    // representation_type
            0x03, // flags: z_near + z_far
            0x00, 0x64, 0x00, 0x00, // z_near = 100
            0x01, 0xF4, 0x00, 0x00, // z_far = 500
        ];
        let info = parse_depth_representation_info(&data);
        assert_eq!(
            info.representation_type,
            DepthRepresentationType::UniformInverseZ
        );
        assert!((info.z_near.unwrap() - 100.0).abs() < f64::EPSILON);
        assert!((info.z_far.unwrap() - 500.0).abs() < f64::EPSILON);
        assert!(info.d_min.is_none());
        assert!(info.d_max.is_none());
    }

    #[test]
    fn test_parse_depth_representation_info_with_all_values() {
        // Type=1 (UniformDisparity), flags=0x0F (all four)
        // z_near: mantissa=10, exponent=1, sign=0 => 10 * 2 = 20.0
        // z_far:  mantissa=50, exponent=2, sign=0 => 50 * 4 = 200.0
        // d_min:  mantissa=1,  exponent=0, sign=1 => -1.0
        // d_max:  mantissa=255, exponent=0, sign=0 => 255.0
        let data = [
            1,    // representation_type
            0x0F, // flags: all four
            0x00, 0x0A, 0x01, 0x00, // z_near = 10 * 2^1 = 20
            0x00, 0x32, 0x02, 0x00, // z_far = 50 * 2^2 = 200
            0x00, 0x01, 0x00, 0x01, // d_min = -1
            0x00, 0xFF, 0x00, 0x00, // d_max = 255
        ];
        let info = parse_depth_representation_info(&data);
        assert_eq!(
            info.representation_type,
            DepthRepresentationType::UniformDisparity
        );
        assert!((info.z_near.unwrap() - 20.0).abs() < f64::EPSILON);
        assert!((info.z_far.unwrap() - 200.0).abs() < f64::EPSILON);
        assert!((info.d_min.unwrap() - (-1.0)).abs() < f64::EPSILON);
        assert!((info.d_max.unwrap() - 255.0).abs() < f64::EPSILON);
    }

    #[test]
    fn test_parse_depth_representation_info_truncated() {
        // Flags say z_near present but data is truncated
        let data = [0, 0x01, 0x00]; // only 1 byte of the 4-byte value
        let info = parse_depth_representation_info(&data);
        assert!(info.z_near.is_none());
    }

    #[test]
    fn test_pow2_f64() {
        assert!((pow2_f64(0) - 1.0).abs() < f64::EPSILON);
        assert!((pow2_f64(1) - 2.0).abs() < f64::EPSILON);
        assert!((pow2_f64(10) - 1024.0).abs() < f64::EPSILON);
    }

    #[test]
    fn test_display_auxiliary_type() {
        assert_eq!(format!("{}", AuxiliaryImageType::Depth), "Depth");
        assert_eq!(
            format!("{}", AuxiliaryImageType::Other(String::from("custom"))),
            "Other(custom)"
        );
    }

    #[test]
    fn test_display_depth_representation_type() {
        assert_eq!(
            format!("{}", DepthRepresentationType::UniformInverseZ),
            "UniformInverseZ"
        );
        assert_eq!(
            format!("{}", DepthRepresentationType::NonuniformDisparity),
            "NonuniformDisparity"
        );
    }
}