MXL : Media eXchange Layer
MXL
Loading...
Searching...
No Matches
mxl::lib::fabrics::ofi::DataLayout::Discrete Struct Reference

Discrete layout variant of DataLayout. More...

#include <DataLayout.hpp>

Public Member Functions

std::size_t activePlaneCount () const noexcept
 Return the number of active planes (consecutive non-zero sliceSizes entries).
std::uint32_t planePayloadOffset (std::size_t planeIndex, std::uint32_t grainPayloadOffset) const
 Return the byte offset from the grain start to where a given plane's payload begins.
std::size_t totalLength () const noexcept
 Return the total length of all active planes together.

Public Attributes

std::array< std::uint32_t, MXL_MAX_PLANES_PER_GRAIN > sliceSizes
std::uint16_t totalSlices

Detailed Description

Discrete layout variant of DataLayout.

Definition at line 23 of file DataLayout.hpp.

Member Function Documentation

◆ activePlaneCount()

std::size_t mxl::lib::fabrics::ofi::DataLayout::Discrete::activePlaneCount ( ) const
nodiscardnoexcept

Return the number of active planes (consecutive non-zero sliceSizes entries).

Definition at line 27 of file DataLayout.cpp.

28 {
29 return std::ranges::count_if(sliceSizes, [](std::uint32_t sliceSize) { return sliceSize > 0; });
30 }
std::array< std::uint32_t, MXL_MAX_PLANES_PER_GRAIN > sliceSizes

◆ planePayloadOffset()

std::uint32_t mxl::lib::fabrics::ofi::DataLayout::Discrete::planePayloadOffset ( std::size_t planeIndex,
std::uint32_t grainPayloadOffset ) const
nodiscard

Return the byte offset from the grain start to where a given plane's payload begins.

Parameters
planeIndexThe zero-based plane index.
grainPayloadOffsetThe byte offset of the first plane's payload from the grain start (i.e. the grain header size).

Definition at line 32 of file DataLayout.cpp.

33 {
34 if (sliceSizes.size() <= planeIndex)
35 {
36 throw Exception::invalidState("Invalid plane index {} not in range {}-{}", planeIndex, 0, sliceSizes.size());
37 }
38
39 return std::accumulate(sliceSizes.begin(),
40 sliceSizes.begin() + planeIndex,
41 grainPayloadOffset,
42 [this](std::uint32_t lhs, std::uint32_t rhs) { return lhs + (rhs * static_cast<std::uint32_t>(totalSlices)); });
43 }
static Exception invalidState(fmt::format_string< T... > fmt, T &&... args)
Make an MXL_ERR_INVALID_STATE exception.
Definition Exception.hpp:59

◆ totalLength()

std::size_t mxl::lib::fabrics::ofi::DataLayout::Discrete::totalLength ( ) const
nodiscardnoexcept

Return the total length of all active planes together.

Definition at line 22 of file DataLayout.cpp.

23 {
24 return std::accumulate(sliceSizes.begin(), sliceSizes.end(), std::size_t{0});
25 }

Member Data Documentation

◆ sliceSizes

std::array<std::uint32_t, MXL_MAX_PLANES_PER_GRAIN> mxl::lib::fabrics::ofi::DataLayout::Discrete::sliceSizes

Size in bytes of a single slice for each plane.

See also
MXL_MAX_PLANES_PER_GRAIN

Definition at line 26 of file DataLayout.hpp.

◆ totalSlices

std::uint16_t mxl::lib::fabrics::ofi::DataLayout::Discrete::totalSlices

Total number of slices (e.g. video lines) per grain.

Definition at line 27 of file DataLayout.hpp.


The documentation for this struct was generated from the following files: