if (n == 0 || x == 1)
return 1;
if (x != -1)
- return (x == 0) ? 1/x : 0;
+ return (x != 0) ? 1/x : 0;
n = -n;
}
u = n;
complexf_t sample;
float v;
#endif
+ int32_t root_power;
int32_t power;
for (i = 0; i < len; i++)
{
/* Only AGC until we have locked down the setting. */
if (s->agc_scaling_save == FP_SCALE(0.0f))
+ {
+ if ((root_power = fixed_sqrt32(power)) == 0)
+ root_power = 1;
#if defined(SPANDSP_USE_FIXED_POINTx)
- s->agc_scaling = saturate16(((int32_t) (FP_SCALE(2.17f)*1024.0f))/fixed_sqrt32(power));
+ s->agc_scaling = saturate16(((int32_t) (FP_SCALE(2.17f)*1024.0f))/root_power);
#else
- s->agc_scaling = (FP_SCALE(2.17f)/RX_PULSESHAPER_GAIN)/sqrtf(power);
+ s->agc_scaling = (FP_SCALE(2.17f)/RX_PULSESHAPER_GAIN)/root_power;
#endif
+ }
/* Pulse shape while still at the carrier frequency, using a quadrature
pair of filters. This results in a properly bandpass filtered complex
signal, which can be brought directly to baseband by complex mixing.
float ii;
float qq;
#endif
+ int32_t root_power;
int32_t power;
for (i = 0; i < len; i++)
if (s->rx.training == V22BIS_RX_TRAINING_STAGE_SYMBOL_ACQUISITION)
{
/* Only AGC during the initial symbol acquisition, and then lock the gain. */
+ if ((root_power = fixed_sqrt32(power)) == 0)
+ root_power = 1;
#if defined(SPANDSP_USE_FIXED_POINT)
- s->rx.agc_scaling = saturate16(((int32_t) (FP_SCALE(0.18f)*FP_SCALE(3.60f)))/fixed_sqrt32(power));
+ s->rx.agc_scaling = saturate16(((int32_t) (FP_SCALE(0.18f)*FP_SCALE(3.60f)))/root_power);
#else
- s->rx.agc_scaling = FP_SCALE(0.18f)*FP_SCALE(3.60f)/fixed_sqrt32(power);
+ s->rx.agc_scaling = FP_SCALE(0.18f)*FP_SCALE(3.60f)/root_power;
#endif
}
/* Pulse shape while still at the carrier frequency, using a quadrature
complexf_t sample;
float v;
#endif
+ int32_t root_power;
int32_t power;
if (s->bit_rate == 4800)
if (s->training_stage == TRAINING_STAGE_SYMBOL_ACQUISITION)
{
/* Only AGC during the initial training */
+ if ((root_power = fixed_sqrt32(power)) == 0)
+ root_power = 1;
#if defined(SPANDSP_USE_FIXED_POINT)
- s->agc_scaling = saturate16(((int32_t) (FP_SCALE(1.414f)*1024.0f))/fixed_sqrt32(power));
+ s->agc_scaling = saturate16(((int32_t) (FP_SCALE(1.414f)*1024.0f))/root_power);
#else
- s->agc_scaling = (FP_SCALE(1.414f)/RX_PULSESHAPER_4800_GAIN)/fixed_sqrt32(power);
+ s->agc_scaling = (FP_SCALE(1.414f)/RX_PULSESHAPER_4800_GAIN)/root_power;
#endif
}
/* Pulse shape while still at the carrier frequency, using a quadrature
if (s->training_stage == TRAINING_STAGE_SYMBOL_ACQUISITION)
{
/* Only AGC during the initial training */
+ if ((root_power = fixed_sqrt32(power)) == 0)
+ root_power = 1;
#if defined(SPANDSP_USE_FIXED_POINT)
- s->agc_scaling = saturate16(((int32_t) (FP_SCALE(1.414f)*1024.0f))/fixed_sqrt32(power));
+ s->agc_scaling = saturate16(((int32_t) (FP_SCALE(1.414f)*1024.0f))/root_power);
#else
- s->agc_scaling = (FP_SCALE(1.414f)/RX_PULSESHAPER_2400_GAIN)/fixed_sqrt32(power);
+ s->agc_scaling = (FP_SCALE(1.414f)/RX_PULSESHAPER_2400_GAIN)/root_power;
#endif
}
/* Pulse shape while still at the carrier frequency, using a quadrature
complexf_t sample;
float v;
#endif
+ int32_t root_power;
int32_t power;
for (i = 0; i < len; i++)
/* Only AGC until we have locked down the setting. */
if (s->agc_scaling_save == FP_SCALE(0.0f))
{
+ if ((root_power = fixed_sqrt32(power)) == 0)
+ root_power = 1;
#if defined(SPANDSP_USE_FIXED_POINT)
- s->agc_scaling = saturate16(((int32_t) (FP_SCALE(1.25f)*1024.0f))/fixed_sqrt32(power));
+ s->agc_scaling = saturate16(((int32_t) (FP_SCALE(1.25f)*1024.0f))/root_power);
#else
- s->agc_scaling = (FP_SCALE(1.25f)/RX_PULSESHAPER_GAIN)/fixed_sqrt32(power);
+ s->agc_scaling = (FP_SCALE(1.25f)/RX_PULSESHAPER_GAIN)/root_power;
#endif
}
/* Pulse shape while still at the carrier frequency, using a quadrature