MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / removePaddingBits

Function removePaddingBits

src/lodepng.cpp:4174–4199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4172}
4173
4174static void removePaddingBits(unsigned char* out, const unsigned char* in,
4175 size_t olinebits, size_t ilinebits, unsigned h)
4176{
4177 /*
4178 After filtering there are still padding bits if scanlines have non multiple of 8 bit amounts. They need
4179 to be removed (except at last scanline of (Adam7-reduced) image) before working with pure image buffers
4180 for the Adam7 code, the color convert code and the output to the user.
4181 in and out are allowed to be the same buffer, in may also be higher but still overlapping; in must
4182 have >= ilinebits*h bits, out must have >= olinebits*h bits, olinebits must be <= ilinebits
4183 also used to move bits after earlier such operations happened, e.g. in a sequence of reduced images from Adam7
4184 only useful if (ilinebits - olinebits) is a value in the range 1..7
4185 */
4186 unsigned y;
4187 size_t diff = ilinebits - olinebits;
4188 size_t ibp = 0, obp = 0; /*input and output bit pointers*/
4189 for(y = 0; y < h; y++)
4190 {
4191 size_t x;
4192 for(x = 0; x < olinebits; x++)
4193 {
4194 unsigned char bit = readBitFromReversedStream(&ibp, in);
4195 setBitOfReversedStream(&obp, out, bit);
4196 }
4197 ibp += diff;
4198 }
4199}
4200
4201/*out must be buffer big enough to contain full image, and in must contain the full decompressed data from
4202the 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