MCPcopy Create free account
hub / github.com/assaultcube/AC / encodepitch

Function encodepitch

source/src/protocol.cpp:547–557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

545}
546
547int encodepitch(float p) // pitch value quantisation: use double resolution for -30°..30° and half resolution for -90°..-30° and 30°..90°
548{
549 const int thres = (1 << 24) / 3;
550 int r = (int)(p * (1 << 24)) / MAXPITCH;
551 if(r > thres) r = r / 4 + (1 << 22);
552 else if(r < -thres) r = r / 4 - (1 << 22);
553 r += (1 << 23) + (1 << (23 - PITCHBITS));
554 if(r < 0) r = 0;
555 else if(r >= (1 << 24)) r = (1 << 24) - 1;
556 return r >> (24 - PITCHBITS);
557}
558
559float decodepitch(int r)
560{

Callers 1

c2sinfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected