LSB of value is written first, and LSB of bytes is used first */
| 430 | |
| 431 | /* LSB of value is written first, and LSB of bytes is used first */ |
| 432 | static void writeBits(LodePNGBitWriter* writer, unsigned value, size_t nbits) { |
| 433 | if(nbits == 1) { /* compiler should statically compile this case if nbits == 1 */ |
| 434 | WRITEBIT(writer, value); |
| 435 | } else { |
| 436 | /* TODO: increase output size only once here rather than in each WRITEBIT */ |
| 437 | size_t i; |
| 438 | for(i = 0; i != nbits; ++i) { |
| 439 | WRITEBIT(writer, (unsigned char)((value >> i) & 1)); |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | /* This one is to use for adding huffman symbol, the value bits are written MSB first */ |
| 445 | static void writeBitsReversed(LodePNGBitWriter* writer, unsigned value, size_t nbits) { |
no outgoing calls
no test coverage detected