You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quant is a quantization suite supporting many targets and unit types.
Quant is tiny, header-only, cross-platform.
Quant is public domain.
Features
Support conversion from/to signed normalized floats to/from N-bits shorts (d3d10 variant).
Support conversion from/to signed normalized floats to/from N-bits shorts (opengl variant).
Support conversion from/to unsigned normalized floats to/from N-bits shorts.
Support conversion from/to quaternions to/from 32-bits integers.
Support conversion from/to positions to/from 48/32/16-bits integers.
Support conversion from/to scales to/from 48/32/16-bits integers.
Pack standard 3D transform matrix (matrix4x4f 64 bytes) into 10 or 12 bytes.
Conversions done as cross-platform and architecture-friendly as possible.
Good visual quality while aiming to smallest types.
Usages
To de/quantize animations.
To de/quantize colors.
To de/quantize sounds.
To de/quantize user input.
To de/quantize network packets.
Etc
API
namespacequant {
// For generic floatsuint16_tencode16_half(float); // 16-bitfloatdecode16_half(uint16_t); // 16-bit// For signed normalized [-1..1] floatsuint8_tencode8_snorm(float); // 8-bitfloatdecode8_snorm(uint8_t); // 8-bit// For unsigned normalized [0..1] floatsuint8_tencode8_unorm(float); // 8-bitfloatdecode8_unorm(uint8_t); // 8-bit// For rotation quaternionsencode101010_quant(uint32_t &q, float x, y, z, w); // 32-bitdecode101010_quant(float &x, &y, &z, &w, uint32_t q); // 32-bit// For position vectorsencode161616_vec(uint64_t &q, float x, y, z); // 48-bit versiondecode161616_vec(float &x, &y, &z, uint64_t q); // 48-bit versionencode8814_vec(uint32_t &q, float x, y, z); // 32-bit versiondecode8814_vec(float &x, &y, &z, uint32_t q); // 32-bit versionencode555_vec(uint16_t q, float x, y, z); // 16-bit versiondecode555_vec(float &x, &y, &z, uint16_t q); // 16-bit version// For scale vectors// Scale tip://- Try to de/quantize scale vectors as `fn(q,1-x,1-y,1-z)` if possible, rather than `fn(q,x,y,z)`//- So, scales close to one will be numerically stabler (~less visual glitches at larger scales)//- So, scales close to zero will be numerically unstabler (~more visual glitches at smaller scales)encode8814_vec(uint32_t q, float x, y, z); // 32-bit versiondecode8814_vec(float &x, &y, &z, uint32_t q); // 32-bit versionencode555_vec(uint16_t q, float x, y, z); // 16-bit versiondecode555_vec(float &x, &y, &z, uint16_t q); // 16-bit version
}