Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
fb238ed9
提交
fb238ed9
authored
9月 13, 2013
作者:
Steve Underwood
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tweaks
上级
378648f2
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
56 行增加
和
30 行删除
+56
-30
dtmf.c
libs/spandsp/src/dtmf.c
+22
-27
t85_decode.c
libs/spandsp/src/t85_decode.c
+32
-1
dtmf_rx_tests.c
libs/spandsp/tests/dtmf_rx_tests.c
+2
-2
没有找到文件。
libs/spandsp/src/dtmf.c
浏览文件 @
fb238ed9
...
@@ -71,21 +71,24 @@
...
@@ -71,21 +71,24 @@
#define DTMF_SAMPLES_PER_BLOCK 102
#define DTMF_SAMPLES_PER_BLOCK 102
#if defined(SPANDSP_USE_FIXED_POINT)
#if defined(SPANDSP_USE_FIXED_POINT)
#define DTMF_THRESHOLD 10438
/* -42dBm0 */
/* The fixed point version scales the 16 bit signal down by 7 bits, so the Goertzels will fit in a 32 bit word */
#define DTMF_NORMAL_TWIST 6.309f
/* 8dB */
#define FP_SCALE(x) ((int16_t) (x/128.0 + ((x >= 0.0) ? 0.5 : -0.5)))
#define DTMF_REVERSE_TWIST 2.512f
/* 4dB */
#define DTMF_THRESHOLD 10438
/* -42dBm0 [((DTMF_SAMPLES_PER_BLOCK*32768.0/1.4142)*10^((-42 - DBM0_MAX_SINE_POWER)/20.0)/128.0)^2]*/
#define DTMF_RELATIVE_PEAK_ROW 6.309f
/* 8dB */
#define DTMF_NORMAL_TWIST 6.309f
/* 8dB [10.0^(8.0/10.0)] */
#define DTMF_RELATIVE_PEAK_COL 6.309f
/* 8dB */
#define DTMF_REVERSE_TWIST 2.512f
/* 4dB [10.0^(4.0/10.0)] */
#define DTMF_TO_TOTAL_ENERGY 83.868f
/* -0.85dB */
#define DTMF_RELATIVE_PEAK_ROW 6.309f
/* 8dB [10.0^(8.0/10.0)] */
#define DTMF_POWER_OFFSET 68.251f
/* 10*log(256.0*256.0*DTMF_SAMPLES_PER_BLOCK) */
#define DTMF_RELATIVE_PEAK_COL 6.309f
/* 8dB [10.0^(8.0/10.0)] */
#define DTMF_TO_TOTAL_ENERGY 83.868f
/* -0.85dB [DTMF_SAMPLES_PER_BLOCK*10^(-0.85/10.0)] */
#define DTMF_POWER_OFFSET 68.251f
/* 10*log(((32768.0/128.0)^2)*DTMF_SAMPLES_PER_BLOCK) */
#else
#else
#define FP_SCALE(x) (x)
#define DTMF_THRESHOLD 171032462.0f
/* -42dBm0 [((DTMF_SAMPLES_PER_BLOCK*32768.0/1.4142)*10^((-42 - DBM0_MAX_SINE_POWER)/20.0))^2] */
#define DTMF_THRESHOLD 171032462.0f
/* -42dBm0 [((DTMF_SAMPLES_PER_BLOCK*32768.0/1.4142)*10^((-42 - DBM0_MAX_SINE_POWER)/20.0))^2] */
#define DTMF_NORMAL_TWIST 6.309f
/* 8dB [10
^(8/10) => 6.309
] */
#define DTMF_NORMAL_TWIST 6.309f
/* 8dB [10
.0^(8.0/10.0)
] */
#define DTMF_REVERSE_TWIST 2.512f
/* 4dB */
#define DTMF_REVERSE_TWIST 2.512f
/* 4dB
[10.0^(4.0/10.0)]
*/
#define DTMF_RELATIVE_PEAK_ROW 6.309f
/* 8dB */
#define DTMF_RELATIVE_PEAK_ROW 6.309f
/* 8dB
[10.0^(8.0/10.0)]
*/
#define DTMF_RELATIVE_PEAK_COL 6.309f
/* 8dB */
#define DTMF_RELATIVE_PEAK_COL 6.309f
/* 8dB
[10.0^(8.0/10.0)]
*/
#define DTMF_TO_TOTAL_ENERGY 83.868f
/* -0.85dB [DTMF_SAMPLES_PER_BLOCK*10^(-0.85/10.0)] */
#define DTMF_TO_TOTAL_ENERGY 83.868f
/* -0.85dB [DTMF_SAMPLES_PER_BLOCK*10^(-0.85/10.0)] */
#define DTMF_POWER_OFFSET 110.395f
/* 10*log(
32768.0*32768.0
*DTMF_SAMPLES_PER_BLOCK) */
#define DTMF_POWER_OFFSET 110.395f
/* 10*log(
(32768.0^2)
*DTMF_SAMPLES_PER_BLOCK) */
#endif
#endif
static
const
float
dtmf_row
[]
=
static
const
float
dtmf_row
[]
=
...
@@ -303,11 +306,7 @@ SPAN_DECLARE(int) dtmf_rx(dtmf_rx_state_t *s, const int16_t amp[], int samples)
...
@@ -303,11 +306,7 @@ SPAN_DECLARE(int) dtmf_rx(dtmf_rx_state_t *s, const int16_t amp[], int samples)
s
->
in_digit
=
hit
;
s
->
in_digit
=
hit
;
}
}
s
->
last_hit
=
hit
;
s
->
last_hit
=
hit
;
#if defined(SPANDSP_USE_FIXED_POINT)
s
->
energy
=
FP_SCALE
(
0
.
0
f
);
s
->
energy
=
0
;
#else
s
->
energy
=
0
.
0
f
;
#endif
s
->
current_sample
=
0
;
s
->
current_sample
=
0
;
}
}
if
(
s
->
current_digits
&&
s
->
digits_callback
)
if
(
s
->
current_digits
&&
s
->
digits_callback
)
...
@@ -330,11 +329,7 @@ SPAN_DECLARE(int) dtmf_rx_fillin(dtmf_rx_state_t *s, int samples)
...
@@ -330,11 +329,7 @@ SPAN_DECLARE(int) dtmf_rx_fillin(dtmf_rx_state_t *s, int samples)
goertzel_reset
(
&
s
->
row_out
[
i
]);
goertzel_reset
(
&
s
->
row_out
[
i
]);
goertzel_reset
(
&
s
->
col_out
[
i
]);
goertzel_reset
(
&
s
->
col_out
[
i
]);
}
}
#if defined(SPANDSP_USE_FIXED_POINT)
s
->
energy
=
FP_SCALE
(
0
.
0
f
);
s
->
energy
=
0
;
#else
s
->
energy
=
0
.
0
f
;
#endif
s
->
current_sample
=
0
;
s
->
current_sample
=
0
;
/* Don't update the hit detection. Pretend it never happened. */
/* Don't update the hit detection. Pretend it never happened. */
/* TODO: Surely we can be cleverer than this. */
/* TODO: Surely we can be cleverer than this. */
...
@@ -399,7 +394,11 @@ SPAN_DECLARE(void) dtmf_rx_parms(dtmf_rx_state_t *s,
...
@@ -399,7 +394,11 @@ SPAN_DECLARE(void) dtmf_rx_parms(dtmf_rx_state_t *s,
s
->
reverse_twist
=
powf
(
10
.
0
f
,
reverse_twist
/
10
.
0
f
);
s
->
reverse_twist
=
powf
(
10
.
0
f
,
reverse_twist
/
10
.
0
f
);
if
(
threshold
>
-
99
)
if
(
threshold
>
-
99
)
{
{
#if defined(SPANDSP_USE_FIXED_POINT)
x
=
(
DTMF_SAMPLES_PER_BLOCK
*
32768
.
0
f
/
(
128
.
0
f
*
1
.
4142
f
))
*
powf
(
10
.
0
f
,
(
threshold
-
DBM0_MAX_SINE_POWER
)
/
20
.
0
f
);
#else
x
=
(
DTMF_SAMPLES_PER_BLOCK
*
32768
.
0
f
/
1
.
4142
f
)
*
powf
(
10
.
0
f
,
(
threshold
-
DBM0_MAX_SINE_POWER
)
/
20
.
0
f
);
x
=
(
DTMF_SAMPLES_PER_BLOCK
*
32768
.
0
f
/
1
.
4142
f
)
*
powf
(
10
.
0
f
,
(
threshold
-
DBM0_MAX_SINE_POWER
)
/
20
.
0
f
);
#endif
s
->
threshold
=
x
*
x
;
s
->
threshold
=
x
*
x
;
}
}
}
}
...
@@ -451,11 +450,7 @@ SPAN_DECLARE(dtmf_rx_state_t *) dtmf_rx_init(dtmf_rx_state_t *s,
...
@@ -451,11 +450,7 @@ SPAN_DECLARE(dtmf_rx_state_t *) dtmf_rx_init(dtmf_rx_state_t *s,
goertzel_init
(
&
s
->
row_out
[
i
],
&
dtmf_detect_row
[
i
]);
goertzel_init
(
&
s
->
row_out
[
i
],
&
dtmf_detect_row
[
i
]);
goertzel_init
(
&
s
->
col_out
[
i
],
&
dtmf_detect_col
[
i
]);
goertzel_init
(
&
s
->
col_out
[
i
],
&
dtmf_detect_col
[
i
]);
}
}
#if defined(SPANDSP_USE_FIXED_POINT)
s
->
energy
=
FP_SCALE
(
0
.
0
f
);
s
->
energy
=
0
;
#else
s
->
energy
=
0
.
0
f
;
#endif
s
->
current_sample
=
0
;
s
->
current_sample
=
0
;
s
->
lost_digits
=
0
;
s
->
lost_digits
=
0
;
s
->
current_digits
=
0
;
s
->
current_digits
=
0
;
...
...
libs/spandsp/src/t85_decode.c
浏览文件 @
fb238ed9
...
@@ -267,14 +267,45 @@ static int finish_sde(t85_decode_state_t *s)
...
@@ -267,14 +267,45 @@ static int finish_sde(t85_decode_state_t *s)
SPAN_DECLARE
(
bool
)
t85_analyse_header
(
uint32_t
*
width
,
uint32_t
*
length
,
const
uint8_t
data
[],
size_t
len
)
SPAN_DECLARE
(
bool
)
t85_analyse_header
(
uint32_t
*
width
,
uint32_t
*
length
,
const
uint8_t
data
[],
size_t
len
)
{
{
uint32_t
i
;
uint32_t
skip
;
if
(
len
<
20
)
if
(
len
<
20
)
{
*
width
=
0
;
*
length
=
0
;
return
false
;
return
false
;
}
*
width
=
pack_32
(
&
data
[
6
]);
*
width
=
pack_32
(
&
data
[
6
]);
*
length
=
pack_32
(
&
data
[
10
]);
*
length
=
pack_32
(
&
data
[
10
]);
if
((
data
[
19
]
&
T85_VLENGTH
))
if
((
data
[
19
]
&
T85_VLENGTH
))
{
{
/* TODO: scan for a true length, if the initial one just says 0xFFFFFFFF */
/* There should be an image length sequence terminating the image later on. */
/* There should be an image length sequence terminating the image later on. */
/* TODO: scan for a true length, instead of this fudge */
for
(
i
=
20
;
i
<
len
-
6
;
i
++
)
{
if
(
data
[
i
]
==
T82_ESC
)
{
if
(
data
[
i
+
1
]
==
T82_COMMENT
)
{
skip
=
pack_32
(
&
data
[
2
]);
if
((
skip
+
6
)
>
(
len
-
i
))
break
;
i
+=
(
6
+
skip
-
1
);
}
else
if
(
data
[
i
+
1
]
==
T82_ATMOVE
)
{
i
+=
(
8
-
1
);
}
else
if
(
data
[
i
+
1
]
==
T82_NEWLEN
)
{
/* We are only allow to have one of these, so if we find one
we should not look any further. */
*
length
=
pack_32
(
&
data
[
i
+
2
]);
break
;
}
}
}
}
}
return
true
;
return
true
;
}
}
...
...
libs/spandsp/tests/dtmf_rx_tests.c
浏览文件 @
fb238ed9
...
@@ -675,11 +675,11 @@ static void mitel_cm7291_side_2_and_bellcore_tests(void)
...
@@ -675,11 +675,11 @@ static void mitel_cm7291_side_2_and_bellcore_tests(void)
{
{
if
(
hit_types
[
i
])
if
(
hit_types
[
i
])
{
{
printf
(
" Digit %c had %d false hits
\n
"
,
i
,
hit_types
[
i
]);
printf
(
" Digit %c had %d false hits
.
\n
"
,
i
,
hit_types
[
i
]);
j
+=
hit_types
[
i
];
j
+=
hit_types
[
i
];
}
}
}
}
printf
(
" %d
hits in total
\n
"
,
j
);
printf
(
" %d
false hits in total.
\n
"
,
j
);
if
(
j
>
470
)
if
(
j
>
470
)
{
{
printf
(
" Failed
\n
"
);
printf
(
" Failed
\n
"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论