noodles_cram/codecs/aac/
flags.rs

1bitflags::bitflags! {
2    /// Adaptive arithmetic coder flags.
3    #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
4    pub struct Flags: u8 {
5        /// Order-1 entropy coding.
6        const ORDER = 0x01;
7        /// Reserved.
8        const RESERVED = 0x02;
9        /// Use an external codec (bzip2).
10        const EXT = 0x04;
11        /// Interleave 32 rANS states.
12        const STRIPE = 0x08;
13        /// Discard the uncompressed data size.
14        const NO_SIZE = 0x10;
15        /// Data is uncompressed.
16        const CAT = 0x20;
17        /// Use run-length encoding.
18        const RLE = 0x40;
19        /// Use bit packing.
20        const PACK = 0x80;
21    }
22}
23
24impl Flags {
25    pub(super) fn order(&self) -> u8 {
26        if self.contains(Self::ORDER) { 1 } else { 0 }
27    }
28
29    pub(super) fn uses_external_codec(&self) -> bool {
30        self.contains(Self::EXT)
31    }
32
33    pub(super) fn is_striped(&self) -> bool {
34        self.contains(Self::STRIPE)
35    }
36
37    pub(super) fn has_uncompressed_size(&self) -> bool {
38        !self.contains(Self::NO_SIZE)
39    }
40
41    pub(super) fn is_uncompressed(&self) -> bool {
42        self.contains(Self::CAT)
43    }
44
45    pub(super) fn is_rle(&self) -> bool {
46        self.contains(Self::RLE)
47    }
48
49    pub(super) fn is_bit_packed(&self) -> bool {
50        self.contains(Self::PACK)
51    }
52}
53
54impl From<u8> for Flags {
55    fn from(n: u8) -> Self {
56        Self::from_bits_truncate(n)
57    }
58}
59
60impl From<Flags> for u8 {
61    fn from(flags: Flags) -> Self {
62        flags.bits()
63    }
64}