MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / removePaddingBits

Function removePaddingBits

samples/shared/lodepng.cpp:4028–4053  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4026}
4027
4028static void removePaddingBits(unsigned char* out, const unsigned char* in,
4029 size_t olinebits, size_t ilinebits, unsigned h)
4030{
4031 /*
4032 After filtering there are still padding bits if scanlines have non multiple of 8 bit amounts. They need
4033 to be removed (except at last scanline of (Adam7-reduced) image) before working with pure image buffers
4034 for the Adam7 code, the color convert code and the output to the user.
4035 in and out are allowed to be the same buffer, in may also be higher but still overlapping; in must
4036 have >= ilinebits*h bits, out must have >= olinebits*h bits, olinebits must be <= ilinebits
4037 also used to move bits after earlier such operations happened, e.g. in a sequence of reduced images from Adam7
4038 only useful if (ilinebits - olinebits) is a value in the range 1..7
4039 */
4040 unsigned y;
4041 size_t diff = ilinebits - olinebits;
4042 size_t ibp = 0, obp = 0; /*input and output bit pointers*/
4043 for(y = 0; y < h; y++)
4044 {
4045 size_t x;
4046 for(x = 0; x < olinebits; x++)
4047 {
4048 unsigned char bit = readBitFromReversedStream(&ibp, in);
4049 setBitOfReversedStream(&obp, out, bit);
4050 }
4051 ibp += diff;
4052 }
4053}
4054
4055/*out must be buffer big enough to contain full image, and in must contain the full decompressed data from
4056the 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