MCPcopy Create free account
hub / github.com/creatale/node-dv / removePaddingBits

Function removePaddingBits

deps/lodepng/lodepng.cpp:4194–4219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4192}
4193
4194static void removePaddingBits(unsigned char* out, const unsigned char* in,
4195 size_t olinebits, size_t ilinebits, unsigned h)
4196{
4197 /*
4198 After filtering there are still padding bits if scanlines have non multiple of 8 bit amounts. They need
4199 to be removed (except at last scanline of (Adam7-reduced) image) before working with pure image buffers
4200 for the Adam7 code, the color convert code and the output to the user.
4201 in and out are allowed to be the same buffer, in may also be higher but still overlapping; in must
4202 have >= ilinebits*h bits, out must have >= olinebits*h bits, olinebits must be <= ilinebits
4203 also used to move bits after earlier such operations happened, e.g. in a sequence of reduced images from Adam7
4204 only useful if (ilinebits - olinebits) is a value in the range 1..7
4205 */
4206 unsigned y;
4207 size_t diff = ilinebits - olinebits;
4208 size_t ibp = 0, obp = 0; /*input and output bit pointers*/
4209 for(y = 0; y < h; ++y)
4210 {
4211 size_t x;
4212 for(x = 0; x < olinebits; ++x)
4213 {
4214 unsigned char bit = readBitFromReversedStream(&ibp, in);
4215 setBitOfReversedStream(&obp, out, bit);
4216 }
4217 ibp += diff;
4218 }
4219}
4220
4221/*out must be buffer big enough to contain full image, and in must contain the full decompressed data from
4222the 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