diff options
Diffstat (limited to 'src/3rdparty/assimp/code/IFF.h')
-rw-r--r-- | src/3rdparty/assimp/code/IFF.h | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/src/3rdparty/assimp/code/IFF.h b/src/3rdparty/assimp/code/IFF.h index a1b2dc9c5..2b42b554b 100644 --- a/src/3rdparty/assimp/code/IFF.h +++ b/src/3rdparty/assimp/code/IFF.h @@ -1,5 +1,3 @@ - - // Definitions for the Interchange File Format (IFF) // Alexander Gessler, 2006 // Adapted to Assimp August 2008 @@ -7,24 +5,22 @@ #ifndef AI_IFF_H_INCLUDED #define AI_IFF_H_INCLUDED -#include "ByteSwap.h" +#include "ByteSwapper.h" -namespace Assimp { -namespace IFF { - -#include "./../include/assimp/Compiler/pushpack1.h" +namespace Assimp { +namespace IFF { ///////////////////////////////////////////////////////////////////////////////// //! Describes an IFF chunk header ///////////////////////////////////////////////////////////////////////////////// struct ChunkHeader { - //! Type of the chunk header - FourCC - uint32_t type; + //! Type of the chunk header - FourCC + uint32_t type; - //! Length of the chunk data, in bytes - uint32_t length; -} PACK_STRUCT; + //! Length of the chunk data, in bytes + uint32_t length; +}; ///////////////////////////////////////////////////////////////////////////////// @@ -32,18 +28,16 @@ struct ChunkHeader ///////////////////////////////////////////////////////////////////////////////// struct SubChunkHeader { - //! Type of the chunk header - FourCC - uint32_t type; - - //! Length of the chunk data, in bytes - uint16_t length; -} PACK_STRUCT; + //! Type of the chunk header - FourCC + uint32_t type; -#include "./../include/assimp/Compiler/poppack1.h" + //! Length of the chunk data, in bytes + uint16_t length; +}; #define AI_IFF_FOURCC(a,b,c,d) ((uint32_t) (((uint8_t)a << 24u) | \ - ((uint8_t)b << 16u) | ((uint8_t)c << 8u) | ((uint8_t)d))) + ((uint8_t)b << 16u) | ((uint8_t)c << 8u) | ((uint8_t)d))) #define AI_IFF_FOURCC_FORM AI_IFF_FOURCC('F','O','R','M') @@ -52,48 +46,54 @@ struct SubChunkHeader ///////////////////////////////////////////////////////////////////////////////// //! Load a chunk header //! @param outFile Pointer to the file data - points to the chunk data afterwards -//! @return Pointer to the chunk header +//! @return Copy of the chunk header ///////////////////////////////////////////////////////////////////////////////// -inline ChunkHeader* LoadChunk(uint8_t*& outFile) +inline ChunkHeader LoadChunk(uint8_t*& outFile) { - ChunkHeader* head = (ChunkHeader*) outFile; - AI_LSWAP4(head->length); - AI_LSWAP4(head->type); - outFile += sizeof(ChunkHeader); - return head; + ChunkHeader head; + ::memcpy(&head.type, outFile, 4); + outFile += 4; + ::memcpy(&head.length, outFile, 4); + outFile += 4; + AI_LSWAP4(head.length); + AI_LSWAP4(head.type); + return head; } ///////////////////////////////////////////////////////////////////////////////// //! Load a sub chunk header //! @param outFile Pointer to the file data - points to the chunk data afterwards -//! @return Pointer to the sub chunk header +//! @return Copy of the sub chunk header ///////////////////////////////////////////////////////////////////////////////// -inline SubChunkHeader* LoadSubChunk(uint8_t*& outFile) +inline SubChunkHeader LoadSubChunk(uint8_t*& outFile) { - SubChunkHeader* head = (SubChunkHeader*) outFile; - AI_LSWAP2(head->length); - AI_LSWAP4(head->type); - outFile += sizeof(SubChunkHeader); - return head; + SubChunkHeader head; + ::memcpy(&head.type, outFile, 4); + outFile += 4; + ::memcpy(&head.length, outFile, 2); + outFile += 2; + AI_LSWAP2(head.length); + AI_LSWAP4(head.type); + return head; } ///////////////////////////////////////////////////////////////////////////////// //! Read the file header and return the type of the file and its size -//! @param outFile Pointer to the file data. The buffer must at +//! @param outFile Pointer to the file data. The buffer must at //! least be 12 bytes large. //! @param fileType Receives the type of the file //! @return 0 if everything was OK, otherwise an error message ///////////////////////////////////////////////////////////////////////////////// -inline const char* ReadHeader(uint8_t* outFile,uint32_t& fileType) +inline const char* ReadHeader(uint8_t* outFile, uint32_t& fileType) { - ChunkHeader* head = LoadChunk(outFile); - if(AI_IFF_FOURCC_FORM != head->type) - { - return "The file is not an IFF file: FORM chunk is missing"; - } - fileType = *((uint32_t*)(head+1)); - AI_LSWAP4(fileType); - return 0; + ChunkHeader head = LoadChunk(outFile); + if(AI_IFF_FOURCC_FORM != head.type) + { + return "The file is not an IFF file: FORM chunk is missing"; + } + ::memcpy(&fileType, outFile, 4); + AI_LSWAP4(fileType); + return 0; } |