MCPcopy Create free account
hub / github.com/DFHack/dfhack / paethPredictor

Function paethPredictor

depends/lodepng/lodepng.cpp:3974–3981  ·  view source on GitHub ↗

Paeth predictor, used by PNG filter type 4 The parameters are of type short, but should come from unsigned chars, the shorts are only needed to make the paeth calculation correct. */

Source from the content-addressed store, hash-verified

3972are only needed to make the paeth calculation correct.
3973*/
3974static unsigned char paethPredictor(short a, short b, short c) {
3975 short pa = LODEPNG_ABS(b - c);
3976 short pb = LODEPNG_ABS(a - c);
3977 short pc = LODEPNG_ABS(a + b - c - c);
3978 /* return input value associated with smallest of pa, pb, pc (with certain priority if equal) */
3979 if(pb < pa) { a = b; pa = pb; }
3980 return (pc < pa) ? c : a;
3981}
3982
3983/*shared values used by multiple Adam7 related functions*/
3984

Callers 2

unfilterScanlineFunction · 0.85
filterScanlineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected