MCPcopy Create free account
hub / github.com/DFHack/dfhack / lode_png_test_bitreader

Function lode_png_test_bitreader

depends/lodepng/lodepng.cpp:587–604  ·  view source on GitHub ↗

Public for testing only. steps and result must have numsteps values. */

Source from the content-addressed store, hash-verified

585
586/* Public for testing only. steps and result must have numsteps values. */
587unsigned lode_png_test_bitreader(const unsigned char* data, size_t size,
588 size_t numsteps, const size_t* steps, unsigned* result) {
589 size_t i;
590 LodePNGBitReader reader;
591 unsigned error = LodePNGBitReader_init(&reader, data, size);
592 if(error) return 0;
593 for(i = 0; i < numsteps; i++) {
594 size_t step = steps[i];
595 unsigned ok;
596 if(step > 25) ok = ensureBits32(&reader, step);
597 else if(step > 17) ok = ensureBits25(&reader, step);
598 else if(step > 9) ok = ensureBits17(&reader, step);
599 else ok = ensureBits9(&reader, step);
600 if(!ok) return 0;
601 result[i] = readBits(&reader, step);
602 }
603 return 1;
604}
605#endif /*LODEPNG_COMPILE_DECODER*/
606
607static unsigned reverseBits(unsigned bits, unsigned num) {

Callers

nothing calls this directly

Calls 6

LodePNGBitReader_initFunction · 0.85
ensureBits32Function · 0.85
ensureBits25Function · 0.85
ensureBits17Function · 0.85
ensureBits9Function · 0.85
readBitsFunction · 0.85

Tested by

no test coverage detected