SIILUtil.h

00001 //***************************************************************************************
00002 //
00003 // File supervisor: Softimage 3D Games & 3D Bridge team
00004 //
00005 // (c) Copyright 2001-2002 Avid Technology, Inc. . All rights reserved.
00006 //
00007 //***************************************************************************************
00008 
00009 /****************************************************************************************
00010 THIS CODE IS PUBLISHED AS A SAMPLE ONLY AND IS PROVIDED "AS IS".
00011 IN NO EVENT SHALL SOFTIMAGE, AVID TECHNOLOGY, INC. AND/OR THEIR RESPECTIVE
00012 SUPPLIERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
00013 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00014 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
00015 CONNECTION WITH THE USE OR PERFORMANCE OF THIS CODE .
00016 
00017 COPYRIGHT NOTICE. Copyright © 1999-2002 Avid Technology Inc. . All rights reserved. 
00018 
00019 SOFTIMAGE is a registered trademark of Avid Technology Inc. or its subsidiaries 
00020 or divisions. Windows NT is a registered trademark of Microsoft Corp. All other
00021 trademarks contained herein are the property of their respective owners. 
00022 ****************************************************************************************/
00023 
00024 //***************************************************************************************
00025 // Defines
00026 //***************************************************************************************
00027 #ifndef __SIILUTIL_H__
00028 #define __SIILUTIL_H__
00029 
00030 //***************************************************************************************
00031 // Includes
00032 //***************************************************************************************
00033 #include <SIBCUtil.h>
00034 
00035 
00036 //***************************************************************************************
00037 // Defines
00038 //***************************************************************************************
00039 #ifdef _WIN32
00040 
00041 #ifndef LITTLE_ENDIAN
00042 #define SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00043 #define SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00044 #define SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00045 #define INV_SWAP_SHORT(n) (n)
00046 #define INV_SWAP_LONG(n) (n)
00047 #define INV_SWAP_FLOAT(n) (n)
00048 #else
00049 #define SWAP_SHORT(n) (n)
00050 #define SWAP_LONG(n) (n)
00051 #define SWAP_FLOAT(n) (n)
00052 #define INV_SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00053 #define INV_SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00054 #define INV_SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00055 #endif
00056 
00057 #else
00058 
00059 #ifndef BYTE_ORDER
00060 
00061 #ifndef LITTLE_ENDIAN
00062 #define SWAP_SHORT(n) (n)
00063 #define SWAP_LONG(n) (n)
00064 #define SWAP_FLOAT(n) (n)
00065 #define INV_SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00066 #define INV_SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00067 #define INV_SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00068 #else
00069 #define SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00070 #define SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00071 #define SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00072 #define INV_SWAP_SHORT(n) (n)
00073 #define INV_SWAP_LONG(n) (n)
00074 #define INV_SWAP_FLOAT(n) (n)
00075 #endif
00076 
00077 #else
00078 
00079 #if ( BYTE_ORDER == LITTLE_ENDIAN )
00080 #define SWAP_SHORT(n) (n)
00081 #define SWAP_LONG(n) (n)
00082 #define SWAP_FLOAT(n) (n)
00083 #define INV_SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00084 #define INV_SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00085 #define INV_SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00086 #else
00087 #define SWAP_SHORT(n) (((((SI_UShort)(n))&0xff00)>>8)|((((SI_UShort)(n))&0x00ff)<<8))
00088 #define SWAP_LONG(n) ((((SI_ULong)(n))>>24)|(((SI_ULong)(n))>>8&0xff00)|(((SI_ULong)(n))<<8&0xff0000)|(((SI_ULong)(n))<<24))
00089 #define SWAP_FLOAT(n) SI_ImageSwapFloat(n)
00090 #define INV_SWAP_SHORT(n) (n)
00091 #define INV_SWAP_LONG(n) (n)
00092 #define INV_SWAP_FLOAT(n) (n)
00093 #endif
00094 
00095 #endif
00096 
00097 #endif
00098 
00099 
00100 //***************************************************************************************
00101 // Global Function
00102 //***************************************************************************************
00107 extern SI_Float SI_ImageSwapFloat(SI_Float value);
00108 
00109 
00110 #endif // __SIILUTIL_H__