MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / B44ShiftAndRound

Function B44ShiftAndRound

Source/ThirdParty/tinyexr.h:4337–4345  ·  view source on GitHub ↗

Shift and round for B44 pack (matches OpenEXR's shiftAndRound)

Source from the content-addressed store, hash-verified

4335
4336// Shift and round for B44 pack (matches OpenEXR's shiftAndRound)
4337static inline int B44ShiftAndRound(int x, int shift) {
4338 // Compute y = x * pow(2, -shift), rounded to nearest integer
4339 // In case of a tie, round to the even one
4340 x <<= 1;
4341 int a = (1 << shift) - 1;
4342 shift += 1;
4343 int b = (x >> shift) & 1;
4344 return (x + a + b) >> shift;
4345}
4346
4347// Pack a 4x4 block of HALF values into 14 bytes (matches OpenEXR's pack())
4348// Returns the number of bytes written (14 for normal, 3 for flat if flatfields=true)

Callers 1

PackB44BlockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected