_TIFFPartialReadStripArray: bring back support for non-conformant SLONG8 data type
Such as in https://github.com/OSGeo/gdal/issues/2165
This commit is contained in:
parent
8192df23fa
commit
3db0ff91bc
@ -3902,11 +3902,37 @@ TIFFReadDirectory(TIFF* tif)
|
|||||||
break;
|
break;
|
||||||
case TIFFTAG_STRIPOFFSETS:
|
case TIFFTAG_STRIPOFFSETS:
|
||||||
case TIFFTAG_TILEOFFSETS:
|
case TIFFTAG_TILEOFFSETS:
|
||||||
|
switch( dp->tdir_type )
|
||||||
|
{
|
||||||
|
case TIFF_SHORT:
|
||||||
|
case TIFF_LONG:
|
||||||
|
case TIFF_LONG8:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fip = TIFFFieldWithTag(tif,dp->tdir_tag);
|
||||||
|
TIFFWarningExt(tif->tif_clientdata,module,
|
||||||
|
"Invalid data type for tag %s",
|
||||||
|
fip ? fip->field_name : "unknown tagname");
|
||||||
|
break;
|
||||||
|
}
|
||||||
_TIFFmemcpy( &(tif->tif_dir.td_stripoffset_entry),
|
_TIFFmemcpy( &(tif->tif_dir.td_stripoffset_entry),
|
||||||
dp, sizeof(TIFFDirEntry) );
|
dp, sizeof(TIFFDirEntry) );
|
||||||
break;
|
break;
|
||||||
case TIFFTAG_STRIPBYTECOUNTS:
|
case TIFFTAG_STRIPBYTECOUNTS:
|
||||||
case TIFFTAG_TILEBYTECOUNTS:
|
case TIFFTAG_TILEBYTECOUNTS:
|
||||||
|
switch( dp->tdir_type )
|
||||||
|
{
|
||||||
|
case TIFF_SHORT:
|
||||||
|
case TIFF_LONG:
|
||||||
|
case TIFF_LONG8:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fip = TIFFFieldWithTag(tif,dp->tdir_tag);
|
||||||
|
TIFFWarningExt(tif->tif_clientdata,module,
|
||||||
|
"Invalid data type for tag %s",
|
||||||
|
fip ? fip->field_name : "unknown tagname");
|
||||||
|
break;
|
||||||
|
}
|
||||||
_TIFFmemcpy( &(tif->tif_dir.td_stripbytecount_entry),
|
_TIFFmemcpy( &(tif->tif_dir.td_stripbytecount_entry),
|
||||||
dp, sizeof(TIFFDirEntry) );
|
dp, sizeof(TIFFDirEntry) );
|
||||||
break;
|
break;
|
||||||
@ -6034,6 +6060,12 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent,
|
|||||||
{
|
{
|
||||||
sizeofval = sizeof(uint64);
|
sizeofval = sizeof(uint64);
|
||||||
}
|
}
|
||||||
|
else if( dirent->tdir_type == TIFF_SLONG8 )
|
||||||
|
{
|
||||||
|
/* Non conformant but used by some images as in */
|
||||||
|
/* https://github.com/OSGeo/gdal/issues/2165 */
|
||||||
|
sizeofval = sizeof(int64);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TIFFErrorExt(tif->tif_clientdata, module,
|
TIFFErrorExt(tif->tif_clientdata, module,
|
||||||
@ -6106,7 +6138,7 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent,
|
|||||||
_TIFFUnsanitizedAddUInt64AndInt(nOffset, (i + 1) * sizeofvalint) <= nOffsetEndPage;
|
_TIFFUnsanitizedAddUInt64AndInt(nOffset, (i + 1) * sizeofvalint) <= nOffsetEndPage;
|
||||||
++i )
|
++i )
|
||||||
{
|
{
|
||||||
if( sizeofval == sizeof(uint16) )
|
if( dirent->tdir_type == TIFF_SHORT )
|
||||||
{
|
{
|
||||||
uint16 val;
|
uint16 val;
|
||||||
memcpy(&val,
|
memcpy(&val,
|
||||||
@ -6116,7 +6148,7 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent,
|
|||||||
TIFFSwabShort(&val);
|
TIFFSwabShort(&val);
|
||||||
panVals[strile + i] = val;
|
panVals[strile + i] = val;
|
||||||
}
|
}
|
||||||
else if( sizeofval == sizeof(uint32) )
|
else if( dirent->tdir_type == TIFF_LONG )
|
||||||
{
|
{
|
||||||
uint32 val;
|
uint32 val;
|
||||||
memcpy(&val,
|
memcpy(&val,
|
||||||
@ -6126,7 +6158,7 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent,
|
|||||||
TIFFSwabLong(&val);
|
TIFFSwabLong(&val);
|
||||||
panVals[strile + i] = val;
|
panVals[strile + i] = val;
|
||||||
}
|
}
|
||||||
else
|
else if( dirent->tdir_type == TIFF_LONG8 )
|
||||||
{
|
{
|
||||||
uint64 val;
|
uint64 val;
|
||||||
memcpy(&val,
|
memcpy(&val,
|
||||||
@ -6136,6 +6168,17 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent,
|
|||||||
TIFFSwabLong8(&val);
|
TIFFSwabLong8(&val);
|
||||||
panVals[strile + i] = val;
|
panVals[strile + i] = val;
|
||||||
}
|
}
|
||||||
|
else /* if( dirent->tdir_type == TIFF_SLONG8 ) */
|
||||||
|
{
|
||||||
|
/* Non conformant data type */
|
||||||
|
int64 val;
|
||||||
|
memcpy(&val,
|
||||||
|
buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint,
|
||||||
|
sizeof(val));
|
||||||
|
if( bSwab )
|
||||||
|
TIFFSwabLong8((uint64*) &val);
|
||||||
|
panVals[strile + i] = (uint64) val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user