ref: 7fa09903cf87beb5c6a595d44431e65d60dd5939
parent: e66b3488c5843a5be0a0d21544c25d135989c4d4
author: V <h_o_w_@hotmail.com>
date: Tue Dec 17 09:13:21 EST 2013
Add MinGW platform makefile and related source changes
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-UNAME=$(shell uname | tr A-Z a-z)
+UNAME=$(shell uname | tr A-Z a-z | tr -d \\-[:digit:].[:digit:])
LIBPREFIX=lib
LIBSUFFIX=a
CP=cp
@@ -35,7 +35,7 @@
CFLAGS += -DNO_DYNAMIC_VP -DHAVE_CACHE_LINE_ALIGN
LDFLAGS +=
-ASMFLAGS += -DNO_DYNAMIC_VP -DNOPREFIX
+ASMFLAGS += -DNO_DYNAMIC_VP
#### No user-serviceable parts below this line
--- a/build/platform-darwin.mk
+++ b/build/platform-darwin.mk
@@ -2,4 +2,4 @@
ASM = nasm
CFLAGS += -Werror -fPIC
LDFLAGS += -lpthread
-ASMFLAGS += -f macho --prefix _
+ASMFLAGS += -f macho --prefix _ -DNOPREFIX
--- a/build/platform-freebsd.mk
+++ b/build/platform-freebsd.mk
@@ -1,5 +1,5 @@
ASM = nasm
CFLAGS += -fPIC
LDFLAGS += -lpthread
-ASMFLAGS += -f elf
+ASMFLAGS += -f elf -DNOPREFIX
--- a/build/platform-linux.mk
+++ b/build/platform-linux.mk
@@ -1,5 +1,5 @@
ASM = nasm
CFLAGS += -Werror -fPIC -DLINUX -D__NO_CTYPE
LDFLAGS += -lpthread
-ASMFLAGS += -f elf
+ASMFLAGS += -f elf -DNOPREFIX
--- /dev/null
+++ b/build/platform-mingw_nt.mk
@@ -1,0 +1,5 @@
+ASM = nasm
+CFLAGS += -DWIN32 -D__NO_CTYPE
+LDFLAGS +=
+ASMFLAGS += -f win -DPREFIX
+
--- a/codec/console/dec/src/read_config.cpp
+++ b/codec/console/dec/src/read_config.cpp
@@ -37,7 +37,7 @@
* 08/18/2008 Created
*
*****************************************************************************/
-#if !defined(_WIN32)
+#if !defined(_WIN32) || !defined(_MSC_VER)
#include <string.h>
#include <stdio.h>
#endif
--- a/codec/decoder/core/src/bit_stream.cpp
+++ b/codec/decoder/core/src/bit_stream.cpp
@@ -48,7 +48,7 @@
}
#else //WORDS_BIGENDIAN
-#ifdef WIN32
+#if defined(WIN32) && defined(_MSC_VER)
inline uint32_t EndianFix (uint32_t uiX) {
__asm {
mov eax, uiX
--- a/codec/decoder/core/src/parse_mb_syn_cavlc.cpp
+++ b/codec/decoder/core/src/parse_mb_syn_cavlc.cpp
@@ -708,7 +708,7 @@
for (; i < uiTotalCoeff; i++) {
if (pBitsCache->uiRemainBits <= 16) SHIFT_BUFFER (pBitsCache);
-#if defined(WIN32) && !defined(WIN64)
+#if defined(WIN32) && !defined(WIN64) && defined(_MSC_VER)
uiCache32Bit = pBitsCache->uiCache32Bit;
WELS_GET_PREFIX_BITS (uiCache32Bit, iPrefixBits);
#else
@@ -811,7 +811,7 @@
iRun[i] = pVlcTable->kpZeroTable[6][uiValue][0];
} else {
if (pBitsCache->uiRemainBits < 16) SHIFT_BUFFER (pBitsCache);
-#if defined(WIN32) && !defined(WIN64)
+#if defined(WIN32) && !defined(WIN64) && defined(_MSC_VER)
uiCache32Bit = pBitsCache->uiCache32Bit;
WELS_GET_PREFIX_BITS (uiCache32Bit, iPrefixBits);
#else
@@ -1345,4 +1345,4 @@
return 0;
}
-} // namespace WelsDec
\ No newline at end of file
+} // namespace WelsDec
--- a/codec/decoder/core/src/utils.cpp
+++ b/codec/decoder/core/src/utils.cpp
@@ -46,6 +46,9 @@
#include <windows.h>
#include <sys/types.h>
#include <sys/timeb.h>
+#ifndef _MSC_VER
+#include <sys/time.h>
+#endif
#else
#include <sys/time.h>
#include <sys/timeb.h>
@@ -79,7 +82,7 @@
}
-#if defined(_WIN32)
+#if defined(_WIN32) && defined(_MSC_VER)
#if defined(_MSC_VER) && (_MSC_VER>=1500)
@@ -275,4 +278,4 @@
return fflush (pFp);
}
-} // namespace WelsDec
\ No newline at end of file
+} // namespace WelsDec
--- a/codec/encoder/core/inc/crt_util_safe_x.h
+++ b/codec/encoder/core/inc/crt_util_safe_x.h
@@ -375,9 +375,7 @@
#endif//(WIN32 && _MSC_VER && _MSC_VER<1500) || __GNUC__
-#if defined(WIN32)
-
-#ifdef _MSC_VER
+#if defined(WIN32) && defined(_MSC_VER)
#if _MSC_VER >= 1500 // VS2008
#define SNPRINTF _snprintf_s
#define LOCALTIME localtime_s
@@ -397,7 +395,6 @@
#define VSPRINTF vsprintf
#define FOPEN fopen
#endif//_MSC_VER >= 1500
-#endif//_MSC_VER
#else//__GNUC__
--- a/codec/encoder/core/inc/macros.h
+++ b/codec/encoder/core/inc/macros.h
@@ -273,7 +273,7 @@
#else
-#if defined(WIN32) && !defined(WIN64)
+#if defined(WIN32) && !defined(WIN64) && defined(_MSC_VER)
static inline uint32_t ENDIAN_FIX (uint32_t x) {
__asm {
mov eax, x
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -41,7 +41,7 @@
#if defined(MT_ENABLED)
#include <assert.h>
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(_WIN32)
#include <semaphore.h>
#ifndef SEM_NAME_MAX
// length of semaphore name should be system constrained at least on mac 10.7
@@ -441,7 +441,7 @@
iIdx = 0;
while (iIdx < iThreadNum) {
-#ifdef __GNUC__ // for posix threading
+#if defined(__GNUC__) && !defined(_WIN32) // for posix threading
str_t name[SEM_NAME_MAX] = {0};
int32_t used_len = 0;
WELS_THREAD_ERROR_CODE err = 0;
@@ -852,7 +852,7 @@
}
#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
-#if defined(__GNUC__)
+#if defined(__GNUC__) && !defined(_WIN32)
WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg) {
SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg;
sWelsEncCtx* pEncPEncCtx = NULL;
@@ -1243,7 +1243,7 @@
// due to WelsMultipleEventsWaitSingleBlocking implememtation can not work well
// in case waiting pUpdateMbListEvent and pReadySliceCodingEvent events at the same time
#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
-#if defined(__GNUC__)
+#if defined(__GNUC__) && !defined(_WIN32)
WelsThreadCreate (&pCtx->pSliceThreading->pUpdateMbListThrdHandles[iIdx], UpdateMbListThreadProc,
&pCtx->pSliceThreading->pThreadPEncCtx[iIdx], 0);
#endif//__GNUC__
--- a/codec/encoder/core/src/utils.cpp
+++ b/codec/encoder/core/src/utils.cpp
@@ -46,6 +46,9 @@
#include <windows.h>
#include <sys/types.h>
#include <sys/timeb.h>
+#ifndef _MSC_VER
+#include <sys/time.h>
+#endif
#else
#include <sys/time.h>
#endif
@@ -147,23 +150,20 @@
if (pEncCtx) {
time_t l_time;
-#if defined(_WIN32)
-#if defined(_MSC_VER)
+#if defined(_WIN32) && defined(_MSC_VER)
#if _MSC_VER >= 1500
struct tm t_now;
#else//VC6
struct tm* t_now;
#endif//_MSC_VER >= 1500
-#endif//_MSC_VER
#else//__GNUC__
struct tm* t_now;
#endif//WIN32
-#if defined( _WIN32 )
+#if defined( _WIN32 ) && defined(_MSC_VER)
struct _timeb tb;
time (&l_time);
-#ifdef _MSC_VER
#if _MSC_VER >= 1500
LOCALTIME (&t_now, &l_time);
#else
@@ -172,7 +172,6 @@
return;
}
#endif//_MSC_VER >= 1500
-#endif//_MSC_VER
FTIME (&tb);
#elif defined( __GNUC__ )
struct timeval tv;
--- a/processing/src/common/typedef.h
+++ b/processing/src/common/typedef.h
@@ -52,7 +52,7 @@
WELSVP_NAMESPACE_BEGIN
-#if defined(_WIN32) || defined(_WIN32) || defined(_MSC_VER)
+#if ( defined(_WIN32) || defined(_WIN32) ) && defined(_MSC_VER)
typedef char int8_t ;
typedef unsigned char uint8_t ;