diff --git a/libs/spandsp/configure.ac b/libs/spandsp/configure.ac index f1bed65c51..22fccd6d25 100644 --- a/libs/spandsp/configure.ac +++ b/libs/spandsp/configure.ac @@ -238,10 +238,8 @@ AC_CHECK_HEADERS([FL/Fl.H]) AC_CHECK_HEADERS([FL/Fl_Overlay_Window.H]) AC_CHECK_HEADERS([FL/Fl_Light_Button.H]) AC_CHECK_HEADERS([FL/fl_draw.H]) -AC_CHECK_HEADERS([FL/Fl_Cartesian.H], [], [], [],[[#include -]]) -AC_CHECK_HEADERS([FL/Fl_Audio_Meter.H], [], [], [],[[#include -]]) +AC_CHECK_HEADERS([FL/Fl_Cartesian.H]) +AC_CHECK_HEADERS([FL/Fl_Audio_Meter.H]) AC_LANG([C]) @@ -520,6 +518,8 @@ if test "$enable_builtin_tiff" = "yes" ; then save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -I$abs_tiffdir/libtiff" AC_CHECK_HEADERS([tiffio.h]) + AC_CHECK_HEADERS([tif_dir.h], [], [], [#include +]) CFLAGS="$save_CFLAGS" COMP_VENDOR_CFLAGS="-I$abs_tiffdir/libtiff $COMP_VENDOR_CFLAGS" COMP_VENDOR_LDFLAGS="-L$abs_tiffdir/libtiff $COMP_VENDOR_LDFLAGS" @@ -527,8 +527,18 @@ if test "$enable_builtin_tiff" = "yes" ; then AC_DEFINE([HAVE_LIBTIFF], [1], [Define to 1 if you have the `tiff' library (-ltiff).]) else AC_CHECK_HEADERS([tiffio.h]) + AC_CHECK_HEADERS([tif_dir.h], [], [], [#include +]) AC_CHECK_LIB([tiff], [TIFFOpen], [TIFF_LIBS="-ltiff"], AC_MSG_ERROR("Cannot build without libtiff (does your system require a libtiff-devel package?)"), -lm) fi + +if test "$ac_cv_header_tif_dir_h" = "yes" ; then + AC_DEFINE([SPANDSP_SUPPORT_TIFF_FX], [1], [Support TIFF/FX in TIFF file handling]) + SPANDSP_SUPPORT_TIFF_FX="#define SPANDSP_SUPPORT_TIFF_FX" +else + SPANDSP_SUPPORT_TIFF_FX="#undef SPANDSP_SUPPORT_TIFF_FX" +fi + AC_CHECK_HEADERS([jpeglib.h]) AC_CHECK_LIB([jpeg], [jpeg_start_compress], [JPEG_LIBS="-ljpeg"]) @@ -551,6 +561,7 @@ AC_SUBST(SPANDSP_USE_EXPORT_CAPABILITY) AC_SUBST(SPANDSP_SUPPORT_T42) AC_SUBST(SPANDSP_SUPPORT_T43) AC_SUBST(SPANDSP_SUPPORT_V34) +AC_SUBST(SPANDSP_SUPPORT_TIFF_FX) AC_SUBST(INSERT_INTTYPES_HEADER) AC_SUBST(INSERT_STDINT_HEADER) AC_SUBST(INSERT_TGMATH_HEADER) diff --git a/libs/spandsp/src/spandsp.h.in b/libs/spandsp/src/spandsp.h.in index 0b1f7aec9b..8dcafa50e8 100644 --- a/libs/spandsp/src/spandsp.h.in +++ b/libs/spandsp/src/spandsp.h.in @@ -36,6 +36,7 @@ @SPANDSP_SUPPORT_T42@ @SPANDSP_SUPPORT_T43@ @SPANDSP_SUPPORT_V34@ +@SPANDSP_SUPPORT_TIFF_FX@ #include @INSERT_INTTYPES_HEADER@ diff --git a/libs/spandsp/src/spandsp/t4_tx.h b/libs/spandsp/src/spandsp/t4_tx.h index 7c100793c1..3eccc679c8 100644 --- a/libs/spandsp/src/spandsp/t4_tx.h +++ b/libs/spandsp/src/spandsp/t4_tx.h @@ -28,8 +28,6 @@ #if !defined(_SPANDSP_T4_TX_H_) #define _SPANDSP_T4_TX_H_ -#define SPANDSP_SUPPORT_TIFF_FX - /*! This function is a callback from the image decoders, to read the unencoded bi-level image, row by row. It is called for each row, with len set to the number of bytes per row expected. \return len for OK, or zero to indicate the end of the image data. */ @@ -41,8 +39,7 @@ typedef int (*t4_row_read_handler_t)(void *user_data, uint8_t buf[], size_t len) */ typedef struct t4_tx_state_s t4_tx_state_t; -#if defined(SPANDSP_SUPPORT_TIFF_FX) -/* TIFF-FX related extensions to the tag set supported by libtiff */ +/* TIFF-FX related extensions to the TIFF tag set */ /* Indexed(346) = 0, 1. SHORT @@ -55,7 +52,7 @@ Indexed(346) = 0, 1. SHORT profile supports palette-color images with the ITULAB encoding. The SamplesPerPixel value must be 1. -GlobalParametersIFD (400) IFD +GlobalParametersIFD (400) IFD/LONG An IFD containing global parameters. It is recommended that a TIFF writer place this field in the first IFD, where a TIFF reader would find it quickly. @@ -177,6 +174,9 @@ ImageLayer(34732) LONG 3: ... */ +/* Define the TIFF/FX tags to extend libtiff, when using a version of libtiff where this + stuff has not been merged. */ +#if defined(SPANDSP_SUPPORT_TIFF_FX) && !defined(TIFFTAG_FAXPROFILE) #define TIFFTAG_INDEXED 346 #define TIFFTAG_GLOBALPARAMETERSIFD 400 #define TIFFTAG_PROFILETYPE 401 diff --git a/libs/spandsp/src/t4_tx.c b/libs/spandsp/src/t4_tx.c index 8dde6e8e98..51aec0b00f 100644 --- a/libs/spandsp/src/t4_tx.c +++ b/libs/spandsp/src/t4_tx.c @@ -79,15 +79,15 @@ #include "faxfont.h" -#if 0 #if defined(SPANDSP_SUPPORT_TIFF_FX) #include #endif -#endif /*! The number of centimetres in one inch */ #define CM_PER_INCH 2.54f +static void t4_tx_set_image_length(t4_tx_state_t *s, int image_length); + #if defined(SPANDSP_SUPPORT_TIFF_FX) /* TIFF-FX related extensions to the tag set supported by libtiff */ static const TIFFFieldInfo tiff_fx_tiff_field_info[] = @@ -126,8 +126,6 @@ static TIFFField tiff_fx_tiff_fields[] = TIFFFieldArray tiff_fx_field_array = { tfiatOther, 0, 12, tiff_fx_tiff_fields }; #endif -static void t4_tx_set_image_length(t4_tx_state_t *s, int image_length); - static TIFFExtendProc _ParentExtender = NULL; static void TIFFFXDefaultDirectory(TIFF *tif) @@ -164,6 +162,7 @@ static int test_resolution(int res_unit, float actual, float expected) } /*- End of function --------------------------------------------------------*/ +#if defined(SPANDSP_SUPPORT_TIFF_FX) static int read_colour_map(t4_tx_state_t *s, int bits_per_sample) { int i; @@ -187,7 +186,7 @@ static int read_colour_map(t4_tx_state_t *s, int bits_per_sample) /* Sweep the colormap in the proper order */ for (i = 0; i < (1 << bits_per_sample); i++) { - s->colour_map[3*i] = (map_L[i] >> 8) & 0xFF; + s->colour_map[3*i + 0] = (map_L[i] >> 8) & 0xFF; s->colour_map[3*i + 1] = (map_a[i] >> 8) & 0xFF; s->colour_map[3*i + 2] = (map_b[i] >> 8) & 0xFF; span_log(&s->logging, SPAN_LOG_FLOW, "Map %3d - %5d %5d %5d\n", i, s->colour_map[3*i], s->colour_map[3*i + 1], s->colour_map[3*i + 2]); @@ -196,8 +195,8 @@ static int read_colour_map(t4_tx_state_t *s, int bits_per_sample) /* Sweep the colormap in the order that seems to work for l04x_02x.tif */ for (i = 0; i < (1 << bits_per_sample); i++) { - s->colour_map[i] = (map_L[i] >> 8) & 0xFF; - s->colour_map[256 + i] = (map_a[i] >> 8) & 0xFF; + s->colour_map[0*256 + i] = (map_L[i] >> 8) & 0xFF; + s->colour_map[1*256 + i] = (map_a[i] >> 8) & 0xFF; s->colour_map[2*256 + i] = (map_b[i] >> 8) & 0xFF; } #endif @@ -207,6 +206,7 @@ static int read_colour_map(t4_tx_state_t *s, int bits_per_sample) return 0; } /*- End of function --------------------------------------------------------*/ +#endif static int get_tiff_directory_info(t4_tx_state_t *s) { @@ -240,6 +240,7 @@ static int get_tiff_directory_info(t4_tx_state_t *s) {1200.0f/CM_PER_INCH, T4_Y_RESOLUTION_1200}, { -1.00f, -1} }; +#if defined(SPANDSP_SUPPORT_TIFF_FX) static const char *tiff_fx_fax_profiles[] = { "???", @@ -250,18 +251,19 @@ static int get_tiff_directory_info(t4_tx_state_t *s) "profile L", "profile M" }; - uint16_t res_unit; - uint8_t parm8; - uint16_t parm16; - uint32_t parm32; char *u; char uu[10]; + uint8_t parm8; + uint16_t parm16; +#endif + uint32_t parm32; float x_resolution; float y_resolution; int i; t4_tx_tiff_state_t *t; uint16_t bits_per_sample; uint16_t samples_per_pixel; + uint16_t res_unit; t = &s->tiff; bits_per_sample = 1;