@@ -93,7 +93,6 @@ typedef struct
93
93
#define LERCDecoderState (tif ) GetLERCState(tif)
94
94
#define LERCEncoderState (tif ) GetLERCState(tif)
95
95
96
- static int LERCEncode (TIFF * tif , uint8_t * bp , tmsize_t cc , uint16_t s );
97
96
static int LERCDecode (TIFF * tif , uint8_t * op , tmsize_t occ , uint16_t s );
98
97
99
98
static int LERCFixupTags (TIFF * tif )
@@ -222,20 +221,20 @@ static int SetupBuffers(TIFF *tif, LERCState *sp, const char *module)
222
221
{
223
222
TIFFErrorExtR (tif , module , "Too large uncompressed strip/tile" );
224
223
_TIFFfreeExt (tif , sp -> uncompressed_buffer );
225
- sp -> uncompressed_buffer = 0 ;
224
+ sp -> uncompressed_buffer = NULL ;
226
225
sp -> uncompressed_alloc = 0 ;
227
226
return 0 ;
228
227
}
229
228
230
229
if (sp -> uncompressed_alloc < new_alloc )
231
230
{
232
231
_TIFFfreeExt (tif , sp -> uncompressed_buffer );
233
- sp -> uncompressed_buffer = _TIFFmallocExt (tif , new_alloc );
232
+ sp -> uncompressed_buffer = ( uint8_t * ) _TIFFmallocExt (tif , new_alloc );
234
233
if (!sp -> uncompressed_buffer )
235
234
{
236
235
TIFFErrorExtR (tif , module , "Cannot allocate buffer" );
237
236
_TIFFfreeExt (tif , sp -> uncompressed_buffer );
238
- sp -> uncompressed_buffer = 0 ;
237
+ sp -> uncompressed_buffer = NULL ;
239
238
sp -> uncompressed_alloc = 0 ;
240
239
return 0 ;
241
240
}
@@ -267,7 +266,7 @@ static int SetupBuffers(TIFF *tif, LERCState *sp, const char *module)
267
266
TIFFErrorExtR (tif , module , "Cannot allocate buffer" );
268
267
sp -> mask_size = 0 ;
269
268
_TIFFfreeExt (tif , sp -> uncompressed_buffer );
270
- sp -> uncompressed_buffer = 0 ;
269
+ sp -> uncompressed_buffer = NULL ;
271
270
sp -> uncompressed_alloc = 0 ;
272
271
return 0 ;
273
272
}
@@ -348,7 +347,7 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
348
347
return 0 ;
349
348
}
350
349
assert (lerc_data_sizet == (unsigned int )lerc_data_sizet );
351
- lerc_data = sp -> compressed_buffer ;
350
+ lerc_data = ( uint8_t * ) sp -> compressed_buffer ;
352
351
lerc_data_size = (unsigned int )lerc_data_sizet ;
353
352
#else
354
353
z_stream strm ;
@@ -369,15 +368,15 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
369
368
strm .avail_in = (uInt )tif -> tif_rawcc ;
370
369
strm .next_in = tif -> tif_rawcp ;
371
370
strm .avail_out = sp -> compressed_size ;
372
- strm .next_out = sp -> compressed_buffer ;
371
+ strm .next_out = ( Bytef * ) sp -> compressed_buffer ;
373
372
zlib_ret = inflate (& strm , Z_FINISH );
374
373
if (zlib_ret != Z_STREAM_END && zlib_ret != Z_OK )
375
374
{
376
375
TIFFErrorExtR (tif , module , "inflate() failed" );
377
376
inflateEnd (& strm );
378
377
return 0 ;
379
378
}
380
- lerc_data = sp -> compressed_buffer ;
379
+ lerc_data = ( uint8_t * ) sp -> compressed_buffer ;
381
380
lerc_data_size = sp -> compressed_size - strm .avail_out ;
382
381
inflateEnd (& strm );
383
382
#endif
@@ -396,7 +395,7 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
396
395
return 0 ;
397
396
}
398
397
399
- lerc_data = sp -> compressed_buffer ;
398
+ lerc_data = ( uint8_t * ) sp -> compressed_buffer ;
400
399
lerc_data_size = (unsigned int )zstd_ret ;
401
400
#else
402
401
TIFFErrorExtR (tif , module , "ZSTD support missing" );
@@ -568,7 +567,7 @@ static int LERCPreDecode(TIFF *tif, uint16_t s)
568
567
{
569
568
_TIFFfreeExt (tif , sp -> uncompressed_buffer_multiband );
570
569
sp -> uncompressed_buffer_multiband =
571
- _TIFFmallocExt (tif , num_bytes_needed );
570
+ ( uint8_t * ) _TIFFmallocExt (tif , num_bytes_needed );
572
571
if (!sp -> uncompressed_buffer_multiband )
573
572
{
574
573
sp -> uncompressed_buffer_multiband_alloc = 0 ;
@@ -752,7 +751,7 @@ static int LERCDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
752
751
assert (sp != NULL );
753
752
assert (sp -> state == LSTATE_INIT_DECODE );
754
753
755
- if (sp -> uncompressed_buffer == 0 )
754
+ if (sp -> uncompressed_buffer == NULL )
756
755
{
757
756
memset (op , 0 , (size_t )occ );
758
757
TIFFErrorExtR (tif , module , "Uncompressed buffer not allocated" );
@@ -773,6 +772,8 @@ static int LERCDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s)
773
772
return 1 ;
774
773
}
775
774
775
+ #ifndef LERC_READ_ONLY
776
+
776
777
static int LERCSetupEncode (TIFF * tif )
777
778
{
778
779
LERCState * sp = LERCEncoderState (tif );
@@ -1005,7 +1006,7 @@ static int LERCPostEncode(TIFF *tif)
1005
1006
{
1006
1007
_TIFFfreeExt (tif , sp -> uncompressed_buffer_multiband );
1007
1008
sp -> uncompressed_buffer_multiband =
1008
- _TIFFmallocExt (tif , num_bytes_needed );
1009
+ ( uint8_t * ) _TIFFmallocExt (tif , num_bytes_needed );
1009
1010
if (!sp -> uncompressed_buffer_multiband )
1010
1011
{
1011
1012
sp -> uncompressed_buffer_multiband_alloc = 0 ;
@@ -1126,7 +1127,8 @@ static int LERCPostEncode(TIFF *tif)
1126
1127
sp -> uncompressed_buffer_multiband , sp -> lerc_version ,
1127
1128
GetLercDataType (tif ), 1 , sp -> segment_width , sp -> segment_height ,
1128
1129
dst_nbands , dst_nbands , sp -> mask_buffer , sp -> maxzerror ,
1129
- sp -> compressed_buffer , sp -> compressed_size , & numBytesWritten );
1130
+ (unsigned char * )sp -> compressed_buffer , sp -> compressed_size ,
1131
+ & numBytesWritten );
1130
1132
}
1131
1133
else
1132
1134
#endif
@@ -1139,7 +1141,8 @@ static int LERCPostEncode(TIFF *tif)
1139
1141
use_mask ? 1 : 0 ,
1140
1142
#endif
1141
1143
use_mask ? sp -> mask_buffer : NULL , sp -> maxzerror ,
1142
- sp -> compressed_buffer , sp -> compressed_size , & numBytesWritten );
1144
+ (unsigned char * )sp -> compressed_buffer , sp -> compressed_size ,
1145
+ & numBytesWritten );
1143
1146
}
1144
1147
if (lerc_ret != 0 )
1145
1148
{
@@ -1271,7 +1274,7 @@ static int LERCPostEncode(TIFF *tif)
1271
1274
{
1272
1275
int ret ;
1273
1276
uint8_t * tif_rawdata_backup = tif -> tif_rawdata ;
1274
- tif -> tif_rawdata = sp -> compressed_buffer ;
1277
+ tif -> tif_rawdata = ( uint8_t * ) sp -> compressed_buffer ;
1275
1278
tif -> tif_rawcc = numBytesWritten ;
1276
1279
ret = TIFFFlushData1 (tif );
1277
1280
tif -> tif_rawdata = tif_rawdata_backup ;
@@ -1282,11 +1285,13 @@ static int LERCPostEncode(TIFF *tif)
1282
1285
return 1 ;
1283
1286
}
1284
1287
1288
+ #endif /* LERC_READ_ONLY */
1289
+
1285
1290
static void LERCCleanup (TIFF * tif )
1286
1291
{
1287
1292
LERCState * sp = GetLERCState (tif );
1288
1293
1289
- assert (sp != 0 );
1294
+ assert (sp != NULL );
1290
1295
1291
1296
tif -> tif_tagmethods .vgetfield = sp -> vgetparent ;
1292
1297
tif -> tif_tagmethods .vsetfield = sp -> vsetparent ;
@@ -1312,20 +1317,21 @@ static void LERCCleanup(TIFF *tif)
1312
1317
static const TIFFField LERCFields [] = {
1313
1318
{TIFFTAG_LERC_PARAMETERS , TIFF_VARIABLE2 , TIFF_VARIABLE2 , TIFF_LONG , 0 ,
1314
1319
TIFF_SETGET_C32_UINT32 , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , FALSE, TRUE,
1315
- "LercParameters" , NULL },
1320
+ ( char * ) "LercParameters" , NULL },
1316
1321
{TIFFTAG_LERC_MAXZERROR , 0 , 0 , TIFF_ANY , 0 , TIFF_SETGET_DOUBLE ,
1317
- TIFF_SETGET_UNDEFINED , FIELD_PSEUDO , TRUE, FALSE, "LercMaximumError" ,
1318
- NULL },
1322
+ TIFF_SETGET_UNDEFINED , FIELD_PSEUDO , TRUE, FALSE,
1323
+ ( char * ) "LercMaximumError" , NULL },
1319
1324
{TIFFTAG_LERC_VERSION , 0 , 0 , TIFF_ANY , 0 , TIFF_SETGET_UINT32 ,
1320
- TIFF_SETGET_UNDEFINED , FIELD_PSEUDO , FALSE, FALSE, "LercVersion" , NULL },
1325
+ TIFF_SETGET_UNDEFINED , FIELD_PSEUDO , FALSE, FALSE, (char * )"LercVersion" ,
1326
+ NULL },
1321
1327
{TIFFTAG_LERC_ADD_COMPRESSION , 0 , 0 , TIFF_ANY , 0 , TIFF_SETGET_UINT32 ,
1322
1328
TIFF_SETGET_UNDEFINED , FIELD_PSEUDO , FALSE, FALSE,
1323
- "LercAdditionalCompression" , NULL },
1329
+ ( char * ) "LercAdditionalCompression" , NULL },
1324
1330
{TIFFTAG_ZSTD_LEVEL , 0 , 0 , TIFF_ANY , 0 , TIFF_SETGET_INT ,
1325
1331
TIFF_SETGET_UNDEFINED , FIELD_PSEUDO , TRUE, FALSE,
1326
- "ZSTD zstd_compress_level" , NULL },
1332
+ ( char * ) "ZSTD zstd_compress_level" , NULL },
1327
1333
{TIFFTAG_ZIPQUALITY , 0 , 0 , TIFF_ANY , 0 , TIFF_SETGET_INT ,
1328
- TIFF_SETGET_UNDEFINED , FIELD_PSEUDO , TRUE, FALSE, "" , NULL },
1334
+ TIFF_SETGET_UNDEFINED , FIELD_PSEUDO , TRUE, FALSE, ( char * ) "" , NULL },
1329
1335
};
1330
1336
1331
1337
static int LERCVSetFieldBase (TIFF * tif , uint32_t tag , ...)
@@ -1517,12 +1523,14 @@ int TIFFInitLERC(TIFF *tif, int scheme)
1517
1523
tif -> tif_decoderow = LERCDecode ;
1518
1524
tif -> tif_decodestrip = LERCDecode ;
1519
1525
tif -> tif_decodetile = LERCDecode ;
1526
+ #ifndef LERC_READ_ONLY
1520
1527
tif -> tif_setupencode = LERCSetupEncode ;
1521
1528
tif -> tif_preencode = LERCPreEncode ;
1522
1529
tif -> tif_postencode = LERCPostEncode ;
1523
1530
tif -> tif_encoderow = LERCEncode ;
1524
1531
tif -> tif_encodestrip = LERCEncode ;
1525
1532
tif -> tif_encodetile = LERCEncode ;
1533
+ #endif
1526
1534
tif -> tif_cleanup = LERCCleanup ;
1527
1535
1528
1536
/* Default values for codec-specific fields */
0 commit comments