| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | /** | |||
| 2 | * @file interpolation.h | |||
| 3 | */ | |||
| 4 | ||||
| 5 | #pragma once | |||
| 6 | ||||
| 7 | #include <cstdint> | |||
| 8 | ||||
| 9 | #include "scaled_channel.h" | |||
| 10 | ||||
| 11 | namespace priv { | |||
| 12 | struct BinResult | |||
| 13 | { | |||
| 14 | size_t Idx; | |||
| 15 | float Frac; | |||
| 16 | }; | |||
| 17 | ||||
| 18 | /** | |||
| 19 | * @brief Finds the location of a value in the bin array. | |||
| 20 | * | |||
| 21 | * @param value The value to find in the bins. | |||
| 22 | * @return A result containing the index to the left of the value, | |||
| 23 | * and how far from (idx) to (idx + 1) the value is located. | |||
| 24 | */ | |||
| 25 | template<class TBin, int TSize> | |||
| 26 | 4225843 | BinResult getBin(float value, const TBin (&bins)[TSize]) { | ||
| 27 | // Enforce numeric only (int, float, uintx_t, etc) | |||
| 28 | static_assert(std::is_arithmetic_v<TBin>, "Table bins must be an arithmetic type"); | |||
| 29 | ||||
| 30 | // Enforce that there are enough bins to make sense (what does one bin even mean?) | |||
| 31 | static_assert(TSize >= 2); | |||
| 32 | ||||
| 33 | // Handle NaN | |||
| 34 |
34/72priv::BinResult priv::getBin<unsigned short, 4>(float, unsigned short const (&) [4]):
✗ Branch 1 not taken.
✓ Branch 2 taken 1411586 times.
priv::BinResult priv::getBin<float, 4>(float, float const (&) [4]):
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
priv::BinResult priv::getBin<short, 6>(float, short const (&) [6]):
✗ Branch 1 not taken.
✓ Branch 2 taken 40703 times.
priv::BinResult priv::getBin<float, 16>(float, float const (&) [16]):
✗ Branch 1 not taken.
✓ Branch 2 taken 182034 times.
priv::BinResult priv::getBin<unsigned short, 6>(float, unsigned short const (&) [6]):
✗ Branch 1 not taken.
✓ Branch 2 taken 384661 times.
priv::BinResult priv::getBin<float, 8>(float, float const (&) [8]):
✗ Branch 1 not taken.
✓ Branch 2 taken 351916 times.
priv::BinResult priv::getBin<short, 4>(float, short const (&) [4]):
✗ Branch 1 not taken.
✓ Branch 2 taken 29154 times.
priv::BinResult priv::getBin<unsigned char, 8>(float, unsigned char const (&) [8]):
✗ Branch 1 not taken.
✓ Branch 2 taken 123823 times.
priv::BinResult priv::getBin<unsigned short, 8>(float, unsigned short const (&) [8]):
✗ Branch 1 not taken.
✓ Branch 2 taken 61396 times.
priv::BinResult priv::getBin<float, 5>(float, float const (&) [5]):
✗ Branch 1 not taken.
✓ Branch 2 taken 284 times.
priv::BinResult priv::getBin<unsigned char, 6>(float, unsigned char const (&) [6]):
✗ Branch 1 not taken.
✓ Branch 2 taken 344505 times.
priv::BinResult priv::getBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Branch 1 not taken.
✓ Branch 2 taken 437289 times.
priv::BinResult priv::getBin<float, 2500>(float, float const (&) [2500]):
✗ Branch 1 not taken.
✓ Branch 2 taken 25000 times.
priv::BinResult priv::getBin<float, 3>(float, float const (&) [3]):
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
priv::BinResult priv::getBin<float, 2>(float, float const (&) [2]):
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
priv::BinResult priv::getBin<short, 8>(float, short const (&) [8]):
✗ Branch 1 not taken.
✓ Branch 2 taken 90832 times.
priv::BinResult priv::getBin<unsigned char, 16>(float, unsigned char const (&) [16]):
✗ Branch 1 not taken.
✓ Branch 2 taken 179 times.
priv::BinResult priv::getBin<unsigned char, 2>(float, unsigned char const (&) [2]):
✗ Branch 1 not taken.
✓ Branch 2 taken 20578 times.
priv::BinResult priv::getBin<short, 16>(float, short const (&) [16]):
✗ Branch 1 not taken.
✓ Branch 2 taken 90819 times.
priv::BinResult priv::getBin<signed char, 8>(float, signed char const (&) [8]):
✗ Branch 1 not taken.
✓ Branch 2 taken 57026 times.
priv::BinResult priv::getBin<float, 6>(float, float const (&) [6]):
✗ Branch 1 not taken.
✓ Branch 2 taken 90819 times.
priv::BinResult priv::getBin<unsigned char, 10>(float, unsigned char const (&) [10]):
✗ Branch 1 not taken.
✓ Branch 2 taken 381 times.
priv::BinResult priv::getBin<unsigned short, 10>(float, unsigned short const (&) [10]):
✗ Branch 1 not taken.
✓ Branch 2 taken 381 times.
priv::BinResult priv::getBin<unsigned char, 4>(float, unsigned char const (&) [4]):
✗ Branch 1 not taken.
✓ Branch 2 taken 202305 times.
priv::BinResult priv::getBin<unsigned short, 12>(float, unsigned short const (&) [12]):
✗ Branch 1 not taken.
✓ Branch 2 taken 4620 times.
priv::BinResult priv::getBin<float, 28>(float, float const (&) [28]):
✗ Branch 1 not taken.
✓ Branch 2 taken 1964 times.
priv::BinResult priv::getBin<short, 5>(float, short const (&) [5]):
✗ Branch 1 not taken.
✓ Branch 2 taken 90815 times.
priv::BinResult priv::getBin<unsigned char, 5>(float, unsigned char const (&) [5]):
✗ Branch 1 not taken.
✓ Branch 2 taken 90875 times.
priv::BinResult priv::getBin<short, 10>(float, short const (&) [10]):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
priv::BinResult priv::getBin<signed char, 2>(float, signed char const (&) [2]):
✗ Branch 1 not taken.
✓ Branch 2 taken 551 times.
priv::BinResult priv::getBin<float, 11>(float, float const (&) [11]):
✗ Branch 1 not taken.
✓ Branch 2 taken 341 times.
priv::BinResult priv::getBin<float, 32>(float, float const (&) [32]):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
priv::BinResult priv::getBin<unsigned short, 2>(float, unsigned short const (&) [2]):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
priv::BinResult priv::getBin<unsigned int, 2>(float, unsigned int const (&) [2]):
✗ Branch 1 not taken.
✓ Branch 2 taken 90826 times.
priv::BinResult priv::getBin<unsigned short, 3>(float, unsigned short const (&) [3]):
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
priv::BinResult priv::getBin<int, 4>(float, int const (&) [4]):
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
|
3/26priv::BinResult priv::getBin<unsigned short, 4>(float, unsigned short const (&) [4]):
✗ Decision 'true' not taken.
✓ Decision 'false' taken 1411586 times.
priv::BinResult priv::getBin<float, 16>(float, float const (&) [16]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 6>(float, unsigned short const (&) [6]):
✗ Decision 'true' not taken.
✓ Decision 'false' taken 384661 times.
priv::BinResult priv::getBin<float, 8>(float, float const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 8>(float, unsigned char const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 8>(float, unsigned short const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<float, 5>(float, float const (&) [5]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 6>(float, unsigned char const (&) [6]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<short, 8>(float, short const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 4>(float, unsigned char const (&) [4]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<float, 11>(float, float const (&) [11]):
✗ Decision 'true' not taken.
✓ Decision 'false' taken 341 times.
priv::BinResult priv::getBin<float, 32>(float, float const (&) [32]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
4225843 | if (std::isnan(value)) { |
| 35 | 2 | return { 0, 0.0f }; | ||
| 36 | } | |||
| 37 | ||||
| 38 | // Handle off-scale low | |||
| 39 |
57/72priv::BinResult priv::getBin<unsigned short, 4>(float, unsigned short const (&) [4]):
✓ Branch 0 taken 637023 times.
✓ Branch 1 taken 774563 times.
priv::BinResult priv::getBin<float, 4>(float, float const (&) [4]):
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 81 times.
priv::BinResult priv::getBin<short, 6>(float, short const (&) [6]):
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 40151 times.
priv::BinResult priv::getBin<float, 16>(float, float const (&) [16]):
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 181631 times.
priv::BinResult priv::getBin<unsigned short, 6>(float, unsigned short const (&) [6]):
✓ Branch 0 taken 272851 times.
✓ Branch 1 taken 111810 times.
priv::BinResult priv::getBin<float, 8>(float, float const (&) [8]):
✓ Branch 0 taken 146908 times.
✓ Branch 1 taken 205008 times.
priv::BinResult priv::getBin<short, 4>(float, short const (&) [4]):
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 29149 times.
priv::BinResult priv::getBin<unsigned char, 8>(float, unsigned char const (&) [8]):
✓ Branch 0 taken 65918 times.
✓ Branch 1 taken 57905 times.
priv::BinResult priv::getBin<unsigned short, 8>(float, unsigned short const (&) [8]):
✓ Branch 0 taken 39798 times.
✓ Branch 1 taken 21598 times.
priv::BinResult priv::getBin<float, 5>(float, float const (&) [5]):
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 241 times.
priv::BinResult priv::getBin<unsigned char, 6>(float, unsigned char const (&) [6]):
✓ Branch 0 taken 202636 times.
✓ Branch 1 taken 141869 times.
priv::BinResult priv::getBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✓ Branch 0 taken 205544 times.
✓ Branch 1 taken 231745 times.
priv::BinResult priv::getBin<float, 2500>(float, float const (&) [2500]):
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 24990 times.
priv::BinResult priv::getBin<float, 3>(float, float const (&) [3]):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 6 times.
priv::BinResult priv::getBin<float, 2>(float, float const (&) [2]):
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
priv::BinResult priv::getBin<short, 8>(float, short const (&) [8]):
✗ Branch 0 not taken.
✓ Branch 1 taken 90832 times.
priv::BinResult priv::getBin<unsigned char, 16>(float, unsigned char const (&) [16]):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 178 times.
priv::BinResult priv::getBin<unsigned char, 2>(float, unsigned char const (&) [2]):
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 20558 times.
priv::BinResult priv::getBin<short, 16>(float, short const (&) [16]):
✗ Branch 0 not taken.
✓ Branch 1 taken 90819 times.
priv::BinResult priv::getBin<signed char, 8>(float, signed char const (&) [8]):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 57025 times.
priv::BinResult priv::getBin<float, 6>(float, float const (&) [6]):
✗ Branch 0 not taken.
✓ Branch 1 taken 90819 times.
priv::BinResult priv::getBin<unsigned char, 10>(float, unsigned char const (&) [10]):
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
priv::BinResult priv::getBin<unsigned short, 10>(float, unsigned short const (&) [10]):
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 202 times.
priv::BinResult priv::getBin<unsigned char, 4>(float, unsigned char const (&) [4]):
✓ Branch 0 taken 74109 times.
✓ Branch 1 taken 128196 times.
priv::BinResult priv::getBin<unsigned short, 12>(float, unsigned short const (&) [12]):
✓ Branch 0 taken 1004 times.
✓ Branch 1 taken 3616 times.
priv::BinResult priv::getBin<float, 28>(float, float const (&) [28]):
✗ Branch 0 not taken.
✓ Branch 1 taken 1964 times.
priv::BinResult priv::getBin<short, 5>(float, short const (&) [5]):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 90814 times.
priv::BinResult priv::getBin<unsigned char, 5>(float, unsigned char const (&) [5]):
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 90867 times.
priv::BinResult priv::getBin<short, 10>(float, short const (&) [10]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<signed char, 2>(float, signed char const (&) [2]):
✓ Branch 0 taken 551 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<float, 11>(float, float const (&) [11]):
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
priv::BinResult priv::getBin<float, 32>(float, float const (&) [32]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned short, 2>(float, unsigned short const (&) [2]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned int, 2>(float, unsigned int const (&) [2]):
✓ Branch 0 taken 90826 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned short, 3>(float, unsigned short const (&) [3]):
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
priv::BinResult priv::getBin<int, 4>(float, int const (&) [4]):
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 52 times.
|
5/26priv::BinResult priv::getBin<unsigned short, 4>(float, unsigned short const (&) [4]):
✓ Decision 'true' taken 637023 times.
✓ Decision 'false' taken 774563 times.
priv::BinResult priv::getBin<float, 16>(float, float const (&) [16]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 6>(float, unsigned short const (&) [6]):
✓ Decision 'true' taken 272851 times.
✓ Decision 'false' taken 111810 times.
priv::BinResult priv::getBin<float, 8>(float, float const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 8>(float, unsigned char const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 8>(float, unsigned short const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<float, 5>(float, float const (&) [5]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 6>(float, unsigned char const (&) [6]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<short, 8>(float, short const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 4>(float, unsigned char const (&) [4]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<float, 11>(float, float const (&) [11]):
✗ Decision 'true' not taken.
✓ Decision 'false' taken 341 times.
priv::BinResult priv::getBin<float, 32>(float, float const (&) [32]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
4225841 | if (value <= bins[0]) { |
| 40 | 1738420 | return { 0, 0.0f }; | ||
| 41 | } | |||
| 42 | ||||
| 43 | // Handle off-scale high | |||
| 44 |
55/72priv::BinResult priv::getBin<unsigned short, 4>(float, unsigned short const (&) [4]):
✓ Branch 0 taken 704866 times.
✓ Branch 1 taken 69697 times.
priv::BinResult priv::getBin<float, 4>(float, float const (&) [4]):
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 68 times.
priv::BinResult priv::getBin<short, 6>(float, short const (&) [6]):
✓ Branch 0 taken 40150 times.
✓ Branch 1 taken 1 time.
priv::BinResult priv::getBin<float, 16>(float, float const (&) [16]):
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 181282 times.
priv::BinResult priv::getBin<unsigned short, 6>(float, unsigned short const (&) [6]):
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 111687 times.
priv::BinResult priv::getBin<float, 8>(float, float const (&) [8]):
✓ Branch 0 taken 5536 times.
✓ Branch 1 taken 199472 times.
priv::BinResult priv::getBin<short, 4>(float, short const (&) [4]):
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 4 times.
priv::BinResult priv::getBin<unsigned char, 8>(float, unsigned char const (&) [8]):
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 57900 times.
priv::BinResult priv::getBin<unsigned short, 8>(float, unsigned short const (&) [8]):
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 21583 times.
priv::BinResult priv::getBin<float, 5>(float, float const (&) [5]):
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 209 times.
priv::BinResult priv::getBin<unsigned char, 6>(float, unsigned char const (&) [6]):
✓ Branch 0 taken 141838 times.
✓ Branch 1 taken 31 times.
priv::BinResult priv::getBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 231495 times.
priv::BinResult priv::getBin<float, 2500>(float, float const (&) [2500]):
✗ Branch 0 not taken.
✓ Branch 1 taken 24990 times.
priv::BinResult priv::getBin<float, 3>(float, float const (&) [3]):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 5 times.
priv::BinResult priv::getBin<float, 2>(float, float const (&) [2]):
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
priv::BinResult priv::getBin<short, 8>(float, short const (&) [8]):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 90831 times.
priv::BinResult priv::getBin<unsigned char, 16>(float, unsigned char const (&) [16]):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 177 times.
priv::BinResult priv::getBin<unsigned char, 2>(float, unsigned char const (&) [2]):
✗ Branch 0 not taken.
✓ Branch 1 taken 20558 times.
priv::BinResult priv::getBin<short, 16>(float, short const (&) [16]):
✗ Branch 0 not taken.
✓ Branch 1 taken 90819 times.
priv::BinResult priv::getBin<signed char, 8>(float, signed char const (&) [8]):
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 57024 times.
priv::BinResult priv::getBin<float, 6>(float, float const (&) [6]):
✗ Branch 0 not taken.
✓ Branch 1 taken 90819 times.
priv::BinResult priv::getBin<unsigned char, 10>(float, unsigned char const (&) [10]):
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
priv::BinResult priv::getBin<unsigned short, 10>(float, unsigned short const (&) [10]):
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 48 times.
priv::BinResult priv::getBin<unsigned char, 4>(float, unsigned char const (&) [4]):
✓ Branch 0 taken 90714 times.
✓ Branch 1 taken 37482 times.
priv::BinResult priv::getBin<unsigned short, 12>(float, unsigned short const (&) [12]):
✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 2524 times.
priv::BinResult priv::getBin<float, 28>(float, float const (&) [28]):
✗ Branch 0 not taken.
✓ Branch 1 taken 1964 times.
priv::BinResult priv::getBin<short, 5>(float, short const (&) [5]):
✓ Branch 0 taken 90785 times.
✓ Branch 1 taken 29 times.
priv::BinResult priv::getBin<unsigned char, 5>(float, unsigned char const (&) [5]):
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 90859 times.
priv::BinResult priv::getBin<short, 10>(float, short const (&) [10]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<signed char, 2>(float, signed char const (&) [2]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<float, 11>(float, float const (&) [11]):
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 293 times.
priv::BinResult priv::getBin<float, 32>(float, float const (&) [32]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned short, 2>(float, unsigned short const (&) [2]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned int, 2>(float, unsigned int const (&) [2]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned short, 3>(float, unsigned short const (&) [3]):
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
priv::BinResult priv::getBin<int, 4>(float, int const (&) [4]):
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 44 times.
|
6/26priv::BinResult priv::getBin<unsigned short, 4>(float, unsigned short const (&) [4]):
✓ Decision 'true' taken 704866 times.
✓ Decision 'false' taken 69697 times.
priv::BinResult priv::getBin<float, 16>(float, float const (&) [16]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 6>(float, unsigned short const (&) [6]):
✓ Decision 'true' taken 123 times.
✓ Decision 'false' taken 111687 times.
priv::BinResult priv::getBin<float, 8>(float, float const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 8>(float, unsigned char const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 8>(float, unsigned short const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<float, 5>(float, float const (&) [5]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 6>(float, unsigned char const (&) [6]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<short, 8>(float, short const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 4>(float, unsigned char const (&) [4]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<float, 11>(float, float const (&) [11]):
✓ Decision 'true' taken 48 times.
✓ Decision 'false' taken 293 times.
priv::BinResult priv::getBin<float, 32>(float, float const (&) [32]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
2487421 | if (value >= bins[TSize - 1]) { |
| 45 | 1105140 | return { TSize - 2, 1.0f }; | ||
| 46 | } | |||
| 47 | ||||
| 48 | 1382281 | size_t idx = 0; | ||
| 49 | ||||
| 50 | // Find the last index less than the searched value | |||
| 51 | // Linear search for now, maybe binary search in future | |||
| 52 | // after collecting real perf data | |||
| 53 |
31/72priv::BinResult priv::getBin<unsigned short, 4>(float, unsigned short const (&) [4]):
✓ Branch 0 taken 90758 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<float, 4>(float, float const (&) [4]):
✓ Branch 0 taken 156 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<short, 6>(float, short const (&) [6]):
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<float, 16>(float, float const (&) [16]):
✓ Branch 0 taken 1812078 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned short, 6>(float, unsigned short const (&) [6]):
✓ Branch 0 taken 399780 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<float, 8>(float, float const (&) [8]):
✓ Branch 0 taken 1000401 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<short, 4>(float, short const (&) [4]):
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned char, 8>(float, unsigned char const (&) [8]):
✓ Branch 0 taken 346361 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned short, 8>(float, unsigned short const (&) [8]):
✓ Branch 0 taken 30332 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<float, 5>(float, float const (&) [5]):
✓ Branch 0 taken 511 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned char, 6>(float, unsigned char const (&) [6]):
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✓ Branch 0 taken 1944889 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<float, 2500>(float, float const (&) [2500]):
✓ Branch 0 taken 31235592 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<float, 3>(float, float const (&) [3]):
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<float, 2>(float, float const (&) [2]):
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<short, 8>(float, short const (&) [8]):
✓ Branch 0 taken 455121 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned char, 16>(float, unsigned char const (&) [16]):
✓ Branch 0 taken 1612 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned char, 2>(float, unsigned char const (&) [2]):
✓ Branch 0 taken 20558 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<short, 16>(float, short const (&) [16]):
✓ Branch 0 taken 992530 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<signed char, 8>(float, signed char const (&) [8]):
✓ Branch 0 taken 285119 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<float, 6>(float, float const (&) [6]):
✓ Branch 0 taken 363254 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned char, 10>(float, unsigned char const (&) [10]):
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned short, 10>(float, unsigned short const (&) [10]):
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned char, 4>(float, unsigned char const (&) [4]):
✓ Branch 0 taken 59643 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned short, 12>(float, unsigned short const (&) [12]):
✓ Branch 0 taken 15541 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<float, 28>(float, float const (&) [28]):
✓ Branch 0 taken 52956 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<short, 5>(float, short const (&) [5]):
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned char, 5>(float, unsigned char const (&) [5]):
✓ Branch 0 taken 272319 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<short, 10>(float, short const (&) [10]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<signed char, 2>(float, signed char const (&) [2]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<float, 11>(float, float const (&) [11]):
✓ Branch 0 taken 1473 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<float, 32>(float, float const (&) [32]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned short, 2>(float, unsigned short const (&) [2]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned int, 2>(float, unsigned int const (&) [2]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<unsigned short, 3>(float, unsigned short const (&) [3]):
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
priv::BinResult priv::getBin<int, 4>(float, int const (&) [4]):
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
|
3/26priv::BinResult priv::getBin<unsigned short, 4>(float, unsigned short const (&) [4]):
✓ Decision 'true' taken 90758 times.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<float, 16>(float, float const (&) [16]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 6>(float, unsigned short const (&) [6]):
✓ Decision 'true' taken 399780 times.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<float, 8>(float, float const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 8>(float, unsigned char const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 8>(float, unsigned short const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<float, 5>(float, float const (&) [5]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 6>(float, unsigned char const (&) [6]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<short, 8>(float, short const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 4>(float, unsigned char const (&) [4]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<float, 11>(float, float const (&) [11]):
✓ Decision 'true' taken 1473 times.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<float, 32>(float, float const (&) [32]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
39382145 | for (idx = 0; idx < TSize - 1; idx++) { |
| 54 |
60/72priv::BinResult priv::getBin<unsigned short, 4>(float, unsigned short const (&) [4]):
✓ Branch 1 taken 69697 times.
✓ Branch 2 taken 21061 times.
priv::BinResult priv::getBin<float, 4>(float, float const (&) [4]):
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 88 times.
priv::BinResult priv::getBin<short, 6>(float, short const (&) [6]):
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 4 times.
priv::BinResult priv::getBin<float, 16>(float, float const (&) [16]):
✓ Branch 1 taken 181282 times.
✓ Branch 2 taken 1630796 times.
priv::BinResult priv::getBin<unsigned short, 6>(float, unsigned short const (&) [6]):
✓ Branch 1 taken 111687 times.
✓ Branch 2 taken 288093 times.
priv::BinResult priv::getBin<float, 8>(float, float const (&) [8]):
✓ Branch 1 taken 199472 times.
✓ Branch 2 taken 800929 times.
priv::BinResult priv::getBin<short, 4>(float, short const (&) [4]):
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 6 times.
priv::BinResult priv::getBin<unsigned char, 8>(float, unsigned char const (&) [8]):
✓ Branch 1 taken 57900 times.
✓ Branch 2 taken 288461 times.
priv::BinResult priv::getBin<unsigned short, 8>(float, unsigned short const (&) [8]):
✓ Branch 1 taken 21583 times.
✓ Branch 2 taken 8749 times.
priv::BinResult priv::getBin<float, 5>(float, float const (&) [5]):
✓ Branch 1 taken 209 times.
✓ Branch 2 taken 302 times.
priv::BinResult priv::getBin<unsigned char, 6>(float, unsigned char const (&) [6]):
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 19 times.
priv::BinResult priv::getBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✓ Branch 1 taken 231495 times.
✓ Branch 2 taken 1713394 times.
priv::BinResult priv::getBin<float, 2500>(float, float const (&) [2500]):
✓ Branch 1 taken 24990 times.
✓ Branch 2 taken 31210602 times.
priv::BinResult priv::getBin<float, 3>(float, float const (&) [3]):
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 3 times.
priv::BinResult priv::getBin<float, 2>(float, float const (&) [2]):
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
priv::BinResult priv::getBin<short, 8>(float, short const (&) [8]):
✓ Branch 1 taken 90831 times.
✓ Branch 2 taken 364290 times.
priv::BinResult priv::getBin<unsigned char, 16>(float, unsigned char const (&) [16]):
✓ Branch 1 taken 177 times.
✓ Branch 2 taken 1435 times.
priv::BinResult priv::getBin<unsigned char, 2>(float, unsigned char const (&) [2]):
✓ Branch 1 taken 20558 times.
✗ Branch 2 not taken.
priv::BinResult priv::getBin<short, 16>(float, short const (&) [16]):
✓ Branch 1 taken 90819 times.
✓ Branch 2 taken 901711 times.
priv::BinResult priv::getBin<signed char, 8>(float, signed char const (&) [8]):
✓ Branch 1 taken 57024 times.
✓ Branch 2 taken 228095 times.
priv::BinResult priv::getBin<float, 6>(float, float const (&) [6]):
✓ Branch 1 taken 90819 times.
✓ Branch 2 taken 272435 times.
priv::BinResult priv::getBin<unsigned char, 10>(float, unsigned char const (&) [10]):
✓ Branch 1 taken 381 times.
✓ Branch 2 taken 387 times.
priv::BinResult priv::getBin<unsigned short, 10>(float, unsigned short const (&) [10]):
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 71 times.
priv::BinResult priv::getBin<unsigned char, 4>(float, unsigned char const (&) [4]):
✓ Branch 1 taken 37482 times.
✓ Branch 2 taken 22161 times.
priv::BinResult priv::getBin<unsigned short, 12>(float, unsigned short const (&) [12]):
✓ Branch 1 taken 2524 times.
✓ Branch 2 taken 13017 times.
priv::BinResult priv::getBin<float, 28>(float, float const (&) [28]):
✓ Branch 1 taken 1964 times.
✓ Branch 2 taken 50992 times.
priv::BinResult priv::getBin<short, 5>(float, short const (&) [5]):
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 66 times.
priv::BinResult priv::getBin<unsigned char, 5>(float, unsigned char const (&) [5]):
✓ Branch 1 taken 90859 times.
✓ Branch 2 taken 181460 times.
priv::BinResult priv::getBin<short, 10>(float, short const (&) [10]):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
priv::BinResult priv::getBin<signed char, 2>(float, signed char const (&) [2]):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
priv::BinResult priv::getBin<float, 11>(float, float const (&) [11]):
✓ Branch 1 taken 293 times.
✓ Branch 2 taken 1180 times.
priv::BinResult priv::getBin<float, 32>(float, float const (&) [32]):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
priv::BinResult priv::getBin<unsigned short, 2>(float, unsigned short const (&) [2]):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
priv::BinResult priv::getBin<unsigned int, 2>(float, unsigned int const (&) [2]):
✗ Branch 1 not taken.
✗ Branch 2 not taken.
priv::BinResult priv::getBin<unsigned short, 3>(float, unsigned short const (&) [3]):
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 time.
priv::BinResult priv::getBin<int, 4>(float, int const (&) [4]):
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 56 times.
|
6/26priv::BinResult priv::getBin<unsigned short, 4>(float, unsigned short const (&) [4]):
✓ Decision 'true' taken 69697 times.
✓ Decision 'false' taken 21061 times.
priv::BinResult priv::getBin<float, 16>(float, float const (&) [16]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 6>(float, unsigned short const (&) [6]):
✓ Decision 'true' taken 111687 times.
✓ Decision 'false' taken 288093 times.
priv::BinResult priv::getBin<float, 8>(float, float const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 8>(float, unsigned char const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 8>(float, unsigned short const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<float, 5>(float, float const (&) [5]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 6>(float, unsigned char const (&) [6]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<short, 8>(float, short const (&) [8]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<unsigned char, 4>(float, unsigned char const (&) [4]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
priv::BinResult priv::getBin<float, 11>(float, float const (&) [11]):
✓ Decision 'true' taken 293 times.
✓ Decision 'false' taken 1180 times.
priv::BinResult priv::getBin<float, 32>(float, float const (&) [32]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
39382145 | if (bins[idx + 1] > value) { |
| 55 | 1382281 | break; | ||
| 56 | } | |||
| 57 | } | |||
| 58 | ||||
| 59 | 1382281 | float low = bins[idx]; | ||
| 60 | 1382281 | float high = bins[idx + 1]; | ||
| 61 | ||||
| 62 | // Compute how far along the bin we are | |||
| 63 | // (0.0f = left side, 1.0f = right side) | |||
| 64 | 1382281 | float fraction = (value - low) / (high - low); | ||
| 65 | ||||
| 66 | 1382281 | return { idx, fraction }; | ||
| 67 | } | |||
| 68 | ||||
| 69 | /** | |||
| 70 | * @brief Finds the location of a closest value in the bin array. | |||
| 71 | * | |||
| 72 | * @param value The value to find in the bins. | |||
| 73 | * @return A result containing the index of the closest to bin value, | |||
| 74 | * and how far from (idx) to (idx + 1) or (idx - 1) the value is located. | |||
| 75 | * If value is outside of bin - {0, <-1.0} or {Tsize - 1, >+1.0} is returned | |||
| 76 | */ | |||
| 77 | template<class TBin, int TSize> | |||
| 78 | 80008 | struct BinResult getClosestBin(float value, const TBin (&bins)[TSize]) { | ||
| 79 | // Enforce numeric only (int, float, uintx_t, etc) | |||
| 80 | static_assert(std::is_arithmetic_v<TBin>, "Table bins must be an arithmetic type"); | |||
| 81 | ||||
| 82 | // Enforce that there are enough bins to make sense (what does one bin even mean?) | |||
| 83 | static_assert(TSize >= 2); | |||
| 84 | ||||
| 85 | // Handle NaN | |||
| 86 |
2/4priv::BinResult priv::getClosestBin<float, 14>(float, float const (&) [14]):
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
priv::BinResult priv::getClosestBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Branch 1 not taken.
✓ Branch 2 taken 80000 times.
|
2/4priv::BinResult priv::getClosestBin<float, 14>(float, float const (&) [14]):
✗ Decision 'true' not taken.
✓ Decision 'false' taken 8 times.
priv::BinResult priv::getClosestBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Decision 'true' not taken.
✓ Decision 'false' taken 80000 times.
|
80008 | if (std::isnan(value)) { |
| 87 | ✗ | return { 0, -1.0f }; | ||
| 88 | } | |||
| 89 | ||||
| 90 | 80008 | const size_t lastIdx = TSize - 1; | ||
| 91 | 80008 | size_t idx = 0; | ||
| 92 | float closest; | |||
| 93 | float step; | |||
| 94 | ||||
| 95 |
3/4priv::BinResult priv::getClosestBin<float, 14>(float, float const (&) [14]):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
priv::BinResult priv::getClosestBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✓ Branch 0 taken 80000 times.
✗ Branch 1 not taken.
|
3/4priv::BinResult priv::getClosestBin<float, 14>(float, float const (&) [14]):
✓ Decision 'true' taken 3 times.
✓ Decision 'false' taken 5 times.
priv::BinResult priv::getClosestBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✓ Decision 'true' taken 80000 times.
✗ Decision 'false' not taken.
|
80008 | if (value <= bins[0]) { |
| 96 | // Handle off-scale low | |||
| 97 | // virtual bins[-1] located at the same distance to the left from bins[0], as bins[1] from bins[0] | |||
| 98 | 80003 | step = bins[1] - bins[0]; | ||
| 99 | 80003 | idx = 0; | ||
| 100 |
2/4priv::BinResult priv::getClosestBin<float, 14>(float, float const (&) [14]):
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
priv::BinResult priv::getClosestBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
2/4priv::BinResult priv::getClosestBin<float, 14>(float, float const (&) [14]):
✓ Decision 'true' taken 3 times.
✓ Decision 'false' taken 2 times.
priv::BinResult priv::getClosestBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
5 | } else if (value >= bins[lastIdx]) { |
| 101 | // Handle off-scale high | |||
| 102 | // virtual bins[lastIdx + 1] located at the same distance to the right from bins[lastIdx], as bins[lastIdx - 1] from bins[lastIdx] | |||
| 103 | 3 | step = bins[lastIdx] - bins[lastIdx - 1]; | ||
| 104 | 3 | idx = lastIdx; | ||
| 105 | } else { | |||
| 106 | // Find the closest bin. 50/50 divide distance between bins | |||
| 107 | // Linear search for now, maybe binary search in future | |||
| 108 | // after collecting real perf data | |||
| 109 |
1/4priv::BinResult priv::getClosestBin<float, 14>(float, float const (&) [14]):
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
priv::BinResult priv::getClosestBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
1/4priv::BinResult priv::getClosestBin<float, 14>(float, float const (&) [14]):
✓ Decision 'true' taken 3 times.
✗ Decision 'false' not taken.
priv::BinResult priv::getClosestBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
3 | for (idx = 0; idx < lastIdx - 1; idx++) { |
| 110 | // ( -0.5, 05 ] | |||
| 111 | // if (bins[idx] + bins[idx + 1] / 2 >= value) { | |||
| 112 |
2/4priv::BinResult priv::getClosestBin<float, 14>(float, float const (&) [14]):
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 time.
priv::BinResult priv::getClosestBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2/4priv::BinResult priv::getClosestBin<float, 14>(float, float const (&) [14]):
✓ Decision 'true' taken 2 times.
✓ Decision 'false' taken 1 time.
priv::BinResult priv::getClosestBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
3 | if (bins[idx] + bins[idx + 1] >= 2 * value) { |
| 113 | 2 | break; | ||
| 114 | } | |||
| 115 | } | |||
| 116 | ||||
| 117 | 2 | step = bins[idx + 1] - bins[idx]; | ||
| 118 | } | |||
| 119 | ||||
| 120 |
2/4priv::BinResult priv::getClosestBin<float, 14>(float, float const (&) [14]):
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
priv::BinResult priv::getClosestBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Branch 0 not taken.
✓ Branch 1 taken 80000 times.
|
2/4priv::BinResult priv::getClosestBin<float, 14>(float, float const (&) [14]):
✗ Decision 'true' not taken.
✓ Decision 'false' taken 8 times.
priv::BinResult priv::getClosestBin<unsigned short, 16>(float, unsigned short const (&) [16]):
✗ Decision 'true' not taken.
✓ Decision 'false' taken 80000 times.
|
80008 | if (step <= 0) { |
| 121 | // bins are not ascending or two bins are equal | |||
| 122 | ✗ | return { idx, 1.0f }; | ||
| 123 | } | |||
| 124 | ||||
| 125 | 80008 | closest = bins[idx]; | ||
| 126 | ||||
| 127 | // Compute how far from the closest bin we are: | |||
| 128 | // 0.0f = rigft in the bin | |||
| 129 | // -0.5f = half way to previous bin, 0.5f = half way to next bin | |||
| 130 | // <= -1.0f = to far below zero bin | |||
| 131 | // >= 1.0f = to far above last bin | |||
| 132 | 80008 | float distance = (value - closest) / step; | ||
| 133 | ||||
| 134 | 80008 | return { idx, distance }; | ||
| 135 | } | |||
| 136 | ||||
| 137 | template<class TBin, int TSize, int TMult, int TDiv> | |||
| 138 | 896582 | BinResult getBin(float value, const scaled_channel<TBin, TMult, TDiv> (&bins)[TSize]) { | ||
| 139 | 896582 | return getBin(value * (float(TMult) / TDiv), *reinterpret_cast<const TBin (*)[TSize]>(&bins)); | ||
| 140 | } | |||
| 141 | ||||
| 142 | 5870139 | static inline float linterp(float low, float high, float frac) | ||
| 143 | { | |||
| 144 | 5870139 | return high * frac + low * (1 - frac); | ||
| 145 | } | |||
| 146 | } // namespace priv | |||
| 147 | ||||
| 148 | template <class TBin, class TValue, int TSize> | |||
| 149 | 937209 | float interpolate2d(const float value, const TBin (&bin)[TSize], const TValue (&values)[TSize]) { | ||
| 150 | // Enforce numeric only (int, float, uintx_t, etc) | |||
| 151 | static_assert(std::is_arithmetic_v<TBin> || is_scaled_channel<TBin>, "Table values must be an arithmetic type or scaled channel"); | |||
| 152 | ||||
| 153 | 937209 | auto b = priv::getBin(value, bin); | ||
| 154 | ||||
| 155 | // Convert to float as we read it out | |||
| 156 | 937209 | float low = static_cast<float>(values[b.Idx]); | ||
| 157 | 937209 | float high = static_cast<float>(values[b.Idx + 1]); | ||
| 158 | 937209 | float frac = b.Frac; | ||
| 159 | ||||
| 160 | 937209 | return priv::linterp(low, high, frac); | ||
| 161 | } | |||
| 162 | ||||
| 163 | // TS defines tables as [y_row_count x x_column_count] and we follow that weird Y, X order of arguments here | |||
| 164 | // todo: add support for scaled_channel to match Map3D flexibility? | |||
| 165 | template<typename VType, unsigned RNum, typename RType, unsigned X_ColumnNum, typename X_CType> | |||
| 166 | 274393 | float interpolate3d(const VType (&table)[RNum][X_ColumnNum], | ||
| 167 | const RType (&rowBins)[RNum], float yRowValue, | |||
| 168 | const X_CType (&colBins)[X_ColumnNum], float xColValue) | |||
| 169 | { | |||
| 170 | 274393 | auto row = priv::getBin(yRowValue, rowBins); | ||
| 171 | 274393 | auto col = priv::getBin(xColValue, colBins); | ||
| 172 | ||||
| 173 | // Orient the table such that (0, 0) is the bottom left corner, | |||
| 174 | // then the following variable names will make sense | |||
| 175 | 274393 | float lowerLeft = table[row.Idx ][col.Idx ]; | ||
| 176 | 274393 | float upperLeft = table[row.Idx + 1][col.Idx ]; | ||
| 177 | 274393 | float lowerRight = table[row.Idx ][col.Idx + 1]; | ||
| 178 | 274393 | float upperRight = table[row.Idx + 1][col.Idx + 1]; | ||
| 179 | ||||
| 180 | // Interpolate each side by itself | |||
| 181 | 274393 | float left = priv::linterp(lowerLeft, upperLeft, row.Frac); | ||
| 182 | 274393 | float right = priv::linterp(lowerRight, upperRight, row.Frac); | ||
| 183 | ||||
| 184 | // Then interpolate between those | |||
| 185 | 274393 | return priv::linterp(left, right, col.Frac); | ||
| 186 | } | |||
| 187 |