Skip to content

acl/math/vector4_packing.h

#include "acl/math/vector4_packing.h"

The functions that pack and unpack vectors.

pack_vector4_128

void pack_vector4_128(rtm::vector4f vector, uint8_t* out_vector_data)

Writes the four components of a vector with float32 values (16 bytes).

unpack_vector4_128

rtm::vector4f unpack_vector4_128(const uint8_t* vector_data)

Reads a vector that pack_vector4_128 wrote.

unpack_vector4_128_unsafe

rtm::vector4f unpack_vector4_128_unsafe(const uint8_t* vector_data, uint32_t bit_offset)

Assumes the vector_data is in big-endian order and is padded in order to load up to 23 bytes from it.

pack_vector4_64

void pack_vector4_64(rtm::vector4f vector, bool is_unsigned, uint8_t* out_vector_data)

Writes the four components of a vector with 16 bits each (8 bytes). The components must be in the range [0.0, 1.0] when is_unsigned is true, otherwise in the range [-1.0, 1.0].

unpack_vector4_64

rtm::vector4f unpack_vector4_64(const uint8_t* vector_data, bool is_unsigned)

Reads a vector that pack_vector4_64 wrote, with the same is_unsigned value.

pack_vector4_32

void pack_vector4_32(rtm::vector4f vector, bool is_unsigned, uint8_t* out_vector_data)

Writes the four components of a vector with 8 bits each (4 bytes). The components must be in the range [0.0, 1.0] when is_unsigned is true, otherwise in the range [-1.0, 1.0].

unpack_vector4_32

rtm::vector4f unpack_vector4_32(const uint8_t* vector_data, bool is_unsigned)

Reads a vector that pack_vector4_32 wrote, with the same is_unsigned value.

pack_vector4_uXX_unsafe

void pack_vector4_uXX_unsafe(
    rtm::vector4f vector,
    uint32_t num_bits,
    uint8_t* out_vector_data)

Packs data in big-endian order and assumes the out_vector_data is padded in order to write up to 16 bytes to it.

unpack_vector4_uXX_unsafe

rtm::vector4f unpack_vector4_uXX_unsafe(
    uint32_t num_bits,
    const uint8_t* vector_data,
    uint32_t bit_offset)

Assumes the vector_data is in big-endian order and padded in order to load up to 16 bytes from it.

unpack_vector2_64_unsafe

rtm::vector4f unpack_vector2_64_unsafe(const uint8_t* vector_data, uint32_t bit_offset)

Assumes the vector_data is in big-endian order and is padded in order to load up to 16 bytes from it.

pack_vector3_96

void pack_vector3_96(rtm::vector4f vector, uint8_t* out_vector_data)

Writes the [x,y,z] components of a vector with float32 values (12 bytes).

unpack_vector3_96_unsafe

rtm::vector4f unpack_vector3_96_unsafe(const uint8_t* vector_data)

Assumes the vector_data is padded in order to load up to 16 bytes from it.

rtm::vector4f unpack_vector3_96_unsafe(const uint8_t* vector_data, uint32_t bit_offset)

Assumes the vector_data is in big-endian order and is padded in order to load up to 19 bytes from it.

pack_vector3_u48_unsafe

void pack_vector3_u48_unsafe(rtm::vector4f vector, uint8_t* out_vector_data)

Assumes the out_vector_data is padded in order to write up to 16 bytes to it.

pack_vector3_s48_unsafe

void pack_vector3_s48_unsafe(rtm::vector4f vector, uint8_t* out_vector_data)

Assumes the out_vector_data is padded in order to write up to 16 bytes to it.

unpack_vector3_u48_unsafe

rtm::vector4f unpack_vector3_u48_unsafe(const uint8_t* vector_data)

Assumes the vector_data is padded in order to load up to 16 bytes from it.

unpack_vector3_s48_unsafe

rtm::vector4f unpack_vector3_s48_unsafe(const uint8_t* vector_data)

Assumes the vector_data is padded in order to load up to 16 bytes from it.

decay_vector3_u48

rtm::vector4f decay_vector3_u48(rtm::vector4f input)

Returns the [x,y,z] components of a vector after a quantization to 16 bits each, without a write to memory. The components must be in the range [0.0, 1.0].

decay_vector3_s48

rtm::vector4f decay_vector3_s48(rtm::vector4f input)

Returns the [x,y,z] components of a vector after a quantization to 16 bits each, without a write to memory. The components must be in the range [-1.0, 1.0].

pack_vector3_32

void pack_vector3_32(
    rtm::vector4f vector,
    uint32_t XBits,
    uint32_t YBits,
    uint32_t ZBits,
    bool is_unsigned,
    uint8_t* out_vector_data)

Writes the [x,y,z] components of a vector with the given number of bits for each component (4 bytes). The sum of the bits must be 32. The components must be in the range [0.0, 1.0] when is_unsigned is true, otherwise in the range [-1.0, 1.0].

decay_vector3_u32

rtm::vector4f decay_vector3_u32(
    rtm::vector4f input,
    uint32_t XBits,
    uint32_t YBits,
    uint32_t ZBits)

Returns the [x,y,z] components of a vector after a quantization with the given number of bits for each component, without a write to memory. The sum of the bits must be 32 and the components must be in the range [0.0, 1.0].

decay_vector3_s32

rtm::vector4f decay_vector3_s32(
    rtm::vector4f input,
    uint32_t XBits,
    uint32_t YBits,
    uint32_t ZBits)

Returns the [x,y,z] components of a vector after a quantization with the given number of bits for each component, without a write to memory. The sum of the bits must be 32 and the components must be in the range [-1.0, 1.0].

unpack_vector3_32

rtm::vector4f unpack_vector3_32(
    uint32_t XBits,
    uint32_t YBits,
    uint32_t ZBits,
    bool is_unsigned,
    const uint8_t* vector_data)

Reads a vector that pack_vector3_32 wrote, with the same number of bits and the same is_unsigned value.

pack_vector3_u24_unsafe

void pack_vector3_u24_unsafe(rtm::vector4f vector, uint8_t* out_vector_data)

Assumes the out_vector_data is padded in order to write up to 16 bytes to it.

pack_vector3_s24_unsafe

void pack_vector3_s24_unsafe(rtm::vector4f vector, uint8_t* out_vector_data)

Assumes the out_vector_data is padded in order to write up to 16 bytes to it.

unpack_vector3_u24_unsafe

rtm::vector4f unpack_vector3_u24_unsafe(const uint8_t* vector_data)

Assumes the vector_data is padded in order to load up to 16 bytes from it.

unpack_vector3_s24_unsafe

rtm::vector4f unpack_vector3_s24_unsafe(const uint8_t* vector_data)

Assumes the vector_data is padded in order to load up to 16 bytes from it.

pack_vector3_uXX_unsafe

void pack_vector3_uXX_unsafe(
    rtm::vector4f vector,
    uint32_t num_bits,
    uint8_t* out_vector_data)

Packs data in big-endian order and assumes the out_vector_data is padded in order to write up to 16 bytes to it.

pack_vector3_sXX_unsafe

void pack_vector3_sXX_unsafe(
    rtm::vector4f vector,
    uint32_t num_bits,
    uint8_t* out_vector_data)

Packs data in big-endian order and assumes the out_vector_data is padded in order to write up to 16 bytes to it.

decay_vector3_uXX

rtm::vector4f decay_vector3_uXX(rtm::vector4f input, uint32_t num_bits)

Returns the [x,y,z] components of a vector after a quantization to num_bits bits each, without a write to memory. The components must be in the range [0.0, 1.0].

decay_vector3_sXX

rtm::vector4f decay_vector3_sXX(rtm::vector4f input, uint32_t num_bits)

Returns the [x,y,z] components of a vector after a quantization to num_bits bits each, without a write to memory. The components must be in the range [-1.0, 1.0].

unpack_vector3_uXX_unsafe

rtm::vector4f unpack_vector3_uXX_unsafe(
    uint32_t num_bits,
    const uint8_t* vector_data,
    uint32_t bit_offset)

Assumes the vector_data is in big-endian order and padded in order to load up to 16 bytes from it.

unpack_vector3_sXX_unsafe

rtm::vector4f unpack_vector3_sXX_unsafe(
    uint32_t num_bits,
    const uint8_t* vector_data,
    uint32_t bit_offset)

Assumes the vector_data is in big-endian order and padded in order to load up to 16 bytes from it.

pack_vector2_uXX_unsafe

void pack_vector2_uXX_unsafe(
    rtm::vector4f vector,
    uint32_t num_bits,
    uint8_t* out_vector_data)

Packs data in big-endian order and assumes the out_vector_data is padded in order to write up to 16 bytes to it.

unpack_vector2_uXX_unsafe

rtm::vector4f unpack_vector2_uXX_unsafe(
    uint32_t num_bits,
    const uint8_t* vector_data,
    uint32_t bit_offset)

Assumes the vector_data is in big-endian order and padded in order to load up to 16 bytes from it.

get_packed_vector_size

uint32_t get_packed_vector_size(vector_format8 format)

Returns the size in bytes of a full precision vector3 sample with the given vector format. The variable format has no fixed size: the function asserts and returns 0.