#include "look1_iu8lu16n16tu16_binlcase.h" #include "rtwtypes.h" uint16_T look1_iu8lu16n16tu16_binlcase(uint8_T u0, const uint8_T bp0[], const uint16_T table[], uint32_T maxIndex) { uint32_T iLeft; uint16_T frac; uint16_T y; if (u0 <= bp0[0U]) { iLeft = 0U; frac = 0U; } else if (u0 < bp0[maxIndex]) { uint32_T bpIdx; uint32_T iRght; bpIdx = maxIndex >> 1U; iLeft = 0U; iRght = maxIndex; while (iRght - iLeft > 1U) { if (u0 < bp0[bpIdx]) { iRght = bpIdx; } else { iLeft = bpIdx; } bpIdx = (iRght + iLeft) >> 1U; } uint8_T bpLeftVar; bpLeftVar = bp0[iLeft]; frac = (uint16_T)(((uint32_T)(uint8_T)((uint32_T)u0 - bpLeftVar) << 16) / (uint8_T)((uint32_T)bp0[iLeft + 1U] - bpLeftVar)); } else { iLeft = maxIndex; frac = 0U; } if (iLeft == maxIndex) { y = table[iLeft]; } else { uint16_T yL_0d0; uint16_T yR_0d0; yR_0d0 = table[iLeft + 1U]; yL_0d0 = table[iLeft]; if (yR_0d0 >= yL_0d0) { y = (uint16_T)((uint32_T)(uint16_T)(((uint32_T)(uint16_T)((uint32_T)yR_0d0 - yL_0d0) * frac) >> 16) + yL_0d0); } else { y = (uint16_T)((uint32_T)yL_0d0 - (uint16_T)(((uint32_T)(uint16_T) ((uint32_T)yL_0d0 - yR_0d0) * frac) >> 16)); } } return y; }