| 4277 | } |
| 4278 | |
| 4279 | static void removePaddingBits(unsigned char* out, const unsigned char* in, |
| 4280 | size_t olinebits, size_t ilinebits, unsigned h) { |
| 4281 | /* |
| 4282 | After filtering there are still padding bits if scanlines have non multiple of 8 bit amounts. They need |
| 4283 | to be removed (except at last scanline of (Adam7-reduced) image) before working with pure image buffers |
| 4284 | for the Adam7 code, the color convert code and the output to the user. |
| 4285 | in and out are allowed to be the same buffer, in may also be higher but still overlapping; in must |
| 4286 | have >= ilinebits*h bits, out must have >= olinebits*h bits, olinebits must be <= ilinebits |
| 4287 | also used to move bits after earlier such operations happened, e.g. in a sequence of reduced images from Adam7 |
| 4288 | only useful if (ilinebits - olinebits) is a value in the range 1..7 |
| 4289 | */ |
| 4290 | unsigned y; |
| 4291 | size_t diff = ilinebits - olinebits; |
| 4292 | size_t ibp = 0, obp = 0; /*input and output bit pointers*/ |
| 4293 | for(y = 0; y < h; ++y) { |
| 4294 | size_t x; |
| 4295 | for(x = 0; x < olinebits; ++x) { |
| 4296 | unsigned char bit = readBitFromReversedStream(&ibp, in); |
| 4297 | setBitOfReversedStream(&obp, out, bit); |
| 4298 | } |
| 4299 | ibp += diff; |
| 4300 | } |
| 4301 | } |
| 4302 | |
| 4303 | /*out must be buffer big enough to contain full image, and in must contain the full decompressed data from |
| 4304 | the IDAT chunks (with filter index bytes and possible padding bits) |
no test coverage detected