Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
b93e53fa
提交
b93e53fa
authored
9月 02, 2012
作者:
Steve Underwood
提交者:
Ken Rice
9月 11, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Start introducing some meaningful TIFF/FX stuff
上级
6cd47a92
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
70 行增加
和
24 行删除
+70
-24
t4_rx.c
libs/spandsp/src/t4_rx.c
+70
-24
没有找到文件。
libs/spandsp/src/t4_rx.c
浏览文件 @
b93e53fa
...
...
@@ -81,6 +81,10 @@
/*! The number of centimetres in one inch */
#define CM_PER_INCH 2.54f
#if defined(SPANDSP_SUPPORT_TIFF_FX)
extern
TIFFFieldArray
tiff_fx_field_array
;
#endif
SPAN_DECLARE
(
const
char
*
)
t4_encoding_to_str
(
int
encoding
)
{
switch
(
encoding
)
...
...
@@ -126,17 +130,20 @@ static int set_tiff_directory_info(t4_rx_state_t *s)
/* Prepare the directory entry fully before writing the image, or libtiff complains */
switch
(
t
->
output_encoding
)
{
case
T4_COMPRESSION_ITU_T6
:
output_compression
=
COMPRESSION_CCITT_T6
;
output_t4_options
=
0
;
case
T4_COMPRESSION_ITU_T4_1D
:
default
:
output_compression
=
COMPRESSION_CCITT_T4
;
output_t4_options
=
GROUP3OPT_FILLBITS
;
break
;
case
T4_COMPRESSION_ITU_T4_2D
:
output_compression
=
COMPRESSION_CCITT_T4
;
output_t4_options
=
GROUP3OPT_FILLBITS
|
GROUP3OPT_2DENCODING
;
break
;
default
:
output_compression
=
COMPRESSION_CCITT_T4
;
output_t4_options
=
GROUP3OPT_FILLBITS
;
case
T4_COMPRESSION_ITU_T6
:
output_compression
=
COMPRESSION_CCITT_T6
;
break
;
case
T4_COMPRESSION_ITU_T85
:
output_compression
=
COMPRESSION_T85
;
break
;
}
...
...
@@ -146,10 +153,21 @@ static int set_tiff_directory_info(t4_rx_state_t *s)
case
COMPRESSION_CCITT_T4
:
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_T4OPTIONS
,
output_t4_options
);
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_FAXMODE
,
FAXMODE_CLASSF
);
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_ROWSPERSTRIP
,
-
1L
);
break
;
case
COMPRESSION_CCITT_T6
:
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_T6OPTIONS
,
0
);
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_FAXMODE
,
FAXMODE_CLASSF
);
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_ROWSPERSTRIP
,
-
1L
);
break
;
case
COMPRESSION_T85
:
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_FAXMODE
,
FAXMODE_CLASSF
);
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_ROWSPERSTRIP
,
-
1L
);
break
;
default
:
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_ROWSPERSTRIP
,
TIFFDefaultStripSize
(
t
->
tiff_file
,
0
));
break
;
}
#if defined(SPANDSP_SUPPORT_TIFF_FX)
...
...
@@ -162,21 +180,10 @@ static int set_tiff_directory_info(t4_rx_state_t *s)
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_BITSPERSAMPLE
,
1
);
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_ORIENTATION
,
ORIENTATION_TOPLEFT
);
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_SAMPLESPERPIXEL
,
1
);
if
(
output_compression
==
COMPRESSION_CCITT_T4
||
output_compression
==
COMPRESSION_CCITT_T6
)
{
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_ROWSPERSTRIP
,
-
1L
);
}
else
{
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_ROWSPERSTRIP
,
TIFFDefaultStripSize
(
t
->
tiff_file
,
0
));
}
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_PLANARCONFIG
,
PLANARCONFIG_CONTIG
);
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_PHOTOMETRIC
,
PHOTOMETRIC_MINISWHITE
);
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_FILLORDER
,
FILLORDER_LSB2MSB
);
/* TIFFTAG_STRIPBYTECOUNTS and TIFFTAG_STRIPOFFSETS are added automatically */
x_resolution
=
s
->
metadata
.
x_resolution
/
100
.
0
f
;
y_resolution
=
s
->
metadata
.
y_resolution
/
100
.
0
f
;
...
...
@@ -266,6 +273,13 @@ static int set_tiff_directory_info(t4_rx_state_t *s)
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_IMAGELENGTH
,
t85_decode_get_image_length
(
&
s
->
decoder
.
t85
));
break
;
}
#if defined(SPANDSP_SUPPORT_TIFF_FX)
if
(
s
->
current_page
==
0
)
{
/* Create a placeholder for the global parameters IFD, to be filled in later */
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_GLOBALPARAMETERSIFD
,
0
);
}
#endif
return
0
;
}
/*- End of function --------------------------------------------------------*/
...
...
@@ -280,15 +294,45 @@ static int open_tiff_output_file(t4_rx_state_t *s, const char *file)
static
int
write_tiff_image
(
t4_rx_state_t
*
s
)
{
if
(
s
->
tiff
.
image_buffer
==
NULL
||
s
->
tiff
.
image_size
<=
0
)
t4_rx_tiff_state_t
*
t
;
#if defined(SPANDSP_SUPPORT_TIFF_FX)
uint64_t
offset
;
#endif
t
=
&
s
->
tiff
;
if
(
t
->
image_buffer
==
NULL
||
t
->
image_size
<=
0
)
return
-
1
;
/* Set up the TIFF directory info... */
set_tiff_directory_info
(
s
);
/* ...and then write the image... */
if
(
TIFFWriteEncodedStrip
(
s
->
tiff
.
tiff_file
,
0
,
s
->
tiff
.
image_buffer
,
s
->
tiff
.
image_size
)
<
0
)
span_log
(
&
s
->
logging
,
SPAN_LOG_WARNING
,
"%s: Error writing TIFF strip.
\n
"
,
s
->
tiff
.
file
);
if
(
TIFFWriteEncodedStrip
(
t
->
tiff_file
,
0
,
t
->
image_buffer
,
t
->
image_size
)
<
0
)
span_log
(
&
s
->
logging
,
SPAN_LOG_WARNING
,
"%s: Error writing TIFF strip.
\n
"
,
t
->
file
);
/* ...then the directory entry, and libtiff is happy. */
TIFFWriteDirectory
(
s
->
tiff
.
tiff_file
);
if
(
!
TIFFWriteDirectory
(
t
->
tiff_file
))
span_log
(
&
s
->
logging
,
SPAN_LOG_WARNING
,
"%s: Failed to write directory for page %d.
\n
"
,
t
->
file
,
s
->
current_page
);
#if defined(SPANDSP_SUPPORT_TIFF_FX)
if
(
s
->
current_page
==
0
)
{
if
(
!
TIFFCreateCustomDirectory
(
t
->
tiff_file
,
&
tiff_fx_field_array
))
{
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_FAXPROFILE
,
PROFILETYPE_G3_FAX
);
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_PROFILETYPE
,
FAXPROFILE_S
);
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_VERSIONYEAR
,
"1998"
);
offset
=
0
;
if
(
!
TIFFWriteCustomDirectory
(
t
->
tiff_file
,
&
offset
))
printf
(
"Failed to write custom directory.
\n
"
);
/* Now go back and patch in the pointer to the new IFD */
if
(
!
TIFFSetDirectory
(
t
->
tiff_file
,
s
->
current_page
))
printf
(
"Failed to set directory.
\n
"
);
if
(
!
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_GLOBALPARAMETERSIFD
,
offset
))
printf
(
"Failed to set field.
\n
"
);
if
(
!
TIFFWriteDirectory
(
t
->
tiff_file
))
span_log
(
&
s
->
logging
,
SPAN_LOG_WARNING
,
"%s: Failed to write directory for page %d.
\n
"
,
t
->
file
,
s
->
current_page
);
}
}
#endif
return
0
;
}
/*- End of function --------------------------------------------------------*/
...
...
@@ -308,9 +352,11 @@ static int close_tiff_output_file(t4_rx_state_t *s)
need to set the correct total page count associated with each page. */
for
(
i
=
0
;
i
<
s
->
current_page
;
i
++
)
{
TIFFSetDirectory
(
t
->
tiff_file
,
(
tdir_t
)
i
);
if
(
!
TIFFSetDirectory
(
t
->
tiff_file
,
(
tdir_t
)
i
))
span_log
(
&
s
->
logging
,
SPAN_LOG_WARNING
,
"%s: Failed to set directory to page %d.
\n
"
,
s
->
tiff
.
file
,
i
);
TIFFSetField
(
t
->
tiff_file
,
TIFFTAG_PAGENUMBER
,
i
,
s
->
current_page
);
TIFFWriteDirectory
(
t
->
tiff_file
);
if
(
!
TIFFWriteDirectory
(
t
->
tiff_file
))
span_log
(
&
s
->
logging
,
SPAN_LOG_WARNING
,
"%s: Failed to write directory for page %d.
\n
"
,
s
->
tiff
.
file
,
i
);
}
}
TIFFClose
(
t
->
tiff_file
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论