rust_aec/
params.rs

1use bitflags::bitflags;
2
3bitflags! {
4    /// AEC flags (mirrors `libaec`'s `aec_stream.flags`).
5    ///
6    /// For GRIB2 template 5.42, a subset of these flags is provided in the
7    /// `ccsdsFlags` field; see [`crate::flags_from_grib2_ccsds_flags`].
8    #[derive(Debug, Clone, Copy, PartialEq, Eq)]
9    pub struct AecFlags: u32 {
10        /// Signed samples (two's complement). If not set, samples are unsigned.
11        const DATA_SIGNED     = 1 << 0;
12        /// Use 3 bytes/sample for 17..=24-bit samples (otherwise 4).
13        const DATA_3BYTE      = 1 << 1;
14        /// Output samples as MSB-first byte order (big-endian within each sample).
15        const MSB            = 1 << 2;
16        /// Enable preprocessing (predictor + folding) in the bitstream.
17        const DATA_PREPROCESS = 1 << 3;
18        /// Restricted ID table for small bit depths.
19        const RESTRICTED      = 1 << 4;
20        /// Pad each RSI interval to the next byte boundary.
21        const PAD_RSI         = 1 << 5;
22    }
23}
24
25#[derive(Debug, Clone, Copy)]
26pub struct AecParams {
27    /// Bits per sample.
28    ///
29    /// For GRIB2 template 5.42: `template42.simple.num_bits`.
30    pub bits_per_sample: u8,
31    /// Block size.
32    ///
33    /// For GRIB2 template 5.42: `template42.block_size`.
34    pub block_size: u32,
35    /// Reference sample interval (RSI).
36    ///
37    /// For GRIB2 template 5.42: `template42.ref_sample_interval`.
38    pub rsi: u32,
39    /// Decoder flags.
40    pub flags: AecFlags,
41}
42
43impl AecParams {
44    /// Create a new parameter set.
45    pub fn new(bits_per_sample: u8, block_size: u32, rsi: u32, flags: AecFlags) -> Self {
46        Self { bits_per_sample, block_size, rsi, flags }
47    }
48}