[asterisk-commits] moy: branch moy/mfcr2 r157236 - in /team/moy/mfcr2: channels/ include/asteris...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Nov 16 20:41:24 CST 2008


Author: moy
Date: Sun Nov 16 20:41:23 2008
New Revision: 157236

URL: http://svn.digium.com/view/asterisk?view=rev&rev=157236
Log:
removed unused code from main/dsp.c for MFR2 tone detection

Modified:
    team/moy/mfcr2/channels/chan_dahdi.c
    team/moy/mfcr2/include/asterisk/dsp.h
    team/moy/mfcr2/main/dsp.c

Modified: team/moy/mfcr2/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/team/moy/mfcr2/channels/chan_dahdi.c?view=diff&rev=157236&r1=157235&r2=157236
==============================================================================
--- team/moy/mfcr2/channels/chan_dahdi.c (original)
+++ team/moy/mfcr2/channels/chan_dahdi.c Sun Nov 16 20:41:23 2008
@@ -6987,7 +6987,7 @@
 		/* set digit mode appropriately */
 		if (p->dsp) {
 			if (NEED_MFDETECT(p))
-				ast_dsp_set_digitmode(p->dsp, DSP_DIGITMODE_MFR1 | p->dtmfrelax); 
+				ast_dsp_set_digitmode(p->dsp, DSP_DIGITMODE_MF | p->dtmfrelax); 
 			else 
 				ast_dsp_set_digitmode(p->dsp, DSP_DIGITMODE_DTMF | p->dtmfrelax);
 		}
@@ -7103,7 +7103,7 @@
 	                        goto quit;
 			}
                         dahdi_set_hook(p->subs[SUB_REAL].dfd, DAHDI_OFFHOOK);
-                        ast_dsp_set_digitmode(p->dsp, DSP_DIGITMODE_MFR1 | p->dtmfrelax);
+                        ast_dsp_set_digitmode(p->dsp, DSP_DIGITMODE_MF | p->dtmfrelax);
                         res = my_getsigstr(chan, anibuf, "#", 10000);
                         if ((res > 0) && (strlen(anibuf) > 2)) {
 				if (anibuf[strlen(anibuf) - 1] == '#')

Modified: team/moy/mfcr2/include/asterisk/dsp.h
URL: http://svn.digium.com/view/asterisk/team/moy/mfcr2/include/asterisk/dsp.h?view=diff&rev=157236&r1=157235&r2=157236
==============================================================================
--- team/moy/mfcr2/include/asterisk/dsp.h (original)
+++ team/moy/mfcr2/include/asterisk/dsp.h Sun Nov 16 20:41:23 2008
@@ -28,14 +28,8 @@
 #define DSP_FEATURE_DIGIT_DETECT	(1 << 3)
 #define DSP_FEATURE_FAX_DETECT		(1 << 4)
 
-
-#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_DTMF			0				/*!< Detect DTMF digits */
+#define DSP_DIGITMODE_MF			1				/*!< Detect MF digits */
 
 #define DSP_DIGITMODE_NOQUELCH		(1 << 8)		/*!< Do not quelch DTMF from in-band */
 #define DSP_DIGITMODE_MUTECONF		(1 << 9)		/*!< Mute conference */

Modified: team/moy/mfcr2/main/dsp.c
URL: http://svn.digium.com/view/asterisk/team/moy/mfcr2/main/dsp.c?view=diff&rev=157236&r1=157235&r2=157236
==============================================================================
--- team/moy/mfcr2/main/dsp.c (original)
+++ team/moy/mfcr2/main/dsp.c Sun Nov 16 20:41:23 2008
@@ -193,16 +193,8 @@
  */
 #define SAMPLES_IN_FRAME	160
 
-#define MFR1_GSIZE		120
-
-#define MFR2_GSIZE		133
-
 /* MF goertzel size */
-static int mf_gsize[] = {
-	MFR1_GSIZE,
-	MFR2_GSIZE,
-	MFR2_GSIZE
-};
+#define MF_GSIZE		120
 
 /* DTMF goertzel size */
 #define DTMF_GSIZE		102
@@ -211,7 +203,6 @@
 #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"
 
@@ -264,8 +255,6 @@
 typedef struct
 {
 	goertzel_state_t tone_out[6];
-	int mode;
-	int gsize; /* Size of goertzel */
 	int current_hit;
 	int hits[5];
 	int current_sample;
@@ -294,24 +283,14 @@
 	1209.0, 1336.0, 1477.0, 1633.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 float mf_tones[] =
+{
+	700.0, 900.0, 1100.0, 1300.0, 1500.0, 1700.0
 };
 
 static char dtmf_positions[] = "123A" "456B" "789C" "*0#D";
 
-static char *all_mf_positions[] = {
-	"1247C-358A--69*---0B----#", /* Bell */
-	"1247B-358C--69D---AE----F", /* Forward */
-	"FEDCB-A987--654---32----1", /* Reverse */
-};
+static char bell_mf_positions[] = "1247C-358A--69*---0B----#";
 
 static int thresholds[THRESHOLD_MAX];
 
@@ -507,20 +486,15 @@
 	s->misses_to_end = DTMF_MISSES_TO_END;
 }
 
-static void ast_mf_detect_init (mf_detect_state_t *s, int mode)
+static void ast_mf_detect_init (mf_detect_state_t *s)
 {
 	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[s->mode][i], 160);
+		goertzel_init (&s->tone_out[i], mf_tones[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)
@@ -531,7 +505,7 @@
 	s->digits[0] = '\0';
 
 	if (mf)
-		ast_mf_detect_init(&s->td.mf, mf);
+		ast_mf_detect_init(&s->td.mf);
 	else
 		ast_dtmf_detect_init(&s->td.dtmf);
 }
@@ -819,8 +793,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) >= (s->td.mf.gsize - s->td.mf.current_sample))
-			limit = sample + (s->td.mf.gsize - s->td.mf.current_sample);
+		if ((samples - sample) >= (MF_GSIZE - s->td.mf.current_sample))
+			limit = sample + (MF_GSIZE - s->td.mf.current_sample);
 		else
 			limit = samples;
 		/* The following unrolled loop takes only 35% (rough estimate) of the 
@@ -837,7 +811,7 @@
 			goertzel_sample(s->td.mf.tone_out + 5, amp[j]);
 		}
 		s->td.mf.current_sample += (limit - sample);
-		if (s->td.mf.current_sample < s->td.mf.gsize) {
+		if (s->td.mf.current_sample < MF_GSIZE) {
 			continue;
 		}
 		/* We're at the end of an MF detection block.  */
@@ -891,24 +865,18 @@
 				second_best = i;
 			}
 			best = best*5 + second_best - 1;
-			hit = all_mf_positions[s->td.mf.mode][best];
+			hit = bell_mf_positions[best];
 			/* Look for two successive similar results */
-			if (s->td.mf.mode) {
-				if (hit == s->td.mf.hits[4] && hit != s->td.mf.hits[3] && hit != s->td.mf.hits[2]) {
-					store_digit(s, hit);
-				}
-			} else {
-				/* The logic in the next test is:
-				   For KP we need 4 successive identical clean detects, with
-				   two blocks of something different preceeding it. For anything
-				   else we need two successive identical clean detects, with
-				   two blocks of something different preceeding it. */
-				if (hit == s->td.mf.hits[4] && hit == s->td.mf.hits[3] &&
-				   ((hit != '*' && hit != s->td.mf.hits[2] && hit != s->td.mf.hits[1])||
-				    (hit == '*' && hit == s->td.mf.hits[2] && hit != s->td.mf.hits[1] && 
-				    hit != s->td.mf.hits[0]))) {
-					store_digit(s, hit);
-				}
+			/* The logic in the next test is:
+			   For KP we need 4 successive identical clean detects, with
+			   two blocks of something different preceeding it. For anything
+			   else we need two successive identical clean detects, with
+			   two blocks of something different preceeding it. */
+			if (hit == s->td.mf.hits[4] && hit == s->td.mf.hits[3] &&
+			   ((hit != '*' && hit != s->td.mf.hits[2] && hit != s->td.mf.hits[1])||
+			    (hit == '*' && hit == s->td.mf.hits[2] && hit != s->td.mf.hits[1] && 
+			    hit != s->td.mf.hits[0]))) {
+				store_digit(s, hit);
 			}
 		}
 
@@ -926,12 +894,12 @@
 
 		/* If we had a hit in this block, include it into mute fragment */
 		if (squelch && hit) {
-			if (mute.end < sample - s->td.mf.gsize) {
+			if (mute.end < sample - MF_GSIZE) {
 				/* There is a gap between fragments */
 				mute_fragment(dsp, &mute);
-				mute.start = (sample > s->td.mf.gsize) ? (sample - s->td.mf.gsize) : 0;
-			}
-			mute.end = limit + s->td.mf.gsize;
+				mute.start = (sample > MF_GSIZE) ? (sample - MF_GSIZE) : 0;
+			}
+			mute.end = limit + DTMF_GSIZE;
 		}
 
 		/* Reinitialise the detector for the next block */
@@ -1367,7 +1335,7 @@
 	}
 
 	if ((dsp->features & DSP_FEATURE_DIGIT_DETECT)) {
-		if ((dsp->digitmode & DSP_DIGITMODE_MASK))
+		if ((dsp->digitmode & DSP_DIGITMODE_MF))
 			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));
@@ -1493,7 +1461,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_MASK);
+		ast_digit_detect_init(&dsp->digit_state, dsp->digitmode & DSP_DIGITMODE_MF);
 		/* Initialize initial DSP progress detect parameters */
 		ast_dsp_prog_reset(dsp);
 		/* Initialize fax detector */
@@ -1548,7 +1516,7 @@
 	int i;
 	
 	dsp->dtmf_began = 0;
-	if (dsp->digitmode & DSP_DIGITMODE_MASK) {
+	if (dsp->digitmode & DSP_DIGITMODE_MF) {
 		mf_detect_state_t *s = &dsp->digit_state.td.mf;
 		/* Reinitialise the detector for the next block */
 		for (i = 0;  i < 6;  i++) {
@@ -1592,11 +1560,11 @@
 	int new;
 	int old;
 	
-	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);
+	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);
 	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_MASK);
+		ast_digit_detect_init(&dsp->digit_state, new & DSP_DIGITMODE_MF);
 	}
 	dsp->digitmode = digitmode;
 	return 0;
@@ -1646,6 +1614,9 @@
 	struct ast_config *cfg;
 
 	cfg = ast_config_load2(CONFIG_FILE_NAME, "dsp", config_flags);
+	if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
+		return 0;
+	}
 
 	if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED) {
 		const char *value;




More information about the asterisk-commits mailing list