MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / removePaddingBits

Function removePaddingBits

dependency/densecrf/examples/lodepng.cpp:4129–4154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4127}
4128
4129static void removePaddingBits(unsigned char* out, const unsigned char* in,
4130 size_t olinebits, size_t ilinebits, unsigned h)
4131{
4132 /*
4133 After filtering there are still padding bits if scanlines have non multiple of 8 bit amounts. They need
4134 to be removed (except at last scanline of (Adam7-reduced) image) before working with pure image buffers
4135 for the Adam7 code, the color convert code and the output to the user.
4136 in and out are allowed to be the same buffer, in may also be higher but still overlapping; in must
4137 have >= ilinebits*h bits, out must have >= olinebits*h bits, olinebits must be <= ilinebits
4138 also used to move bits after earlier such operations happened, e.g. in a sequence of reduced images from Adam7
4139 only useful if (ilinebits - olinebits) is a value in the range 1..7
4140 */
4141 unsigned y;
4142 size_t diff = ilinebits - olinebits;
4143 size_t ibp = 0, obp = 0; /*input and output bit pointers*/
4144 for(y = 0; y < h; ++y)
4145 {
4146 size_t x;
4147 for(x = 0; x < olinebits; ++x)
4148 {
4149 unsigned char bit = readBitFromReversedStream(&ibp, in);
4150 setBitOfReversedStream(&obp, out, bit);
4151 }
4152 ibp += diff;
4153 }
4154}
4155
4156/*out must be buffer big enough to contain full image, and in must contain the full decompressed data from
4157 the IDAT chunks (with filter index bytes and possible padding bits)

Callers 1

postProcessScanlinesFunction · 0.85

Calls 2

setBitOfReversedStreamFunction · 0.85

Tested by

no test coverage detected