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

Function Adam7_deinterlace

src/lodepng.cpp:4124–4172  ·  view source on GitHub ↗

in: Adam7 interlaced image, with no padding bits between scanlines, but between reduced images so that each reduced image starts at a byte. out: the same pixels, but re-ordered so that they're now a non-interlaced image with size w*h bpp: bits per pixel out has the following size in bits: w * h * bpp. in is possibly bigger due to padding bits between reduced images. out must be big enough AND mus

Source from the content-addressed store, hash-verified

4122NOTE: comments about padding bits are only relevant if bpp < 8
4123*/
4124static void Adam7_deinterlace(unsigned char* out, const unsigned char* in, unsigned w, unsigned h, unsigned bpp)
4125{
4126 unsigned passw[7], passh[7];
4127 size_t filter_passstart[8], padded_passstart[8], passstart[8];
4128 unsigned i;
4129
4130 Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);
4131
4132 if(bpp >= 8)
4133 {
4134 for(i = 0; i < 7; i++)
4135 {
4136 unsigned x, y, b;
4137 size_t bytewidth = bpp / 8;
4138 for(y = 0; y < passh[i]; y++)
4139 for(x = 0; x < passw[i]; x++)
4140 {
4141 size_t pixelinstart = passstart[i] + (y * passw[i] + x) * bytewidth;
4142 size_t pixeloutstart = ((ADAM7_IY[i] + y * ADAM7_DY[i]) * w + ADAM7_IX[i] + x * ADAM7_DX[i]) * bytewidth;
4143 for(b = 0; b < bytewidth; b++)
4144 {
4145 out[pixeloutstart + b] = in[pixelinstart + b];
4146 }
4147 }
4148 }
4149 }
4150 else /*bpp < 8: Adam7 with pixels < 8 bit is a bit trickier: with bit pointers*/
4151 {
4152 for(i = 0; i < 7; i++)
4153 {
4154 unsigned x, y, b;
4155 unsigned ilinebits = bpp * passw[i];
4156 unsigned olinebits = bpp * w;
4157 size_t obp, ibp; /*bit pointers (for out and in buffer)*/
4158 for(y = 0; y < passh[i]; y++)
4159 for(x = 0; x < passw[i]; x++)
4160 {
4161 ibp = (8 * passstart[i]) + (y * ilinebits + x * bpp);
4162 obp = (ADAM7_IY[i] + y * ADAM7_DY[i]) * olinebits + (ADAM7_IX[i] + x * ADAM7_DX[i]) * bpp;
4163 for(b = 0; b < bpp; b++)
4164 {
4165 unsigned char bit = readBitFromReversedStream(&ibp, in);
4166 /*note that this function assumes the out buffer is completely 0, use setBitOfReversedStream otherwise*/
4167 setBitOfReversedStream0(&obp, out, bit);
4168 }
4169 }
4170 }
4171 }
4172}
4173
4174static void removePaddingBits(unsigned char* out, const unsigned char* in,
4175 size_t olinebits, size_t ilinebits, unsigned h)

Callers 1

postProcessScanlinesFunction · 0.85

Calls 3

Adam7_getpassvaluesFunction · 0.85
setBitOfReversedStream0Function · 0.85

Tested by

no test coverage detected