Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
2ed8e047
提交
2ed8e047
authored
8月 30, 2013
作者:
Steve Underwood
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tweaks to the spandsp alloc functions, and a fix for bi-level image row
squashing.
上级
8f0dbcaa
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
407 行增加
和
233 行删除
+407
-233
alloc.c
libs/spandsp/src/alloc.c
+46
-20
alloc.h
libs/spandsp/src/spandsp/alloc.h
+19
-5
t4_rx.h
libs/spandsp/src/spandsp/private/t4_rx.h
+8
-5
t4_tx.h
libs/spandsp/src/spandsp/private/t4_tx.h
+10
-4
t42.h
libs/spandsp/src/spandsp/t42.h
+2
-0
t85.h
libs/spandsp/src/spandsp/t85.h
+2
-0
t30.c
libs/spandsp/src/t30.c
+6
-12
t42.c
libs/spandsp/src/t42.c
+33
-1
t43.c
libs/spandsp/src/t43.c
+4
-2
t4_rx.c
libs/spandsp/src/t4_rx.c
+181
-65
t4_tx.c
libs/spandsp/src/t4_tx.c
+85
-118
t85_decode.c
libs/spandsp/src/t85_decode.c
+11
-1
没有找到文件。
libs/spandsp/src/alloc.c
浏览文件 @
2ed8e047
...
...
@@ -50,21 +50,25 @@
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#if
def _MSC_VER
#if
defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4232)
/* address of dllimport is not static, identity not guaranteed */
#endif
#if defined(HAVE_ALIGNED_ALLOC)
static
span_aligned_alloc_t
__span_aligned_alloc
=
aligned_alloc
;
static
span_aligned_free_t
__span_aligned_free
=
free
;
#elif defined(HAVE_MEMALIGN)
static
span_aligned_alloc_t
__span_aligned_alloc
=
memalign
;
#elif defined(HAVE_POSIX_MEMALIGN)
static
void
*
fake_posix_memalign
(
size_t
alignment
,
size_t
size
);
static
span_aligned_alloc_t
__span_aligned_alloc
=
fake_posix_memalign
;
static
span_aligned_free_t
__span_aligned_free
=
free
;
#elif defined(__MSVC__)
static
void
*
fake_aligned_alloc
(
size_t
alignment
,
size_t
size
);
static
span_aligned_alloc_t
__span_aligned_alloc
=
fake_aligned_alloc
;
static
span_aligned_free_t
__span_aligned_free
=
_aligned_free
;
#else
static
void
*
fake_aligned_alloc
(
size_t
alignment
,
size_t
size
);
static
span_aligned_alloc_t
__span_aligned_alloc
=
fake_aligned_alloc
;
static
span_aligned_free_t
__span_aligned_free
=
free
;
#endif
static
span_alloc_t
__span_alloc
=
malloc
;
static
span_realloc_t
__span_realloc
=
realloc
;
...
...
@@ -76,12 +80,19 @@ static span_free_t __span_free = free;
#if defined(HAVE_ALIGNED_ALLOC)
#elif defined(HAVE_MEMALIGN)
#elif defined(__MSVC__)
static
void
*
fake_aligned_alloc
(
size_t
alignment
,
size_t
size
)
{
/* Make Microsoft's _aligned_malloc() look like the C11 aligned_alloc */
return
_aligned_malloc
(
size
,
alignment
);
}
/*- End of function --------------------------------------------------------*/
#elif defined(HAVE_POSIX_MEMALIGN)
static
void
*
fake_
posix_memalign
(
size_t
alignment
,
size_t
size
)
static
void
*
fake_
aligned_alloc
(
size_t
alignment
,
size_t
size
)
{
void
*
ptr
;
/* Make posix_memalign
look like the more modern
aligned_alloc */
/* Make posix_memalign
() look like the C11
aligned_alloc */
posix_memalign
(
&
ptr
,
alignment
,
size
);
return
ptr
;
}
...
...
@@ -94,12 +105,6 @@ static void *fake_aligned_alloc(size_t alignment, size_t size)
/*- End of function --------------------------------------------------------*/
#endif
SPAN_DECLARE
(
void
*
)
span_aligned_alloc
(
size_t
alignment
,
size_t
size
)
{
return
__span_aligned_alloc
(
alignment
,
size
);
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
void
*
)
span_alloc
(
size_t
size
)
{
return
__span_alloc
(
size
);
...
...
@@ -118,11 +123,28 @@ SPAN_DECLARE(void) span_free(void *ptr)
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
int
)
span_mem_allocators
(
span_aligned_alloc_t
custom_aligned_alloc
,
span_alloc_t
custom_alloc
,
SPAN_DECLARE
(
void
*
)
span_aligned_alloc
(
size_t
alignment
,
size_t
size
)
{
return
__span_aligned_alloc
(
alignment
,
size
);
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
void
)
span_aligned_free
(
void
*
ptr
)
{
__span_aligned_free
(
ptr
);
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
int
)
span_mem_allocators
(
span_alloc_t
custom_alloc
,
span_realloc_t
custom_realloc
,
span_free_t
custom_free
)
span_free_t
custom_free
,
span_aligned_alloc_t
custom_aligned_alloc
,
span_aligned_free_t
custom_aligned_free
)
{
__span_alloc
=
(
custom_alloc
)
?
custom_alloc
:
malloc
;
__span_realloc
=
(
custom_realloc
)
?
custom_realloc
:
realloc
;
__span_free
=
(
custom_free
)
?
custom_free
:
free
;
__span_aligned_alloc
=
(
custom_aligned_alloc
)
?
custom_aligned_alloc
...
...
@@ -131,14 +153,18 @@ SPAN_DECLARE(int) span_mem_allocators(span_aligned_alloc_t custom_aligned_alloc,
aligned_alloc
;
#elif defined(HAVE_MEMALIGN)
memalign
;
#elif defined(HAVE_POSIX_MEMALIGN)
fake_posix_memalign
;
#else
fake_aligned_alloc
;
#endif
__span_alloc
=
(
custom_alloc
)
?
custom_alloc
:
malloc
;
__span_realloc
=
(
custom_realloc
)
?
custom_realloc
:
realloc
;
__span_free
=
(
custom_free
)
?
custom_free
:
free
;
__span_aligned_free
=
(
custom_aligned_free
)
?
custom_aligned_free
:
#if defined(__MSVC__)
_aligned_free
;
#else
free
;
#endif
return
0
;
}
/*- End of function --------------------------------------------------------*/
...
...
libs/spandsp/src/spandsp/alloc.h
浏览文件 @
2ed8e047
...
...
@@ -28,7 +28,17 @@
#if !defined(_SPANDSP_ALLOC_H_)
#define _SPANDSP_ALLOC_H_
/* Notes:
- Most platforms don't have an aligned realloc function, so we don't try to
support an aligned realloc on any platform.
- Some platforms use a special free function for memory which was allocated
by alligned allocation functions. We use a separate aligned_free function
on all platforms, for compatibility, even though it may simply reduce to
free().
*/
typedef
void
*
(
*
span_aligned_alloc_t
)(
size_t
alignment
,
size_t
size
);
typedef
void
(
*
span_aligned_free_t
)(
void
*
ptr
);
typedef
void
*
(
*
span_alloc_t
)(
size_t
size
);
typedef
void
*
(
*
span_realloc_t
)(
void
*
ptr
,
size_t
size
);
typedef
void
(
*
span_free_t
)(
void
*
ptr
);
...
...
@@ -41,20 +51,24 @@ extern "C"
/* Allocate size bytes allocated to ALIGNMENT bytes. */
SPAN_DECLARE
(
void
*
)
span_aligned_alloc
(
size_t
alignment
,
size_t
size
);
/* Free a block allocated by span_aligned_alloc, or span_aligned_realloc. */
SPAN_DECLARE
(
void
)
span_aligned_free
(
void
*
ptr
);
/* Allocate size bytes of memory. */
SPAN_DECLARE
(
void
*
)
span_alloc
(
size_t
size
);
/* Re-allocate the previously allocated block in ptr, making the new block size bytes long. */
SPAN_DECLARE
(
void
*
)
span_realloc
(
void
*
ptr
,
size_t
size
);
/* Free a block allocated by span_alloc
, span_aligned_alloc,
or span_realloc. */
/* Free a block allocated by span_alloc or span_realloc. */
SPAN_DECLARE
(
void
)
span_free
(
void
*
ptr
);
SPAN_DECLARE
(
int
)
span_mem_allocators
(
span_aligned_alloc_t
custom_aligned_alloc
,
span_alloc_t
custom_alloc
,
SPAN_DECLARE
(
int
)
span_mem_allocators
(
span_alloc_t
custom_alloc
,
span_realloc_t
custom_realloc
,
span_free_t
custom_free
);
span_free_t
custom_free
,
span_aligned_alloc_t
custom_aligned_alloc
,
span_aligned_free_t
custom_aligned_free
);
#if defined(__cplusplus)
}
#endif
...
...
libs/spandsp/src/spandsp/private/t4_rx.h
浏览文件 @
2ed8e047
...
...
@@ -91,6 +91,13 @@ typedef struct
const
char
*
dcs
;
}
t4_rx_metadata_t
;
typedef
struct
{
uint8_t
*
buf
;
int
buf_len
;
int
buf_ptr
;
}
no_decoder_state_t
;
/*!
T.4 FAX decompression descriptor. This defines the working state
for a single instance of a T.4 FAX decompression channel.
...
...
@@ -114,6 +121,7 @@ struct t4_rx_state_s
union
{
no_decoder_state_t
no_decoder
;
t4_t6_decode_state_t
t4_t6
;
t85_decode_state_t
t85
;
#if defined(SPANDSP_SUPPORT_T88)
...
...
@@ -132,11 +140,6 @@ struct t4_rx_state_s
int
current_decoder
;
uint8_t
*
pre_encoded_buf
;
int
pre_encoded_len
;
int
pre_encoded_ptr
;
int
pre_encoded_bit
;
/* Supporting information, like resolutions, which the backend may want. */
t4_rx_metadata_t
metadata
;
...
...
libs/spandsp/src/spandsp/private/t4_tx.h
浏览文件 @
2ed8e047
...
...
@@ -100,6 +100,14 @@ typedef struct
int
resolution_code
;
}
t4_tx_metadata_t
;
typedef
struct
{
uint8_t
*
buf
;
int
buf_len
;
int
buf_ptr
;
int
bit
;
}
no_encoder_state_t
;
/*!
T.4 FAX compression descriptor. This defines the working state
for a single instance of a T.4 FAX compression channel.
...
...
@@ -149,6 +157,7 @@ struct t4_tx_state_s
union
{
no_encoder_state_t
no_encoder
;
t4_t6_encode_state_t
t4_t6
;
t85_encode_state_t
t85
;
#if defined(SPANDSP_SUPPORT_T88)
...
...
@@ -176,10 +185,7 @@ struct t4_tx_state_s
int
pack_row
;
int
pack_bit_mask
;
uint8_t
*
pre_encoded_buf
;
int
pre_encoded_len
;
int
pre_encoded_ptr
;
int
pre_encoded_bit
;
no_encoder_state_t
no_encoder
;
/*! \brief Supporting information, like resolutions, which the backend may want. */
t4_tx_metadata_t
metadata
;
...
...
libs/spandsp/src/spandsp/t42.h
浏览文件 @
2ed8e047
...
...
@@ -76,6 +76,8 @@ SPAN_DECLARE(void) set_lab_gamut2(lab_params_t *s, int L_P, int L_Q, int a_P, in
SPAN_DECLARE
(
void
)
get_lab_gamut2
(
lab_params_t
*
s
,
int
*
L_P
,
int
*
L_Q
,
int
*
a_P
,
int
*
a_Q
,
int
*
b_P
,
int
*
b_Q
);
SPAN_DECLARE
(
bool
)
t42_analyse_header
(
uint32_t
*
width
,
uint32_t
*
length
,
const
uint8_t
data
[],
size_t
len
);
SPAN_DECLARE
(
void
)
t42_encode_set_options
(
t42_encode_state_t
*
s
,
uint32_t
l0
,
int
quality
,
int
options
);
SPAN_DECLARE
(
int
)
t42_encode_set_image_width
(
t42_encode_state_t
*
s
,
uint32_t
image_width
);
...
...
libs/spandsp/src/spandsp/t85.h
浏览文件 @
2ed8e047
...
...
@@ -64,6 +64,8 @@ extern "C"
{
#endif
SPAN_DECLARE
(
bool
)
t85_analyse_header
(
uint32_t
*
width
,
uint32_t
*
length
,
const
uint8_t
data
[],
size_t
len
);
/*! \brief Check if we are at the end of the current document page.
\param s The T.85 context.
\return 0 for more data to come. SIG_STATUS_END_OF_DATA for no more data. */
...
...
libs/spandsp/src/t30.c
浏览文件 @
2ed8e047
...
...
@@ -1505,8 +1505,6 @@ static int build_dcs(t30_state_t *s)
set_ctrl_bit
(
s
->
dcs_frame
,
T30_DCS_BIT_FULL_COLOUR_MODE
);
if
(
image_type
==
T4_IMAGE_TYPE_GRAY_12BIT
||
image_type
==
T4_IMAGE_TYPE_COLOUR_12BIT
)
set_ctrl_bit
(
s
->
dcs_frame
,
T30_DCS_BIT_12BIT_COMPONENT
);
//if (???????? & T4_COMPRESSION_NO_SUBSAMPLING))
// set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_NO_SUBSAMPLING);
set_ctrl_bits
(
s
->
dcs_frame
,
T30_MIN_SCAN_0MS
,
T30_DCS_BIT_MIN_SCAN_LINE_TIME_1
);
use_bilevel
=
false
;
break
;
...
...
@@ -1789,17 +1787,13 @@ static int analyze_rx_dis_dtc(t30_state_t *s, const uint8_t *msg, int len)
}
if
(
!
test_ctrl_bit
(
s
->
far_dis_dtc_frame
,
T30_DIS_BIT_200_400_CAPABLE
))
{
if
(
!
test_ctrl_bit
(
s
->
far_dis_dtc_frame
,
T30_DIS_BIT_INCH_RESOLUTION_PREFERRED
))
s
->
mutual_bilevel_resolutions
&=
~
T4_RESOLUTION_200_400
;
if
(
!
test_ctrl_bit
(
s
->
far_dis_dtc_frame
,
T30_DIS_BIT_METRIC_RESOLUTION_PREFERRED
))
s
->
mutual_bilevel_resolutions
&=
~
T4_RESOLUTION_R8_SUPERFINE
;
s
->
mutual_bilevel_resolutions
&=
~
T4_RESOLUTION_200_400
;
s
->
mutual_bilevel_resolutions
&=
~
T4_RESOLUTION_R8_SUPERFINE
;
}
if
(
!
test_ctrl_bit
(
s
->
far_dis_dtc_frame
,
T30_DIS_BIT_200_200_CAPABLE
))
{
if
(
!
test_ctrl_bit
(
s
->
far_dis_dtc_frame
,
T30_DIS_BIT_INCH_RESOLUTION_PREFERRED
))
s
->
mutual_bilevel_resolutions
&=
~
T4_RESOLUTION_200_200
;
if
(
!
test_ctrl_bit
(
s
->
far_dis_dtc_frame
,
T30_DIS_BIT_METRIC_RESOLUTION_PREFERRED
))
s
->
mutual_bilevel_resolutions
&=
~
T4_RESOLUTION_R8_FINE
;
s
->
mutual_bilevel_resolutions
&=
~
T4_RESOLUTION_200_200
;
s
->
mutual_bilevel_resolutions
&=
~
T4_RESOLUTION_R8_FINE
;
s
->
mutual_colour_resolutions
&=
~
T4_RESOLUTION_200_200
;
}
else
...
...
@@ -6706,8 +6700,8 @@ SPAN_DECLARE(t30_state_t *) t30_init(t30_state_t *s,
|
T4_SUPPORT_LENGTH_A4
|
T4_SUPPORT_LENGTH_B4
|
T4_SUPPORT_LENGTH_UNLIMITED
;
/* Set the output encoding to something safe. For bi-level images
ost things get
1D and 2D encoding right. Quite a lot get other things wrong. */
/* Set the output encoding to something safe. For bi-level images
most things
get
1D and 2D encoding right. Quite a lot get other things wrong. */
s
->
supported_output_compressions
=
T4_COMPRESSION_T4_2D
|
T4_COMPRESSION_JPEG
;
s
->
local_min_scan_time_code
=
T30_MIN_SCAN_0MS
;
span_log_init
(
&
s
->
logging
,
SPAN_LOG_NONE
,
NULL
);
...
...
libs/spandsp/src/t42.c
浏览文件 @
2ed8e047
...
...
@@ -72,7 +72,7 @@
#include "spandsp/private/t85.h"
#include "spandsp/private/t42.h"
/* The open_memstream() and fmemopen() in older versions of glibc seem
s
quirky */
/* The open_memstream() and fmemopen() in older versions of glibc seem quirky */
#if defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 12))
#undef OPEN_MEMSTREAM
#endif
...
...
@@ -230,6 +230,38 @@ static __inline__ int unpack_16(uint8_t *s, uint16_t value)
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
bool
)
t42_analyse_header
(
uint32_t
*
width
,
uint32_t
*
length
,
const
uint8_t
data
[],
size_t
len
)
{
int
type
;
int
seg
;
int
pos
;
/* Search the image data for its width and length */
*
length
=
0
;
*
width
=
0
;
pos
=
0
;
if
(
pack_16
(
&
data
[
pos
])
!=
0xFFD8
)
return
false
;
pos
+=
2
;
while
(
pos
<
len
)
{
type
=
pack_16
(
&
data
[
pos
]);
pos
+=
2
;
seg
=
pack_16
(
&
data
[
pos
])
-
2
;
pos
+=
2
;
if
(
type
==
0xFFC0
)
{
*
length
=
pack_16
(
&
data
[
pos
+
1
]);
*
width
=
pack_16
(
&
data
[
pos
+
3
]);
return
true
;
}
pos
+=
seg
;
}
return
false
;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
int
)
xyz_to_corrected_color_temp
(
float
*
temp
,
float
xyz
[
3
])
{
float
us
;
...
...
libs/spandsp/src/t43.c
浏览文件 @
2ed8e047
...
...
@@ -865,7 +865,8 @@ SPAN_DECLARE(int) t43_decode_restart(t43_decode_state_t *s)
{
/* ITULAB */
/* Illuminant D50 */
set_lab_illuminant
(
&
s
->
lab
,
96
.
422
f
,
100
.
000
f
,
82
.
521
f
);
//set_lab_illuminant(&s->lab, 96.422f, 100.000f, 82.521f);
set_lab_illuminant
(
&
s
->
lab
,
100
.
0
f
,
100
.
0
f
,
100
.
0
f
);
set_lab_gamut
(
&
s
->
lab
,
0
,
100
,
-
85
,
85
,
-
75
,
125
,
false
);
s
->
t85
.
min_bit_planes
=
1
;
...
...
@@ -898,7 +899,8 @@ SPAN_DECLARE(t43_decode_state_t *) t43_decode_init(t43_decode_state_t *s,
/* ITULAB */
/* Illuminant D50 */
set_lab_illuminant
(
&
s
->
lab
,
96
.
422
f
,
100
.
000
f
,
82
.
521
f
);
//set_lab_illuminant(&s->lab, 96.422f, 100.000f, 82.521f);
set_lab_illuminant
(
&
s
->
lab
,
100
.
0
f
,
100
.
0
f
,
100
.
0
f
);
set_lab_gamut
(
&
s
->
lab
,
0
,
100
,
-
85
,
85
,
-
75
,
125
,
false
);
s
->
t85
.
min_bit_planes
=
1
;
...
...
libs/spandsp/src/t4_rx.c
浏览文件 @
2ed8e047
差异被折叠。
点击展开。
libs/spandsp/src/t4_tx.c
浏览文件 @
2ed8e047
差异被折叠。
点击展开。
libs/spandsp/src/t85_decode.c
浏览文件 @
2ed8e047
...
...
@@ -53,7 +53,7 @@
#include "spandsp/private/t81_t82_arith_coding.h"
#include "spandsp/private/t85.h"
static
__inline__
int32_t
pack_32
(
uint8_t
*
s
)
static
__inline__
int32_t
pack_32
(
const
uint8_t
*
s
)
{
int32_t
value
;
...
...
@@ -265,6 +265,16 @@ static int finish_sde(t85_decode_state_t *s)
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE
(
bool
)
t85_analyse_header
(
uint32_t
*
width
,
uint32_t
*
length
,
const
uint8_t
data
[],
size_t
len
)
{
if
(
len
<
20
)
return
false
;
*
width
=
pack_32
(
&
data
[
6
]);
*
length
=
pack_32
(
&
data
[
10
]);
return
true
;
}
/*- End of function --------------------------------------------------------*/
static
int
check_bih
(
t85_decode_state_t
*
s
)
{
/* Check that the fixed parameters have the values they are expected to be
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论