mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-trx.git
synced 2025-11-20 22:08:07 +00:00
sigProcLib: Use explicit NaN check in sinc table generation
Using "x < 0.01" is a crude check for detecting NaN condition, which occurs in a sinc call when x = 0 due to divide-by-zero. Use stdlib isnan() call for this purpose. Also, as the table is created only once during initialization, use double floats for table value generation. Change-Id: I3a838fe3139fa977dfe906246020a14451185714
This commit is contained in:
@@ -979,16 +979,10 @@ signalVector *modulateBurst(const BitVector &wBurst, int guardPeriodLength,
|
|||||||
|
|
||||||
static void generateSincTable()
|
static void generateSincTable()
|
||||||
{
|
{
|
||||||
float x;
|
|
||||||
|
|
||||||
for (int i = 0; i < TABLESIZE; i++) {
|
for (int i = 0; i < TABLESIZE; i++) {
|
||||||
x = (float) i / TABLESIZE * 8 * M_PI;
|
auto x = (double) i / TABLESIZE * 8 * M_PI;
|
||||||
if (fabs(x) < 0.01) {
|
auto y = sin(x) / x;
|
||||||
sincTable[i] = 1.0f;
|
sincTable[i] = isnan(y) ? 1.0 : y;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
sincTable[i] = sinf(x) / x;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user