| 117 | } |
| 118 | |
| 119 | std::optional<std::array<int, 3>> DecodeNextTriple(BitSource& bits) |
| 120 | { |
| 121 | // Values are encoded in a 16-bit value as (1600 * C1) + (40 * C2) + C3 + 1 |
| 122 | // If there is less than 2 bytes left or the next byte is the unlatch codeword then the current segment has ended |
| 123 | if (bits.available() < 16) |
| 124 | return {}; |
| 125 | int firstByte = bits.readBits(8); |
| 126 | if (firstByte == 254) // Unlatch codeword |
| 127 | return {}; |
| 128 | |
| 129 | int fullBitValue = (firstByte << 8) + bits.readBits(8) - 1; |
| 130 | int a = fullBitValue / 1600; |
| 131 | fullBitValue -= a * 1600; |
| 132 | int b = fullBitValue / 40; |
| 133 | int c = fullBitValue - b * 40; |
| 134 | |
| 135 | return {{a, b, c}}; |
| 136 | } |
| 137 | |
| 138 | enum class Mode {C40, TEXT}; |
| 139 |
no test coverage detected