Skip to content

acl/core/sample_rounding_policy.h

#include "acl/core/sample_rounding_policy.h"

The rounding policies that select a sample at a sample time.

sample_rounding_policy

enum class sample_rounding_policy
{
    none = 0,
    floor = 1,
    ceil = 2,
    nearest = 3,
    per_track = 4,
};

This enum dictates how interpolation samples are calculated based on the sample time. DO NOT CHANGE THESE VALUES AS THEY ARE USED TO INDEX INTO FIXED SIZED BUFFERS THAT MAY NOT ACCOMODATE ALL VALUES.

Value Description
none If the sample time lies between two samples, both sample indices are returned and the interpolation alpha lies in between.
floor If the sample time lies between two samples, both sample indices are returned and the interpolation will be 0.0. Note that when this is used to sample a clip with a partially streamed database the sample returned is the same that would have been had the database been fully streamed in. Meaning that if we have 3 samples A, B, C and you sample between B and C, normally B would be returned. If B has been moved into the database and is missing, B will be reconstructed through interpolation.
ceil If the sample time lies between two samples, both sample indices are returned and the interpolation will be 1.0. Note that when this is used to sample a clip with a partially streamed database the sample returned is the same that would have been had the database been fully streamed in. Meaning that if we have 3 samples A, B, C and you sample between A and B, normally B would be returned. If B has been moved into the database and is missing, B will be reconstructed through interpolation.
nearest If the sample time lies between two samples, both sample indices are returned and the interpolation will be 0.0 or 1.0 depending on which sample is nearest. Note that this behaves similarly to floor and ceil above when used with a partially streamed database.
per_track Specifies that the rounding policy must be queried for every track independently. Note that this feature can be enabled/disabled in the decompression_settings struct provided during decompression. Since this is a niche feature, the default settings disable it. WARNING: Using per track rounding may not behave as intended if a partially streamed database is used or if keyframes have been stripped. For performance reasons, unlike the modes above, only a single value will be interpolated: the one at the specified sample time. This means that if we have 3 samples A, B, C and you sample between B and C with floor, if B has been moved to a database and is missing, B (interpolated) is not returned. Normally, A and C would be used to interpolate at the sample time specified as such we do not calculate where B lies. As a result of this, A would be returned unlike the behavior of floor when used to sample all tracks. This is the behavior chosen by design. During decompression, samples are unpacked and interpolated before we know which track they belong to. As such, when the per track mode is used, we output 4 samples (instead of just the one we need), one for each possible mode above. One we know which sample we need (among the 4), we can simply index with the rounding mode to grab it. This is very fast and the cost is largely hidden. Supporting the same behavior as the rounding modes above when a partially streamed in database is used would require us to interpolate 3 samples instead of 1 which would be a lot more expensive for rotation sub-tracks. It would also add a lot of code complexity. For those reasons, the behavior differs. A future task will allow tracks to be split into different layers where database settings can be independent. This will allow us to place special tracks into their own layer where key frames are not removed. A separate task may allow us to specify per track whether the values can be interpolated or not. This would allow us to detect boundary key frames (where the value changes) and retain those we need to ensure that the end result is identical.

k_num_sample_rounding_policies

size_t k_num_sample_rounding_policies = 5;

The number of sample rounding policies.