Skip to content

Commit

Permalink
Merge pull request #38 from enpinion/master
Browse files Browse the repository at this point in the history
MinGW compilation fixes
  • Loading branch information
dnewman-gpsw authored Jan 9, 2020
2 parents bf1b09f + 62c64fe commit 7bfce84
Show file tree
Hide file tree
Showing 86 changed files with 354 additions and 335 deletions.
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@ add_definitions(-D_ALLOCATOR=1 -DWARPSTUFF=1)

if (WIN32)
SET(COMPILER_FLAGS "")
SET(COMPILER_FLAGS_W_OMP "/openmp" )
SET(ADDITIONAL_LIBS "")
if (MSVC)
SET(COMPILER_FLAGS_W_OMP "/openmp")
SET(ADDITIONAL_LIBS "")
else()
SET(COMPILER_FLAGS_W_OMP -fopenmp)
SET(ADDITIONAL_LIBS "-lgomp")
endif()
endif (WIN32)

if (UNIX)
SET(COMPILER_FLAGS -fPIC -O3)
SET(COMPILER_FLAGS_W_OMP -fopenmp -O3)
SET(COMPILER_FLAGS -fPIC)
SET(COMPILER_FLAGS_W_OMP -fopenmp)
SET(ADDITIONAL_LIBS "-luuid -lpthread -lgomp")
SET(TOY_LIBS "-lm")
endif (UNIX)

if (APPLE)
SET(COMPILER_FLAGS -fvisibility=hidden -O3)
SET(COMPILER_FLAGS_W_OMP -O3)
SET(COMPILER_FLAGS -fvisibility=hidden)
SET(COMPILER_FLAGS_W_OMP)
SET(ADDITIONAL_LIBS "-lpthread")
endif (APPLE)

Expand Down
26 changes: 13 additions & 13 deletions Codec/DemoasicFrames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <assert.h>
#include <emmintrin.h> // SSE2 intrinsics

#ifdef _WINDOWS
#ifdef _WIN32
#include <windows.h>
//#include <atlbase.h> // Required for VS2005 but not 2003
#elif __APPLE__
Expand Down Expand Up @@ -4969,7 +4969,7 @@ void BayerRippleFilter( int width,
}


#ifdef _WINDOWS
#ifdef _WIN32

static int
WINAPI
Expand Down Expand Up @@ -5097,7 +5097,7 @@ float *LoadCube64_3DLUT(DECODER *decoder, CFHDDATA *cfhddata, int *lutsize)
if(decoder->LUTsPathStr[0] == 0)
InitLUTPaths(decoder);

#ifdef _WINDOWS
#ifdef _WIN32
sprintf_s(crcname, sizeof(crcname), "%s/%08X.cflook", decoder->LUTsPathStr, (uint32_t)cfhddata->user_look_CRC);
err = fopen_s(&fp, crcname, "rb");
#else
Expand All @@ -5111,7 +5111,7 @@ float *LoadCube64_3DLUT(DECODER *decoder, CFHDDATA *cfhddata, int *lutsize)
int validcflook = 0;
int len = 0;

#ifdef _WINDOWS
#ifdef _MSC_VER
len = (int)fread_s(&CFLKhdr, sizeof(CFLook_Header), 1, sizeof(CFLook_Header), fp);
#else
len = (int)fread(&CFLKhdr, 1, sizeof(CFLook_Header), fp);
Expand Down Expand Up @@ -5351,7 +5351,7 @@ void UpdateCFHDDATA(DECODER *decoder, unsigned char *ptr, int len, int delta, in
size = ptr[4] + (ptr[5]<<8) + (ptr[6]<<16);
tag = MAKETAG(ptr[0],ptr[1],ptr[2],ptr[3]);

#if _WINDOWS && _DEBUG && 0
#if _WIN32 && _DEBUG && 0
if(type == 'f')
{
char t[1000],tt[100];
Expand Down Expand Up @@ -5664,7 +5664,7 @@ void UpdateCFHDDATA(DECODER *decoder, unsigned char *ptr, int len, int delta, in
break;

case TAG_TIMECODE:
#ifdef _WINDOWS
#ifdef _WIN32
strncpy_s(cfhddata->FileTimecodeData.orgtime, sizeof(cfhddata->FileTimecodeData.orgtime),(char *)data, 15);
#else
strncpy(cfhddata->FileTimecodeData.orgtime, (char *)data, 15);
Expand Down Expand Up @@ -5725,7 +5725,7 @@ void UpdateCFHDDATA(DECODER *decoder, unsigned char *ptr, int len, int delta, in
{
int copysize = (int)size;
if(copysize > 39) copysize = 39;
#ifdef _WINDOWS
#ifdef _WIN32
strncpy_s(cfhddata->look_filename, sizeof(cfhddata->look_filename), (char *)data, copysize);
#else
strncpy(cfhddata->look_filename, (char *)data, copysize);
Expand All @@ -5738,7 +5738,7 @@ void UpdateCFHDDATA(DECODER *decoder, unsigned char *ptr, int len, int delta, in
{
if(0 != strncmp(cfhddata->look_export_path, (char *)data, size))
{
#ifdef _WINDOWS
#ifdef _WIN32
strncpy_s(cfhddata->look_export_path, sizeof(cfhddata->look_export_path), (char *)data, size);
#else
strncpy(cfhddata->look_export_path, (char *)data, size);
Expand Down Expand Up @@ -6436,7 +6436,7 @@ void UpdateCFHDDATA(DECODER *decoder, unsigned char *ptr, int len, int delta, in
case TAG_DISPLAY_FREEFORM:
copysize = size;
if(copysize >= FREEFORM_STR_MAXSIZE) copysize = FREEFORM_STR_MAXSIZE-1;
#ifdef _WINDOWS
#ifdef _WIN32
strncpy_s(decoder->MDPdefault.freeform, sizeof(decoder->MDPdefault.freeform), (char *)data, copysize);
#else
strncpy(decoder->MDPdefault.freeform, (char *)data, copysize);
Expand All @@ -6448,7 +6448,7 @@ void UpdateCFHDDATA(DECODER *decoder, unsigned char *ptr, int len, int delta, in
copysize = size;
if(copysize >= FONTNAME_STR_MAXSIZE) copysize = FONTNAME_STR_MAXSIZE-1;

#ifdef _WINDOWS
#ifdef _WIN32
strncpy_s(decoder->MDPdefault.font, sizeof(decoder->MDPdefault.font), (char *)data, copysize);
#else
strncpy(decoder->MDPdefault.font, (char *)data, copysize);
Expand Down Expand Up @@ -6485,7 +6485,7 @@ void UpdateCFHDDATA(DECODER *decoder, unsigned char *ptr, int len, int delta, in
case TAG_DISPLAY_FORMAT:
copysize = size;
if(copysize >= FORMAT_STR_MAXSIZE) copysize = FORMAT_STR_MAXSIZE-1;
#ifdef _WINDOWS
#ifdef _WIN32
strncpy_s(decoder->MDPdefault.format_str, sizeof(decoder->MDPdefault.format_str), (char *)data, copysize);
#else
strncpy(decoder->MDPdefault.format_str, (char *)data, copysize);
Expand All @@ -6495,7 +6495,7 @@ void UpdateCFHDDATA(DECODER *decoder, unsigned char *ptr, int len, int delta, in
case TAG_DISPLAY_PNG_PATH:
copysize = size;
if(copysize >= PNG_PATH_MAXSIZE) copysize = PNG_PATH_MAXSIZE-1;
#ifdef _WINDOWS
#ifdef _WIN32
strncpy_s(decoder->MDPdefault.png_path, sizeof(decoder->MDPdefault.png_path), (char *)data, copysize);
#else
strncpy(decoder->MDPdefault.png_path, (char *)data, copysize);
Expand Down Expand Up @@ -6654,7 +6654,7 @@ void GetCurrentID(DECODER *decoder, unsigned char *ptr, unsigned int len, char *
break;
case TAG_DISPLAY_FREEFORM:
if(size > id_size-1) size = id_size-1;
#ifdef _WINDOWS
#ifdef _WIN32
strncpy_s(id, id_size,(char *)data, size);
#else
strncpy(id, (char *)data, size);
Expand Down
8 changes: 4 additions & 4 deletions Codec/RGB2YUV.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const int tweakYUV2RGB_CG601[8] = {-28,14,6,1,7,3,23,23};
const int tweakYUV2RGB_VS601[8] = {-26,12,9,-8,1,-6,15,14};
#endif

#ifdef _WINDOWS
#ifdef _WIN32
#include <windows.h>
#endif

Expand All @@ -73,7 +73,7 @@ void LoadTweak()
sscanf(txt,"%d,%d,%d,%d,%d,%d,%d,%d,%d",&tweak[0],&tweak[1],&tweak[2],&tweak[3],&tweak[4],&tweak[5],&tweak[6],&tweak[7],&tweak[8]);
txt[len] = 0;
#ifdef _WINDOWS
#ifdef _WIN32
OutputDebugString(txt);
#endif
}
Expand Down Expand Up @@ -573,7 +573,7 @@ void ChunkyARGB8toPlanarRGB16(unsigned char *in_rgb8, unsigned short *out_rgb16,
gggggggg = _mm_slli_epi16(gggggggg, 8);
bbbbbbbb = _mm_slli_epi16(bbbbbbbb, 8);

//#ifdef _WINDOWS // is QT32 mode different on the PC?
//#ifdef _WIN32 // is QT32 mode different on the PC?
_mm_storeu_si128((__m128i *)&out_rgb16[x], bbbbbbbb);
_mm_storeu_si128((__m128i *)&out_rgb16[x+width], gggggggg);
_mm_storeu_si128((__m128i *)&out_rgb16[x+width*2], rrrrrrrr);
Expand Down Expand Up @@ -619,7 +619,7 @@ void ChunkyARGB8toPlanarRGB16(unsigned char *in_rgb8, unsigned short *out_rgb16,
gggggggg = _mm_slli_epi16(gggggggg, 8);
bbbbbbbb = _mm_slli_epi16(bbbbbbbb, 8);

//#ifdef _WINDOWS // is QT32 mode different on the PC?
//#ifdef _WIN32 // is QT32 mode different on the PC?
_mm_store_si128((__m128i *)&out_rgb16[x], bbbbbbbb);
_mm_store_si128((__m128i *)&out_rgb16[x+width], gggggggg);
_mm_store_si128((__m128i *)&out_rgb16[x+width*2], rrrrrrrr);
Expand Down
6 changes: 5 additions & 1 deletion Codec/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@
#include "../Common/CFHDAllocator.h"


#ifdef _WINDOWS
#ifdef _WIN32

#ifdef INLINE
#undef INLINE
#endif
#ifdef _MSC_VER
#define INLINE __forceinline
#else
#define INLINE inline
#endif

#elif defined(__APPLE__)

Expand Down
4 changes: 2 additions & 2 deletions Codec/bandfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct bandfile_band_header
CODEC_ERROR OpenBandFile(BANDFILE *bandfile, const char *pathname)
{
memset(bandfile, 0, sizeof(BANDFILE));
#ifdef _WINDOWS
#ifdef _WIN32
fopen_s(&bandfile->file, pathname, "rb");
#else
bandfile->file = fopen(pathname, "rb");
Expand Down Expand Up @@ -326,7 +326,7 @@ CODEC_ERROR ReadBandData(BANDFILE *bandfile, void *data, size_t size)
CODEC_ERROR CreateBandFile(BANDFILE *bandfile, const char *pathname)
{
memset(bandfile, 0, sizeof(BANDFILE));
#ifdef _WINDOWS
#ifdef _WIN32
fopen_s(&bandfile->file, pathname, "rb");
#else
bandfile->file = fopen(pathname, "wb");
Expand Down
12 changes: 6 additions & 6 deletions Codec/bayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -6714,7 +6714,7 @@ void ComputeCube(DECODER *decoder)

cfhddata->export_look = 0;

#ifdef _WINDOWS
#ifdef _WIN32
err = fopen_s(&fp, cfhddata->look_export_path, "w");
#else
fp = fopen(cfhddata->look_export_path, "w");
Expand Down Expand Up @@ -6768,7 +6768,7 @@ void ComputeCube(DECODER *decoder)
int err = 0;


#ifdef _WINDOWS
#ifdef _WIN32
strcpy_s(cubename, sizeof(cubename), cfhddata->look_export_path);
cubename[strlen(cubename) - 4] = 0;
strcat_s(cubename, sizeof(cubename), "cube");
Expand All @@ -6778,7 +6778,7 @@ void ComputeCube(DECODER *decoder)
cubename[strlen(cubename) - 4] = 0;
#endif

#ifdef _WINDOWS
#ifdef _WIN32
err = fopen_s(&fp, cubename, "w");
#else
fp = fopen(cubename, "w");
Expand All @@ -6789,7 +6789,7 @@ void ComputeCube(DECODER *decoder)
char fname[260] = "CubeExport";
//short *pLUT = (short *)RawCube;

#ifdef _WINDOWS
#ifdef _WIN32
//_splitpath(cubename, NULL, NULL, fname, NULL);
_splitpath_s(cubename, NULL, 0, NULL, 0, fname, sizeof(fname), NULL, 0);
#endif
Expand Down Expand Up @@ -7418,7 +7418,7 @@ void ComputeCube(DECODER *decoder)

#endif

#ifdef _WINDOWS
#ifdef _WIN32
#pragma warning(disable: 4554)
#endif

Expand Down Expand Up @@ -13666,7 +13666,7 @@ THREAD_PROC(WorkerThreadProc, lpParam)
//int initFsm = -1;
//FSM fsm;

#ifdef _WINDOWS
#ifdef _WIN32
if(decoder->thread_cntrl.affinity)
{
HANDLE hCurrentThread = GetCurrentThread();
Expand Down
10 changes: 5 additions & 5 deletions Codec/bitstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ uint8_t *GetBitstreamPosition(BITSTREAM *stream)
// Set the current position of the pointer into the block
void SetBitstreamPosition(BITSTREAM *stream, uint8_t *position)
{
#ifdef _WINDOWS
#ifdef _WIN32
LONGLONG skip = ((LONGLONG)position) - ((LONGLONG)stream->lpCurrentWord);
#else
int64_t skip = ((int64_t)position) - ((int64_t)stream->lpCurrentWord);
Expand All @@ -240,7 +240,7 @@ uint8_t GetWord(BITSTREAM *stream)
if (stream->file != BITSTREAM_FILE_INVALID &&
stream->access == BITSTREAM_ACCESS_READ)
{
#ifdef _WINDOWS
#ifdef _WIN32
// Read a block from the file
BOOL bReadOkay = ReadFile(stream->file, stream->block, stream->dwBlockLength, &stream->nWordsUsed, NULL);

Expand Down Expand Up @@ -772,7 +772,7 @@ void PutWord(BITSTREAM *stream, uint8_t word)
{
DWORD dwByteCount = stream->nWordsUsed * sizeof(uint8_t );
DWORD dwBytesWritten;
#ifdef _WINDOWS
#ifdef _WIN32
// Write the block to the output file
bool bWriteOkay = WriteFile(stream->file, stream->block, dwByteCount, &dwBytesWritten, NULL);

Expand Down Expand Up @@ -1861,7 +1861,7 @@ void CloseBitstream(BITSTREAM *stream)
{
DWORD nBytesToWrite = stream->nWordsUsed * sizeof(uint8_t );
DWORD nBytesWritten;
#ifdef _WINDOWS
#ifdef _WIN32
// Write the block to the output file
WriteFile(stream->file, stream->block, nBytesToWrite, &nBytesWritten, NULL);
assert(nBytesToWrite == nBytesWritten);
Expand Down Expand Up @@ -1921,7 +1921,7 @@ void DetachBitstreamFile(BITSTREAM *stream)
{
DWORD nBytesToWrite = stream->nWordsUsed * sizeof(uint8_t );
DWORD nBytesWritten;
#ifdef _WINDOWS
#ifdef _WIN32
// Write the block to the output file
WriteFile(stream->file, stream->block, nBytesToWrite, &nBytesWritten, NULL);
assert(nBytesToWrite == nBytesWritten);
Expand Down
2 changes: 1 addition & 1 deletion Codec/bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#undef _POSIX
#endif

#ifdef _WINDOWS
#ifdef _WIN32
#include <windows.h>
#else
// Force the use of POSIX on Macintosh and Linux
Expand Down
2 changes: 1 addition & 1 deletion Codec/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include <emmintrin.h>

#if (DEBUG && _WINDOWS)
#if (DEBUG && _WIN32)
#include <tchar.h> // For printing debug string in the console window
#endif

Expand Down
6 changes: 3 additions & 3 deletions Codec/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define _GRAPHICS 0
#endif

#ifdef _WINDOWS
#ifdef _WIN32
#ifndef DEBUG_ALLOCS
#define DEBUG_ALLOCS 1
#endif
Expand Down Expand Up @@ -86,7 +86,7 @@
#include <stdbool.h>

// Use the standard definition for the maximum length of a pathname
#ifdef _WINDOWS
#ifdef _WIN32
#ifndef PATH_MAX
#define PATH_MAX _MAX_PATH
#endif
Expand Down Expand Up @@ -267,7 +267,7 @@ static void *malloc22(size_t size, size_t align)
#define _DELAYED_THREAD_START 1

#ifndef _INTERLACED_WORKER_THREADS
#ifdef _WINDOWS
#ifdef _WIN32
#define _INTERLACED_WORKER_THREADS (_THREADED_DECODER) // Use worker threads for the last transform?
#else
#define _INTERLACED_WORKER_THREADS 0
Expand Down
2 changes: 1 addition & 1 deletion Codec/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int Timecode2frames(char *tc, int rate)

if (tc)
{
#ifdef _WINDOWS
#ifdef _WIN32
ret = sscanf_s(tc, "%02d:%02d:%02d:%02d", &hr, &mn, &sc, &fr);
#else
ret = sscanf(tc, "%02d:%02d:%02d:%02d", &hr, &mn, &sc, &fr);
Expand Down
4 changes: 2 additions & 2 deletions Codec/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

// Adapted from Microsoft Visual Studio .NET sample code

#ifdef _WINDOWS
#ifdef _WIN32
#include <windows.h>
#elif __APPLE__
#include "macdefs.h"
Expand All @@ -40,7 +40,7 @@
// This bit is set when cpuid is called with register set to 80000001h (only applicable to AMD)
#define _3DNOW_FEATURE_BIT 0x80000000

#ifdef _WINDOWS
#ifdef _WIN32

int GetProcessorCount()
{
Expand Down
Loading

0 comments on commit 7bfce84

Please sign in to comment.