Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
libfsst::Counters Struct Reference

Public Member Functions

void count1Set (u32 pos1, u16 val)
void count1Inc (u32 pos1)
void count2Inc (u32 pos1, u32 pos2)
u32 count1GetNext (u32 &pos1)
u32 count2GetNext (u32 pos1, u32 &pos2)
void backup1 (u8 *buf)
void restore1 (u8 *buf)

Public Attributes

u8 count1High [FSST_CODE_MAX]
u8 count1Low [FSST_CODE_MAX]
u8 count2High [FSST_CODE_MAX][FSST_CODE_MAX/2]
u8 count2Low [FSST_CODE_MAX][FSST_CODE_MAX]

Member Function Documentation

◆ count1Set()

void libfsst::Counters::count1Set ( u32 pos1,
u16 val )
inline
450707 {
450708 count1Low[pos1] = val&255;
450709 count1High[pos1] = val>>8;
450710 }

◆ count1Inc()

void libfsst::Counters::count1Inc ( u32 pos1)
inline
450711 {
450712 if (!count1Low[pos1]++) // increment high early (when low==0, not when low==255). This means (high > 0) <=> (cnt > 0)
450713 count1High[pos1]++; //(0,0)->(1,1)->..->(255,1)->(0,1)->(1,2)->(2,2)->(3,2)..(255,2)->(0,2)->(1,3)->(2,3)...
450714 }

◆ count2Inc()

void libfsst::Counters::count2Inc ( u32 pos1,
u32 pos2 )
inline
450715 {
450716 if (!count2Low[pos1][pos2]++) // increment high early (when low==0, not when low==255). This means (high > 0) <=> (cnt > 0)
450717 // inc 4-bits high counter with 1<<0 (1) or 1<<4 (16) -- depending on whether pos2 is even or odd, repectively
450718 count2High[pos1][(pos2)>>1] += 1 << (((pos2)&1)<<2); // we take our chances with overflow.. (4K maxval, on a 8K sample)
450719 }

◆ count1GetNext()

u32 libfsst::Counters::count1GetNext ( u32 & pos1)
inline
450720 { // note: we will advance pos1 to the next nonzero counter in register range
450721 // read 16-bits single symbol counter, split into two 8-bits numbers (count1Low, count1High), while skipping over zeros
450722 u64 high = fsst_unaligned_load(&count1High[pos1]); // note: this reads 8 subsequent counters [pos1..pos1+7]
450723
450724 u32 zero = high?(__builtin_ctzll(high)>>3):7UL; // number of zero bytes
450725 high = (high >> (zero << 3)) & 255; // advance to nonzero counter
450726 if (((pos1 += zero) >= FSST_CODE_MAX) || !high) // SKIP! advance pos2
450727 return 0; // all zero
450728
450729 u32 low = count1Low[pos1];
450730 if (low) high--; // high is incremented early and low late, so decrement high (unless low==0)
450731 return (u32) ((high << 8) + low);
450732 }
static softfloat zero()

◆ count2GetNext()

u32 libfsst::Counters::count2GetNext ( u32 pos1,
u32 & pos2 )
inline
450733 { // note: we will advance pos2 to the next nonzero counter in register range
450734 // read 12-bits pairwise symbol counter, split into low 8-bits and high 4-bits number while skipping over zeros
450735 u64 high = fsst_unaligned_load(&count2High[pos1][pos2>>1]); // note: this reads 16 subsequent counters [pos2..pos2+15]
450736 high >>= ((pos2&1) << 2); // odd pos2: ignore the lowest 4 bits & we see only 15 counters
450737
450738 u32 zero = high?(__builtin_ctzll(high)>>2):(15UL-(pos2&1UL)); // number of zero 4-bits counters
450739 high = (high >> (zero << 2)) & 15; // advance to nonzero counter
450740 if (((pos2 += zero) >= FSST_CODE_MAX) || !high) // SKIP! advance pos2
450741 return 0UL; // all zero
450742
450743 u32 low = count2Low[pos1][pos2];
450744 if (low) high--; // high is incremented early and low late, so decrement high (unless low==0)
450745 return (u32) ((high << 8) + low);
450746 }

◆ backup1()

void libfsst::Counters::backup1 ( u8 * buf)
inline
450747 {
450748 memcpy(buf, count1High, FSST_CODE_MAX);
450749 memcpy(buf+FSST_CODE_MAX, count1Low, FSST_CODE_MAX);
450750 }

◆ restore1()

void libfsst::Counters::restore1 ( u8 * buf)
inline
450751 {
450752 memcpy(count1High, buf, FSST_CODE_MAX);
450753 memcpy(count1Low, buf+FSST_CODE_MAX, FSST_CODE_MAX);
450754 }

The documentation for this struct was generated from the following file: