提交 88587ec0 authored 作者: Steve Underwood's avatar Steve Underwood

Minor tweaks from cleaning up spandsp

上级 a55d70ed
......@@ -257,10 +257,10 @@ then
esac
fi
#AC_DEFINE([SPANDSP_SUPPORT_T42], [1], [Support T.42 JPEG compression])
SPANDSP_SUPPORT_T42="#undef SPANDSP_SUPPORT_T42"
#AC_DEFINE([SPANDSP_SUPPORT_T43], [1], [Support T.43 JBIG gray and colour compression])
SPANDSP_SUPPORT_T43="#undef SPANDSP_SUPPORT_T43"
AC_DEFINE([SPANDSP_SUPPORT_T42], [1], [Support T.42 JPEG compression])
SPANDSP_SUPPORT_T42="#define SPANDSP_SUPPORT_T42 1"
AC_DEFINE([SPANDSP_SUPPORT_T43], [1], [Support T.43 JBIG gray and colour compression])
SPANDSP_SUPPORT_T43="#define SPANDSP_SUPPORT_T43 1"
#AC_DEFINE([SPANDSP_SUPPORT_V32BIS], [1], [Support the V.32bis modem])
SPANDSP_SUPPORT_V32BIS="#undef SPANDSP_SUPPORT_V32BIS"
#AC_DEFINE([SPANDSP_SUPPORT_V34], [1], [Support the V.34 FAX modem])
......
......@@ -21,12 +21,6 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Based in part on a single channel G.722 codec which is:
*
* Copyright (c) CMU 1993
* Computer Science, Speech Group
* Chengxiang Lu and Alex Hauptmann
*/
/*! \file */
......
......@@ -21,15 +21,8 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Based on a single channel G.722 codec which is:
*
***** Copyright (c) CMU 1993 *****
* Computer Science, Speech Group
* Chengxiang Lu and Alex Hauptmann
*/
/*! \file */
#if !defined(_SPANDSP_G722_H_)
......
......@@ -690,9 +690,24 @@ SPAN_DECLARE(int) t30_set_supported_compressions(t30_state_t *s, int supported_c
| T4_SUPPORT_COMPRESSION_T6
| T4_SUPPORT_COMPRESSION_T85
| T4_SUPPORT_COMPRESSION_T85_L0
#if defined(SPANDSP_SUPPORT_T88)
| T4_SUPPORT_COMPRESSION_T88
#endif
//| T4_SUPPORT_COMPRESSION_T81
#if defined(SPANDSP_SUPPORT_T43)
| T4_SUPPORT_COMPRESSION_T43
#endif
#if defined(SPANDSP_SUPPORT_T45)
| T4_SUPPORT_COMPRESSION_T45
#endif
#if 0
| T4_SUPPORT_COMPRESSION_GRAYSCALE
| T4_SUPPORT_COMPRESSION_COLOUR
| T4_SUPPORT_COMPRESSION_12BIT
| T4_SUPPORT_COMPRESSION_COLOUR_TO_GRAY
| T4_SUPPORT_COMPRESSION_GRAY_TO_BILEVEL
| T4_SUPPORT_COMPRESSION_COLOUR_TO_BILEVEL
| T4_SUPPORT_COMPRESSION_RESCALING
#endif
| 0;
s->supported_compressions = supported_compressions;
......
......@@ -48,7 +48,6 @@
#include "floating_fudge.h"
#include <tiffio.h>
#include <assert.h>
#include <jpeglib.h>
#include "spandsp/telephony.h"
#include "spandsp/fast_convert.h"
......@@ -719,15 +718,17 @@ static void jpg_encode_error_exit(j_common_ptr cinfo)
/*- End of function --------------------------------------------------------*/
/* This is the error catcher */
#ifndef WIN32
static struct jpeg_error_mgr encode_error_handler =
{
#if defined(_MSC_VER) || defined(__sunos) || defined(__solaris) || defined(__sun)
jpg_encode_error_exit,
0,
jpg_encode_error_exit
#else
.error_exit = jpg_encode_error_exit,
.output_message = jpg_encode_error_exit
};
#else
static struct jpeg_error_mgr encode_error_handler = {jpg_encode_error_exit,0,jpg_encode_error_exit};
#endif
};
static int t42_srgb_to_itulab_jpeg(t42_encode_state_t *s)
{
......@@ -1032,15 +1033,17 @@ static void jpg_decode_error_exit(j_common_ptr cinfo)
/*- End of function --------------------------------------------------------*/
/* This is the error catcher */
#ifndef WIN32
static struct jpeg_error_mgr decode_error_handler =
{
#if defined(_MSC_VER) || defined(__sunos) || defined(__solaris) || defined(__sun)
jpg_decode_error_exit,
0,
jpg_decode_error_exit
#else
.error_exit = jpg_decode_error_exit,
.output_message = jpg_decode_error_exit
};
#else
static struct jpeg_error_mgr decode_error_handler = {jpg_decode_error_exit,0,jpg_decode_error_exit};
#endif
};
static int t42_itulab_jpeg_to_srgb(t42_decode_state_t *s)
{
......
......@@ -41,7 +41,6 @@
#endif
#include <time.h>
#include "floating_fudge.h"
#include <jpeglib.h>
#include <setjmp.h>
#include "spandsp/telephony.h"
......
......@@ -112,6 +112,7 @@ noinst_PROGRAMS = ademco_contactid_tests \
t4_tests \
t4_t6_tests \
t42_tests \
t43_tests \
t81_t82_arith_coding_tests \
t85_tests \
time_scale_tests \
......@@ -325,6 +326,9 @@ t4_t6_tests_LDADD = $(LIBDIR) -lspandsp
t42_tests_SOURCES = t42_tests.c
t42_tests_LDADD = $(LIBDIR) -lspandsp
t43_tests_SOURCES = t43_tests.c
t43_tests_LDADD = $(LIBDIR) -lspandsp
t81_t82_arith_coding_tests_SOURCES = t81_t82_arith_coding_tests.c
t81_t82_arith_coding_tests_LDADD = $(LIBDIR) -lspandsp
......
......@@ -490,6 +490,7 @@ int main(int argc, char *argv[])
int noise_level;
int code_to_look_up;
int scan_line_time;
int colour_enabled;
t38_stats_t t38_stats;
t30_stats_t t30_stats;
logging_state_t *logging;
......@@ -528,14 +529,18 @@ int main(int argc, char *argv[])
scan_line_time = 0;
decode_file_name = NULL;
code_to_look_up = -1;
colour_enabled = FALSE;
t38_transport = T38_TRANSPORT_UDPTL;
while ((opt = getopt(argc, argv, "c:d:D:efFgH:i:Ilm:M:n:p:s:S:tT:u:v:z:")) != -1)
while ((opt = getopt(argc, argv, "c:Cd:D:efFgH:i:Ilm:M:n:p:s:S:tT:u:v:z:")) != -1)
{
switch (opt)
{
case 'c':
code_to_look_up = atoi(optarg);
break;
case 'C':
colour_enabled = TRUE;
break;
case 'd':
decode_file_name = optarg;
break;
......@@ -845,7 +850,7 @@ int main(int argc, char *argv[])
| T4_SUPPORT_LENGTH_US_LETTER
| T4_SUPPORT_LENGTH_US_LEGAL
| T4_SUPPORT_LENGTH_UNLIMITED);
#if 0
#if 1
t30_set_supported_bilevel_resolutions(t30_state[i],
T4_SUPPORT_RESOLUTION_R8_STANDARD
| T4_SUPPORT_RESOLUTION_R8_FINE
......@@ -880,9 +885,8 @@ int main(int argc, char *argv[])
| T4_SUPPORT_RESOLUTION_600_1200
| T4_SUPPORT_RESOLUTION_1200_1200);
#endif
#if 1
t30_set_supported_colour_resolutions(t30_state[i], 0);
#else
if (colour_enabled)
{
t30_set_supported_colour_resolutions(t30_state[i],
T4_SUPPORT_RESOLUTION_100_100
| T4_SUPPORT_RESOLUTION_200_200
......@@ -890,7 +894,11 @@ int main(int argc, char *argv[])
| T4_SUPPORT_RESOLUTION_400_400
| T4_SUPPORT_RESOLUTION_600_600
| T4_SUPPORT_RESOLUTION_1200_1200);
#endif
}
else
{
t30_set_supported_colour_resolutions(t30_state[i], 0);
}
t30_set_supported_output_compressions(t30_state[i], T4_SUPPORT_COMPRESSION_T4_2D);
t30_set_ecm_capability(t30_state[i], use_ecm);
t30_set_supported_compressions(t30_state[i],
......
......@@ -17,7 +17,7 @@
run_fax_test()
{
rm -f fax_tests_1.tif
rm -f fax_tests.tif
echo ./fax_tests ${OPTS} -i ${FILE}
./fax_tests ${OPTS} -i ${FILE} >xyzzy 2>xyzzy2
RETVAL=$?
......@@ -35,12 +35,87 @@ run_fax_test()
echo fax_tests failed!
exit $RETVAL
fi
rm -f fax_tests_1.tif
rm -f fax_tests.tif
echo tested ${FILE}
}
run_colour_fax_test()
{
rm -f fax_tests.tif
echo ./fax_tests ${OPTS} -i ${IN_FILE}
./fax_tests ${OPTS} -i ${IN_FILE} >xyzzy 2>xyzzy2
RETVAL=$?
if [ $RETVAL != 0 ]
then
echo fax_tests failed!
exit $RETVAL
fi
# Now use tiffcmp to check the results. It will return non-zero if any page images differ. The -t
# option means the normal differences in tags will be ignored.
tiffcmp -t ${OUT_FILE} fax_tests.tif >/dev/null
RETVAL=$?
if [ $RETVAL != 0 ]
then
echo fax_tests failed!
exit $RETVAL
fi
rm -f fax_tests.tif
echo tested ${IN_FILE} to ${OUT_FILE}
}
ITUTESTS_DIR=../test-data/itu/fax
TIFFFX_DIR=../test-data/itu/tiff-fx
LOCALTESTS_DIR=../test-data/local
# Colour/gray -> bilevel by not allowing ECM
for OPTS in "-p AA" "-p TT" "-p GG" "-p TG" "-p GT"
do
IN_FILE="${LOCALTESTS_DIR}/lenna-colour.tif"
OUT_FILE="${LOCALTESTS_DIR}/lenna-colour-bilevel.tif"
run_colour_fax_test
IN_FILE="${LOCALTESTS_DIR}/lenna-bw.tif"
OUT_FILE="${LOCALTESTS_DIR}/lenna-bw-bilevel.tif"
run_colour_fax_test
IN_FILE="${TIFFFX_DIR}/c03x_02x.tif"
OUT_FILE="${TIFFFX_DIR}/c03x_02x.tif"
run_colour_fax_test
IN_FILE="${TIFFFX_DIR}/l02x_02x.tif"
OUT_FILE="${TIFFFX_DIR}/l02x_02x.tif"
run_colour_fax_test
IN_FILE="${TIFFFX_DIR}/l04x_02x.tif"
OUT_FILE="${TIFFFX_DIR}/l04x_02x.tif"
run_colour_fax_test
done
# Colour/gray -> colour/gray by allowing ECM
for OPTS in "-p AA -C -e" "-p TT -C -e" "-p GG -C -e" "-p TG -C -e" "-p GT -C -e"
do
IN_FILE="${LOCALTESTS_DIR}/lenna-colour.tif"
OUT_FILE="${LOCALTESTS_DIR}/lenna-colour.tif"
run_colour_fax_test
IN_FILE="${LOCALTESTS_DIR}/lenna-bw.tif"
OUT_FILE="${LOCALTESTS_DIR}/lenna-bw.tif"
run_colour_fax_test
IN_FILE="${TIFFFX_DIR}/c03x_02x.tif"
OUT_FILE="${TIFFFX_DIR}/c03x_02x.tif"
run_colour_fax_test
IN_FILE="${TIFFFX_DIR}/l02x_02x.tif"
OUT_FILE="${TIFFFX_DIR}/l02x_02x.tif"
run_colour_fax_test
IN_FILE="${TIFFFX_DIR}/l04x_02x.tif"
OUT_FILE="${TIFFFX_DIR}/l04x_02x.tif"
run_colour_fax_test
done
# Bi-level tests
for OPTS in "-p AA" "-p AA -e" "-p TT" "-p TT -e" "-p GG" "-p GG -e" "-p TG" "-p TG -e" "-p GT" "-p GT -e"
do
FILE="${ITUTESTS_DIR}/itutests.tif"
......
......@@ -157,7 +157,8 @@ int main(int argc, char *argv[])
TIFF_FX_init();
#endif
set_lab_illuminant(&lab_param, 0.9638f, 1.0f, 0.8245f);
/* The default luminant is D50 */
set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f);
set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE);
source_file = (argc > 1) ? argv[1] : IN_FILE_NAME;
......@@ -218,7 +219,8 @@ int main(int argc, char *argv[])
#endif
lab_params_t lab;
set_lab_illuminant(&lab, 0.9638f, 1.0f, 0.8245f);
/* The default luminant is D50 */
set_lab_illuminant(&lab, 96.422f, 100.000f, 82.521f);
set_lab_gamut(&lab, 0, 100, -85, 85, -75, 125, FALSE);
lab_to_srgb(&lab, colour_map, colour_map, 256);
for (i = 0; i < (1 << bits_per_pixel); i++)
......@@ -447,12 +449,13 @@ int main(int argc, char *argv[])
if (photometric == PHOTOMETRIC_ITULAB)
{
printf("YYY ITULAB\n");
if (!t42_itulab_to_itulab(logging, (tdata_t) &outptr, &outsize, data, off, w, h))
#if 0
if (!t42_itulab_to_itulab(logging, (tdata_t) &outptr, &outsize, data, off, w, h, 3))
{
printf("Failed to convert to ITULAB\n");
return 1;
}
#endif
free(data);
data = (uint8_t *) outptr;
off = outsize;
......@@ -470,11 +473,12 @@ int main(int argc, char *argv[])
lab_to_srgb(&lab_param, data, data, w*h);
break;
case PHOTOMETRIC_ITULAB:
set_lab_illuminant(&lab_param, 0.9638f, 1.0f, 0.8245f);
/* The default luminant is D50 */
set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f);
set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE);
break;
}
if (!t42_srgb_to_itulab(logging, &lab_param, (tdata_t) &outptr, &outsize, data, off, w, h))
//if (!t42_srgb_to_itulab_jpeg(logging, &lab_param, (tdata_t) &outptr, &outsize, data, off, w, h, 3))
{
printf("Failed to convert to ITULAB\n");
return 1;
......@@ -532,7 +536,8 @@ int main(int argc, char *argv[])
bytes_per_row = (bits_per_pixel + 7)/8;
bytes_per_row *= w*samples_per_pixel;
totdata = h*bytes_per_row;
set_lab_illuminant(&lab_param, 0.9638f, 1.0f, 0.8245f);
/* The default luminant is D50 */
set_lab_illuminant(&lab_param, 96.422f, 100.000f, 82.521f);
set_lab_gamut(&lab_param, 0, 100, -85, 85, -75, 125, FALSE);
#if 0
start = rdtscll();
......@@ -551,7 +556,7 @@ int main(int argc, char *argv[])
#else
data2 = malloc(totdata);
start = rdtscll();
if (!t42_itulab_to_srgb(logging, &lab_param, data2, &off, data, off, &w, &h))
//if (!t42_itulab_jpeg_to_srgb(logging, &lab_param, data2, &off, data, off, &w, &h, &samples_per_pixel))
{
printf("Failed to convert from ITULAB\n");
return 1;
......
差异被折叠。
......@@ -37,8 +37,12 @@
#include "udptl.h"
#if !defined(FALSE)
#define FALSE 0
#endif
#if !defined(TRUE)
#define TRUE (!FALSE)
#endif
static int decode_length(const uint8_t *buf, int limit, int *len, int *pvalue)
{
......@@ -58,7 +62,7 @@ static int decode_length(const uint8_t *buf, int limit, int *len, int *pvalue)
return 0;
}
*pvalue = (buf[(*len)++] & 0x3F) << 14;
/* Indicate we have a fragment */
/* Indicate that we have a fragment */
return 1;
}
/*- End of function --------------------------------------------------------*/
......@@ -66,11 +70,13 @@ static int decode_length(const uint8_t *buf, int limit, int *len, int *pvalue)
static int decode_open_type(const uint8_t *buf, int limit, int *len, const uint8_t **p_object, int *p_num_octets)
{
int octet_cnt;
#if 0
int octet_idx;
int stat;
const uint8_t **pbuf;
for (octet_idx = 0, *p_num_octets = 0; ; octet_idx += octet_cnt)
*p_num_octets = 0;
for (octet_idx = 0; ; octet_idx += octet_cnt)
{
if ((stat = decode_length(buf, limit, len, &octet_cnt)) < 0)
return -1;
......@@ -89,6 +95,21 @@ static int decode_open_type(const uint8_t *buf, int limit, int *len, const uint8
if (stat == 0)
break;
}
#else
/* We do not deal with fragments, so there is no point in looping through them. Just say that something
fragmented is bad. */
if (decode_length(buf, limit, len, &octet_cnt) != 0)
return -1;
*p_num_octets = octet_cnt;
if (octet_cnt > 0)
{
/* Make sure the buffer contains at least the number of bits requested */
if ((*len + octet_cnt) > limit)
return -1;
*p_object = &buf[*len];
*len += octet_cnt;
}
#endif
return 0;
}
/*- End of function --------------------------------------------------------*/
......@@ -153,7 +174,6 @@ static int encode_open_type(uint8_t *buf, int *len, const uint8_t *data, int num
int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len)
{
int stat;
int stat2;
int i;
int j;
int k;
......@@ -216,16 +236,16 @@ int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len)
total_count = 0;
do
{
if ((stat2 = decode_length(buf, len, &ptr, &count)) < 0)
if ((stat = decode_length(buf, len, &ptr, &count)) < 0)
return -1;
for (i = 0; i < count; i++)
{
if ((stat = decode_open_type(buf, len, &ptr, &bufs[total_count + i], &lengths[total_count + i])) != 0)
if (decode_open_type(buf, len, &ptr, &bufs[total_count + i], &lengths[total_count + i]) != 0)
return -1;
}
total_count += count;
}
while (stat2 > 0);
while (stat > 0);
/* We should now be exactly at the end of the packet. If not, this is a fault. */
if (ptr != len)
return -1;
......@@ -246,6 +266,7 @@ int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len)
/* Save the new packet. Redundancy mode won't use this, but some systems will switch into
FEC mode after sending some redundant packets, and this may then be important. */
x = (seq_no - i) & UDPTL_BUF_MASK;
if (lengths[i - 1] > 0)
memcpy(s->rx[x].buf, bufs[i - 1], lengths[i - 1]);
s->rx[x].buf_len = lengths[i - 1];
s->rx[x].fec_len[0] = 0;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论