diff --git a/common/include/guiddef.h b/common/include/guiddef.h index 17e0ed3..d3b78cc 100644 --- a/common/include/guiddef.h +++ b/common/include/guiddef.h @@ -90,7 +90,9 @@ typedef struct _GUID { EXTERN_C const GUID FAR name #endif // INITGUID +#if _MSC_VER < 1900 #define DEFINE_OLEGUID(name, l, w1, w2) DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46) +#endif #ifndef _GUIDDEF_H_ #define _GUIDDEF_H_ diff --git a/image/decode/segdec.c b/image/decode/segdec.c index fb83f2b..4793d14 100644 --- a/image/decode/segdec.c +++ b/image/decode/segdec.c @@ -63,7 +63,9 @@ static U32 _FORCEINLINE _load4(void* pv) v |= ((U32)((U16 *) pv)[1]) << 16; return _byteswap_ulong(v); #else // _M_IA64 - return _byteswap_ulong(*(U32*)pv); + U32 v; + memcpy(&v, pv, sizeof(U32)); + return _byteswap_ulong(v); #endif // _M_IA64 #endif // _BIG__ENDIAN_ } @@ -959,7 +961,7 @@ Int DecodeMacroblockLowpass (CWMImageStrCodec * pSC, CCodingContext *pContext, pCoeffs[k] += getBits (pIO, iModelBits); } else if (pCoeffs[k] < 0) { - pCoeffs[k] <<= iModelBits; + pCoeffs[k] = (int) (((unsigned) pCoeffs[k]) << iModelBits); pCoeffs[k] -= getBits (pIO, iModelBits); } #endif // WIN32 diff --git a/image/encode/strenc.c b/image/encode/strenc.c index d6e970e..65c277e 100644 --- a/image/encode/strenc.c +++ b/image/encode/strenc.c @@ -482,8 +482,10 @@ Int StrIOEncInit(CWMImageStrCodec* pSC) pSC->ppTempFile[i] = (char *)malloc(FILENAME_MAX * sizeof(char)); if(pSC->ppTempFile[i] == NULL) return ICERR_ERROR; - if ((pFilename = tmpnam(NULL)) == NULL) + char tmpnambuf[] = {'f', 'i', 'l', 'e', 'X', 'X', 'X', 'X', 'X', 'X', '\0'}; + if (mkstemp(tmpnambuf) == -1) return ICERR_ERROR; + pFilename = tmpnambuf; strcpy(pSC->ppTempFile[i], pFilename); #endif if(CreateWS_File(pSC->ppWStream + i, pFilename, "w+b") != ICERR_OK) return ICERR_ERROR; diff --git a/image/sys/adapthuff.c b/image/sys/adapthuff.c index a690889..cd83034 100644 --- a/image/sys/adapthuff.c +++ b/image/sys/adapthuff.c @@ -28,6 +28,8 @@ #include "strcodec.h" +#include + #ifdef MEM_TRACE #define TRACE_MALLOC 1 #define TRACE_NEW 0 @@ -459,7 +461,7 @@ Void AdaptDiscriminant (CAdaptiveHuffman *pAdHuff) assert (t < gMaxTables[iSym]); //pAdHuff->m_iDiscriminant >>= 1; - pAdHuff->m_iLowerBound = (t == 0) ? (-1 << 31) : -THRESHOLD; + pAdHuff->m_iLowerBound = (t == 0) ? INT_MIN : -THRESHOLD; pAdHuff->m_iUpperBound = (t == gMaxTables[iSym] - 1) ? (1 << 30) : THRESHOLD; switch (iSym) { diff --git a/image/sys/ansi.h b/image/sys/ansi.h index 74900c9..26a4e7d 100644 --- a/image/sys/ansi.h +++ b/image/sys/ansi.h @@ -27,6 +27,8 @@ //*@@@---@@@@****************************************************************** #pragma once +#include + //================================ // bitio functions //================================ @@ -42,20 +44,5 @@ //================================ // common defines //================================ -#define FORCE_INLINE -#define CDECL -#if __LP64__ -#define UINTPTR_T unsigned long long -#define INTPTR_T long long -#else -#define UINTPTR_T unsigned int -#define INTPTR_T int -#endif - - -//================================ -// quantization optimization -//================================ -//#define RECIP_QUANT_OPT - - +#define UINTPTR_T uintptr_t +#define INTPTR_T intptr_t diff --git a/image/sys/image.c b/image/sys/image.c index c819cbc..8dbb701 100644 --- a/image/sys/image.c +++ b/image/sys/image.c @@ -27,7 +27,6 @@ //*@@@---@@@@****************************************************************** #include "strcodec.h" -// #include "xplatform_image.h" #ifdef MEM_TRACE #define TRACE_MALLOC 1 diff --git a/image/sys/strcodec.c b/image/sys/strcodec.c index c746d6f..9b0a7d1 100644 --- a/image/sys/strcodec.c +++ b/image/sys/strcodec.c @@ -671,6 +671,7 @@ ERR detach_SB(SimpleBitIO* pSB) #ifdef _BIG__ENDIAN_ #define _byteswap_ulong(x) (x) #else // _BIG__ENDIAN_ +#if _MSC_VER < 1924 U32 _byteswap_ulong(U32 bits) { U32 r = (bits & 0xffu) << 24; @@ -680,6 +681,7 @@ U32 _byteswap_ulong(U32 bits) return r; } +#endif // _MSC_VER #endif // _BIG__ENDIAN_ #endif @@ -694,7 +696,9 @@ U32 load4BE(void* pv) v |= ((U32)((U16 *) pv)[1]) << 16; return _byteswap_ulong(v); #else // _M_IA64 - return _byteswap_ulong(*(U32*)pv); + U32 v; + memcpy(&v, pv, sizeof(U32)); + return _byteswap_ulong(v); #endif // _M_IA64 #endif // _BIG__ENDIAN_ } diff --git a/image/sys/strcodec.h b/image/sys/strcodec.h index 695a454..b1d5e14 100644 --- a/image/sys/strcodec.h +++ b/image/sys/strcodec.h @@ -31,7 +31,6 @@ #include "windowsmediaphoto.h" #include "common.h" -// #include "xplatform_image.h" // added for Xcode PK universal binary #ifdef __ppc__ @@ -64,7 +63,7 @@ #ifndef UNREFERENCED_PARAMETER #define UNREFERENCED_PARAMETER(P) { (P) = (P); } -#endif UNREFERENCED_PARAMETER +#endif // UNREFERENCED_PARAMETER #ifdef UNDER_CE #define PLATFORM_WCE diff --git a/image/sys/xplatform_image.h b/image/sys/xplatform_image.h deleted file mode 100644 index cf58230..0000000 --- a/image/sys/xplatform_image.h +++ /dev/null @@ -1,84 +0,0 @@ -//*@@@+++@@@@****************************************************************** -// -// Copyright © Microsoft Corp. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// • Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// • Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -//*@@@---@@@@****************************************************************** - -#ifndef XPLATFORM_IMAGE_H -#define XPLATFORM_IMAGE_H - -#ifdef __ANSI__ -// ANSI -#define FORCE_INLINE -#define CDECL -#define UINTPTR_T unsigned int -#define INTPTR_T int -#define DECLSPEC_ALIGN(bytes) -#endif // __ANSI__ - - -//#if defined(WIN32) -#if defined(WIN32) && !defined(UNDER_CE) // WIN32 seems to be defined always in VS2005 for ARM platform -// x86 -//#define CDECL __cdecl -#define DECLSPEC_ALIGN(bytes) __declspec(align(bytes)) -#endif // x86 - - -#if defined(_ARM_) || defined(UNDER_CE) -// ARM, WinCE -#define FORCE_INLINE inline -#define CDECL -#define UINTPTR_T unsigned int -#define INTPTR_T int -#define DECLSPEC_ALIGN(bytes) - -// parser -#define FULL_PATH_CONFIG_FILE_ENCODE "\\ConfigFile_encode.txt" -#define FULL_PATH_CONFIG_FILE_DECODE "\\ConfigFile_decode.txt" -#define MAX_ARGC 14 -#define MaxCharReadCount 10 -#define MAX_FNAME 256 -#define DELIMITER "filelist:" -#define CODEC_ENCODE "encode" -#define CODEC_DECODE "decode" -#define PHOTON "ptn" -#define OUTRAW "raw" -#define OUTBMP "bmp" -#define OUTPPM "ppm" -#define OUTTIF "tif" -#define OUTHDR "hdr" -#define OUTIYUV "iyuv" -#define OUTYUV422 "yuv422" -#define OUTYUV444 "yuv444" -int XPLATparser(char *pcARGV[], char *pcCodec); -void freeXPLATparser(int iARGC, char *pcARGV[]); - -// WinCE intrinsic -#include -#endif // ARM, WinCE - -#endif // XPLATFORM_IMAGE_H - diff --git a/image/x86/x86.h b/image/x86/x86.h index c182fc9..76ea196 100644 --- a/image/x86/x86.h +++ b/image/x86/x86.h @@ -50,9 +50,3 @@ #define INTPTR_T intptr_t -//================================ -// quantization optimization -//================================ -#define RECIP_QUANT_OPT - - diff --git a/jxrgluelib/JXRGlueJxr.c b/jxrgluelib/JXRGlueJxr.c index 1745acf..f60a2e3 100644 --- a/jxrgluelib/JXRGlueJxr.c +++ b/jxrgluelib/JXRGlueJxr.c @@ -27,6 +27,7 @@ // //*@@@---@@@@****************************************************************** #include +#include #include diff --git a/jxrtestlib/JXRTestHdr.c b/jxrtestlib/JXRTestHdr.c index a62914c..74697d3 100644 --- a/jxrtestlib/JXRTestHdr.c +++ b/jxrtestlib/JXRTestHdr.c @@ -27,7 +27,7 @@ //*@@@---@@@@****************************************************************** #ifndef ANSI #define _CRT_SECURE_NO_WARNINGS -#endif ANSI +#endif // ANSI #include #include diff --git a/jxrtestlib/JXRTestPnm.c b/jxrtestlib/JXRTestPnm.c index 8917d4a..840c746 100644 --- a/jxrtestlib/JXRTestPnm.c +++ b/jxrtestlib/JXRTestPnm.c @@ -27,7 +27,7 @@ //*@@@---@@@@****************************************************************** #ifndef ANSI #define _CRT_SECURE_NO_WARNINGS -#endif ANSI +#endif // ANSI #include diff --git a/jxrtestlib/JXRTestYUV.c b/jxrtestlib/JXRTestYUV.c index 52dc4ca..b803387 100644 --- a/jxrtestlib/JXRTestYUV.c +++ b/jxrtestlib/JXRTestYUV.c @@ -120,6 +120,9 @@ ERR PKImageEncode_WritePixels_IYUV( if(pY == NULL || pU == NULL || pV == NULL) { + free(pY); + free(pU); + free(pV); return ICERR_ERROR; } @@ -198,6 +201,9 @@ ERR PKImageEncode_WritePixels_YUV422( if(pY == NULL || pU == NULL || pV == NULL) { + free(pY); + free(pU); + free(pV); return ICERR_ERROR; } //YYUV @@ -273,6 +279,9 @@ ERR PKImageEncode_WritePixels_YUV444( if(pY == NULL || pU == NULL || pV == NULL) { + free(pY); + free(pU); + free(pV); return ICERR_ERROR; } @@ -491,6 +500,9 @@ ERR PKImageDecode_Copy_IYUV( if(pY == NULL || pU == NULL || pV == NULL) { + free(pY); + free(pU); + free(pV); return ICERR_ERROR; } @@ -564,6 +576,9 @@ ERR PKImageDecode_Copy_YUV422( if(pY == NULL || pU == NULL || pV == NULL) { + free(pY); + free(pU); + free(pV); return ICERR_ERROR; } @@ -635,6 +650,9 @@ ERR PKImageDecode_Copy_YUV444( if(pY == NULL || pU == NULL || pV == NULL) { + free(pY); + free(pU); + free(pV); return ICERR_ERROR; }