acl/compression/track.h¶
#include "acl/compression/track.h"
The raw track types: a list of samples with one type and one sample rate.
track¶
class track
An untyped track of data. A track is a time series of values sampled uniformly over time at a specific sample rate. Tracks can either own their memory or reference an external buffer. For convenience, this type can be cast with the track_cast(..) family of functions. Each track type has the same size as every track description is contained within a union.
Construction¶
track::track¶
track() noexcept
Creates an empty, untyped track.
track(track&& other) noexcept
Move constructor for a track.
track::~track¶
~track()
Destroys the track. If it owns the memory referenced, it will be freed.
track::operator=¶
track& operator=(track&& other) noexcept
Move assignment for a track.
Samples¶
track::operator[]¶
void* operator[](uint32_t index)
const void* operator[](uint32_t index) const
Returns a pointer to an untyped sample at the specified index.
Properties¶
track::is_owner¶
bool is_owner() const
Returns true if the track owns its memory, false otherwise.
track::is_ref¶
bool is_ref() const
Returns true if the track references memory that it does not own, false otherwise.
track::is_empty¶
bool is_empty() const
Returns true if the track doesn't contain any data, false otherwise.
track::get_allocator¶
iallocator* get_allocator() const
Returns a pointer to the allocator instance or nullptr if there is none present.
track::get_num_samples¶
uint32_t get_num_samples() const
Returns the number of samples contained within the track. This does not account for the repeating first sample when the wrap looping policy is used. See sample_looping_policy for details.
track::get_stride¶
uint32_t get_stride() const
Returns the stride in bytes in between samples as laid out in memory. This is always sizeof(sample_type) unless the memory isn't owned internally.
track::get_interpolator¶
track_interpolator_t get_interpolator() const
Returns the track interpolator type.
track::get_type¶
track_type8 get_type() const
Returns the track type.
track::get_category¶
track_category8 get_category() const
Returns the track category.
track::get_sample_size¶
uint32_t get_sample_size() const
Returns the size in bytes of each track sample.
track::get_sample_rate¶
float get_sample_rate() const
Returns the track sample rate. A track has its sampled uniformly distributed in time at a fixed rate (e.g. 30 samples per second).
track::get_name¶
const string& get_name() const
Returns the track name.
track::set_name¶
void set_name(const string& name)
Sets the track name.
track::get_output_index¶
uint32_t get_output_index() const
Returns the track output index. When compressing, it is often desirable to strip or re-order the tracks we output. This can be used to sort by LOD or to strip stale tracks. Tracks with an invalid track index are stripped in the output.
track::get_description¶
template<typename desc_type>
desc_type& get_description()
template<typename desc_type>
const desc_type& get_description() const
Returns the track description.
Copies and validation¶
track::get_copy¶
track get_copy(iallocator& allocator) const
Returns a copy of the track where the memory will be owned by the copy.
track::get_ref¶
track get_ref() const
Returns a reference to the track where the memory isn't owned.
track::is_valid¶
error_result is_valid() const
Returns whether a track is valid or not. A track is valid if:
- It is empty
- It has a positive and finite sample rate
- A valid description
track::track_desc_untyped¶
union track::track_desc_untyped
A union of every track description. This ensures every track has the same size regardless of its type.
track::track_desc_untyped::scalar¶
track_desc_scalarf scalar;
The description of a scalar track.
track::track_desc_untyped::transform¶
track_desc_transformf transform;
The description of a transform track.
track::track_desc_untyped::track_desc_untyped¶
explicit track_desc_untyped(const track_desc_scalarf& desc) noexcept
Constructs the union with the description of a scalar track.
explicit track_desc_untyped(const track_desc_transformf& desc) noexcept
Constructs the union with the description of a transform track.
track_typed¶
template<track_type8 track_type_, track_interpolator_t track_interpolator_ = track_interpolator_t::linear>
class track_typed : public acl::track
A typed track of data. See track for details.
Types and constants¶
track_typed::type¶
track_type8 type = track_type_;
The track type.
track_typed::interpolator¶
track_interpolator_t interpolator = track_interpolator_;
The interpolation mode.
track_typed::category¶
track_category8 category = track_traits<track_type_, track_interpolator_>::category;
The track category.
track_typed::sample_type¶
using sample_type = typename track_traits<track_type_, track_interpolator_>::sample_type;
The type of each sample in this track.
track_typed::desc_type¶
using desc_type = typename track_traits<track_type_, track_interpolator_>::desc_type;
The type of the track description.
Construction¶
track_typed::track_typed¶
track_typed() noexcept
Constructs an empty typed track.
track_typed(track_typed&& other) noexcept
Move assignment for a track.
track_typed::~track_typed¶
~track_typed() = default
Destroys the track and potentially frees any memory it might own.
track_typed::operator=¶
track_typed& operator=(track_typed&& other) noexcept
Move assignment for a track.
Samples¶
track_typed::operator[]¶
sample_type& operator[](uint32_t index)
Returns the sample at the specified index. If this track does not own the memory, mutable references aren't allowed and an invalid reference will be returned, leading to a crash.
const sample_type& operator[](uint32_t index) const
Returns the sample at the specified index.
track_typed::get_data¶
sample_type* get_data()
Returns a pointer to the sample data. Note that if the sample stride is not sizeof(sample_type) then samples are not contiguous in memory!
const sample_type* get_data() const
Note that if the sample stride is not sizeof(sample_type) then samples are not contiguous in memory!
Properties¶
track_typed::get_description¶
desc_type& get_description()
const desc_type& get_description() const
Returns the track description.
track_typed::get_type¶
track_type8 get_type() const
Returns the track type.
track_typed::get_category¶
track_category8 get_category() const
Returns the track category.
Copies¶
track_typed::get_copy¶
track_typed get_copy(iallocator& allocator) const
Returns a copy of the track where the memory will be owned by the copy.
track_typed::get_ref¶
track_typed get_ref() const
Returns a reference to the track where the memory isn't owned.
Factory functions¶
track_typed::make_copy¶
static track_typed<track_type_, track_interpolator_> make_copy(
const desc_type& desc,
iallocator& allocator,
const sample_type* data,
uint32_t num_samples,
float sample_rate,
uint32_t stride = sizeof(sample_type))
Creates a track that copies the data and owns the memory.
track_typed::make_reserve¶
static track_typed<track_type_, track_interpolator_> make_reserve(
const desc_type& desc,
iallocator& allocator,
uint32_t num_samples,
float sample_rate)
Creates a track and preallocates but does not initialize the memory that it owns.
track_typed::make_owner¶
static track_typed<track_type_, track_interpolator_> make_owner(
const desc_type& desc,
iallocator& allocator,
sample_type* data,
uint32_t num_samples,
float sample_rate,
uint32_t stride = sizeof(sample_type))
Creates a track and takes ownership of the already allocated memory.
track_typed::make_ref¶
static track_typed<track_type_, track_interpolator_> make_ref(
const desc_type& desc,
sample_type* data,
uint32_t num_samples,
float sample_rate,
uint32_t stride = sizeof(sample_type))
Creates a track that just references the data without owning it.
track_cast¶
template<typename track_type>
track_type& track_cast(track& track_)
template<typename track_type>
const track_type& track_cast(const track& track_)
Casts an untyped track into the desired track type while asserting for safety.
template<typename track_type>
track_type* track_cast(track* track_)
template<typename track_type>
const track_type* track_cast(const track* track_)
Casts an untyped track into the desired track type. Returns nullptr if the types are not compatible or if the input is nullptr.
track_float1f_ex¶
using track_float1f_ex = track_typed<track_type8::float1f, track_interpolator_t::extended>;
A track of float1f scalar samples, with the extended interpolator: each sample has its own interpolator.
track_float2f_ex¶
using track_float2f_ex = track_typed<track_type8::float2f, track_interpolator_t::extended>;
A track of float2f scalar samples, with the extended interpolator: each sample has its own interpolator.
track_float3f_ex¶
using track_float3f_ex = track_typed<track_type8::float3f, track_interpolator_t::extended>;
A track of float3f scalar samples, with the extended interpolator: each sample has its own interpolator.
track_float4f_ex¶
using track_float4f_ex = track_typed<track_type8::float4f, track_interpolator_t::extended>;
A track of float4f scalar samples, with the extended interpolator: each sample has its own interpolator.
track_vector4f_ex¶
using track_vector4f_ex = track_typed<track_type8::vector4f, track_interpolator_t::extended>;
A track of vector4f scalar samples, with the extended interpolator: each sample has its own interpolator.
track_vqvf_ex¶
using track_vqvf_ex = track_typed<track_type8::vqvf, track_interpolator_t::extended>;
A track of vqvf transform samples, with the extended interpolator: each sample has its own interpolator.