Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
b205313f
提交
b205313f
authored
4月 30, 2014
作者:
Steve Underwood
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More fixes from Coverity scans
上级
94221563
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
62 行增加
和
34 行删除
+62
-34
dds_float.c
libs/spandsp/src/dds_float.c
+35
-19
dds.h
libs/spandsp/src/spandsp/dds.h
+13
-0
g711.h
libs/spandsp/src/spandsp/g711.h
+14
-15
没有找到文件。
libs/spandsp/src/dds_float.c
浏览文件 @
b205313f
...
@@ -2100,6 +2100,12 @@ static const float sine_table[SINELEN] =
...
@@ -2100,6 +2100,12 @@ static const float sine_table[SINELEN] =
-
0
.
003067
96
f
-
0
.
003067
96
f
};
};
SPAN_DECLARE
(
float
)
dds_phase_to_radians
(
uint32_t
phase
)
{
return
phase
*
2
.
0
f
*
3
.
1415926
f
/
(
65536
.
0
f
*
65536
.
0
f
);
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
int32_t
)
dds_phase_ratef
(
float
frequency
)
SPAN_DECLARE
(
int32_t
)
dds_phase_ratef
(
float
frequency
)
{
{
return
(
int32_t
)
(
frequency
*
65536
.
0
f
*
65536
.
0
f
/
SAMPLE_RATE
);
return
(
int32_t
)
(
frequency
*
65536
.
0
f
*
65536
.
0
f
/
SAMPLE_RATE
);
...
@@ -2124,44 +2130,45 @@ SPAN_DECLARE(float) dds_scaling_dbovf(float level)
...
@@ -2124,44 +2130,45 @@ SPAN_DECLARE(float) dds_scaling_dbovf(float level)
}
}
/*- End of function --------------------------------------------------------*/
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
void
)
dds_advancef
(
uint32_t
*
phase_acc
,
int32_t
phase_rat
e
)
static
__inline__
float
dds_lookupx
(
uint32_t
phas
e
)
{
{
*
phase_acc
+=
phase_rate
;
return
sine_table
[
phase
>>
(
32
-
SLENK
)]
;
}
}
/*- End of function --------------------------------------------------------*/
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
float
)
dds
f
(
uint32_t
*
phase_acc
,
int32_t
phase_rat
e
)
SPAN_DECLARE
(
float
)
dds
_lookupf
(
uint32_t
phas
e
)
{
{
float
amp
;
return
dds_lookupx
(
phase
);
}
/*- End of function --------------------------------------------------------*/
amp
=
sine_table
[
*
phase_acc
>>
(
32
-
SLENK
)];
SPAN_DECLARE
(
float
)
dds_offsetf
(
uint32_t
phase_acc
,
int32_t
phase_offset
)
*
phase_acc
+=
phase_rate
;
{
return
amp
;
return
dds_lookupx
(
phase_acc
+
phase_offset
)
;
}
}
/*- End of function --------------------------------------------------------*/
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
float
)
dds_lookupf
(
uint32_t
phas
e
)
SPAN_DECLARE
(
void
)
dds_advancef
(
uint32_t
*
phase_acc
,
int32_t
phase_rat
e
)
{
{
return
sine_table
[
phase
>>
(
32
-
SLENK
)]
;
*
phase_acc
+=
phase_rate
;
}
}
/*- End of function --------------------------------------------------------*/
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
float
)
dds
_modf
(
uint32_t
*
phase_acc
,
int32_t
phase_rate
,
float
scale
,
int32_t
phas
e
)
SPAN_DECLARE
(
float
)
dds
f
(
uint32_t
*
phase_acc
,
int32_t
phase_rat
e
)
{
{
float
amp
;
float
amp
;
amp
=
sine_table
[
*
(
phase_acc
+
phase
)
>>
(
32
-
SLENK
)]
*
scale
;
amp
=
dds_lookupx
(
*
phase_acc
)
;
*
phase_acc
+=
phase_rate
;
*
phase_acc
+=
phase_rate
;
return
amp
;
return
amp
;
}
}
/*- End of function --------------------------------------------------------*/
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
complexf_t
)
dds_complexf
(
uint32_t
*
phase_acc
,
int32_t
phase_rat
e
)
SPAN_DECLARE
(
float
)
dds_modf
(
uint32_t
*
phase_acc
,
int32_t
phase_rate
,
float
scale
,
int32_t
phas
e
)
{
{
complexf_
t
amp
;
floa
t
amp
;
amp
=
complex_setf
(
sine_table
[(
*
phase_acc
+
(
1
<<
30
))
>>
(
32
-
SLENK
)],
amp
=
dds_lookupx
(
*
phase_acc
+
phase
)
*
scale
;
sine_table
[
*
phase_acc
>>
(
32
-
SLENK
)]);
*
phase_acc
+=
phase_rate
;
*
phase_acc
+=
phase_rate
;
return
amp
;
return
amp
;
}
}
...
@@ -2169,8 +2176,17 @@ SPAN_DECLARE(complexf_t) dds_complexf(uint32_t *phase_acc, int32_t phase_rate)
...
@@ -2169,8 +2176,17 @@ SPAN_DECLARE(complexf_t) dds_complexf(uint32_t *phase_acc, int32_t phase_rate)
SPAN_DECLARE
(
complexf_t
)
dds_lookup_complexf
(
uint32_t
phase
)
SPAN_DECLARE
(
complexf_t
)
dds_lookup_complexf
(
uint32_t
phase
)
{
{
return
complex_setf
(
sine_table
[(
phase
+
(
1
<<
30
))
>>
(
32
-
SLENK
)],
return
complex_setf
(
dds_lookupx
(
phase
+
(
1
<<
30
)),
dds_lookupx
(
phase
));
sine_table
[
phase
>>
(
32
-
SLENK
)]);
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
complexf_t
)
dds_complexf
(
uint32_t
*
phase_acc
,
int32_t
phase_rate
)
{
complexf_t
amp
;
amp
=
complex_setf
(
dds_lookupx
(
*
phase_acc
+
(
1
<<
30
)),
dds_lookupx
(
*
phase_acc
));
*
phase_acc
+=
phase_rate
;
return
amp
;
}
}
/*- End of function --------------------------------------------------------*/
/*- End of function --------------------------------------------------------*/
...
@@ -2178,8 +2194,8 @@ SPAN_DECLARE(complexf_t) dds_complex_modf(uint32_t *phase_acc, int32_t phase_rat
...
@@ -2178,8 +2194,8 @@ SPAN_DECLARE(complexf_t) dds_complex_modf(uint32_t *phase_acc, int32_t phase_rat
{
{
complexf_t
amp
;
complexf_t
amp
;
amp
=
complex_setf
(
sine_table
[(
*
phase_acc
+
phase
+
(
1
<<
30
))
>>
(
32
-
SLENK
)]
*
scale
,
amp
=
complex_setf
(
dds_lookupx
(
*
phase_acc
+
phase
+
(
1
<<
30
))
*
scale
,
sine_table
[(
*
phase_acc
+
phase
)
>>
(
32
-
SLENK
)]
*
scale
);
dds_lookupx
(
*
phase_acc
+
phase
)
*
scale
);
*
phase_acc
+=
phase_rate
;
*
phase_acc
+=
phase_rate
;
return
amp
;
return
amp
;
}
}
...
...
libs/spandsp/src/spandsp/dds.h
浏览文件 @
b205313f
...
@@ -36,6 +36,12 @@ extern "C"
...
@@ -36,6 +36,12 @@ extern "C"
{
{
#endif
#endif
/*! \brief Convert a 32 bit phase angle to an angle in radians, between 0 and 2*PI
\param phase The angle to convert.
\return The angle in radians.
*/
SPAN_DECLARE
(
float
)
dds_phase_to_radians
(
uint32_t
phase
);
/*! \brief Find the phase rate value to achieve a particular frequency.
/*! \brief Find the phase rate value to achieve a particular frequency.
\param frequency The desired frequency, in Hz.
\param frequency The desired frequency, in Hz.
\return The phase rate which while achieve the desired frequency.
\return The phase rate which while achieve the desired frequency.
...
@@ -221,6 +227,13 @@ SPAN_DECLARE(float) ddsf(uint32_t *phase_acc, int32_t phase_rate);
...
@@ -221,6 +227,13 @@ SPAN_DECLARE(float) ddsf(uint32_t *phase_acc, int32_t phase_rate);
*/
*/
SPAN_DECLARE
(
float
)
dds_lookupf
(
uint32_t
phase
);
SPAN_DECLARE
(
float
)
dds_lookupf
(
uint32_t
phase
);
/*! \brief Lookup the floating point value of a particular phase offset from an accumulated phase.
\param phase_acc The accumulated phase.
\param phase_offset The phase offset.
\return The signal amplitude.
*/
SPAN_DECLARE
(
float
)
dds_offsetf
(
uint32_t
phase_acc
,
int32_t
phase_offset
);
/*! \brief Generate a floating point tone sample, with modulation.
/*! \brief Generate a floating point tone sample, with modulation.
\param phase_acc A pointer to a phase accumulator value.
\param phase_acc A pointer to a phase accumulator value.
\param phase_rate The phase increment to be applied.
\param phase_rate The phase increment to be applied.
...
...
libs/spandsp/src/spandsp/g711.h
浏览文件 @
b205313f
...
@@ -137,15 +137,15 @@ static __inline__ uint8_t linear_to_ulaw(int linear)
...
@@ -137,15 +137,15 @@ static __inline__ uint8_t linear_to_ulaw(int linear)
}
}
seg
=
top_bit
(
linear
|
0xFF
)
-
7
;
seg
=
top_bit
(
linear
|
0xFF
)
-
7
;
/*
* Combine the sign, segment, quantization bits,
* and complement the code word.
*/
if
(
seg
>=
8
)
if
(
seg
>=
8
)
{
u_val
=
(
uint8_t
)
(
0x7F
^
mask
);
u_val
=
(
uint8_t
)
(
0x7F
^
mask
);
}
else
else
{
/* Combine the sign, segment, quantization bits, and complement the code word. */
u_val
=
(
uint8_t
)
(((
seg
<<
4
)
|
((
linear
>>
(
seg
+
3
))
&
0xF
))
^
mask
);
u_val
=
(
uint8_t
)
(((
seg
<<
4
)
|
((
linear
>>
(
seg
+
3
))
&
0xF
))
^
mask
);
}
#if defined(G711_ULAW_ZEROTRAP)
#if defined(G711_ULAW_ZEROTRAP)
/* Optional ITU trap */
/* Optional ITU trap */
if
(
u_val
==
0
)
if
(
u_val
==
0
)
...
@@ -201,13 +201,14 @@ static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
...
@@ -201,13 +201,14 @@ static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
*/
*/
static
__inline__
uint8_t
linear_to_alaw
(
int
linear
)
static
__inline__
uint8_t
linear_to_alaw
(
int
linear
)
{
{
uint8_t
a_val
;
int
mask
;
int
mask
;
int
seg
;
int
seg
;
if
(
linear
>=
0
)
if
(
linear
>=
0
)
{
{
/* Sign (bit 7) bit = 1 */
/* Sign (bit 7) bit = 1 */
mask
=
G711_ALAW_AMI_MASK
|
0x80
;
mask
=
0x80
|
G711_ALAW_AMI_MASK
;
}
}
else
else
{
{
...
@@ -220,16 +221,14 @@ static __inline__ uint8_t linear_to_alaw(int linear)
...
@@ -220,16 +221,14 @@ static __inline__ uint8_t linear_to_alaw(int linear)
seg
=
top_bit
(
linear
|
0xFF
)
-
7
;
seg
=
top_bit
(
linear
|
0xFF
)
-
7
;
if
(
seg
>=
8
)
if
(
seg
>=
8
)
{
{
if
(
linear
>=
0
)
a_val
=
(
uint8_t
)
(
0x7F
^
mask
);
{
}
/* Out of range. Return maximum value. */
else
return
(
uint8_t
)
(
0x7F
^
mask
);
{
}
/* Combine the sign, segment, and quantization bits. */
/* We must be just a tiny step below zero */
a_val
=
(
uint8_t
)
(((
seg
<<
4
)
|
((
linear
>>
((
seg
)
?
(
seg
+
3
)
:
4
))
&
0x0F
))
^
mask
);
return
(
uint8_t
)
mask
;
}
}
/* Combine the sign, segment, and quantization bits. */
return
a_val
;
return
(
uint8_t
)
(((
seg
<<
4
)
|
((
linear
>>
((
seg
)
?
(
seg
+
3
)
:
4
))
&
0x0F
))
^
mask
);
}
}
/*- End of function --------------------------------------------------------*/
/*- End of function --------------------------------------------------------*/
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论