MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / stbi__clamp

Function stbi__clamp

lite/example/cpp_example/mge/cv/stb_image.h:2564–2573  ·  view source on GitHub ↗

take a -128..127 value and stbi__clamp it and convert to 0..255

Source from the content-addressed store, hash-verified

2562
2563// take a -128..127 value and stbi__clamp it and convert to 0..255
2564stbi_inline static stbi_uc stbi__clamp(int x) {
2565 // trick to use a single test to catch both cases
2566 if ((unsigned int)x > 255) {
2567 if (x < 0)
2568 return 0;
2569 if (x > 255)
2570 return 255;
2571 }
2572 return (stbi_uc)x;
2573}
2574
2575#define stbi__f2f(x) ((int)(((x)*4096 + 0.5)))
2576#define stbi__fsh(x) ((x)*4096)

Callers 1

stbi__idct_blockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected