gst-plugin-isobmff 0.15.0

GStreamer ISO Base Media File Format (MP4) Plugin
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
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
// Copyright (C) 2021-2022 Sebastian Dröge <sebastian@centricular.com>
//
// This Source Code Form is subject to the terms of the Mozilla Public License, v2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at
// <https://mozilla.org/MPL/2.0/>.
//
// SPDX-License-Identifier: MPL-2.0

use std::collections::BTreeMap;
use std::collections::VecDeque;
use std::sync::LazyLock;

use gst::glib;
use gst::prelude::*;
#[cfg(feature = "v1_28")]
use gst::tags;

mod ac3;
mod aux_info;
mod boxes;
mod brands;
mod eac3;
mod flac;
mod fmp4mux;
mod mp4mux;
#[cfg(feature = "v1_28")]
mod precision_timestamps;
mod transform_matrix;
mod uncompressed;

pub(crate) static CAT: LazyLock<gst::DebugCategory> = LazyLock::new(|| {
    gst::DebugCategory::new(
        "isobmffmux",
        gst::DebugColorFlags::empty(),
        Some("ISO Base Media File Format Mux Element"),
    )
});

/// Supported Bayer format strings for video/x-bayer caps
pub(crate) const BAYER_FORMATS: &[&str] = &[
    "bggr", "gbrg", "grbg", "rggb", "bggr10le", "bggr10be", "gbrg10le", "gbrg10be", "grbg10le",
    "grbg10be", "rggb10le", "rggb10be", "bggr12le", "bggr12be", "gbrg12le", "gbrg12be", "grbg12le",
    "grbg12be", "rggb12le", "rggb12be", "bggr14le", "bggr14be", "gbrg14le", "gbrg14be", "grbg14le",
    "grbg14be", "rggb14le", "rggb14be", "bggr16le", "bggr16be", "gbrg16le", "gbrg16be", "grbg16le",
    "grbg16be", "rggb16le", "rggb16be",
];

glib::wrapper! {
    pub(crate) struct FMP4MuxPad(ObjectSubclass<crate::isobmff::fmp4mux::imp::FMP4MuxPad>) @extends gst_base::AggregatorPad, gst::Pad, gst::Object;
}

glib::wrapper! {
    pub(crate) struct MP4MuxPad(ObjectSubclass<crate::isobmff::mp4mux::imp::MP4MuxPad>) @extends gst_base::AggregatorPad, gst::Pad, gst::Object;
}

glib::wrapper! {
    pub(crate) struct FMP4Mux(ObjectSubclass<crate::isobmff::fmp4mux::imp::FMP4Mux>) @extends gst_base::Aggregator, gst::Element, gst::Object, @implements gst::ChildProxy;
}

glib::wrapper! {
    pub(crate) struct MP4Mux(ObjectSubclass<crate::isobmff::mp4mux::imp::MP4Mux>) @extends gst_base::Aggregator, gst::Element, gst::Object, @implements gst::ChildProxy;
}

glib::wrapper! {
    pub(crate) struct CMAFMux(ObjectSubclass<crate::isobmff::fmp4mux::imp::CMAFMux>) @extends FMP4Mux, gst_base::Aggregator, gst::Element, gst::Object, @implements gst::ChildProxy;
}

glib::wrapper! {
    pub(crate) struct DASHMP4Mux(ObjectSubclass<crate::isobmff::fmp4mux::imp::DASHMP4Mux>) @extends FMP4Mux, gst_base::Aggregator, gst::Element, gst::Object, @implements gst::ChildProxy;
}

glib::wrapper! {
    pub(crate) struct ISOFMP4Mux(ObjectSubclass<crate::isobmff::fmp4mux::imp::ISOFMP4Mux>) @extends FMP4Mux, gst_base::Aggregator, gst::Element, gst::Object, @implements gst::ChildProxy;
}

glib::wrapper! {
    pub(crate) struct ISOMP4Mux(ObjectSubclass<crate::isobmff::mp4mux::imp::ISOMP4Mux>) @extends MP4Mux, gst_base::Aggregator, gst::Element, gst::Object, @implements gst::ChildProxy;
}

glib::wrapper! {
    pub(crate) struct ONVIFFMP4Mux(ObjectSubclass<crate::isobmff::fmp4mux::imp::ONVIFFMP4Mux>) @extends FMP4Mux, gst_base::Aggregator, gst::Element, gst::Object, @implements gst::ChildProxy;
}

glib::wrapper! {
    pub(crate) struct ONVIFMP4Mux(ObjectSubclass<crate::isobmff::mp4mux::imp::ONVIFMP4Mux>) @extends MP4Mux, gst_base::Aggregator, gst::Element, gst::Object, @implements gst::ChildProxy;
}

pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
    if !gst::meta::CustomMeta::is_registered("FMP4KeyframeMeta") {
        gst::meta::CustomMeta::register("FMP4KeyframeMeta", &[]);
    }

    #[cfg(feature = "doc")]
    {
        FMP4Mux::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
        FMP4MuxPad::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
        HeaderUpdateMode::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
        WriteEdtsMode::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
        ChunkMode::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
        MP4Mux::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
        MP4MuxPad::static_type().mark_as_plugin_api(gst::PluginAPIFlags::empty());
    }

    gst::Element::register(
        Some(plugin),
        "isofmp4mux",
        gst::Rank::PRIMARY,
        ISOFMP4Mux::static_type(),
    )?;
    gst::Element::register(
        Some(plugin),
        "cmafmux",
        gst::Rank::PRIMARY,
        CMAFMux::static_type(),
    )?;
    gst::Element::register(
        Some(plugin),
        "dashmp4mux",
        gst::Rank::PRIMARY,
        DASHMP4Mux::static_type(),
    )?;
    gst::Element::register(
        Some(plugin),
        "onviffmp4mux",
        gst::Rank::PRIMARY,
        ONVIFFMP4Mux::static_type(),
    )?;
    gst::Element::register(
        Some(plugin),
        "isomp4mux",
        gst::Rank::MARGINAL,
        ISOMP4Mux::static_type(),
    )?;
    gst::Element::register(
        Some(plugin),
        "onvifmp4mux",
        gst::Rank::MARGINAL,
        ONVIFMP4Mux::static_type(),
    )?;

    #[cfg(feature = "v1_28")]
    {
        tags::register::<PrecisionClockTypeTag>();
        tags::register::<PrecisionClockTimeUncertaintyNanosecondsTag>();
    }
    Ok(())
}

#[cfg(feature = "v1_28")]
pub enum PrecisionClockTimeUncertaintyNanosecondsTag {}

#[cfg(feature = "v1_28")]
pub enum PrecisionClockTypeTag {}

#[derive(Debug, Copy, Clone)]
pub(crate) enum DeltaFrames {
    /// Only single completely decodable frames
    IntraOnly,
    /// Frames may depend on past frames
    PredictiveOnly,
    /// Frames may depend on past or future frames
    Bidirectional,
}

impl DeltaFrames {
    /// Whether dts is required to order buffers differently from presentation order
    pub(crate) fn requires_dts(&self) -> bool {
        matches!(self, Self::Bidirectional)
    }
    /// Whether this coding structure does not allow delta flags on buffers
    pub(crate) fn intra_only(&self) -> bool {
        matches!(self, Self::IntraOnly)
    }
}

/**
 * GstFMP4MuxHeaderUpdateMode:
 *
 * How and when updating of the header (`moov`, initialization segment) is allowed.
 */
#[allow(clippy::upper_case_acronyms)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, glib::Enum)]
#[repr(i32)]
#[enum_type(name = "GstFMP4MuxHeaderUpdateMode")]
pub(crate) enum HeaderUpdateMode {
    /**
     * GstFMP4MuxHeaderUpdateMode:none:
     *
     * Don't allow and do any header updates at all.
     *
     * Caps changes are not allowed in this mode.
     */
    None,
    /**
     * GstFMP4MuxHeaderUpdateMode:rewrite:
     *
     * Try rewriting the initial header with the overall duration at the very end.
     *
     * Caps changes are not allowed in this mode.
     */
    Rewrite,
    /**
     * GstFMP4MuxHeaderUpdateMode:update:
     *
     * Send an updated version of the initial header with the overall duration at
     * the very end.
     *
     * Caps changes are not allowed in this mode.
     */
    Update,
    /**
     * GstFMP4MuxHeaderUpdateMode:caps:
     *
     * Send an updated header whenever caps or tag changes are pending that affect the initial
     * header. The updated header does not have the duration set and will always be followed by a
     * new fragment.
     *
     * Since: plugins-rs-0.14.0
     */
    Caps,
}

/// Synchronisation capability of clock
///
/// This is used in the TAIClockInfoBox, see ISO/IEC 23001-17:2024 Amd 1.
#[repr(u8)]
#[allow(dead_code)]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub(crate) enum TaicClockType {
    /// Clock type is unknown
    Unknown = 0u8,
    /// Clock does not synchronise to an atomic clock time source
    CannotSync = 1u8,
    // Clock can synchronise to an atomic clock time source
    CanSync = 2u8,
    // Reserved - DO NOT USE
    Reserved = 3u8,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, glib::Enum, Default)]
#[enum_type(name = "GstFMP4MuxWriteEdtsMode")]
pub(crate) enum WriteEdtsMode {
    #[default]
    Auto,
    Always,
    Never,
}

#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[cfg(feature = "v1_28")]
pub(crate) struct TaiClockInfo {
    // Set with the PrecisionClockTimeUncertaintyNanoseconds tag
    // Defaults to unknown
    time_uncertainty: u64,
    // Cannot currently be set, defaults to microsecond
    clock_resolution: u32,
    // Cannot currently be set, defaults to unknown
    clock_drift_rate: i32,
    // Set with the PrecisionClockType tag
    // Defaults to unknown
    clock_type: TaicClockType,
}

// Standard values for taic box (ISO/IEC 23001-17 Amd 1)
#[cfg(feature = "v1_28")]
pub(crate) const TAIC_TIME_UNCERTAINTY_UNKNOWN: u64 = 0xFFFF_FFFF_FFFF_FFFF;
#[cfg(feature = "v1_28")]
pub(crate) const TAIC_CLOCK_DRIFT_RATE_UNKNOWN: i32 = 0x7FFF_FFFF;

// Data for auxiliary information, as used for per-sample timestamps and for protection schemes
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord, Hash)]
pub(crate) struct AuxiliaryInformation {
    pub(crate) aux_info_type: Option<[u8; 4]>,
    pub(crate) aux_info_type_parameter: u32,
}

// Data for auxiliary information, as used for per-sample timestamps and for protection schemes
#[derive(Clone, Debug, Default)]
pub(crate) struct AuxiliaryInformationData {
    pub(crate) chunk_offsets: VecDeque<u64>,
    pub(crate) entry_lengths: VecDeque<u8>,
}

#[derive(Debug, Clone)]
pub(crate) struct ElstInfo {
    pub(crate) start: Option<gst::Signed<gst::ClockTime>>,
    pub(crate) duration: Option<gst::ClockTime>,
}

#[allow(clippy::upper_case_acronyms)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum Variant {
    CMAF,
    DASH,
    FragmentedISO,
    FragmentedONVIF,
    ISO,
    ONVIF,
}

impl Variant {
    pub(crate) fn is_single_stream(self) -> bool {
        match self {
            Variant::FragmentedISO | Variant::FragmentedONVIF => false,
            Variant::CMAF | Variant::DASH => true,
            Variant::ISO | Variant::ONVIF => todo!(),
        }
    }

    pub(crate) fn is_fragmented(self) -> bool {
        match self {
            Variant::FragmentedISO | Variant::FragmentedONVIF | Variant::CMAF | Variant::DASH => {
                true
            }
            Variant::ISO | Variant::ONVIF => false,
        }
    }
}

#[derive(Debug)]
pub(crate) struct PresentationConfiguration {
    pub(crate) variant: Variant,
    pub(crate) update: bool,

    /// Pre-defined movie timescale if not 0.
    pub(crate) movie_timescale: u32,

    /// First caps must be the video/reference stream. Must be in the order the tracks are going to
    /// be used later for the fragments too, for fragmented encoding.
    pub(crate) tracks: Vec<TrackConfiguration>,

    pub(crate) write_mehd: bool,
    pub(crate) duration: Option<gst::ClockTime>,

    /// Whether to write edts box
    pub(crate) write_edts: bool,
}

impl PresentationConfiguration {
    pub(crate) fn to_timescale(&self) -> u32 {
        if self.movie_timescale > 0 {
            self.movie_timescale
        } else {
            // Use the reference track timescale
            self.tracks[0].to_timescale()
        }
    }
}

#[derive(Debug)]
pub(crate) struct Sample {
    /// Sync point
    pub(crate) sync_point: bool,

    /// Sample duration
    pub(crate) duration: gst::ClockTime,

    /// Composition time offset
    ///
    /// This is `None` for streams that have no concept of DTS.
    pub(crate) composition_time_offset: Option<i64>,

    /// Size
    pub(crate) size: u32,

    /// Whether the sample should point to the next sample description
    pub(crate) sample_desc_idx: u32,
}

#[derive(Debug)]
pub(crate) struct Chunk {
    /// Chunk start offset
    pub(crate) offset: u64,

    /// Samples of this stream that are part of this chunk
    pub(crate) samples: Vec<Sample>,
}

#[derive(Debug)]
pub(crate) struct TrackConfiguration {
    /// Caps of this track
    pub(crate) caps: Vec<gst::Caps>,

    /// Set if this is an intra-only tracck
    pub(crate) delta_frames: DeltaFrames,

    /// Pre-defined trak timescale if not 0.
    pub(crate) trak_timescale: u32,

    // More data to be included in the track header
    pub(crate) extra_header_data: Option<Vec<u8>>,

    // Codec-specific boxes to be included in the sample entry
    pub(crate) codec_specific_boxes: Vec<u8>,

    // Tags meta for audio language and video orientation
    pub(crate) language_code: Option<[u8; 3]>,
    pub(crate) orientation: &'static transform_matrix::TransformMatrix,
    pub(crate) avg_bitrate: Option<u32>,
    pub(crate) max_bitrate: Option<u32>,

    /// Edit list clipping information
    pub(crate) elst_infos: Vec<ElstInfo>,

    /// Earliest PTS
    ///
    /// If this is >0 then an edit list entry is needed to shift
    /// Only used for non-fragmented track
    pub(crate) earliest_pts: gst::ClockTime,

    /// End PTS
    /// Only used for non-fragmented track
    pub(crate) end_pts: gst::ClockTime,

    /// All the chunks stored for this stream
    /// Only used for non-fragmented track
    pub(crate) chunks: Vec<Chunk>,

    /// Whether this stream should be encoded as an ISO/IEC 23008-12 image sequence
    pub(crate) image_sequence: bool,

    /// TAI Clock information (ISO/IEC 23001-17 Amd 1)
    #[cfg(feature = "v1_28")]
    pub(crate) tai_clock_info: Option<TaiClockInfo>,

    /// Sample auxiliary information (ISO/IEC 14496-12:2022 Section 8.7.8 and 8.7.9)
    pub(crate) auxiliary_info: BTreeMap<AuxiliaryInformation, AuxiliaryInformationData>,

    /// Information needed for creating `chnl` box
    chnl_layout_info: Option<ChnlLayoutInfo>,
}

pub(crate) fn caps_to_timescale(caps: &gst::CapsRef) -> u32 {
    let s = caps.structure(0).unwrap();

    match s.get::<gst::Fraction>("framerate") {
        Ok(fps) => {
            if fps.numer() == 0 {
                return 10_000;
            }

            if fps.denom() != 1
                && fps.denom() != 1001
                && let Some(fps) = (fps.denom() as u64)
                    .nseconds()
                    .mul_div_round(1_000_000_000, fps.numer() as u64)
                    .and_then(gst_video::guess_framerate)
            {
                return (fps.numer() as u32)
                    .mul_div_round(100, fps.denom() as u32)
                    .unwrap_or(10_000);
            }

            if fps.denom() == 1001 {
                fps.numer() as u32
            } else {
                (fps.numer() as u32)
                    .mul_div_round(100, fps.denom() as u32)
                    .unwrap_or(10_000)
            }
        }
        _ => match s.get::<i32>("rate") {
            Ok(rate) => rate as u32,
            _ => 10_000,
        },
    }
}

impl TrackConfiguration {
    pub(crate) fn to_timescale(&self) -> u32 {
        if self.trak_timescale > 0 {
            self.trak_timescale
        } else {
            caps_to_timescale(self.caps())
        }
    }

    pub(crate) fn caps(&self) -> &gst::Caps {
        self.caps.first().unwrap()
    }

    pub(crate) fn stream_entry_count(&self) -> usize {
        self.caps.len()
    }
}

#[derive(Debug)]
pub(crate) struct Buffer {
    /// Track index
    pub(crate) idx: usize,

    /// Actual buffer
    pub(crate) buffer: gst::Buffer,

    /// Timestamp (PTS or DTS)
    pub(crate) timestamp: gst::Signed<gst::ClockTime>,

    /// Sample duration
    pub(crate) duration: gst::ClockTime,

    /// Composition time offset
    pub(crate) composition_time_offset: Option<i64>,
}

#[derive(Debug)]
pub(crate) struct FragmentHeaderConfiguration<'a> {
    pub(crate) variant: Variant,

    /// Sequence number for this fragment.
    pub(crate) sequence_number: u32,

    /// If this is a full fragment or only a chunk.
    pub(crate) chunk: bool,

    pub(crate) streams: &'a [FragmentHeaderStream],
    pub(crate) buffers: &'a [Buffer],

    /// If this is for the last fragment.
    pub(crate) last_fragment: bool,
}

#[derive(Debug)]
pub(crate) struct FragmentHeaderStream {
    /// Caps of this stream
    pub(crate) caps: gst::Caps,

    /// Set if this is an intra-only stream
    pub(crate) delta_frames: DeltaFrames,

    /// Pre-defined trak timescale if not 0.
    pub(crate) trak_timescale: u32,

    /// Start time of this fragment
    ///
    /// `None` if this stream has no buffers in this fragment.
    pub(crate) start_time: Option<gst::ClockTime>,

    /// Start NTP time of this fragment
    ///
    /// This is in nanoseconds since epoch and is used for writing the prft box if present.
    ///
    /// Only the first track is ever used.
    pub(crate) start_ntp_time: Option<gst::ClockTime>,
}

impl FragmentHeaderStream {
    pub(crate) fn to_timescale(&self) -> u32 {
        if self.trak_timescale > 0 {
            self.trak_timescale
        } else {
            caps_to_timescale(&self.caps)
        }
    }
}

#[derive(Debug)]
pub(crate) struct FragmentOffset {
    pub(crate) time: gst::ClockTime,
    pub(crate) offset: u64,
}

#[derive(Debug)]
pub(crate) struct SplitNowEvent {
    pub chunk: bool,
}

impl From<&SplitNowEvent> for gst::Event {
    fn from(value: &SplitNowEvent) -> Self {
        gst::event::CustomDownstream::builder(
            gst::Structure::builder("FMP4MuxSplitNow")
                .field("chunk", value.chunk)
                .build(),
        )
        .build()
    }
}

impl From<SplitNowEvent> for gst::Event {
    fn from(value: SplitNowEvent) -> Self {
        gst::Event::from(&value)
    }
}

impl SplitNowEvent {
    pub(crate) fn try_parse(
        event: &gst::event::CustomDownstream,
    ) -> Option<Result<Self, glib::BoolError>> {
        let s = event.structure()?;
        if s.name() != "FMP4MuxSplitNow" {
            return None;
        }

        let chunk = match s
            .get_optional::<bool>("chunk")
            .map_err(|e| glib::bool_error!("Invalid SplitNow event with wrong chunk field: {e}"))
        {
            Ok(chunk) => chunk.unwrap_or(false),
            Err(err) => return Some(Err(err)),
        };

        Some(Ok(SplitNowEvent { chunk }))
    }
}

/**
 * GstFMP4MuxChunkMode:
 *
 * Whether chunking is done based on duration or key frames.
 */
#[allow(clippy::upper_case_acronyms)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, glib::Enum)]
#[repr(i32)]
#[enum_type(name = "GstFMP4MuxChunkMode")]
pub(crate) enum ChunkMode {
    /**
     * GstFMP4MuxChunkMode:none:
     *
     * Chunk mode not set.
     */
    None,
    /**
     * GstFMP4MuxChunkMode:duration:
     *
     * Chunk based on duration.
     */
    Duration,
    /**
     * GstFMP4MuxChunkMode:keyframe:
     *
     * Chunk on key frame boundaries.
     */
    Keyframe,
}

#[derive(Debug, Clone)]
pub(crate) struct ChnlLayoutInfo {
    audio_info: gst_audio::AudioInfo,
    layout_idx: u8, /* Must be u8 for `chnl` box */
    reorder_map: Option<Vec<usize>>,
    omitted_channels_map: u64,
}