summaryrefslogtreecommitdiff
path: root/tools/tiff2pdf.c
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@codelibre.net>2021-01-01 20:14:07 +0000
committerRoger Leigh <rleigh@codelibre.net>2021-01-21 23:14:13 +0000
commit39a74eede0455ec8ee334dcddf71f5354d508d8b (patch)
tree3f6515dfaa192da54d5dd731b9f90d32908b3cd5 /tools/tiff2pdf.c
parentaf604f119a7b23d0b14dc5940fc84e45616dee69 (diff)
downloadlibtiff-git-39a74eede0455ec8ee334dcddf71f5354d508d8b.tar.gz
Use standard C99 integer types
Diffstat (limited to 'tools/tiff2pdf.c')
-rw-r--r--tools/tiff2pdf.c418
1 files changed, 209 insertions, 209 deletions
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index df614bdf..2a4e40f1 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -121,9 +121,9 @@ typedef enum{
/* This struct defines a logical page of a TIFF. */
typedef struct {
tdir_t page_directory;
- uint32 page_number;
+ uint32_t page_number;
ttile_t page_tilecount;
- uint32 page_extra;
+ uint32_t page_extra;
} T2P_PAGE;
/* This struct defines a PDF rectangle's coordinates. */
@@ -143,12 +143,12 @@ typedef struct {
/* This struct defines information about the tiles on a PDF page. */
typedef struct {
ttile_t tiles_tilecount;
- uint32 tiles_tilewidth;
- uint32 tiles_tilelength;
- uint32 tiles_tilecountx;
- uint32 tiles_tilecounty;
- uint32 tiles_edgetilewidth;
- uint32 tiles_edgetilelength;
+ uint32_t tiles_tilewidth;
+ uint32_t tiles_tilelength;
+ uint32_t tiles_tilecountx;
+ uint32_t tiles_tilecounty;
+ uint32_t tiles_edgetilewidth;
+ uint32_t tiles_edgetilelength;
T2P_TILE* tiles_tiles;
} T2P_TILES;
@@ -158,24 +158,24 @@ typedef struct {
T2P_PAGE* tiff_pages;
T2P_TILES* tiff_tiles;
tdir_t tiff_pagecount;
- uint16 tiff_compression;
- uint16 tiff_photometric;
- uint16 tiff_fillorder;
- uint16 tiff_bitspersample;
- uint16 tiff_samplesperpixel;
- uint16 tiff_planar;
- uint32 tiff_width;
- uint32 tiff_length;
+ uint16_t tiff_compression;
+ uint16_t tiff_photometric;
+ uint16_t tiff_fillorder;
+ uint16_t tiff_bitspersample;
+ uint16_t tiff_samplesperpixel;
+ uint16_t tiff_planar;
+ uint32_t tiff_width;
+ uint32_t tiff_length;
float tiff_xres;
float tiff_yres;
- uint16 tiff_orientation;
+ uint16_t tiff_orientation;
toff_t tiff_dataoffset;
tsize_t tiff_datasize;
tsize_t tiff_maxdatasize;
- uint16 tiff_resunit;
- uint16 pdf_centimeters;
- uint16 pdf_overrideres;
- uint16 pdf_overridepagesize;
+ uint16_t tiff_resunit;
+ uint16_t pdf_centimeters;
+ uint16_t pdf_overrideres;
+ uint16_t pdf_overridepagesize;
float pdf_defaultxres;
float pdf_defaultyres;
float pdf_xres;
@@ -189,14 +189,14 @@ typedef struct {
int pdf_image_fillpage; /* 0 (default: no scaling, 1:scale imagesize to pagesize */
T2P_BOX pdf_mediabox;
T2P_BOX pdf_imagebox;
- uint16 pdf_majorversion;
- uint16 pdf_minorversion;
- uint32 pdf_catalog;
- uint32 pdf_pages;
- uint32 pdf_info;
- uint32 pdf_palettecs;
- uint16 pdf_fitwindow;
- uint32 pdf_startxref;
+ uint16_t pdf_majorversion;
+ uint16_t pdf_minorversion;
+ uint32_t pdf_catalog;
+ uint32_t pdf_pages;
+ uint32_t pdf_info;
+ uint32_t pdf_palettecs;
+ uint16_t pdf_fitwindow;
+ uint32_t pdf_startxref;
#define TIFF2PDF_FILEID_SIZE 33
char pdf_fileid[TIFF2PDF_FILEID_SIZE];
#define TIFF2PDF_DATETIME_SIZE 17
@@ -217,35 +217,35 @@ typedef struct {
char pdf_keywords[TIFF2PDF_KEYWORDS_SIZE];
int pdf_keywords_set;
t2p_cs_t pdf_colorspace;
- uint16 pdf_colorspace_invert;
- uint16 pdf_switchdecode;
- uint16 pdf_palettesize;
+ uint16_t pdf_colorspace_invert;
+ uint16_t pdf_switchdecode;
+ uint16_t pdf_palettesize;
unsigned char* pdf_palette;
int pdf_labrange[4];
t2p_compress_t pdf_defaultcompression;
- uint16 pdf_defaultcompressionquality;
+ uint16_t pdf_defaultcompressionquality;
t2p_compress_t pdf_compression;
- uint16 pdf_compressionquality; /* for deflate : 100 * zipquality + predictor */
- uint16 pdf_nopassthrough;
+ uint16_t pdf_compressionquality; /* for deflate : 100 * zipquality + predictor */
+ uint16_t pdf_nopassthrough;
t2p_transcode_t pdf_transcode;
t2p_sample_t pdf_sample;
- uint32* pdf_xrefoffsets;
- uint32 pdf_xrefcount;
+ uint32_t* pdf_xrefoffsets;
+ uint32_t pdf_xrefcount;
tdir_t pdf_page;
#ifdef OJPEG_SUPPORT
tdata_t pdf_ojpegdata;
- uint32 pdf_ojpegdatalength;
- uint32 pdf_ojpegiflength;
+ uint32_t pdf_ojpegdatalength;
+ uint32_t pdf_ojpegiflength;
#endif
float tiff_whitechromaticities[2];
float tiff_primarychromaticities[6];
float tiff_referenceblackwhite[2];
- uint16* tiff_transferfunction[3];
+ uint16_t* tiff_transferfunction[3];
int pdf_image_interpolate; /* 0 (default) : do not interpolate,
1 : interpolate */
- uint16 tiff_transferfunctioncount;
- uint32 pdf_icccs;
- uint32 tiff_iccprofilelength;
+ uint16_t tiff_transferfunctioncount;
+ uint32_t pdf_icccs;
+ uint32_t tiff_iccprofilelength;
tdata_t tiff_iccprofile;
/* fields for custom read/write procedures */
@@ -289,25 +289,25 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P*, TIFF*, TIFF*, ttile_t);
int t2p_process_ojpeg_tables(T2P*, TIFF*);
#endif
#ifdef JPEG_SUPPORT
-int t2p_process_jpeg_strip(unsigned char*, tsize_t*, unsigned char*, tsize_t, tsize_t*, tstrip_t, uint32);
+int t2p_process_jpeg_strip(unsigned char*, tsize_t*, unsigned char*, tsize_t, tsize_t*, tstrip_t, uint32_t);
#endif
-void t2p_tile_collapse_left(tdata_t, tsize_t, uint32, uint32, uint32);
+void t2p_tile_collapse_left(tdata_t, tsize_t, uint32_t, uint32_t, uint32_t);
void t2p_write_advance_directory(T2P*, TIFF*);
tsize_t t2p_sample_planar_separate_to_contig(T2P*, unsigned char*, unsigned char*, tsize_t);
tsize_t t2p_sample_realize_palette(T2P*, unsigned char*);
-tsize_t t2p_sample_abgr_to_rgb(tdata_t, uint32);
-tsize_t t2p_sample_rgba_to_rgb(tdata_t, uint32);
-tsize_t t2p_sample_rgbaa_to_rgb(tdata_t, uint32);
-tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t, uint32);
+tsize_t t2p_sample_abgr_to_rgb(tdata_t, uint32_t);
+tsize_t t2p_sample_rgba_to_rgb(tdata_t, uint32_t);
+tsize_t t2p_sample_rgbaa_to_rgb(tdata_t, uint32_t);
+tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t, uint32_t);
tsize_t t2p_write_pdf_header(T2P*, TIFF*);
-tsize_t t2p_write_pdf_obj_start(uint32, TIFF*);
+tsize_t t2p_write_pdf_obj_start(uint32_t, TIFF*);
tsize_t t2p_write_pdf_obj_end(TIFF*);
tsize_t t2p_write_pdf_name(const unsigned char*, TIFF*);
tsize_t t2p_write_pdf_string(const char*, TIFF*);
tsize_t t2p_write_pdf_stream(tdata_t, tsize_t, TIFF*);
tsize_t t2p_write_pdf_stream_start(TIFF*);
tsize_t t2p_write_pdf_stream_end(TIFF*);
-tsize_t t2p_write_pdf_stream_dict(tsize_t, uint32, TIFF*);
+tsize_t t2p_write_pdf_stream_dict(tsize_t, uint32_t, TIFF*);
tsize_t t2p_write_pdf_stream_dict_start(TIFF*);
tsize_t t2p_write_pdf_stream_dict_end(TIFF*);
tsize_t t2p_write_pdf_stream_length(tsize_t, TIFF*);
@@ -316,16 +316,16 @@ tsize_t t2p_write_pdf_info(T2P*, TIFF*, TIFF*);
void t2p_pdf_currenttime(T2P*);
void t2p_pdf_tifftime(T2P*, TIFF*);
tsize_t t2p_write_pdf_pages(T2P*, TIFF*);
-tsize_t t2p_write_pdf_page(uint32, T2P*, TIFF*);
+tsize_t t2p_write_pdf_page(uint32_t, T2P*, TIFF*);
void t2p_compose_pdf_page(T2P*);
-void t2p_compose_pdf_page_orient(T2P_BOX*, uint16);
-void t2p_compose_pdf_page_orient_flip(T2P_BOX*, uint16);
+void t2p_compose_pdf_page_orient(T2P_BOX*, uint16_t);
+void t2p_compose_pdf_page_orient_flip(T2P_BOX*, uint16_t);
tsize_t t2p_write_pdf_page_content(T2P*, TIFF*);
tsize_t t2p_write_pdf_xobject_stream_dict(ttile_t, T2P*, TIFF*);
tsize_t t2p_write_pdf_xobject_cs(T2P*, TIFF*);
tsize_t t2p_write_pdf_transfer(T2P*, TIFF*);
-tsize_t t2p_write_pdf_transfer_dict(T2P*, TIFF*, uint16);
-tsize_t t2p_write_pdf_transfer_stream(T2P*, TIFF*, uint16);
+tsize_t t2p_write_pdf_transfer_dict(T2P*, TIFF*, uint16_t);
+tsize_t t2p_write_pdf_transfer_stream(T2P*, TIFF*, uint16_t);
tsize_t t2p_write_pdf_xobject_calcs(T2P*, TIFF*);
tsize_t t2p_write_pdf_xobject_icccs(T2P*, TIFF*);
tsize_t t2p_write_pdf_xobject_icccs_dict(T2P*, TIFF*);
@@ -383,7 +383,7 @@ t2pWriteFile(TIFF *tif, tdata_t data, tmsize_t size)
return -1;
}
-static uint64
+static uint64_t
t2pSeekFile(TIFF *tif, toff_t offset, int whence)
{
thandle_t client = TIFFClientdata(tif);
@@ -412,8 +412,8 @@ t2p_writeproc(thandle_t handle, tdata_t data, tmsize_t size)
return size;
}
-static uint64
-t2p_seekproc(thandle_t handle, uint64 offset, int whence)
+static uint64_t
+t2p_seekproc(thandle_t handle, uint64_t offset, int whence)
{
T2P *t2p = (T2P*) handle;
if (t2p->outputdisable <= 0 && t2p->outputfile)
@@ -428,7 +428,7 @@ t2p_closeproc(thandle_t handle)
return fclose(t2p->outputfile);
}
-static uint64
+static uint64_t
t2p_sizeproc(thandle_t handle)
{
(void) handle;
@@ -449,10 +449,10 @@ t2p_unmapproc(thandle_t handle, void *data, toff_t offset)
}
#if defined(OJPEG_SUPPORT) || defined(JPEG_SUPPORT)
-static uint64
-checkAdd64(uint64 summand1, uint64 summand2, T2P* t2p)
+static uint64_t
+checkAdd64(uint64_t summand1, uint64_t summand2, T2P* t2p)
{
- uint64 bytes = summand1 + summand2;
+ uint64_t bytes = summand1 + summand2;
if (bytes < summand1) {
TIFFError(TIFF2PDF_MODULE, "Integer overflow");
@@ -464,10 +464,10 @@ checkAdd64(uint64 summand1, uint64 summand2, T2P* t2p)
}
#endif /* defined(OJPEG_SUPPORT) || defined(JPEG_SUPPORT) */
-static uint64
-checkMultiply64(uint64 first, uint64 second, T2P* t2p)
+static uint64_t
+checkMultiply64(uint64_t first, uint64_t second, T2P* t2p)
{
- uint64 bytes = first * second;
+ uint64_t bytes = first * second;
if (second && bytes / second != first) {
TIFFError(TIFF2PDF_MODULE, "Integer overflow");
@@ -1027,7 +1027,7 @@ void t2p_validate(T2P* t2p){
#endif
#ifdef ZIP_SUPPORT
if(t2p->pdf_defaultcompression==T2P_COMPRESS_ZIP){
- uint16 m=t2p->pdf_defaultcompressionquality%100;
+ uint16_t m= t2p->pdf_defaultcompressionquality % 100;
if(t2p->pdf_defaultcompressionquality/100 > 9 ||
(m>1 && m<10) || m>15){
t2p->pdf_defaultcompressionquality=0;
@@ -1061,11 +1061,11 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){
tdir_t directorycount=0;
tdir_t i=0;
- uint16 pagen=0;
- uint16 paged=0;
- uint16 xuint16=0;
- uint16 tiff_transferfunctioncount=0;
- uint16* tiff_transferfunction[3];
+ uint16_t pagen=0;
+ uint16_t paged=0;
+ uint16_t xuint16=0;
+ uint16_t tiff_transferfunctioncount=0;
+ uint16_t* tiff_transferfunction[3];
directorycount=TIFFNumberOfDirectories(input);
if(directorycount > TIFF_DIR_MAX) {
@@ -1080,8 +1080,8 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){
if(t2p->tiff_pages==NULL){
TIFFError(
TIFF2PDF_MODULE,
- "Can't allocate %" TIFF_SIZE_FORMAT " bytes of memory for tiff_pages array, %s",
- (TIFF_SIZE_T) directorycount * sizeof(T2P_PAGE),
+ "Can't allocate %zu bytes of memory for tiff_pages array, %s",
+ (size_t) directorycount * sizeof(T2P_PAGE),
TIFFFileName(input));
t2p->t2p_error = T2P_ERR_ERROR;
return;
@@ -1091,15 +1091,15 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){
if(t2p->tiff_tiles==NULL){
TIFFError(
TIFF2PDF_MODULE,
- "Can't allocate %" TIFF_SIZE_FORMAT " bytes of memory for tiff_tiles array, %s",
- (TIFF_SIZE_T) directorycount * sizeof(T2P_TILES),
+ "Can't allocate %zu bytes of memory for tiff_tiles array, %s",
+ (size_t) directorycount * sizeof(T2P_TILES),
TIFFFileName(input));
t2p->t2p_error = T2P_ERR_ERROR;
return;
}
_TIFFmemset( t2p->tiff_tiles, 0x00, directorycount * sizeof(T2P_TILES));
for(i=0;i<directorycount;i++){
- uint32 subfiletype = 0;
+ uint32_t subfiletype = 0;
if(!TIFFSetDirectory(input, i)){
TIFFError(
@@ -1178,8 +1178,8 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){
&(tiff_transferfunction[1]),
&(tiff_transferfunction[2]))) {
- if((tiff_transferfunction[1] != (uint16*) NULL) &&
- (tiff_transferfunction[2] != (uint16*) NULL)
+ if((tiff_transferfunction[1] != (uint16_t*) NULL) &&
+ (tiff_transferfunction[2] != (uint16_t*) NULL)
) {
tiff_transferfunctioncount=3;
} else {
@@ -1264,8 +1264,8 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){
if( t2p->tiff_tiles[i].tiles_tiles == NULL){
TIFFError(
TIFF2PDF_MODULE,
- "Can't allocate %" TIFF_SIZE_FORMAT " bytes of memory for t2p_read_tiff_init, %s",
- (TIFF_SIZE_T) t2p->tiff_tiles[i].tiles_tilecount * sizeof(T2P_TILE),
+ "Can't allocate %zu bytes of memory for t2p_read_tiff_init, %s",
+ (size_t) t2p->tiff_tiles[i].tiles_tilecount * sizeof(T2P_TILE),
TIFFFileName(input));
t2p->t2p_error = T2P_ERR_ERROR;
return;
@@ -1285,9 +1285,9 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){
int t2p_cmp_t2p_page(const void* e1, const void* e2){
int d;
- d = (int32)(((T2P_PAGE*)e1)->page_number) - (int32)(((T2P_PAGE*)e2)->page_number);
+ d = (int32_t)(((T2P_PAGE*)e1)->page_number) - (int32_t)(((T2P_PAGE*)e2)->page_number);
if(d == 0){
- d = (int32)(((T2P_PAGE*)e1)->page_directory) - (int32)(((T2P_PAGE*)e2)->page_directory);
+ d = (int32_t)(((T2P_PAGE*)e1)->page_directory) - (int32_t)(((T2P_PAGE*)e2)->page_directory);
}
return d;
}
@@ -1307,12 +1307,12 @@ int t2p_cmp_t2p_page(const void* e1, const void* e2){
void t2p_read_tiff_data(T2P* t2p, TIFF* input){
int i=0;
- uint16* r = NULL;
- uint16* g = NULL;
- uint16* b = NULL;
- uint16* a = NULL;
- uint16 xuint16;
- uint16* xuint16p;
+ uint16_t* r = NULL;
+ uint16_t* g = NULL;
+ uint16_t* b = NULL;
+ uint16_t* a = NULL;
+ uint16_t xuint16;
+ uint16_t* xuint16p;
float* xfloatp;
t2p->pdf_transcode = T2P_TRANSCODE_ENCODE;
@@ -1819,7 +1819,7 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){
if(t2p->tiff_compression== COMPRESSION_ADOBE_DEFLATE
|| t2p->tiff_compression==COMPRESSION_DEFLATE){
if(TIFFIsTiled(input) || (TIFFNumberOfStrips(input)==1) ){
- uint16 predictor;
+ uint16_t predictor;
t2p->pdf_transcode = T2P_TRANSCODE_RAW;
t2p->pdf_compression=T2P_COMPRESS_ZIP;
TIFFGetField(input, TIFFTAG_PREDICTOR, &predictor);
@@ -1894,8 +1894,8 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){
&(t2p->tiff_transferfunction[0]),
&(t2p->tiff_transferfunction[1]),
&(t2p->tiff_transferfunction[2]))) {
- if((t2p->tiff_transferfunction[1] != (uint16*) NULL) &&
- (t2p->tiff_transferfunction[2] != (uint16*) NULL)
+ if((t2p->tiff_transferfunction[1] != (uint16_t*) NULL) &&
+ (t2p->tiff_transferfunction[2] != (uint16_t*) NULL)
) {
t2p->tiff_transferfunctioncount=3;
} else {
@@ -1958,8 +1958,8 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* input){
/**
* checks for overflow
*/
-static void t2p_set_tiff_datasize(T2P* t2p, uint64 k) {
- if (k != (uint64)(tmsize_t)k || (tmsize_t)k < 0) {
+static void t2p_set_tiff_datasize(T2P* t2p, uint64_t k) {
+ if (k != (uint64_t)(tmsize_t)k || (tmsize_t)k < 0) {
TIFFError(TIFF2PDF_MODULE, "Integer overflow");
t2p->t2p_error = T2P_ERR_ERROR;
return;
@@ -1973,13 +1973,13 @@ static void t2p_set_tiff_datasize(T2P* t2p, uint64 k) {
*/
void t2p_read_tiff_size(T2P* t2p, TIFF* input){
- uint64* sbc=NULL;
+ uint64_t* sbc=NULL;
#if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT)
unsigned char* jpt=NULL;
tstrip_t i=0;
tstrip_t stripcount=0;
#endif
- uint64 k = 0;
+ uint64_t k = 0;
if(t2p->pdf_transcode == T2P_TRANSCODE_RAW){
#if defined(CCITT_SUPPORT) || defined(ZIP_SUPPORT)
@@ -2012,7 +2012,7 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){
if(TIFFGetField(input, TIFFTAG_JPEGIFOFFSET, &(t2p->tiff_dataoffset))){
if(t2p->tiff_dataoffset != 0){
if(TIFFGetField(input, TIFFTAG_JPEGIFBYTECOUNT, &(t2p->tiff_datasize))!=0){
- if((uint64)t2p->tiff_datasize < k) {
+ if((uint64_t)t2p->tiff_datasize < k) {
TIFFWarning(TIFF2PDF_MODULE,
"Input file %s has short JPEG interchange file byte count",
TIFFFileName(input));
@@ -2043,7 +2043,7 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){
#endif
#ifdef JPEG_SUPPORT
if(t2p->tiff_compression == COMPRESSION_JPEG) {
- uint32 count = 0;
+ uint32_t count = 0;
if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0 ){
if(count > 4){
k += count;
@@ -2102,12 +2102,12 @@ void t2p_read_tiff_size(T2P* t2p, TIFF* input){
void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){
- uint64* tbc = NULL;
- uint16 edge=0;
+ uint64_t* tbc = NULL;
+ uint16_t edge=0;
#ifdef JPEG_SUPPORT
unsigned char* jpt;
#endif
- uint64 k;
+ uint64_t k;
edge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile);
@@ -2134,7 +2134,7 @@ void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){
#endif
#ifdef JPEG_SUPPORT
if(t2p->tiff_compression==COMPRESSION_JPEG) {
- uint32 count = 0;
+ uint32_t count = 0;
if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt)!=0){
if(count > 4){
k = checkAdd64(k, count, t2p);
@@ -2237,18 +2237,18 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){
tsize_t sepstripsize=0;
#ifdef OJPEG_SUPPORT
toff_t inputoffset=0;
- uint16 h_samp=1;
- uint16 v_samp=1;
- uint16 ri=1;
- uint32 rows=0;
+ uint16_t h_samp=1;
+ uint16_t v_samp=1;
+ uint16_t ri=1;
+ uint32_t rows=0;
#endif /* ifdef OJPEG_SUPPORT */
#ifdef JPEG_SUPPORT
unsigned char* jpt;
float* xfloatp;
- uint64* sbc;
+ uint64_t* sbc;
unsigned char* stripbuffer;
tsize_t striplength=0;
- uint32 max_striplength=0;
+ uint32_t max_striplength=0;
#endif /* ifdef JPEG_SUPPORT */
/* Fail if prior error (in particular, can't trust tiff_datasize) */
@@ -2456,7 +2456,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){
#endif /* ifdef OJPEG_SUPPORT */
#ifdef JPEG_SUPPORT
if(t2p->tiff_compression == COMPRESSION_JPEG) {
- uint32 count = 0;
+ uint32_t count = 0;
buffer = (unsigned char*)
_TIFFmalloc(t2p->tiff_datasize);
if(buffer==NULL){
@@ -2698,7 +2698,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){
input,
t2p->tiff_width,
t2p->tiff_length,
- (uint32*)buffer,
+ (uint32_t*)buffer,
ORIENTATION_TOPLEFT,
0)){
TIFFError(TIFF2PDF_MODULE,
@@ -2744,7 +2744,7 @@ dataready:
#ifdef JPEG_SUPPORT
case T2P_COMPRESS_JPEG:
if(t2p->tiff_photometric==PHOTOMETRIC_YCBCR) {
- uint16 hor = 0, ver = 0;
+ uint16_t hor = 0, ver = 0;
if (TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &hor, &ver) !=0 ) {
if(hor != 0 && ver != 0){
TIFFSetField(output, TIFFTAG_YCBCRSUBSAMPLING, hor, ver);
@@ -2846,14 +2846,14 @@ dataready:
tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_t tile){
- uint16 edge=0;
+ uint16_t edge=0;
tsize_t written=0;
unsigned char* buffer=NULL;
tsize_t bufferoffset=0;
unsigned char* samplebuffer=NULL;
tsize_t samplebufferoffset=0;
tsize_t read=0;
- uint16 i=0;
+ uint16_t i=0;
ttile_t tilecount=0;
/* tsize_t tilesize=0; */
ttile_t septilecount=0;
@@ -2861,7 +2861,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_
#ifdef JPEG_SUPPORT
unsigned char* jpt;
float* xfloatp;
- uint32 xuint32=0;
+ uint32_t xuint32=0;
#endif
/* Fail if prior error (in particular, can't trust tiff_datasize) */
@@ -2991,13 +2991,13 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_
#ifdef JPEG_SUPPORT
if(t2p->tiff_compression == COMPRESSION_JPEG){
unsigned char table_end[2];
- uint32 count = 0;
+ uint32_t count = 0;
buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize);
if(buffer==NULL){
TIFFError(TIFF2PDF_MODULE,
- "Can't allocate %" TIFF_SIZE_FORMAT " bytes of memory "
+ "Can't allocate %zu bytes of memory "
"for t2p_readwrite_pdf_image_tile, %s",
- (TIFF_SIZE_T) t2p->tiff_datasize,
+ (size_t) t2p->tiff_datasize,
TIFFFileName(input));
t2p->t2p_error = T2P_ERR_ERROR;
return(0);
@@ -3186,7 +3186,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_
}
if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile) != 0){
- if ((uint64)t2p->tiff_datasize < (uint64)TIFFTileRowSize(input) * (uint64)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength) {
+ if ((uint64_t)t2p->tiff_datasize < (uint64_t)TIFFTileRowSize(input) * (uint64_t)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength) {
/* we don't know how to handle PLANARCONFIG_CONTIG, PHOTOMETRIC_YCBCR with 3 samples per pixel */
TIFFWarning(
TIFF2PDF_MODULE,
@@ -3251,7 +3251,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_
#ifdef JPEG_SUPPORT
case T2P_COMPRESS_JPEG:
if (t2p->tiff_photometric==PHOTOMETRIC_YCBCR) {
- uint16 hor = 0, ver = 0;
+ uint16_t hor = 0, ver = 0;
if (TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &hor, &ver)!=0) {
if (hor != 0 && ver != 0) {
TIFFSetField(output, TIFFTAG_YCBCRSUBSAMPLING, hor, ver);
@@ -3305,8 +3305,8 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_
if (TIFFStripSize(output) > t2p->tiff_datasize) {
TIFFError(TIFF2PDF_MODULE,
- "Size mismatch input %" TIFF_SSIZE_FORMAT ", output %" TIFF_SSIZE_FORMAT,
- t2p->tiff_datasize, TIFFStripSize(output));
+ "Size mismatch input %" PRId64 ", output %" PRId64,
+ (int64_t) t2p->tiff_datasize, (int64_t) TIFFStripSize(output));
_TIFFfree(buffer);
t2p->t2p_error = T2P_ERR_ERROR;
return(0);
@@ -3334,26 +3334,26 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_
#ifdef OJPEG_SUPPORT
int t2p_process_ojpeg_tables(T2P* t2p, TIFF* input){
- uint16 proc=0;
+ uint16_t proc=0;
void* q;
- uint32 q_length=0;
+ uint32_t q_length=0;
void* dc;
- uint32 dc_length=0;
+ uint32_t dc_length=0;
void* ac;
- uint32 ac_length=0;
- uint16* lp;
- uint16* pt;
- uint16 h_samp=1;
- uint16 v_samp=1;
+ uint32_t ac_length=0;
+ uint16_t* lp;
+ uint16_t* pt;
+ uint16_t h_samp=1;
+ uint16_t v_samp=1;
unsigned char* ojpegdata;
- uint16 table_count;
- uint32 offset_table;
- uint32 offset_ms_l;
- uint32 code_count;
- uint32 i=0;
- uint32 dest=0;
- uint16 ri=0;
- uint32 rows=0;
+ uint16_t table_count;
+ uint32_t offset_table;
+ uint32_t offset_ms_l;
+ uint32_t code_count;
+ uint32_t i=0;
+ uint32_t dest=0;
+ uint16_t ri=0;
+ uint32_t rows=0;
if(!TIFFGetField(input, TIFFTAG_JPEGPROC, &proc)){
TIFFError(TIFF2PDF_MODULE,
@@ -3579,21 +3579,21 @@ int t2p_process_ojpeg_tables(T2P* t2p, TIFF* input){
#ifdef JPEG_SUPPORT
int t2p_process_jpeg_strip(
- unsigned char* strip,
- tsize_t* striplength,
- unsigned char* buffer,
- tsize_t buffersize,
- tsize_t* bufferoffset,
- tstrip_t no,
- uint32 height){
+ unsigned char* strip,
+ tsize_t* striplength,
+ unsigned char* buffer,
+ tsize_t buffersize,
+ tsize_t* bufferoffset,
+ tstrip_t no,
+ uint32_t height){
tsize_t i=0;
while (i < *striplength) {
tsize_t datalen;
- uint16 ri;
- uint16 v_samp;
- uint16 h_samp;
+ uint16_t ri;
+ uint16_t v_samp;
+ uint16_t h_samp;
int j;
int ncomp;
@@ -3641,7 +3641,7 @@ int t2p_process_jpeg_strip(
if( *bufferoffset + 11 + 3*(ncomp-1) >= buffersize )
return(0);
for(j=0;j<ncomp;j++){
- uint16 samp = buffer[*bufferoffset+11+(3*j)];
+ uint16_t samp = buffer[*bufferoffset + 11 + (3 * j)];
if( (samp>>4) > h_samp)
h_samp = (samp>>4);
if( (samp & 0x0f) > v_samp)
@@ -3649,12 +3649,12 @@ int t2p_process_jpeg_strip(
}
v_samp*=8;
h_samp*=8;
- ri=((( ((uint16)(buffer[*bufferoffset+5])<<8) |
- (uint16)(buffer[*bufferoffset+6]) )+v_samp-1)/
- v_samp);
- ri*=((( ((uint16)(buffer[*bufferoffset+7])<<8) |
- (uint16)(buffer[*bufferoffset+8]) )+h_samp-1)/
- h_samp);
+ ri=(((((uint16_t)(buffer[*bufferoffset + 5]) << 8) |
+ (uint16_t)(buffer[*bufferoffset + 6]) ) + v_samp - 1) /
+ v_samp);
+ ri*=(((((uint16_t)(buffer[*bufferoffset + 7]) << 8) |
+ (uint16_t)(buffer[*bufferoffset + 8]) ) + h_samp - 1) /
+ h_samp);
buffer[*bufferoffset+5]=
(unsigned char) ((height>>8) & 0xff);
buffer[*bufferoffset+6]=
@@ -3713,13 +3713,13 @@ int t2p_process_jpeg_strip(
tilelength buffer of samples.
*/
void t2p_tile_collapse_left(
- tdata_t buffer,
- tsize_t scanwidth,
- uint32 tilewidth,
- uint32 edgetilewidth,
- uint32 tilelength){
+ tdata_t buffer,
+ tsize_t scanwidth,
+ uint32_t tilewidth,
+ uint32_t edgetilewidth,
+ uint32_t tilelength){
- uint32 i;
+ uint32_t i;
tsize_t edgescanwidth=0;
edgescanwidth = (scanwidth * edgetilewidth + (tilewidth - 1))/ tilewidth;
@@ -3778,12 +3778,12 @@ tsize_t t2p_sample_planar_separate_to_contig(
tsize_t t2p_sample_realize_palette(T2P* t2p, unsigned char* buffer){
- uint32 sample_count=0;
- uint16 component_count=0;
- uint32 palette_offset=0;
- uint32 sample_offset=0;
- uint32 i=0;
- uint32 j=0;
+ uint32_t sample_count=0;
+ uint16_t component_count=0;
+ uint32_t palette_offset=0;
+ uint32_t sample_offset=0;
+ uint32_t i=0;
+ uint32_t j=0;
size_t data_size;
sample_count=t2p->tiff_width*t2p->tiff_length;
component_count=t2p->tiff_samplesperpixel;
@@ -3818,13 +3818,13 @@ tsize_t t2p_sample_realize_palette(T2P* t2p, unsigned char* buffer){
into RGB interleaved data, discarding A.
*/
-tsize_t t2p_sample_abgr_to_rgb(tdata_t data, uint32 samplecount)
+tsize_t t2p_sample_abgr_to_rgb(tdata_t data, uint32_t samplecount)
{
- uint32 i=0;
- uint32 sample=0;
+ uint32_t i=0;
+ uint32_t sample=0;
for(i=0;i<samplecount;i++){
- sample=((uint32*)data)[i];
+ sample=((uint32_t*)data)[i];
((char*)data)[i*3]= (char) (sample & 0xff);
((char*)data)[i*3+1]= (char) ((sample>>8) & 0xff);
((char*)data)[i*3+2]= (char) ((sample>>16) & 0xff);
@@ -3839,18 +3839,18 @@ tsize_t t2p_sample_abgr_to_rgb(tdata_t data, uint32 samplecount)
*/
tsize_t
-t2p_sample_rgbaa_to_rgb(tdata_t data, uint32 samplecount)
+t2p_sample_rgbaa_to_rgb(tdata_t data, uint32_t samplecount)
{
- uint32 i;
+ uint32_t i;
/* For the 3 first samples, there is overlap between source and
* destination, so use memmove().
* See http://bugzilla.maptools.org/show_bug.cgi?id=2577
*/
for(i = 0; i < 3 && i < samplecount; i++)
- memmove((uint8*)data + i * 3, (uint8*)data + i * 4, 3);
+ memmove((uint8_t*)data + i * 3, (uint8_t*)data + i * 4, 3);
for(; i < samplecount; i++)
- memcpy((uint8*)data + i * 3, (uint8*)data + i * 4, 3);
+ memcpy((uint8_t*)data + i * 3, (uint8_t*)data + i * 4, 3);
return(i * 3);
}
@@ -3861,18 +3861,18 @@ t2p_sample_rgbaa_to_rgb(tdata_t data, uint32 samplecount)
*/
tsize_t
-t2p_sample_rgba_to_rgb(tdata_t data, uint32 samplecount)
+t2p_sample_rgba_to_rgb(tdata_t data, uint32_t samplecount)
{
- uint32 i = 0;
- uint32 sample = 0;
- uint8 alpha = 0;
+ uint32_t i = 0;
+ uint32_t sample = 0;
+ uint8_t alpha = 0;
for (i = 0; i < samplecount; i++) {
- sample=((uint32*)data)[i];
- alpha=(uint8)((255 - ((sample >> 24) & 0xff)));
- ((uint8 *)data)[i * 3] = (uint8) ((sample >> 16) & 0xff) + alpha;
- ((uint8 *)data)[i * 3 + 1] = (uint8) ((sample >> 8) & 0xff) + alpha;
- ((uint8 *)data)[i * 3 + 2] = (uint8) (sample & 0xff) + alpha;
+ sample=((uint32_t*)data)[i];
+ alpha=(uint8_t)((255 - ((sample >> 24) & 0xff)));
+ ((uint8_t *)data)[i * 3] = (uint8_t) ((sample >> 16) & 0xff) + alpha;
+ ((uint8_t *)data)[i * 3 + 1] = (uint8_t) ((sample >> 8) & 0xff) + alpha;
+ ((uint8_t *)data)[i * 3 + 2] = (uint8_t) (sample & 0xff) + alpha;
}
return (i * 3);
@@ -3883,9 +3883,9 @@ t2p_sample_rgba_to_rgb(tdata_t data, uint32 samplecount)
to unsigned.
*/
-tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t buffer, uint32 samplecount){
+tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t buffer, uint32_t samplecount){
- uint32 i=0;
+ uint32_t i=0;
for(i=0;i<samplecount;i++){
if( (((unsigned char*)buffer)[(i*3)+1] & 0x80) !=0){
@@ -3929,7 +3929,7 @@ tsize_t t2p_write_pdf_header(T2P* t2p, TIFF* output){
This function writes the beginning of a PDF object to output.
*/
-tsize_t t2p_write_pdf_obj_start(uint32 number, TIFF* output){
+tsize_t t2p_write_pdf_obj_start(uint32_t number, TIFF* output){
tsize_t written=0;
char buffer[32];
@@ -3963,9 +3963,9 @@ tsize_t t2p_write_pdf_obj_end(TIFF* output){
tsize_t t2p_write_pdf_name(const unsigned char* name, TIFF* output){
tsize_t written=0;
- uint32 i=0;
+ uint32_t i=0;
char buffer[64];
- uint16 nextchar=0;
+ uint16_t nextchar=0;
size_t namelen=0;
namelen = strlen((char *)name);
@@ -4061,7 +4061,7 @@ tsize_t t2p_write_pdf_name(const unsigned char* name, TIFF* output){
tsize_t t2p_write_pdf_string(const char* pdfstr, TIFF* output)
{
tsize_t written = 0;
- uint32 i = 0;
+ uint32_t i = 0;
char buffer[64];
size_t len = 0;
@@ -4151,7 +4151,7 @@ tsize_t t2p_write_pdf_stream_end(TIFF* output){
This function writes a stream dictionary for a PDF stream to output.
*/
-tsize_t t2p_write_pdf_stream_dict(tsize_t len, uint32 number, TIFF* output){
+tsize_t t2p_write_pdf_stream_dict(tsize_t len, uint32_t number, TIFF* output){
tsize_t written=0;
char buffer[32];
@@ -4428,7 +4428,7 @@ tsize_t t2p_write_pdf_pages(T2P* t2p, TIFF* output)
This function writes a PDF Page structure to output.
*/
-tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){
+tsize_t t2p_write_pdf_page(uint32_t object, T2P* t2p, TIFF* output){
unsigned int i=0;
tsize_t written=0;
@@ -4531,14 +4531,14 @@ tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){
void t2p_compose_pdf_page(T2P* t2p){
- uint32 i=0;
- uint32 i2=0;
+ uint32_t i=0;
+ uint32_t i2=0;
T2P_TILE* tiles=NULL;
T2P_BOX* boxp=NULL;
- uint32 tilecountx=0;
- uint32 tilecounty=0;
- uint32 tilewidth=0;
- uint32 tilelength=0;
+ uint32_t tilecountx=0;
+ uint32_t tilecounty=0;
+ uint32_t tilewidth=0;
+ uint32_t tilelength=0;
int istiled=0;
float f=0;
float width_ratio=0;
@@ -4737,7 +4737,7 @@ void t2p_compose_pdf_page(T2P* t2p){
return;
}
-void t2p_compose_pdf_page_orient(T2P_BOX* boxp, uint16 orientation){
+void t2p_compose_pdf_page_orient(T2P_BOX* boxp, uint16_t orientation){
float m1[9];
float f=0.0;
@@ -4812,7 +4812,7 @@ void t2p_compose_pdf_page_orient(T2P_BOX* boxp, uint16 orientation){
return;
}
-void t2p_compose_pdf_page_orient_flip(T2P_BOX* boxp, uint16 orientation){
+void t2p_compose_pdf_page_orient_flip(T2P_BOX* boxp, uint16_t orientation){
float m1[9];
float f=0.0;
@@ -5120,7 +5120,7 @@ tsize_t t2p_write_pdf_transfer(T2P* t2p, TIFF* output){
return(written);
}
-tsize_t t2p_write_pdf_transfer_dict(T2P* t2p, TIFF* output, uint16 i){
+tsize_t t2p_write_pdf_transfer_dict(T2P* t2p, TIFF* output, uint16_t i){
tsize_t written=0;
char buffer[32];
@@ -5139,7 +5139,7 @@ tsize_t t2p_write_pdf_transfer_dict(T2P* t2p, TIFF* output, uint16 i){
return(written);
}
-tsize_t t2p_write_pdf_transfer_stream(T2P* t2p, TIFF* output, uint16 i){
+tsize_t t2p_write_pdf_transfer_stream(T2P* t2p, TIFF* output, uint16_t i){
tsize_t written=0;
@@ -5448,7 +5448,7 @@ tsize_t t2p_write_pdf_xreftable(T2P* t2p, TIFF* output){
tsize_t written=0;
char buffer[64];
int buflen=0;
- uint32 i=0;
+ uint32_t i=0;
written += t2pWriteFile(output, (tdata_t) "xref\n0 ", 7);
buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(t2p->pdf_xrefcount + 1));
@@ -5551,16 +5551,16 @@ tsize_t t2p_write_pdf(T2P* t2p, TIFF* input, TIFF* output){
tsize_t written=0;
ttile_t i2=0;
tsize_t streamlen=0;
- uint16 i=0;
+ uint16_t i=0;
t2p_read_tiff_init(t2p, input);
if(t2p->t2p_error!=T2P_ERR_OK){return(0);}
- t2p->pdf_xrefoffsets= (uint32*) _TIFFmalloc(TIFFSafeMultiply(tmsize_t,t2p->pdf_xrefcount,sizeof(uint32)) );
+ t2p->pdf_xrefoffsets= (uint32_t*) _TIFFmalloc(TIFFSafeMultiply(tmsize_t, t2p->pdf_xrefcount, sizeof(uint32_t)) );
if(t2p->pdf_xrefoffsets==NULL){
TIFFError(
TIFF2PDF_MODULE,
"Can't allocate %u bytes of memory for t2p_write_pdf",
- (unsigned int) (t2p->pdf_xrefcount * sizeof(uint32)) );
+ (unsigned int) (t2p->pdf_xrefcount * sizeof(uint32_t)) );
t2p->t2p_error = T2P_ERR_ERROR;
return(written);
}
@@ -5668,8 +5668,8 @@ tsize_t t2p_write_pdf(T2P* t2p, TIFF* input, TIFF* output){
t2p_read_tiff_size_tile(t2p, input, i2);
if (t2p->tiff_maxdatasize && (t2p->tiff_datasize > t2p->tiff_maxdatasize)) {
TIFFError(TIFF2PDF_MODULE,
- "Allocation of %" TIFF_UINT64_FORMAT " bytes is forbidden. Limit is %" TIFF_UINT64_FORMAT ". Use -m option to change limit",
- (uint64)t2p->tiff_datasize, (uint64)t2p->tiff_maxdatasize);
+ "Allocation of %" PRIu64 " bytes is forbidden. Limit is %" PRIu64 ". Use -m option to change limit",
+ (uint64_t)t2p->tiff_datasize, (uint64_t)t2p->tiff_maxdatasize);
t2p->t2p_error = T2P_ERR_ERROR;
return (0);
}
@@ -5698,8 +5698,8 @@ tsize_t t2p_write_pdf(T2P* t2p, TIFF* input, TIFF* output){
t2p_read_tiff_size(t2p, input);
if (t2p->tiff_maxdatasize && (t2p->tiff_datasize > t2p->tiff_maxdatasize)) {
TIFFError(TIFF2PDF_MODULE,
- "Allocation of %" TIFF_UINT64_FORMAT " bytes is forbidden. Limit is %" TIFF_UINT64_FORMAT ". Use -m option to change limit",
- (uint64)t2p->tiff_datasize, (uint64)t2p->tiff_maxdatasize);
+ "Allocation of %" PRIu64 " bytes is forbidden. Limit is %" PRIu64 ". Use -m option to change limit",
+ (uint64_t)t2p->tiff_datasize, (uint64_t)t2p->tiff_maxdatasize);
t2p->t2p_error = T2P_ERR_ERROR;
return (0);
}