MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / unfilter

Function unfilter

dependency/densecrf/examples/lodepng.cpp:4037–4066  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4035}
4036
4037static unsigned unfilter(unsigned char* out, const unsigned char* in, unsigned w, unsigned h, unsigned bpp)
4038{
4039 /*
4040 For PNG filter method 0
4041 this function unfilters a single image (e.g. without interlacing this is called once, with Adam7 seven times)
4042 out must have enough bytes allocated already, in must have the scanlines + 1 filtertype byte per scanline
4043 w and h are image dimensions or dimensions of reduced image, bpp is bits per pixel
4044 in and out are allowed to be the same memory address (but aren't the same size since in has the extra filter bytes)
4045 */
4046
4047 unsigned y;
4048 unsigned char* prevline = 0;
4049
4050 /*bytewidth is used for filtering, is 1 when bpp < 8, number of bytes per pixel otherwise*/
4051 size_t bytewidth = (bpp + 7) / 8;
4052 size_t linebytes = (w * bpp + 7) / 8;
4053
4054 for(y = 0; y < h; ++y)
4055 {
4056 size_t outindex = linebytes * y;
4057 size_t inindex = (1 + linebytes) * y; /*the extra filterbyte added to each row*/
4058 unsigned char filterType = in[inindex];
4059
4060 CERROR_TRY_RETURN(unfilterScanline(&out[outindex], &in[inindex + 1], prevline, bytewidth, filterType, linebytes));
4061
4062 prevline = &out[outindex];
4063 }
4064
4065 return 0;
4066}
4067
4068/*
4069 in: Adam7 interlaced image, with no padding bits between scanlines, but between

Callers 1

postProcessScanlinesFunction · 0.85

Calls 1

unfilterScanlineFunction · 0.85

Tested by

no test coverage detected