floatTolin.h
Go to the documentation of this file.
1 #ifndef FLOAT_TO_LIN_H
2 #define FLOAT_TO_LIN_H
3 
4 static const uint16_t CNT = 2048;
5 
6 static int16_t lookup[CNT] = {0};
7 
8 static int16_t getRange(uint16_t idx) {
9 
10  bool neg = false;
11  if (idx > (CNT / 2)) {
12  idx = idx - (CNT / 2);
13  neg = true;
14  }
15 
16  int16_t value = 0;
17  if (idx < 256)
18  value = idx;
19  else if (idx < 384)
20  value = ((idx - 256) << 1) + 256;
21  else if (idx < 512)
22  value = ((idx - 384) << 2) + 512;
23  else if (idx < 640)
24  value = ((idx - 512) << 3) + 1024;
25  else if (idx < 768)
26  value = ((idx - 640) << 4) + 2048;
27  else if (idx < 896)
28  value = ((idx - 768) << 5) + 4096;
29  else if (idx < 1024)
30  value = ((idx - 896) << 6) + 8192;
31  else if (idx == 1024)
32  value = 32767;
33 
34  if (neg == true)
35  value = -value;
36 
37  return value;
38 }
39 
41  for (uint16_t idx = 0; idx < CNT; idx++) {
42  lookup[idx] = getRange(idx);
43  }
44 }
45 
47  return ((input < 2048) ? lookup[input] : 0);
48 }
49 
50 #endif //FLOAT_TO_LIN_H
lookup
static int16_t lookup[CNT]
Definition: floatTolin.h:6
input
std::string input
Definition: tokenizer_unittest.cc:197
getRange
static int16_t getRange(uint16_t idx)
Definition: floatTolin.h:8
idx
static uint32_t idx(tarjan *t, const upb_refcounted *r)
Definition: ruby/ext/google/protobuf_c/upb.c:5925
FloatToLinGenerateTable
void FloatToLinGenerateTable()
Definition: floatTolin.h:40
CNT
static const uint16_t CNT
Definition: floatTolin.h:4
value
GLsizei const GLfloat * value
Definition: glcorearb.h:3093
Convert11bitFloat2LinearVal
int16_t Convert11bitFloat2LinearVal(uint16_t input)
Definition: floatTolin.h:46


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:51