shithub: openh264

Download patch

ref: ac6828f4fa06d5d15a64370cdb63b29ba3627f7e
parent: f2aa3c75ae8a3d41ef85be739752d3f189c7eea3
author: Licai Guo <guolicai@gmail.com>
date: Sat Dec 14 15:37:33 EST 2013

Enable 64-bit build on Linux & Mac

--- a/Makefile
+++ b/Makefile
@@ -13,12 +13,20 @@
 # Configurations
 ifeq ($(BUILDTYPE), Release)
 CFLAGS += -O3
+ifneq ($(ENABLE64BIT), Yes)
 USE_ASM = Yes
+endif
 else
 CFLAGS = -g
 USE_ASM = No
 endif
-
+ifeq ($(ENABLE64BIT), Yes)
+CFLAGS += -m64
+LDFLAGS += -m64
+else
+CFLAGS += -m32
+LDFLAGS += -m32
+endif
 include build/platform-$(UNAME).mk
 
 ifeq ($(USE_ASM),Yes)
--- a/build/platform-darwin.mk
+++ b/build/platform-darwin.mk
@@ -1,5 +1,5 @@
 USE_ASM = No  # We don't have ASM working on Mac yet
 ASM = nasm
-CFLAGS += -arch i386 -fPIC
-LDFLAGS += -arch i386 -ldl -lpthread
+CFLAGS += -fPIC
+LDFLAGS += -ldl -lpthread
 ASMFLAGS += -f macho --prefix _
--- a/build/platform-linux.mk
+++ b/build/platform-linux.mk
@@ -1,5 +1,5 @@
 ASM = nasm
-CFLAGS += -m32 -fPIC -DLINUX -D__NO_CTYPE
-LDFLAGS += -m32 -ldl -lpthread
+CFLAGS += -fPIC -DLINUX -D__NO_CTYPE
+LDFLAGS += -ldl -lpthread
 ASMFLAGS += -f elf
 
--- a/codec/decoder/core/inc/macros.h
+++ b/codec/decoder/core/inc/macros.h
@@ -57,7 +57,7 @@
 */
 #define FORCE_STACK_ALIGN_1D(_tp, _nm, _sz, _al) \
 	_tp _nm ## _tEmP[(_sz)+(_al)-1]; \
-	_tp *_nm = _nm ## _tEmP + ((_al)-1) - (((int32_t)(_nm ## _tEmP + ((_al)-1)) & ((_al)-1))/sizeof(_tp))
+	_tp *_nm = _nm ## _tEmP + ((_al)-1) - (((uintptr_t)(_nm ## _tEmP + ((_al)-1)) & ((_al)-1))/sizeof(_tp))
 
 
 #define ENFORCE_STACK_ALIGN_2D(_tp, _nm, _cx, _cy, _al) \
@@ -64,7 +64,7 @@
 	assert( ((_al) && !((_al) & ((_al) - 1))) && ((_al) >= sizeof(_tp)) ); /*_al should be power-of-2 and >= sizeof(_tp)*/\
 	_tp _nm ## _tEmP[(_cx)*(_cy)+(_al)/sizeof(_tp)-1]; \
 	_tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)/sizeof(_tp)-1); \
-	_nm ## _tEmP_al -= (((int32_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
+	_nm ## _tEmP_al -= (((uintptr_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
 	_tp (*_nm)[(_cy)] = (_tp (*)[(_cy)])_nm ## _tEmP_al;
 
 
--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -86,7 +86,7 @@
     ++ pBits;
 
     if ((iIdx >= 3) && ((* (pBits - 1)) == 0x1)) {
-      *pOffset = ((uint32_t)pBits) - ((uint32_t)kpBuf);
+      *pOffset = ((uintptr_t)pBits) - ((uintptr_t)kpBuf);
       return pBits;
     }
 
@@ -970,4 +970,4 @@
   return iCountNum;
 }
 
-} // namespace WelsDec
\ No newline at end of file
+} // namespace WelsDec
--- a/codec/decoder/core/src/mem_align.cpp
+++ b/codec/decoder/core/src/mem_align.cpp
@@ -84,7 +84,7 @@
   memset (pBuf, 0, kuiSize + kiAlignBytes + kiSizeVoidPtr + kiSizeInt);
 
   pAlignBuf = pBuf + kiAlignBytes + kiSizeVoidPtr + kiSizeInt;
-  pAlignBuf -= (int32_t) pAlignBuf & kiAlignBytes;
+  pAlignBuf -= (uintptr_t) pAlignBuf & kiAlignBytes;
   * ((void_t**) (pAlignBuf - kiSizeVoidPtr)) = pBuf;
   * ((int32_t*) (pAlignBuf - (kiSizeVoidPtr + kiSizeInt))) = kuiSize;
 
--- a/codec/encoder/core/inc/array_stack_align.h
+++ b/codec/encoder/core/inc/array_stack_align.h
@@ -67,7 +67,7 @@
 assert( ((_al) && !((_al) & ((_al) - 1))) && ((_al) >= sizeof(_tp)) ); /*_al should be power-of-2 and >= sizeof(_tp)*/\
 _tp _nm ## _tEmP[(_sz)+(_al)/sizeof(_tp)-1]; \
 _tp *_nm = _nm ## _tEmP + ((_al)/sizeof(_tp)-1); \
-_nm -= (((int32_t)_nm & ((_al)-1))/sizeof(_tp));
+_nm -= (((uintptr_t)_nm & ((_al)-1))/sizeof(_tp));
 
 /*
  * ENFORCE_STACK_ALIGN_2D: force 2 dimension local pData aligned in stack
@@ -90,7 +90,7 @@
 assert( ((_al) && !((_al) & ((_al) - 1))) && ((_al) >= sizeof(_tp)) ); /*_al should be power-of-2 and >= sizeof(_tp)*/\
 _tp _nm ## _tEmP[(_cx)*(_cy)+(_al)/sizeof(_tp)-1]; \
 _tp *_nm ## _tEmP_al = _nm ## _tEmP + ((_al)/sizeof(_tp)-1); \
-_nm ## _tEmP_al -= (((int32_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
+_nm ## _tEmP_al -= (((uintptr_t)_nm ## _tEmP_al & ((_al)-1))/sizeof(_tp)); \
 _tp (*_nm)[(_cy)] = (_tp (*)[(_cy)])_nm ## _tEmP_al;
 
 /*
--- a/codec/encoder/core/src/memory_align.cpp
+++ b/codec/encoder/core/src/memory_align.cpp
@@ -111,7 +111,7 @@
     return NULL;
 
   pAlignedBuffer = pBuf + kiAlignedBytes + kiSizeOfVoidPointer + kiSizeOfInt;
-  pAlignedBuffer -= ((int32_t) pAlignedBuffer & kiAlignedBytes);
+  pAlignedBuffer -= ((uintptr_t) pAlignedBuffer & kiAlignedBytes);
   * ((void**) (pAlignedBuffer - kiSizeOfVoidPointer)) = pBuf;
   * ((int32_t*) (pAlignedBuffer - (kiSizeOfVoidPointer + kiSizeOfInt))) = kiPayloadSize;