[asterisk-commits] markster: branch markster/mfr2 r113008 - in /team/markster/mfr2: channels/ in...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Apr 6 08:56:03 CDT 2008
Author: markster
Date: Sun Apr 6 08:56:02 2008
New Revision: 113008
URL: http://svn.digium.com/view/asterisk?view=rev&rev=113008
Log:
Commit new MFR2 DSP routines for testing...
Modified:
team/markster/mfr2/channels/chan_zap.c
team/markster/mfr2/include/asterisk/dsp.h
team/markster/mfr2/main/dsp.c
Modified: team/markster/mfr2/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/markster/mfr2/channels/chan_zap.c?view=diff&rev=113008&r1=113007&r2=113008
==============================================================================
--- team/markster/mfr2/channels/chan_zap.c (original)
+++ team/markster/mfr2/channels/chan_zap.c Sun Apr 6 08:56:02 2008
@@ -6202,7 +6202,7 @@
/* set digit mode appropriately */
if (p->dsp) {
if (NEED_MFDETECT(p))
- ast_dsp_set_digitmode(p->dsp, DSP_DIGITMODE_MF | p->dtmfrelax);
+ ast_dsp_set_digitmode(p->dsp, DSP_DIGITMODE_MFR1 | p->dtmfrelax);
else
ast_dsp_set_digitmode(p->dsp, DSP_DIGITMODE_DTMF | p->dtmfrelax);
}
@@ -6318,7 +6318,7 @@
return NULL;
}
zt_set_hook(p->subs[SUB_REAL].zfd, ZT_OFFHOOK);
- ast_dsp_set_digitmode(p->dsp, DSP_DIGITMODE_MF | p->dtmfrelax);
+ ast_dsp_set_digitmode(p->dsp, DSP_DIGITMODE_MFR1 | p->dtmfrelax);
res = my_getsigstr(chan, anibuf, "#", 10000);
if ((res > 0) && (strlen(anibuf) > 2)) {
if (anibuf[strlen(anibuf) - 1] == '#')
Modified: team/markster/mfr2/include/asterisk/dsp.h
URL: http://svn.digium.com/view/asterisk/team/markster/mfr2/include/asterisk/dsp.h?view=diff&rev=113008&r1=113007&r2=113008
==============================================================================
--- team/markster/mfr2/include/asterisk/dsp.h (original)
+++ team/markster/mfr2/include/asterisk/dsp.h Sun Apr 6 08:56:02 2008
@@ -28,8 +28,14 @@
#define DSP_FEATURE_DIGIT_DETECT (1 << 3)
#define DSP_FEATURE_FAX_DETECT (1 << 4)
-#define DSP_DIGITMODE_DTMF 0 /*!< Detect DTMF digits */
-#define DSP_DIGITMODE_MF 1 /*!< Detect MF digits */
+
+#define DSP_DIGITMODE_MASK 0x3
+#define DSP_DIGITMODE_DTMF 0x0 /*!< Detect DTMF digits */
+#define DSP_DIGITMODE_MFR1 0x1 /*!< Detect MF digits */
+#define DSP_DIGITMODE_MFR2_FWD 0x2
+/*!< Detect MFR2 Forward */
+#define DSP_DIGITMODE_MFR2_REV 0x3
+/*!< Detect MFR2 Reverse */
#define DSP_DIGITMODE_NOQUELCH (1 << 8) /*!< Do not quelch DTMF from in-band */
#define DSP_DIGITMODE_MUTECONF (1 << 9) /*!< Mute conference */
Modified: team/markster/mfr2/main/dsp.c
URL: http://svn.digium.com/view/asterisk/team/markster/mfr2/main/dsp.c?view=diff&rev=113008&r1=113007&r2=113008
==============================================================================
--- team/markster/mfr2/main/dsp.c (original)
+++ team/markster/mfr2/main/dsp.c Sun Apr 6 08:56:02 2008
@@ -193,8 +193,16 @@
*/
#define SAMPLES_IN_FRAME 160
+#define MFR1_GSIZE 120
+
+#define MFR2_GSIZE 133
+
/* MF goertzel size */
-#define MF_GSIZE 120
+static int mf_gsize[] = {
+ MFR1_GSIZE,
+ MFR2_GSIZE,
+ MFR2_GSIZE
+};
/* DTMF goertzel size */
#define DTMF_GSIZE 102
@@ -203,6 +211,7 @@
#define DTMF_HITS_TO_BEGIN 2
/* How many successive misses needed to consider end of a digit */
#define DTMF_MISSES_TO_END 3
+
#define CONFIG_FILE_NAME "dsp.conf"
@@ -255,6 +264,8 @@
typedef struct
{
goertzel_state_t tone_out[6];
+ int mode;
+ int gsize; /* Size of goertzel */
int current_hit;
int hits[5];
int current_sample;
@@ -283,14 +294,24 @@
1209.0, 1336.0, 1477.0, 1633.0
};
-static float mf_tones[] =
-{
- 700.0, 900.0, 1100.0, 1300.0, 1500.0, 1700.0
+#define MF_MFR1 0
+#define MF_MFR2_FWD 1
+#define MF_MFR2_REV 2
+
+static float mf_tones[][6] =
+{
+ { 700.0, 900.0, 1100.0, 1300.0, 1500.0, 1700.0 },
+ { 1380.0, 1500.0, 1620.0, 1740.0, 1860.0, 1980.0 },
+ { 540.0, 660.0, 780.0, 900.0, 1020.0, 1140.0 },
};
static char dtmf_positions[] = "123A" "456B" "789C" "*0#D";
-static char bell_mf_positions[] = "1247C-358A--69*---0B----#";
+static char *all_mf_positions[] = {
+ "1247C-358A--69*---0B----#", /* Bell */
+ "1247B-358C--69D---AE----F", /* Forward */
+ "FEDCB-A987--654---32----1", /* Reverse */
+};
static int thresholds[THRESHOLD_MAX];
@@ -485,15 +506,20 @@
s->misses_to_end = DTMF_MISSES_TO_END;
}
-static void ast_mf_detect_init (mf_detect_state_t *s)
+static void ast_mf_detect_init (mf_detect_state_t *s, int mode)
{
int i;
+ mode--;
+ if ((mode < 0) || (mode > 2))
+ mode = 0;
+ s->mode = mode;
s->hits[0] = s->hits[1] = s->hits[2] = s->hits[3] = s->hits[4] = 0;
for (i = 0; i < 6; i++) {
- goertzel_init (&s->tone_out[i], mf_tones[i], 160);
+ goertzel_init (&s->tone_out[i], mf_tones[s->mode][i], 160);
}
s->current_sample = 0;
s->current_hit = 0;
+ s->gsize = mf_gsize[s->mode];
}
static void ast_digit_detect_init(digit_detect_state_t *s, int mf)
@@ -504,7 +530,7 @@
s->digits[0] = '\0';
if (mf)
- ast_mf_detect_init(&s->td.mf);
+ ast_mf_detect_init(&s->td.mf, mf);
else
ast_dtmf_detect_init(&s->td.dtmf);
}
@@ -793,8 +819,8 @@
for (sample = 0; sample < samples; sample = limit) {
/* 80 is optimised to meet the MF specs. */
/* XXX So then why is MF_GSIZE defined as 120? */
- if ((samples - sample) >= (MF_GSIZE - s->td.mf.current_sample))
- limit = sample + (MF_GSIZE - s->td.mf.current_sample);
+ if ((samples - sample) >= (s->td.mf.gsize - s->td.mf.current_sample))
+ limit = sample + (s->td.mf.gsize - s->td.mf.current_sample);
else
limit = samples;
/* The following unrolled loop takes only 35% (rough estimate) of the
@@ -811,7 +837,7 @@
goertzel_sample(s->td.mf.tone_out + 5, amp[j]);
}
s->td.mf.current_sample += (limit - sample);
- if (s->td.mf.current_sample < MF_GSIZE) {
+ if (s->td.mf.current_sample < s->td.mf.gsize) {
continue;
}
/* We're at the end of an MF detection block. */
@@ -865,7 +891,7 @@
second_best = i;
}
best = best*5 + second_best - 1;
- hit = bell_mf_positions[best];
+ hit = all_mf_positions[s->td.mf.mode][best];
/* Look for two successive similar results */
/* The logic in the next test is:
For KP we need 4 successive identical clean detects, with
@@ -894,12 +920,12 @@
/* If we had a hit in this block, include it into mute fragment */
if (squelch && hit) {
- if (mute.end < sample - MF_GSIZE) {
+ if (mute.end < sample - s->td.mf.gsize) {
/* There is a gap between fragments */
mute_fragment(dsp, &mute);
- mute.start = (sample > MF_GSIZE) ? (sample - MF_GSIZE) : 0;
- }
- mute.end = limit + DTMF_GSIZE;
+ mute.start = (sample > s->td.mf.gsize) ? (sample - s->td.mf.gsize) : 0;
+ }
+ mute.end = limit + s->td.mf.gsize;
}
/* Reinitialise the detector for the next block */
@@ -1333,7 +1359,7 @@
}
if ((dsp->features & DSP_FEATURE_DIGIT_DETECT)) {
- if ((dsp->digitmode & DSP_DIGITMODE_MF))
+ if ((dsp->digitmode & DSP_DIGITMODE_MASK))
digit = mf_detect(dsp, &dsp->digit_state, shortdata, len, (dsp->digitmode & DSP_DIGITMODE_NOQUELCH) == 0, (dsp->digitmode & DSP_DIGITMODE_RELAXDTMF));
else
digit = dtmf_detect(dsp, &dsp->digit_state, shortdata, len, (dsp->digitmode & DSP_DIGITMODE_NOQUELCH) == 0, (dsp->digitmode & DSP_DIGITMODE_RELAXDTMF));
@@ -1458,7 +1484,7 @@
dsp->digitmode = DSP_DIGITMODE_DTMF;
dsp->faxmode = DSP_FAXMODE_DETECT_CNG;
/* Initialize digit detector */
- ast_digit_detect_init(&dsp->digit_state, dsp->digitmode & DSP_DIGITMODE_MF);
+ ast_digit_detect_init(&dsp->digit_state, dsp->digitmode & DSP_DIGITMODE_MASK);
/* Initialize initial DSP progress detect parameters */
ast_dsp_prog_reset(dsp);
/* Initialize fax detector */
@@ -1503,7 +1529,7 @@
int i;
dsp->dtmf_began = 0;
- if (dsp->digitmode & DSP_DIGITMODE_MF) {
+ if (dsp->digitmode & DSP_DIGITMODE_MASK) {
mf_detect_state_t *s = &dsp->digit_state.td.mf;
/* Reinitialise the detector for the next block */
for (i = 0; i < 6; i++) {
@@ -1547,11 +1573,11 @@
int new;
int old;
- old = dsp->digitmode & (DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MF | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX);
- new = digitmode & (DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MF | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX);
+ old = dsp->digitmode & (DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MASK | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX);
+ new = digitmode & (DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MASK | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX);
if (old != new) {
/* Must initialize structures if switching from MF to DTMF or vice-versa */
- ast_digit_detect_init(&dsp->digit_state, new & DSP_DIGITMODE_MF);
+ ast_digit_detect_init(&dsp->digit_state, new & DSP_DIGITMODE_MASK);
}
dsp->digitmode = digitmode;
return 0;
More information about the asterisk-commits
mailing list