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

Function addColorBits

dependency/densecrf/examples/lodepng.cpp:2981–2990  ·  view source on GitHub ↗

index: bitgroup index, bits: bitgroup size(1, 2 or 4), in: bitgroup value, out: octet array to add bits to*/

Source from the content-addressed store, hash-verified

2979
2980/*index: bitgroup index, bits: bitgroup size(1, 2 or 4), in: bitgroup value, out: octet array to add bits to*/
2981static void addColorBits(unsigned char* out, size_t index, unsigned bits, unsigned in)
2982{
2983 unsigned m = bits == 1 ? 7 : bits == 2 ? 3 : 1; /*8 / bits - 1*/
2984 /*p = the partial index in the byte, e.g. with 4 palettebits it is 0 for first half or 1 for second half*/
2985 unsigned p = index & m;
2986 in &= (1u << bits) - 1u; /*filter out any other bits of the input value*/
2987 in = in << (bits * (m - p));
2988 if(p == 0) out[index * bits / 8] = in;
2989 else out[index * bits / 8] |= in;
2990}
2991
2992typedef struct ColorTree ColorTree;
2993

Callers 1

rgba8ToPixelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected