@ -31,17 +31,17 @@
# include "safe_op.hpp"
# include "slice.hpp"
# ifdef EXV_ENABLE_BMFF
# ifdef EXV_ENABLE_BMFF
# include "bmffimage.hpp"
# endif // EXV_ENABLE_BMFF
# endif // EXV_ENABLE_BMFF
# include "cr2image.hpp"
# include "crwimage.hpp"
# include "epsimage.hpp"
# include "jpgimage.hpp"
# include "mrwimage.hpp"
# ifdef EXV_HAVE_LIBZ
# ifdef EXV_HAVE_LIBZ
# include "pngimage.hpp"
# endif // EXV_HAVE_LIBZ
# endif // EXV_HAVE_LIBZ
# include "rafimage.hpp"
# include "tiffimage.hpp"
# include "tiffimage_int.hpp"
@ -56,12 +56,12 @@
# include "jp2image.hpp"
# include "nikonmn_int.hpp"
# ifdef EXV_ENABLE_VIDEO
# ifdef EXV_ENABLE_VIDEO
# include "matroskavideo.hpp"
# include "quicktimevideo.hpp"
# include "riffvideo.hpp"
# include "asfvideo.hpp"
# endif // EXV_ENABLE_VIDEO
# endif // EXV_ENABLE_VIDEO
# include "rw2image.hpp"
# include "pgfimage.hpp"
# include "xmpsidecar.hpp"
@ -176,7 +176,7 @@ namespace Exiv2 {
{
}
void Image : : printStructure ( std : : ostream & , PrintStructureOption , int /*depth*/ )
void Image : : printStructure ( std : : ostream & , PrintStructureOption , int /*depth*/ )
{
throw Error ( kerUnsupportedImageType , io_ - > path ( ) ) ;
}
@ -248,7 +248,7 @@ namespace Exiv2 {
}
bool Image : : isLittleEndianPlatform ( ) { return ! isBigEndianPlatform ( ) ; }
uint64_t Image : : byteSwap ( uint64_t value , bool bSwap ) const
uint64_t Image : : byteSwap ( uint64_t value , bool bSwap ) const
{
uint64_t result = 0 ;
byte * source_value = reinterpret_cast < byte * > ( & value ) ;
@ -260,7 +260,7 @@ namespace Exiv2 {
return bSwap ? result : value ;
}
uint32_t Image : : byteSwap ( uint32_t value , bool bSwap ) const
uint32_t Image : : byteSwap ( uint32_t value , bool bSwap ) const
{
uint32_t result = 0 ;
result | = ( value & 0x000000FF ) < < 24 ;
@ -270,7 +270,7 @@ namespace Exiv2 {
return bSwap ? result : value ;
}
uint16_t Image : : byteSwap ( uint16_t value , bool bSwap ) const
uint16_t Image : : byteSwap ( uint16_t value , bool bSwap ) const
{
uint16_t result = 0 ;
result | = ( value & 0x00FF ) < < 8 ;
@ -278,16 +278,16 @@ namespace Exiv2 {
return bSwap ? result : value ;
}
uint16_t Image : : byteSwap2 ( const DataBuf & buf , size_t offset , bool bSwap ) const
uint16_t Image : : byteSwap2 ( const DataBuf & buf , size_t offset , bool bSwap ) const
{
uint16_t v ;
char * p = ( char * ) & v ;
p [ 0 ] = buf . pData_ [ offset ] ;
p [ 1 ] = buf . pData_ [ offset + 1 ] ;
return Image : : byteSwap ( v , bSwap ) ;
return Image : : byteSwap ( v , bSwap ) ;
}
uint32_t Image : : byteSwap4 ( const DataBuf & buf , size_t offset , bool bSwap ) const
uint32_t Image : : byteSwap4 ( const DataBuf & buf , size_t offset , bool bSwap ) const
{
uint32_t v ;
char * p = ( char * ) & v ;
@ -295,10 +295,10 @@ namespace Exiv2 {
p [ 1 ] = buf . pData_ [ offset + 1 ] ;
p [ 2 ] = buf . pData_ [ offset + 2 ] ;
p [ 3 ] = buf . pData_ [ offset + 3 ] ;
return Image : : byteSwap ( v , bSwap ) ;
return Image : : byteSwap ( v , bSwap ) ;
}
uint64_t Image : : byteSwap8 ( const DataBuf & buf , size_t offset , bool bSwap ) const
uint64_t Image : : byteSwap8 ( const DataBuf & buf , size_t offset , bool bSwap ) const
{
uint64_t v ;
byte * p = reinterpret_cast < byte * > ( & v ) ;
@ -306,7 +306,7 @@ namespace Exiv2 {
for ( int i = 0 ; i < 8 ; i + + )
p [ i ] = buf . pData_ [ offset + i ] ;
return Image : : byteSwap ( v , bSwap ) ;
return Image : : byteSwap ( v , bSwap ) ;
}
const char * Image : : typeName ( uint16_t tag ) const
@ -338,7 +338,7 @@ namespace Exiv2 {
}
static std : : set < long > visits ; // #547
void Image : : printIFDStructure ( BasicIo & io , std : : ostream & out , Exiv2 : : PrintStructureOption option , uint32_t start , bool bSwap , char c , int depth )
void Image : : printIFDStructure ( BasicIo & io , std : : ostream & out , Exiv2 : : PrintStructureOption option , uint32_t start , bool bSwap , char c , int depth )
{
depth + + ;
if ( depth = = 1 ) visits . clear ( ) ;
@ -351,18 +351,18 @@ namespace Exiv2 {
do {
// Read top of directory
const int seekSuccess = ! io . seek ( start , BasicIo : : beg ) ;
const int seekSuccess = ! io . seek ( start , BasicIo : : beg ) ;
const long bytesRead = io . read ( dir . pData_ , 2 ) ;
if ( ! seekSuccess | | bytesRead = = 0 ) {
throw Error ( kerCorruptedMetadata ) ;
}
uint16_t dirLength = byteSwap2 ( dir , 0 , bSwap ) ;
uint16_t dirLength = byteSwap2 ( dir , 0 , bSwap ) ;
bool tooBig = dirLength > 500 ;
if ( tooBig ) throw Error ( kerTiffDirectoryTooLarge ) ;
if ( bFirst & & bPrint ) {
out < < Internal : : indent ( depth ) < < Internal : : stringFormat ( " STRUCTURE OF TIFF FILE (%c%c): " , c , c ) < < io . path ( ) < < std : : endl ;
out < < Internal : : indent ( depth ) < < Internal : : stringFormat ( " STRUCTURE OF TIFF FILE (%c%c): " , c , c ) < < io . path ( ) < < std : : endl ;
if ( tooBig ) out < < Internal : : indent ( depth ) < < " dirLength = " < < dirLength < < std : : endl ;
}
@ -381,10 +381,10 @@ namespace Exiv2 {
bFirst = false ;
io . read ( dir . pData_ , 12 ) ;
uint16_t tag = byteSwap2 ( dir , 0 , bSwap ) ;
uint16_t type = byteSwap2 ( dir , 2 , bSwap ) ;
uint32_t count = byteSwap4 ( dir , 4 , bSwap ) ;
uint32_t offset = byteSwap4 ( dir , 8 , bSwap ) ;
uint16_t tag = byteSwap2 ( dir , 0 , bSwap ) ;
uint16_t type = byteSwap2 ( dir , 2 , bSwap ) ;
uint32_t count = byteSwap4 ( dir , 4 , bSwap ) ;
uint32_t offset = byteSwap4 ( dir , 8 , bSwap ) ;
// Break for unknown tag types else we may segfault.
if ( ! typeValid ( type ) ) {
@ -396,10 +396,10 @@ namespace Exiv2 {
std : : string sp = " " ; // output spacer
//prepare to print the value
uint32_t kount = isPrintXMP ( tag , option ) ? count // haul in all the data
: isPrintICC ( tag , option ) ? count // ditto
: isStringType ( type ) ? ( count > 32 ? 32 : count ) // restrict long arrays
: count > 5 ? 5
uint32_t kount = isPrintXMP ( tag , option ) ? count // haul in all the data
: isPrintICC ( tag , option ) ? count // ditto
: isStringType ( type ) ? ( count > 32 ? 32 : count ) // restrict long arrays
: count > 5 ? 5
: count
;
uint32_t pad = isStringType ( type ) ? 1 : 0 ;
@ -419,14 +419,14 @@ namespace Exiv2 {
}
DataBuf buf ( ( long ) allocate ) ; // allocate a buffer
std : : memset ( buf . pData_ , 0 , buf . size_ ) ;
std : : memcpy ( buf . pData_ , dir . pData_ + 8 , 4 ) ; // copy dir[8:11] into buffer (short strings)
std : : memcpy ( buf . pData_ , dir . pData_ + 8 , 4 ) ; // copy dir[8:11] into buffer (short strings)
const bool bOffsetIsPointer = count * size > 4 ;
if ( bOffsetIsPointer ) { // read into buffer
size_t restore = io . tell ( ) ; // save
io . seek ( offset , BasicIo : : beg ) ; // position
io . read ( buf . pData_ , count * size ) ; // read
io . seek ( restore , BasicIo : : beg ) ; // restore
if ( bOffsetIsPointer ) { // read into buffer
size_t restore = io . tell ( ) ; // save
io . seek ( offset , BasicIo : : beg ) ; // position
io . read ( buf . pData_ , count * size ) ; // read
io . seek ( restore , BasicIo : : beg ) ; // restore
}
if ( bPrint ) {
@ -436,23 +436,23 @@ namespace Exiv2 {
" " ;
out < < Internal : : indent ( depth )
< < Internal : : stringFormat ( " %8u | %#06x %-28s |%10s |%9u |%10s | " ,
address , tag , tagName ( tag ) . c_str ( ) , typeName ( type ) , count , offsetString . c_str ( ) ) ;
< < Internal : : stringFormat ( " %8u | %#06x %-28s |%10s |%9u |%10s | "
, address , tag , tagName ( tag ) . c_str ( ) , typeName ( type ) , count , offsetString . c_str ( ) ) ;
if ( isShortType ( type ) ) {
for ( size_t k = 0 ; k < kount ; k + + ) {
out < < sp < < byteSwap2 ( buf , k * size , bSwap ) ;
out < < sp < < byteSwap2 ( buf , k * size , bSwap ) ;
sp = " " ;
}
} else if ( isLongType ( type ) ) {
for ( size_t k = 0 ; k < kount ; k + + ) {
out < < sp < < byteSwap4 ( buf , k * size , bSwap ) ;
out < < sp < < byteSwap4 ( buf , k * size , bSwap ) ;
sp = " " ;
}
} else if ( isRationalType ( type ) ) {
for ( size_t k = 0 ; k < kount ; k + + ) {
uint32_t a = byteSwap4 ( buf , k * size + 0 , bSwap ) ;
uint32_t b = byteSwap4 ( buf , k * size + 4 , bSwap ) ;
uint32_t a = byteSwap4 ( buf , k * size + 0 , bSwap ) ;
uint32_t b = byteSwap4 ( buf , k * size + 4 , bSwap ) ;
out < < sp < < a < < " / " < < b ;
sp = " " ;
}
@ -466,8 +466,8 @@ namespace Exiv2 {
if ( option = = kpsRecursive & & ( tag = = 0x8769 /* ExifTag */ | | tag = = 0x014a /*SubIFDs*/ | | type = = tiffIfd ) ) {
for ( size_t k = 0 ; k < count ; k + + ) {
size_t restore = io . tell ( ) ;
uint32_t offset = byteSwap4 ( buf , k * size , bSwap ) ;
printIFDStructure ( io , out , option , offset , bSwap , c , depth ) ;
uint32_t offset = byteSwap4 ( buf , k * size , bSwap ) ;
printIFDStructure ( io , out , option , offset , bSwap , c , depth ) ;
io . seek ( restore , BasicIo : : beg ) ;
}
} else if ( option = = kpsRecursive & & tag = = 0x83bb /* IPTCNAA */ ) {