mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-14 05:18:31 +00:00
Updated SpanDSP to snapshot on 2009-06-03 with some additions:
Fixed VS2005 version of make_modem_filter Fixed a couple of places where declaration and definition of functions do not have the same calling conventions. Only relevant for Win32 compiles. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13831 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
832bab2a4a
commit
e791f33545
131 files changed
+8988
-2017
No files matched your search
+76
-66
@@ -23,7 +23,7 @@
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: v29rx.c,v 1.164 2009/04/21 13:59:07 steveu Exp $
|
||||
* $Id: v29rx.c,v 1.166 2009/06/02 16:03:56 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -841,12 +841,82 @@ static void process_half_baud(v29_rx_state_t *s, complexf_t *sample)
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static __inline__ int signal_detect(v29_rx_state_t *s, int16_t amp)
|
||||
{
|
||||
int16_t diff;
|
||||
int16_t x;
|
||||
int32_t power;
|
||||
|
||||
/* There should be no DC in the signal, but sometimes there is.
|
||||
We need to measure the power with the DC blocked, but not using
|
||||
a slow to respond DC blocker. Use the most elementary HPF. */
|
||||
x = amp >> 1;
|
||||
/* There could be overflow here, but it isn't a problem in practice */
|
||||
diff = x - s->last_sample;
|
||||
s->last_sample = x;
|
||||
power = power_meter_update(&(s->power), diff);
|
||||
#if defined(IAXMODEM_STUFF)
|
||||
/* Quick power drop fudge */
|
||||
diff = abs(diff);
|
||||
if (10*diff < s->high_sample)
|
||||
{
|
||||
if (++s->low_samples > 120)
|
||||
{
|
||||
power_meter_init(&(s->power), 4);
|
||||
s->high_sample = 0;
|
||||
s->low_samples = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s->low_samples = 0;
|
||||
if (diff > s->high_sample)
|
||||
s->high_sample = diff;
|
||||
}
|
||||
#endif
|
||||
if (s->signal_present > 0)
|
||||
{
|
||||
/* Look for power below turn-off threshold to turn the carrier off */
|
||||
#if defined(IAXMODEM_STUFF)
|
||||
if (s->carrier_drop_pending || power < s->carrier_off_power)
|
||||
#else
|
||||
if (power < s->carrier_off_power)
|
||||
#endif
|
||||
{
|
||||
if (--s->signal_present <= 0)
|
||||
{
|
||||
/* Count down a short delay, to ensure we push the last
|
||||
few bits through the filters before stopping. */
|
||||
v29_rx_restart(s, s->bit_rate, FALSE);
|
||||
report_status_change(s, SIG_STATUS_CARRIER_DOWN);
|
||||
return 0;
|
||||
}
|
||||
#if defined(IAXMODEM_STUFF)
|
||||
/* Carrier has dropped, but the put_bit is
|
||||
pending the signal_present delay. */
|
||||
s->carrier_drop_pending = TRUE;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Look for power exceeding turn-on threshold to turn the carrier on */
|
||||
if (power < s->carrier_on_power)
|
||||
return 0;
|
||||
s->signal_present = 1;
|
||||
#if defined(IAXMODEM_STUFF)
|
||||
s->carrier_drop_pending = FALSE;
|
||||
#endif
|
||||
report_status_change(s, SIG_STATUS_CARRIER_UP);
|
||||
}
|
||||
return power;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
SPAN_DECLARE_NONSTD(int) v29_rx(v29_rx_state_t *s, const int16_t amp[], int len)
|
||||
{
|
||||
int i;
|
||||
int step;
|
||||
int16_t x;
|
||||
int16_t diff;
|
||||
#if defined(SPANDSP_USE_FIXED_POINT)
|
||||
complexi16_t z;
|
||||
complexi16_t zz;
|
||||
@@ -866,68 +936,8 @@ SPAN_DECLARE_NONSTD(int) v29_rx(v29_rx_state_t *s, const int16_t amp[], int len)
|
||||
if (++s->rrc_filter_step >= V29_RX_FILTER_STEPS)
|
||||
s->rrc_filter_step = 0;
|
||||
|
||||
/* There should be no DC in the signal, but sometimes there is.
|
||||
We need to measure the power with the DC blocked, but not using
|
||||
a slow to respond DC blocker. Use the most elementary HPF. */
|
||||
x = amp[i] >> 1;
|
||||
/* There could be overflow here, but it isn't a problem in practice */
|
||||
diff = x - s->last_sample;
|
||||
power = power_meter_update(&(s->power), diff);
|
||||
#if defined(IAXMODEM_STUFF)
|
||||
/* Quick power drop fudge */
|
||||
diff = abs(diff);
|
||||
if (10*diff < s->high_sample)
|
||||
{
|
||||
if (++s->low_samples > 120)
|
||||
{
|
||||
power_meter_init(&(s->power), 4);
|
||||
s->high_sample = 0;
|
||||
s->low_samples = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s->low_samples = 0;
|
||||
if (diff > s->high_sample)
|
||||
s->high_sample = diff;
|
||||
}
|
||||
#endif
|
||||
s->last_sample = x;
|
||||
if (s->signal_present)
|
||||
{
|
||||
/* Look for power below turn-off threshold to turn the carrier off */
|
||||
#if defined(IAXMODEM_STUFF)
|
||||
if (s->carrier_drop_pending || power < s->carrier_off_power)
|
||||
#else
|
||||
if (power < s->carrier_off_power)
|
||||
#endif
|
||||
{
|
||||
if (--s->signal_present <= 0)
|
||||
{
|
||||
/* Count down a short delay, to ensure we push the last
|
||||
few bits through the filters before stopping. */
|
||||
v29_rx_restart(s, s->bit_rate, FALSE);
|
||||
report_status_change(s, SIG_STATUS_CARRIER_DOWN);
|
||||
continue;
|
||||
}
|
||||
#if defined(IAXMODEM_STUFF)
|
||||
/* Carrier has dropped, but the put_bit is
|
||||
pending the signal_present delay. */
|
||||
s->carrier_drop_pending = TRUE;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Look for power exceeding turn-on threshold to turn the carrier on */
|
||||
if (power < s->carrier_on_power)
|
||||
continue;
|
||||
s->signal_present = 1;
|
||||
#if defined(IAXMODEM_STUFF)
|
||||
s->carrier_drop_pending = FALSE;
|
||||
#endif
|
||||
report_status_change(s, SIG_STATUS_CARRIER_UP);
|
||||
}
|
||||
if ((power = signal_detect(s, amp[i])) == 0)
|
||||
continue;
|
||||
if (s->training_stage == TRAINING_STAGE_PARKED)
|
||||
continue;
|
||||
/* Only spend effort processing this data if the modem is not
|
||||
@@ -1018,7 +1028,7 @@ SPAN_DECLARE(int) v29_rx_fillin(v29_rx_state_t *s, int len)
|
||||
/* We want to sustain the current state (i.e carrier on<->carrier off), and
|
||||
try to sustain the carrier phase. We should probably push the filters, as well */
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Fill-in %d samples\n", len);
|
||||
if (!s->signal_present)
|
||||
if (s->signal_present <= 0)
|
||||
return 0;
|
||||
if (s->training_stage == TRAINING_STAGE_PARKED)
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user