summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libtiff/libtiff/tif_lzw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/libtiff/libtiff/tif_lzw.c')
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_lzw.c86
1 files changed, 37 insertions, 49 deletions
diff --git a/src/3rdparty/libtiff/libtiff/tif_lzw.c b/src/3rdparty/libtiff/libtiff/tif_lzw.c
index d92d0fd..c06aec4 100644
--- a/src/3rdparty/libtiff/libtiff/tif_lzw.c
+++ b/src/3rdparty/libtiff/libtiff/tif_lzw.c
@@ -107,7 +107,7 @@ typedef struct {
/*
* Encoding-specific state.
*/
-typedef uint16 hcode_t; /* codes fit in 16 bits */
+typedef uint16_t hcode_t; /* codes fit in 16 bits */
typedef struct {
long hash;
hcode_t code;
@@ -123,7 +123,7 @@ typedef struct code_ent {
unsigned char firstchar; /* first token of string */
} code_t;
-typedef int (*decodeFunc)(TIFF*, uint8*, tmsize_t, uint16);
+typedef int (*decodeFunc)(TIFF*, uint8_t*, tmsize_t, uint16_t);
typedef struct {
LZWBaseState base;
@@ -132,7 +132,7 @@ typedef struct {
long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */
long dec_restart; /* restart count */
#ifdef LZW_CHECKEOS
- uint64 dec_bitsleft; /* available bits in raw data */
+ uint64_t dec_bitsleft; /* available bits in raw data */
tmsize_t old_tif_rawcc; /* value of tif_rawcc at the end of the previous TIFLZWDecode() call */
#endif
decodeFunc dec_decode; /* regular or backwards compatible */
@@ -149,7 +149,7 @@ typedef struct {
long enc_ratio; /* current compression ratio */
long enc_incount; /* (input) data bytes encoded */
long enc_outcount; /* encoded (output) bytes */
- uint8* enc_rawlimit; /* bound on tif_rawdata buffer */
+ uint8_t* enc_rawlimit; /* bound on tif_rawdata buffer */
hash_t* enc_hashtab; /* kept separate for small machines */
} LZWCodecState;
@@ -157,9 +157,9 @@ typedef struct {
#define DecoderState(tif) ((LZWCodecState*) LZWState(tif))
#define EncoderState(tif) ((LZWCodecState*) LZWState(tif))
-static int LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s);
+static int LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s);
#ifdef LZW_COMPAT
-static int LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s);
+static int LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s);
#endif
static void cl_hash(LZWCodecState*);
@@ -173,9 +173,9 @@ static void cl_hash(LZWCodecState*);
* strip is suppose to be terminated with CODE_EOI.
*/
#define NextCode(_tif, _sp, _bp, _code, _get) { \
- if ((_sp)->dec_bitsleft < (uint64)nbits) { \
+ if ((_sp)->dec_bitsleft < (uint64_t)nbits) { \
TIFFWarningExt(_tif->tif_clientdata, module, \
- "LZWDecode: Strip %d not terminated with EOI code", \
+ "LZWDecode: Strip %"PRIu32" not terminated with EOI code", \
_tif->tif_curstrip); \
_code = CODE_EOI; \
} else { \
@@ -207,7 +207,7 @@ LZWSetupDecode(TIFF* tif)
* Allocate state block so tag methods have storage to record
* values.
*/
- tif->tif_data = (uint8*) _TIFFmalloc(sizeof(LZWCodecState));
+ tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof(LZWCodecState));
if (tif->tif_data == NULL)
{
TIFFErrorExt(tif->tif_clientdata, module, "No space for LZW state block");
@@ -256,7 +256,7 @@ LZWSetupDecode(TIFF* tif)
* Setup state for decoding a strip.
*/
static int
-LZWPreDecode(TIFF* tif, uint16 s)
+LZWPreDecode(TIFF* tif, uint16_t s)
{
static const char module[] = "LZWPreDecode";
LZWCodecState *sp = DecoderState(tif);
@@ -352,12 +352,12 @@ static void
codeLoop(TIFF* tif, const char* module)
{
TIFFErrorExt(tif->tif_clientdata, module,
- "Bogus encoding, loop in the code table; scanline %d",
+ "Bogus encoding, loop in the code table; scanline %"PRIu32,
tif->tif_row);
}
static int
-LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
+LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s)
{
static const char module[] = "LZWDecode";
LZWCodecState *sp = DecoderState(tif);
@@ -426,7 +426,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
bp = (unsigned char *)tif->tif_rawcp;
#ifdef LZW_CHECKEOS
- sp->dec_bitsleft += (((uint64)tif->tif_rawcc - sp->old_tif_rawcc) << 3);
+ sp->dec_bitsleft += (((uint64_t)tif->tif_rawcc - sp->old_tif_rawcc) << 3);
#endif
nbits = sp->lzw_nbits;
nextdata = sp->lzw_nextdata;
@@ -454,7 +454,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
break;
if (code > CODE_CLEAR) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
- "LZWDecode: Corrupted LZW table at scanline %d",
+ "LZWDecode: Corrupted LZW table at scanline %"PRIu32,
tif->tif_row);
return (0);
}
@@ -471,7 +471,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
if (free_entp < &sp->dec_codetab[0] ||
free_entp >= &sp->dec_codetab[CSIZE]) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Corrupted LZW table at scanline %d",
+ "Corrupted LZW table at scanline %"PRIu32,
tif->tif_row);
return (0);
}
@@ -480,7 +480,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
if (free_entp->next < &sp->dec_codetab[0] ||
free_entp->next >= &sp->dec_codetab[CSIZE]) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Corrupted LZW table at scanline %d",
+ "Corrupted LZW table at scanline %"PRIu32,
tif->tif_row);
return (0);
}
@@ -503,7 +503,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
if(codep->length == 0) {
TIFFErrorExt(tif->tif_clientdata, module,
"Wrong length of decoded string: "
- "data probably corrupted at scanline %d",
+ "data probably corrupted at scanline %"PRIu32,
tif->tif_row);
return (0);
}
@@ -552,8 +552,8 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
}
}
- tif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp );
- tif->tif_rawcp = (uint8*) bp;
+ tif->tif_rawcc -= (tmsize_t)((uint8_t*) bp - tif->tif_rawcp );
+ tif->tif_rawcp = (uint8_t*) bp;
#ifdef LZW_CHECKEOS
sp->old_tif_rawcc = tif->tif_rawcc;
#endif
@@ -566,15 +566,9 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
sp->dec_maxcodep = maxcodep;
if (occ > 0) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at scanline %d (short %I64d bytes)",
- tif->tif_row, (unsigned __int64) occ);
-#else
- TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at scanline %d (short %llu bytes)",
- tif->tif_row, (unsigned long long) occ);
-#endif
+ "Not enough data at scanline %"PRIu32" (short %ld bytes)",
+ tif->tif_row, occ);
return (0);
}
return (1);
@@ -597,7 +591,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
}
static int
-LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
+LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s)
{
static const char module[] = "LZWDecodeCompat";
LZWCodecState *sp = DecoderState(tif);
@@ -660,7 +654,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
bp = (unsigned char *)tif->tif_rawcp;
#ifdef LZW_CHECKEOS
- sp->dec_bitsleft += (((uint64)tif->tif_rawcc - sp->old_tif_rawcc) << 3);
+ sp->dec_bitsleft += (((uint64_t)tif->tif_rawcc - sp->old_tif_rawcc) << 3);
#endif
nbits = sp->lzw_nbits;
nextdata = sp->lzw_nextdata;
@@ -688,7 +682,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
break;
if (code > CODE_CLEAR) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
- "LZWDecode: Corrupted LZW table at scanline %d",
+ "LZWDecode: Corrupted LZW table at scanline %"PRIu32,
tif->tif_row);
return (0);
}
@@ -705,7 +699,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
if (free_entp < &sp->dec_codetab[0] ||
free_entp >= &sp->dec_codetab[CSIZE]) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Corrupted LZW table at scanline %d", tif->tif_row);
+ "Corrupted LZW table at scanline %"PRIu32, tif->tif_row);
return (0);
}
@@ -713,7 +707,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
if (free_entp->next < &sp->dec_codetab[0] ||
free_entp->next >= &sp->dec_codetab[CSIZE]) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Corrupted LZW table at scanline %d", tif->tif_row);
+ "Corrupted LZW table at scanline %"PRIu32, tif->tif_row);
return (0);
}
free_entp->firstchar = free_entp->next->firstchar;
@@ -735,7 +729,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
if(codep->length == 0) {
TIFFErrorExt(tif->tif_clientdata, module,
"Wrong length of decoded "
- "string: data probably corrupted at scanline %d",
+ "string: data probably corrupted at scanline %"PRIu32,
tif->tif_row);
return (0);
}
@@ -776,8 +770,8 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
}
}
- tif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp );
- tif->tif_rawcp = (uint8*) bp;
+ tif->tif_rawcc -= (tmsize_t)((uint8_t*) bp - tif->tif_rawcp );
+ tif->tif_rawcp = (uint8_t*) bp;
#ifdef LZW_CHECKEOS
sp->old_tif_rawcc = tif->tif_rawcc;
#endif
@@ -790,15 +784,9 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
sp->dec_maxcodep = maxcodep;
if (occ > 0) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at scanline %d (short %I64d bytes)",
- tif->tif_row, (unsigned __int64) occ);
-#else
- TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at scanline %d (short %llu bytes)",
- tif->tif_row, (unsigned long long) occ);
-#endif
+ "Not enough data at scanline %"PRIu32" (short %ld bytes)",
+ tif->tif_row, occ);
return (0);
}
return (1);
@@ -829,7 +817,7 @@ LZWSetupEncode(TIFF* tif)
* Reset encoding state at the start of a strip.
*/
static int
-LZWPreEncode(TIFF* tif, uint16 s)
+LZWPreEncode(TIFF* tif, uint16_t s)
{
LZWCodecState *sp = EncoderState(tif);
@@ -896,7 +884,7 @@ LZWPreEncode(TIFF* tif, uint16 s)
* for the decoder.
*/
static int
-LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
+LZWEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s)
{
register LZWCodecState *sp = EncoderState(tif);
register long fcode;
@@ -908,8 +896,8 @@ LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
unsigned long nextdata;
long nextbits;
int free_ent, maxcode, nbits;
- uint8* op;
- uint8* limit;
+ uint8_t* op;
+ uint8_t* limit;
(void) s;
if (sp == NULL)
@@ -1067,7 +1055,7 @@ static int
LZWPostEncode(TIFF* tif)
{
register LZWCodecState *sp = EncoderState(tif);
- uint8* op = tif->tif_rawcp;
+ uint8_t* op = tif->tif_rawcp;
long nextbits = sp->lzw_nextbits;
unsigned long nextdata = sp->lzw_nextdata;
long outcount = sp->enc_outcount;
@@ -1163,7 +1151,7 @@ TIFFInitLZW(TIFF* tif, int scheme)
/*
* Allocate state block so tag methods have storage to record values.
*/
- tif->tif_data = (uint8*) _TIFFmalloc(sizeof (LZWCodecState));
+ tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof (LZWCodecState));
if (tif->tif_data == NULL)
goto bad;
DecoderState(tif)->dec_codetab = NULL;