* @return true if the number of input bits will fit in a code with the specified version and * error correction level. */
| 252 | * error correction level. |
| 253 | */ |
| 254 | static bool WillFit(int numInputBits, const Version& version, ErrorCorrectionLevel ecLevel) { |
| 255 | // In the following comments, we use numbers of Version 7-H. |
| 256 | // numBytes = 196 |
| 257 | int numBytes = version.totalCodewords(); |
| 258 | // getNumECBytes = 130 |
| 259 | auto& ecBlocks = version.ecBlocksForLevel(ecLevel); |
| 260 | int numEcBytes = ecBlocks.totalCodewords(); |
| 261 | // getNumDataBytes = 196 - 130 = 66 |
| 262 | int numDataBytes = numBytes - numEcBytes; |
| 263 | int totalInputBytes = (numInputBits + 7) / 8; |
| 264 | return numDataBytes >= totalInputBytes; |
| 265 | } |
| 266 | |
| 267 | static const Version& ChooseVersion(int numInputBits, ErrorCorrectionLevel ecLevel) |
| 268 | { |
no test coverage detected