acl/compression/pre_process.h¶
#include "acl/compression/pre_process.h"
The actions and the settings that pre-process a raw track list before compression.
pre_process_actions¶
enum class pre_process_actions
{
none = 0x00,
normalize_rotations = 0x01,
sanitize_identity_rotations = 0x40,
ensure_quat_w_positive = 0x02,
optimize_looping = 0x04,
sanitize_constant_tracks = 0x08,
sanitize_default_tracks = 0x10,
convert_transform_type = 0x20,
recommended = normalize_rotations | sanitize_identity_rotations | optimize_looping | sanitize_constant_tracks | sanitize_default_tracks,
};
pre_process_action represents various actions that can be executed when pre-processing raw data. Multiple actions can be combined with binary operators. When multiple actions are used, they execute in the order defined here.
| Value | Description |
|---|---|
none |
No action to perform. |
normalize_rotations |
Ensures every rotation quaternion is normalized. A quaternion will be normalized only if it isn't already normalized to preserve its original value where possible. Transform tracks only. This is lossy. |
sanitize_identity_rotations |
Sanitizes every rotation quaternion with a W component of exactly 1.0 or -1.0. Because of float precision, such a quaternion can have small non-zero [xyz] components: it has a rotation axis but no rotation around that axis. This action sets [xyz] to 0.0 and keeps the sign of W. A track changes only when the error stays within its precision. Lossy pre-processing only. Transform tracks only. This is lossy. |
ensure_quat_w_positive |
Ensures every rotation quaternion has a positive W component. This forces all quaternions into the same side of the hyper-sphere to facilitate interpolation by avoiding wrapping around. Because both halves of the hyper-sphere represent equivalent rotations, this operation is considered lossless. Transform tracks only. This is lossless. |
optimize_looping |
Ensures that if the first and last keyframes match well enough to satisfy the precision requirements, the last keyframe is overwritten with the first keyframe to make sure they match perfectly. This is lossy. |
sanitize_constant_tracks |
Sanitizes every constant track (and sub-track) by duplicating the optimal sample. This is lossy. |
sanitize_default_tracks |
Sanitizes every default track (and sub-track) by duplicating the default sample. This is lossy. |
convert_transform_type |
A demotion from vqvf to vqsf makes each scale uniform. It happens only when no track needs a non-uniform scale: Converts the transform tracks into the transform type of pre_process_settings_t::transform_type. The types hold more and more scale information: vqf (no scale), vqsf (uniform scale), vqvf (3D scale). A promotion (for example vqf -> vqsf, or vqsf -> vqvf) always succeeds and is lossless. When the source has no scale, each new scale is the identity of the additive format (1.0, or 0.0 with additive1). A demotion to vqf removes the scale. It happens only when no track needs its scale: When a track needs its scale, the tracks keep their type. The track list must be a track_array instance: a typed track array (for example track_array_vqvf) cannot change its type, thus pre-processing returns an error. Transform tracks only. This is lossy with the lossy policy. |
recommended |
Performs all recommended pre-process actions. |
pre_process_precision_policy¶
enum class pre_process_precision_policy
{
lossless,
lossy,
};
pre_process_precision_policy controls whether we should be lossless or lossy
| Value | Description |
|---|---|
lossless |
Pre-processing will use binary equality and binary equivalent transformations where possible. |
lossy |
Pre-processing will use the error metric and precision values provided. |
pre_process_settings_t¶
struct pre_process_settings_t
Various settings to control pre-processing.
pre_process_settings_t::actions¶
pre_process_actions actions = pre_process_actions::recommended;
The list of actions to perform.
pre_process_settings_t::precision_policy¶
pre_process_precision_policy precision_policy = pre_process_precision_policy::lossless;
The precision policy to follow.
pre_process_settings_t::transform_runtime_type¶
transform_runtime_type_t transform_runtime_type = transform_runtime_type_t::automatic;
The runtime transform type, the custom transform adapter, and the transform metric to use with transform tracks when lossy They have the same meaning and the same defaults as in the compression settings, see compression_settings Use the same values as for compression Lossy pre-processing only Transform tracks only
pre_process_settings_t::custom_transform_adapter¶
itransform_adapter* custom_transform_adapter = nullptr;
The runtime transform type, the custom transform adapter, and the transform metric to use with transform tracks when lossy They have the same meaning and the same defaults as in the compression settings, see compression_settings Use the same values as for compression Lossy pre-processing only Transform tracks only
pre_process_settings_t::transform_metric¶
itransform_metric* transform_metric = nullptr;
The runtime transform type, the custom transform adapter, and the transform metric to use with transform tracks when lossy They have the same meaning and the same defaults as in the compression settings, see compression_settings Use the same values as for compression Lossy pre-processing only Transform tracks only
pre_process_settings_t::transform_type¶
track_type8 transform_type = track_type8::vqvf;
The transform type to convert the transform tracks into (vqvf, vqf, or vqsf) convert_transform_type action only Transform tracks only
pre_process_settings_t::transform_base¶
transform_base_desc_t transform_base;
The base of the track list, if any. See transform_base_desc_t. Pre-processing uses the transform space of the track list, see track_array::get_transform_space. Use the same value as for compression.
Defaults to no base. Lossy pre-processing only Transform tracks only
pre_process_track_list¶
error_result pre_process_track_list(
iallocator& allocator,
const pre_process_settings_t& settings,
track_array& track_list)
Pre-processes a track array by performing various operations to improve compression.
ACL avoids modifying the raw data during compression to ensure that the caller can still measure the same error that the internal algorithm sees. However, this can lead to sub-optimal compression in certain cases. Rotation format conversion and constant/default sub-track collapsing can yield values that the optimizing algorithm can never fully reach, leading it to try too hard for little to no gain. To avoid this issue, the raw data can be pre-processed. This allows the caller to control everything. Raw data can be pre-processed once following import (e.g. from FBX).
Parameters
allocator: The allocator instance to use for intermediary allocationssettings: The settings to use during pre-processing.track_list: The track list to pre-process.
This function returns an error result. If an error occurred, the raw data may have mutated partially.
error_result pre_process_track_list(
iallocator& allocator,
const pre_process_settings_t& settings,
track_array_vqvf& track_list)
error_result pre_process_track_list(
iallocator& allocator,
const pre_process_settings_t& settings,
track_array_vqf& track_list)
error_result pre_process_track_list(
iallocator& allocator,
const pre_process_settings_t& settings,
track_array_vqsf& track_list)
Pre-processes a typed transform track array, see above. A typed track array cannot change its type: the convert_transform_type action returns an error.