Skip to main content

jxr_core/
container.rs

1//! Typed Annex-A container pixel-format metadata.
2
3use crate::ChromaSampling;
4
5/// Classified Annex-A `PIXEL_FORMAT` value.
6#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
7pub enum AnnexAPixelFormat {
8    /// A format defined by T.832 Table A.6.
9    Known(AnnexAPixelFormatDescriptor),
10    /// An unrecognized identifier, retained byte-for-byte.
11    Unknown([u8; 16]),
12}
13
14/// Semantic family of a known Annex-A pixel format.
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
16pub enum AnnexAPixelFamily {
17    Luma,
18    Rgb,
19    Rgbe,
20    Cmyk { direct: bool },
21    Yuv(ChromaSampling),
22    NComponent,
23}
24
25/// Numeric interpretation declared by the Annex-A format.
26#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
27pub enum AnnexANumericKind {
28    Unsigned,
29    FixedPoint,
30    Float,
31}
32
33/// Per-component output representation required by the Annex-A format.
34#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
35pub enum AnnexABitDepth {
36    Bit1,
37    U8,
38    U10,
39    U16,
40    I16,
41    F16,
42    I32,
43    F32,
44    Rgb555,
45    Rgb565,
46    Rgb101010,
47}
48
49/// Reference byte/channel ordering associated with a known format.
50#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
51pub enum AnnexAChannelOrder {
52    Luma,
53    Rgb,
54    /// RGB followed by one zero-valued storage padding component.
55    Rgbx,
56    Bgr,
57    /// BGR followed by one zero-valued storage padding component.
58    Bgrx,
59    Rgba,
60    Bgra,
61    Cmyk,
62    Yuv,
63    Rgbe,
64    Components,
65    PackedBgr,
66}
67
68/// Table A.6 properties needed for inspection and codestream validation.
69#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
70pub struct AnnexAPixelFormatDescriptor {
71    pub family: AnnexAPixelFamily,
72    /// Total decoded channels, including alpha when present.
73    pub channels: u8,
74    pub alpha: bool,
75    pub premultiplied_alpha: bool,
76    pub bit_depth: AnnexABitDepth,
77    pub numeric: AnnexANumericKind,
78    pub order: AnnexAChannelOrder,
79}