ph-color 0.1.1

Fixed-point no_std color math for embedded targets: conversion, transfer functions, matrices, gain, and interpolation
Documentation
// @generated by `cargo xtask generate`; do not edit by hand.
// Formulas: crates/color-bake/src/oklab.rs

use crate::fixed::{Q0_16, Q4_28};
use crate::interp::InterpLut;

/// Q4.28 encoding of 0.5, used to bias Oklab a/b into UQ0.16.
pub const A_B_BIAS_Q428: Q4_28 = Q4_28::from_raw(134217728);

/// Linear sRGB to LMS, Q4.28.
#[rustfmt::skip]
pub const OKLAB_M1: [[Q4_28; 3]; 3] = Q4_28::mat3_from_raw([
    [110654858, 143970669, 13809929],
    [56882412, 182723893, 28829151],
    [23703512, 75623325, 169108620],
]);

/// LMS-prime to Lab, Q4.28.
#[rustfmt::skip]
pub const OKLAB_M2: [[Q4_28; 3]; 3] = Q4_28::mat3_from_raw([
    [56493384, 213035152, -1093082],
    [530964928, -651920256, 120955328],
    [6953562, 210123696, -217077248],
]);

/// LMS to linear sRGB, Q4.28.
#[rustfmt::skip]
pub const OKLAB_M1_INV: [[Q4_28; 3]; 3] = Q4_28::mat3_from_raw([
    [1094342007, -887907069, 62000518],
    [-340493734, 700551418, -91622228],
    [-1126378, -188822497, 458384331],
]);

/// Lab to LMS-prime, Q4.28; expects offset a/b.
#[rustfmt::skip]
pub const OKLAB_M2_INV: [[Q4_28; 3]; 3] = Q4_28::mat3_from_raw([
    [268435456, 106391112, 57929380],
    [268435456, -28336408, -17140724],
    [268435456, -24020726, -346680512],
]);

/// Affine addend compensating for the stored +0.5 a/b bias.
#[rustfmt::skip]
pub const OKLAB_M2_INV_OFFSET: [Q4_28; 3] = Q4_28::row_from_raw([-82160246, 22738566, 185350619]);

/// Maximum absolute cube-root LUT error in UQ0.16 LSBs.
pub const CBRT_MAX_ERR_LSB: u16 = 3972;

/// Segmented cube-root table on the unit interval, 257 knots.
#[rustfmt::skip]
pub const CBRT: InterpLut<257> = InterpLut::from_knots(Q0_16::array_from_raw([
    0,
    10321,
    13004,
    14886,
    16384,
    17649,
    18755,
    19744,
    20642,
    21469,
    22236,
    22954,
    23629,
    24268,
    24875,
    25454,
    26008,
    26538,
    27049,
    27541,
    28016,
    28475,
    28920,
    29352,
    29771,
    30179,
    30576,
    30963,
    31341,
    31710,
    32070,
    32423,
    32768,
    33105,
    33436,
    33761,
    34080,
    34392,
    34699,
    35001,
    35298,
    35589,
    35876,
    36159,
    36437,
    36711,
    36981,
    37247,
    37509,
    37768,
    38023,
    38275,
    38524,
    38769,
    39011,
    39251,
    39487,
    39721,
    39952,
    40180,
    40406,
    40629,
    40850,
    41068,
    41284,
    41498,
    41710,
    41920,
    42127,
    42333,
    42536,
    42738,
    42938,
    43135,
    43332,
    43526,
    43718,
    43909,
    44099,
    44286,
    44472,
    44657,
    44840,
    45021,
    45202,
    45380,
    45557,
    45733,
    45908,
    46081,
    46253,
    46424,
    46593,
    46761,
    46928,
    47094,
    47259,
    47422,
    47585,
    47746,
    47906,
    48066,
    48224,
    48381,
    48537,
    48692,
    48846,
    48999,
    49151,
    49302,
    49453,
    49602,
    49751,
    49898,
    50045,
    50191,
    50336,
    50480,
    50624,
    50766,
    50908,
    51049,
    51189,
    51329,
    51468,
    51606,
    51743,
    51879,
    52015,
    52150,
    52285,
    52418,
    52551,
    52684,
    52816,
    52947,
    53077,
    53207,
    53336,
    53464,
    53592,
    53720,
    53846,
    53972,
    54098,
    54223,
    54347,
    54471,
    54594,
    54717,
    54839,
    54961,
    55082,
    55202,
    55322,
    55442,
    55561,
    55679,
    55797,
    55915,
    56032,
    56148,
    56264,
    56380,
    56495,
    56609,
    56723,
    56837,
    56950,
    57063,
    57175,
    57287,
    57399,
    57510,
    57620,
    57731,
    57840,
    57950,
    58059,
    58167,
    58275,
    58383,
    58490,
    58597,
    58704,
    58810,
    58916,
    59021,
    59126,
    59231,
    59335,
    59439,
    59542,
    59646,
    59749,
    59851,
    59953,
    60055,
    60156,
    60257,
    60358,
    60459,
    60559,
    60659,
    60758,
    60857,
    60956,
    61054,
    61153,
    61250,
    61348,
    61445,
    61542,
    61639,
    61735,
    61831,
    61927,
    62022,
    62117,
    62212,
    62307,
    62401,
    62495,
    62589,
    62682,
    62775,
    62868,
    62961,
    63053,
    63145,
    63237,
    63328,
    63419,
    63510,
    63601,
    63692,
    63782,
    63872,
    63962,
    64051,
    64140,
    64229,
    64318,
    64406,
    64495,
    64583,
    64670,
    64758,
    64845,
    64932,
    65019,
    65106,
    65192,
    65278,
    65364,
    65450,
    65535,
]), CBRT_MAX_ERR_LSB);